unit icon indicating copy to clipboard operation
unit copied to clipboard

Unit's (error) log file should be configurable for minimum severity level

Open andrejohansson opened this issue 2 years ago • 3 comments

I'm running the unit docker image and when it starts up it logs a message to stderr which in turns causes the logs to be picked up by our gcp logging streamer which sees it as an error.

2023/10/17 08:18:46 [info] 1#1 unit 1.29.1 started"

Why is it defaulting to stderr for that info message? Can I turn it of or redirect it somehow?

I see that I can redirect application logs here on an application level but how do I do this on a global level (which I guess is were startup log messages reside): https://unit.nginx.org/configuration/#settings

andrejohansson avatar Oct 17 '23 11:10 andrejohansson

Hi André,

The explanation of these log events can be found here: https://unit.nginx.org/troubleshooting/#troubleshooting-log

All event/message severity levels are written to the Unit log file. For Docker images, these typically are redirected to stderr.

Currently there is no way to set a minimum severity level. Converting this issue to an enhancement request - it would be a nice feature.

lcrilly avatar Oct 17 '23 12:10 lcrilly

Thanks for your reply and the information!

But I fail to understand your link, you say that logs are typically redirected to stderr but when I check the code it´s redirecting to stdout (which would have been fine for us):

    && ln -sf /dev/stdout /var/log/unit.log

andrejohansson avatar Oct 18 '23 14:10 andrejohansson

Oops. My mistake - good catch!

I will propose that we change the official Dockerfiles so that the Unit log goes to stderr. Especially as we don't want to conflict with any application or access logging that might use stdout.

In the interim. You can start your containers with additional command line parameters to unitd:

CMD ["unitd", "--no-daemon", "--control", "unix:/var/run/control.unit.sock", "--log", "/dev/stderr"]

This will override the default log filename and therefore avoid the symlink.

lcrilly avatar Oct 18 '23 14:10 lcrilly