Apache2 BootCamp : Logging and Monitoring

1,095 views

Published on

Published in: Technology, Education
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
1,095
On SlideShare
0
From Embeds
0
Number of Embeds
7
Actions
Shares
0
Downloads
15
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Apache2 BootCamp : Logging and Monitoring

  1. 1. #8 Day #2 Logging and Monitoring Wildan Maulana wildan.m@openthinklabs.com http://workshop.openthinklabs.com
  2. 2. 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
  3. 3. 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
  4. 4. 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
  5. 5. Where Do You Want to Log the Information?● Logging to Files● Logging to a Program● Logging to Databases● Cluster Logging
  6. 6. 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”” myformat CustomLog logs/access_log myformatCustomLog logs/access_log “%h %l %u %t ”%r” %>s %b ”%{User-agent}i””
  7. 7. Where Do You Want to Log the Information? Logging to a Program |
  8. 8. Where Do You Want to Log the Information? Logging to Databases http://bit.ly/c8EiYy
  9. 9. Where Do You Want to Log the Information? Cluster Logging mod_log_spread
  10. 10. Conditional Logging● The HostNameLookups Directive● The IdentityCheck Directive● Environment Variables● Status Code
  11. 11. Conditional LoggingThe HostNameLookups DirectiveHostNameLookups on|off|double
  12. 12. Conditional LoggingThe IdentityCheck Directive IdentityCheck on|off
  13. 13. Conditional Logging Environment VariablesSetEnvIf Request_URI “(.gif|.jpg)$” imageCustomLog logs/access_log common env=!image
  14. 14. Conditional Logging Status Code %400,501{User-agent}i400 : malformed requests 501 : methods not implemented
  15. 15. Error Messages● Logging to a File● Logging to a Program● The syslog Daemon Argument● The LogLevel Directive
  16. 16. Error Messages Logging to a FileErrorLog logs/my_error_log
  17. 17. Error Messages Logging to a ProgramErrorLog “|/usr/local/bin/someprogram”
  18. 18. Error MessagesThe syslog Daemon Argument ErrorLog syslog:local6
  19. 19. Monitoring Apache <Location /server-info> SetHandler server-info Order deny,allow Deny from allmod_info Allow from .example.com </Location> mod_status <Location /server-status> SetHandler server-status Order deny,allow Deny from all Allow from .example.com </Location>
  20. 20. Error Messages The LogLevel Directive LogLevel warnhttp://httpd.apache.org/docs/2.0/mod/core.html#loglevel
  21. 21. Managing Logs● Resolving Hostnames● Log Rotation● Merging and Splitting Logs● Logging to Databases● Log Analysis● Monitoring Error Logs
  22. 22. Common Errors● Connection Reset by Peer● File favico.icon Not Found● File robots.txt Not Found● httpd.pid Overwritten
  23. 23. Q&Ahttp://workshop.openthinklabs.com/resources
  24. 24. Reference● Daniel Lopez Ridruezo; SAMS Teach Yourself Apache2 in 24 Hours, SAMS Publishing, 2002 (Buy this book on Amazon)

×