logging-log4net-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From <ma...@manfbraun.de>
Subject RE: Problem logging exceptions
Date Tue, 27 Apr 2010 17:22:49 GMT
Hi !

To me, it looks like, you forgot to create a logger, befor you log .... !??

	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.


-----Original Message-----
From: Dotnet_user [mailto:dotnet_user11@yahoo.com] 
Sent: Tuesday, April 27, 2010 5:17 PM
To: log4net-user@logging.apache.org
Subject: Problem logging exceptions

Hello everyone,

I'm using log4net to log my exceptions. The configuration settings look like

<?xml version="1.0" encoding="utf-8" ?>



<section name="log4net"
type="log4net.Config.Log4NetConfigurationSectionHandler, log4net"/>


<log4net debug="false">

<appender name="RollingLogFileAppender"

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




<level value="INFO"/>

<appender-ref ref="RollingLogFileAppender"/>




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




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:
Sent from the Log4net - Users mailing list archive at Nabble.com.

View raw message