views:

181

answers:

3

Tell me about loggers and logging! Point me in the right direction so I can learn more.

Edit: Id like to know more about logging application events for debugging purposes. While the commented link to 'Logging Best Practices' is helpful, the information there is a bit over my head as it assumes previous knowledge about logging.

+1  A: 

Logging is mostly used for debugging or bug tracking.

E.g. when planes crash out of the blue nobody would know exactly what happened if this black box containing log data wasn't on board.

It's the same with your operating system and many other applications. If something breaks a good first place to go will be the a log file to see what happened right up until the end. If you're lucky you'll even find the error message that actually cause the breakdown, then google and solve it.

I think that is the main purpose of a normal log file.

You can also take advantage of it in another way and make the log file the product of the application. Like GPS loggers tracking where you went on holiday, how far you ran, etc. Then plot the data in Google Earth or something similar.

anderstornvig
I wouldn't agree with that. Logging might be used to debug a problem but it certainly isn't the same thing as debugging.
olle
logging is *NOT* debugging. Often, when debugging a problem, it can be useful to examine the logs, but logs are *not* error messages, and logging is *not* an aspect of debugging.
William Pursell
You're quite right. I may be exaggerating. Let me rephrase it then.
anderstornvig
+1  A: 

I'm not sure if you're asking about key loggers or logging events from an application, OS or whatever else out there that puts things in logs.

Basically its an excellant way to keep track of things and/or debug something that's causing you headaches.

The Windows event viewer for one is a great way to dig into what has been happening lately with your system and applications running on it.

Things can be logged to anything - from a text file to a database.

Theres a whole world out there full of logging!

CLR
+1  A: 

Logging is used to track the execution path of a program.

Ideally, using only the logs, you should be able to tell what point an application is currently at. If you are creating a web application, this becomes more difficult, as there will be many users, but the logs should be able to distinguish what kinds of executions are happening.

As I mentioned here there are generally different levels of logging, depending on what development stage you are at.

Early in development you are likely to want to log pretty much everything. Later on, you are going to only want to log the major sticking points, so that you app can run smoothly.

Logs can therefore be critical to debugging (where did it break), but they can also be used for security purposes (tracking logins and logouts), and usage statistics (how many concurrent users).

Logging is something that should be included in every architecture design so that you will be able to identify errors before they occur.