users@glassfish.java.net

Glassfish + log4j + multiple log4j.xml

From: <glassfish_at_javadesktop.org>
Date: Wed, 13 Jan 2010 05:20:33 PST

Hi all!
Situation:
    Application Server: Glassfish v.2.1
    OS: Windows XP
    Number of application in domain: 3 independent applications
    Each application contains ejb and web module.

Task: to organize logging policy:each application has its own log-file.

Internet "tells" me a solution (on server side):
1) place log4j.jar into .../domains/domain1/lib
2) for each application create its own log4j.xml (configuration file) and place it in WEB-INF/classes folder
3) restart the server

How I did it:

1) clear
2) xml for first application (named 'fsvps')

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
<log4j:configuration>
   <appender name="fileLogger" class="org.apache.log4j.RollingFileAppender">
      <param name="File" value="../logs/fsvps.log" />
      <param name="encoding" value="UTF-8" />
      <param name="MaxFileSize" value="2000KB"/>
      <param name="MaxBackupIndex" value="10"/>
      <param name="Append" value="true" />
      <layout class="org.apache.log4j.PatternLayout">
          <param name="ConversionPattern" value="%p %t %c - %m%n"/>
      </layout>
   </appender>
   <logger name="fsvps" additivity="false">
      <level value="trace"/>
      <appender-ref ref="fileLogger"/>
   </logger>
   <root>
      <level value ="trace"/>
      <appender-ref ref="fileLogger"/>
   </root>
</log4j:configuration>

for other applications xml is the same but I changed fsvps.log to fsvps-rpt.log and fsvps-losts.log accordingly and I changed name of logger to fsvps-rpt and fsvps-losts accordingly.

Note:First application uses freemarker
        Other 2 (fsvps-rpt, fsvps-losts) dont't use freemarker

3) When I restart the server and go to the log directory I find the fsvps.log file (as I expect). From Freemarker manual:

"FreeMarker integrates with the following logging packages: Log4J, Avalon LogKit, and java.util.logging (Java2 platform 1.4 and above). You need not do anything in order for FreeMarker to use these loggers; if any of them is discovered through the class loader that loaded FreeMarker classes, it is used automatically. All log messages produced by FreeMarker are logged into the logger hierarchy whose top-level logger is named freemarker."

But I can't find other 2 files in the same directory. And in the server.log I find:

[#|2010-01-13T16:06:15.859+0300|INFO|sun-appserver2.1|org.apache.catalina.loader.WebappLoader|_ThreadID=15;_ThreadName=pool-1-thread-2;|Unknown loader Application library chain for fsvps-rpt parentCL :: EJBClassLoader :
urlSet = []
doneCalled = false
 Parent -> java.net.URLClassLoader_at_137d4a4
 constituent CLs ::
 :: null :: optionalChain
 class com.sun.appserv.server.util.ClassLoaderChain|#]

Next. If I undeploy fsvps and restart server I find again 1 file - fsvps-losts.log or fsvps-rpt.log, depending on what application I addressed to first.

How can I resolve my problem and achieve the main goal? I've been skirmishing for solution more than 2 days (
[Message sent by forum member 'arttaras' (arttaras_at_mail.ru)]

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