namespace Zxd.Core.Test { [TestClass] public class UnitTest1 { public UnitTest1() { const string OUTPUT_TEMPLATE = "{Timestamp:yyyy-MM-dd HH:mm:ss.fff} <{ThreadId}> [{Level:u3}] {Message:lj}{NewLine}{Exception}"; Log.Logger = new LoggerConfiguration() .MinimumLevel.Debug() .MinimumLevel.Override("Microsoft", LogEventLevel.Information) .MinimumLevel.Override("Microsoft.EntityFrameworkCore", LogEventLevel.Warning) .Enrich.WithThreadId() .Enrich.FromLogContext() .WriteTo.Console(outputTemplate: OUTPUT_TEMPLATE) .WriteTo.File("logs/log.log" , rollingInterval: RollingInterval.Day , outputTemplate: OUTPUT_TEMPLATE) .CreateLogger(); var config = new ConfigurationBuilder() .Add(new JsonConfigurationSource { Path = "appsettings.json", ReloadOnChange = true }) .Build(); IServiceCollection services = new ServiceCollection(); services.AddLogging(logging => { logging.ClearProviders(); logging.AddSerilog(); }); services.AddSingleton(config); var serviceProvider = services.BuildServiceProvider(); } [TestMethod] public void TestMethod1() { var time = 1 << 0; var str = $"{time}"; } } }