Fix log x IOC

This commit is contained in:
Samuele Locatelli
2023-04-05 09:32:09 +02:00
parent 20d6c6cd36
commit ef2fd78269
5 changed files with 106 additions and 7 deletions
+57 -4
View File
@@ -2,6 +2,7 @@
using Microsoft.AspNetCore.Mvc;
using MP.IOC.Data;
using NLog;
using NLog.Fluent;
namespace MP.IOC.Controllers
{
@@ -26,7 +27,7 @@ namespace MP.IOC.Controllers
[HttpGet("GetByPODL")]
public async Task<string> GetByPODL(string idxMacc, int idxPODL)
{
string answ = "";
string answ = "NO DATA";
string archPath = await DService.MacchineRecipeArchive(idxMacc);
var podlData = await DService.POdlGetByKey(idxPODL);
if (podlData != null)
@@ -35,8 +36,34 @@ namespace MP.IOC.Controllers
string fullPath = Path.Combine(archPath, fileName);
if (!string.IsNullOrEmpty(fullPath))
{
answ = System.IO.File.ReadAllText(fullPath);
try
{
if (System.IO.File.Exists(fullPath))
{
answ = System.IO.File.ReadAllText(fullPath);
if (string.IsNullOrEmpty(answ))
{
Log.Error($"Errore in GetByPODL: contenuto file vuoto | idxMacc: {idxMacc} | idxPODL: {idxPODL}");
}
}
else
{
Log.Error($"Errore in GetByPODL: il file non esiste | fullPath {fullPath}");
}
}
catch (Exception exc)
{
Log.Error($"Eccezione in GetByPODL:{Environment.NewLine}{exc}");
}
}
else
{
Log.Error($"Errore in GetByPODL: fullPath null ");
}
}
else
{
Log.Error($"Errore in GetByPODL: podlData null | idxPODL: {idxPODL}");
}
return answ;
}
@@ -44,15 +71,41 @@ namespace MP.IOC.Controllers
[HttpGet("GetFile")]
public async Task<string> GetFile(string idxMacc, string fileName)
{
string answ = "";
string answ = "NO DATA";
string archPath = await DService.MacchineRecipeArchive(idxMacc);
if (!string.IsNullOrEmpty(archPath))
{
string fullPath = Path.Combine(archPath, fileName);
if (!string.IsNullOrEmpty(fullPath))
{
answ = System.IO.File.ReadAllText(fullPath);
try
{
if (System.IO.File.Exists(fullPath))
{
answ = System.IO.File.ReadAllText(fullPath);
if (string.IsNullOrEmpty(answ))
{
Log.Error($"Errore in GetFile: contenuto file vuoto | idxMacc: {idxMacc} | fileName: {fileName}");
}
}
else
{
Log.Error($"Errore in GetFile: il file non esiste | fullPath {fullPath}");
}
}
catch (Exception exc)
{
Log.Error($"Eccezione in GetFile:{Environment.NewLine}{exc}");
}
}
else
{
Log.Error($"Errore in GetFile: fullPath null ");
}
}
else
{
Log.Error($"Errore in GetFile: archPath null ");
}
return answ;
}
+46
View File
@@ -0,0 +1,46 @@
<?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"
xsi:schemaLocation="http://www.nlog-project.org/schemas/NLog.xsd NLog.xsd"
autoReload="true"
throwExceptions="false"
internalLogLevel="Off" internalLogFile="c:\temp\nlog-internal.log">
<!-- optional, add some variables
https://github.com/nlog/NLog/wiki/Configuration-file#variables
-->
<variable name="myvar" value="myvalue" />
<!--
See https://github.com/nlog/nlog/wiki/Configuration-file
for information on customizing logging rules and outputs.
-->
<targets>
<!--
add your targets here
See https://github.com/nlog/NLog/wiki/Targets for possible targets.
See https://github.com/nlog/NLog/wiki/Layout-Renderers for the possible layout renderers.
-->
<!--
Write events to a file with the date in the filename.
<target xsi:type="File" name="f" fileName="${basedir}/logs/${shortdate}.log"
layout="${longdate} ${uppercase:${level}} ${message}" />
-->
<target xsi:type="File" name="fileTarget" fileName="${basedir}/logs/${shortdate}.log" layout="${longdate} | ${uppercase:${level}} | ${logger:shortName=false} | ${message}" />
<target xsi:type="ColoredConsole" name="consoleTarget" layout="${longdate} | ${uppercase:${level}} | ${logger:shortName=true} | ${message}" />
</targets>
<rules>
<!-- add your logging rules here -->
<!--
Write all events with minimal level of Debug (So Debug, Info, Warn, Error and Fatal, but not Trace) to "f"
<logger name="*" minlevel="Debug" writeTo="f" />
-->
<logger name="*" minlevel="Debug" writeTo="consoleTarget" />
<!--<logger name="Microsoft.*" maxlevel="Info" final="true" />-->
<logger name="*" minlevel="Info" writeTo="fileTarget" />
</rules>
</nlog>
+1 -1
View File
@@ -1,6 +1,6 @@
<body>
<i>Modulo MP-IOC </i>
<h4>Versione: 6.16.2304.419</h4>
<h4>Versione: 6.16.2304.509</h4>
<br /> Note di rilascio:
<ul>
<li>
+1 -1
View File
@@ -1 +1 @@
6.16.2304.419
6.16.2304.509
+1 -1
View File
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<item>
<version>6.16.2304.419</version>
<version>6.16.2304.509</version>
<url>https://nexus.steamware.net/repository/SWS/MP-IOC/stable/LAST/MP.IOC.zip</url>
<changelog>https://nexus.steamware.net/repository/SWS/MP-IOC/stable/LAST/ChangeLog.html</changelog>
<mandatory>false</mandatory>