summaryrefslogtreecommitdiffhomepage
path: root/src/nxt_conf_validation.c
diff options
context:
space:
mode:
authorAndrew Clayton <a.clayton@nginx.com>2023-03-30 05:53:13 +0100
committerAndrew Clayton <a.clayton@nginx.com>2023-04-11 19:08:32 +0100
commit45c45eaeb4443ff4af9cc49e716bbd9d65596b02 (patch)
tree1ca6fd50b5a7e3dfce5c90ddd30d5e73316c43f4 /src/nxt_conf_validation.c
parent8b8952930c8462b5c56cdaf14e4a1c7c8b0c203d (diff)
downloadunit-45c45eaeb4443ff4af9cc49e716bbd9d65596b02.tar.gz
unit-45c45eaeb4443ff4af9cc49e716bbd9d65596b02.tar.bz2
Add per-application logging.
Currently when running in the foreground, unit application processes will send stdout to the current TTY and stderr to the unit log file. That behaviour won't change. When running as a daemon, unit application processes will send stdout to /dev/null and stderr to the unit log file. This commit allows to alter the latter case of unit running as a daemon, by allowing applications to redirect stdout and/or stderr to specific log files. This is done via two new application options, 'stdout' & 'stderr', e.g "applications": { "myapp": { ... "stdout": "/path/to/log/unit/app/stdout.log", "stderr": "/path/to/log/unit/app/stderr.log" } } These log files are created by the application processes themselves and thus the log directories need to be writable by the user (and or group) of the application processes. E.g $ sudo mkdir -p /path/to/log/unit/app $ sudo chown APP_USER /path/to/log/unit/app These need to be setup before starting unit with the above config. Currently these log files do not participate in log-file rotation (SIGUSR1), that may change in a future commit. In the meantime these logs can be rotated using the traditional copy/truncate method. NOTE: You may or may not see stuff printed to stdout as stdout was traditionally used by CGI applications to communicate with the webserver. Closes: <https://github.com/nginx/unit/issues/197> Closes: <https://github.com/nginx/unit/issues/846> Reviewed-by: Alejandro Colomar <alx@nginx.com> Signed-off-by: Andrew Clayton <a.clayton@nginx.com>
Diffstat (limited to 'src/nxt_conf_validation.c')
-rw-r--r--src/nxt_conf_validation.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/nxt_conf_validation.c b/src/nxt_conf_validation.c
index 9169bcc9..6d798a81 100644
--- a/src/nxt_conf_validation.c
+++ b/src/nxt_conf_validation.c
@@ -1047,6 +1047,12 @@ static nxt_conf_vldt_object_t nxt_conf_vldt_common_members[] = {
.type = NXT_CONF_VLDT_OBJECT,
.validator = nxt_conf_vldt_isolation,
.u.members = nxt_conf_vldt_app_isolation_members,
+ }, {
+ .name = nxt_string("stdout"),
+ .type = NXT_CONF_VLDT_STRING,
+ }, {
+ .name = nxt_string("stderr"),
+ .type = NXT_CONF_VLDT_STRING,
},
NXT_CONF_VLDT_END