Versiones comparadas

Clave

  • Se ha añadido esta línea.
  • Se ha eliminado esta línea.
  • El formato se ha cambiado.
Sección
Columna

Loggers and Appenders

Logging system has two components: loggers and appenders. These types of components enable users to log messages according to message type and level andcontrol at runtime where they are reported.

Loggers

The first and foremost advantage of this system resided in the ability to disable certain log statements while allowing others to print unhindered.
This capability assumes that the loggers are categorized according to some developer-chosen criteria.

Loggers are named entitites. Logger names are case-sensitive and they follow the hierarchical naming rule:

A Logger is said to be an ancestor of another logger if its name followed by a dot is a prefix of the descendant logger name. A logger is said to be a parent of a child logger if there are no ancestors between itself and the
descendant logger.

For example, the logger named "entities.player" is a parent of the logger named "entities.player.character". Similarly, "entities" is a parent of "entities.player" and an ancestor of "entities.player.character".

Loggers may be assigned levels. The set of possible levels are TRACE, DEBUG, INFO, WARN, ERROR AND FATAL, or be disabled using level DISABLED.

By definition the printing method determines the level of a logging request. For example, TC_LOG_INFO(...) is a logging request of level INFO.

A logging request is said to be enabled if its level is higher than or equal to the level of its logger. Otherwise, the request is said to be disabled. A logger without an assigned level will inherit one from the hierarchy.

Example

Logger NameAssigned LevelInherited Level
rootProotProot
serverNoneProot

 

As "server" is not defined, it uses the root logger and it's log level.
TRACE < DEBUG < INFO < WARN < ERROR < FATAL.

Columna
width20%
Panel
borderStyledashed

Tabla de contenidos

Logging system "log4j-like"

Tabla de contenidos

Appenders

The ability to selectively enable of dissable logging request based on their loggers is only part of the picture. This system allows logging requests to print to multiple destinations. An output destination is called an appender.
Current system defines appenders for Console, files and Database, but can be easily extended to remote socket server, NT event loggers, syslog daemons or any other system.

...