2 Replies Latest reply on Feb 6, 2006 12:08 PM by 807597

    Log4j: XML configuration file problem

    807597
      Hello,


      I set up some logging in my existing application with log4j and an xml configuration file. Now I made some changes to my package structure, and some problems occured. So I thougt of setting the logging level of one of my loggers (named myapp.iointerface.DBAccess in the config file). So the only change I did was adding a
      <param name="Level" value="TRACE"/>
      to my logger. Now, log4j complains when it reads the configruation file:
      log4j:WARN Continuable parsing error 36 and column 11
      log4j:WARN The content of element type "logger" must match "(level?,appender-ref*)".
      My config file:
      <?xml version="1.0" encoding="UTF-8"?> 
      <!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
      <log4j:configuration debug="false" xmlns:log4j="http://jakarta.apache.org/log4j/">
           
           <appender name="RootConsole" class="org.apache.log4j.ConsoleAppender">
                <param name="Threshold" value="DEBUG"/>
                <param name="Target" value="System.err"/>
                <layout class="org.apache.log4j.PatternLayout">
                     <param name="ConversionPattern" value="%d{dd MM yyyy HH:mm:ss} %p %C %nIn Zeile Nummer: %L %m %n%n"/>
                </layout>
           </appender>
           
           <appender name="LoginInfo" class="org.apache.log4j.FileAppender">
                <param name="Threshold" value="TRACE"/>
                <param name="File" value="${user.dir}/login_info.log"/>
                <layout class="org.apache.log4j.PatternLayout">
                     <param name="ConversionPattern" value="%d{dd MM yyyy HH:mm:ss} %p %C %nIn Zeile Nummer: %L %m %n%n"/>
                </layout>
           </appender>
                
           <appender name="DBConnectionInfo" class="org.apache.log4j.FileAppender">
                <param name="Threshold" value="TRACE"/>
                <param name="File" value="${user.dir}/db_connection.log"/>
                <layout class="org.apache.log4j.PatternLayout">
                     <param name="ConversionPattern" value="%d{dd MM yyyy HH:mm:ss} %p %C %n%m %n%n"/>
                </layout>
           </appender>
           
           <logger name="myapp.windows.MainFrameController" additivity="false">
                <appender-ref ref="LoginInfo"/>
           </logger>
           
           <logger name="myapp.iointerface.DBAccess" additivity="false">
                <param name="Level" value="TRACE"/>
                <appender-ref ref="DBConnectionInfo"/>
           </logger>
           
           <root>
                <param name="Level" value="DEBUG"/>
                <appender-ref ref="RootConsole"/>
           </root>
           
      </log4j:configuration>
      Does anybody know what's wrong with that? I don't understand and found nothing googling it netiher. The strange thing is, that logging messages with level TRACE are recorded in the destination file, but the level id DEBUG.

      Thx,

      Julien