Closed rajdeep-2001 closed 2 years ago
What OS are you using? The ideal way to forward stdout to a file using systemd is the way you already explained above. Another one is to redirect to log stream to a file using ExecStart=/bin/python3 /etc/nginx-ldap/nginx-ldap-auth-daemon.py 2>&1 >> /var/log/your.log
.
This will append the stdout
as well as the stderr
to a custom logfile.
We are using Amazon linux2 Nginx Plus AMI as a subscription from the market place. os-release
NAME="Amazon Linux" VERSION="2" ID="amzn" ID_LIKE="centos rhel fedora" VERSION_ID="2" PRETTY_NAME="Amazon Linux 2" HOME_URL="https://amazonlinux.com/"
Thanks and as you suggested, below redirection works:-
ExecStart=/bin/sh -c 'exec /bin/python3 /etc/nginx-ldap/nginx-ldap-auth-daemon.py 2>&1 >> /var/log/nginx/ldap_auth_daemon.log'
However, the service/process writes to the above redirected log file only when the systemd service is stopped i.e. it does not write in real-time.
Sorry for the delay, this issue is fixed, was a buffer issue. Can be closed. Thanks👍
We are running this module on Nginx Plus AMI EC2 instance i.e. no containerisation. Nginx conf is fine. However, unable to push logs to a separate file and have that propagated to Cloudwatch. $LOG env var is not working OR please suggest how to set $LOG var to push the standard output and error logs to a different file. Updating the documentation with LOG setup would be really useful. Much appreciated!!
Py daemon has been setup as a systemd unit. systemd v219
Unit file:
nginx-ldap-auth.default