org.as2lib.core.BasicClass +--org.as2lib.env.log.LogManager
LogManager
is the core access point of the As2lib Logging API.
You use it to set the underlying repository that stores and releases loggers and to obtain a logger according to a logger's name of the repository.
The repository must be set before anything else using this class as access point to obtain loggers. There is no default repository.
This class could be used as follows with a non-singleton repository. Note
that you can of course also use any other kind of logger repository.
// configuration: when setting everything up
var loggerHierarchy:LoggerHierarchy = new LoggerHierarchy();
var traceLogger:SimpleHierarchicalLogger = new SimpleHierarchicalLogger("org.mydomain");
traceLogger.addHandler(new TraceHandler());
loggerHierarchy.addLogger(traceLogger);
LogManager.setLoggerRepository(loggerHierarchy);
// usage: in the class org.mydomain.MyClass
var myLogger:Logger = LogManager.getLogger("org.mydomain.MyClass");
if (myLogger.isInfoEnabled()) {
myLogger.info("This is an informative log message.");
}
If you have one logger that shall always be returned you can use the
convenience method setLogger that does all the work with the repository
for you.
// configuration: when setting everything up
var traceLogger:SimpleLogger = new SimpleLogger();
traceLogger.addHandler(new TraceHandler());
LogManager.setLogger(traceLogger);
// usage: in the class org.mydomain.MyClass
var myLogger:Logger = LogManager.getLogger("org.mydomain.MyClass");
if (myLogger.isInfoEnabled()) {
myLogger.info("This is an informative log message.");
}
static public function getLogger(loggerName:String):Logger
Returns the logger according the passed-in loggerName
.
Uses the set logger repository to receive the logger that is returned.
null
is returned if the logger repository returns null
or
undefined
.
loggerName | the name of the logger to return |
the logger according to the passed-in name
static public function setLogger(logger:Logger):Void
Sets the logger
that is returned on calls to the getLogger
method.
This method actually sets a singleton repository via the static
setLoggerRepository that always returns the passed-in logger
and ignores the name.
You could also set the repository by hand, this is just an easier way of doing it if you always want the same logger to be returned.
logger | the logger to return on calls to the method
|
static public function getLoggerRepository(Void):LoggerRepository
Reutrns the logger repository set via setLoggerRepository.
There is no default logger repository, so you must set it before anything else.
the set logger repository
static public function setLoggerRepository(loggerRepository:LoggerRepository):Void
Sets a new repositroy returned by getLoggerRepository.
The getLogger method uses this repository to obtain the logger for the passed-in name.
loggerRepository | the new logger repository |