标签:nbsp har interval build 修改 public 文件 path readonly
public static IHostBuilder CreateHostBuilder(string[] args) => Host.CreateDefaultBuilder(args) .ConfigureWebHostDefaults(webBuilder => { webBuilder.UseStartup<Startup>(); }) .UseSerilog((context, configuration) => { var path = AppDomain.CurrentDomain.BaseDirectory; path = path.Substring(0, path.LastIndexOf("bin") + 3); configuration .MinimumLevel.Debug() .MinimumLevel.Override("Microsoft", LogEventLevel.Error) .Enrich.FromLogContext() .WriteTo.Console() .WriteTo.File(path: Path.Combine(path, "log.log"), rollingInterval: RollingInterval.Day); });//注入管道
[Route("[controller]")] [ApiController] public class SerilogController : ControllerBase { private readonly ILogger<SerilogController> _logger; public SerilogController(ILogger<SerilogController> logger) { _logger = logger; } [HttpGet] public void Name() { _logger.LogError("输出日志成功"); var v = "你好"; var vv = "世界"; _logger.LogInformation("{0}{1}", v, vv);//占位符 var v1 = "你好"; var vv1 = 18; _logger.LogInformation("{0}{1}", v1, vv1>=18);//添加条件判断 var model = new { Name = "你是谁", age = 14 }; _logger.LogInformation("{@model}",model);//JSON格式打印日志 }
标签:nbsp har interval build 修改 public 文件 path readonly
原文地址:https://www.cnblogs.com/mvpbest/p/13631572.html