File
datefileoutputter.rb
Path: log4r/outputter/datefileoutputter.rb
Modified: Wed Mar 17 11:13:07 PST 2004

DateFileOutputter

Subclass of FileOutputter that changes the log file daily. When a new day begins, a new file is created with the date included in the name.

Usage

  df_out = DateFileOutputter.new('name',
             :dirname="/tmp", :date_pattern=>"%m-%d"
           )

Rate of Change

A new logfile is created whenever the current time as formatted by the date pattern no longer matches the previous time. (This is a simple String comparison.) So, in order to change the frequency of the rollover, just alter the date pattern to match how fast the files should be generated. For instance, to generate files by the minute,

  df_out.date_pattern = "%M"

This causes the following files to show up one minute apart, asuming the script starts at the 4th minute of the hour:

  file_04.rb
  file_05.rb
  file_06.rb
  ...

The only limitation of this approach is that the precise time cannot be recorded as the smallest time interval equals the rollover period for this system.

Required files

log4r/outputter/fileoutputter log4r/staticlogger
Classes and Modules

Module Log4r
  ::Class Log4r::BasicFormatter
  ::Class Log4r::ConfigError
  ::Class Log4r::Configurator
  ::Class Log4r::DateFileOutputter
  ::Class Log4r::DefaultFormatter
  ::Class Log4r::EmailOutputter
  ::Class Log4r::FileOutputter
  ::Class Log4r::Formatter
  ::Class Log4r::IOOutputter
  ::Class Log4r::Log4rTools
  ::Class Log4r::LogEvent
  ::Class Log4r::LogServer
  ::Class Log4r::Logger
  ::Class Log4r::ObjectFormatter
  ::Class Log4r::Outputter
  ::Class Log4r::PatternFormatter
  ::Class Log4r::RemoteOutputter
  ::Class Log4r::RollingFileOutputter
  ::Class Log4r::RootLogger
  ::Class Log4r::SimpleFormatter
  ::Class Log4r::StderrOutputter
  ::Class Log4r::StdoutOutputter
  ::Class Log4r::SyslogOutputter
  ::Class Log4r::YamlConfigurator