apache2 bootcamp : logging and monitoring
TRANSCRIPT
![Page 2: Apache2 BootCamp : Logging and Monitoring](https://reader034.vdocuments.net/reader034/viewer/2022052619/5558be3ed8b42a7e298b522b/html5/thumbnails/2.jpg)
Overview
● Understand log formats and logging levels● Rotate and analyze logs● Interpret common errors that might appear in
your logs● Monitor Apache resource usage and
performance using mod_status
![Page 3: Apache2 BootCamp : Logging and Monitoring](https://reader034.vdocuments.net/reader034/viewer/2022052619/5558be3ed8b42a7e298b522b/html5/thumbnails/3.jpg)
Logging HTTP Requests
● Define what you want to log; your log format● Define where you want to log it; your log files, a
database, an external program● Define whether or not to log; conditional
logging rules
![Page 4: Apache2 BootCamp : Logging and Monitoring](https://reader034.vdocuments.net/reader034/viewer/2022052619/5558be3ed8b42a7e298b522b/html5/thumbnails/4.jpg)
What Do You Want to Log?
● Common Log Format (CLF) :“%h %l %u %t \”%r\” %>s %b”
10.0.0.1 - - [19/Nov/2001:11:34:56 -0800] “GET / HTTP/1.1” 200 1456
LogFormat “%h %l %u %t \”%r\” %>s %b” common
Log Formatting Directives : http://bit.ly/lAayTL
![Page 5: Apache2 BootCamp : Logging and Monitoring](https://reader034.vdocuments.net/reader034/viewer/2022052619/5558be3ed8b42a7e298b522b/html5/thumbnails/5.jpg)
Where Do You Want to Log the Information?
● Logging to Files● Logging to a Program● Logging to Databases● Cluster Logging
![Page 6: Apache2 BootCamp : Logging and Monitoring](https://reader034.vdocuments.net/reader034/viewer/2022052619/5558be3ed8b42a7e298b522b/html5/thumbnails/6.jpg)
Where Do You Want to Log the Information?Logging to Files
LogFormat “%h %l %u %t \”%r\” %>s %b \”%{User-agent}i\””TransferLog logs/access_log
LogFormat “%h %l %u %t \”%r\” %>s %b \”%{User-agent}i\”” myformatCustomLog logs/access_log myformat
CustomLog logs/access_log “%h %l %u %t \”%r\” %>s %b \”%{User-agent}i\””
![Page 7: Apache2 BootCamp : Logging and Monitoring](https://reader034.vdocuments.net/reader034/viewer/2022052619/5558be3ed8b42a7e298b522b/html5/thumbnails/7.jpg)
Where Do You Want to Log the Information?Logging to a Program
|
![Page 8: Apache2 BootCamp : Logging and Monitoring](https://reader034.vdocuments.net/reader034/viewer/2022052619/5558be3ed8b42a7e298b522b/html5/thumbnails/8.jpg)
Where Do You Want to Log the Information?Logging to Databases
http://bit.ly/c8EiYy
![Page 9: Apache2 BootCamp : Logging and Monitoring](https://reader034.vdocuments.net/reader034/viewer/2022052619/5558be3ed8b42a7e298b522b/html5/thumbnails/9.jpg)
Where Do You Want to Log the Information?Cluster Logging
mod_log_spread
![Page 10: Apache2 BootCamp : Logging and Monitoring](https://reader034.vdocuments.net/reader034/viewer/2022052619/5558be3ed8b42a7e298b522b/html5/thumbnails/10.jpg)
Conditional Logging
● The HostNameLookups Directive● The IdentityCheck Directive● Environment Variables● Status Code
![Page 11: Apache2 BootCamp : Logging and Monitoring](https://reader034.vdocuments.net/reader034/viewer/2022052619/5558be3ed8b42a7e298b522b/html5/thumbnails/11.jpg)
Conditional LoggingThe HostNameLookups Directive
HostNameLookups on|off|double
![Page 12: Apache2 BootCamp : Logging and Monitoring](https://reader034.vdocuments.net/reader034/viewer/2022052619/5558be3ed8b42a7e298b522b/html5/thumbnails/12.jpg)
Conditional LoggingThe IdentityCheck Directive
IdentityCheck on|off
![Page 13: Apache2 BootCamp : Logging and Monitoring](https://reader034.vdocuments.net/reader034/viewer/2022052619/5558be3ed8b42a7e298b522b/html5/thumbnails/13.jpg)
Conditional LoggingEnvironment Variables
SetEnvIf Request_URI “(\.gif|\.jpg)$” imageCustomLog logs/access_log common env=!image
![Page 14: Apache2 BootCamp : Logging and Monitoring](https://reader034.vdocuments.net/reader034/viewer/2022052619/5558be3ed8b42a7e298b522b/html5/thumbnails/14.jpg)
Conditional LoggingStatus Code
%400,501{User-agent}i
400 : malformed requests501 : methods not implemented
![Page 15: Apache2 BootCamp : Logging and Monitoring](https://reader034.vdocuments.net/reader034/viewer/2022052619/5558be3ed8b42a7e298b522b/html5/thumbnails/15.jpg)
Error Messages
● Logging to a File● Logging to a Program● The syslog Daemon Argument● The LogLevel Directive
![Page 16: Apache2 BootCamp : Logging and Monitoring](https://reader034.vdocuments.net/reader034/viewer/2022052619/5558be3ed8b42a7e298b522b/html5/thumbnails/16.jpg)
Error MessagesLogging to a File
ErrorLog logs/my_error_log
![Page 17: Apache2 BootCamp : Logging and Monitoring](https://reader034.vdocuments.net/reader034/viewer/2022052619/5558be3ed8b42a7e298b522b/html5/thumbnails/17.jpg)
Error MessagesLogging to a Program
ErrorLog “|/usr/local/bin/someprogram”
![Page 18: Apache2 BootCamp : Logging and Monitoring](https://reader034.vdocuments.net/reader034/viewer/2022052619/5558be3ed8b42a7e298b522b/html5/thumbnails/18.jpg)
Error MessagesThe syslog Daemon Argument
ErrorLog syslog:local6
![Page 19: Apache2 BootCamp : Logging and Monitoring](https://reader034.vdocuments.net/reader034/viewer/2022052619/5558be3ed8b42a7e298b522b/html5/thumbnails/19.jpg)
Monitoring Apache
mod_info
mod_status
<Location /server-status>SetHandler server-statusOrder deny,allowDeny from allAllow from .example.com</Location>
<Location /server-info>SetHandler server-infoOrder deny,allowDeny from allAllow from .example.com</Location>
![Page 20: Apache2 BootCamp : Logging and Monitoring](https://reader034.vdocuments.net/reader034/viewer/2022052619/5558be3ed8b42a7e298b522b/html5/thumbnails/20.jpg)
Error MessagesThe LogLevel Directive
LogLevel warn
http://httpd.apache.org/docs/2.0/mod/core.html#loglevel
![Page 21: Apache2 BootCamp : Logging and Monitoring](https://reader034.vdocuments.net/reader034/viewer/2022052619/5558be3ed8b42a7e298b522b/html5/thumbnails/21.jpg)
Managing Logs
● Resolving Hostnames● Log Rotation● Merging and Splitting Logs● Logging to Databases● Log Analysis● Monitoring Error Logs
![Page 22: Apache2 BootCamp : Logging and Monitoring](https://reader034.vdocuments.net/reader034/viewer/2022052619/5558be3ed8b42a7e298b522b/html5/thumbnails/22.jpg)
Common Errors
● Connection Reset by Peer● File favico.icon Not Found● File robots.txt Not Found● httpd.pid Overwritten
![Page 23: Apache2 BootCamp : Logging and Monitoring](https://reader034.vdocuments.net/reader034/viewer/2022052619/5558be3ed8b42a7e298b522b/html5/thumbnails/23.jpg)
Q&Ahttp://workshop.openthinklabs.com/resources
![Page 24: Apache2 BootCamp : Logging and Monitoring](https://reader034.vdocuments.net/reader034/viewer/2022052619/5558be3ed8b42a7e298b522b/html5/thumbnails/24.jpg)
Reference
● Daniel Lopez Ridruezo; SAMS Teach Yourself Apache2 in 24 Hours, SAMS Publishing, 2002 (Buy this book on Amazon)