Starts in:
1 DAY
7 HRS
22 MIN
17 SEC
Starts in:
1 D
7 H
22 M
17 S
Open Closed

ABP.IO WASM - Log level configuration #1496


User avatar
1
Leonardo.Willrich created

Hi,

I was wondering how can I set on production the log level as per microsoft document (https://docs.abp.io/en/abp/latest/Logging).

I realized that in my local development environment, target = Debug, it shows [DBG] lines in the log (Host\Logs). But, in productions or test environment where I have published and deployed the solution as target = Release, I cannot see those lines.

Also, the log file is just one and it is getting bigger and bigger. Is that possible to split in several files and define a limit size for each file? In Log4Net that is possible, but, reading the microsoft doc I am not sure how to do that.

That is the config that I've added into appsettings.json, but it makes no difference.


2 Answer(s)
  • User Avatar
    1
    gterdem created
    Senior .NET Developer

    You can check LoggerConfiguration under Program.cs and modify as you need. Here is a sample logging modification: <br>

    Log.Logger = new LoggerConfiguration()
    #if DEBUG
                    .MinimumLevel.Debug()
    #else
                    .MinimumLevel.Information()
    #endif
                    .MinimumLevel.Override("Microsoft", LogEventLevel.Information)
                    .MinimumLevel.Override("Microsoft.EntityFrameworkCore", LogEventLevel.Warning)
                    .WriteTo.Async(c => c.File("Logs/logs.txt"))
                    .WriteTo.Async(c => c.Console())
                    .CreateLogger();
    
  • User Avatar
    2
    Leonardo.Willrich created

    Hi gterdem,

    Actually, ABP.IO WASM template is using Serilog to create log files, right? So, why on the documentation it is saying that logs are created based on Microsoft Logger?

    Also, the settings are hardcode. As suggestion, it should be changed to read from appsettings.json, which makes more sense.

    Here is my customization for logs to read from appsettings.json and also break files based on the file size of 10Mb.

Made with ❤️ on ABP v9.1.0-preview. Updated on November 20, 2024, 13:06