Skip to content

Logging

Brian D. Burns edited this page Jan 30, 2013 · 7 revisions

Logging

Backup supports 3 different methods of logging messages during the backup process.

  • Console: Sending messages directly to the console.
  • Logfile: Storing all messages within Backup's own backup.log file.
  • Syslog: Sending messages to the system's Syslog compatible logger.

Each of these methods may be enabled/disabled via command line options, as covered on the Performing Backups page.

Additionally, these options may be configured within your config.rb file, along with other Global Configuration.

##
# Global Configuration
# Add more (or remove) global configuration below

# Shown here with their default values
Backup::Logger.configure do
  # Console options:
  console.quiet = false

  # Logfile options:
  logfile.enabled   = true
  logfile.log_path  = 'log'
  logfile.max_bytes = 500_000

  # Syslog options:
  syslog.enabled  = false
  syslog.ident    = 'backup'
  syslog.options  = Syslog::LOG_PID
  syslog.facility = Syslog::LOG_LOCAL0
  syslog.info     = Syslog::LOG_INFO
  syslog.warn     = Syslog::LOG_WARNING
  syslog.error    = Syslog::LOG_ERR
end

# Backup::Storage::S3.defaults do |s3|
#   s3.access_key_id     = "my_access_key_id"
#   s3.secret_access_key = "my_secret_access_key"
# end
#
# etc...

Console Options

Backup::Logger.configure do
  console.quiet = true
end

console.quiet

Setting this to true is equivalent to using --quiet on the command line.

Using --no-quiet on the command line would override this setting in config.rb.

Messages of type :info are sent on STDOUT. Messages of type :warn and :error are sent on STDERR.

Logfile Options

Backup::Logger.configure do
  logfile.enabled   = true
  logfile.log_path  = 'log'
  logfile.max_bytes = 500_000
end

logfile.enabled

Setting this to true is equivalent to using --logfile on the command line. This is true by default, so the use of --logfile on the command line is not necessary.

Setting this to false will disable the use of Backup's backup.log file. This may also be accomplished using the --no-logfile command line switch.

Use of --no-logfile on the command line would override a setting of true in the config.rb.

When disabled, --log-path will not be used or created.

logfile.log_path

Setting this is equivalent to using the --log-path command line option. By default, this is set to 'log'.

This may be set to an absolute path, or a path relative to --root-path. Therefore, if --root-path is using it's default of ~/Backup, this would place the backup.log file in ~/Backup/log.

If a path is specified using the --log-path command line option, any setting here will be ignored.

logfile.max_bytes

Before each backup perform command is run, the backup.log file will be truncated, leaving only the most recent entries. By default, max_bytes is set to 500K.

Note that truncation only occurs once before all models matching the given trigger(s) are performed.

Syslog Options

Backup::Logger.configure do
  syslog.enabled  = false
  syslog.ident    = 'backup'
  syslog.options  = Syslog::LOG_PID
  syslog.facility = Syslog::LOG_LOCAL0
  syslog.info     = Syslog::LOG_INFO
  syslog.warn     = Syslog::LOG_WARNING
  syslog.error    = Syslog::LOG_ERR
end

syslog.enabled

Setting this is equivalent to using the --syslog command line option. This is false by default.

Use of the --no-syslog command line option will override any setting in config.rb.

Note

Messages sent to Syslog are sent without a timestamp or severity level within the message text, since Syslog will provide these.

For example, messages logged to the Console or Logfile will be sent as:

[YYYY/MM/DD HH:MM:SS][level] message line text

Whereas messages sent to Syslog will simply be sent as:

message line text

syslog.ident

By default, this is set to 'backup'.

Be sure to check with your logger's documentation for any restrictions.

syslog.options

By default this is set to Syslog::LOG_PID.

Note that setting this to nil would cause Syslog to default to LOG_PID | LOG_CONS.

See the Syslog.open documentation for acceptable values.

syslog.facility

By default this is set to Syslog::LOG_LOCAL0.

Note that setting this to nil would cause Syslog to default to LOG_USER.

See the Syslog.open documentation for acceptable values.

syslog.info, syslog.warn, syslog.error

By default, these are set to Syslog::LOG_INFO, Syslog::LOG_WARNING and Syslog::LOG_ERR.

See the Syslog.log documentation for acceptable values.