Access logging to stdout
We want to use Envoy in a Kubernetes environment. It would be nice if Envoy can log to stdout/stderr instead of a file so we can take advantage of the default logging infrastructure including log rotation and log processing pipeline (fluentd on standard docker logs on the host)
What logs are you talking about? app logs are already written to stderr.
Aren't access logs written to a file according to https://lyft.github.io/envoy/docs/configuration/http_conn_man/access_log.html?
Yes for access logs. I don't really see any sane way that you can write access logs to stderr, if app logs also go there? I suppose it could be added as an option.
Two options for you:
"access_log": [
{
"path": "/dev/stdout"
}
],
or log to file and in the Dockerfile:
RUN ln -sf /dev/stdout /var/log/envoy.log
Thanks @damaex17. Given the workarounds I'm going to close this as won't fix.
To assist others, here's a snippet of yaml that will configure access_log to log to stdout.
filter_chains:
- filters:
- name: envoy.http_connection_manager
config:
access_log:
- name: envoy.file_access_log
config:
path: "/dev/stdout"
I can't get /dev/stdout to work unless I run as root, which I really don't want to do.
Is this working for everyone ? When i set path as
/dev/stdout
I am not able to see the access logs.
But when I echo something to stdout like
echo "hello" > /proc/1/fd/1
All of a sudden I get all the logs. Looks like the access logs aren't properly flushed to stdout.
Hello,
Although my configuration declares the stdout as the place to send the admin logs:
{ "admin": { "access_log_path": "/dev/stdout", "address": "tcp://0.0.0.0:9901" },
I can't see anything there.
[root@prs-fh2ns /]# tail -f /dev/stdout
Also the workaround @tak2siva made above didn't help my case ;-(
[root@prs-fh2ns /]# ps -ef UID PID PPID C STIME TTY TIME CMD root 1 0 0 Jun05 ? 00:00:17 /usr/bin/python /usr/bin/supervisord -c /etc/supervisord.conf root 80 1 0 Jun05 ? 00:02:09 /usr/bin/envoy -c /etc/envoy/active-conf.json [root@prs-fh2ns /]# echo "hello" > /proc/80/fd/1
Did I missed something?
Thanks
i encounter the case which is the same with @sporkmonger , do u found out how to solve it ? it cost me one day to dive into it, but get nothing helpful
An updated version of @jevonearth snippet
filter_chains:
- filters:
- name: envoy.filters.network.http_connection_manager
typed_config:
"@type": type.googleapis.com/envoy.extensions.filters.network.http_connection_manager.v3.HttpConnectionManager
access_log:
- name: envoy.access_loggers.file
typed_config:
"@type": type.googleapis.com/envoy.extensions.access_loggers.file.v3.FileAccessLog
path: /dev/stdout
Out of interest... is this a bad idea to leave in production? It was a bit surprising to me that I wasn't able to see the actual routing done by envoy, so I was looking for exactly this solution, but is it actually bad practice? How am I supposed to view the access log otherwise in a kubernetes cluster for example?
is this a bad idea to leave in production?
hi @enyo - iiuc - no using stdout/err is the recommended way if you are running inside a container
I've only been able to log to the systemd journal with this hack
https://github.com/envoyproxy/envoy/issues/8297#issuecomment-620659781
An updated version of @jevonearth snippet
filter_chains: - filters: - name: envoy.filters.network.http_connection_manager typed_config: "@type": type.googleapis.com/envoy.extensions.filters.network.http_connection_manager.v3.HttpConnectionManager access_log: - name: envoy.access_loggers.file typed_config: "@type": type.googleapis.com/envoy.extensions.access_loggers.file.v3.FileAccessLog path: /dev/stdout
thanks!!
but how to control log file size? It's still increasing..
@malza321 afaiaa Envoy doesnt provide any logrotation itself - see #5678
How you do it depends on your setup - eg whether it is containerized and/or how Envoy is started and run (eg systemd) and how you want to capture the logs
The standard linux/unix tool is logrotate - i dont have any experience of using it with Envoy specifically - but noticed #13962 that you might want to look at
@malza321 afaiaa Envoy doesnt provide any logrotation itself - see #5678
How you do it depends on your setup - eg whether it is containerized and/or how Envoy is started and run (eg systemd) and how you want to capture the logs
The standard linux/unix tool is logrotate - i dont have any experience of using it with Envoy specifically - but noticed #13962 that you might want to look at
I don't have any cloud infra and will not have. I just use envoy binary file and config file only. and no permission on system file as well.
I ran into this trying to adapt a configuration file to work from a systemd service unit.
I assume people run this from standard system launchers with standard system loggers, so what's the process for that? Should I just omit the logging section?
@coolaj86 if you were expecting help you might think twice posting rude and insulting messages about the envoy community
perhaps taking a more constructive approach like trying to fix the problem you are having yourself and contributing that back
i have added https://github.com/envoyproxy/envoy/issues/32764 to give the issue better visibility