logging-log4net-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Dean Fiala" <dfi...@celadonlabs.com>
Subject RE: Using log4Net from my web service (.net 2.0, C#); nothing happens
Date Thu, 30 Oct 2008 13:48:07 GMT
This is likely a permissions error.  You need to grant the ASP.NET user (or
NETWORK SERVICE user for Win2k3 or higher) write permissions on the folder
where you want to write the log file to.  The default is to only allow the
user to read files, not write them.

-----Original Message-----
From: Sriram Ranganathan [mailto:sriram.ranga@gmail.com] 
Sent: Thursday, October 30, 2008 6:22 AM
To: log4net-user@logging.apache.org
Subject: Using log4Net from my web service (.net 2.0, C#); nothing happens

My web service is using C# and .Net 2.0

When a "handled" exception is thrown during the web service call, the
service should return normally but should log some information so some admin
chappie can look at it later.

So I thought of usnig log4net but don't know how to. After checking on the
net, it seemed easy enough:

1: This is In my web.config file of the web service:

<?xml version="1.0"?>   
<section name="log4net"
<appender name="RollingFile" type="log4net.Appender.RollingFileAppender">   
<file value="chuckchuck.log" />  
<appendToFile value="true" />  
<maximumFileSize value="100KB" />  
<maxSizeRollBackups value="2" />  
<layout type="log4net.Layout.PatternLayout">   
<conversionPattern value="%level %thread %logger - %message%newline" />  
<level value="DEBUG" />  
<appender-ref ref="RollingFile" />  
<compilation debug="true"/>   
<authentication mode="Windows"/>   

2. This is in the class where I have to do the logging:


 using System;

using log4net;

using log4net.Config;

public class CalculationNotPossibleException : Exception


protected static readonly ILog log =

public CalculationNotPossibleException()



private String userMessage;

public String UserMessage


get { return userMessage; }

set { userMessage = value; }


public void logInput(CalculationInput p_calculationInput)


log.Debug("Sriram says DEBUG - this text will be in log file");

log.Info("Sriram says INFO - this text will be in log file");




3. When my web service is invoked, I know for a fact that the above code
(log.debug .....) is executed. I know the code control comes there, so I
expect there to be a log file called chuckchuck.log created and the above
lines to be printed into that file.

But that doesn't happen.

I don't get any errors (even in eventviewer) from log4net but there is no
log file called chuckchuck.log in my entire system ... I did a search for
all files with this name. 

Some people might say I have to create an appender in the log4j section of
the web.config file for the name "CalculationNotPossibleException" which is
my class name that is doing the logging. But the way I see it, the root is
supposed to handle it all, so it oughta work.

 In my application, this is the only place I have to log anything. So there
is no other related code anywhere at all.

So what am I missing?

Request - for those people givnig ideas, if you are saying "put the log4j
thingies in a separate config file" etc .... any comments like this ...
please tell me details such as where (location) I am supposed to save the
new config file and how my web service is supposed to pick up the location
of this config file ... etc etc. I.e. - please give precise comments with as
much detail as possible .... I would really appreciate it.

Wherever possible, please give me the code to do whatever I am missing,
whether it be in my C# file or in my web.config or any other config u might
ask me to make.

Thanks and much appreciation,

Sriram Ranganathan

View this message in context:
Sent from the Log4net - Users mailing list archive at Nabble.com.

View raw message