From 5db36307da90bfbc0e185f617c88d692c7f846f0 Mon Sep 17 00:00:00 2001 From: Annamaria Sassi Date: Thu, 5 Feb 2026 10:50:56 +0100 Subject: [PATCH] Aggiunto NLog --- Directory.Packages.props | 2 + Test.UI/Program.cs | 7 +++ Test.UI/Test.UI.csproj | 2 + Test.UI/appsettings.json | 44 +++++++++++++++++++ WebWindowComplex/TableComp.razor.cs | 17 +++++++ WebWindowComplex/WebWindowComplex.csproj | 14 +++++- .../WebWindowConfigurator.csproj | 3 +- 7 files changed, 87 insertions(+), 2 deletions(-) diff --git a/Directory.Packages.props b/Directory.Packages.props index 353f231..8cbcbcc 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -17,6 +17,8 @@ + + \ No newline at end of file diff --git a/Test.UI/Program.cs b/Test.UI/Program.cs index cd7c56c..f7388cb 100644 --- a/Test.UI/Program.cs +++ b/Test.UI/Program.cs @@ -1,6 +1,7 @@ using EgwCoreLib.Lux.Data.Services; using Microsoft.Extensions.Configuration; using NLog; +using NLog.Web; using StackExchange.Redis; using System.Reflection; using Test.UI.Client.Pages; @@ -10,7 +11,12 @@ var builder = WebApplication.CreateBuilder(args); var assemblyVersion = Assembly.GetExecutingAssembly().GetName().Version?.ToString(); +var logger = LogManager.Setup() + .LoadConfigurationFromAppSettings() + .GetCurrentClassLogger(); + ConfigurationManager configuration = builder.Configuration; +logger.Info("Program.cs: startup"); // Add services to the container. builder.Services.AddRazorComponents() @@ -36,6 +42,7 @@ var app = builder.Build(); // aggiunt base URL x routing corretto string baseUrl = configuration.GetValue("ServerConf:BaseUrl") ?? ""; app.UsePathBase(baseUrl); +logger.Info($"BaseUrl: {baseUrl}"); // Configure the HTTP request pipeline. if (app.Environment.IsDevelopment()) diff --git a/Test.UI/Test.UI.csproj b/Test.UI/Test.UI.csproj index 7f471cd..e067628 100644 --- a/Test.UI/Test.UI.csproj +++ b/Test.UI/Test.UI.csproj @@ -33,6 +33,8 @@ runtime; build; native; contentfiles; analyzers; buildtransitive all + + diff --git a/Test.UI/appsettings.json b/Test.UI/appsettings.json index fcc297e..8c5f5d9 100644 --- a/Test.UI/appsettings.json +++ b/Test.UI/appsettings.json @@ -6,6 +6,50 @@ "Microsoft.AspNetCore": "Warning" } }, + "NLog": { + "variables": { + "baseFileDir": "${basedir}/logs/", + "layout": "${longdate} | ${uppercase:${level}} | ${logger:shortName=false} | ${message}" + }, + // "internalLogLevel": "Info", + // "internalLogFile": "c:\\temp\\internal-nlog.txt", + "extensions": [ + { "assembly": "NLog.Extensions.Logging" }, + { "assembly": "NLog.Web.AspNetCore" } + ], + "throwConfigExceptions": true, + "targets": { + "async": true, + "logfile": { + "type": "File", + "fileName": "${basedir}/logs/${shortdate}.log", + "layout": "${layout}", + "archiveEvery": "Day", + "archiveFileName": "${basedir}/logs/old/${shortdate}_{#}.log", + "archiveNumbering": "DateAndSequence", + "archiveAboveSize": "1024000", + "archiveDateFormat": "HH", + "maxArchiveFiles": "60", + "maxArchiveDays": "30" + }, + "logconsole": { + "type": "ColoredConsole", + "layout": "${longdate} | ${uppercase:${level}} | ${logger:shortName=true} | ${message}" + } + }, + "rules": [ + { + "logger": "*", + "minLevel": "Trace", + "writeTo": "logconsole" + }, + { + "logger": "*", + "minLevel": "Info", + "writeTo": "logfile" + } + ] + }, "AllowedHosts": "*", "ConnectionStrings": { "Redis": "redis.ufficio:26379, serviceName=devel, DefaultDatabase=6, keepAlive=180, connectTimeout=15000, syncTimeout=15000, asyncTimeout=15000, abortConnect=false, ssl=false, allowAdmin=true" diff --git a/WebWindowComplex/TableComp.razor.cs b/WebWindowComplex/TableComp.razor.cs index 042d94e..5900a51 100644 --- a/WebWindowComplex/TableComp.razor.cs +++ b/WebWindowComplex/TableComp.razor.cs @@ -1,6 +1,7 @@ using Egw.Window.Data; using Microsoft.AspNetCore.Components; using Newtonsoft.Json; +using NLog; using System.Threading.Tasks; using WebWindowComplex.Compo; using WebWindowComplex.DTO; @@ -392,6 +393,7 @@ namespace WebWindowComplex protected Task DoClose() { editLock = false; + Log.Info("Richietsa Chiusura"); return EC_OnClose.InvokeAsync(false); } @@ -415,6 +417,7 @@ namespace WebWindowComplex // verifico variazione JWD if (!prevJwd.Equals(CurrJwd) || doForce || prevReq != (int)DataReq.ReqSvg) { + Log.Info("Richietsa svg"); prevJwd = CurrJwd; prevReq = (int)DataReq.ReqSvg; Dictionary Args = new Dictionary(); @@ -443,6 +446,7 @@ namespace WebWindowComplex // verifico variazione JWD if (!prevJwd.Equals(CurrJwd) || isFirst || prevReq != (int)DataReq.ReqHwOpt) { + Log.Info("Richietsa Hardware option"); prevJwd = CurrJwd; prevReq = (int)DataReq.ReqHwOpt; Dictionary Args = new Dictionary(); @@ -474,6 +478,7 @@ namespace WebWindowComplex if (!prevJwd.Equals(CurrJwd) || prevReq != (int)DataReq.ReqShape) //if (!prevLiveData.CurrJwd.Equals(CurrJwd)) { + Log.Info("Richietsa shape"); prevJwd = CurrJwd; prevReq = (int)DataReq.ReqShape; Dictionary Args = new Dictionary(); @@ -503,6 +508,7 @@ namespace WebWindowComplex // verifico variazione JWD if (!prevJwd.Equals(CurrJwd) || prevReq != (int)DataReq.ReqElement) { + Log.Info("Richietsa Profili Elementi"); prevJwd = CurrJwd; prevReq = (int)DataReq.ReqElement; Dictionary Args = new Dictionary(); @@ -521,6 +527,7 @@ namespace WebWindowComplex /// protected Task DoReset() { + Log.Info("Richietsa reset"); return Task.CompletedTask; // Da fare } @@ -532,6 +539,7 @@ namespace WebWindowComplex protected Task DoSave() { editLock = false; + Log.Info("Richietsa Salvataggio"); //manca salvataggio JWD return EC_OnClose.InvokeAsync(true); } @@ -602,6 +610,7 @@ namespace WebWindowComplex catch (Exception ex) { listErrLink.Add("Window", $"Deserializing Error:{Environment.NewLine}{ex}"); + Log.Error($"Errore nel deserializzare jwd: {ex.Message}"); // uso un oggetto "basico" per non fermarmi await BuildFrameDefault(); } @@ -911,6 +920,8 @@ namespace WebWindowComplex private List m_FillList = new List(); private List m_SplittedList = new List(); + private static Logger Log = LogManager.GetCurrentClassLogger(); + #endregion Private Fields #region Private Properties @@ -955,29 +966,35 @@ namespace WebWindowComplex if (ListPayload.Hardware == null || ListPayload.Hardware.Count == 0) { listErrPre.Add("Hardware", "Missing Hardware List!"); + Log.Warn("Missing Hardware List"); } else { if (ListPayload.FamilyHardware == null || ListPayload.FamilyHardware.Count == 0) { listErrPre.Add("FamilyHardware", "Missing Family HW List!"); + Log.Warn(" Missing Family HW List"); } } if (ListPayload.Glass == null || ListPayload.Glass.Count == 0) { listErrPre.Add("Glass", "Missing Glass List!"); + Log.Warn(" Missing Glass List"); } if (ListPayload.Material == null || ListPayload.Material.Count == 0) { listErrPre.Add("Material", "Missing Material List!"); + Log.Warn(" Missing Material List"); } if (ListPayload.ColorMaterial == null || ListPayload.ColorMaterial.Count == 0) { listErrPre.Add("ColorMaterial", "Missing ColorMaterial List!"); + Log.Warn("Missing ColorMaterial List"); } if (ListPayload.ProfileList == null || ListPayload.ProfileList.Count == 0) { listErrPre.Add("Profile", "Missing Profile data!"); + Log.Warn("Missing Profile data"); } } diff --git a/WebWindowComplex/WebWindowComplex.csproj b/WebWindowComplex/WebWindowComplex.csproj index 521971c..9c174f1 100644 --- a/WebWindowComplex/WebWindowComplex.csproj +++ b/WebWindowComplex/WebWindowComplex.csproj @@ -6,7 +6,7 @@ net8.0 enable enable - 3.1.2.418 + 3.1.2.510 Annamaria Sassi Egalware Componente gestione Configurazioni avanzate Window per LUX @@ -27,6 +27,7 @@ + @@ -71,6 +72,17 @@ + + + + + + + + + + + diff --git a/WebWindowConfigurator/WebWindowConfigurator.csproj b/WebWindowConfigurator/WebWindowConfigurator.csproj index 902517d..aaebafe 100644 --- a/WebWindowConfigurator/WebWindowConfigurator.csproj +++ b/WebWindowConfigurator/WebWindowConfigurator.csproj @@ -6,7 +6,7 @@ net8.0 enable enable - 3.1.2.418 + 3.1.2.510 Annamaria Sassi Egalware Componente gestione JWD per LUX @@ -98,5 +98,6 @@ +