Sitecore have an ample capabilities on logging. All logging system is based on log4net services. And if you need to change destination of your logs all that you need – configure right log appender. There is wide range of log4net appenders available out of the box. And also big amount of open source modules that you are able to fit for your needs. For example:
- You can write your logs in MongoDB.
- You can create Slack bot that will put logs in Slack channel.
- Use ElasticSearch+LogStash+Kibana(or RabbitMQ)
But there are few peculiar properties that doesn’t allow to use major appenders out of the box. Log4net web.config configuration section in Sitecore is initialized by Sitecore.Logging (not by log4net.dll) assembly and it requres additional steps. Sitecore.Logging is extended copy of log4net assembly. Even namespaces are same! While fitting new appender to Sitecore your appender should be inherited from log4net.Appender.AppenderSkeleton. Take into account that class with same namespace is present in both log4net.dll and Sitecore.Logging.dll. You need to use class from Sitecore.Logging.dll !!!
- Get sources of appender
- Add reference to Sitecore.Logging assembly with alias Sitecore for ability to use log4net and Sitecore.Logging in same project
- Inherit your appender from Sitecore.Logging AppenderSkeleton class implementation MyAppender : Sitecore::log4net.Appender.AppenderSkeleton
- Implement missed class members: you need to reimplement Append method. It has different signature comparing to default one Append(Sitecore::log4net.spi.LoggingEvent loggingEvent)