Post on 26-Dec-2014
description
“ A large fraction of the flaws in software development are due to programmers not fully understanding all the possible states their code may execute in.”
- John Carmack.
13년 2월 21일 목요일
“ A large fraction of the flaws in software development are due to programmers not fully understanding all the possible states their code may execute in.”
- John Carmack.
☛ We can fix bugs by understanding states where our code was executing in.
13년 2월 21일 목요일
Agenda
• Log?
• How to log?
• Log analysis
• Case Study
13년 2월 21일 목요일
Log?
13년 2월 21일 목요일
What is log?
• Record of continuos events
• ex) Black Box of an Airplane
• For complex, little-interaction system
• Long term iteration
13년 2월 21일 목요일
Why is log important?
• For obscure, unreproducible problems
• Pinpoint, analyze & fix
• Understand complex activities at large
• (Very) Often, log is your last resort!
13년 2월 21일 목요일
How to log
13년 2월 21일 목요일
Format
• Text, one line, consistent field delimiter
• Timestamp
• timezone, milli-seconds, NTP
• Unique identifier
• transaction id, session id
• Log level - infos as well as problems
• debug, info, warning, error, critical
13년 2월 21일 목요일
Output
• Console, file, network, etc..
• Multiple output targets
• File is a fairly reliable output
• Better to have async log writer
• Buffer & thread, throttling policy
13년 2월 21일 목요일
Rotating & archiving
• Solution for growing log files
• Disk full is common cause of false operation
• Remove old files with rules
• by size, time, backup count,
• Archiving if needed
13년 2월 21일 목요일
Configurable
• Change log level, format, output, etc..
• Config file - no recompile
• Dynamic reloading is handy
13년 2월 21일 목요일
Log Centralization
• Collect logs from various sources
• application, database, network, system, performance (iostat, vmstat, ps, ... )
• Log client / server
13년 2월 21일 목요일
A Complex System
Web Server
Web Server
SwitchWebDB
GameDBLogin Server
Game Server
BillingDB
Chat Server
Billing Server
LogDB
Client
Browser
Patcher CDN
Channel Server
13년 2월 21일 목요일
Complex Logs
Web Log
Web Log
Login Log
Game Log
Chat Log
Billing Log
Channel Log
Client Log
Patcher Log
Switch Log
13년 2월 21일 목요일
Centralized Logs
Web Log
Web Log
Login Log
Game Log
Chat Log
Billing Log
Channel Log
Client Log
Patcher Log
Switch Log
Client Log
Timeline
13년 2월 21일 목요일
Log analysis
13년 2월 21일 목요일
When?
• Developing stage
• Understand application states and flows
• Monitoring stage
• Is everything going well?
• Debugging stage
• What had happened when something went wrong?
13년 2월 21일 목요일
How?
• Classic Tools
• grep
• awk
• sed
• Custom Tools
13년 2월 21일 목요일
Case Study
13년 2월 21일 목요일
syslog• 1980 Eric Allman ( now standard )
• Separates dependencies
• Multi-purpose & devices
• system management, security auditing, informational & debugging messages
• servers, printers, routers
• Facility
• auth, daemon, cron, ftp, lpr, kern, mail, user..
13년 2월 21일 목요일
13년 2월 21일 목요일
log4j / log4cxx
• Logging utility
• Logger, appenders and layouts
• Buffering, Rotating
• Configurable
• dynamic reloading
• Plugin
13년 2월 21일 목요일
fluentd
• The Log Collector
• ‘syslogd that understands JSON’
• Pluggable Architecture
• Input(Http + JSON), Buffer(Memory, File), Output(File, AmazonS3, Fluentd, ... )
13년 2월 21일 목요일
loggly
• Cloud-based log management
• unlimited storage
• Web-based log analysis
• access logs anywhere
• Application debugging, Deployment monitoring
13년 2월 21일 목요일
13년 2월 21일 목요일
Q&A
13년 2월 21일 목요일
• python log config - http://docs.python.org/2/library/logging.config.html
• Log4j best practices - http://juliusdavies.ca/logging.html
• Logging best practices - http://dev.splunk.com/view/logging/SP-CAAADP6
• Log4j/cxx - http://logging.apache.org/log4j/2.x/ http://logging.apache.org/log4cxx/
• Fluentd - http://fluentd.org http://before30.tistory.com/179
• Loggly - http://loggly.com
Refs.
13년 2월 21일 목요일