Log4j error messages and their meanings

Ceki Gülcü
November 2004, last updated on December 17th, 2004


Message: The 'log4j.dtd' is no longer used nor needed.

Given syntactical flexiblilty that JoranConfigrator supports, it is no longer possible to express this syntatical range with a DTD. Thus, new log4j configuration files in XML should follow the general template.

Good:

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE configuration>

<configuration xmlns='http://logging.apache.org/'>
  ...
</configuration>
        

However, JoranConfigurator will continue to parse your old XML configuration files which previously required a reference to log4j.dtd. Thus, altough deprecated, the following form will continue to be parsed correctly.

Deprecated:

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">

<log4j:configuration xmlns:log4j='http://jakarta.apache.org/log4j/'>
  ...
</log4j:configuration>
        

Using this deprecated form will generate the above mentioned error message along with an error from the XML parser.

Message: The FileNamePattern option must be set before using TimeBasedRollingPolicy or FixedWindowRollingPolicy.

The FileNamePattern option for both TimeBasedRollingPolicy and FixedWindowRollingPolicy is mandatory.

Message: Could not find an appender named [XYZ]. Did you define it below in the config file?

Whereas the order of declatation of appenders did not matter in log4j 1.2, in log4j version 1.3 and later, any appender referenced at a given point must have been already declared above that point. In practice though, only configuration files declaring an AsyncAppender may be affected by this change and only if the appenders embeded in th AsyncAppender are declared below it instead of being declared above it.

For example, the following config file will no longer work.

Bad:

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE log4j:configuration>

<log4j:configuration xmlns:log4j='http://jakarta.apache.org/log4j/'>

  <appender name="ASYNC" class="org.apache.log4j.AsyncAppender">
    <appender-ref ref="FILE" />
  </appender>

   <appender name="FILE" class="org.apache.log4j.FileAppender">
    <param name="File" value="myapp.log"/>
    ...
  </appender>

  <root>
    <level value ="debug" />
    <appender-ref ref="ASYNC" />
  </root>

</log4j:configuration>
        

It should be changed to the following form.

Good:

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE configuration>

<configuration xmlns='http://logging.apache.org/'>

   <appender name="FILE" class="org.apache.log4j.FileAppender">
     <param name="File" value="myapp.log"/>
      ...
   </appender>

  <appender name="ASYNC" class="org.apache.log4j.AsyncAppender">
    <appender-ref ref="FILE" />
  </appender>

  <root>
    <level value ="debug" />
    <appender-ref ref="ASYNC" />
  </root>
</configuration>
        
Copyright © 1999-2005, Apache Software Foundation