I'm having trouble finding my physical log files. I'm using the java.util.logging classes. I have a trivial sandbox class containing the following code:
package test;
import java.util.logging.Level;
import java.util.logging.Logger;
public class TestLogging {
public static void main(String[] args) {
@SuppressWarnings("unused")
TestLogging test = new TestLogging();
}
public TestLogging() {
System.out.println(getClass().getClassLoader().getResource("logging.properties"));
Logger logger = Logger.getLogger("test");
logger.logp(Level.CONFIG, "myClass", "myMethod", "Monday");
logger.logp(Level.FINE, "myClass", "myMethod", "Tuesday");
logger.logp(Level.FINER, "myClass", "myMethod", "Wednesday");
logger.logp(Level.FINEST, "myClass", "myMethod", "Thursday");
logger.logp(Level.INFO, "myClass", "myMethod", "Friday");
logger.logp(Level.SEVERE, "myClass", "myMethod", "Saturday");
logger.logp(Level.WARNING, "myClass", "myMethod", "Sunday");
}
}
My logging.properties file (again, stripped of comments) is:
handlers= java.util.logging.FileHandler, java.util.logging.ConsoleHandler
.level= ALL
java.util.logging.FileHandler.pattern = %h/java%u.log
java.util.logging.FileHandler.limit = 50000
java.util.logging.FileHandler.count = 1
java.util.logging.FileHandler.formatter = java.util.logging.XMLFormatter
java.util.logging.ConsoleHandler.level = INFO
java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter
x.y.level = SEVERE
x.y.z.level = WARNING
org.sscce.level = WARNING
org.sscce.baz3.level = INFO
The logging.properties file is in the classpath under User Entries in the Run Configuration for this class.
When I execute the class, I get this on the console:
file:/C:/Program%20Files/Java/jdk1.6.0_18/jre/lib/logging.properties
28-Feb-2012 2:05:55 PM myClass myMethod
INFO: Friday
28-Feb-2012 2:05:56 PM myClass myMethod
SEVERE: Saturday
28-Feb-2012 2:05:56 PM myClass myMethod
WARNING: Sunday
I asked for the logging level on the console to be INFO and that's all I have on the console so that part seems to be working. But when I look for my physical java logs in %h, which is C:\Documents and Settings[My Windows ID], there are no files that follow the pattern javaX.log where X is an integer.
What am I doing wrong? Is the program not seeing the logging.properties file? Or are the values set in some way to prevent any physical log from being written?
I need some help in debugging this because I can't see anything obviously wrong. Any takers?