文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>Apache日志文件

Apache日志文件

时间:2010-03-18  来源:aprilus


摘录自:日志文件 - Apache 2.2 中文版参考手册

错误日志(Error Log)

Ubuntu下的默认路径:/var/log/apache2/error.log*

相关指令
* ErrorLog
* LogLevel

持续监视错误日志:

tail -f error_log


访问日志(Access Log)

Ubuntu下的默认路径:/var/log/apache2/access.log*

相关模块
* mod_log_config
* mod_setenvif
相关指令
* CustomLog
* LogFormat
* SetEnvIf

通用日志格式(Common Log Format):

LogFormat "%h %l %u %t \"%r\" %>s %b" common
CustomLog logs/access_log common

组合日志格式(Combined Log Format):

LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-agent}i\"" combined
CustomLog log/access_log combined

多文件访问日志:

LogFormat "%h %l %u %t \"%r\" %>s %b" common
CustomLog logs/access_log common
CustomLog logs/referer_log "%{Referer}i -> %U"
CustomLog logs/agent_log "%{User-agent}i"

条件日志:

# 不记录本机发出的请求
SetEnvIf Remote_Addr "127\.0\.0\.1" dontlog
# 不记录对robots.txt文件的请求
SetEnvIf Request_URI "^/robots\.txt$" dontlog
# 记录其他请求
CustomLog logs/access_log common env=!dontlog


# 将使用英语的请求记录到一个日志,而记录非英语的请求到另一个日志
SetEnvIf Accept-Language "en" english
CustomLog logs/english_log common env=english
CustomLog logs/non_english_log common env=!english


日志滚动

mv access_log access_log.old
mv error_log error_log.old
apachectl graceful
sleep 600
gzip access_log.old error_log.old

管道日志

CustomLog "|/usr/local/apache/bin/rotatelogs /var/log/access_log 86400" common

虚拟主机

LogFormat "%v %l %u %t \"%r\" %>s %b" comonvhost
CustomLog logs/access_log comonvhost

其他日志文件

相关模块
* mod_logio
* mod_log_forensic
* mod_cgi
* mod_rewrite
相关指令
* LogFormat
* ForensicLog
* PidFile
* RewriteLog
* RewriteLogLevel
* ScriptLog
* ScriptLogBuffer
* ScriptLogLength
相关阅读 更多 +
排行榜 更多 +
辰域智控app

辰域智控app

系统工具 下载
网医联盟app

网医联盟app

运动健身 下载
汇丰汇选App

汇丰汇选App

金融理财 下载