如何将Apache日志重定向到STDOUT和Apache日志文件 [英] How to Redirect Apache Logs to both STDOUT and Apache Log File

查看:215
本文介绍了如何将Apache日志重定向到STDOUT和Apache日志文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在运行一个docker容器,想将我的apache服务器的日志写入STDOUT和文件中.

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

关于我的Apache httpd.conf文件中需要哪种配置的任何想法?

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

任何帮助将不胜感激!

推荐答案

您可以尝试以下方法:

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

来自apache.org文档: Apache httpd能够写入错误,并通过管道将日志文件访问另一个进程,而不是直接访问文件.此功能极大地增加了日志记录的灵活性,而无需在主服务器中添加代码.为了将日志写入管道,只需将文件名替换为管道字符"|",后跟可执行文件的名称,该可执行文件应在其标准输入上接受日志条目. Apache将在服务器启动时启动管道日志进程,如果在服务器运行时崩溃则将重新启动它. (这最后一个功能就是为什么我们可以将此技术称为可靠的管道记录".)

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

这篇关于如何将Apache日志重定向到STDOUT和Apache日志文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