Anders G. Nordby

Lead Software Engineer at Sopra Steria

Tag Archives: log4net

log4net appender names are case sensitive

Note to self…

I spent quite some time today trying to get the logging to work. Fiddling around with file locations for the log files, checking write permissions, etc. My frustration level kept rising, as none of my efforts resulted in a log file – even if the application should log plenty of stuff. Finally, a co-worker came by, and spotted the error immediately! (Isn’t that kind of annoying, how everyone else immediately can see what you yourself cannot?)

This was my EPiServerLog.config file:

<?xml version="1.0" encoding="utf-8"?>
  <appender name="fileLogAppender" type="log4net.Appender.FileAppender" >
    <file value="C:\Logs\ErrorLog.txt" />
    <encoding value="utf-8" />
    <lockingModel type="log4net.Appender.FileAppender+MinimalLock" />
    <appendToFile value="true" />
    <layout type="log4net.Layout.PatternLayout">
      <conversionPattern value="%date %level [%thread] %type.%method - %message%n" />
    <level value="All" />
    <appender-ref ref="fileLogappender" />

Notice that the case of the ‘a’ in the appender name is different in two places… Making sure the case was the same in both places solved the problem.