update 20241003
This commit is contained in:
@@ -1,92 +0,0 @@
|
||||
using NLog;
|
||||
using NLog.Time;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Logging
|
||||
{
|
||||
public class Logging
|
||||
{
|
||||
|
||||
private static readonly NLog.Logger Logger = NLog.LogManager.GetLogger("EDOKA");
|
||||
|
||||
public static string connectionstring { get; set; } = "";
|
||||
public static string IntLogLevel { get; set; } = "";
|
||||
public static string IntUserID { get; set; } = "*";
|
||||
|
||||
public static void Info(string message, string herkunft, string zusatz)
|
||||
{
|
||||
if (DoLogging("Info") != true) { return; }
|
||||
GlobalDiagnosticsContext.Set("Herkunft", herkunft);
|
||||
GlobalDiagnosticsContext.Set("Zusatz", zusatz);
|
||||
Logger.Info(message);
|
||||
}
|
||||
public static void Warning(string message, string herkunft, string zusatz)
|
||||
{
|
||||
if (DoLogging("Warning") != true) { return; }
|
||||
GlobalDiagnosticsContext.Set("Herkunft", herkunft);
|
||||
GlobalDiagnosticsContext.Set("Zusatz", zusatz);
|
||||
Logger.Warn(message);
|
||||
}
|
||||
public static void Error(string message, string herkunft, string zusatz) {
|
||||
if (DoLogging("Error") != true) { return; }
|
||||
|
||||
GlobalDiagnosticsContext.Set("Herkunft",herkunft);
|
||||
GlobalDiagnosticsContext.Set("Zusatz", zusatz);
|
||||
Logger.Error(message);
|
||||
}
|
||||
|
||||
public static void Fatal(string message, string herkunft, string zusatz)
|
||||
{
|
||||
if (DoLogging("Fatal") != true) { return; }
|
||||
|
||||
GlobalDiagnosticsContext.Set("Herkunft", herkunft);
|
||||
GlobalDiagnosticsContext.Set("Zusatz", zusatz);
|
||||
Logger.Fatal(message);
|
||||
}
|
||||
public static void Trance(string message, string herkunft, string zusatz)
|
||||
{
|
||||
if (DoLogging("Trace") != true) { return; }
|
||||
|
||||
GlobalDiagnosticsContext.Set("Herkunft", herkunft);
|
||||
GlobalDiagnosticsContext.Set("Zusatz", zusatz);
|
||||
Logger.Trace(message);
|
||||
}
|
||||
public static void Debug(string message, string herkunft, string zusatz)
|
||||
{
|
||||
if (DoLogging("Debug") != true) { return; }
|
||||
|
||||
GlobalDiagnosticsContext.Set("Herkunft", herkunft);
|
||||
GlobalDiagnosticsContext.Set("Zusatz", zusatz);
|
||||
Logger.Debug(message);
|
||||
}
|
||||
|
||||
|
||||
|
||||
private static Boolean DoLogging(string Loglevel)
|
||||
{
|
||||
if (IntUserID != "*")
|
||||
{
|
||||
if (IntUserID.Contains(System.Security.Principal.WindowsIdentity.GetCurrent().Name))
|
||||
{
|
||||
if (IntLogLevel.Contains(Loglevel))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (IntLogLevel.Contains(Loglevel))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
179
Logging/Logging.cs
Normal file
179
Logging/Logging.cs
Normal file
@@ -0,0 +1,179 @@
|
||||
using NLog;
|
||||
using NLog.Time;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Logging
|
||||
{
|
||||
public class Logging
|
||||
{
|
||||
|
||||
private static readonly NLog.Logger Logger = NLog.LogManager.GetLogger("OnDoc");
|
||||
public static string connectionstring { get; set; } = "";
|
||||
public static string IntLogLevel { get; set; } = "";
|
||||
public static string IntUserID { get; set; } = "*";
|
||||
|
||||
public static void Info(string message, string herkunft, string zusatz)
|
||||
{
|
||||
if (DoLogging("Info") != true) { return; }
|
||||
GlobalDiagnosticsContext.Set("Herkunft", herkunft);
|
||||
GlobalDiagnosticsContext.Set("Zusatz", zusatz);
|
||||
Logger.Info(message);
|
||||
}
|
||||
public static void Warning(string message, string herkunft, string zusatz)
|
||||
{
|
||||
if (DoLogging("Warning") != true) { return; }
|
||||
GlobalDiagnosticsContext.Set("Herkunft", herkunft);
|
||||
GlobalDiagnosticsContext.Set("Zusatz", zusatz);
|
||||
Logger.Warn(message);
|
||||
}
|
||||
public static void Error(string message, string herkunft, string zusatz) {
|
||||
if (DoLogging("Error") != true) { return; }
|
||||
|
||||
GlobalDiagnosticsContext.Set("Herkunft",herkunft);
|
||||
GlobalDiagnosticsContext.Set("Zusatz", zusatz);
|
||||
Logger.Error(message);
|
||||
}
|
||||
|
||||
public static void Fatal(string message, string herkunft, string zusatz)
|
||||
{
|
||||
if (DoLogging("Fatal") != true) { return; }
|
||||
|
||||
GlobalDiagnosticsContext.Set("Herkunft", herkunft);
|
||||
GlobalDiagnosticsContext.Set("Zusatz", zusatz);
|
||||
Logger.Fatal(message);
|
||||
}
|
||||
public static void Trance(string message, string herkunft, string zusatz)
|
||||
{
|
||||
if (DoLogging("Trace") != true) { return; }
|
||||
|
||||
GlobalDiagnosticsContext.Set("Herkunft", herkunft);
|
||||
GlobalDiagnosticsContext.Set("Zusatz", zusatz);
|
||||
Logger.Trace(message);
|
||||
}
|
||||
public static void Debug(string message, string herkunft, string zusatz)
|
||||
{
|
||||
if (DoLogging("Debug") != true) { return; }
|
||||
|
||||
GlobalDiagnosticsContext.Set("Herkunft", herkunft);
|
||||
GlobalDiagnosticsContext.Set("Zusatz", zusatz);
|
||||
Logger.Debug(message);
|
||||
}
|
||||
|
||||
|
||||
private static Boolean DoLogging(string Loglevel)
|
||||
{
|
||||
if (IntUserID != "*")
|
||||
{
|
||||
if (IntUserID.Contains(System.Security.Principal.WindowsIdentity.GetCurrent().Name))
|
||||
{
|
||||
if (IntLogLevel.Contains(Loglevel))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (IntLogLevel.Contains(Loglevel))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
public class DocLog
|
||||
{
|
||||
|
||||
private static readonly NLog.Logger Logger = NLog.LogManager.GetLogger("DocLog");
|
||||
|
||||
public static string connectionstring { get; set; } = "";
|
||||
public static string IntLogLevel { get; set; } = "";
|
||||
public static string IntUserID { get; set; } = "*";
|
||||
|
||||
public static void Info(string message, string herkunft, string dokumentid, string partnernr, string aktion)
|
||||
{
|
||||
if (DoLogging("Info") != true) { return; }
|
||||
GlobalDiagnosticsContext.Set("Herkunft", herkunft);
|
||||
GlobalDiagnosticsContext.Set("Dokumentid", dokumentid);
|
||||
GlobalDiagnosticsContext.Set("Partnernr",partnernr);
|
||||
GlobalDiagnosticsContext.Set("Aktion", aktion);
|
||||
Logger.Info(message);
|
||||
|
||||
}
|
||||
public static void Warning(string message, string herkunft, string dokumentid, string partnernr, string aktion)
|
||||
{
|
||||
if (DoLogging("Warning") != true) { return; }
|
||||
GlobalDiagnosticsContext.Set("Herkunft", herkunft);
|
||||
GlobalDiagnosticsContext.Set("Dokumentid", dokumentid);
|
||||
GlobalDiagnosticsContext.Set("Partnernr", partnernr);
|
||||
GlobalDiagnosticsContext.Set("Aktion", aktion);
|
||||
Logger.Warn(message);
|
||||
}
|
||||
public static void Error(string message, string herkunft, string dokumentid, string partnernr, string aktion)
|
||||
{
|
||||
if (DoLogging("Error") != true) { return; }
|
||||
GlobalDiagnosticsContext.Set("Herkunft", herkunft);
|
||||
GlobalDiagnosticsContext.Set("Dokumentid", dokumentid);
|
||||
GlobalDiagnosticsContext.Set("Partnernr", partnernr);
|
||||
GlobalDiagnosticsContext.Set("Aktion", aktion);
|
||||
Logger.Error(message);
|
||||
}
|
||||
|
||||
public static void Fatal(string message, string herkunft, string dokumentid, string partnernr, string aktion)
|
||||
{
|
||||
if (DoLogging("Fatal") != true) { return; }
|
||||
GlobalDiagnosticsContext.Set("Herkunft", herkunft);
|
||||
GlobalDiagnosticsContext.Set("Dokumentid", dokumentid);
|
||||
GlobalDiagnosticsContext.Set("Partnernr", partnernr);
|
||||
GlobalDiagnosticsContext.Set("Aktion", aktion);
|
||||
Logger.Fatal(message);
|
||||
}
|
||||
public static void Trance(string message, string herkunft, string dokumentid, string partnernr, string aktion)
|
||||
{
|
||||
if (DoLogging("Trace") != true) { return; }
|
||||
GlobalDiagnosticsContext.Set("Herkunft", herkunft);
|
||||
GlobalDiagnosticsContext.Set("Dokumentid", dokumentid);
|
||||
GlobalDiagnosticsContext.Set("Partnernr", partnernr);
|
||||
GlobalDiagnosticsContext.Set("Aktion", aktion);
|
||||
Logger.Trace(message);
|
||||
}
|
||||
public static void Debug(string message, string herkunft, string dokumentid, string partnernr, string aktion)
|
||||
{
|
||||
if (DoLogging("Debug") != true) { return; }
|
||||
GlobalDiagnosticsContext.Set("Herkunft", herkunft);
|
||||
GlobalDiagnosticsContext.Set("Dokumentid", dokumentid);
|
||||
GlobalDiagnosticsContext.Set("Partnernr", partnernr);
|
||||
GlobalDiagnosticsContext.Set("Aktion", aktion);
|
||||
Logger.Debug(message);
|
||||
}
|
||||
|
||||
|
||||
private static Boolean DoLogging(string Loglevel)
|
||||
{
|
||||
if (IntUserID != "*")
|
||||
{
|
||||
if (IntUserID.Contains(System.Security.Principal.WindowsIdentity.GetCurrent().Name))
|
||||
{
|
||||
if (IntLogLevel.Contains(Loglevel))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (IntLogLevel.Contains(Loglevel))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -50,7 +50,7 @@
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Class1.cs" />
|
||||
<Compile Include="Logging.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1 +1 @@
|
||||
21310f9f88e117cb3a88ad2cb1dfe90f6a2a2f081b586ade33573bb4d69b1c4c
|
||||
9e7ad222616494aed9cb0e7121cd2e4419cc83ac294e8afb0ae2a94160f2bb13
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user