0

related:

How to change slf4j level at runtime? SLF4J debugging level configuration + Logging framework integration Set Dynamic Console Logging Level Using SLF4J Setting log level of message at runtime in slf4j How to dynamically change log level in SLF4j OR Log4J

is it possible to do this easily?

edit: looks like you can't do that. one must fool around with the underlying implementation. i am using the simple jar.

thanks

Community
  • 1
  • 1
Ray Tayek
  • 9,841
  • 8
  • 50
  • 90
  • Do you want to change the level for the current running application or do you want to persist the change also for the next application start? Is it a desktop application or does it run inside an application server? – SubOptimal Mar 02 '15 at 07:43
  • "Easily" is subjective -- in what way are all those answers you cited not "easy"? – Stephen P Mar 02 '15 at 07:48
  • just wanted to change it programmaticaly at run time. none of the answers to the other questions let me do it easily without a lot of trouble. – Ray Tayek Mar 02 '15 at 16:12

2 Answers2

0

I do it this way, but there are others:

 String tmpName = "newLogConfig.xml"
    try (InputStream defaultIs = Log4jReconfigurator.class.getResourceAsStream()) {
      logger.warn("Using log4j configuration " + tmpName);
      new DOMConfigurator().doConfigure(is, LogManager.getLoggerRepository());
    } catch (IOException e) {
      logger.error("Failed to reconfigure log configuration", e);
    }

I provide predefined logging templates, and this allows you to load them at runtime.

ISparkes
  • 1,695
  • 15
  • 15
0

You cant configure SLF4J, you need to configure the concrete logging framework SLF4J is configured to work with.

Evgeniy Dorofeev
  • 133,369
  • 30
  • 199
  • 275