Hi !
To me, it looks like, you forgot to create a logger, befor you log .... !??
Missing:
ILog log = log4net.LogManager.GetLogger(typeof(yourType));
In my web scenarios, I call it ether in the constructor or use
a "global" variable, which I initilize like shown above.
You my call it in "Application_Start(...)"
Hope, this helps.
br++mabra
-----Original Message-----
From: Dotnet_user [mailto:[email protected]]
Sent: Tuesday, April 27, 2010 5:17 PM
To: [email protected]
Subject: Problem logging exceptions
Hello everyone,
I'm using log4net to log my exceptions. The configuration settings look like
this:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<section name="log4net"
type="log4net.Config.Log4NetConfigurationSectionHandler, log4net"/>
</configSections>
<log4net debug="false">
<appender name="RollingLogFileAppender"
type="log4net.Appender.RollingFileAppender">
<file value="C:\Logs\sample.log" />
<appendToFile value="true"/>
<rollingStyle value="Size"/>
<maxSizeRollBackups value="10"/>
<maximumFileSize value="10MB"/>
<staticLogFileName value="true"/>
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%-5level %date %logger.%method[line %line] -
%message%newline"/>
</layout>
</appender>
<root>
<level value="INFO"/>
<appender-ref ref="RollingLogFileAppender"/>
</root>
</log4net>
</configuration>
I started out by adding this configuration to web.config, but I got an error
(VS studio could not find a schema for log4net-"Could not find schema
information for the element log4net"). So I followed this link
(http://stackoverflow.com/questions/174430/log4net-could-not-find-schema-inf
ormation-messages)
and configured my settings in a separate xml file and added the following
line of code in my AssemblyInfo.cs:
[assembly: log4net.Config.XmlConfigurator(ConfigFile = "xmlfile.xml", Watch
= true)]
And in the actual code, I placed this line:
public void CreateUser(String username, String password)
{
try
{
log.Info("Inside createuser");
//code for creating user
}
catch(exception e)
{
log.Info("something happened in create user", e);
}
}
The problem is that the log file is not being created. Can anybody tell me
what I'm doing wrong here?
Any suggestions/inputs will be very helpful.
Thank you all in advance.
--
View this message in context:
http://old.nabble.com/Problem-logging-exceptions-tp28378261p28378261.html
Sent from the Log4net - Users mailing list archive at Nabble.com.