Thanks for the reply. I'm trying to find documentation about what parameters 
are available for the appenders, in particular, the
file appender,rollingfile appender, and smtpappender.

The docs at apache don't seem to list all of the parameters available. Do you 
know where I could find them?

Thanks,
Mike

-----Original Message-----
From: Ron Grabowski [mailto:[EMAIL PROTECTED]
Sent: Friday, February 25, 2005 10:40 AM
To: Log4NET User
Subject: Re: need sample


The first place I look for help for things like this is Google. Have
you tried searching for "log4net example"?

 http://www.google.com/search?q=log4net+example

I would create a log4net.config file that looks something like this:

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

<appender name="MyFirstFileAppender"
type="log4net.Appender.FileAppender">
<file value="log-file.txt" />
<appendToFile value="true" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%5p %d (%c:%L) - %m%n" />
</layout>
</appender>

<root>
<level value="ALL" />
<appender-ref ref="MyFirstFileAppender" />
</root>

</log4net>

Then add this code as early as you can during your program's start up:

string log4netConfigFilePath =
Path.Combine(AppDomain.CurrentDomain.SetupInformation.ApplicationBase,
"log4net.config");

log4net.Config.DOMConfigurator.ConfigureAndWatch(new
FileInfo(log4netConfigFilePath));

To log a statement do this:

if (log.IsDebugEnabled)
{
 log.Debug("Hello World");
}

Hope that helps,
Ron

--- "Rutledge, J. Mike" <[EMAIL PROTECTED]> wrote:


---------------------------------
need sample
Can anyone point me to some sample c# code on how to set up the logger
and fileappender?
I've tried following the examples in the supplied documentation but I
don't understand it all.

For example,

ILog log =  LogManager.GetLogger(typeof(Form1));
FileAppender fa = new FileAppender("c:\\znewlog.txt");

This fails because fileappender constructor is looking for another
parameter
of type ILayout. I can't find any example of what Ilayout is or how to
pass
it in.

Also, If I decide to use a config file to do this, how do you link the
logger to the config file (make it look there for it's settings)?


Thanks,
Rut


---------------------------------


CONFIDENTIALITY NOTE:  This e-mail message, including any
attachment(s),contains information that may be confidential,
protected by theattorney-client or other legal privileges, and/or
proprietary non-publicinformation.  If you are not an intended
recipient of this message or anauthorized assistant to an intended
recipient, please notify the senderby replying to this message and
then delete it from your system.  Use,dissemination, distribution,
or reproduction of this message and/or anyof its attachments (if
any) by unintended recipients is not authorizedand may be unlawful.


Reply via email to