Skip to content

More advanced log configuration #4405

@ThomasArdal

Description

@ThomasArdal

Microsoft.Azure.Functions.Extensions brought us the first attempt of being able to configure custom logging providers in Functions. With the current solution (where I can inject an ILoggerProvider), I can configure functions to log everything to a single log output. I would like to be able to do much more advanced logging configuration, though. Being able to register multiple logging provider, decide which log levels goes into which logs, and other features like that, is an essential part of most applications today.

Ideally, logging would be configured like any other application using Microsoft.Extensions.Logging:

[assembly: FunctionsStartup(typeof(MyNamespace.Startup))]

namespace MyNamespace
{
    public class Startup : FunctionsStartup
    {
        public override void Configure(IFunctionsHostBuilder builder)
        {
            ...
            builder.Services.AddLogging(logging =>
            {
                logging.AddConfiguration(config.GetSection("Logging"));
                logging.AddConsole();
                logging.AddDebug();
                logging.AddEventSourceLogger();
            });
        }
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions