This project is read-only.


The logging system in the web server is abstract and is only inteded to be used as a bridge to your favorite logging system.
We have included a console logger for debugging purposes.

Need anything else? Use nlogger or log4net.

Using the console logger

            LogFactory.Assign(new ConsoleLogFactory(null));

Filtering log entries

            LogFilter filter = new LogFilter();
            filter.AddType(typeof(HttpServer.Mvc.Controllers.ControllerDirector), LogLevel.Debug);
            filter.AddType(typeof(HttpServer.Messages.MessageFactoryContext), LogLevel.Warning);
            filter.AddType(typeof(HttpServer.Messages.Parser.HttpParser), LogLevel.Warning);
            LogFactory.Assign(new ConsoleLogFactory(filter));

Creating a bridge to your own favorite logging library

    // used by the webserver to create new logging classes.
    class MyLogProvider : HttpServer.Logging.ILogFactory
        public HttpServer.Logging.ILogger CreateLogger(Type type)
            return new LogBridge(type);

    // the actual logger bridge.
    class LogBridge : HttpServer.Logging.ILogger
        private ILogger _logger; // nlog logger
        public LogBridge(Type type)
            _logger = LogManager.GetLogger(type.Name);

        public void Debug(string message)

        public void Debug(string message, Exception exception)
            _logger.DebugException(message, exception);

        // [... other logging methods ...]

   LogFactory.Assign(new MyLogProvider());

Last edited Mar 29, 2010 at 7:14 PM by jgauffin, version 4


No comments yet.