This is the whole purpose of logging — to reveal the problems. If it logs twice, it means the code context calling this log is called twice. If this is not supposed to be that way,
my congratulations: you used logging properly, so it
already helped you to detect a defect. Now, put more information in the logs and find out how to fix it. One practical advice: in the code fragment in question, you can examine where it is called in different stages of your application run time, by examining of the call stack in these points, in case when there are no exceptions to dump. To do that, please use the class
System.Diagnostics.StackTrace
:
http://msdn.microsoft.com/en-us/library/system.diagnostics.stacktrace%28v=vs.100%29.aspx[
^].
Learn more from the facilities of
System.Diagnostics
; they are very useful:
http://msdn.microsoft.com/en-us/library/system.diagnostics%28v=vs.100%29.aspx[
^].
In most cases, you should be able to use the debugger. The event log is used primarily in the cases when debugging is too difficult or the debugging session is not accessible for you, for example, if the process is executed only in your customer's location which is out of your control. It's the best to do as much debugging as you can using the Debugger on some development computer.
That's all I could advise based on your limited information. You are quite welcome to ask some follow-up questions though.
Good luck,
—SA