Joutsen Logging  v0.4.1
Logging

Logging is a simple framework for the Mono/.NET framework that allows to create log output in different forms. It is modular and extensible. Loggers can easily be configured in XML files and used to write to different targets. At the same time it is possible to restrict the output through filters and create different output formats.

Installation

Simply download the latest assemblies and add them to your .NET project or build them yourself by cloning the repository and build the solution using the build.sh file from the scripts folder.

Example

In order to use the logger in your project simply create a logger instance and add the desired filter and handlers like this:

Logger logger = new DefaultLogger
{
Filter = new LogLevelFilter(LogLevel.Detailed);
};
logger.AddHandler(new ConsoleHandler(new SimpleFormatter("{SourceClassName}.{SourceMethodName} {Message}")));
Stream fileStream = new FileStream("path/to/logfile");
logger.AddHandler(new StreamHandler(fileStream, new XmlFormatter(), Encoding.UTF8));

Another way to create a logger is by creating a config file that defines the logger, filter and formatters like this:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<section name="logging" type="Joutsen.Logging.Configuration.LoggerConfigurationSection, Joutsen.Logging" allowDefinition="Everywhere" />
</configSections>
<logging class="Joutsen.Logging.DefaultLogger, Joutsen.Logging">
<filter type="logLevel" logLevel="Info" />
<handlers>
<console>
<format type="simple" outputFormat="{SourceClassName}.{SourceMethodName} {Message}"/>
</console>
<file encoding="utf-8" filename="path/to/logfile">
<format type="xml" />
</file>
</handlers>
</logging>
</configuration>

The easiest way to retrive the logger is then to use the logger factory:

Logger logger = Defaults.Logger;

Once the logger is created call the methods on the instance to create entries.

logger.Info("Log entry message");

See the API documentation for further details.

Documentation

Development documentation can be found here.

API documentation in HTML can be downloaded from [here]().

Tests

Tests can be run using NUnit by using the projects in the test folder. For unit test simply run

nunit.exe tests/Logging.UnitTests.nunit

Similarly run

nunit.exe tests/Logging.All.Tests.nunit

to also run the component tests.

Build and tests are also automatically run on the Jenkins CI server at https://ci.norsecorby.de/.