我目前正在使用Azure Functions,并且刚刚找到此接口定义。
Assembly Microsoft.Extensions.Logging.Abstractions, Version=1.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60
using System;
namespace Microsoft.Extensions.Logging
{
public interface ILogger
{
IDisposable BeginScope<TState>(TState state);
bool IsEnabled(LogLevel logLevel);
void Log<TState>(LogLevel logLevel, EventId eventId, TState state, Exception exception, Func<TState, Exception, string> formatter);
}
}
我特别感兴趣void Log<TState>。这个函数看起来像一个泛型,但似乎神奇地扩展为6个函数。
log.LogCritical("...");
log.LogDebug("...");
log.LogError("...");
log.LogInformation("...");
log.LogTrace("...");
log.LogWarning("...");
我通过Azure Function定义收到对日志的引用。
[FunctionName("WhoAmI")]
public static async Task<HttpResponseMessage> Run([HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = null)] HttpRequestMessage req, ILogger log)
{ ... }
Microsoft样本和文档反映了这一点。
我猜这是C#或Visual Studio功能,而不是巫术,但是它是哪个功能?
慕桂英4014372
相关分类