0

My java console is being bombarded with messages and I want to turn this off.

my code is

    List<Logger> loggers = Collections.<Logger>list(LogManager.getCurrentLoggers());
        loggers.add(LogManager.getLogger(<<something goes here>>));
        for (Logger logger : loggers) {
            logger.setLevel(Level.OFF);
        }

Is this code right, I don't know how to setup the alternative which is Log4j.properties.

Anyway the code will likely turn off all loggers, how do I turn off Log4j (i.e. quartz scheduler)

Any help??

Kevster
  • 35
  • 1
  • 1
  • 9
  • Seems like http://stackoverflow.com/questions/8169578/number-of-loggers-used, maybe you might try first? – HRgiger Mar 23 '17 at 00:42
  • I tried getRootLogger() but my application does not pick this up – Kevster Mar 23 '17 at 00:46
  • Soz this might defeat the purpose, I only want to turn off quartz scheduler log – Kevster Mar 23 '17 at 00:51
  • put log4j properties in classpath, i.e. check this example http://www.mkyong.com/logging/log4j-hello-world-example/ and this http://stackoverflow.com/questions/5297686/log4j-package-specific-logging you need something like "log4j.logger.org.quartz=OFF" – HRgiger Mar 23 '17 at 00:56
  • Ok giger, I make a log4j.properties in my project class path and I add log4j.logger.org.quartz=OFF is this correct? Just to clarify 1 line. – Kevster Mar 23 '17 at 01:01
  • No it should be something like MKyong example – HRgiger Mar 23 '17 at 01:04
  • At least rootLogger an stdout parts should be there then additionally you add ..org.quartz=off which means turn off all loggers under this package – HRgiger Mar 23 '17 at 01:05
  • OK I add log4j.logger.org.quartz=OFF in log4j.properties – Kevster Mar 23 '17 at 01:17
  • It says I do not have access to this file java.io.FileNotFoundException: C:\log4j-application.log (Access is denied) – Kevster Mar 23 '17 at 01:45
  • yes because file appender trying to create this log file in system, it is defined in your properties file, so what you can do is remove all the lines starting with "log4j.appender.file" and update root logger as log4j.rootLogger=DEBUG, stdout – HRgiger Mar 23 '17 at 02:12
  • I've taken out the log4j.appender.filefile and added log4j.logger.org.quartz=OFF but I'm still getting alot of print outs – Kevster Mar 23 '17 at 05:11

0 Answers0