JDD2014: Working with logs - Krzysztof Otrębski
description
Transcript of JDD2014: Working with logs - Krzysztof Otrębski
Working with LogsKrzysztof 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/
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
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
•
•
•
•
•
Message Diagnostic Context (MDC)
WeatherTicketsHotels
DirectionsPayment
User A
User B
log …
log …
log …
log …
log …
log …
log …
log …
log …
log …
Requests/Responses Application
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…………….
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
Integration with IDE
Working with legacy codeWhat does the work with
legacy code look like?
Killing bugs!!