Azure / azure-functions-host

The host/runtime that powers Azure Functions
https://functions.azure.com
MIT License
1.94k stars 442 forks source link

Document how to utilize other Logging services/platforms #5823

Open brandonh-msft opened 4 years ago

brandonh-msft commented 4 years ago

Regarding: https://docs.microsoft.com/en-us/azure/azure-functions/functions-monitoring#application-insights-pricing-and-limits

This page should provide information on if/how other platforms can be used "natively" with Azure Functions. i.e. can I, somehow, make ILogger an NLog object? Some other logging platform? If not, it should be called out so customers aren't banging their heads against a wall trying to do it. If so, we should have an example of how to do this.

Posting here by request

linking to predecessor and potential duplicate

cc @brettsam @ggailey777

fabiocav commented 4 years ago

I believe Azure Monitor is the recommended path moving forward. Azure Functions emits the logs to Azure Monitor and you can setup different sinks/providers there.

@brettsam and @apawast for visibility on docs requirement and to comment if needed.

IGx89 commented 4 years ago

In case another customer scenario helps, we needed to use another logging service due to enterprise requirements for all logs to be sent to Splunk. We accomplished that by writing a custom Splunk ILogger provider and configuring our function apps (and web apps) to use it like so:

public class Startup : FunctionsStartup
{
    ...
    public override void Configure(IFunctionsHostBuilder builder)
    {
        builder.Services.AddLogging((logging) => {
            logging.AddSplunk((options) => { ... });
        });
        ...
    }
    ...
}

It does look like there's a way to get logs streamed from Azure Monitor to Splunk as well, but we haven't investigated it yet. It may cause logs from Azure apps to be quite different from logs from non-Azure apps too, which wouldn't be ideal. This way everything's consistent for us.

fabiocav commented 4 years ago

Indeed, that works, but the reason why Azure Monitor is the recommended way to integrate is because that will work for all supported languages, while the approach above only works for .NET (or requires the introduction of a .NET Extension)