我有以下app.config:
<log4net>
<appender name="RollingFileAppender" type="log4net.Appender.RollingFileAppender">
<param name="File" value="S3Logger.log"/>
<appendToFile value="true" />
<rollingStyle value="Size" />
<maxSizeRollBackups value="10" />
<maximumFileSize value="10MB" />
<staticLogFileName value="true" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date [%thread] %level %logger - %message%newline" />
</layout>
</appender>
<appender name="RemotingAppender" type="log4net.Appender.RemotingAppender" >
<sink value="tcp://localhost:7070/LoggingSink" />
<lossy value="false" />
<bufferSize value="1" />
</appender>
<!-- Setup the root category, add the appenders and set the default level -->
<root>
<appender-ref ref="RollingFileAppender" />
<appender-ref ref="RemotingAppender" />
</root>
</log4net>
以及后面的代码:
public partial class App : Application
{
NameValueCollection appConfig = ConfigurationManager.AppSettings;
private readonly ILog log = LogManager.GetLogger(typeof(App));
private TaskbarIcon tb;
public App()
{
InitializeComponent();
XmlConfigurator.Configure();
//initialize NotifyIcon
if (getServiceStatus() == ServiceControllerStatus.Running)
{
tb = (TaskbarIcon)FindResource("ActiveServiceIcon");
}
else
{
tb = (TaskbarIcon)FindResource("InactiveServiceIcon");
}
log.Debug("Icon Created");
}
}
出于某种原因,我只在文件中获取日志记录,而不是通过 log2console “.net remoting reciever” 知道为什么吗?
(我正在使用通过 nuget 安装的 vs2012 和 log4net)