Put Year in Linux Syslog

tarakranjan
tarakranjan used Ask the Experts™
on
Hi Friends,,

How can i format syslog to put Year in the time stamp.


/\
-t
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Top Expert 2007

Commented:
You can't change the timestamp format with the default syslog.

You will need to use another syslog program like syslog-ng

Commented:
You have to use syslog-nd for that.
Then edit the config file for syslog-ng (/etc/syslog-ng/syslog-ng.conf) add add the ts_format() option:

options {
        chain_hostnames(no);
        stats_freq(43200);
 
        # here you can specify the time format. iso includes the year
        ts_format(iso);
};

Open in new window

Project Manager
Commented:
You can write you log to a named pipe and then keep a 'sed'  inserting the year:

mkfifo /var/log/debug.fifo

# insert this line in your /etc/syslog.conf

debug.*           |/var/log/debug.fifo

nohup sed s,^,"`date +%Y` ", < /var/log/debug.fifo >> /var/log/debug

Every january 1st at 0 a.m. you'll have to kill you seds and run them again.


Ricardo CananiProject Manager

Commented:
Don't forget fo restart your syslog after changing syslog.conf

Author

Commented:
got the solutions

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial