The Logger Module provides a set of static methods to use for logging. I.E. Logger.Error("Error message"). The class will dynamically invoke processors which will write log entries to a specific target. I.E. you can enable the SitecoreLogProcessor to write to the standard Sitecore log. You can easily implement own processors.

Configuration of the logger is done via config file. Also, a config item can be used to allow configuration changes at runtime.

Logger How it works


Usage is very simple. Just use one of Logger's static methods to log an event.
Namics.Opensource.Modules.Logger.Logger.Warn("Some warning");

Installation Guide

To set up the module, follow these steps:
  1. Install the logger package using the Sitecore Installation Wizard
  2. Configure Logging and Processors in the /App_Config/Includes/Namics.Logger.config

To set up the runtime configuration item:
  1. Create a new Item inheriting the /sitecore/templates/Modules/Namics Logger/Namics Logger Config Template
  2. Set the path of the newly created item in Namics.Logger.config in the setting Namics.Debug.ConfigItemPath


The following configuration options are available:

Setting Example Value Description
Namics.Debug.ConfigItemPath /sitecore/system/Modules/Namics Logger/Logger Config Path to the configuration item. If empty or if the item doesn't exist, the config file is used as fallback
Namics.Debug.LogLevel * NONE * AUDIT * FATAL * ERROR * WARN * INFO * DEBUG Sets the log level. DEBUG will log all messages while NONE won't log any messages at all.
Namics.Debug.LogProcessors e.g. MyNamespace.MyClass | MyNamespace.MyOtherClass List of processor class names separated by a pipe | character. Each processor receives log entries and outputs them to a specific target.
Namics.Debug.Console.AllowedIp | | 10.0. | 10.1. List of IP prefixes. The prefix of the user's IP needs to match to enable browser console logging via HTTP Headers. Use "ALL" as value to enable logging for all IPs.

The database for the database logger can be configured in the ConnectionStrings config, e.g.:
  <!-- Other connection strings -->
  <add name="DatabaseLog" connectionString="user id=MyDatabaseUser;password=MyPassword;Data Source=MyDatabaseServer;Database=MyDatabaseName;"/>

Log Processors

Included in Namics Logger

Title Fully qualified class name Description
SitecoreLogProcessor Namics.Opensource.Modules.Logger. Processors.SitecoreLog.SitecoreLogProcessor Writes log entries to the standard sitecore log.
BrowserConsoleLogProcessor Namics.Opensource.Modules.Logger. Processors.BrowserConsoleLog. Writes log entries to the browser console log using HTTP headers (FirePHP protocol) if the user's IP matches the configured IP prefix. Refer to FirePHP for details. If your server is behind an application firewall, you might need to enable the HTTP headers as described in the FirePHP Reference.
MemoryLogProcessor Namics.Opensource.Modules.Logger. Processors.MemoryLog.MemoryLogProcessor Writes log entries to a static collection in memory. The log entry collection can be accessed via MemoryLogProcessor.Entries and can be cleared using MemoryLogProcessor.Clear(). Caution: log entries of all threads are written into the collection simultaneously. It is not recommended to use this processor in production.
DatabaseLogProcessor Namics.Opensource.Modules.Logger. Processors.DatabaseLog.DatabaseLogProcessor Writes log entries to the configured SQL database. The database is configured using the Sitecore ConnectionString config by adding an entry with the name 'DatabaseLog'. If it doesn't already exist, the module will create a table also called 'DatabaseLog' for you.

Implement an own Log Processor

To implement an own Log Processor, simply implement the Namics.Opensource.Modules.Logger.Processors.ILogProcessor interface and add the fully qualified name of your class to the BrowserConsoleLogProcessor list in config.

public class OwnLogger : Namics.Opensource.Modules.Logger.Processors.ILogProcessor
        /// <summary>
        /// Processes a log entry.
        /// </summary>
        /// <param name="pEntry">
        /// The log entry object
        /// </param>
        public void WriteLogEntry(LogEntry pEntry)
            // Do something with the log entry here

Displaying Browser Console Log Messages in Chrome or Firefox

Install Firebug and the FirePHP addon. That's all.

Install the FirePHP4Chrome Extension.


Logger Console Sample Screen

Last edited Sep 5, 2013 at 12:37 PM by LZurbriggen, version 9


No comments yet.