Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to inject ILogger at constructor level #4858

Closed
lommez opened this issue Aug 28, 2019 · 1 comment
Closed

How to inject ILogger at constructor level #4858

lommez opened this issue Aug 28, 2019 · 1 comment

Comments

@lommez
Copy link

lommez commented Aug 28, 2019

Is possible to inject ILogger at constructor level?

I've tried to do something like this:

[assembly: WebJobsStartup(typeof(Startup))]

namespace HelloFunc
{
    internal class Startup : IWebJobsStartup
    {
        public void Configure(IWebJobsBuilder builder)
        {
            builder
                .Services
                .AddSettings()
                .AddLogging();
        }
    }
}

But didtn work.

@brettsam
Copy link
Member

No need to call AddLogging(). If you request an ILogger<T> in your constructor, you'll get one. More long-winded answer with more links here: #2720 (comment).

@ghost ghost locked as resolved and limited conversation to collaborators Dec 31, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants