64 lines
1.7 KiB
C#
64 lines
1.7 KiB
C#
|
|
using System;
|
|||
|
|
using System.Collections.Generic;
|
|||
|
|
using System.Linq;
|
|||
|
|
using System.Text;
|
|||
|
|
using System.Threading.Tasks;
|
|||
|
|
|
|||
|
|
namespace LogServer
|
|||
|
|
{
|
|||
|
|
public class Log4NetHelper
|
|||
|
|
{
|
|||
|
|
/// <summary>
|
|||
|
|
/// 写log
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="logMessage"></param>
|
|||
|
|
public static void Log(string logMessage)
|
|||
|
|
{
|
|||
|
|
var log = LoggerFactory.CreateInstance(Log4NetType.Info.ToString());
|
|||
|
|
if (log.IsInfoEnabled)
|
|||
|
|
{
|
|||
|
|
log.Info(logMessage);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
/// <summary>
|
|||
|
|
/// debug
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="logMessage"></param>
|
|||
|
|
public static void Debug(string logMessage)
|
|||
|
|
{
|
|||
|
|
var log = LoggerFactory.CreateInstance(Log4NetType.Info.ToString());
|
|||
|
|
if (log.IsInfoEnabled)
|
|||
|
|
{
|
|||
|
|
log.Info(logMessage);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
/// <summary>
|
|||
|
|
/// debug
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="logMessage">消息</param>
|
|||
|
|
/// <param name="ex">异常</param>
|
|||
|
|
public static void Debug(string logMessage, Exception ex)
|
|||
|
|
{
|
|||
|
|
var log = LoggerFactory.CreateInstance(Log4NetType.Info.ToString());
|
|||
|
|
if (log.IsInfoEnabled)
|
|||
|
|
{
|
|||
|
|
log.Error(logMessage, ex);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
/// <summary>
|
|||
|
|
/// log
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="logMessage">消息</param>
|
|||
|
|
/// <param name="ex">异常</param>
|
|||
|
|
public static void Log(string logMessage, Exception ex)
|
|||
|
|
{
|
|||
|
|
var log = LoggerFactory.CreateInstance(Log4NetType.Info.ToString());
|
|||
|
|
if (log.IsInfoEnabled)
|
|||
|
|
{
|
|||
|
|
log.Error(logMessage, ex);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}
|