开发者

Multiple Logging files (per WSGI project) in Apache under the same VirtualHost

开发者 https://www.devze.com 2023-02-04 01:27 出处:网络
I\'m currently running a setup where different projects 开发者_JAVA技巧are served according to URL:

I'm currently running a setup where different projects 开发者_JAVA技巧are served according to URL:

http://machine_address/project_nameA
http://machine_address/project_nameB
(...)

Since all projects are served under the same VirtualHost, I ended up having each project handled by a different WSGIDaemonProcess such that they can be restarted independently. In addition, each Daemon is run under a different user according to the project settings.

The only limitation I have with this setup is that all the Apache logs still go into the same file on /var/log/apache2/.

What I would like to have is each project writing its own log, allowing owners of a given project to monitor the project specific logs (access, error,...).

I've tried to use the ErrorLog and TransferLog directives, but since these are restricted to either the Server or the VirtualHost level, I couldn't figure out a way to compartmentalize the logs.

So this question is divided into two:

  • How can I have individual logs on a per-project basis?
  • Is there any way to have these logs being created with a specific group/owner and permission, such that project owners can read but not write to the logs?


There is no way through configuration of mod_wsgi to say that all stdout/stderr from a mod_wsgi daemon process should go to an alternate log file than that setup for the VirtualHost.

It has been considered, but certain error messages are actually generated from Apache child processes and those couldn't be redirected to that log file. The confusion from having messages go to two different logs didn't seem worth it.

If you still want to try, then all you need do is as very first thing in WSGI script file do something like:

import sys
sys.stderr = sys.stdout = file('/tmp/daemon.log', 'a')
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号