State of the art logging
-
Upload
milan-vukoje -
Category
Technology
-
view
260 -
download
0
description
Transcript of State of the art logging
![Page 1: State of the art logging](https://reader034.fdocuments.in/reader034/viewer/2022051212/55972fab1a28ab43518b4637/html5/thumbnails/1.jpg)
Milan Vukoje
www.vukoje.net
State of the art logging
October 23rd 2013
![Page 3: State of the art logging](https://reader034.fdocuments.in/reader034/viewer/2022051212/55972fab1a28ab43518b4637/html5/thumbnails/3.jpg)
Topics
• What is tracing?
• How to build it?
• Logger as profiler
• Logger design
• Log analysis
• Demo 1 – WEBCOM trace analysis GUI
• Demo 2 – AOP logging in MVC with NLog and Glimpse
![Page 4: State of the art logging](https://reader034.fdocuments.in/reader034/viewer/2022051212/55972fab1a28ab43518b4637/html5/thumbnails/4.jpg)
What is tracing?
• How to know what is production system doing?• Why not remote debugging?• Why not profiler?• What more?
• Debugging• Profiling• Notifications• logs as data
![Page 5: State of the art logging](https://reader034.fdocuments.in/reader034/viewer/2022051212/55972fab1a28ab43518b4637/html5/thumbnails/5.jpg)
So how to build it?
• Custom solution?• System.Diagnostics.Trace?• IntelliTrace?• Log4Net?
• no support for CSV• no support for dynamic file naming• java port with a bit awkward code• last release in 2006
• Nlog?• simple• good code• Plenty of features• side project by MS employee
![Page 6: State of the art logging](https://reader034.fdocuments.in/reader034/viewer/2022051212/55972fab1a28ab43518b4637/html5/thumbnails/6.jpg)
Where to store logs?
• File system• Accessibility• Cleanup• Replication• Affecting speed
• Event log• Database• Cloud• App memory
• web farms?• session dependency• Out of memory
![Page 7: State of the art logging](https://reader034.fdocuments.in/reader034/viewer/2022051212/55972fab1a28ab43518b4637/html5/thumbnails/7.jpg)
Logger as profiler
• When off – no impact• When on – trivial impact• Delay messages formatting!• Avoid DateTime.Now;• Use StopWatch.GetTimeStamp();
![Page 8: State of the art logging](https://reader034.fdocuments.in/reader034/viewer/2022051212/55972fab1a28ab43518b4637/html5/thumbnails/8.jpg)
“using” vs. start/end logs
• better for functions with multiple exit points• works good with exception control flow• less repeated work• better support for automatization
![Page 9: State of the art logging](https://reader034.fdocuments.in/reader034/viewer/2022051212/55972fab1a28ab43518b4637/html5/thumbnails/9.jpg)
Logger design issues
• Hide behind facade• Logger must not break• Should not be transactional• GUI for runtime configuration• Redundant logs• Editable logs• Logs size and cleanup• Avoid conditional tracing
![Page 10: State of the art logging](https://reader034.fdocuments.in/reader034/viewer/2022051212/55972fab1a28ab43518b4637/html5/thumbnails/10.jpg)
Log levels
• Levels are not informative enough• We need more meaningful API• Trace (Low/High)
• debug and performance info• Events (Info/Warn/Error/Fatal)
• durable info with different types • suitable for monitoring• much less than trace
![Page 11: State of the art logging](https://reader034.fdocuments.in/reader034/viewer/2022051212/55972fab1a28ab43518b4637/html5/thumbnails/11.jpg)
Log entity data
• Message/title + description• Log level• Timestamp• Exception call stack• Logger name - extracted from class name
• Additional data• labels (categories)• ticks
![Page 12: State of the art logging](https://reader034.fdocuments.in/reader034/viewer/2022051212/55972fab1a28ab43518b4637/html5/thumbnails/12.jpg)
Log context data
• Event context • App/Tenant/User/HttpRequest…
• Trace buffer• Session buffer• Trace call back and tag
![Page 13: State of the art logging](https://reader034.fdocuments.in/reader034/viewer/2022051212/55972fab1a28ab43518b4637/html5/thumbnails/13.jpg)
AOP vs. manual logging
![Page 14: State of the art logging](https://reader034.fdocuments.in/reader034/viewer/2022051212/55972fab1a28ab43518b4637/html5/thumbnails/14.jpg)
AOP vs. manual logging
• AOP• easy• too much logs• no explanations, just method names
• Manual• boring• repetitive• better control• better meaning
• Combine them!• Explain through logs
![Page 15: State of the art logging](https://reader034.fdocuments.in/reader034/viewer/2022051212/55972fab1a28ab43518b4637/html5/thumbnails/15.jpg)
How to scope logs?
• No scoping• Per app• Per server• Per tenant• Per user • Per user action• Configurable
![Page 16: State of the art logging](https://reader034.fdocuments.in/reader034/viewer/2022051212/55972fab1a28ab43518b4637/html5/thumbnails/16.jpg)
Log analysis?
• Log as data• Notepad(++)• Excel (csv)• LogParser studio• Integrated app tool
![Page 17: State of the art logging](https://reader034.fdocuments.in/reader034/viewer/2022051212/55972fab1a28ab43518b4637/html5/thumbnails/17.jpg)
Demo 1 – WEBCOM trace analysis GUI
![Page 18: State of the art logging](https://reader034.fdocuments.in/reader034/viewer/2022051212/55972fab1a28ab43518b4637/html5/thumbnails/18.jpg)
Demo 2 – AOP logging in MVC web app using NLog and Glimpse
![Page 19: State of the art logging](https://reader034.fdocuments.in/reader034/viewer/2022051212/55972fab1a28ab43518b4637/html5/thumbnails/19.jpg)
Thank you for your attention!
Any Questions?