ExceptionHelper异常工具类
using System;
using System.Collections.Generic;
using System.Text;
namespace JiaWel.Utilities
{
public static class ExceptionHelper
{
//日志记录
private static readonly log4net.ILog log = log4net.LogManager.GetLogger("JiaWel.LOG4");
/// <summary>
/// 记录错误信息
/// </summary>
/// <param name="method">调用的方法名称</param>
/// <param name="message">错误详细信息</param>
public static void WriteException(string method, string message)
{
try
{
lock (log)
{
log.ErrorFormat(DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss") + " | " + method + " | 详情:" + message);
}
}
catch (System.Exception)
{
// throw;
}
}
/// <summary>
/// 记录错误信息
/// </summary>
/// <param name="method">调用的方法名称</param>
/// <param name="message">错误详细信息</param>
public static void WriteErrorMessage(string method, string message)
{
try
{
lock (log)
{
log.ErrorFormat(DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss") + " | " + method + " | 详情:" + message);
}
}
catch (System.Exception)
{
// throw;
}
}
/// <summary>
/// 记录提示信息
/// </summary>
/// <param name="message"></param>
public static void WriteInfoMessage(string method, string message)
{
try
{
lock (log)
{
log.InfoFormat(DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss") + " | " + method + " | 详情:" + message);
}
}
catch (Exception)
{
// throw;
}
}
}
}