Boost C++ Libraries

Next

Chapter 1. Boost.Log v2

Andrey Semashev

Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt).

Table of Contents

Motivation
How to read the documentation
Installation and compatibility
Supported compilers and platforms
Configuring and building the library
Definitions
Design overview
Tutorial
Trivial logging
Trivial logging with filters
Setting up sinks
Creating loggers and writing logs
Adding more information to log: Attributes
Log record formatting
Filtering revisited
Wide character logging
Detailed features description
Core facilities
Logging sources
Sink frontends
Sink backends
Lambda expressions
Attributes
Utilities
Extending the library
Writing your own sinks
Writing your own sources
Writing your own attributes
Extending library settings support
Rationale and FAQ
Why string literals as scope names?
Why scoped attributes don't override existing attributes?
Why log records are weakly ordered in a multithreaded application?
Why attributes set with stream manipulators do not participate in filtering?
Why not using lazy streaming?
Why not using hierarchy of loggers, like in log4j? Why not Boost.Log4j? Etc.
Does Boost.Log support process forking?
Does Boost.Log support logging at process initialization and termination?
Why my application crashes on process termination when file sinks are used?
Why my application fails to link with Boost.Log? What's the fuss about library namespaces?
Why MSVC 2010 fails to link the library with error LNK1123: failure during conversion to COFF: file invalid or corrupt?
Reference
Top level headers
Core components
Attributes
Expressions
Logging sources
Sinks
Utilities
Other libraries support layer
Changelog
TODO in future releases
Acknowledgments

Today applications grow rapidly, becoming complicated and difficult to test and debug. Most of the time applications run on a remote site, leaving the developer little chance to monitor their execution and figure out the reasons for their failure, once it should happen. Moreover, even the local debugging may become problematic if the application behavior depends heavily on asynchronous side events, such as a device feedback or another process activity.

This is where logging can help. The application stores all essential information about its execution to a log, and when something goes wrong this information can be used to analyze the program behavior and make the necessary corrections. There are other very useful applications of logging, such as gathering statistical information and highlighting events (i.e. indicating that some situation has occurred or that the application is experiencing some problems). These tasks have proved to be vital for many real-world industrial applications.

This library aims to make logging significantly easier for the application developer. It provides a wide range of out-of-the-box tools along with public interfaces for extending the library. The main goals of the library are:

  • Simplicity. A small example code snippet should be enough to get the feel of the library and be ready to use its basic features.
  • Extensibility. A user should be able to extend functionality of the library for collecting and storing information into logs.
  • Performance. The library should have as little performance impact on the user's application as possible.

Next