1 Reply Latest reply on Sep 15, 2011 9:58 AM by Stephen Coy

    Log4j for each EJB

    Mitja Skuhala Newbie

      I want log for each aplication (EJB) in its own *.log file.   But all logs are in one file (web.log) ... the first time a called Logger log=Logger.getLogger(MyServlet.class) was in web.war where the property was set to web.log.


      The next time when i call getLoger(EJB1Service.class)...nothing changed.




          |-EJB1.jar  (log4j.xml)  to ejb1.log


          |-EJB2.jar  (log4.xml)   to ejb2.log

          |- WEB.war (log4j.xml)   to    web.log
          | - Lib (folder):


                     | -log4j.jar



      That looks like ma EAR file.


      Its this normal? or i'm dooing something wrong?

        • 1. Re: Log4j for each EJB
          Stephen Coy Master

          Hi there,


          Yes, this is quite normal. log4j will only load its configuration once, using the most immediate configuration file found in the classpath. Typically, this will be the one in the webapp as that would be the first one to see any activity.


          You can probably solve your problem by defining all of your appenders in the same log4j.xml file with different names and then point your loggers/categories at them as needed. Read the log4j doco http://logging.apache.org/log4j/1.2/manual.html for more information on this.




          Steve C