最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

logging - C# - ILoggerFactory - Deployed app adds a carriage return in the log - Stack Overflow

programmeradmin3浏览0评论

I try to log infos in my C# API

In the VS output window, everything works fine, I would get something like

Logger: Information: Some message A
Logger: Information: Some message B
Logger: Information: Some message C

As my api is deployed, the log goes completely insane

info: Logger[0]
      Some message A
info: Logger[0]
      Some message B
info: Logger[0]
      Some message C

This is how I initialize my logger in my Program.cs

var app = builder.Build();
var loggerFactory = app.Services.GetRequiredService<ILoggerFactory>();
var logger = loggerFactory.CreateLogger("Logger");
logger.LogInformation("Some message A");
logger.LogInformation("Some message B");
logger.LogInformation("Some message C");
  • How can I have more control to the log format ?
  • How can I get rid of that Logger[0] and that useless carriage return ?

Would be great to have something like

[hh:mm:ss:msec] info: Some message A

EVEN when the app is deployed

Thanks for your help

发布评论

评论列表(0)

  1. 暂无评论