How to Redirect Apache Logs to both STDOUT and Apa

2019-07-18 17:32发布

I am running a docker container and want to write logs of my apache server to both STDOUT and file.

Any idea as to what kind of configuration is needed in my Apache httpd.conf file?

Any help would be highly appreciated!

1条回答
太酷不给撩
2楼-- · 2019-07-18 18:01

you can try this:

CustomLog "| /usr/bin/tee /var/log/access_log" common

from apache.org docs: Apache httpd is capable of writing error and access log files through a pipe to another process, rather than directly to a file. This capability dramatically increases the flexibility of logging, without adding code to the main server. In order to write logs to a pipe, simply replace the filename with the pipe character "|", followed by the name of the executable which should accept log entries on its standard input. Apache will start the piped-log process when the server starts, and will restart it if it crashes while the server is running. (This last feature is why we can refer to this technique as "reliable piped logging".)

查看更多
登录 后发表回答