I wonder what exactly should I log. I mean, I can log exceptions and this is pretty standard, but can I use Elmah to log other things?
I actually don't use that many try, catch blocks. I read that these should be used only for special cases exceptions not for "standard behavior" because they can slow down performance.
Usually I prevent exceptions from occurring using simple if clause.
For example in simple division by 0.
int z = x/y;
I will write this as follows:
int z;
if(y!=0)
{
z = x/y;
}
else
{
z=0;
}
Now this is perfectly acceptable for me.
I don't consider this to be an exception but still... I would like to know that somewhere the y parameter equals 0.
Is it ok to log this information using Elmah ? Or should I use something else?
You can easy log with elmah manually. Just call:
For custom message just run:
You can also decide to use log4net or nlog for more complex logging and use Elmah appender