Log4Net on 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 A开发者_StackOverflow社区ssemblyInfo.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
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
精彩评论