68 lines
1.8 KiB
C#
68 lines
1.8 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
|
|
namespace DeiNiu.Utils
|
|
{
|
|
public class LogHelper
|
|
{
|
|
static log4net.ILog log =log4net.LogManager.GetLogger("logCommon");
|
|
/// <summary>
|
|
/// 输出日志到Log4Net
|
|
/// </summary>
|
|
/// <param name="t"></param>
|
|
/// <param name="ex"></param>
|
|
#region static void WriteLog(Type t, Exception ex)
|
|
|
|
public static void WriteLog(Type t, Exception ex)
|
|
{
|
|
// log4net.ILog log = log4net.LogManager.GetLogger(t);
|
|
log.Error(getMsg(t.ToString(), ex.StackTrace), ex);
|
|
}
|
|
|
|
#endregion
|
|
|
|
/// <summary>
|
|
/// 输出日志到Log4Net
|
|
/// </summary>
|
|
/// <param name="t"></param>
|
|
/// <param name="msg"></param>
|
|
#region static void WriteLog(Type t, string msg)
|
|
|
|
public static void WriteLog(Type t, string msg)
|
|
{
|
|
// log4net.ILog log = log4net.LogManager.GetLogger(t);
|
|
|
|
log.Error(getMsg(t.ToString(), msg));
|
|
}
|
|
|
|
|
|
public static void debug(string className, string msg)
|
|
{
|
|
// log4net.ILog log = log4net.LogManager.GetLogger(className);
|
|
log.Debug(getMsg(className, msg));
|
|
}
|
|
|
|
public static void debug(Type t, string msg)
|
|
{
|
|
// log4net.ILog log = log4net.LogManager.GetLogger(t);
|
|
log.Debug(getMsg(t.ToString(),msg));
|
|
}
|
|
|
|
public static void info(string className, string msg)
|
|
{
|
|
// log4net.ILog log = log4net.LogManager.GetLogger(className);
|
|
log.Info(getMsg(className,msg));
|
|
}
|
|
|
|
static string getMsg(string className, string msg)
|
|
{
|
|
return string.Format("{0} -----{1}",className,msg);
|
|
}
|
|
|
|
#endregion
|
|
|
|
}
|
|
}
|