You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-user@logging.apache.org by Ke...@barclayscapital.com on 2010/11/03 16:55:29 UTC

Extra RollingFileAppender with NLOG4j

I'm trying to get the RollingFileAppender from the extra log4j companion file working but I'm having problems configuring the appender.  I am using this with the most current version of NLOG4J

The following is my config file:

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

<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
    <appender name="console" class="org.apache.log4j.ConsoleAppender">
        <param name="Target" value="System.out"/>
        <layout class="org.apache.log4j.PatternLayout">
            <param name="ConversionPattern" value="%-5p %c{1} - %m%n"/>
        </layout>
    </appender>

    <appender name="logFileAppender" class="org.apache.log4j.rolling.RollingFileAppender">
        <rollingPolicy class="org.apache.log4j.rolling.TimeBasedRollingPolicy">
            <param name="FileNamePattern" value="/log/metrics.%d{yyyy-MM-dd-HH}.log" />
        </rollingPolicy>
        <layout class="org.apache.log4j.PatternLayout">
            <param name="ConversionPattern" value="%m%n" />
        </layout>
    </appender>

    <!--         -->
    <!-- Loggers -->
    <!--         -->
    <logger name="com.barcap.eq.common.metric.LoggingMetric" additivity="false">
        <level value="INFO" />
        <appender-ref ref="console" />
        <appender-ref ref="logFileAppender" />
    </logger>

    <root>
        <priority value ="debug" />
        <appender-ref ref="console" />
    </root>

</log4j:configuration>


At startup, I get the following errors:
log4j:ERROR Element type "rollingPolicy" must be declared.
log4j:ERROR The content of element type "appender" must match "(errorHandler?,param*,layout?,filter*,appender-ref*)".

If I attempt to write to the appender, I then get:
log4j:WARN Please set a rolling policy for the RollingFileAppender named 'logFileAppender'
log4j:ERROR No output stream or file set for the appender named [logFileAppender].

I think the issue is that the rollingPolicy element isn't defined in log4j.dtd but I'm not sure how to proceed with this.  Is NLOG4J not compatible with the companion jar?

Thanks.

_______________________________________________

This e-mail may contain information that is confidential, privileged or otherwise protected from disclosure. If you are not an intended recipient of this e-mail, do not duplicate or redistribute it by any means. Please delete it and any attachments and notify the sender that you have received it in error. Unless specifically indicated, this e-mail is not an offer to buy or sell or a solicitation to buy or sell any securities, investment products or other financial product or service, an official confirmation of any transaction, or an official statement of Barclays. Any views or opinions presented are solely those of the author and do not necessarily represent those of Barclays. This e-mail is subject to terms available at the following link: www.barcap.com/emaildisclaimer. By messaging with Barclays you consent to the foregoing.  Barclays Capital is the investment banking division of Barclays Bank PLC, a company registered in England (number 1026167) with its registered office at 1 Churchill Place, London, E14 5HP.  This email may relate to or be sent from other members of the Barclays Group.
_______________________________________________

Re: Extra RollingFileAppender with NLOG4j

Posted by Curt Arnold <ca...@apache.org>.
Comments in-line


On Nov 3, 2010, at 10:55 AM, <Ke...@barclayscapital.com> <Ke...@barclayscapital.com> wrote:
> At startup, I get the following errors:
> log4j:ERROR Element type "rollingPolicy" must be declared.

This also occurs with earlier versions of Apache log4j and is due to the lack of a definition of rollingPolicy in the log4j.dtd.  The lack of a definition in the log4j.dtd results in a failed XML validation, but noting more.  Reporting it as an error is overstating the significance of a validation failure.

> log4j:ERROR The content of element type "appender" must match "(errorHandler?,param*,layout?,filter*,appender-ref*)"

The log4j.dtd specifies that elements in a configuration file appear in a specified order.  log4j's DOMConfiguration isn't as picky.  This warning can be eliminated by ordering the contents of an appender element as shown in the warning.

> .
> 
> If I attempt to write to the appender, I then get:
> log4j:WARN Please set a rolling policy for the RollingFileAppender named 'logFileAppender'
> log4j:ERROR No output stream or file set for the appender named [logFileAppender].

This could be due either to a bad configuration file or some mismatch between NLOJ4J and the appender.

