Is it possible to change colors in serilog?

孤人 提交于 2020-12-13 04:51:36

问题


I have just integrated Serilog in my dot net core project. It is working really well but I use a dark theme and some logs are really dificult to read. As an example:

This is how I init Serilog:

string environment =  Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT");
        
LoggerConfiguration loggerConfig = new LoggerConfiguration();
            
if (environment == "Production")
    loggerConfig.MinimumLevel.Information();
                
loggerConfig.MinimumLevel.Override("Microsoft.AspNetCore",
    LogEventLevel.Warning) 
    .Enrich.FromLogContext()
    .WriteTo.Console()
    .WriteTo.File("Logs/app.log");

Is there any way I could change colors to make that black logs white for example?


回答1:


Yes, the way to change colors when using the Console sink is through themes. You can try one of the built-in ones, or create your own.



来源:https://stackoverflow.com/questions/62953942/is-it-possible-to-change-colors-in-serilog

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!