-
Notifications
You must be signed in to change notification settings - Fork 14
Closed
Description
Make sure you are looking for non-default levels which are Debug and Trace
by the way same code with 1.6 working just fine.
you have to commentserviceCollection.AddLogging(loggingBuilder => loggingBuilder.AddSeq(seqSection));
and uncomment the ones starting with//x)
and last need to change package versions<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="1.1.2" /> <PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="1.1.1" /> <PackageReference Include="Microsoft.Extensions.Logging" Version="1.1.2" />
Program.cs
using System;
using System.Diagnostics;
using System.IO;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
namespace ConsoleApp1
{
internal class Program
{
private static void Main(string[] args)
{
IConfigurationRoot configuration = new ConfigurationBuilder().SetBasePath(Directory.GetCurrentDirectory())
.AddJsonFile("appsettings.json", true, true)
.Build();
IServiceCollection serviceCollection = new ServiceCollection();
IConfigurationSection seqSection = configuration.GetSection("Seq");
serviceCollection.AddLogging(loggingBuilder => loggingBuilder.AddSeq(seqSection));
//x serviceCollection.AddLogging();
IServiceProvider serviceProvider = serviceCollection.BuildServiceProvider();
//x ILoggerFactory loggerFactory = serviceProvider.GetService<ILoggerFactory>();
//x loggerFactory.AddSeq(seqSection);
Seq.Extensions.Logging.SelfLog.Enable(Console.Out);
var logger = serviceProvider.GetService<ILogger<Program>>();
using (logger.BeginScope("{ApplicationName} :: {ApplicationGuid}", nameof(Program), Guid.NewGuid()))
{
logger.LogTrace("Trace");
logger.LogDebug("Debug");
logger.LogInformation("Information");
}
Console.WriteLine($"KEY: {seqSection.Key}{Environment.NewLine}VALUE: {seqSection.Value}");
Console.ReadLine();
}
}
}appsettings.json
{
"Seq": {
"ServerUrl": "http://localhost:5341",
"MinimumLevel": "Trace",
"LevelOverride": {
"Default": "Trace"
}
}
}ConsoleApp1.csproj
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<Content Include="appsettings.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="2.0.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="2.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="2.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Filter" Version="1.1.2" />
<PackageReference Include="Seq.Extensions.Logging" Version="3.0.0" />
</ItemGroup>
</Project>Metadata
Metadata
Assignees
Labels
No labels