skip to Main Content

NLog override level use JSON configuration

I have Asp.NET Core application that uses a third-party library that outputs messages with the INFO information level: _logger.LogInformation("About information..."); This is about how the log display is configured (I use a JSON configuration): { "NLog": { "targets": { "console":…

VIEW QUESTION

Asp.net – How to make NLog stop writing redundant information?

My Programm.cs: var logger = LogManager.Setup() .RegisterNLogWeb() .LoadConfigurationFromFile("nlog.config") .GetCurrentClassLogger(); try { var builder = WebApplication.CreateBuilder(args); builder.Services.AddControllers(options => { options.Filters.Add<LogResponseFilterAttribute>(); }); builder.Services.AddScoped<LogResponseFilterAttribute>(); builder.Logging.ClearProviders(); builder.Logging.SetMinimumLevel(LogLevel.Information); builder.Host.UseNLog(); var app = builder.Build(); app.UseHttpsRedirection(); app.UseAuthorization(); app.MapControllers(); app.Run(); } catch (Exception e) { logger.Error(e, "Stopped program…

VIEW QUESTION

Asp.net – NLog logs only to one .log file

I'm using NLog.Web.AspNetCore to makings logs, but Nlog logs only to one all with date .log file (allfile name in nlog.config). There is my nlog.config file <?xml version="1.0" encoding="utf-8" ?> <nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" autoReload="true" internalLogLevel="Info" internalLogFile="c:tempinternal-nlog-AspNetCore.txt"> <!-- enable asp.net core…

VIEW QUESTION

NLog: how to specify log folder at runtime – Asp.net

For an example, i have following code (ASP.NET core 6): Program.cs: //... var config = new NLog.Config.LoggingConfiguration(); var logfile = new NLog.Targets.FileTarget("logfile") { FileName = Path.Combine(AppFolderPath, "log", "${var:myLogName}", "log_${date:format=dd-MM-yyyy}.txt") }; config.AddRule(NLog.LogLevel.Trace, NLog.LogLevel.Fatal, logfile); LogManager.Configuration = config; //... Startup.cs: public void…

VIEW QUESTION
Back To Top
Search