Neptune Logging
1 Overview
Neptune includes a logging framework that allows client code to log certain events. Application
code uses the logging macros to log events through logger objects.
Logger objects have a unique name and are responsible for dispatching log events through the
logging framework.
A log event has a log level that indicates a notion of priority or severity, a source filename, a
source line number, and a message.
Loggers encapsulate event information in an event record, which contains all the parameters
supplied by the client, as well as a timestamp and the name of the logger through which the event
was initially dispatched.
Loggers are organized in a hierarchical tree structure. Each logger has its own configuration that
includes a log level used to filter log events (a logger will only dispatch log events which have a
log level equal or higher to the logger’s log level), one or more handlers, and a parent logger.
Loggers will, by default, forward all of their log event records to their parent logger, unless their
configuration specifies not to forward records. When a logger is not configured with its own log
level, it inherits the log level of its parent.
The parent-child relationship of loggers is determined by the name of the loggers. A logger name
is a list of one or more name fragments separated by a dot. The parent of a logger is the logger
with the name equal to that logger’s name excluding the last name fragment (for example, the
parent of the logger named ‘neptune.test.foo’ is named ‘neptune.test’). The framework supplies a
root logger as an ancestor of all other loggers in the system. The root logger’s name is an empty
string.
Log handlers are responsible for formatting log event records and publishing them. The
framework includes built-in handlers, including a handler that formats log event records as text
and writes them to a file or to the console, and a handler that formats log event records as a
message and sends it to a logging console over a network connection.
Logger objects are automatically created on behalf on the client code the first time they are used.
They are automatically destroyed when the application exits.
The configuration of all the loggers in the system, including their log levels, list of handlers, and
handler options (such as the name of the file to write to for file-based log handlers) is encoded in
a logging configuration file and/or in a property list. The configuration source for the system can
be specified at compile time, or at runtime through the use of environment variables.
- 1
- 2
- 3
前往页