users@glassfish.java.net

Re: Logging Question

From: <glassfish_at_javadesktop.org>
Date: Thu, 31 May 2007 11:43:26 PDT

I think I may understand your problem.

But lets be clear.

If you want to redirect certain parts of the Glassfish App Server logging to different files, I don't know if that is possible. I should say, I don't think that such configuration is exposed through the domain.xml. Specifically, say you wanted to route all of the Persistence based logging through to a separate file, I do not think that you can do that at all.

If you want to route specific bits of logging for your APPLICATION, then that's a different issue. That's certainly possible.

In that case you need to configure your Loggers and Handlers yourself from within your application. That is straightforward and there are simple examples in the java.util.logging docs (notably http://java.sun.com/j2se/1.4.2/docs/guide/util/logging/overview.html).

However, if you want to configure your handlers using the stock java.util.logging Properties file, I think you're out of luck.

It appears that the handlers used there are "global" in scope and available for "everything". There doesn't appear to be the facility of creating a specific File Handler (or any handler for that matter) and apply it to a specific Logger via the standard properties mechanism. Log4j can certainly do this, but it doesn't appear that Java's can out of the box.

The configurability is available within the classes. You can simply assign any Handler you like directly to a Logger object, and happy day. But the default properties file and reader via the LogManager does not appear to support that kind of flexibility.

A mark against java.util.logging, but not a showstopper I don't think.

But to be fair, it does bring up the issues of LogManagers, classloaders, etc.

For example, do the WAR and EJB tiers have different LogManagers? Do they all share a global LogManager? Do they share the one with Glassfish itself? If I have 2 WARs both using the same library (which would be using Loggers of the same name), if I set one to INFO and the other to WARNING, which one wins?

Just the proverbial problems you have when dealing with ostensibly Singleton-esque system utility classes in an class loader "rich" environment like an Appserver. Experiments may be necessary to figure out what needs to be done, and you may simply have to have a Servlet startup method call an EJB method in order to ensure that your Logging configuration is done properly in the right places.

I'm going to play with this, though. While we've been just doing pretty basic logging, it would be good to better understand this relationship.
[Message sent by forum member 'whartung' (whartung)]

http://forums.java.net/jive/thread.jspa?messageID=219781