Apache2 BootCamp : Logging and Monitoring
-
Upload
wildan-maulana -
Category
Technology
-
view
830 -
download
0
Transcript of Apache2 BootCamp : Logging and Monitoring
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
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
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
Where Do You Want to Log the Information?
● Logging to Files● Logging to a Program● Logging to Databases● Cluster Logging
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\””
Where Do You Want to Log the Information?Logging to a Program
|
Where Do You Want to Log the Information?Logging to Databases
http://bit.ly/c8EiYy
Where Do You Want to Log the Information?Cluster Logging
mod_log_spread
Conditional Logging
● The HostNameLookups Directive● The IdentityCheck Directive● Environment Variables● Status Code
Conditional LoggingThe HostNameLookups Directive
HostNameLookups on|off|double
Conditional LoggingThe IdentityCheck Directive
IdentityCheck on|off
Conditional LoggingEnvironment Variables
SetEnvIf Request_URI “(\.gif|\.jpg)$” imageCustomLog logs/access_log common env=!image
Conditional LoggingStatus Code
%400,501{User-agent}i
400 : malformed requests501 : methods not implemented
Error Messages
● Logging to a File● Logging to a Program● The syslog Daemon Argument● The LogLevel Directive
Error MessagesLogging to a File
ErrorLog logs/my_error_log
Error MessagesLogging to a Program
ErrorLog “|/usr/local/bin/someprogram”
Error MessagesThe syslog Daemon Argument
ErrorLog syslog:local6
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>
Error MessagesThe LogLevel Directive
LogLevel warn
http://httpd.apache.org/docs/2.0/mod/core.html#loglevel
Managing Logs
● Resolving Hostnames● Log Rotation● Merging and Splitting Logs● Logging to Databases● Log Analysis● Monitoring Error Logs
Common Errors
● Connection Reset by Peer● File favico.icon Not Found● File robots.txt Not Found● httpd.pid Overwritten
Q&Ahttp://workshop.openthinklabs.com/resources
Reference
● Daniel Lopez Ridruezo; SAMS Teach Yourself Apache2 in 24 Hours, SAMS Publishing, 2002 (Buy this book on Amazon)