Logging 101

28
“ 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. 13221목요일

description

로깅에 관한 기본 + 알파를 정리하려 하였으나, 수박 겉핡기

Transcript of Logging 101

Page 1: Logging 101

“ 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일 목요일

Page 2: Logging 101

“ 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일 목요일

Page 4: Logging 101

Agenda

• Log?

• How to log?

• Log analysis

• Case Study

13년 2월 21일 목요일

Page 5: Logging 101

Log?

13년 2월 21일 목요일

Page 6: Logging 101

What is log?

• Record of continuos events

• ex) Black Box of an Airplane

• For complex, little-interaction system

• Long term iteration

13년 2월 21일 목요일

Page 7: Logging 101

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일 목요일

Page 8: Logging 101

How to log

13년 2월 21일 목요일

Page 9: Logging 101

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일 목요일

Page 10: Logging 101

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일 목요일

Page 11: Logging 101

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일 목요일

Page 12: Logging 101

Configurable

• Change log level, format, output, etc..

• Config file - no recompile

• Dynamic reloading is handy

13년 2월 21일 목요일

Page 13: Logging 101

Log Centralization

• Collect logs from various sources

• application, database, network, system, performance (iostat, vmstat, ps, ... )

• Log client / server

13년 2월 21일 목요일

Page 14: Logging 101

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일 목요일

Page 15: Logging 101

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일 목요일

Page 16: Logging 101

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일 목요일

Page 17: Logging 101

Log analysis

13년 2월 21일 목요일

Page 18: Logging 101

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일 목요일

Page 19: Logging 101

How?

• Classic Tools

• grep

• awk

• sed

• Custom Tools

13년 2월 21일 목요일

Page 20: Logging 101

Case Study

13년 2월 21일 목요일

Page 21: Logging 101

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일 목요일

Page 22: Logging 101

13년 2월 21일 목요일

Page 23: Logging 101

log4j / log4cxx

• Logging utility

• Logger, appenders and layouts

• Buffering, Rotating

• Configurable

• dynamic reloading

• Plugin

13년 2월 21일 목요일

Page 24: Logging 101

fluentd

• The Log Collector

• ‘syslogd that understands JSON’

• Pluggable Architecture

• Input(Http + JSON), Buffer(Memory, File), Output(File, AmazonS3, Fluentd, ... )

13년 2월 21일 목요일

Page 25: Logging 101

loggly

• Cloud-based log management

• unlimited storage

• Web-based log analysis

• access logs anywhere

• Application debugging, Deployment monitoring

13년 2월 21일 목요일

Page 26: Logging 101

13년 2월 21일 목요일

Page 27: Logging 101

Q&A

13년 2월 21일 목요일