Episerver 11

How to change Episerver logging framework?

So lets say you want for some reason to change the default logging framework (log4net, https://logging.apache.org/log4net/). Episerver has made this really easy and it is documented at the bottom of this page: https://world.episerver.com/documentation/developer-guides/CMS/logging/

Basically you need to implement two interfaces: ILogger and ILoggerFactory

After implementing the interfaces you need to decorate your assembly with LoggerFactoryAttribute and set the LoggerFactoryType to your ILoggerFactory implementation type.

Before using your implementation remember to remove the Episerver.Logging.Log4Net NuGet package (and log4net package too). “The Logging API currently only supports one logger type and the API uses the first factory type it can find when it scans assemblies.”

I wanted to try out this feature and checked that there was no existing NLog (http://nlog-project.org/) package in the Episerver NuGet feed (yes there is EPi.Libraries.Logging.NLog 3.0.0 , but it doesn’t replace the logging framework, you need to configure log4net to not log anything). So I gave it this a shot and implemented logging with NLog. Sources are in GitHub: Swapcode.Episerver.Logging.NLog.

I’ll also upload the NuGet for this to Episerver NuGet feed and add the link if my package is accepted.

*update 2018-02-06* I’ve updated the documentation on GitHub to include all information needed for setup and configuration.

Advertisements

4 thoughts on “How to change Episerver logging framework?

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 )

Google+ photo

You are commenting using your Google+ 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 )

w

Connecting to %s