52 lines
1.3 KiB
C#
52 lines
1.3 KiB
C#
using System;
|
|||
|
|
using System.Collections.Generic;
|
||
|
|
using System.Linq;
|
||
|
|
using System.Text;
|
||
|
|
using System.Threading.Tasks;
|
||
|
|
|
||
|
|
|
||
|
|
[assembly: log4net.Config.XmlConfigurator(ConfigFile = "log4net.config", ConfigFileExtension = "config", Watch = true)]
|
||
|
|
public class Logger
|
||
|
|
{
|
||
|
|
private static readonly log4net.ILog loginfo = log4net.LogManager.GetLogger("loginfo");
|
||
|
|
private static readonly log4net.ILog logerror = log4net.LogManager.GetLogger("logerror");
|
||
|
|
private static readonly log4net.ILog logmqtt = log4net.LogManager.GetLogger("logmqtt");
|
||
|
|
|
||
|
|
public static void WriteInfo(string info)
|
||
|
|
{
|
||
|
|
Console.WriteLine(info);
|
||
|
|
if (loginfo.IsInfoEnabled)
|
||
|
|
{
|
||
|
|
loginfo.Info(info);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
public static void WriteMqtt(string info)
|
||
|
|
{
|
||
|
|
Console.WriteLine(info);
|
||
|
|
if (logmqtt.IsInfoEnabled)
|
||
|
|
{
|
||
|
|
logmqtt.Info(info);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
public static void WriteError(string error)
|
||
|
|
{
|
||
|
|
Console.WriteLine(error);
|
||
|
|
if (logerror.IsErrorEnabled)
|
||
|
|
{
|
||
|
|
logerror.Error(error);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
public static void WriteError(string info, Exception ex)
|
||
|
|
{
|
||
|
|
Console.WriteLine(info);
|
||
|
|
if (logerror.IsErrorEnabled)
|
||
|
|
{
|
||
|
|
logerror.Error(info, ex);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|