简体   繁体   中英

Log4j1.x migration to log4j2 java

I have upgraded log4j1.x version to log4j2.17, I observed that some of new logs are printing on my console/server.log which might be from other jars I am using (eg updating server status in database)

How can I restrict stdout in my console or server.log

I have added console appender in my log4j2.xml

While this looks like a bad idea - you would want important logs from dependencies to be a part of your log for debugging issues, here is the way to do it.

In log4j.properties file, you can set the root logger to ERROR. Then for the your own application, you can override the now default ERROR to INFO/DEBUG.

log4j.rootLogger=ERROR, stdout
log4j.X.Y.Z=DEBUG

Ref - Filtering out log4j messages from third-party frameworks?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM