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

Added Console Example #143

Merged
merged 1 commit into from
Oct 16, 2017
Merged

Added Console Example #143

merged 1 commit into from
Oct 16, 2017

Conversation

304NotModified
Copy link
Member

@304NotModified 304NotModified commented Oct 12, 2017

fixes #131


services.AddTransient<Runner>();
// services.AddSingleton<ILoggerFactory, NLogLoggerFactory>();
services.AddSingleton<ILoggerFactory, LoggerFactory>();
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@snakefoot any idea why the structured logging won't work if I use

 services.AddSingleton<ILoggerFactory, NLogLoggerFactory>();

instead of

services.AddSingleton<ILoggerFactory, LoggerFactory>();

(also in unit tests)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't know much of about this, so no

@304NotModified 304NotModified force-pushed the console-example-netcore2 branch from 6011a49 to aedbc18 Compare October 16, 2017 20:26
@304NotModified 304NotModified force-pushed the console-example-netcore2 branch from aedbc18 to ca4e059 Compare October 16, 2017 20:29
@304NotModified 304NotModified merged commit 1ea9771 into master Oct 16, 2017
@304NotModified 304NotModified deleted the console-example-netcore2 branch October 16, 2017 20:37
@snakefoot
Copy link
Contributor

snakefoot commented Oct 31, 2017

@304NotModified Think this code-example needs some minor modifications:

Csproj-project needs the following package references:

    <PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="2.0.0" />
    <PackageReference Include="Microsoft.Extensions.Logging.Filter" Version="1.1.2" />
    <PackageReference Include="NLog" Version="4.5.0-beta07" />
    <PackageReference Include="NLog.Extensions.Logging" Version="1.0.0-rtm-rc2" />

Program.cs needs configuration of ILoggingBuilder:

        private static IServiceProvider BuildDi()
        {
            var services = new ServiceCollection();
            services.AddLogging((builder) => builder.SetMinimumLevel(LogLevel.Trace));
            ...
        }

@304NotModified
Copy link
Member Author

Are those references needed?

ILoggingBuilder config looks good!

@snakefoot
Copy link
Contributor

snakefoot commented Oct 31, 2017

Well you have the package-references listed on the wiki-page, just missing from this example project (not sure why, since it cannot compile and run without these references):

https://github.com/NLog/NLog.Extensions.Logging/wiki/Getting-started-with-.NET-Core-2---Console-application

The bonus reference "Microsoft.Extensions.Logging.Filter" seems to be needed for calling SetMinimumLevel

@seblucas
Copy link
Contributor

seblucas commented Nov 1, 2017

I do not have any reference to "Microsoft.Extensions.Logging.Filter" and I can call SetMinimumLevel (running .net core 2.0)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add example for console and .NET Core (using DI)
3 participants