apache syslog-ng 错误日志和访问日志

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1119153/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-13 17:53:23  来源:igfitidea点击:

apache syslog-ng error logs and access logs

apacheapache2syslog

提问by uzumaki naruto

I am trying to send all my apache logs to syslog-ng(on remote machine) which in turn writes to a file.

我试图将我所有的 apache 日志发送到 syslog-ng(在远程机器上),然后再写入一个文件。

so I configure syslog-ng this way

所以我这样配置 syslog-ng

source s_apache {
      unix-stream("/var/log/apache_log.socket" max-connections(512) keep-alive(yes));
};
filter f_apache { match("error"); };
destination df_custom { file("/var/log/custom.log"); };
log {
        source(s_apache);
        filter(f_apache);
        destination(df_custom);
};

and add the following line to apache2.conf

并将以下行添加到 apache2.conf

ErrorLog "|/usr/bin/logger -t 'apache'  -u /var/log/apache_log.socket"

but only logs being written to "/var/log/custom.log" are

但只有写入“/var/log/custom.log”的日志是

[Mon Jul 13 17:24:36 2009] [notice] caught SIGTERM, shutting down

and

[Mon Jul 13 17:26:11 2009] [notice] Apache/2.2.11 (Ubuntu) configured -- resuming normal operations

I want all logs to be sent to custom.log..... Please help me.... where am I going wrong?

我想将所有日志发送到 custom.log..... 请帮帮我....我哪里出错了?

回答by lg.

I can suggest to you this link: http://httpd.apache.org/docs/2.2/logs.htmlHere you can learn about log on apache. If you want all log on syslog-ng, you must configure also access logs with CustomLog directive.

我可以给你推荐这个链接:http: //httpd.apache.org/docs/2.2/logs.html在这里你可以了解登录apache。如果您希望所有日志都在 syslog-ng 上,您还必须使用 CustomLog 指令配置访问日志。

Regards, Lorenzo.

问候,洛伦佐。

回答by rane

I had the same problem, and i found that the the ErrorLog and CustomLog settings were getting overwritten by /etc/apache2/sites-available/default

我遇到了同样的问题,我发现 ErrorLog 和 CustomLog 设置被 /etc/apache2/sites-available/default 覆盖

After commenting out those, it worked !

在注释掉这些之后,它起作用了!

Or you can just put these settings in < virtualhost > if you want to log only specific domain calls

或者,如果您只想记录特定的域调用,您可以将这些设置放在 < virtualhost > 中

Regards rane

问候雷恩