views:

59

answers:

2

I wrote a Formatter (test.MyFormatter) by extending the class java.util.logging.Formatter;

Now I want to use test.MyFormatter instead of java.util.logging.SimpleFormatter:

in the configuration file i replaced the entry:

java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter

with

java.util.logging.ConsoleHandler.formatter = test.MyFormatter

unfortunately this is not working.

can somebody explain me, if what I am doing is:

  1. correct
  2. if yes, why it not working?
+1  A: 

According to the javadoc your configuration is correct.

If it is not working double check that

  1. test.MyFormatter is in your class path
  2. Check that you don't accidentally use Log4J or Commons-logging.
  3. Check that your configuration is loaded.
  4. Check that your MyFormatter has public constructor without parameters.
uthark
A: 

You have to override the default configuration using the LogManager class. Something like this:

LogManager.getLogManager().readConfiguration(
      getClass().getResourceAsStream("path/to/logging.xml");
IgKh