boost-log

Experience using Boost.Log logging library? [closed]

让人想犯罪 __ 提交于 2019-11-30 10:20:07
问题 As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 6 years ago . I am considering starting to use the Boost.Log logging library. Is anyone using Boost.Log? Please share your experiences in this

boost log to print source code file name and line number

故事扮演 提交于 2019-11-30 03:39:40
I'm using Boost(1.55.0) Logging in my C++ application. I have been able to generate log of this format [2014-Jul-15 10:47:26.137959]: <debug> A regular message I want to be able to add source file name and line number where the log is generated. [2014-Jul-15 10:47:26.137959]: <debug> [filename:line_no] A regular message example: [2014-Jul-15 10:47:26.137959]: <debug> [helloworld.cpp : 12] A regular message Source Code: #include <boost/log/core.hpp> #include <boost/log/trivial.hpp> #include <boost/log/expressions.hpp> #include <boost/log/sinks/text_file_backend.hpp> #include <boost/log/utility

Boost log severity_logger init_from_stream

走远了吗. 提交于 2019-11-29 18:01:47
问题 I am using boost 1.54.0. Below you can find a minimum example that illustrates my problem. I use the severity_logger of boost log. I want to configure my sinks from a stream. (In the following example I use a stringstream. In my real application the stream comes from a file.) I want to use the %Severity% for output or filtering purposes. My problem is: If I use it as given in the example below, %Severity% is empty. %LineID% and %Message% are filled as expected. If I set up a sink as given in

Boost.Log: Support file name and line number

爱⌒轻易说出口 提交于 2019-11-29 15:34:34
问题 I am trying to make my team go away from log4cxx and try to use Boost.Log v2 instead. Our current log4cxx pattern is rather simple: log4cxx::helpers::Properties prop; prop.setProperty("log4j.rootLogger","DEBUG, A1"); prop.setProperty("log4j.appender.A1","org.apache.log4j.ConsoleAppender"); prop.setProperty("log4j.appender.A1.layout","org.apache.log4j.PatternLayout"); prop.setProperty("log4j.appender.A1.layout.ConversionPattern","%d{ABSOLUTE} %-5p [%c] %m%n"); log4cxx::PropertyConfigurator:

Log file is not getting created

我与影子孤独终老i 提交于 2019-11-29 13:06:16
I need a global logger that I can use across multiple classes in my project. I want to have logger settings in an ini file. I start following example here and combined it with some suggestions at my earlier question here . My Logger.h is as follows. #pragma once #include <boost/log/common.hpp> #include <boost/log/attributes.hpp> #include <boost/log/utility/setup/from_stream.hpp> #include <boost/regex.hpp> #include <boost/log/expressions.hpp> #include <boost/log/sources/global_logger_storage.hpp> #include <boost/log/support/date_time.hpp> #include <boost/log/trivial.hpp> #include <boost/log

Problems Linking boost log 1_60 with MinGw on Windows 7

感情迁移 提交于 2019-11-29 11:18:28
On upgrading to boost 1.60.0 some applications are failing to link with boost log when built with MinGw 4.9.2 on Windows 7. I get the following linker errors: undefined reference to `_imp___ZN5boost3log9v2_mt_nt67trivial6logger3getEv' undefined reference to `_imp___ZN5boost3log9v2_mt_nt63aux15stream_providerIcE17allocate_compoundERNS1_6recordE' undefined reference to `_imp___ZN5boost3log9v2_mt_nt63aux25unhandled_exception_countEv' undefined reference to `_imp___ZN5boost3log9v2_mt_nt611record_view11public_data7destroyEPKS3_' bad reloc address 0x1 in section `.text$

Boost.log: How to prevent the output will be duplicated to all added streams when it uses the add_file_log() function?

风格不统一 提交于 2019-11-29 07:00:25
I use the add_file_log() function to initialize a logging sink that stores log records into a text file. When I define several sinks, I have observed: a file is created for each sink. the output is copied to all files. This is my logger: class logger { public: logger(const logger&) =delete; logger(logger&&) =delete; logger& operator=(const logger&) =delete; logger& operator=(logger&&) =delete; static logger& get_instance( const std::string& file, bool console ) { boost::log::register_simple_formatter_factory< boost::log::trivial::severity_level, char >("Severity"); std::string the_format = "[

Cast a boost::log::expressions::attr< std::string > to std::string

北战南征 提交于 2019-11-29 02:36:38
While using Boost.Log, I am trying to keep my TimeStamp formatter such as: logging::add_file_log ( keywords::file_name = "my.log", keywords::format = ( expr::stream << expr::format_date_time< boost::posix_time::ptime >("TimeStamp", "%Y-%m-%d %H:%M:%S") << "," << expr::attr< int >("Line") << " " << expr::attr< std::string >("File") << " " << logging::trivial::severity << " - " << expr::smessage ) ); It is said that I cannot use the other form of formatter since I'll have much difficulties turning "TimeStamp" into my custom format: static void my_formatter(logging::record_view const& rec,

Boost.Log with CMake causing undefined reference error

一个人想着一个人 提交于 2019-11-28 21:15:51
I am trying to use the new Boost.Log library in a project I am working on. The project is built with CMake. I am receiving link errors claiming that the linker has come across undefined references to Boost.Log Linking CXX executable main CMakeFiles/main.dir/main.cpp.o: In function `main': main.cpp:(.text+0x30): undefined reference to `boost::log::v2s_mt_posix::trivial::logger::get()' I have a simple hello world test that fails with these errors. If I am linking against the Boost.Log libraries what would cause it to generate an undefined reference error? main.cpp: #include <boost/log/trivial

Boost Log 2.0 : empty Severity level in logs

不问归期 提交于 2019-11-28 20:22:30
I'm using Boost-Log 2.0, which has some differences from version 1, and I have a hard time outputting the "Severity" attribute. I'm using the "Boost.Format-style" formatters "%TimeStamp% [%Uptime%] (%LineID%) <%Severity%>: %Message%" TimeStamp , LineID , and Message are common_attributes . Uptime is an attribute I added using attrs::timer() . I thought that Severity was automatically added when using severity_logger , but apparently it isn't and that's my problem. I get empty severities, eg: 2013-Apr-06 19:21:52.408974 [00:00:00.001337] (3) <>: A warning severity message Notice the empty <> .