Click here to Skip to main content
15,889,877 members
Home / Discussions / C#
   

C#

 
AnswerRe: Need a little hint my brain is burned out Pin
Clifford Nelson26-Oct-12 9:20
Clifford Nelson26-Oct-12 9:20 
Questionapplication logging strategy - advice Pin
Simon_Whale25-Oct-12 4:22
Simon_Whale25-Oct-12 4:22 
AnswerRe: application logging strategy - advice Pin
Richard MacCutchan25-Oct-12 6:23
mveRichard MacCutchan25-Oct-12 6:23 
GeneralRe: application logging strategy - advice Pin
R. Giskard Reventlov25-Oct-12 6:37
R. Giskard Reventlov25-Oct-12 6:37 
GeneralRe: application logging strategy - advice Pin
Simon_Whale25-Oct-12 11:50
Simon_Whale25-Oct-12 11:50 
AnswerRe: application logging strategy - advice Pin
Eddy Vluggen25-Oct-12 8:41
professionalEddy Vluggen25-Oct-12 8:41 
GeneralRe: application logging strategy - advice Pin
Simon_Whale25-Oct-12 12:01
Simon_Whale25-Oct-12 12:01 
AnswerRe: application logging strategy - advice Pin
jschell25-Oct-12 10:43
jschell25-Oct-12 10:43 
Simon_Whale wrote:
what I am asking is advice / help or even pointers to a good logging strategy.


There are several definitions for logging. I have taken to using the following definitions.
1. Audit logging. This involves tracking what 'users' are doing on the system. For example if a user deletes a record then a 'audit log' is created. This can be driven 'users' that are not actually people such as a 3rd party application.
2. Operations logging. This is information collected specifically to assist operations staff in diagnosing expected error conditions. For example if a third party web service goes down then operations needs to know about it.
3. Trace logging. This is logging that assist a developer in determining why a system failed due to unexpected problems. It will often require familiarity with the code base to understand everything.

Audit logging is defined by business requirements.
Operations logging is defined mostly by operations but can be guessed at by development.
Trace logging is solely dependent on development making educated guesses about failure points.



Specifically for trace logging...

Trace logging does NOT work if it does not exist in the production system. Thus trace logging is NOT a tool that is used during development. That doesn't mean you can't add logging to figure out some obscure problem while you are writing code but it does mean that the logging statements that are left in must be manageable in production.

It also means that logging must exist in the production system. It is not turned off nor turned down.

Trace logging can be used by operations but operations does not dictate, control nor otherwise own it. Operations can make suggestions for improvements but consideration should be given that operations has their own log and thus most times what they want should be in there and not in the trace log.

In general logging (trace logging) cannot use a off box repository (database,etc) because both of those can fail. And with such failures there must be some way to log that.

Trace logging must not stop the real application from running. Compare this to audit logging which one might code such that the application stops working if it can no longer do audit logging.

With smaller systems it often seems possible and desirable to do things like log the entry and exit from every major method. However that is impossible in systems will larger volumes. Both because the log files can become large very quickly (think 10 of gigs daily or larger) and because finding anything when there is a lot of data becomes a problem.

So addressing large system only one can come up with the following
- Log exceptions but insure that they only log once. In practice this means that if you catch an exception and log it you do NOT re-throw it.
- Log entry and exit (including success/failure) from major functional areas.
- Provide a trace id for every message in the application and even better in the system. When logging relevant to message processing then always log with that id.
- Log off box request/response attempts. This includes success and failure. Especially when going to a 3rd party.
- Avoiding logging in looping structures. This is to reduce noise. Logging at the beginning and the end is sufficient.
- Avoid duplicate logging. If you load configuration information don't log it every time you access the configuration information, but only the first time.
- Log messages must contain relevant information. Thus don't log "x=3" but instead "result of order query=3"
- Log messages are not a dumping ground for development. Developers must keep in mind that the log file is not an infinite resource and also keep in mind that although they will need to use it to debut problems that unnecessary log lines can multiply hundreds of thousands of times in production and thus make it that much harder to determine problems. The log file provides assistance but not solutions to unknown problems.

Another trick that I have found valuable works in some scenarios with exception handling.
- This is often a boundary layer system.
- I catch an exception, log it along with an id (GUID).
- I throw another exception with a message that is appropriate for the boundary layer and I include the id as part of the message.

The advantage of the above is that upstream, perhaps a user or a third party system gets an error message that means something to them. And questions about that can be address in the context of finding the exception cause in the log file with the id if that becomes necessary.
GeneralRe: application logging strategy - advice Pin
Simon_Whale25-Oct-12 12:02
Simon_Whale25-Oct-12 12:02 
AnswerRe: application logging strategy - advice Pin
V.25-Oct-12 21:10
professionalV.25-Oct-12 21:10 
Questionapplicatin developing in c# Pin
krishnaveni_g24-Oct-12 23:29
krishnaveni_g24-Oct-12 23:29 
AnswerRe: applicatin developing in c# Pin
Eddy Vluggen24-Oct-12 23:35
professionalEddy Vluggen24-Oct-12 23:35 
AnswerRe: applicatin developing in c# Pin
Sivaraman Dhamodharan24-Oct-12 23:47
Sivaraman Dhamodharan24-Oct-12 23:47 
AnswerMy vote of 1 Pin
Keith Barrow25-Oct-12 2:49
professionalKeith Barrow25-Oct-12 2:49 
AnswerRe: applicatin developing in c# Pin
Vasudevan Deepak Kumar25-Oct-12 8:54
Vasudevan Deepak Kumar25-Oct-12 8:54 
GeneralRe: applicatin developing in c# Pin
V.26-Oct-12 2:39
professionalV.26-Oct-12 2:39 
AnswerRe: applicatin developing in c# Pin
gopal pradhan8-Nov-12 23:33
gopal pradhan8-Nov-12 23:33 
AnswerRe: applicatin developing in c# Pin
gopal pradhan8-Nov-12 23:34
gopal pradhan8-Nov-12 23:34 
QuestionCreate single setup to install x64 & x86 msi Pin
honeyashu24-Oct-12 21:40
honeyashu24-Oct-12 21:40 
AnswerRe: Create single setup to install x64 & x86 msi Pin
Mycroft Holmes24-Oct-12 22:25
professionalMycroft Holmes24-Oct-12 22:25 
GeneralRe: Create single setup to install x64 & x86 msi Pin
honeyashu24-Oct-12 23:25
honeyashu24-Oct-12 23:25 
GeneralRe: Create single setup to install x64 & x86 msi Pin
Dave Kreskowiak25-Oct-12 4:13
mveDave Kreskowiak25-Oct-12 4:13 
GeneralRe: Create single setup to install x64 & x86 msi Pin
honeyashu25-Oct-12 18:10
honeyashu25-Oct-12 18:10 
GeneralRe: Create single setup to install x64 & x86 msi Pin
Dave Kreskowiak25-Oct-12 18:26
mveDave Kreskowiak25-Oct-12 18:26 
AnswerRe: Create single setup to install x64 & x86 msi Pin
BobJanova24-Oct-12 22:34
BobJanova24-Oct-12 22:34 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.