Opened 7 years ago
Closed 7 years ago
#11719 closed Support Requests (worksforme)
Create a log file only if some data is written to it
Reported by: | Owned by: | Andrey Semashev | |
---|---|---|---|
Milestone: | To Be Determined | Component: | log |
Version: | Boost 1.59.0 | Severity: | Problem |
Keywords: | Cc: |
Description
I am creating a log file using
src::severity_logger< severity_level > m_DbLogger; logging::add_file_log (
keywords::auto_flush = true, keywords::file_name = m_Settings.LogFileSQL + "_diagnostics.log", keywords::time_based_rotation = sinks::file::rotation_at_time_point(0, 0, 0), keywords::format = (
boost::log::expressions::stream << boost::log::expressions::format_date_time< boost::posix_time::ptime >("TimeStamp", "%Y-%m-%d %H:%M:%S") << ": [" << boost::log::expressions::attr< severity_level >("Severity") << "] " << boost::log::expressions::smessage
)
);
It creates a log file before any log goes into it. I want to have that log file ONLY IF some data is written into it. If no log goes into it we dont want to see that log file.
Please suggest a solution for it.
Change History (2)
comment:1 by , 7 years ago
Severity: | Showstopper → Problem |
---|
comment:2 by , 7 years ago
Resolution: | → worksforme |
---|---|
Status: | new → closed |
The file is created when log records are passed to the sink. If that is not what happens in your case, please provide a minimal compilable code sample that reproduces the problem.