简体   繁体   中英

Warn level not show log4net

i have the folloging XML to log4net

  <configSections>
    <section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" />
  </configSections>
  <log4net>
    <root>
      <level value="ALL" />
      <appender-ref ref="FileAppenderXml" />
    </root>
    <appender name="FileAppenderXml" type="log4net.Appender.RollingFileAppender">
      <file type="log4net.Util.PatternString" value="logs\%date{yyyy}\%date{MM}\%date{yyyyMMdd}.xml"/>
      <appendToFile value="true"/>
      <rollingStyle value="Date" />
      <datePattern value="yyyyMMdd" />
      <layout type="log4net.Layout.XmlLayoutSchemaLog4j">
        <locationInfo value="true"/>
        <conversionPattern value="%date [%thread] %-5level - %message%newline" />
      </layout>
      <param name="Encoding" value="utf-8" />
    </appender>
  </log4net>

Using Yalv I started to detect that Warning (WARN) events are not generated by the application. I am using 4 levels (INFO, WARN, DEBUG, ERROR) and only the WARN type is the one not shown.

Here an extract:

        switch (typeLog)
        {
            case elogType.infoType:
                log.Info(currentMessage);
                break;

            case elogType.errorType:
                log.Error(currentMessage);
                break;

            case elogType.debugType:
                log.Debug(currentMessage);
                break;

            case elogType.warningType :
                log.Warn(currentMessage);
                break;
        }

Could it be some XML configuration or maybe the code?

So the issue appear to be that when the WARN event fires but it appears as "INFO."

According to the documentation:

When logging at level INFO the actual level used is not Info but the value of LoggerRepository.LevelMap["INFO"] . The default value for this is Info, but this can be changed by reconfiguring the level map.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM