boost-log

Boost::Log and log numbering

不羁岁月 提交于 2019-12-06 10:04:33
问题 I've recently tried to add some logging via Boost log to a small application. However, using log rotation I can't for some reason get it to pick up the correct counter in the logs directory. For example, if my Logs directory contains the files Log_000.log and Log_001.log I'd expect the logging to start with Log_002.log but it always starts again from 0. I'm probably missing something but if anyone can spot something I'd be grateful. Here's my startup code: void initLogging() { boost::log::add

Boost Log causes crash when trying first log statement (when not Administrator)

[亡魂溺海] 提交于 2019-12-06 05:33:13
问题 I am trying to deploy my application right now, which uses Boost Log (Boost 1.58). It is a simple console app, being run in Windows 7. Logging works perfectly fine on my personal desktop. However, when I deploy the application to a Win7 virtual machine, it crashes upon my first log statement: boost::log::sources::severity_logger<SeverityLevel> slg; BOOST_LOG_SEV(slg, SeverityLevel::Notification) << L"Application loaded"; // <-- Crash here The log directory gets created, but the log file never

How can I manually flush a boost log?

ぐ巨炮叔叔 提交于 2019-12-06 04:13:03
问题 I'm playing with Boost.Log in boost 1.54.0 to see if it is a viable option for my application. In general, I don't have a problem with the buffering, so I'm not looking to turn on auto_flush or anything... but I noticed that messages that are logged before I call fork() are duplicated, and I'm wondering if it's because they are buffered, the buffer gets duplicated when the process image is copied, and then both processes eventually write their buffer copies to the log file... So basically, I

Boost Log changing the default logging::core formatter?

丶灬走出姿态 提交于 2019-12-06 03:46:14
I'm using Boost v1.54 and I would like to simply change the default sink format of logging::core but haven't found a way to do so. In the Log Record Formatting documentation they only show how to change the format for custom sinks e.g. log files and not the default one? Is there a way to globally set the default format in Boost Log? This is what they do: void init() { logging::add_file_log ( keywords::file_name = "sample_%N.log", keywords::rotation_size = 10 * 1024 * 1024, keywords::time_based_rotation = sinks::file::rotation_at_time_point(0, 0, 0), keywords::format = "[%TimeStamp%]: %Message%

How can I redirect output to a boost log?

筅森魡賤 提交于 2019-12-06 01:55:28
I have a C++ program that uses boost log, and I load a user-provided dynamic link library. I'd like to redirect stderr to the boost log, so that anytime the user's library does: std::cerr << "Some stuff"; It produces the same result** as: BOOST_LOG_SEV(log,info) << "Some stuff"; Is this possible, and if so then how do I do it? (Also, I'm not sure what to do about the severity... since cerr << doesn't privide severity information. I'm open to suggestions on that as well...) ** By "same result" I mean that it gets logged to the same log file as the rest of the log messages, and the same log

Boost Thread Access Violation in Boost Log on shutdown

两盒软妹~` 提交于 2019-12-05 15:29:17
I have an application that uses boost logging. During shutdown, it gets an access violation on a null pointer access. When I step through the code to the point of failure, it appears that the boost::log dll is being de-allocated and then boost::thread code tries to access the memory that was once occupied by the log dll. I am not using any boost threads in my own code, and so assume the boost-thread dll is used by boost log. To ensure all sinks are destroyed prior to shutdown, I am calling: core->flush() and core->remove_all_sinks() I am using boost 1.60 and have also tried this with boost 1

how to customize “TimeStamp” format of Boost.Log

元气小坏坏 提交于 2019-12-05 00:04:12
I want to get year-month-day hour:minute:second.fraction(2 digits), if I use "%Y-%m-%d %H:%M:%S.%f", I got almost what I want exception for the fraction( last part ) of seconds, it's showing 6 digits on my Windows XP, I don't know how to get 2 digits only, any idea? Boaz Yaniv Boost.DateTime (upon which Boost.Log relies) doesn't seem to support specialized fractional seconds formatting, so the only way to do that would be to write your own custom attribute formatter, or (the easier, but less nice way) to slightly modify your formatting code. Instead of something like this: backend->set

boost log format single attribute with logging::init_from_stream

狂风中的少年 提交于 2019-12-04 16:34:00
When I set up format params in code, to format date time output I can use something like this logging::formatter simpleFormat(expr::format("%1% %2%") % expr::format_date_time<boost::posix_time::ptime>("TimeStamp", "%H:%M:%S") % expr::smessage ); But when I initialize logger with a config file, I can specify format only in attributes position notation, not their format details. so, this line in a boost log config file Format="[%TimeStamp%]: %Message%" produces output: [2015-Feb-06 09:32:27.401496]: blah blah blah I want to reduce timestamp to something like this [06.02.2015 09:32:27] How can it

Boost::Log and log numbering

空扰寡人 提交于 2019-12-04 13:00:59
I've recently tried to add some logging via Boost log to a small application. However, using log rotation I can't for some reason get it to pick up the correct counter in the logs directory. For example, if my Logs directory contains the files Log_000.log and Log_001.log I'd expect the logging to start with Log_002.log but it always starts again from 0. I'm probably missing something but if anyone can spot something I'd be grateful. Here's my startup code: void initLogging() { boost::log::add_common_attributes(); auto core = boost::log::core::get(); core->add_global_attribute("UTCTimeStamp"

Unresolved external when using boost log

时光总嘲笑我的痴心妄想 提交于 2019-12-04 12:52:59
I'm having problem while trying to use boost log. I'm getting following error message: 1>------ Build started: Project: vms, Configuration: Release x64 ------ 1> main.cpp 1> Linking to lib file: libboost_system-vc140-mt-1_60.lib 1> Linking to lib file: libboost_date_time-vc140-mt-1_60.lib 1> Linking to lib file: libboost_regex-vc140-mt-1_60.lib 1> Linking to lib file: libboost_log-vc140-mt-1_60.lib 1> Linking to lib file: libboost_filesystem-vc140-mt-1_60.lib 1> Linking to lib file: libboost_date_time-vc140-mt-1_60.lib 1> Linking to lib file: libboost_thread-vc140-mt-1_60.lib 1> Linking to lib