1

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
  • Define "not working". Are you getting an exception? If so, what is it? Or is your Formatter ignored? Commented Feb 6, 2010 at 13:10

2 Answers 2

1

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.
Sign up to request clarification or add additional context in comments.

Comments

0

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

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.