user550738
user550738

Reputation:

How to add logging in .NET runtime or to a C# application that's already been distributed to customers?

I have inherited a massive C# application, server (a windows service) and client (windows desktop application).

It's deployed at a variety of customer locations.

I have a list of customer issues and bugs to address, but the logging in the application is woefully inadequate.

A couple of times I've taken to adding new lines of logging in the code, rebuilding the code, sending the customer the new DLLs and asking them to install them manually, but this is a very kludgey way to debugging customer problems.

Is there a way to just tell the VM (the dot net runtime engine) to produce a log file of what objects were instantiated, and which methods were entered and exited ... maybe even line numbers of lines of code that were executed?

That sort of thing would help me incredibly.

Upvotes: 1

Views: 905

Answers (1)

Kelly Elton
Kelly Elton

Reputation: 4427

No that's not possible to just tell the VM to log things like that. You can however trace everything in your program(method calls etc).

You can use PostSharp to log detailed info on method calls(you don't need this, but this would provide you an automated way to do it in a large project).

There are also some nice alternatives to PostSharp, such as Loom.net and PostCrap.

Your next option is to modify the exe after it's been created to do this type of logging(tracing) by modifying the IL

There is also something like Runtime Flow, but this probably won't fit your requirements due to an unwieldy install.

Upvotes: 2

Related Questions