5 Replies Latest reply on May 1, 2008 2:01 PM by peterj

    using commons logging with Log4jService

    erezharari

      jboss use log4j throughLog4jService.
      how can i use commons logging with the service Log4jService?

      i wrote a test with common logging.
      configured a logger and an appender in jboss-log4l.xml.
      put commons-logging.properties in a jar under server/default/lib with content:
      org.apache.commons.logging.Log=org.apache.commons.logging.impl.Log4JLogger

      then, when i log to the logger i get a message:
      log4j:WARN No appenders could be found for logger (erez).

      am i missing anything?
      is there a known issue of commons logging and jboss?

        • 1. Re: using commons logging with Log4jService
          peterj

          What type of application are you trying to log? EJB? Servlet? Portlet?

          Please post the changes you made to jboss-log4j.xml. Be sure to enclose the text in code brackets and preview your post (to check the formatting) before submitting it.

          (Also, if you are not attmepting to do logging from a portlet then you placed this question in the wrong forum.)

          • 2. Re: using commons logging with Log4jService
            erezharari

            Well, it was just a primilinary test using a jsp page that would eventually be used within a portlet.

            in log4j.xml i added:

            <appender name="erez_" class="org.apache.log4j.RollingFileAppender">
             <param name="Threshold" value="debug"/>
             <param name="File" value="${jboss.home}/erez.log"/>
             <param name="MaxFileSize" value="100KB"/>
            </appender>
            <logger name="erez" additivity="true">
             <level value="debug"/>
             <appender-ref ref="erez_"/>
            </logger>
            


            the file erez.log is indeed created, but no logs are written into it..

            • 3. Re: using commons logging with Log4jService
              peterj

              Your logger name is "erez". Only loggers that are named erez, or are children of erez, will be logged to that log file.

              What is the name of the logger you are using in the JSP?

              • 4. Re: using commons logging with Log4jService
                erezharari

                indeed 'erez' with error level

                • 5. Re: using commons logging with Log4jService
                  peterj

                  I compared your log setting with one that I have. The thing that is different is the < logger > entry - I don't have one. Instead I have a < category > entry. Unfortunately, I don't have my Log4J book with me so I cannot verify the validity of the < logger > entry. Try replacing it with:

                  <category name="erez">
                   <priority value="DEBUG"/>
                   <appender-ref ref="erez_" />
                   </category>