log4net - Web Application
Configuration
My web application is in:
C:\Inetpub\wwwroot\Track\
Web.config
The Web.config
file is in the same folder and contains a section for the
logging configuration.
../../misc/howto/log4net/Web.config
A sample XML configuration can be seen in the log4net - Getting Started.
The LogFileAppender
is configured to log to:
logs\\log-file.txt
The identity of the user running the web application will not have permission
to write to the logs
folder. To give the user permission, right click on
the logs
folder, select Properties, Security, select the
NETWORK SERVICE
group and tick the Allow, Write check box.
For more information see Re: logging stops under wwwroot.
Assembly
Setup the assembly configuration in AssemblyInfo.cs
:
[assembly: log4net.Config.XmlConfigurator(Watch=true)]
Remove Watch=true
is you don’t want the log4net system to watch the file
for runtime changes.