How can one quickly turn off all Log4J output using a log4j.properties
file?
相关问题
- Delete Messages from a Topic in Apache Kafka
- Jackson Deserialization not calling deserialize on
- How to maintain order of key-value in DataFrame sa
- StackExchange API - Deserialize Date in JSON Respo
- Difference between Types.INTEGER and Types.NULL in
If you want to turn off logging programmatically then use
Set level to OFF (instead of DEBUG, INFO, ....)
In addition, it is also possible to turn logging off programmatically:
Or
You can change the level to OFF which should get rid of all logging. According to the log4j website, valid levels in order of importance are TRACE, DEBUG, INFO, WARN, ERROR, FATAL. There is one undocumented level called OFF which is a higher level than FATAL, and turns off all logging.
You can also create an extra root logger to log nothing (level OFF), so that you can switch root loggers easily. Here's a post to get you started on that.
You might also want to read the Log4J FAQ, because I think turning off all logging may not help. It will certainly not speed up your app that much, because logging code is executed anyway, up to the point where log4j decides that it doesn't need to log this entry.
Change level to what you want. (I am using Log4j2, version 2.6.2). This is simplest way, change to
<Root level="off">
For example: File
log4j2.xml
Development environment
Production environment