Read those release notes…

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="http://www.sitecore.net/xmlconfig/">
  <sitecore>
    <log4net>

      <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"/>
        </layout>
        <encoding value="utf-8"/>
      </appender>

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

    </log4net>
  </sitecore>
</configuration>

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…

Advertisements

One thought on “Read those release notes…

  1. Pingback: So you’re thinking about an upgrade? | Jeremy Davis

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s