Hi Diana,
log4net is easy to use, I try to explain in short.
Before you can write any log entry, you must configure logging system.
It is usually done during constructing the main application's class (for
example in Main() method for console apps) and usually we use
configuration file to do this:
using log4net;
using log4net.Config;
XmlConfigurator.Configure(new System.IO.FileInfo("log4net.config"));
this line configures log4net system using log4net.config file. This file
describes all targets, where log entries can be written to, short
example is attached (it allows to into console, file and Windows
eventlog)
Now you can log anything you want - but some coding is needed - you must
get instance of logger (usually in constructor of every class, inside
which you want to log):
using log4net;
Ilog log = LogManager.GetLogger(typeof(yourClassName));
or
Ilog log = LogManager.GetLogger("yourLoggerName");
Now you can send log messages to the log system:
log.Info(.....);
log.Warn(....);
log.Error(....); etc.
How message is written into log target depends on configuration - see
log4net documentation.
All I wrote is valid for standard console or Windows application - I
have no experience with logging in ASP.NET, but there will not be big
difference (l hope someone gives you exact information, I think log4net
should be probably configured in Global.asax)
Radovan
________________________________
From: Diana Santos [mailto:[EMAIL PROTECTED]
Sent: Monday, August 27, 2007 3:54 PM
To: [email protected]
Subject: doubt about log4net configuration
Hi,
I need some ligths on log4net. A friend of mine told me that we
use the log4j and we only configure one file obtaining all log the for
the application without adding aditional code lines, including the log
of the actions taken in the data base. (INSERT / SELECT / DELETE ...)
Konw, i'm using the DotNetNuke framework to create a portal, and
i want to use the log4net to do some aditional logging. All the articles
and post that i read, some say that i have to add to all classes, that i
want to do the log, some lines as the import of the log4net and methots
that do the log...
Is there any way to only configure a file like log4j?
thanks for the help.
P.S: i'm using ASP.NET 2.0
log4net.config
Description: log4net.config
