Unable to set property [lockingModel] on object [log4net.Appender.RollingFileAppender] using value [MinimalLock]

隐身守侯 提交于 2020-01-14 12:34:18

问题


I am getting this error in my C# application. I am using log4net as a logging tool.

Here is my app.config file:

<configuration>

  <configSections>
    <section name="log4net" type ="log4net.Config.Log4NetConfigurationSectionHandler,log4net"/>
  </configSections>

  <log4net>
    <root>
      <level value="ALL" />
      <appender-ref ref="myLogger" />
    </root>
    <appender name="myLogger" type="log4net.Appender.RollingFileAppender,log4net">
      <param name="File" value="C:\MyApp\Logs\appLog.txt" />
      <param name="AppendToFile" value="true" />
      <rollingStyle value="Size" />
      <maxSizeRollBackups value="2" />
      <maximumFileSize value="100KB" />
      <staticLogFileName value="true" />
      <datePattern value="yyyyMMdd" />
      <lockingModel value="log4net.Appender.FileAppender+MinimalLock" />
      <immediateFlush value="true" />
      <layout type="log4net.Layout.PatternLayout">
        <conversionPattern value="%date [%thread] %-5level %logger - %message%newline" />
      </layout>
    </appender>
  </log4net>

</configuration>

Can anyone please help?


回答1:


Use this:

<lockingModel type="log4net.Appender.FileAppender+MinimalLock" />

Note: type instead of value.



来源:https://stackoverflow.com/questions/4076727/unable-to-set-property-lockingmodel-on-object-log4net-appender-rollingfileapp

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!