Adding year in the syslog message (linux)

Possa picture Possa · Feb 21, 2011 · Viewed 9.8k times · Source


I need to log the year in the log message generated by syslog daemon. In particular in the /var/log/secure file. Is it possible?

Here an example of normal syslog message:

Feb 16 04:06:58 HOST sshd[28573]: Accepted password for USER from SOURCE port 7269 ssh2

And I need something similar to:

Feb 16 2011 04:06:58 HOST sshd[28573]: Accepted password for USER from SOURCE port 7269 ssh2

Thanks in advance.

Answer

Chance Hsu picture Chance Hsu · Oct 27, 2011

If you use rsyslog, it is easy. Refer to following:

  1. Modify /etc/rsyslog.conf to following:

    ...
    authpriv.*     /var/log/secure;RSYSLOG_FileFormat
    ...
    
  2. And then asking rsyslog daemon to reload configuration:

    $ kill -HUP <pid of rsyslog daemon>
    

More reference :