Module: Apache::Logging

Included in:
Config
Defined in:
lib/apache/logging.rb

Overview

Methods to handle logging configuration are defined here.

For each of the four main log types (Custom, Error, Script, and Rewrite), the following two methods are created:

  • (type)_log: A non-rotated log file

  • rotate_(type)_log: A rotated log file

Non-rotated logs work as such:

custom_log "/path/to/log/file.log", :common #=> CustomLog "/path/to/log/file.log" common

Rotated logs work as such:

rotate_custom_log "/path/to/log/file-%Y%m%d.log", 86400, :common
  #=> CustomLog "|/path/to/rotatelogs /path/to/log/file-%Y%m%d.jpg 86400" common

Both variations check to make sure the log file diretory exists during generation. The rotate_ variations need @rotate_logs_path set to work.

Instance Method Summary collapse

Instance Method Details

#combined_log_format(name = 'combined') ⇒ Object



36
37
38
# File 'lib/apache/logging.rb', line 36

def combined_log_format(name = 'combined')
  log_format '%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"', name.to_sym
end

#common_log_format(name = 'common') ⇒ Object



40
41
42
# File 'lib/apache/logging.rb', line 40

def common_log_format(name = 'common')
  log_format '%h %l %u %t \"%r\" %>s %b', name.to_sym
end