How to Redirect Apache Logs to both STDOUT and Apa

2019-07-18 17:29发布

问题:

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:

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".)