aggiunti log

This commit is contained in:
Gianmarco Mucciariello 2025-06-23 15:13:01 +02:00
parent a4190cc8d5
commit 250c4a44d3
3 changed files with 17 additions and 4 deletions

View File

@ -9,7 +9,15 @@
<target name="file" xsi:type="AsyncWrapper" queueLimit="5000" overflowAction="Discard">
<target xsi:type="File" fileName="${basedir}/logs/${level}.txt" />
</target>
<target name="database"
<target name="console" xsi:type="ColoredConsole"
layout="${time} [${level:uppercase=true}] ${logger}: ${message} ${exception:format=tostring}">
<highlight-row condition="level == LogLevel.Debug" foregroundColor="DarkGray" />
<highlight-row condition="level == LogLevel.Info" foregroundColor="Gray" />
<highlight-row condition="level == LogLevel.Warn" foregroundColor="Yellow" />
<highlight-row condition="level == LogLevel.Error" foregroundColor="Red" />
<highlight-row condition="level == LogLevel.Fatal" foregroundColor="Red" backgroundColor="White" />
</target>
<target name="database"
xsi:type="Database"
connectionStringName="SqlServerStampeC6Connection"
commandText=" INSERT INTO [dbo].LogN ([Logged], [Level], [Message], [Logger], [CallSite],
@ -27,6 +35,6 @@
</target>
</targets>
<rules>
<logger name="*" minlevel="Debug" writeTo="database" />
<logger name="*" minlevel="Debug" writeTo="file,console" />
</rules>
</nlog>

View File

@ -216,6 +216,7 @@ namespace PDFGenerator.BusinessLayer
var DataThreadsDT = (new SQLServer()).GetDataTableFromProcedure(CACHE.QueryContratti, pars);
if (DataThreadsDT != null && DataThreadsDT.Rows.Count > 0)
{
logger.Info($"Query contratti completata con successo. Trovate {DataThreadsDT.Rows.Count} righe");
ret = new List<DataThread>();
foreach (DataRow r in DataThreadsDT.Rows)
{
@ -225,6 +226,10 @@ namespace PDFGenerator.BusinessLayer
);
}
}
else
{
logger.Warn($"Nessun dato trovato dalla query contratti: {CACHE.QueryContratti}");
}
}
catch (Exception ex)
{

View File

@ -796,7 +796,6 @@ namespace PDFGenerator
if (string.IsNullOrWhiteSpace(_dataThread.NomeFilePdf))
{
logger.Info("_dataThread.NomeFilePdf è vuoto");
Console.WriteLine("_dataThread.NomeFilePdf è vuoto");
_dataThread.NomeFilePdf = "Test";
}
@ -809,7 +808,8 @@ namespace PDFGenerator
int counter = 1;
while (File.Exists(filePath))
{
filePath = System.IO.Path.Combine(folder, $"{fileNameBase}_{counter}.pdf");
_dataThread.NomeFilePdf = $"{fileNameBase}_{counter}";
filePath = System.IO.Path.Combine(folder, $"{_dataThread.NomeFilePdf}.pdf");
counter++;
}