初始化项目
This commit is contained in:
63
APIserver/LogServer/Log4NetHelper.cs
Normal file
63
APIserver/LogServer/Log4NetHelper.cs
Normal file
@@ -0,0 +1,63 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user