Hans
Hans

Reputation: 23

log4net You have tried to set a null level to root

I have a WPF application that uses Log4Net to log all kinds of information. The application runs fine and everything is logged as it should be. However, when scrolling trhough the Output window, I found following messages:

log4net:ERROR You have tried to set a null level to root. log4net:ERROR You have tried to set a null level to root. log4net.Core.LogException: Error in the application. log4net.Core.LogException: Error in the application.

Here's my config file:

<log4net>
    <appender name="RollingFileAppender" type="log4net.Appender.RollingFileAppender">
        <file value="c:\temp\logs\UtexbelAppLog.txt"></file>
        <appendToFile value="true"></appendToFile>
        <rollingStyle value="Size"></rollingStyle>
        <maximumFileSize value="1MB"></maximumFileSize>
        <maxSizeRollBackups value="5"></maxSizeRollBackups>
        <staticLogFileName value="true"></staticLogFileName>
        <layout type="log4net.Layout.PatternLayout">
        <conversionPattern value="%date{dd-MM-yyyy HH:mm:ss} %level - %message - %line%newline%exception"></conversionPattern>
        </layout>
    </appender>
    <root>
        <level value="WARNING"></level>
        <appender-ref ref="RollingFileAppender"></appender-ref>
    </root>
</log4net>

I have no idea why I'm getting these messages. Any help would be much appreciated.

Upvotes: 2

Views: 2407

Answers (2)

Sprint3rx
Sprint3rx

Reputation: 33

There is no <level value="WARNING"></level> it should be <level value="WARN"></level>

Upvotes: 2

Ludo.C
Ludo.C

Reputation: 75

Try to add this between your "root" quotes :

<logger name="LoggerName">
    <level value="WARN" />
    <appender-ref ref="RollingFileAppender" />
</logger>

Here is the available levels, in order of increasing priority :

  • ALL
  • DEBUG
  • INFO
  • WARN
  • ERROR
  • FATAL
  • OFF

More informations on this link, chapter "Loggers" : https://logging.apache.org/log4net/release/manual/configuration.html

Upvotes: 5

Related Questions