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

Usage

Register a specific implementation

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

  • djLogOverSimpleLogger

  • djLogOverNOPLogger

  • djLogOverLog4D

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

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