我试图找到使log4net工作所需的最低设置。以下是我的配置
<log4net>
<appender name="something" type="log4net.Appender.RollingFileAppender">
</appender>
<root>
<appender-ref ref="something"/>
</root>
</log4net>
我收到以下错误:
log4net:ERROR XmlHierarchyConfigurator: Could not create Appender [something] of type [log4net.Appender.RollingFileAppender]. Reported error follows.
System.NullReferenceException: Object reference not set to an instance of an object.
at log4net.Appender.RollingFileAppender.ActivateOptions()
at log4net.Repository.Hierarchy.XmlHierarchyConfigurator.ParseAppender(XmlElement appenderElement)
log4net:ERROR XmlHierarchyConfigurator: Appender named [something] not found.
我无法找到有关RollingFileAppender所需设置的任何文档。我还应该添加什么?
答案 0 :(得分:1)
看起来您需要文件名和布局部分。我得到了以下工作:
<log4net>
<appender name="FileAppender" type="log4net.Appender.RollingFileAppender" >
<param name="File" value="Logs\\MyAppLog.log"/>
<layout type="log4net.Layout.PatternLayout">
</layout>
</appender>
<root>
<appender-ref ref="FileAppender"/>
</root>
</log4net>