Reputation: 29752
In my web.config I had some custom log4net error loggers defined:
<configuration>
<log4net>
<appender name="RR.Db" type="log4net.Appender.SitecoreLogFileAppender, Sitecore.Logging">
<file value="$(dataFolder)/logs/RR.Db.{date}.txt" />
<appendToFile value="true" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%4t %d{ABSOLUTE} %-5p %m%n" />
</layout>
<encoding value="utf-8" />
</appender>
<logger name="RR.Db" additivity="false">
<level value="INFO"/>
<appender-ref ref="RR.Db"/>
</logger>
....
</log4net>
</configuration>
These have been working fine for sometime. When I upgraded sitecore from 8.0 to 8.1 (and subsequently 8.2) all my loggers suddenly just stopped working. All logs sent to custom logs just started appearing in the default log.log file and none of my custom logs were created.
Why? How can I fix this?
Upvotes: 4
Views: 1891
Reputation: 29752
Took me a long while to figure this out but it turns out sitecore have altered (with the minimal of information as usual) how these logs are regsitered. I found buried in the release notes this line:
<log4net>
section has been moved under<sitecore>
node and now supports new support patching.
So basically they've moved where the log4net section should be configured. It should now be under the <sitecore>
config and not directly under the <configuration>
where it was previously/is in every other application that uses log4net.
I fixed this by adding a new .config file, /App_config/Include/logging.xx.config
. In this file I added the config from the web.config with a few tweaks:
<?xml version="1.0"?>
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/" xmlns:x="http://www.sitecore.net/xmlconfig/">
<sitecore>
<log4net>
<appender name="RR.Db" type="log4net.Appender.SitecoreLogFileAppender, Sitecore.Logging">
<file value="$(dataFolder)/logs/RR.Db.{date}.txt" />
<appendToFile value="true" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%4t %d{ABSOLUTE} %-5p %m%n" />
</layout>
<encoding value="utf-8" />
</appender>
<logger name="RR.Db" additivity="false">
<level value="INFO"/>
<appender-ref ref="RR.Db"/>
</logger>
....
</log4net>
</sitecore>
</configuration>
You should also remove the configuration for these logs in the web.config, the above is now where this lives not in the root. Everything now works as expected.
Upvotes: 6