: Apache on Windows - splitting vHost logs I have a Windows Server 2008 running Apache, and it will be hosting several virtual hosts. I'd rather not use the logrotate tool (|bin/logrotate), as
I have a Windows Server 2008 running Apache, and it will be hosting several virtual hosts.
I'd rather not use the logrotate tool (|bin/logrotate), as it seems create significant extra overhead with all the processes.
Is there a simple Windows alternative to get the log entries from a combined log file split into several per-site files? Preferably with custom output directories, but that is optional.
More posts by @Phylliss660
1 Comments
Sorted by latest first Latest Oldest Best
Quoting directly from Apache 1.3 documentation on Log Files, this issue is addressed very nicely:
When running a server with many virtual hosts, there are several options for dealing with log files. First, it is possible to use logs exactly as in a single-host server. Simply by placing the logging directives outside the sections in the main server context, it is possible to log all requests in the same access log and error log. This technique does not allow for easy collection of statistics on individual virtual hosts.
If CustomLog or ErrorLog directives are placed inside a section, all requests or errors for that virtual host will be logged only to the specified file. Any virtual host which does not have logging directives will still have its requests sent to the main server logs. This technique is very useful for a small number of virtual hosts, but if the number of hosts is very large, it can be complicated to manage. In addition, it can often create problems with insufficient file descriptors.
For the access log, there is a very good compromise. By adding information on the virtual host to the log format string, it is possible to log all hosts to the same log, and later split the log into individual files. For example, consider the following directives.
LogFormat "%v %l %u %t "%r" %>s %b" comonvhost
CustomLog logs/access_log comonvhost
The %v is used to log the name of the virtual host that is serving the request. Then a program like split-logfile can be used to post-process the access log in order to split it into one file per virtual host.
Unfortunately, no similar technique is available for the error log, so you must choose between mixing all virtual hosts in the same error log and using one error log per virtual host.
Key points:
split-logfile is a program that can split the access log for you.
The error.log is either-or. You can't write it to a separate file and the combined file, while also adding an easy to see identifier.
UPDATE:
My answer addresses splitting the logs by virtualhost, but not periodic log rotation, which may not be possible on Windows without stopping and starting apache. See comments below.
Terms of Use Create Support ticket Your support tickets Stock Market News! © vmapp.org2024 All Rights reserved.