Solved

Why is log4Net not generating a log file in my WCF service?

Posted on 2014-09-12
1
1,444 Views
Last Modified: 2014-10-07
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


  <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>

Open in new window



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");

Open in new window


When I examine m_log at run time, all the following fields are set to false:
IsDebugEnabled
IsErrorEnabled
IsFatalEnabled
IsInfoEnabled
IsWarningEnabled

Open in new window

0
Comment
Question by:jxbma
1 Comment
 
LVL 96

Accepted Solution

by:
Bob Learned earned 500 total points
ID: 40323305
Does the web service have access rights to the C:\Logs folder?
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
send messages to whatsapp programatically 2 50
InputLanguage 1 27
parsing JSON help 1 10
What are the simplest ways to create a Merge Sort? 3 15
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

832 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question