我正在使用软件包 Serilog. sink.File 我希望仅对少数消息禁用时间戳,而不创建LoggerConfiguration的另一个示例,例如-
Log.Logger = new LoggerConfiguration().WriteTo.File("logs/log.txt", outputTemplate: "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level:u3}] {Message:lj}{NewLine}").CreateLogger();
输出:
2023-03-10 05:33:24 [INF] App started
2023-03-10 05:33:24 [INF] Some process1
2023-03-10 05:33:24 [INF] file1
2023-03-10 05:33:24 [INF] file2
2023-03-10 05:33:24 [INF] file3
2023-03-10 05:33:24 [INF] Operation completed.
我想要:
2023-03-10 05:33:24 [INF] App started
2023-03-10 05:33:24 [INF] Some process1
file1
file2
file3
2023-03-10 05:33:24 [INF] Operation completed.
如何做到这一点?
1条答案
按热度按时间x8diyxa71#
找到方法了。我用
shared
参数true创建了两个logger对象。