I am a Log4Net newbie and I am having some problems in order to log my application log messages in a log file. I think something is wrong with Web.config file configuration. This is a snippet of what I have in web.config:
<configSections>
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net"/>
</configSections>
<log4net>
<root>
</root>
<logger name="Tomahawk" additivity="False">
<level value="ALL" />
<appender-ref ref="MyFileAppender" />
</logger>
<appender name="MyFileAppender" type="log4net.Appender.FileAppender">
<file value="application.log" />
<appendToFile value="true" />
<lockingModel type="log4net.Appender.FileAppender+MinimalLock" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date %level %logger - %message%newline" />
</layout>
</appender>
</log4net>
Moreover, I included the following line in AssemblyInfo.cs:
[assembly: log4net.Config.XmlConfigurator(Watch = true)]
In C# code, ALL I do is this:
ILog log = LogManager.GetLogger("Tomahawk");
log.info("Some debug info...");
But nothing happens. Nothing is being logged in the log file.
Does anyone have a clue about this issue?
LogManager.GetRepository().Configuredto see if log4net is picking up the configuration - there are some cases where an assembly attribute doesn't pick it up correctly, e.g. if the attribute isn't in the startup project. If it is configured, check the permissions on the file allow the program to write to it. - stuartd