jdd2014: working with logs - krzysztof otrębski

9
Working with Logs Krzysztof Otrębski

Upload: proidea

Post on 01-Jul-2015

71 views

Category:

Software


1 download

DESCRIPTION

Most developers in their work have probably dealt with logging frameworks as nowadays almost any non-trivial application makes use of them. Although there exists a large number of logging frameworks that manage to get their job done right, it is still difficult to find a program that would help analyze the log files. Most of the time the developer ends up using popular tools like "grep | less". In this session I will briefly discuss: * how to organize logs * what is useful about logs * how to browse logs and what are the available tools * how to cope with legacy code.

TRANSCRIPT

Page 1: JDD2014: Working with logs - Krzysztof Otrębski

Working with LogsKrzysztof Otrębski

Page 2: JDD2014: Working with logs - Krzysztof Otrębski

Long time ago I used to…

Work with legacy code

Depend on logs as the main source ofinformation

http://www.thebrieflife.com/2013/02/24/the-sisyphean-challenge/

Page 3: JDD2014: Working with logs - Krzysztof Otrębski

Divide and ConquerAn example webapplication

Application

WeatherTicketsHotels

DirectionsPayment

Requests/Responses

SOAP-XML

JSON

SOAP-XML

SOAP-XML

SOAP-XML

JSON

app.logweather.log

tickets.log

hotels.log

directions.log

payment.log

traffic.log

Page 4: JDD2014: Working with logs - Krzysztof Otrębski

How to select logs onearly and late stagePreliminary log selection

Logging different components intoseparate files

Rolling files daily

‘On demand’ log selection

Adding class, thread, level, date to alog event

Page 5: JDD2014: Working with logs - Krzysztof Otrębski

Message Diagnostic Context (MDC)

WeatherTicketsHotels

DirectionsPayment

User A

User B

log …

log …

log …

log …

log …

log …

log …

log …

log …

log …

Requests/Responses Application

Page 6: JDD2014: Working with logs - Krzysztof Otrębski

Do the same for tests

TestClass1testMethod1-1testMethod1-2testMethod1-3

log…………….

log…………….

log…………….

log…………….

log…………….

log…………….

log…………….

log…….log…………….

TestClass2testMethod2-1testMethod2-2

testMethod2-3

log…………….

log…………….

log…………….

log…………….

log…………….

log…………….

log…………….

log…….log…………….

Page 7: JDD2014: Working with logs - Krzysztof Otrębski

Huston, we have a problemMy application uses threads for parallel

computing

new Thread(new MyRunnable()).start() will passMDC

In some cases we lose control on threadcreation

•java.util.concurrent.Executors

Page 8: JDD2014: Working with logs - Krzysztof Otrębski

Integration with IDE

Page 9: JDD2014: Working with logs - Krzysztof Otrębski

Working with legacy codeWhat does the work with

legacy code look like?

Killing bugs!!