2

I want to change the levels of the loggers that have been set in my logback.xml file . I can make the change manually but i want to accomplish by writing a piece of code. I am dense about this stuff and this is the first time i am working on logging . Any help on this front or on log4j or any such pointers will be helpful.

Rags
  • 434
  • 2
  • 6
  • 20

1 Answers1

3

You can set logging level in your program as:

Logger root = (Logger)LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME);
root.setLevel(Level.INFO);

Check the logback manual
Hope that helps!

Anshu
  • 7,783
  • 5
  • 31
  • 41
  • I am going this in scala so It goes like this val MyLogger = LoggerFactor.getLogger("logger name") MyLogger.setLevel(LEVEL.INFO) – Rags Sep 29 '12 at 22:43
  • 1
    @Rags Did that scala code worked for you? I have no setter `setLevel` for that... – Cristian Boariu Feb 18 '13 at 21:12