jxbma
asked on
Why is log4Net not generating a log file in my WCF service?
Hi:
I'm currently having difficulty getting log4net working in my WCF service application.
I'm running the service through VS 2010 (iis express)
I don't see any build errors or run time exceptions.
But the desired log file is not getting generated.
The WCF service implementation is broken into 2 parts (service library and service)
TestServiceLibrary.dll
TestService.dll
This is what the log4net configuration look like in my app.config file:
TestServiceLibrary -> App.config
Actual calls to Log4net takes place in TestServiceLibrary.dll:
This my code snippet
When I examine m_log at run time, all the following fields are set to false:
I'm currently having difficulty getting log4net working in my WCF service application.
I'm running the service through VS 2010 (iis express)
I don't see any build errors or run time exceptions.
But the desired log file is not getting generated.
The WCF service implementation is broken into 2 parts (service library and service)
TestServiceLibrary.dll
TestService.dll
This is what the log4net configuration look like in my app.config file:
TestServiceLibrary -> App.config
<configSections>
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" requirePermission="false"/>
</configSections>
<log4net debug="false">
<appender name="RollingLogFileAppender" type="log4net.Appender.RollingFileAppender">
<file value="C:\\logs\\TestService_log.txt"/>
<!-- the file to write to. change for your location and service -->
<appendToFile value="true"/>
<immediateFlush value="true" />
<datePattern value="yyyyMMdd"/>
<rollingStyle value="Date"/>
<!-- defines what the log message looks like. you want the timestamp and message, the rest is more or less decoration -->
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date [%thread] %-5level %logger - %message%newline"/>
</layout>
</appender>
<appender name="DebugAppender" type="log4net.Appender.DebugAppender">
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date [%thread] %-5level %logger - %message%newline"/>
</layout>
</appender>
<root>
<level value="DEBUG"/>
<!-- determines what 'level' of message to output. take as-is -->
<appender-ref ref="RollingLogFileAppender" />
<appender-ref ref="DebugAppender"/>
</root>
</log4net>
Actual calls to Log4net takes place in TestServiceLibrary.dll:
This my code snippet
private static ILog m_log = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
m_log.Debug("Debug Test Log4Net write");
m_log.Debug("Info Test Log4Net write");
When I examine m_log at run time, all the following fields are set to false:
IsDebugEnabled
IsErrorEnabled
IsFatalEnabled
IsInfoEnabled
IsWarningEnabled
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.