3

I have the following logging.properties file which is located in WEB-INF/classes

handlers = 1myapp.org.apache.juli.FileHandler, java.util.logging.ConsoleHandler
.handlers = 1myapp.org.apache.juli.FileHandler, java.util.logging.ConsoleHandler

1myapp.org.apache.juli.FileHandler.level = FINE
1myapp.org.apache.juli.FileHandler.directory = ${catalina.base}/logs
1myapp.org.apache.juli.FileHandler.prefix = myapp.
1myapp.org.apache.juli.FileHandler.formatter = java.util.logging.SimpleFormatter
1myapp.java.util.logging.SimpleFormatter.format="%5$s%n"

java.util.logging.ConsoleHandler.level = FINE
java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter
java.util.logging.SimpleFormatter.format="%5$s%n"

The log file "myapp.date.log" is created correctly. So, the configurations seems to work so far. The entries in the log should contain only the log message. But instead the default format is used.

What´s wrong? It´s very hard to find a realy good tutorial about configuring the logging.

Franz Deschler
  • 2,456
  • 5
  • 25
  • 39
  • Your question is similar to http://stackoverflow.com/a/14690747 Try to set `java.util.logging.SimpleFormatter.format` in system property. – Beck Yang Jul 10 '16 at 14:34
  • I´m using Tomcat 8. So the bug should be fixed. But even setting the system property doesn´t work. – Franz Deschler Jul 10 '16 at 15:15

1 Answers1

0

As a first workaround, I created a custom formatter and set it in the configuration:

1myapp.org.apache.juli.FileHandler.formatter = myapp.server.logging.CustomLogFormatter

But this does not work for the ConsoleHandler.

Franz Deschler
  • 2,456
  • 5
  • 25
  • 39