Apache服务器 - 多个目录,不同的错误日志 [英] Apache server -- multiple directories, different error logs

查看:255
本文介绍了Apache服务器 - 多个目录,不同的错误日志的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在/ var / WWW两个目录(比如,在/ var / WWW / APP1和/ var / WWW / APP2),它的错误日志我想发送到不同的文件。两者是同一个域下,所以我的认为的,我不能把他们在不同的虚拟主机。因此,例如,我会访问它们为:

的http://本地主机/ APP1

的http://本地主机/ APP2

我碰到这个页面来了

<一个href=\"http://stackoverflow.com/questions/1460757/generate-access-logs-for-different-subdirectories-in-apache\">Generate在Apache的

不同的子目录的访问日志

其解完全适用于访问日志。然而,ENV的说法似乎并不与ErrorLog指令工作。

这个发现,我工作的这一点,这似乎是错误之前:

 &LT;虚拟主机*:80&GT;
  SERVERADMIN射线@本地  的DocumentRoot的/ var / WWW / APP1  &LT;目录/&GT;
    选择指数多视图了FollowSymLinks
    设置AllowOverride无
    为了否认,允许
    所有允许
  &LT; /目录&GT;  错误日志$ {} APACHE_LOG_DIR /app1/error.log  LOGLEVEL警告  的CustomLog $ {} APACHE_LOG_DIR结合/app1/access.log
&LT; /虚拟主机&GT;

我多少有些失落什么我应该做的。也就是说,如果有办法让错误日志的工作或我是否应该跟上配置为每个目录虚拟主机尝试。任何帮助将是AP preciated!谢谢!


解决方案

/ 为什么你设置目录选项在虚拟主机背景?使用&LT;目录/ var / WWW / APP1&GT; 而不是&LT;目录/&GT;

由于阿帕奇ErrorLog指令文档其背景是服务器配置,虚拟主机 - 这意味着它是唯一可以定义错误日志整个服务器或 VirtalHost ,也不能用于目录。所以,如果你想不同的日志发送到不同的文件尽量使用 SetEnvIf之后来你在哪里都像 SetEnvIf之后REQUEST_URI目录设置环境变量depeding ^ \\ / A1 \\ / A1 SetEnvIf之后REQUEST_URI ^ \\ / A2 \\ /!A1 ,然后根据日志写入A1 环境变量。

I have two directories in /var/www (say, /var/www/app1 and /var/www/app2) whose error logs I want sent to different files. Both are under the same domain, so I think that I can't put them under different virtual hosts. So, for example, I would access them as:

http://localhost/app1

http://localhost/app2

I came across this page:

Generate access logs for different subdirectories in Apache

whose solution works perfectly for the access logs. However, the "env" argument doesn't seem to work with the ErrorLog directive.

Before this "discovery", I was working on this, which seems wrong:

<VirtualHost *:80>
  ServerAdmin ray@localhost

  DocumentRoot /var/www/app1

  <Directory />
    Options Indexes FollowSymLinks MultiViews
    AllowOverride None
    Order deny,allow
    allow from all
  </Directory>

  ErrorLog ${APACHE_LOG_DIR}/app1/error.log

  LogLevel warn

  CustomLog ${APACHE_LOG_DIR}/app1/access.log combined
</VirtualHost>

I'm somewhat lost about what I should be doing. That is, if there is some way to get ErrorLog to work or if I should keep trying with configuring a virtual host for each directory. Any help would be appreciated! Thank you!

解决方案

Why you set Directory options for / in VirtualHost context? Use <Directory /var/www/app1> instead of <Directory />

Due to Apache ErrorLog directive docs its context is server config, virtual host - which means that it's only possible to define ErrorLog for whole server or for VirtalHost, nor for Directory. So if you want to send different logs to different files try to use SetEnvIf to set Env variable depeding on the directory where you are like SetEnvIf Request_URI ^\/a1\/ a1 and SetEnvIf Request_URI ^\/a2\/ !a1 and then write logs depending on a1 environment variable.

这篇关于Apache服务器 - 多个目录,不同的错误日志的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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