ocean.util.log.Logger

Logging system for applications

The most common pattern for using this class is to have a module-global object and initialize it on construction:

module superapp.main;

import ocean.util.log.Logger;

private Logger log;
static this ()
{
    log = Log.lookup("superapp.main");
}

void main (string[] args)
{
    log.info("App started with {} arguments: {}", args.length, args);
}

This usage can however be problematic in complex cases, as it introduces a module constructor which can lead to cycles during module construction, hence sometimes it might be worth moving to a narrower scope (e.g. nesting it inside a class / struct).

Loggers can be configured to output their message using a certain Layout (see ocean.util.log.layout package), which will define how the message looks like, and they can output to one or more Appender, which defines where the message is writen. Common choices are standard outputs (stdout / stderr), syslog, or a file.

In order to make Logger common use cases more simple, and allow flexible usage of logger without needing to re-compile the application, a module to configure a hierarchy from a configuration file is available under ocean.util.log.Config.

Members

Aliases

Level
alias Level = ILogger.Level

These represent the standard LOG4J event levels.

Classes

Logger
class Logger

Loggers are named entities, sometimes shared, sometimes specific to a particular portion of code. The names are generally hierarchical in nature, using dot notation (with '.') to separate each named section. For example, a typical name might be something like "mail.send.writer"

Structs

Log
struct Log

Manager for routing Logger calls to the default hierarchy. Note that you may have multiple hierarchies per application, but must access the hierarchy directly for root() and lookup() methods within each additional instance.

Meta

License

Boost Software License Version 1.0. See LICENSE_BOOST.txt for details. Alternatively, this file may be distributed under the terms of the Tango 3-Clause BSD License (see LICENSE_BSD.txt for details).