logging-log4net-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Lathendra Uddaraju <uddaraju.va...@gmail.com>
Subject Log4Net with WCF Service is not writting the Log file.
Date Mon, 27 Sep 2010 17:50:17 GMT

Hai All,

    I have WCF Service which is hosted in IIS 7.5 and I am using Log4Net for
logging errors that are raised in the WCF Service. I have all the setting
configured properly in my application as per the Log4Net samples
configuration. My application is working when I am using VS 2010 application
server. But when I host the same Service in Windows 7 IIS 7.5 the log is
being created with out any exception but there is no data in the log file.

One more thing is I have kept the Debugger in the ErrorLogger file of the
Log4Net and seen all the values there, every thing is fine and I can see all
the values are properly going till the last moment but in the log file
nothing is present. I am unable to understand why the service is not able to
write the file in the specified path which is mentioned in the web.config

The Log4Net settings in the Presentation Layer is as follows.

        <!--    Log4Net Appender for logging to Log file    -->
        <appender name="RollingFile" type="log4net.Appender.FileAppender">
            <file value="D:\_log\EdgeLog.log" />
            <appendToFile value="true" />
            <maximumFileSize value="1024KB" />
            <maxSizeRollBackups value="10" />
            <layout type="log4net.Layout.PatternLayout">
                <conversionPattern value="
----------------------------------- %newlineDate of Error:  %date{yyyy-MM-dd
HH:mm:ss} | Error Level:  %level | Logger:  %logger | Domain Con: 
[%property{NDC}] | %newline%message%%newline
------------------------------------ %newline" />
          Log4Net Appender for sending email with the error details
        <appender name="SmtpAppender" type="log4net.Appender.SmtpAppender">
            <to value="dhanamjaya.devineni.contractor@altria.com" />
            <from value="salesedgesystem@altria.com" />
            <subject value="Sales Application Exception" />
            <smtpHost value="smtp.pmusa.net" />
            <bufferSize value="102400" />
            <lossy value="true" />
            <evaluator type="log4net.Core.LevelEvaluator">
                <threshold value="WARN" />
            <layout type="log4net.Layout.PatternLayout">
                <conversionPattern value=" ---------------------------------
Sales Edge Web Framework ---------------------------------
%newline%newlineDate of Error:  %date{yyyy-MM-dd HH:mm:ss} %newline  Error
Level:  %level %newline       Logger:  %logger %newline Diag Context: 
[%property{NDC}] %newline       Domain:  %appdomain %newline%message%newline
%newline" />
            <!-- Configure the levels based on which logging will be done
            <level value="ALL" />
            <appender-ref ref="RollingFile" />
            <appender-ref ref="SmtpAppender" />

The WCF Service Method where I am raising the exception is as follows.

public stringGetAllTerritories()
            string result = string.Empty;
            TerritoryBL territoryBL = new TerritoryBL();
                result = territoryBL.GenerateTerritoryXML();
                //return result;
                throw new Exception("Log4Net Testing with WCF Service -
            catch (Exception ex)
                ErrorLogger.ReportError("Exception in WCF Service", ex,
                return result;
                territoryBL = null;

In the catch block I am catching the exception and logging the error message
in the Log file.

Even though the file is not present in the specified location, the file is
created by the hosted service but when I open the file after the running the
code, there is nothing in the file and size of the file is 0 KB.

I strongly believe that I am missing some permission for the folder where
the log file is being written.

I tried with the following users with Full Control, but the service is not
writing to the log file.



Thanks in Advance ...
View this message in context: http://old.nabble.com/Log4Net-with-WCF-Service-is-not-writting-the-Log-file.-tp29816712p29816712.html
Sent from the Log4net - Users mailing list archive at Nabble.com.

View raw message