Java Logging API Strange behaviour

Similar to the problem of :

http://forum.java.sun.com/thread.jspa?forumID=31&threadID=746125

I have the following problem:

I have the following class

package my.test;

publicclass TestLogging{

static Logger log=Logger.getLogger( TestLogging.class.getPackage().getName());

publicstatic loadAndLog(){

log.info("Loading logging configuration");

try{

// load logging configuration

InputStream logConfig=getResourceAsStream("/WEB-INF/logging.conf");

if(logConfig==null){

log.info("Log config file could not be found");

}else{

LogManager.getLogManager().readConfiguration(logConfig);

log.info("Logging configuration loaded");

}

}catch(IOException ioe){

ioe.printStackTrace();

log.warning("Logging configuration loading failed");

System.out.println("Logging loaded failed");

}

}

}

The file logging.conf contains the following settings

# defaults

handlers=java.util.logging.ConsoleHandler, java.util.logging.FileHandler

.level=FINE

# Handlers settings

java.util.logging.ConsoleHandler.level=FINE

java.util.logging.ConsoleHandler.formatter=java.util.logging.SimpleFormatter

java.util.logging.FileHandler.level=FINE

# custom loggers settings

my.test.level=FINE

Now running the static method gives me this output:

INFO: Loading logging configuration

But i expect this output:

INFO: Loading logging configuration

INFO: Logging configuration loaded

What am i doing wrong?

I have read the Java Logging API OVerview and Javadoc,

i don't knwo what is going wrong.

My real program has a lot more loggers and the configration

file is loaded in the begin of the program.. But then none of the loggers

output anything! But all levels are set on FINE.

WTF

[2827 byte] By [tjerkwa] at [2007-11-27 4:36:45]
# 1
Anybody? im really stuck here
tjerkwa at 2007-7-12 9:46:55 > top of Java-index,Java Essentials,Java Programming...
# 2

Yess! I think i have found an article that will help me solve it:

http://www.crazysquirrel.com/computing/java/logging.jspx

In short: Im using Tomcat with Java Logging API.. But the java

logging api has no way to seperate configuration of loggers for each

web application. Configuration can only be done on VM level.

So Tomcat has some tweaks and its own configuration file.

Anyway it is strange that no exception is thrown whenever i load my own configuration file. Strange...

I am printing the article now and i will read it.. When i have solved it i will post it here.

tjerkwa at 2007-7-12 9:46:55 > top of Java-index,Java Essentials,Java Programming...
# 3

I suggest you use log4j as a logging library. This will fix the problem you're having with various logging configurations on different web applications.

Since you're already familiar with the Java API's logging, you should catch up pretty fast with log4j.

http://logging.apache.org/log4j/docs/index.html

Dalzhima at 2007-7-12 9:46:55 > top of Java-index,Java Essentials,Java Programming...
# 4
Mmm yes i was thinking of that.. The Java Logging API is really missing some features.. and the loading of the configuration files is also really a mess. Too bad.
tjerkwa at 2007-7-12 9:46:55 > top of Java-index,Java Essentials,Java Programming...