0

I try to configure logging programatically. I load the informations from a .properties-file. To configure the logger i call:

final Logger logger = Logger.getLogger(cat);
logger.setLevel(Level.ALL);
logger.log(Level.ALL,"Test");

It prints Test, so this part works. This is the stacktrace inside getLogger: Trace of create logger

Later, when the logger will get used, the level is INFO. Later use

It looks like there are different logger contexts. How to merge?

Grim
  • 1,938
  • 10
  • 56
  • 123
  • When you want to have just 1 logger, you could make it `static` and use it via that reference but usually you'd configure log settings more like http://stackoverflow.com/questions/6307648/change-global-setting-for-logger-instances – zapl May 26 '16 at 10:48
  • Statics are instanticated on classload, i like to configure before classload. – Grim May 26 '16 at 10:51
  • I don't know where the code in your example is but it won't execute before the class it's in gets loaded either – zapl May 26 '16 at 10:57
  • They are different classes, one class loads the configuration (called ConfigImpl.java) and the other class reference the static logger (freemarker.cache.TemplateCache). – Grim May 26 '16 at 11:08

1 Answers1

0

Ah! The Garbage-collector removes the logger meanwhile and drops the configured value.

Grim
  • 1,938
  • 10
  • 56
  • 123