By dalibu
Currently I have logwatch running, and via cron job it will send an email to me each evening. In the email it will list the http requests, however, it is not possible to see which virtual host they come from. For example I a report will say:
Requests with error response codes 403 Forbidden /wp-content/uploads/: 2 Time(s)
It would be better if it said:
Requests with error response codes 403 Forbidden www.mydomain.com/wp-content/uploads/: 2 Time(s)
Any ideas?
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
It seems I have answered my own question. I changed this line in apache2.conf:
LogFormat "%h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" combined
into this:
LogFormat "%h %l %u %t \"%m %{Host}i%U%q %H\" %>s %b" combined
Thanks for this, very useful. At least, the \"%m %{Host}i%U%q %H\" part is, but while changing the combined log format, you’ve also converted it to the common format, while still calling it combined.
If you want to use it as you have it here, it should really be called common, since that is what it’s based on, just adding the host. As in, you lost the %O \"%{Referer}i\" \"%{User-Agent}i\" part from the end of combined and replaced it with %b from common.
Here it is for each, and more in line with the standard Apache setup, except for adding the host in the same way:
LogFormat "%h %l %u %t \"%m %{Host}i%U%q %H\" %>s %b" common
LogFormat "%h %l %u %t \"%m %{Host}i%U%q %H\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" combined
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.