|
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System;
namespace Microsoft.Extensions.Logging.Abstractions
{
/// <summary>
/// Minimalistic logger that does nothing.
/// </summary>
public class NullLogger : ILogger
{
/// <summary>
/// Returns the shared instance of <see cref="NullLogger"/>.
/// </summary>
public static NullLogger Instance { get; } = new NullLogger();
/// <summary>
/// Initializes a new instance of the <see cref="NullLogger"/> class.
/// </summary>
private NullLogger()
{
}
/// <inheritdoc />
public IDisposable BeginScope<TState>(TState state) where TState : notnull
{
return NullScope.Instance;
}
/// <inheritdoc />
public bool IsEnabled(LogLevel logLevel)
{
return false;
}
/// <inheritdoc />
public void Log<TState>(LogLevel logLevel, EventId eventId, TState state, Exception? exception, Func<TState, Exception?, string> formatter)
{
}
}
}
|