I'm using java system logging in tomcat 7, but no logging statements get written to the log. I've added this file to my WEB-INF/classes. The log file "new-xyz-test" gets created (so I have at least some of the config right) but its empty - no log statements get printed to it.
handlers=java.util.logging.ConsoleHandler, org.apache.juli.FileHandler
org.apache.juli.FileHandler.level=ALL
org.apache.juli.FileHandler.directory=${catalina.base}/logs
org.apache.juli.FileHandler.prefix=new-xyz-test-
java.util.logging.ConsoleHandler.level=ALL
java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter
com.xyz.level=ALL
com.xyz.handlers=org.apache.juli.FileHandler
To configure JULI in the web applications you need have a
logging.properties
file in theWEB-INF/classes
directory. If you use the default handlers, you may lose messages. You need to specify a prefix for the handler in your file.A handler prefix (e.g.
1FILE.
) starts with a number, then has an arbitrary string, and ends with a period (.).Arguments in the JVM
If you are not running the Tomcat from the
startup.sh
orstartup.bat
, you need to specify:logging.properties
for Tomcat (in theconf
directory of Tomcat)org.apache.juli.ClassLoaderLogManager
. This is important because allows you to configure for each web application different loggin options. By default, a JVM process can only have a single configuration file.) ,Similar to the next (I'm using eclipse):
By default,
java.util.logging
read the file that is included in the JDK or JRE, e.g.:are you sure that you write to the correct logger , i.e.
Logger.getLogger("com.xyz")
?I think that you may got wrong when you wrote in logging.properties:
com.xyz.level=ALL com.xyz.handlers=org.apache.juli.FileHandler
in the case that you actually write to the loggerLogger.getLogger(com.xyz.YourClass.class)
, that because in the logging properties file you should write the logger name which is in your casecom.xyz.YourClass