Skip to content

Commit d78f80d

Browse files
snakefoot304NotModified
authored andcommitted
NLog Hosting Sample include ConfigureLogging with SetMinimumLevel (#392)
1 parent 3f07a9c commit d78f80d

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

examples/NetCore2/HostingExample/Program.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ private static async Task Main()
1818
{
1919
var hostBuilder = new HostBuilder()
2020
.UseNLog()
21+
.ConfigureLogging(builder => builder.SetMinimumLevel(Microsoft.Extensions.Logging.LogLevel.Trace))
2122
.ConfigureServices((hostContext, services) => services.AddHostedService<ConsoleHostedService>());
2223

2324
// Build and run the host in one go; .RCA is specialized for running it in a console.
@@ -53,8 +54,8 @@ public ConsoleHostedService(ILogger<ConsoleHostedService> logger)
5354
protected override async Task ExecuteAsync(CancellationToken stoppingToken)
5455
{
5556
_logger.LogInformation("Hello from your hosted service thread!");
56-
_logger.LogInformation("I may or may not return for a long time depending on what I do.");
57-
_logger.LogInformation("In this example, I return right away, but my host will continue to run until");
57+
_logger.LogTrace("I may or may not return for a long time depending on what I do.");
58+
_logger.LogDebug("In this example, I return right away, but my host will continue to run until");
5859
_logger.LogInformation("its CancellationToken is Cancelled (SIGTERM(Ctrl-C) or a Lifetime Event )");
5960
await Task.CompletedTask;
6061
}

0 commit comments

Comments
 (0)