Jeremy Davis
Jeremy Davis
Sitecore, C# and web development
Jeremy Davis
Jeremy Davis
Sitecore, C# and web development
Article printed from:

Read those release notes...

Published 17 April 2017
Updated 27 June 2017

It's easy to get distracted by all the shiny big features that get deployed in new releases of Sitecore, but every so often a little gem slips past almost without comment. Except in the release notes...

One such change that I came across recently was hiding in plain sight in the notes for v8.1 (rev. 151003). With surprisingly little fanfare, the configuration for Log4Net has been moved under the <sitecore/> element in the site's configuration. And hence you can now apply config patches to adjust the log file settings.

It's not a massive thing in the grand scheme, but it adds another useful feature to the list of stuff you can modify with a patch.

So instead of XDT or manual edits, you can now have much more deployment-friendly changes like:

<configuration xmlns:patch="">

      <appender name="MyCustomAppender" type="log4net.Appender.SitecoreLogFileAppender, Sitecore.Logging">
        <file value="$(dataFolder)/logs/testlog.{date}.txt"/>
        <appendToFile value="true"/>
        <layout type="log4net.Layout.PatternLayout">
          <conversionPattern value="%4t %d{ABSOLUTE} %-5p %m%n"/>
        <encoding value="utf-8"/>

      <logger name="MyCustomLogger" additivity="false">
        <level value="INFO"/>
        <appender-ref ref="MyCustomAppender"/>



It's probably of most use when you're building event handlers or pipeline components – as now you can easily have a custom log for them deployed in a package. But it's also useful if you want a custom view of the standard log data – like emailing you about exceptions for example.

Useful things, release notes...

↑ Back to top