Installation | Topics | Beyond Lino

About logging

This document explains logging to a system administrator of a Lino production site.

Lino comes with a sophisticated framework for logging, which gets activated automatically. You can choose to not use it by defining your own LOGGING and LOGGING_CONFIG settings.

We assume that you have read the Django’s doc about Logging.

Developers will also want to read About logging.

The log directory

When a Lino process starts up, it checks whether there is a subdirectory named log in the local site directory. If such a directory exists, Lino automatically activates file logging to a file named lino.log in that directory. The log directory may be a symbolic link to a directory below /var/log/.

log

A subdirectory of a Lino site’s project directory that contains the lino.log file.

lino.log

The name of Lino’s logger file.

Default value is lino.log. You can change this name by setting the logger_filename attribute of your Site class.

Until 20160729 it was system.log.

On a production site you can have multiple processes running on a same site at the same time, which can lead to conflicts because these processes write to a same lino.log file. That’s why we also have a log server.

log server

A background process used when multiple processes need to write to a same lino.log file on a production site. Lino

Lino provides a built-in log server, which you must start by running the linod admin command.

Lino logging configuration

Some settings influence logging:

Setting the logging level via the environment

You can use environment variables LINO_LOGLEVEL LINO_FILE_LOGLEVEL to control the logging level.

LINO_LOGLEVEL

The logging level to use for both console and file handlers. It should be one of INFO, DEBUG etc.

LINO_FILE_LOGLEVEL

The logging level to use for file handlers (the lino.log file) when you want this to be different from LINO_LOGLEVEL. 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