This project is read-only.

Logging

A small logging framework with support for console and file logs. It can easily be extended with more types of logging targets.

Usage

The quick and dirty solution would be to use the SimpleLogManager to get everything working quickly. It's not as powerful as the regular setup but will work for 90% of all users.

    class SimpleLogManagerTest
    {
        private ILogger _logger;

        public SimpleLogManagerTest()
        {
            // true will create a console if it do not exist.
            // perfect for debugging winfoms/wfp applications.
            SimpleLogManager.AddConsole(true);

            // Will create a file log
            SimpleLogManager.AddFile("Mylog");

            // and assign a logger.
            _logger = LogManager.GetLogger<SimpleLogManagerTest>();
        }

        public void SomeMethod()
        {
            // Logging isn't harder than this.
            // one method per log level
            _logger.Debug("We are in some method");

            try
            {
                int a = 5/0;
            }
            catch(Exception err)
            {
                // Exceptions are automatically formatted properly
                // including all nested inner exceptions.
                _logger.Error("Oooops, something went wrong!", err);
            }
        }
    }

Output:

Last edited Mar 16, 2011 at 8:36 PM by jgauffin, version 1

Comments

No comments yet.