Esempio n. 1
0
 static Log()
 {
     try
     {
         LoggingService = new LoggingService();
     }
     catch (Exception e)
     {
         Ultities.EventLogException("Tracer constructor", e);
     }
 }
Esempio n. 2
0
 public static void LogDebug(string message, params object[] parameters)
 {
     try
     {
         string fullName = Assembly.GetCallingAssembly().FullName;
         LogMessage(LogLevel.Debug, message + FormatParams(parameters), null, fullName, null, 0, false);
     }
     catch (Exception e)
     {
         Ultities.EventLogException("Tracer.TraceDebug", e);
     }
 }
Esempio n. 3
0
 public static void LogTrace(LogLevel severity, string message)
 {
     try
     {
         string fullName = Assembly.GetCallingAssembly().FullName;
         LogMessage(severity, message, null, fullName, null, 0, false);
     }
     catch (Exception e)
     {
         Ultities.EventLogException("Tracer.Trace", e);
     }
 }
Esempio n. 4
0
 public static void LogInfo(string message, params object[] parameters)
 {
     try
     {
         LogMessage(LogLevel.Info, message + FormatParams(parameters), null,
                    Assembly.GetCallingAssembly().FullName, null, 0, false);
     }
     catch (Exception e)
     {
         Ultities.EventLogException("Tracer.TraceInfo", e);
     }
 }
Esempio n. 5
0
 public static void LogError(string errorMessage, int errorNumber = 0)
 {
     try
     {
         string fullName = Assembly.GetCallingAssembly().FullName;
         LogMessage(LogLevel.Error, errorMessage, null, fullName, null, errorNumber, false);
     }
     catch (Exception e)
     {
         Ultities.EventLogException("Tracer.TraceError", e);
     }
 }
Esempio n. 6
0
        private LogLevel GetNLogLevelFromSeverity(int severity)
        {
            LogLevel info = LogLevel.Info;

            try
            {
                info = LogLevel.FromOrdinal(severity);
            }
            catch (Exception e)
            {
                Ultities.EventLogException("LoggingService.GetNLogLevelFromSeverity", e);
            }
            return(info);
        }
Esempio n. 7
0
 private static void LogException(LogLevel severity, Exception exception, string message = null)
 {
     try
     {
         string fullName = Assembly.GetCallingAssembly().FullName;
         if (!string.IsNullOrEmpty(message))
         {
             LogMessage(severity, message, null, fullName, null, 0, false);
         }
         LogMessage(severity, null, null, fullName, exception, 0, false);
     }
     catch (Exception e)
     {
         Ultities.EventLogException("Tracer.TraceException", e);
     }
 }
Esempio n. 8
0
        public static void LogDataSet(LogLevel severity, DataSet dataset)
        {
            string fullName = Assembly.GetCallingAssembly().FullName;

            try
            {
                if (dataset == null)
                {
                    LogMessage(LogLevel.Error, "TraceDataSet called with a null dataset", null, fullName, null, 0, false);
                }
                else
                {
                    string tempFileName = Path.GetTempFileName();
                    dataset.WriteXml(tempFileName);
                    LogMessage(severity, "The DataSet file was written to:" + tempFileName, null, fullName, null, 0, false);
                }
            }
            catch (Exception e)
            {
                Ultities.EventLogException("Logger.LogDataSet", e);
            }
        }
Esempio n. 9
0
        private static void LogFunc(string functionName, bool enterFunc = false, params object[] parameters)
        {
            string fullName = Assembly.GetCallingAssembly().FullName;

            string isEnterStr = enterFunc ? "LogEnterFunc" : "LogExitFunc";

            try
            {
                if (string.IsNullOrEmpty(functionName))
                {
                    LogMessage(LogLevel.Error, isEnterStr + " called with a null function name.", null, fullName, null,
                               0, false);
                }
                else
                {
                    LogMessage(LogLevel.Trace, isEnterStr + functionName + FormatParams(parameters), null, fullName,
                               null, 0, false);
                }
            }
            catch (Exception e)
            {
                Ultities.EventLogException("Logger.Logger." + isEnterStr, e);
            }
        }