Installation | Maintenance | Beyond Lino
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 wassystem.log
.
Lino logging configuration¶
Some settings influence logging:
lino.core.site.Site.history_aware_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