Setting log format in logging.properties

I need some direction in setting the log format in Tomcat 7. I am relatively new to registration settings, so please excuse the humor for these questions if this seems a little basic ...

Using the standard log in Tomcat configured in logging.properties displays the log in the format:

Jun 6, 2011 9:27:00 AM com.class.Control_WS callWebService 
INFO: Response received from Control_WS:[Y]

I would like to configure these logs for single line compression, as well as for expanding the date format, including milliseconds.

Example:

[2011-05-04T11:37:00.037|INFO|javax.enterprise.system.stream.out|Response recieved from Control_WS:[Y]]

Can I do something with JUL or do I need to switch to LOG4J?

Any simple examples that can be provided or directed will be greatly appreciated.

+4
source share
2 answers

Java 7 ( :-)), java.util.logging (JUL). Java 7 java.util.logging.SimpleFormatter.format, , JUL SimpleFormatter . , SimpleFormatter ( ), .

:

  • Java 7.:-)
  • . JUL ( ), format, , .
+8

, , , Formatter, .properties formatter . , ConsoleHandler, :

java.util.logging.ConsoleHandler.formatter = com.mycompany.MyFormatter

( , ) - tomcat. , ${catalina.home}/lib/ext

+3

All Articles