Logging
#3
Blueberry is correct. It won't create more than one file, so you'll only get the date when the tee command is executed. I know from experience there's a way around this (and it's not the way you probably think it is - because that way, breaks the logging), but I'm not going to explain this method to you.

Why?

Using the actual Linux logging system, would work better, as it has better redundancy built in (i.e. less chance of missing something, etc). Additionally, 'tee' will only append to a file every now-and-then, not straight away

So, I'll be helpful and give you some instructions to do what you want, for an rsyslog based system!


Step 1: You'll notice that everything from AssaultCube is already being logged to /var/log/syslog - so, no need to set up logging, just re-configure it to direct correctly.

Step 2: Open /etc/rsyslog.conf and find this line to change:
*.*;auth,authpriv.none          -/var/log/syslog

Replace it with the following, which will stop AssaultCube from being logged to /var/log/syslog:
*.*;auth,authpriv.none;local6.none;      -/var/log/syslog

Step 3: I recommend that above where the "RULES" list is, that you use the following extra commands:
$ActionResumeRetryCount -1      # Infinite retries on insert-failure.
$ActionQueueType LinkedList     # Memory-based logging, this one uses less memory/more CPU.
$ActionQueueFileName /var/log/emergency_rsyslog # Enables disk-assist, just in case of failure.
$ActionQueueMaxFileSize 250M    # Limit emergency file-size, just in case.
$ActionQueueSaveOnShutdown on   # Save in-memory data if rsyslog shuts down.

Step 4: Below the commands you just copy/pasted, type this to redirect the log to a file, on a per-server basis. Ensure you replace "SERVERTAG" with whatever your server tag is. Remember, you can change this tag using the -N command-line argument:
if $syslogtag contains 'SERVERTAG' then /path/to/your/logfile.log

Step 4 OPTIONAL: Use the following to just redirect ALL AssaultCube log data to a file:
if $programname == 'AssaultCube' then /path/to/your/logfile.log

Step 5: Below these, add the following line to stop any further data being logged to syslog:
&~

Step 6: After all these changes, save the file. Reboot rsyslog:
service rsyslog restart


Congratulations. You're now logging AssaultCube to a separate file (or files if you did it on a per-server basis) and not clogging your syslog file! Now we talk about logrotate. You should use logrotate (instead of your own script) - but, if you've come this far and don't trust me, I'm not going to explain why you should - go google it.

The following syslog commands will make your files be archived by date in the folder they were found.


Step 7: In this example, I'm going to pretend the config file is named /etc/logassaultcube.conf (replace the filepath in all the examples below if you choose a different name).
nano -w /etc/logassaultcube.conf

Step 8: Copy/paste the below code into the file, then adjust it according to your needs. If you're not sure what any of these options do, then type 'man logrotate':
nocompress    # Don't tarball any of the logs.
/path/to/your/logfile.log {
    rotate 36500    # Keep archived logs for 100 years.
    daily            # Rotate daily (not weekly, etc).
    missingok        # Rotate even if file is missing.
    ifempty        # Rotate even if file is empty.
    noolddir        # Don't archive logs into a separate folder.
    dateext        # Archived logs get dated, as per below:
    dateformat -%Y-%m-%d    # NAME-2014-03-09.log
    extension .log            # NAME-2014-03-09.log
    create 0644 root root        # Permissions for archived files.
    postrotate
        invoke-rc.d rsyslog rotate > /dev/null
    endscript
}

Step 9: Set up a script run your logrotate file. In this example, I'm going to pretend the script file is named /etc/logassaultcube.sh (replace the filepath in all the examples below if you choose a different name).
nano -w /etc/logassaultcube.sh

Step 10: Copy/paste the below into that script file:
#!/bin/sh

test -x /usr/sbin/logrotate || exit 0
/usr/sbin/logrotate -f /etc/logassaultcube.conf

Step 11: Make the script file executable:
chmod +x /etc/logassaultcube.sh

Step 12: Set up the super-user's cron to run logrotate at 11:59pm daily:
sudo crontab -e

Step 13: Copy/paste this line into the crontab:
59 23    * * *    /etc/logassaultcube.sh


... AND, you're done.
Thanks given by:


Messages In This Thread
Logging - by Mousikos - 08 Mar 14, 03:20AM
RE: Logging - by blueberry - 08 Mar 14, 09:08AM
RE: Logging - by RandumKiwi - 08 Mar 14, 09:45AM
RE: Logging - by Mousikos - 10 Mar 14, 03:35PM
RE: Logging - by RandumKiwi - 10 Mar 14, 03:42AM
RE: Logging - by Mousikos - 10 Mar 14, 03:44AM
RE: Logging - by +f0r3v3r+ - 10 Mar 14, 05:40AM
RE: Logging - by DeafieGamer - 10 Mar 14, 12:39PM
RE: Logging - by RandumKiwi - 10 Mar 14, 08:11PM
RE: Logging - by Mousikos - 01 May 14, 06:09AM
RE: Logging - by jamz - 01 May 14, 08:38AM
RE: Logging - by RandumKiwi - 01 May 14, 11:11AM
RE: Logging - by Mousikos - 01 May 14, 03:54PM
RE: Logging - by RandumKiwi - 01 May 14, 11:14AM
RE: Logging - by jamz - 02 May 14, 09:57AM
RE: Logging - by RandumKiwi - 02 May 14, 11:01PM
RE: Logging - by Mousikos - 03 May 14, 01:48AM
RE: Logging - by RandumKiwi - 03 May 14, 04:01AM