In my current project, I need to use an in-house logging system that was built on NLog in the Sitecore project.
Since Sitecore uses log4net for logging and we don’t want to replace all of it with another logging system, the easiest way would be to create a custom log4net appender that can forward the log messages to another logger.
Firstly, let’s define the NLog loggers in NLog.config file. In the following example, I defined 6 loggers that each of them maps to a log4net logger in Sitecore. I was using NLog 4.1, so I was able to use JSON as the log file format.
Then I created an appender that inherited from log4net.Appender.AppenderSkeleton. It overrode the Append method. What it does is:
Last step was to define this appender in the < log4net> section in the Web.config file.
Now we are able to append this NLogAppender to any