Skip to content
Michael Justin edited this page Feb 5, 2016 · 25 revisions

Usage

Register a specific implementation

To register a specific logging framework, just add one of the djLogOver... units to the project.

Available binding units: djLogOverSimpleLogger, djLogOverNOPLogger, djLogOverLog4D

program Test;
interface
uses
  djLogOverSimpleLogger, // registers the 'simple' logger implementation
  UnitA, ...
  ...;
begin
  ...
end.

djLogOverLog4D

This unit will register Log4D as the logging framework. Configuration of Log4D must be applied as usual, either by invoking file based configuration, or by setting properties in application code (or both).

djLogOverSimpleLogger

This unit will register SimpleLogger as the logging framework. For configuration please check its Wiki page.

djLogOverNOPLogger

This unit will register NOPLogger as logging framework. NOPLogger actually does nothing, so it is equivalent to disabling logging for the program.

Create loggers where needed

unit UnitA;
interface
uses 
   ...
   djLogAPI, djLoggerFactory;
type
  TMyMainClass = class(TObject)
  private
    Logger: ILogger;
    ...
  public
    constructor Create;
    ...
  end;
  ...
constructor TMyMainClass.Create;
begin
  inherited;
  
  Logger := TdjLoggerFactory.GetLogger('main.Logger');
  Logger.Trace('Creating instance of TMyMainClass.');
  ...
end;

Log output:

42 TRACE main.Logger - Creating instance of TMyMainClass.
Clone this wiki locally