Opened 6 years ago

Last modified 6 years ago

#12684 new Bugs

Application crashing when collector maximum size is reached

Reported by: ketan0712@… Owned by: Andrey Semashev
Milestone: To Be Determined Component: log
Version: Boost 1.61.0 Severity: Problem
Keywords: BOOST Cc:

Description

0 down vote favorite I am using BOOST for my Logger API. I have a scenario when the maximum size of collector is reached it should stop logging. but currently the application is crashing.

Example: maximum size of collector = 10MB and Maximum file size =4MB so it generates two files with size 4MB each and 1 with 2MB and the application should stop but its crashing here.

Code is given below: sink = boost::make_shared<file_sink>(keywords::file_name = file_name,

keywords::rotation_size = m_maxLogFileSize, keywords::open_mode = std::ios_base::out | std::ios_base::app, keywords::auto_flush = true );

try{

sink->locked_backend()->set_file_collector(sinks::file::make_collector(keywords::target = m_dirLocation, keywords::max_size = 1 * 1024)); m_maxLogFileSize)); sink->locked_backend()->set_file_collector(sinks::file::make_collector(keywords::target = m_dirLocation, keywords::max_size = 10 * 1024 *1024, keywords::min_free_space = 1024));

} catch (exception e) {

std::cout << "Maximum size reached in collector" << std::endl;

}

sink->set_formatter(

expr::stream << expr::format_date_time< boost::posix_time::ptime >("TimeStamp", m_timeFormat) << m_logSeparator << "[" << expr::attr< boost::log::trivial::severity_level >("Severity") << "]" << m_logSeparator << " " << expr::attr< boost::thread::id >("ThreadID") << m_logSeparator << " " << expr::attr<std::string>("FileName") << "" << ":" << expr::attr<int>("Line") << m_logSeparator << " " << expr::attr<std::string>("Function") << m_logSeparator << " " << expr::xml_decor[expr::stream << expr::smessage]

);

sink->locked_backend()->scan_for_files(); sink->locked_backend()->auto_flush(true);

Add the sink to the core logging::core::get()->add_sink(sink);

Change History (2)

comment:1 by Kohei Takahashi, 6 years ago

Component: Nonelog
Owner: set to Andrey Semashev

comment:2 by Andrey Semashev, 6 years ago

  1. max_size limit does not cause logging to stop. Rather it forces deletion of the oldest file to free space for the new one, when the next file rotation happens.
  1. Please, attach the complete compilable test case that reproduces the problem. Also please specify your compiler and platform.
Note: See TracTickets for help on using tickets.