-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Output to "log_file" gets rotated, but this is not documented or tunable, and rotated files don't follow usual naming conventions #3280
Comments
When removing
does it work as expected? |
Hi, did the following testing:
Theefore, it is confirmed that by removing the specified lines in the code, zigbee2mqtt works, regarding log rotation, as "expected"; in the sense that it does not rotate the log files and hence this task can be done by (for example) logrotate. Having a flag in the code to turn log rotation off for those few of us inclined to do so, would be super. Thank you. |
Implemented, can be set via advanced:
log_rotation: false |
I had to read this - Koenkk/zigbee2mqtt#3280 - issue to work it out. The documentation should contain this information.
Bug Report
What happened
Not a bug report as such, rather, a RFE (Request For Enhancement).
Today, while doing some random log checking in the Linux server where zigbee2mqtt is running, noticed the configured log file (as set in the "log_file" directive) had rotated:
Checked the documentation for the configuration file (https://www.zigbee2mqtt.io/information/configuration.html) and didn't see anything related to log rotation defaults or tuning.
Took the time to dig deeper the last part of the old log file and the first part of the new one, and didn't see anything out of the ordinary happening (such as a service restart).
As expected, it is the "zigbee2mqtt.log" the one being currently open and appended to by the service. Of course, I have "log_file: zigbee2mqtt.log" under "advanced:" in the yaml configuration file.
What did you expect to happen
If assuming letting the application generating the logs to be the one in charge or rotating them is a good thing (which I don't think it is the case, there being dedicated solutions for log rotation, such as the good old "logrotate"), at least I would have expected:
That zigbee2mqtt behaves in this way, makes it the exception regarding log management among the myriad of other services, processes and applications running on a regular Linux server, which is probably added code to this software, and makes log management for zigbee2mqtt unnecessarily specific and time consuming.
How to reproduce it (minimal and precise)
It looks like the rotation was triggered when the active log file was over 10,000,000 bytes big. This is confirmed by looking into the source code (cloned the repository today and saw this):
lib/util/logger.js
So if my limited (aka non-existent) understanding of the JS source code is correct, we have a hardcoded log rotation policy by which we will keep at most 3 log files with up to 10 MB each, and filenames which are not following usual naming standards.
Of course, as an end user / administrator I couldn't care less about the ins and out of the code (and resorting to external libraries to simplify code seems to be right), but not if at the expense of making "zigbee2mqtt" a bad neighbour and an special use case when dealing with logs.
It is my opinion zigbee2mqtt should :
This way, 95% of users may continue to use zigbee2mqtt the way they do (as they don't care about logs except for the last few lines when debugging), but the remainder 5% can have the software logs under control and managed the same way many others in the system are.
Debug Info
zigbee2mqtt version: HEAD as of April 4 2020
CC253X firmware version: N/A
The text was updated successfully, but these errors were encountered: