A while back I left Blogger and downloaded my blogs to my system. I hosted them there with each individual blog as a VirtualHost for a while. Later, I imported them into WordPress and am hosting them from WP now.
When I was hosting them locally as virtual hosts, I had each one use a separate Apache log file, but now, all of the blogs are logged to the same file.
I cannot find a setting in WordPress, and there is no way to specify it in an .htaccess
file since the sites are virtual. That is, WordPress blogs are not actually located on the drive as separate directories—(besides, log settings cannot be used in .htaccess
anyway).
How can a WordPress multi installation be configured so that one or more sites log to their own log file?
toscho’s second suggestion of using SetEnvIf is promising. I managed to get it to put access to one site in a separate log file and keep it out of the main log by using the directives below.
…
<IfModule log_config_module>
…
# I’m re-using the dontlog environment variable because there is no reason to make a special variable (for me), so it avoids having to use an expression (plus, it just makes sense)
SetEnvIf Request_URI "^/blogs" dontlog
SetEnvIf Request_URI "^/blogs/blog1" blog1
SetEnvIf Request_URI "^/blogs/foobar" foobar
…
CustomLog "../Logs/Main/access.log" common env=!dontlog
CustomLog "../Logs/Blogs/blog1.log" common env=blog1
CustomLog "../Logs/Blogs/foobar.log" common env=foobar
…
UnsetEnv dontlog
UnsetEnv blog1
UnsetEnv foobar
</IfModule>
…
This works for a single-site blog, but for multisite, the problem is in trying to keep things uncluttered and simplify adding new blogs because it looks like it is not possible to use variables in log filenames as follows, which means making a separate entry for each and every one:
…
<IfModule log_config_module>
…
SetEnvIf Request_URI "^/blogs" dontlog
# Set environment variable to matched regex subexpression corresponding to blog name
SetEnvIf Request_URI "^/blogs(.+/)" blog=$1
…
CustomLog "../Logs/Main/access.log" common env=!dontlog
CustomLog "../Logs/Blogs/%{blog}e.log" common env=blog
…
UnsetEnv dontlog
UnsetEnv blog
</IfModule>
…
I end up with a log containing all blog access in a file named %{blog}e.log
.