4 Replies Latest reply on Sep 10, 2007 3:00 AM by changemylife

    Warning when use log4j

    changemylife

      Hi all!
      I begginer with Log4j, and I have a problem that I need help:
      I use:

      jboss-4.0.5.GA, EJB3.0

      I have a bean (called RecordBean):
      ...
      private static final Logger myLogger = Logger.getLogger(RecordBean.class);

      public void add(int num1, int num2) {
      myLogger.info("Perform the adding two numbers...");
      ...
      }

      And inside
      \server\default\conf
      , I edit file log4j.xml (add my definition):
      <appender name="XXX" class="org.apache.log4j.FileAppender">
       <param name="File" value="${jboss.server.log.dir}/mylog.log"/>
       <param name="Threshold" value="INFO"/>
       <layout class="org.apache.log4j.PatternLayout">
       <param name="ConversionPattern" value="%d %-5p [%c] %m%n"/>
       </layout>
       </appender>
      .....
       <logger name="bean.log">
       <appender-ref ref="QT"/>
       </logger>
      
       <root>
       <appender-ref ref="CONSOLE"/>
       <appender-ref ref="FILE"/>
       </root>

      But when I deploy RecordBean, and my client call add method, logging ok, but I receive some Warning:
      log4j:WARN No appenders could be found for logger (org.jboss.security.SecurityAssociation).
      log4j:WARN Please initialize the log4j system properly.

      I imported log4j.jar.
      Please help me to solve this problem.


        • 1. Re: Warning when use log4j
          peterj

          The warning you are getting, is it on the client or on the server? I am assuming client (that is where I usually get this error). This means that either the client itself, or one of the libraries it is using, does logging, but not logging configuration (whether properties or xml) was found. You can either ignore the warning message (I usually do), or supply a simple log4j.properties file for the client's use.

          • 2. Re: Warning when use log4j
            changemylife

            Hi all!
            Some warning that I received from client. But has a problem that I understand. If my client is EJB project, I will receive this warning. But if my client app is Java project, I not receive some warning!

            • 3. Re: Warning when use log4j
              peterj

              That makes perfect sense.

              You need to satisfy three conditions to get this warning:

              1) No log4j.properties or log5j.xml file
              2) The lag4j.jar file in your classpath
              3) Invoke a method that tried to log something

              Apparently, when your client calls an EJB, all three conditions are satisfied. For other clients, one or more of these conditions is not satisfied (probably not methods are doing logging).

              • 4. Re: Warning when use log4j
                changemylife

                Hi all !
                Thanks about your guides. I solved my problems.