Boost C++ Libraries of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

This is the documentation for an old version of Boost. Click here to view this page for the latest version.

Function template add_file_log



// In header: <boost/log/utility/setup/file.hpp>

template<typename... ArgsT> 
  shared_ptr< sinks::synchronous_sink< sinks::text_file_backend > > 
  add_file_log(ArgsT...const & args);


The function initializes the logging library to write logs to a file stream.



A number of named arguments. The following parameters are supported:

  • file_name The file name or its pattern. This parameter is mandatory.

  • open_mode The mask that describes the open mode for the file. See std::ios_base::openmode.

  • rotation_size The size of the file at which rotation should occur. See basic_text_file_backend.

  • time_based_rotation The predicate for time-based file rotations. See basic_text_file_backend.

  • auto_flush A boolean flag that shows whether the sink should automatically flush the file after each written record.

  • target The target directory to store rotated files in. See sinks::file::make_collector.

  • max_size The maximum total size of rotated files in the target directory. See sinks::file::make_collector.

  • min_free_space Minimum free space in the target directory. See sinks::file::make_collector.

  • scan_method The method of scanning the target directory for log files. See sinks::file::scan_method.

  • filter Specifies a filter to install into the sink. May be a string that represents a filter, or a filter lambda expression.

  • format Specifies a formatter to install into the sink. May be a string that represents a formatter, or a formatter lambda expression (either streaming or Boost.Format-like notation).


Pointer to the constructed sink.