nginx / unit

NGINX Unit - universal web app server - a lightweight and versatile open source server that simplifies the application stack by natively executing application code across eight different programming language runtimes.
https://unit.nginx.org
Apache License 2.0
5.37k stars 323 forks source link

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

Open andrejohansson opened 11 months ago

andrejohansson commented 11 months ago

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

lcrilly commented 11 months ago

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.

andrejohansson commented 11 months ago

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
lcrilly commented 11 months ago

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.