Sitecore Client Logging with JSNLog In Sitecore 8.1
With Sitecore 8.1, support has been added to log client side events. The new logging framework is built upon the standard Sitecore logging framework (which uses Log4net), allowing client side events to be logged back to the data/log folder on the delivery server.
Under the hood, Sitecore client logging uses JSNLog which has been wrapped to allow Sitecore to configure it via a patch and to make use of the existing Log4net logging.
All configuration for client logging is contained within Sitecore.JSNLog.config within App_Data/Include.
Enabled - Allows Client logging to be enabled. Beware disabling this option as the Sitecore CMS uses client logging for its diagnostics. You may need this option on if you need to raise support tickets.
serverSideMessageFormat - Here you can specify the format of the error message that is stored within the log. Above in the comments in the config file are a list of all the varibles. These can be seen below.
This is the appender thats used to write the errors to the Sitecore data log folder. Here we can specify the error level.
level - Here you can specify what level of logging is used (DEBUG|ERROR|INFO)
Using Client Logging In Your Website
By default when using client logging you will see a JSON object being displayed in your browser's console every time you write to the log. You can see this below
This functionality can be switched off, so logs are written but the log isn't displayed in the console window.
Within the Sitecore.JSNLog.config, there is an appender for the console called - consoleAppender. This is enabled by the logger appender element that accepts a comma seperate list of appenders. Removing the consoleAppender from this list disabled the console appender.