Logging
and why it’s the shit.
You are going to love logging!
Ever had to debug a live issue and had no
information to go on?
The aim of logging is to tell the story
of what the application is doing
You tell the story to ILog
private static readonly ILog _log =
LogManager.GetLogger(typeof(Foo));
There are 4 different log levels
Info
High level user activity
_log.InfoFormat(
"User {0} has just logged in",
user.Id
);
Debug
Details of the internal logic of a method
_log.DebugFormat(
"User {0} needs to pay {2} bills",
user.Id, user.Bills.Count
);
Warn
Something suspicious has happened from
which we have recovered but...
if this happens a lot, we need to investigate
_log.WarnFormat(
"User {0} tried to hack our servers",
user.Id
);
Error
Something went seriously wrong - this requires
investigation because it means we have a bug.
_log.ErrorFormat(
"Could not find User {0}’s bills",
user.Id
);
Where the hell are the logs a
and how do we use them?
tail -f is your friend
Adding an identifier (e.g. user id) to your logs
makes it easier to grep
Some do’s & don’ts
DO create a logger in
every class you use
DON’T be afraid
of doing LOTS of
logging
Questions?
Thanks to
Ed Devlin (Who initially came up with these guidelines)
David Padbury (Who I stole these slides from)
Images
Goo...
Upcoming SlideShare
Loading in...5
×

Logging

768

Published on

0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
768
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
21
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

Logging

  1. 1. Logging and why it’s the shit.
  2. 2. You are going to love logging!
  3. 3. Ever had to debug a live issue and had no information to go on?
  4. 4. The aim of logging is to tell the story of what the application is doing
  5. 5. You tell the story to ILog
  6. 6. private static readonly ILog _log = LogManager.GetLogger(typeof(Foo));
  7. 7. There are 4 different log levels
  8. 8. Info
  9. 9. High level user activity
  10. 10. _log.InfoFormat( "User {0} has just logged in", user.Id );
  11. 11. Debug
  12. 12. Details of the internal logic of a method
  13. 13. _log.DebugFormat( "User {0} needs to pay {2} bills", user.Id, user.Bills.Count );
  14. 14. Warn
  15. 15. Something suspicious has happened from which we have recovered but... if this happens a lot, we need to investigate
  16. 16. _log.WarnFormat( "User {0} tried to hack our servers", user.Id );
  17. 17. Error
  18. 18. Something went seriously wrong - this requires investigation because it means we have a bug.
  19. 19. _log.ErrorFormat( "Could not find User {0}’s bills", user.Id );
  20. 20. Where the hell are the logs a and how do we use them?
  21. 21. tail -f is your friend
  22. 22. Adding an identifier (e.g. user id) to your logs makes it easier to grep
  23. 23. Some do’s & don’ts
  24. 24. DO create a logger in every class you use
  25. 25. DON’T be afraid of doing LOTS of logging
  26. 26. Questions?
  27. 27. Thanks to Ed Devlin (Who initially came up with these guidelines) David Padbury (Who I stole these slides from) Images Good Friends by Juliana Coutinho, http://www.flickr.com/photos/ngmmemuda/4166182931/ Four Colors by by Tambako the Jaguar http://www.flickr.com/photos/tambako/2390708966/ Engineering Information by Calistobreeze http://www.flickr.com/photos/callisto/2172555529/ Swat by fengschwing http://www.flickr.com/photos/fengschwing/4931950933/ Comments and faves by bumblesweet http://www.flickr.com/photos/bumblesweet/4253655700/ Ahhhhhhh by kennymatic http://www.flickr.com/photos/kwl/4678498113/in/set-72157623544311963/ What is going on? by SAN_DRINO, http://www.flickr.com/photos/san_drino/1454922072/ The Simple Life by kennymatic http://www.flickr.com/photos/kwl/4574642827/in/set-72157623544311963/ the_dos_and_donts_with_babies_001 by DrJohnBullas http://www.flickr.com/photos/johnbullas/2247403198/ What the wut? by kennymatic http://www.flickr.com/photos/kwl/4514986410/in/set-72157623544311963/
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×