Windows Server 2003 上的 Log4Net
我一直在 Windows 7 操作系统上使用 Visual Studio 2010 开发 Web 应用程序。
我使用 Log4Net 来登录事件查看器,效果非常好,这意味着所有内容都正确记录在我的 Windows 7 事件查看器上。
在 Windows Server 2003 计算机上安装相同的项目后,我注意到没有记录任何内容...
我已经在 Windows Server 2003 计算机的管理员组中添加了 ASPNET,但问题仍然存在...
在 AssemblyInfo 上。我添加了.cs 文件:
[程序集:log4net.Config.XmlConfigurator()]
在 Web.config 文件上我添加了:
... ...
-->
<appender name="EventLogAppender" type="log4net.Appender.EventLogAppender" >
<param name="LogName" value="MyLog" />
<param name="ApplicationName" value="MyApplication" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date [%thread] %-5level %logger [%property{NDC}] - %message%newline" />
</layout>
</appender>
<!-- Setup the root category, add the appenders and set the default level -->
<root>
<level value="INFO" />
<appender-ref ref="ConsoleAppender" />
</root>
<!-- ApplicationKit category - the presentation UI -->
<logger name="MyLogger">
<level value="INFO" />
<appender-ref ref="FileAppender" />
<appender-ref ref="EventLogAppender" />
</logger>
最后是背后的代码:
... log4net.Config.XmlConfigurator.Configure(); Ilog log = LogManager.GetLogger("MyLogger"); ...
我已经在以下位置创建了 MyLog 键值:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Eventlog
但仍然没有记录任何内容。
我 100% 确信这在 Windows 7 上完美运行。
我需要在 Windows Server 2003 上进行一些其他特殊配置吗?
提前致谢
I've been working on a web application using Visual Studio 2010 on a Windows 7 OS.
I used Log4Net for logging on the Event Viewer and that worked out great, meaning that everything is being correctly logged on my Windows 7 Event Viewer.
After installing this same project on a Windows Server 2003 Machine, I've noticed that nothing get's logged...
I already added the ASPNET on the Administrators group of the Windows Server 2003 machine but still the problem persists...
On the AssemblyInfo.cs file I added:
[assembly: log4net.Config.XmlConfigurator()]
On Web.config file I added:
...
...
-->
<appender name="EventLogAppender" type="log4net.Appender.EventLogAppender" >
<param name="LogName" value="MyLog" />
<param name="ApplicationName" value="MyApplication" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date [%thread] %-5level %logger [%property{NDC}] - %message%newline" />
</layout>
</appender>
<!-- Setup the root category, add the appenders and set the default level -->
<root>
<level value="INFO" />
<appender-ref ref="ConsoleAppender" />
</root>
<!-- ApplicationKit category - the presentation UI -->
<logger name="MyLogger">
<level value="INFO" />
<appender-ref ref="FileAppender" />
<appender-ref ref="EventLogAppender" />
</logger>
And finally on the code behind:
...
log4net.Config.XmlConfigurator.Configure();
Ilog log = LogManager.GetLogger("MyLogger");
...
I already created the MyLog key value on:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Eventlog
But still, nothing gets logged there.
I'm 100% percent sure this works perfectly on Windows 7.
Do I need to make some oyher special configuration on Windows Server 2003?
Thanks in advance
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好吧...
事实证明,我还必须向网络服务授予以下密钥的完全权限:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Eventlog
瞧
Well...
As it turned out I also had to give the NETWORK SERVICE full permissions to the following key:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Eventlog
Voila