public class Program { public static void Main(string[] args) { Log.Logger = new LoggerConfiguration() .MinimumLevel.Debug() .WriteTo.Console() .WriteTo.File("logs/myapp.txt", rollingInterval: RollingInterval.Day) .CreateLogger(); CreateHostBuilder(args).Build().Run(); } public static IHostBuilder CreateHostBuilder(string[] args) => Host.CreateDefaultBuilder(args) .ConfigureWebHostDefaults(webBuilder => { webBuilder.UseStartup<Startup>(); }); }
[HttpGet] public string GetStrings([FromServices]IGetMiss miss) { Log.Debug("我出来了"); Class aa = new Class(_miss); string r = aa.Name; return miss.Miss(); }
最后,引入的包是: Serilog.AspNetCore
只需要在Program.cs中配置一下记录地址,和格式时间,就可以在全局记录
需要自己自定义的朋友可以去官网了解:
点击进入Serilog官网
标签:aa,Core,string,Serilog,args,Net,miss,public From: https://www.cnblogs.com/xiangshifu/p/17141121.html