Boost.Log Configuration Files

后端 未结 1 1537
离开以前
离开以前 2021-02-14 07:38

I\'m adding logging to an old C++ program. After some research, I\'ve decided to use Boost Log . The documentation is filled with examples of creating sinks and filters. However

1条回答
  •  悲&欢浪女
    2021-02-14 08:22

    Eventually I found the official documentation, either it was added recently, or it is well hidden so that I didn't see it before:

    http://www.boost.org/doc/libs/1_57_0/libs/log/doc/html/log/detailed/utilities.html#log.detailed.utilities.setup.settings_file


    Unfortunately, I can't find an exhaustive answer neither, but some observations:

    Certainly it is possible to use a configuration file:

    boost::log::init_from_stream(std::basic_istream< CharT > &)

    Example of the file (from Boost log severity_logger init_from_stream):

    [Sinks.MySink]
    Destination=Console
    Format="%LineID%: <%Severity%> - %Message%"
    

    From the following link you can identify additional valid setting keys and values (e.g. Destination=TextFile, Filter=, AutoFlush=, FileName=)

    http://boost.2283326.n4.nabble.com/log-init-from-settings-problem-with-applying-format-and-filter-td3643483.html

    Constants in boost's parser_utils.hpp give another idea of keywords that are by default supported by the configuration file (E.g. section [Core] with key DisableLogging).

    Providing settings for user defined types is described here (with a corresponding snippet of the configuration file at the end of the page):

    http://www.boost.org/doc/libs/1_57_0/libs/log/doc/html/log/extension/settings.html

    It seems to me that it is difficult to find a description of the configuration file format entries because the valid entries are derived from the source code implementing the sinks, filters etc. This implementation may be even user defined so it is impossible to give explicit configuration format description.

    Maybe you can try to create your configuration in a programmatic way and when transforming it to the form of the configuration file, you can open separate questions for the particular properties that you are not able find out how to set them.

    0 讨论(0)
提交回复
热议问题