Installation | Topics | Beyond Lino
About logging¶
Lino comes with a mature default configuration for logging that is designed to work out of the box.
This document explains logging to a system administrator of a Lino production site. Developers might also want to read About logging.
The default logging config¶
The Lino default configuration makes a production site log to the
systemd journal with the site’s project_name as syslog identifier.
How to watch the latest 100 log entries of your site:
$ sudo journalctl -n 100 -f -t mysite
See also Systemd cheatsheet.
Lino logging configuration¶
Some settings influence logging:
Setting the logging level using environment variables¶
You can use environment variables LINO_LOGLEVEL,
LINO_FILE_LOGLEVEL and LINO_SQL_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 (either the systemd journal or the
lino.log file) when you want this to be different from
LINO_LOGLEVEL. It should be one of INFO, DEBUG etc.
- LINO_SQL_LOGLEVEL¶
The logging level to set for the django.db.backends
handler instead of the default value WARNING.
The default logging level for the django.db.backends
handler is WARNING. You can change this default value by setting the
LINO_SQL_LOGLEVEL variable.
Configure logging yourself¶
You can choose to not use the default logging config by defining your own
LOGGING and LOGGING_CONFIG. See the Django’s doc about
Logging.
Configuring logrotate¶
This section is no longer needed.
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