Skip to main content

How to use Java Loggin in a war?

Please note these java.net forums are being decommissioned and use the new and improved forums at https://community.oracle.com/community/java.
No replies
rsoika
Offline
Joined: 2006-12-09

Hi,
I can't figure out how to use a sepparat log file in a WAR or EAR to log only application specific messages into a application specific log file.
In my JSF Application I use a code like this to get a Logger instance:

 private static  Logger jlog = null;<span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"> </span>

final ClassLoader cl = WorkitemBean.class.getClassLoader();

     LogManager.getLogManager().readConfiguration(
        cl.getResourceAsStream(&quot;de.test.log.properties&quot;));<span class="Apple-tab-span" style="white-space:pre">  </span>

But it seams that the 'readConfiguration()' method resets the whole logging for my glassfish instance :-( So everything goes into the log file defined in my de.test.log.property file.
The property file looks like this

.level=INFO

de.test.level=ALL

# Console only INFO
java.util.logging.ConsoleHandler.level = INFO
# Log file settings
java.util.logging.FileHandler.level=ALL
java.util.logging.FileHandler.pattern =test.log
java.util.logging.FileHandler.limit = 50000
java.util.logging.FileHandler.count = 1
java.util.logging.FileHandler.formatter = java.util.logging.SimpleFormatter

Can anybody point me to an example how to write application specific log messages into a separat log file and leave all other messages form the other applications and the glassfish server into the console / server.log

Thanks for any help
Ralph