Format syslog time output to 12 hr format

Is there a way to get syslog to report the time in 12 hr format?


If your regional settings allow it, you can use dconf-editor to change it:

@tkn is the Syslog time controlled by the clock settings? I've never used Syslog. Changed clock to 12hr and still showing 24hr in syslog.

I got the same thing. It still shows 24 hr format?

I would think the predefined format isn't set up for A.M. P.M. in the syslog.
Here is a link maybe you can explore:

1 Like

oops.... my fault. I overlooked the word 'syslog'

No, there is no such option.

All systemlogging is done by journald in the background an stored in binary format.
To read the logs we use journalctl which actually has some display options.

The time formatting options are limited (either locale-dependent, but still 24-hour, or Unix timestamps, or ISO 8601 timestamps).

So no, unless you create a little script to convert the output of journalctl you're stuck

1 Like

I have a little script here that will display the log output in 12h timeformat:


journalctl | while read line
	case "${line:7:1}" in
	0  ) hour="${line:8:1}"			;;
	1|2) hour="${line:7:2}"			;;
	*  ) echo "$line" ; continue	;;

	(( hour > 12 )) && ampm=pm && (( hour -= 12 )) || ampm=am
	printf "%s%s %02d%s\n" "${line:0:7}" "$ampm" "$hour" "${line:9}"

EDIT: fixed a small bug

1 Like

Thanks a lot tkn.