1

We currently have a simple Log class that can take in an exception. In our business logic if we happen to need a try/catch around a specific set of code, we log the exception and then rethrow it. The problem is that our Log class is in a common dll and when it writes the log I want to be able to also grab the path of the offending code (e.g. "D:\application\libraries"). Is there a simple way to do this without always having to pass in the executing assembly path to the logger each time?

Edit: Forgot to mention we're using C# 4.0.

starblue
  • 55,348
  • 14
  • 97
  • 151
jaryd
  • 861
  • 12
  • 21

1 Answers1

1

Have you tried with Assembly.GetCallingAssembly() inside your log method?

Sebastian Piu
  • 7,838
  • 1
  • 32
  • 50
  • Seems to work although I will have to do some string formatting to make it look "pretty" but it does get the job done. Thanks. – jaryd Oct 20 '10 at 13:59