Skip to content
Charlie McConnell edited this page Jun 10, 2014 · 6 revisions

Logging for Safewallet

Rotating your logs to s3

  • First, set up s3cmd - this is as simple as installing it from your package manager, and running s3cmd --configure. You'll need an s3 account and your access keys.
  • Create a logrotate config file for safewallet in /etc/logrotate.d/safewallet:
$SAFEWALLET_LOGS_DIR/* {
    daily
    rotate 7
    notifempty
    nocreate
    copytruncate
    compress
    delaycompress
    dateext
    dateformat -%Y-%m-%d
    lastaction
        /usr/bin/s3cmd sync $SAFEWALLET_LOGS_DIR/*.gz s3://$YOUR_BUCKET_NAME/archived-logs/
    endscript
}

Note that you'll need to add your actual path name and bucket name in place of the variables above. Another thing to note is that s3 uses the /logs/ key to store its own access logs, so we have chosen /archived-logs/ above.

  • Next, do a test dry run with logrotate /etc/logrotate.d/safewallet -dv - make sure there are no errors.
  • Finally, run your first rotation manually with logrotate /etc/logrotate.d/safewallet -fv to make sure that logrotate handles the safewallet logs on its next execution.

Because this configuration uses the delaycompress option, files will not be compressed until their second rotation. For example:

# After one rotation:
ls logs/
today.log  today.log-2014-06-08

#After two rotations:
ls logs/
today.log  today.log-2014-06-09 today.log-2014-06-08.gz

Log files are compressed with gzip by default. To decompress, run gunzip file.gz and the file will be decompressed in place.

Clone this wiki locally