.NetCore Console Logging Example ( Microsoft.Extensions.Logging version 3.1.)




using Microsoft.Extensions.Logging;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            using (var loggerFactory = LoggerFactory.Create(builder => builder.AddConsole()))
            {
                ILogger logger = loggerFactory.CreateLogger<Program>();

                logger.LogInformation("info.");
                logger.LogCritical("critical.");
                logger.LogDebug("debug.");
                logger.LogError("error.");
                logger.LogTrace("trace");
                logger.LogWarning("warning.");
            }
        }
    }
}

Yorumlar