以下配置沒有任何反應。log4net與EventLogAppender不記錄
的App.config
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net"/>
</configSections>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
<log4net>
<appender name="EventLogAppender" type="log4net.Appender.EventLogAppender" >
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date [%thread] %-5level %logger [%property{NDC}] - %message%newline" />
</layout>
</appender>
</log4net>
</configuration>
Form1.cs中(例)
public partial class Form1 : Form
{
private static readonly ILog log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
public Form1()
{
InitializeComponent();
log.Fatal("Test!");
}
}
什麼版本的工作室? – 2013-02-26 11:47:30
Visual Studio 2012 + Windows 8. – timmkrause 2013-02-26 11:49:47