====== Separating Logs on Unix/Linux Systems ======

This document is a work in progress. It may need some tweaks.

To make it easier to track issues or monitor your system, you may wish to separate your Synchronet logs into terminal, mail, ftp, web, etc. This procedure works on Ubuntu but should be similar for any Linux based system.


First, check your log settings in ctrl/sbbs.ini

  LogIdent=synchronet
  
This will be used for programname in the rsyslog config file. Is recommended to keep it as "synchronet".


Next, make a directory for your logs. This should be owned by your BBS user so change chown accordingly.

  mkdir /var/log/sbbs
  chown bbs:bbs /var/log/sbbs
  

Create a file /etc/rsyslog.d/01-synchronet.conf with the following contents.

<code>
if $programname == 'synchronet' then {
  if $msg startswith ' web ' then {
    action(type="omfile" file="/var/log/sbbs/web.sbbs.log" fileOwner="bbs" fileGroup="bbs")
  } else if $msg startswith ' mail ' then {
    action(type="omfile" file="/var/log/sbbs/mail.sbbs.log" fileOwner="bbs" fileGroup="bbs")
  } else if $msg startswith ' srvc ' then {
    action(type="omfile" file="/var/log/sbbs/service.sbbs.log" fileOwner="bbs" fileGroup="bbs")
  } else if $msg startswith ' evnt BINK' then {
    action(type="omfile" file="/var/log/sbbs/binkit.sbbs.log" fileOwner="bbs" fileGroup="bbs")
  } else if $msg startswith ' evnt ' then {
    action(type="omfile" file="/var/log/sbbs/event.sbbs.log" fileOwner="bbs" fileGroup="bbs")
  } else if $msg startswith ' term ' then {
    action(type="omfile" file="/var/log/sbbs/term.sbbs.log" fileOwner="bbs" fileGroup="bbs")
  } else if $msg startswith ' ftp ' then {
    action(type="omfile" file="/var/log/sbbs/ftp.sbbs.log" fileOwner="bbs" fileGroup="bbs")
  }
  else
  {
    action(type="omfile" file="/var/log/sbbs/sbbs.log" fileOwner="bbs" fileGroup="bbs")
  }
  stop
}
</code>

If you're not running running your ircd standalone you'll need to add a block for ' ircd ' otherwise if it is standalone, include the block below.

<code>
if $programname == 'ircd' then {
  action(type="omfile" file="/var/log/sbbs/ircd.log" fileOwner="bbs" fileGroup="bbs")
  stop
}
</code>

You will also want to ensure that SyslogIdentifier=ircd is set in your ircd service file. 

Change fileOwner and fileGroup to your BBS user's username and group.

Restart rsyslog using systemctl or the relevant command for your OS.

  systemctl restart syslog
  

You should now see various logfiles being created in /var/log/sbbs.

Setup log rotation. This will keep a history of 12 logfiles which are rotated monthly. Adjust to suit your needs.

Create /etc/logrotate.d/sbbs

<code>
/var/log/sbbs/*sbbs.log
{
        su bbs bbs
        rotate 12
        monthly
        missingok
        notifempty
        compress
        sharedscripts
        missingok
        postrotate
                /sbbs/bin/postrotate
        endscript
}
</code>

Change the su line to your BBS username/group.



===== See Also =====
  * [[:howto:|howto index]]

{{tag>}}
