Closed
Description
Issue description
The documentation for compile-time logging source generation contains the following code snippet:
using System.Text.Json;
using Microsoft.Extensions.Logging;
ILogger<SampleObject> logger = LoggerFactory.Create(
builder =>
builder.AddJsonConsole(
options =>
options.JsonWriterOptions = new JsonWriterOptions()
{
Indented = true
}))
.CreateLogger<SampleObject>();
logger.CustomLogEvent(LogLevel.Information, "Liana", "Seattle");
public static partial class SampleObject
{
[LoggerMessage(EventId = 23)]
public static partial void CustomLogEvent(
this ILogger logger, LogLevel logLevel,
string name, string city);
}
This code does not compile due to it using a static class as a generic type argument. Even without this, no logs will appear in the console as the LoggerFactory is not properly disposed of and therefore the logs are not flushed.