envoy icon indicating copy to clipboard operation
envoy copied to clipboard

Access logging to stdout

Open kuroneko25 opened this issue 9 years ago • 20 comments

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)

kuroneko25 avatar Jul 19 '17 21:07 kuroneko25

What logs are you talking about? app logs are already written to stderr.

mattklein123 avatar Jul 19 '17 22:07 mattklein123

Aren't access logs written to a file according to https://lyft.github.io/envoy/docs/configuration/http_conn_man/access_log.html?

kuroneko25 avatar Jul 20 '17 19:07 kuroneko25

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.

mattklein123 avatar Jul 20 '17 19:07 mattklein123

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

damaex17 avatar Jul 25 '17 08:07 damaex17

Thanks @damaex17. Given the workarounds I'm going to close this as won't fix.

mattklein123 avatar Jul 25 '17 15:07 mattklein123

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"

jevonearth avatar Feb 26 '18 18:02 jevonearth

I can't get /dev/stdout to work unless I run as root, which I really don't want to do.

sporkmonger avatar Mar 22 '18 22:03 sporkmonger

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.

tak2siva avatar May 25 '18 10:05 tak2siva

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

georgasa avatar Jun 06 '18 13:06 georgasa

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

zrss avatar Nov 06 '18 11:11 zrss

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

caiolopes avatar Oct 08 '20 23:10 caiolopes

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?

enyo avatar Oct 30 '20 18:10 enyo

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

phlax avatar Oct 30 '20 19:10 phlax

I've only been able to log to the systemd journal with this hack

https://github.com/envoyproxy/envoy/issues/8297#issuecomment-620659781

dontlaugh avatar Nov 12 '20 22:11 dontlaugh

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 avatar May 01 '21 16:05 malza321

@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

phlax avatar May 01 '21 16:05 phlax

@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.

malza321 avatar May 01 '21 21:05 malza321

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 avatar Mar 07 '24 06:03 coolaj86

@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

phlax avatar Mar 07 '24 09:03 phlax

i have added https://github.com/envoyproxy/envoy/issues/32764 to give the issue better visibility

phlax avatar Mar 07 '24 10:03 phlax