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!!


Top Related