> 
> I think the issue is that the rollingPolicy element isn't defined in log4j.dtd

That results in an misleading warning, but would not result in a failure to configure.


> but I'm not sure how to proceed with this.  Is NLOG4J not compatible with the companion jar?
> 

As mentioned, NLOG4J is a fork of Apache log4j and is not supported here.  If the configuration file works with Apache log4j, then you could try configuring with the org.apache.log4j.extras.DOMConfigurator which may or may not work with NLOG4J.



---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org


Re: Extra RollingFileAppender with NLOG4j

Posted by Jacob Kjome <ho...@visi.com>.
NLog4j is not an Apache Logging project.  It's a fork of Log4j hosted outside 
of Apache Logging.  Please try with an official Log4j version and respond back 
if you run into issues.

Jake


On Wed, 3 Nov 2010 11:55:29 -0400
  <Ke...@barclayscapital.com> wrote:
> I'm trying to get the RollingFileAppender from the extra log4j companion 
>file working but I'm having problems configuring the appender.  I am using 
>this with the most current version of NLOG4J
> 
> The following is my config file:
> 
> <?xml version="1.0" encoding="UTF-8" ?>
> <!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
> 
> <log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
>    <appender name="console" class="org.apache.log4j.ConsoleAppender">
>        <param name="Target" value="System.out"/>
>        <layout class="org.apache.log4j.PatternLayout">
>            <param name="ConversionPattern" value="%-5p %c{1} - %m%n"/>
>        </layout>
>    </appender>
> 
>    <appender name="logFileAppender" 
>class="org.apache.log4j.rolling.RollingFileAppender">
>        <rollingPolicy 
>class="org.apache.log4j.rolling.TimeBasedRollingPolicy">
>            <param name="FileNamePattern" 
>value="/log/metrics.%d{yyyy-MM-dd-HH}.log" />
>        </rollingPolicy>
>        <layout class="org.apache.log4j.PatternLayout">
>            <param name="ConversionPattern" value="%m%n" />
>        </layout>
>    </appender>
> 
>    <!--         -->
>    <!-- Loggers -->
>    <!--         -->
>    <logger name="com.barcap.eq.common.metric.LoggingMetric" 
>additivity="false">
>        <level value="INFO" />
>        <appender-ref ref="console" />
>        <appender-ref ref="logFileAppender" />
>    </logger>
> 
>    <root>
>        <priority value ="debug" />
>        <appender-ref ref="console" />
>    </root>
> 
> </log4j:configuration>
> 
> 
> At startup, I get the following errors:
> log4j:ERROR Element type "rollingPolicy" must be declared.
> log4j:ERROR The content of element type "appender" must match 
>"(errorHandler?,param*,layout?,filter*,appender-ref*)".
> 
> If I attempt to write to the appender, I then get:
> log4j:WARN Please set a rolling policy for the RollingFileAppender named 
>'logFileAppender'
> log4j:ERROR No output stream or file set for the appender named 
>[logFileAppender].
> 
> I think the issue is that the rollingPolicy element isn't defined in 
>log4j.dtd but I'm not sure how to proceed with this.  Is NLOG4J not 
>compatible with the companion jar?
> 
> Thanks.
> 
> _______________________________________________
> 
> This e-mail may contain information that is confidential, privileged or 
>otherwise protected from disclosure. If you are not an intended recipient of 
>this e-mail, do not duplicate or redistribute it by any means. Please delete 
>it and any attachments and notify the sender that you have received it in 
>error. Unless specifically indicated, this e-mail is not an offer to buy or 
>sell or a solicitation to buy or sell any securities, investment products or 
>other financial product or service, an official confirmation of any 
>transaction, or an official statement of Barclays. Any views or opinions 
>presented are solely those of the author and do not necessarily represent 
>those of Barclays. This e-mail is subject to terms available at the following 
>link: www.barcap.com/emaildisclaimer. By messaging with Barclays you consent 
>to the foregoing.  Barclays Capital is the investment banking division of 
>Barclays Bank PLC, a company registered in England (number 1026167) with its 
>registered office at 1 Churchill Place, London, E14 5HP.  This email may 
>relate to or be sent from other members of the Barclays Group.
> _______________________________________________


---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org