0

I have create the following code in java :

LogManager manager = LogManager.getLogManager();
String className = this.getClass().getName();
String level = manager.getProperty(className + ".filter");

nevertheless, the variable is null after the call to getProperty, but className has the name : "view.frame.WindowHandler"

Any ideas ? Thank you very much

Shotgun Ninja
  • 2,540
  • 3
  • 26
  • 32
onda47
  • 615
  • 2
  • 6
  • 21
  • 1
    Your code says `".filter"`, shouldn't it say `".level"`? [This doc](http://docs.oracle.com/javase/7/docs/api/java/util/logging/LogManager.html) seems to indicate that the log level should be in the `{loggerName}.level` property. – Shotgun Ninja May 20 '15 at 21:14
  • me I see that : "A property config.... such as setting logger levels, adding handlers, adding filters, etc" I took the code from this url : (http://www.java2s.com/Code/Java/Language-Basics/WindowHandlerdisplaylogmessageinawindowJFrame.htm) – onda47 May 20 '15 at 21:28
  • 1
    Yeah, the code on the Java2S page uses `".level"` too. Is this a typo on your part? – Shotgun Ninja May 21 '15 at 14:35
  • Also, are you sure you've added the filter or the level to the logger? Either via `Logger#setLevel()` or `Logger#setFilter()`, or (in the case of the level) from the configuration file? – Shotgun Ninja May 22 '15 at 17:38
  • Sorry I made a mistake on the link, that is the good link : http://www.java2s.com/Code/Java/Language-Basics/JavalogLogandWindowJFrameframe.htm – onda47 May 23 '15 at 11:17

1 Answers1

0

You have to define an entry that is loaded by the LogManager configuration. The default logging configuration file located in lib/logging.properties in the JRE directory. Add the following entries to the logging.properties file:

#WindowHandler settings
view.frame.WindowHandler.level = INFO
view.frame.WindowHandler.filter = some.filter.class.Name

You should create your own logging.properties file and set the java.util.logging.config.file system property to configure the LogManager for your application.

jmehrens
  • 10,580
  • 1
  • 38
  • 47