get underlying log4 logger from commons logger

/ Published in: Java
Save to your folder(s)

This snippet shows how to get access to the underlying log4j logger when using apache commons logging.

Copy this code and paste it in your HTML
  1. if(logger instanceof Log4JLogger)
  2. {
  3. Log4JLogger log4j = (Log4JLogger)logger;
  4. Logger underlyingLogger = log4j.getLogger();
  5. underlyingLogger.setLevel(Level.INFO);
  6. underlyingLogger.addAppender(new ConsoleAppender(
  7. new PatternLayout("%-5p [%t]: %m%n")));
  8. }

Report this snippet


RSS Icon Subscribe to comments

You need to login to post a comment.