Initial Comit

This commit is contained in:
Stefan Hutter
2024-05-31 13:32:10 +02:00
commit 50e9e06829
522 changed files with 4979364 additions and 0 deletions

49
Helper/NLogHelper.cs Normal file
View File

@@ -0,0 +1,49 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using NLog;
using NLog.Common;
using NLog.Targets;
using NLog.Config;
namespace Helper
{
public static class NLogHelper
{
public static void LogConfig(ref NLog.Logger Logger)
{
var configuration = new NLog.Config.LoggingConfiguration();
//var logfile = new NLog.Targets.FileTarget("logfile") { FileName = "logfile.txt" };
//var logconsole = new NLog.Targets.ConsoleTarget("logconsole");
var dbTarget = new DatabaseTarget();
dbTarget.ConnectionString = @"Server=SHU01\SHU00;Database=edoka_journale;User ID=sa;Password=*shu29";
dbTarget.CommandText =
@"INSERT INTO NLog ([Origin], [Message], [LogLevel],[UserID]) VALUES (@Origin,@Message,@LogLevel, @UserID);";
dbTarget.Parameters.Add(new DatabaseParameterInfo("@Origin", new NLog.Layouts.SimpleLayout("${callsite}")));
dbTarget.Parameters.Add(new DatabaseParameterInfo("@Message", new NLog.Layouts.SimpleLayout("${logger}")));
dbTarget.Parameters.Add(new DatabaseParameterInfo("@LogLevel", new NLog.Layouts.SimpleLayout("${level}")));
dbTarget.Parameters.Add(new DatabaseParameterInfo("@UserID", new NLog.Layouts.SimpleLayout("${message}")));
dbTarget.Parameters.Add(new DatabaseParameterInfo("@exception", new NLog.Layouts.SimpleLayout("${exception}")));
configuration.AddTarget("database", dbTarget);
}
public static string NameOf(this object o)
{
return o.GetType().Name;
}
}
}