- Posted by: Eneko Gonzalez
- Posted on: March 22 2005 12:42 EST
I've two ears in a Weblogic server using java.util.logging (i'm not allowed to use anything else like Commons-Logging or Log4j) and i have a problem with the configuration of the logs of those ears.
In each ear I read a configuration file (named xxxlog.properties, being xxx the name of the app) to make the java.util.Logging System write the messages in a different file (xxx.log). To read those configuration files, i'm using the java.util.logging.LogManager.readConfiguration(inputStream) method.
Well, the problem is that when i only use one of the apps, everything goes ok, but when i use both apps, the log messages are wrotten in the incorrect output file.
Any idea of how to solve this? I'm not allowed to use only one configuration file for the whole server, and must have one output file for each ear in the server...
Thanks in advance.
---- Example configuration file (both are similar) ----
My guess is that you are invoking the LogManager every time you need to get handle to the logger class. Instead if you cache the Logger class once initially and keep using it, that wouldn't happen.
Hope it helps.
My guess is that you are invoking the LogManager every time you need to get handle to the logger class. Instead if you cache the Logger class once initially and keep using it, that wouldn't happen.Hope it helps.Rakesh.
I only invoke LogManager.readConfiguration once in each app. I think the problem is that this method calls java.util.Properties.load(inputStream), so the whole configuration is reloaded and I loose the older one because this second method overwrites the properties.
So the question is: how can i change mi configuration files son each app logs to a different file? My classes have different packages in each app, so can i do something like this?
The LogManager.readConfiguration reinitialize the logging for the JVM, by reseting the previous configuration( see the source code for LogManager() in jdk 1.4),all previous settings got loosed, so is not suitable for your problem, unfortunatelly java.util.logging does not provide a mechanism for your problem, the solution is to make your own properties file for log configuration and configure dynamically your loggers/handlers at startup.
I notice that it is possible to set different log level for
each handler, something like:
static Logger logger = Logger.getLogger(com.company_name);
Handler fh = new FileHandler(logFileName);