| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- using System;
- using log4net;
- [assembly: log4net.Config.XmlConfigurator(ConfigFile = "Log.config", ConfigFileExtension = "config", Watch = true)]
- namespace Core.ONH.Collection.comm
- {
- public class LogHelper
- {
- /// <summary>
- /// 输出日志到Log4Net
- /// </summary>
- /// <param name="t"></param>
- /// <param name="ex"></param>
- #region static void WriteException(Type t, Exception ex)
- public static void WriteException(Type t, Exception ex)
- {
- ILog log = LogManager.GetLogger(t == null ? typeof(LogHelper) : t);
- log.Error("Error", ex);
- }
- #endregion
- /// <summary>
- /// 输出日志到Log4Net
- /// </summary>
- /// <param name="t"></param>
- /// <param name="msg"></param>
- #region static void WriteException(Type t, string msg)
- public static void WriteException(Type t, string msg)
- {
- ILog log = LogManager.GetLogger(t);
- log.Error(msg);
- }
- #endregion
- /// <summary>
- /// 输出日志到Log4Net
- /// </summary>
- /// <param name="t"></param>
- /// <param name="msg"></param>
- #region static void WriteException(Type t, string msg)
- public static void WriteInfo(Type t, string msg)
- {
- ILog log = LogManager.GetLogger(t);
- log.Info(msg);
- }
- #endregion
- }
- }
|