Title: Message

Here is how to add a single log statement to an application:

 

Add this line at the top of the file containing the method you want to add logging to:

 

using log4net;

 

Add this line in the “global” area of the class in that file, say right after:

 

namespace SomeClass

{

            public class SomeClass: System.Web.UI.Page

            {

 

Add this line:

 

                        private static readonly ILog log = LogManager.GetLogger("Logger" );

 

Then inside a method add:

                        private void Page_Load(object sender, System.EventArgs e)

                        {

                                    log.Debug("debugging " + this.Trace);

 

You need to add a line to AssemblyInfo.cs:

[assembly: log4net.Config.DOMConfigurator()]

 

 and add a reference to the log4l.dll (right-click the project and select it) – this is outlined on the website below.

 

I think that’s it – you could log your head off at this point I think. Only 3 lines harder than System.Console.writeline() I think …

 

Thanks,

 

Owen Corpening

Acorn Systems


From: Hart, Leo [mailto:[EMAIL PROTECTED]
Sent: Thursday, March 17, 2005 10:15 AM
To: Log4NET User
Subject: RE: Log4Net only for the committed techies

 

Have you seen this walkthrough? 

 

 

It was enough to get me started, though I did need to do some additional research as far as configuration files go.  If you have a specific question, like "How do I get my web app to recognize log4net or something, just ask."  I'll do my best to provide you with an answer, as will others on this list.

-----Original Message-----
From: Oliver Sturm [mailto:[EMAIL PROTECTED]
Sent: Thursday, March 17, 2005 11:08 AM
To: Log4NET User
Subject: Re: Log4Net only for the committed techies

Reply via email to