2

looking for some advice here on developing a common logging environment for a NuGet package.

I've currently got a private NuGet package created from a C# library that works perfectly for local console apps and as such was written to log to the Windows event log.

Now I want to be able to use that package in an Azure function but of course Azure uses a different logging mechanism.

Any advice on how to create a logging overlay that allows the library to be compiled on my local PC in Visual Studio but also support logging in Azure if the package is used there?

Cheers, Dave

1 Answers1

0

I believe you are looking for the Microsoft.Extensions.Logging namespace and interface. This interface is used extensively across azure services, .Net 4+ and .Net Core. If you look for related nuget packages you will find multiple implementations for different logging scenarios and tools, including native sinks like event logs, functions, console as well as custom sinks like Splunk and Serilog.

If you separate your logging implementation from your application/package code and implement Microsoft.Extensions.Logging and adhere to the interface, then your logging interface can be easily plumbed in to many supported sinks, including functions.

A previous answer of mine provides an earlier, more manual approach to this problem. See here.

enter image description here

Murray Foxcroft
  • 12,785
  • 7
  • 58
  • 86