Search code examples
asp.net-coreblazorblazor-server-side

What is the safest (least dependencies) to log startup in a Blazor app on Azure


When my Blazor app first starts, before the ILogger system is initialized (or fails initialization), I want to be able to log four things:

  1. The very first line in main() - so I know the app started.
  2. About to call builder.Build()
  3. If there was a problem instantiating the first iLogger instance
  4. The catch for main() to log the exception.

Once builder.Build() has successfully completed and the first iLogger is instantiated, I then can use the logging system. But if any of that fails, I need logging to somewhere to tell me what failed.

So what system can I use that has as few dependencies as possible?


Solution

  • Use System.Diagnostics.Debug.WriteLine() or Trace. If those don't work the system is not loading.

    h/t to a friend who gave me the suggestion.