Logging using rsyslog

Hi guys,
I've installed rsyslog on my TL-WDR3600 with a root overlay, but the logging timestamp is in UTC for some odd reason.
I wonder if the missing tzdata package is the culprit.
The rsyslog is from the default openwrt repository for version OpenWrt 19.07.2 r10947-65030d81f3 / LuCI openwrt-19.07 branch git-20.094.46635-de52000

Thanks,
a/

I don't think the problem is tzdata, I don't have it installed and have a timestamp with my local time.

There is an option in the conf file (/etc/rsyslog.conf), which seems to handle the timestamp format:

# Use traditional timestamp format.
# To enable high precision timestamps, comment out the following line.

$ActionFileDefaultTemplate RSYSLOG_TraditionalFileFormat

Maybe you want to look into that.

That line only changes the format not the actual timezone if I comment it out

As a side note I just upgraded from 18.06 to stable and rsyslog was working fine on the 18.06 version.

The rsyslogd package should have a dependency pinned to it

opkg install zoneinfo-$your_region

Without zoneinfo package there is no way to change from the UTC time zone to the desired system location timezone.

@kisisten Did installing the appropriate zoneinfo-<region> package fix the problem for you? I am running into the exact same issue and I have zoneinfo-asia package installed.

yep, also don't forget the /etc/localtime setting, due to libc dependence https://www.gnu.org/software/libc/manual/html_node/TZ-Variable.html

Yep, I did all that, but it doesn't appear to be working. I have the same issue with rsyslog and syslog-ng.

root@bumblebee:~# ls -l /etc/localtime
lrwxrwxrwx    1 root     root            32 Apr 17 21:19 /etc/localtime -> /usr/share/zoneinfo/Asia/Kolkata
root@bumblebee:~# opkg list-installed | grep zone
zoneinfo-asia - 2019b-1
zoneinfo-core - 2019b-1
root@bumblebee:~#

Interestingly, the log from syslog-ng itself when it starts up and shutdown is in the right time zone. :frowning:

So another observation is, some components log in the right time zone, whereas other's don't. The log messages from kernel, dnsmasq etc are good, but other messages get logged in UTC.

Apr 18 15:29:50 bumblebee kernel: [   13.640878] br-lan: port 1(eth0) entered blocking state
Apr 18 15:29:50 bumblebee kernel: [   13.646617] br-lan: port 1(eth0) entered forwarding state
Apr 18 09:59:50 bumblebee netifd: Network device 'eth0' link is up
Apr 18 15:29:50 bumblebee kernel: [   13.661240] igb 0000:04:00.0 eth3: igb: eth3 NIC Link is Up 1000 Mbps Full Duplex, Flow Control: RX
Apr 18 09:59:50 bumblebee netifd: Network device 'eth3' link is up
Apr 18 09:59:50 bumblebee netifd: Interface 'wan_cpe' has link connectivity
Apr 18 15:29:50 bumblebee kernel: [   13.920805] IPv6: ADDRCONF(NETDEV_CHANGE): eth3: link becomes ready
Apr 18 15:29:50 bumblebee kernel: [   13.929021] IPv6: ADDRCONF(NETDEV_CHANGE): eth3.702: link becomes ready
Apr 18 15:29:50 bumblebee kernel: [   13.936469] IPv6: ADDRCONF(NETDEV_CHANGE): eth3.1830: link becomes ready
Apr 18 09:59:50 bumblebee netifd: VLAN 'eth3.702' link is up
Apr 18 09:59:50 bumblebee netifd: Interface 'wan' has link connectivity
Apr 18 09:59:50 bumblebee netifd: Interface 'wan' is setting up now
Apr 18 09:59:50 bumblebee netifd: VLAN 'eth3.1830' link is up
Apr 18 09:59:50 bumblebee netifd: Interface 'wan_voip' has link connectivity

root@bumblebee:~# date
Sat Apr 18 15:37:58 IST 2020
root@bumblebee:~#
root@bumblebee:~# logger test message
root@bumblebee:~# logread | grep 'test message'
Apr 18 10:05:38 bumblebee root: test message
Apr 18 10:08:59 bumblebee root: test message
root@bumblebee:~# date
Sat Apr 18 15:39:06 IST 2020
root@bumblebee:~#

I wonder if its logger not sending the message with the right time zone?

EDIT

Looks like this is an issue with the busybox logger utility. I installed the logger separately by running, and now logs are in the right time zone,

opkg install --force-overwrite logger

Changing from the busybox logger fixed some of the issues, but there were still issues for logs from some other components.

So I ended up changing the syslog-ng template to use the receive time rather than the sender's time zone.

template default-ignore-sender-tz {
    template("${R_FULLDATE} ${HOST} ${PRIORITY} ${PROGRAM}[${PID}]: ${MSGONLY}\n");
};

destination messages {
	file("/var/log/messages" template(default-ignore-sender-tz));
};

https://www.syslog-ng.com/technical-documents/doc/syslog-ng-open-source-edition/3.16/administration-guide/57#TOPIC-956604