Logging 101

Post on 26-Dec-2014

277 views 0 download

description

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

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

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

Logging 101haje01@gmail.com

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