log4net in asp.net with LogFileAppender

G

Gawel

hajo,
can someone send me an example how to use above pattern
in asp.net applicaiton? I can not figure out how to do it.
I get no exceptions, simply no logging occures.


Thanks for any info


Gawel
 
M

Matt Berther

Hello Gawel,

I, too, had a problem getting this working properly... This is what I ended
up doing...

1. Modify the web.config file by adding this configSection:

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

2. Then add this configuration section:

<log4net>
<root>
<level value="OFF" />
<appender-ref ref="FileAppender" />
</root>

<appender name="FileAppender" type="log4net.Appender.FileAppender">
<file value="log-file.txt"/>
<appendToFile value="true"/>

<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%d [%t] %-5p %c [%x] &lt;%X{auth}> - %m%n" />
</layout>
</appender>
</log4net>

3. Now, the key part that put everything together... In Application_Start,
put this line:
log4net.Config.DOMConfigurator.Configure(); // this loads the config information
from the web.config file

4. Add logging to your classes, according to the samples at the log4net website.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,564
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top