About logging

This document explains everything you need to know about logging for Lino applications.

We presume that you have read the Django's doc about Logging.

The Lino application log

log

When a Lino process starts up and sees a subdirectory named log in the project directory, then it automatically starts logging.

The main logger file

lino.log
system.log

The name of Lino's main logger file Default value is lino.log. Until 20160729 it was system.log.

Setting the log level via the environment

LINO_LOGLEVEL

If an environment variable LINO_LOGLEVEL is set, then it should contain the log level to use for both console and file handlers. It should be one of INFO, DEBUG etc.

Configuring logrotate

To activate logging to a file, you simply add a symbolic link named log which points to the actual location:

$ sudo mkdir -p /var/log/lino/
$ sudo chown :www-data /var/log/lino/
$ sudo chmod g+ws /var/log/lino/
$ sudo mkdir /var/log/lino/prj1/
$ cd ~/mypy/prj1/
$ ln -s /var/log/lino/prj1/ log/

We recommend a file /etc/logrotate.d/lino with something like:

/path/to/lino_sites/prod/log/lino.log {
        weekly
        missingok
        rotate 156
        compress
        delaycompress
        notifempty
        create 660 root www-data
        su root www-data
        sharedscripts
}

After changes in the config you can tell logrotate to force them:

$ sudo logrotate -f /etc/logrotate.d/lino

Logging all bash commands to syslog

Add the following to your system-wide /etc/bash.bashrc:

# copied from http://backdrift.org/logging-bash-history-to-syslog-using-traps
function log2syslog
{
   declare COMMAND
   COMMAND=$(fc -ln -0)
   logger -p local1.notice -t bash -i -- "${USER}:${COMMAND}"
}
trap log2syslog DEBUG