Я знаю для большинства типов. что. < /p>
с простой программой, подобной этим: < /p>
Код: Выделить всё
using Microsoft.Extensions.Logging;
namespace LoggingTester
{
internal class Program
{
private static readonly Action LogErrorMessageDate = LoggerMessage.Define(
LogLevel.Error,
new EventId(1, "ErrorMessage"),
"An error occurred on {Date}");
private static readonly Action LogErrorMessageDateTime = LoggerMessage.Define(
LogLevel.Error,
new EventId(1, "ErrorMessage"),
"An error occurred on {Date}");
static void Main()
{
ILogger logger = LoggerFactory.Create(builder =>
{
builder.AddConsole();
}).CreateLogger
();
LogErrorMessageDate(logger, DateOnly.FromDateTime(DateTime.Now), new ApplicationException("Error!"));
LogErrorMessageDateTime(logger, DateTime.Now, new ApplicationException("Error!"));
}
}
}
Подробнее здесь: https://stackoverflow.com/questions/797 ... mat-for-ou
Мобильная версия