Main Page | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members | Related Pages

Logger Class Reference

Inheritance diagram for Logger:

ILogger LoggerInstance List of all members.

Public Member Functions

void trace (char[] msg)
void info (char[] msg)
void warn (char[] msg)
void error (char[] msg)
void fatal (char[] msg)
char[] getName ()
Level getLevel ()
void setLevel (Level level)
void setLevel (Level level, bool force)
bool isEnabled (Level level)
bool isAdditive ()
void setAdditive (bool enabled)
void clearAppenders ()
void addAppender (Appender appender)
ulong getUptime ()

Static Public Member Functions

Logger getRootLogger ()
Logger getLogger (char[] name)

Static Public Attributes

char[][] LevelNames

Private Types

enum  Level {
  Trace = 0, Info, Warn, Error,
  Fatal, None
}

Detailed Description

This is the primary API to the log package. Use the two static methods to access and/or create Logger instances, and the other methods to modify specific Logger attributes.

Logger myLogger = Logger.getLogger ("my.logger"); myLogger.info ("an informational message"); myLogger.error ("an exception message: " ~ exception.toString); etc ...

Messages passed to a Logger are assumed to be pre-formatted. You may find that the TextFormat class is handy for collating various components of the message.

TextFormat tf = new TextFormat (256); myLogger.warn (tf.format("temperature is %d degrees!", 101));

You may also need to use one of the two classes BasicConfigurator and PropertyConfigurator, along with the various Layout & Appender implementations to support your exact rendering needs.

Mango.log closely follows both the API and the behaviour as documented at the official Log4J site, where you'll find a good tutorial. Those pages are hosted over here.

Definition at line 79 of file Logger.d.


Member Enumeration Documentation

enum Level [inherited]
 

These represent the standard LOG4J event levels. Note that Debug is called Trace here, because debug is a reserved word in D (this needs to be fixed!).

Enumeration values:
Trace 
Info 
Warn 
Error 
Fatal 
None 

Definition at line 52 of file ILevel.d.

Referenced by CacheServer::LoaderThread::load(), TaskServer::TaskConsumer::notify(), CacheInvalidatee::notify(), Hierarchy::propogate(), ClusterThread::run(), ClusterQueue::run(), and PropertyConfigurator::this().


Member Function Documentation

Logger getRootLogger  )  [inline, static]
 

Return the root Logger instance. This is the ancestor of all loggers and, as such, can be used to manipulate the entire hierarchy. For instance, setting the root 'level' attribute will affect all other loggers in the tree.

Definition at line 93 of file Logger.d.

Referenced by PropertyConfigurator::configure(), BasicConfigurator::defaultAppender(), and AdminServlet::setLoggerLevel().

Logger getLogger char[]  name  )  [inline, static]
 

Return an instance of the named logger. Names should be hierarchical in nature, using dot notation (with '.') to seperate each name section. For example, a typical name might be something like "mango.io.Buffer".

If the logger does not currently exist, it is created and inserted into the hierarchy. A parent will be attached to it, which will be either the root logger or the closest ancestor in terms of the hierarchical name space.

Definition at line 112 of file Logger.d.

Referenced by PropertyConfigurator::configure(), main(), AdminServlet::setLoggerLevel(), ServletContext::this(), and AdminServlet::this().

void trace char[]  msg  ) 
 

Add a trace messages. This is called 'debug' in Log4J but that is a reserved word in the D language. This needs some more thought.

Reimplemented from ILogger.

Reimplemented in LoggerInstance.

Referenced by AdminServlet::service().

void info char[]  msg  ) 
 

Add an info message

Reimplemented from ILogger.

Reimplemented in LoggerInstance.

Referenced by ServletContext::log(), main(), AdminServlet::setLoggerLevel(), and testHashMap().

void warn char[]  msg  ) 
 

Add a warning message

Reimplemented from ILogger.

Reimplemented in LoggerInstance.

void error char[]  msg  ) 
 

Add an error message

Reimplemented from ILogger.

Reimplemented in LoggerInstance.

Referenced by ServletContext::log(), and VersionMango::testRollingFileLog().

void fatal char[]  msg  ) 
 

Add a fatal message

Reimplemented from ILogger.

Reimplemented in LoggerInstance.

Referenced by main().

char [] getName  ) 
 

Return the name of this Logger

Reimplemented from ILogger.

Reimplemented in LoggerInstance.

Referenced by AdminServlet::service().

Level getLevel  ) 
 

Return the current level assigned to this logger

Reimplemented from ILogger.

Reimplemented in LoggerInstance.

Referenced by AdminServlet::service().

void setLevel Level  level  ) 
 

Set the activity level of this logger. Levels control how much information is emitted during runtime, and relate to each other as follows:

Trace < Info < Warn < Error < Fatal < None

That is, if the level is set to Error, only calls to the error() and fatal() methods will actually produce output: all others will be inhibited.

Note that Log4J is a hierarchical environment, and each logger defaults to inheriting a level from its parent.

Reimplemented from ILogger.

Reimplemented in LoggerInstance.

Referenced by AdminServlet::addLogger(), PropertyConfigurator::configure(), BasicConfigurator::configure(), and AdminServlet::setLoggerLevel().

void setLevel Level  level,
bool  force
 

same as setLevel (Level), but with additional control over whether the children are forced to accept the changed level or not. If 'force' is false, then children adopt the parent level only if they have their own level set to Level.None

Reimplemented from ILogger.

Reimplemented in LoggerInstance.

bool isEnabled Level  level  ) 
 

Is this logger enabled for the provided level?

Reimplemented from ILogger.

Reimplemented in LoggerInstance.

bool isAdditive  ) 
 

Return whether this logger uses additive appenders or not. See setAdditive().

Reimplemented from ILogger.

Reimplemented in LoggerInstance.

void setAdditive bool  enabled  ) 
 

Specify whether or not this logger has additive behaviour. This is enabled by default, and causes a logger to invoke all appenders within its ancestry (until an ancestor is found with an additive attribute of false).

Reimplemented from ILogger.

Reimplemented in LoggerInstance.

void clearAppenders  ) 
 

Remove all appenders from this logger.

Reimplemented in LoggerInstance.

void addAppender Appender  appender  ) 
 

Add an appender to this logger. You may add multiple appenders to appropriate loggers, and each of them will be invoked for that given logger, and for each of its child loggers (assuming isAdditive() is true for those children). Note that multiple instances of the same appender, regardless of where they may reside within the tree, are not invoked at runtime. That is, only one from a set of identical loggers will execute.

Use clearAttributes() to remove all from a given logger.

Reimplemented in LoggerInstance.

Referenced by BasicConfigurator::defaultAppender(), and VersionMango::testRollingFileLog().

ulong getUptime  ) 
 

Get number of milliseconds since this application started

Reimplemented from ILogger.

Reimplemented in LoggerInstance.


Member Data Documentation

char [][] LevelNames [static]
 

Initial value:

 ["TRACE " "INFO " "WARN " 
                                      "ERROR " "FATAL " "NONE "]

Definition at line 81 of file Logger.d.


The documentation for this class was generated from the following file:
Generated on Sun Nov 7 19:07:07 2004 for Mango by doxygen 1.3.6