I am trying to enable Common.Logging.Log4Net to write all types of logs to a log file. The tutorials make it look so simple but I don't know what I am doing wrong. These are the steps I am taking:
- Create a new ASP.NET MVC empty project
- Install the "Common Logging Log4Net 1211" NuGet package
Add the following lines to the default web.config:
<common> <logging> <factoryAdapter type="Common.Logging.Log4Net.Log4NetLoggerFactoryAdapter, Common.Logging.Log4Net"> <arg key="configType" value="INLINE" /> </factoryAdapter> </logging> </common> <log4net> <root> <level value="ALL" /> <appender-ref ref="FileAppender" /> </root> <appender name="FileAppender" type="log4net.Appender.FileAppender" > <param name="File" value="C:\Users\MyName\Downloads\log.txt" /> <layout type="log4net.Layout.PatternLayout"> <conversionPattern value="%date [%thread] %level %logger - %message%newline" /> </layout> </appender> </log4net>
Make sure the app. pool identity account has RW access to the path where I am trying to save the log file.
Throw a random exception from code for testing purposes.
Am I missing anything? Is there a way I can debug log4net? Please help this poor soul. Thank you.