Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disabling Log4J Output in Java

How can one quickly turn off all Log4J output using a log4j.properties file?

like image 377
cmcginty Avatar asked Feb 21 '09 02:02

cmcginty


2 Answers

Set level to OFF (instead of DEBUG, INFO, ....)

like image 188
Edwin Avatar answered Sep 23 '22 09:09

Edwin


If you want to turn off logging programmatically then use

List<Logger> loggers = Collections.<Logger>list(LogManager.getCurrentLoggers()); loggers.add(LogManager.getRootLogger()); for ( Logger logger : loggers ) {     logger.setLevel(Level.OFF); } 
like image 44
Andrew Gilmartin Avatar answered Sep 26 '22 09:09

Andrew Gilmartin