Boost logo

Boost Users :

Subject: [Boost-users] [Log 2.0] rotating files size limiation
From: Ovanes Markarian (om_boost_at_[hidden])
Date: 2014-01-13 07:05:50


Hello *,

I am a bit stuck to implement a very simple scenario with boost log. I need
to limit the size of entire rotation log.

My current logger configuration looks like that:

void setup_logging( channel_settings_t const& settings
                    , std::string const& log_file
                    , std::string const& log_level
                    )
  {
    config_logger_attributes(logging::core::get(), settings, log_level);

    using namespace logging::aux::default_attribute_names;

    //add logging to file (which implicitly deletes the default console
logger)
    logging::add_file_log
    (
      keywords::auto_flush = true,
      keywords::open_mode = std::ios::out | std::ios::app,
      keywords::file_name = log_file+"_%N.log",
      keywords::rotation_size = 50 * 1024, // Just for test limit to 50K
      keywords::format = //"%TimeStamp%: [%Channel%] |ThreadId|
<%Severity%> %Message%"
        expr::format("%1% : [%2%] |%3%| <%4%> %5%")
        % expr::attr< boost::posix_time::ptime >(timestamp())
        % expr::attr<std::string>(channel())
        % expr::attr<attrs::current_thread_id::value_type>(thread_id())
        % trivial::severity
        % expr::smessage
    )->locked_backend()->set_file_collector
       ( sinks::file::make_collector
         ( keywords::target = "logs"
         , keywords::max_size = 200 * 1024 // just for test limit to 200K
         )
       )
    ;
  }

Unfortunately, I can't find what the target keyword means, despite the fact
that it is a target directory. Target directory relating to smth or should
there be a full path? Should this target directory exist? I did a test and
rotating log files just grow upon the 200K limit.

I just want to have let's say 3 or 4 last rotated log files, the rest
should be removed? We already ran into the situation, where the logger used
all disc space and the server crashed :(

Any help if very appreciated!

Thanks,
Ovanes



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net