Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Console and Syslog log formats are different #9872

Closed
IgorAga opened this issue Nov 28, 2021 · 6 comments
Closed

Console and Syslog log formats are different #9872

IgorAga opened this issue Nov 28, 2021 · 6 comments
Labels
problem Something isn't working stale Stale issues

Comments

@IgorAga
Copy link

IgorAga commented Nov 28, 2021

When logging to both Console and Syslog I'm getting completely different format of log entries:

Example:

Zigbee2MQTT:info 2021-11-28 15:29:56: Currently 8 devices are joined: in Console entry

2021-11-28T12:29:56.860+03:00 192.168.0.2 zigbee2mqtt - - - Currently 8 devices are joined:<134>1 without new line in Syslog entry for most of entries.

As a result Syslog becomes completely unreadable, while Console output is clear.

My logging settings are as following:

log_level: info
log_output: ['console', 'syslog']
log_syslog:
app_name: zigbee2mqtt
host: 192.168.0.6
localhost: 192.168.0.2
pid: process.pid
port: 514
protocol: tcp4
type: '5424'

Another point is that log_level: parameter works fine for Console output, however Syslog always logs in log_level: debug mode.

My rsyslog.service is running on 192.168.0.6 and is serving several other logs without any problem.

And yes, I am in timezone UTC+3... but don't see any need to remind me in every log entry about that.

Thanks in advance.

@amadeo-alex
Copy link
Contributor

amadeo-alex commented Nov 28, 2021

The messages being one big chunk of text might be a bug (please see PR referenced below).
Regarding the log format itself, dirty copying format parameter from file logger unfortunately ends up with this:
obraz

This is because zigbee2mqtt is not directly responsible for the syslog messages format. As far as I've been able to quickly check, the formatting is done by #glossy (used by #winston-syslog). z2m just passed message content.

This could be changed by providing customProducer to glossy.

@amadeo-alex
Copy link
Contributor

Interesting, the PR solved the issue for me on Kiwi Syslog Server (windows syslog server), but when I pointed z2m to my rsyslog server it failed miserably with:
obraz
The first message starts with:
obraz
and ends with:
obraz

The same happens with "vanilla" z2m, something is not right here. Seems like z2m is not sending proper line endings?

@amadeo-alex
Copy link
Contributor

amadeo-alex commented Nov 28, 2021

"Interesting intensifies"
I've switched to UDP as a means of transport:
obraz
As you can see, this time there is no newline issue (afaik each UDP message is treated as a separate message, that would explain this). The interesting thing is the "\n" at the end of each message.

My EOL settings:
obraz

I've searched a bit after that and found this: winstonjs/winston-syslog#150
Seems like exactly the same issue. This person has "<13>" between the messages, if you look closely in my case, when TCP is selected as a means of transport, there are "<134>" between the messages (in addition to "\n" specified in the z2m config).

@IgorAga
Copy link
Author

IgorAga commented Nov 29, 2021

I tried to switch to UDP - and yes, it solves newline issue (I do not have eol: \n in my configuration).

Nov 29 06:19:27 192.168.0.2 zigbee2mqtt Logging to console only'
Nov 29 06:19:27 192.168.0.2 zigbee2mqtt Starting Zigbee2MQTT version 1.22.0 (commit #df0543d4)
Nov 29 06:19:27 192.168.0.2 zigbee2mqtt Starting zigbee-herdsman (0.13.164)

Funny thing, however, is that with UDP configured it shows timestamp in different format and UTC only (local time is 09:19:27 i this case).

That's definitely better, but raises another issue with the timestamp :)

@IgorAga
Copy link
Author

IgorAga commented Nov 29, 2021

Interesting point is that timestamp in Console output is in local timezone:

Zigbee2MQTT:info 2021-11-29 09:40:40: Logging to console only'
Zigbee2MQTT:info 2021-11-29 09:40:41: Starting Zigbee2MQTT version 1.22.0 (commit #df0543d4)
Zigbee2MQTT:info 2021-11-29 09:40:41: Starting zigbee-herdsman (0.13.164)

while the same entries in Syslog are in UTC:

Nov 29 06:40:40 192.168.0.2 zigbee2mqtt Logging to console only'
Nov 29 06:40:41 192.168.0.2 zigbee2mqtt Starting Zigbee2MQTT version 1.22.0 (commit #df0543d4)
Nov 29 06:40:41 192.168.0.2 zigbee2mqtt Starting zigbee-herdsman (0.13.164)

@github-actions
Copy link
Contributor

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 7 days

@github-actions github-actions bot added the stale Stale issues label Dec 30, 2021
@github-actions github-actions bot closed this as completed Jan 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
problem Something isn't working stale Stale issues
Projects
None yet
Development

No branches or pull requests

2 participants