-
Notifications
You must be signed in to change notification settings - Fork 9
Home
Michael Justin edited this page Feb 8, 2016
·
25 revisions
To register a specific logging framework, just add one of the djLogOver...
units to the project.
Available binding units:
-
djLogOverLog4D
for logging over Log4D -
djLogOverLazLogger
for logging over LazLogger -
djLogOverSimpleLogger
for logging over SimpleLogger (included) -
djLogOverNOPLogger
for logging over NOPLogger (included)
program HelloWorld;
uses
djLogOverLazLogger, djLogAPI, djLoggerFactory;
var
Logger: ILogger;
begin
Logger := TdjLoggerFactory.GetLogger('demo');
Logger.Info('Hello World');
WriteLn('hit any key');
ReadLn;
end.
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). See Logging over Log4D for details.
This unit will register LazLogger as logging framework. See Logging over LazLogger for details.
This unit will register SimpleLogger as the logging framework. See SimpleLogger for details.
This unit will register NOPLogger as logging framework. NOPLogger actually does nothing, so it is equivalent to disabling logging for the program.
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.