Try our conversational search powered by Generative AI!

Replacing Log4Net in EpiServier 7.5


I am trying to replace the out of the box Log4Net logging in EPiServer with Syslog. I've got this working by following the guide under the heading 'Implementing the API' at the bottom of this page The last step says the following: 

The Logging API currently only supports one logger type and the API will use the first factory type it can find when scanning assemblies. It is therefore recommended that you make sure that the EPiServer.Logging.Log4Net assembly is removed before deploying another implementation.

However, at the top of the page it says this:

Initially the EPiServer.CMS package will have a package dependency to EPiServer.Logging.Log4Net, which is the log4net implementation of the API to maintain compatibility and ease the transitioning. This dependency is planned to be removed as a part of a future update.

True enough I cannot remove the EPiServer.Logging.Log4Net from my solution as CMS Core (we're on 7.19.2) depends on it. Does this mean I cannot use a different Logging solution in EPiServer 7.5?

Nov 16, 2018 10:18

If I remember correctly the loggin abstraction was added in CMS 9, so you would need to upgrade to use a different logging solution

Nov 16, 2018 11:44

That's a shame. Thanks for confirming.

Nov 16, 2018 12:47

you can still use log4net to "capture" log entries coming from Episerver (as you cannot replace logging engine underneath) and have configured Udp appender to "forward" entries to Syslog.

Sample config below:

<appender name="UdpAppender" type="log4net.Appender.UdpAppender">
    <param name="RemoteAddress" value="" />
    <param name="RemotePort" value="514" />
    <layout type="log4net.Layout.PatternLayout, log4net">
        <conversionPattern value="%-5level %logger [%property{NDC}] - %message%newline" />
Nov 16, 2018 14:33

@Valdis: I'm trying to make him upgrade here. it's for the best of everybody ;)

Nov 16, 2018 14:41

I'm sorry for ruing that. Yes, discard my answer - go upgrade! :)

Nov 16, 2018 14:45
Edited, Nov 19, 2018 15:19
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.