Changing GNUSocial log files
Written by ⓘⓓⓔⓝⓣⓛⓤⓓ - -

syslog
to create logs during its execution. As there are no specific indications these logs all go to /var/log/syslog
.Mixing sub-systems
This is also where some other sub systems are writing their own logs.awk '{print $5}' /var/log/syslog \gives this result :
| sed -e 's/[0-9].//g' \
| tr -d '[]' \
| sort -u
kernel:
named:
postfix/anvil:
postfix/cleanup:
postfix/local:
postfix/master:
postfix/pickup:
postfix/qmgr:
postfix/smtp:
postfix/smtpd:
rsyslogd:statusnet:
/USR/SBIN/CRON:
Configure GNUSocial to use its own log file
I wanted to have GNUSocial logs separated from the other subsystems. I followed the instructions of the documentation and I modifiedconfig.php
to add two lines (I did that when it was still status.net)#logs$config['site']['logdebug'] = false;At the first attempt to write a log it failed ... nothing was logged in
$config['site']['logfile'] = '/var/log/statusnet/statusnet.log';
/var/log/statusnet/statusnet.log
. Looks like a user permissions problem.... (www-data
is the group of www-data
user who runs Apache)chown -R root:www-data /var/log/statusnet
chmod g+w /var/log/statusnet/statusnet.log
Limit the growth
Now that GNUSocial logs should be on their own, how can I limit their disk usage over time ? On a linux system the answer is by logrotating them. So I wrote alogrotated
configuration file for these logs in /etc/logrotate.d/statusnet
/var/log/statusnet/*.logThis a read like this :
{
rotate 7
daily
missingok
notifempty
delaycompress
compress
create 660 root www-data
}
/var/log/statusnet/*.log
: consider every file named*.log
in/var/log/statusnet directory
rotate 7
, daily, missingok, notifempty, delaycompress, compress : every day create a new log file and keep the seven latest log files. If nothing was written in the log file than do noting. You can also ignore the log rotation if there is no file at all. And, by the way, compress it so that it takes even less room.create 660 root www-data
: every new log file should be created so that users belonging to www-data group and root itself can read and write the file
Strange behaviour
Using the aforementioned configuration ofconfig.php
I expect not to see any more debug logs and I expected to see every log in /var/log/statusnet/statusnet.log
... Well that's not what is happening : /var/log/sysout
still contains GNUSocial logs but much less than before. I can read daemon messages and every messages stating that a PHP call is "Including config file: /var/www/statusnet/config.php
"LOG_DEBUG
messages are in/var/log/statusnet/statusnet.log
LogFilter
pluginaddPlugin('LogFilter', array( 'priority' => array(LOG_ERR => true, LOG_INFO => true, LOG_DEBUG => false), 'regex' => array('/About to push/i' => false, '/Including config file/i' => false, '/Successfully handled item/i' => false) ));But these line are still printed out. A quick search indicates that
./lib/statusnet.php
is the culprit# find . -name "*.php" -exec grep -H "Including config file" '{}' \;./config.php: '/Including config file/i' => false,./lib/statusnet.php: common_log(LOG_INFO, "Including config file: " . $_config_file);My next step is to change this message priority to
LOG_DEBUG
by editing ./lib/statusnet.php
... to no avail for the message is still present ...Ocam's razor is still sharp :
replace
common_log(LOG_INFO, "Including config file: " . $_config_file);by
//common_log(LOG_INFO, "Including config file: " . $_config_file);in
./lib/statusnet.php
Et voilà ...