[bind10-dev] Logging initialization
Stephen Morris
stephen at isc.org
Fri Jun 17 13:24:53 UTC 2011
There seems to be a little confusion around initializing logging, so...
All production programs are expected to call
isc::log::initLogger(<progname>) early in their initialization. This
initializes the logging to send output to stdout and sets the root
logger name to <progname>. (The root logger name is included in messages
to allow identification of their source.) Additional arguments allow
the default severity and debug level to be set: for example, the
severity of messages logged could be set to DEBUG if the "-v" switch
were provided.
A second version of the function is isc::log::initLogger(<severity>)
where <severity> is one of the constants defined in logger_level.h and
controls the severity of messages output. (Currently it defaults to
isc::log:INFO.) With this form, certain aspects of the logging can be
controlled with environment variables:
B10_LOGGER_ROOT
Sets the name of the root logger in messages. If not defined, the
string "bind10" is used.
B10_LOGGER_SEVERITY
One of DEBUG, WARN, INFO, ERROR, FATAL or NONE. Regardless of what was
given in the call to initLogger(<severity>), if this environment
variable is defined it overrides that value: only messages of the
defined severity (or greater) will be output. Messages are suppressed
if it is set to NONE.
B10_LOGGER_DBGLEVEL
Only relevant if the chosen severity is DEBUG, this sets the debug
level, which is a number between 0 and 99. The higher the number, the
more detailed the level of debug messages output.
B10_LOGGER_LOCALMSG
If set, this is the name of a file that contains local message definitions.
The intention is that the first form is used in programs where the final
logging configuration will be obtained from the configuration database
and where the presence or absence of environment variables should not
affect behaviour. The second form is aimed at unit tests when some
control can be exercised over the logging in the absence of the database.
Stephen
More information about the bind10-dev
mailing list