37 lines
1.2 KiB
C#
37 lines
1.2 KiB
C#
using log4net.Config;
|
|
using log4net;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Reflection;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace SMTP2O365Relais
|
|
{
|
|
public static class Logger
|
|
{
|
|
private static readonly ILog log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
|
|
|
static Logger()
|
|
{
|
|
Console.WriteLine("Logger initialized");
|
|
string logConfigPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "log4net.config");
|
|
if (!File.Exists(logConfigPath))
|
|
{
|
|
Console.WriteLine($"log4net-Konfigurationsdatei nicht gefunden: {logConfigPath}");
|
|
}
|
|
else
|
|
{
|
|
var logRepository = LogManager.GetRepository(Assembly.GetEntryAssembly());
|
|
XmlConfigurator.Configure(logRepository, new FileInfo(logConfigPath));
|
|
}
|
|
}
|
|
|
|
public static void Info(string message) => log.Info(message);
|
|
public static void Warn(string message) => log.Warn(message);
|
|
public static void Error(string message, Exception ex = null) => log.Error(message, ex);
|
|
public static void Debug(string message) => log.Debug(message);
|
|
}
|
|
}
|