microsoft / VSExtensibility

A repo for upcoming changes to extensibility in Visual Studio, the new extensibility model, and language server protocol.
MIT License
365 stars 46 forks source link

Best Practices to Log stack trace when our extension crashes.... #94

Closed CartBlanche closed 1 year ago

CartBlanche commented 2 years ago

What is the best way to log, or see, the stack trace when out extension crashes and takes the IDE with it? Is there a Best Practices document or suggestions? Maybe writing things to /log perhaps?

We'd like customers of our extension to be able to send us log, so we can see where our extension crashed for them.

BertanAygun commented 2 years ago

@CartBlanche, are you asking for an existing extension using in-proc VSSDK?

There are couple logging paths for Visual Studio currently:

If you want to create a log entry here from your VSSDK based extension, you can use TraceConfiguration.CreateTraceConfigurationInstanceAsync method (see links below).

For extensions using the new out-of-proc SDK, code should be using the TraceSource instance via dependency injection. This instance is already created via using TraceConfiguration class.

https://github.com/MicrosoftDocs/visualstudio-docs/blob/main/docs/extensibility/how-to-troubleshoot-brokered-services.md#tracing-rpc-between-client-and-service

https://docs.microsoft.com/en-us/dotnet/api/microsoft.visualstudio.loghub.traceconfiguration.createtraceconfigurationinstanceasync?view=visualstudiosdk-2022

CartBlanche commented 2 years ago

@BertanAygun Thanks for the info. I'll pass it on.