Example #1
0
 /// <summary>
 /// Log a message of severity Error
 /// </summary>
 /// <param name="c">Category, mapped to categories in EntLib config file</param>
 /// <param name="m">Message string logged</param>
 /// <param name="p">Parameters</param>
 public static void LogError(Constants.Category c, string m, IDictionary <string, object> d = null)
 {
     if (Logger.IsLoggingEnabled())
     {
         LogEntry entry = CreateLogEntry(m, c, Constants.Severity.Error);
         PerformLogging(d, entry);
     }
 }
Example #2
0
        private static LogEntry CreateLogEntry(Exception ex, Constants.Category c, Constants.Severity s, IDictionary <string, object> d = null)
        {
            LogEntry logentry = new LogEntry();

            logentry.Message  = ex.Message;
            logentry.Severity = MapToTraceEventType(s);
            logentry.Title    = c.ToString();
            return(logentry);
        }
Example #3
0
        /// <summary>
        /// For Audit Log with extended properties
        /// </summary>
        /// <param name="message"></param>
        /// <param name="c"></param>
        /// <param name="s"></param>
        /// <param name="d"></param>
        /// <returns></returns>
        private static LogEntry CreateLogEntryWithObject(string message, Constants.Category c, Constants.Severity s, IDictionary <string, object> d)
        {
            LogEntry logentry = new LogEntry();

            logentry.Message            = message;
            logentry.Severity           = MapToTraceEventType(s);
            logentry.Title              = c.ToString();
            logentry.ExtendedProperties = d;
            return(logentry);
        }
Example #4
0
 /// <summary>
 /// Log an object into text file for Audit log
 /// </summary>
 /// <param name="m">Message string logged</param>
 /// <param name="c">Category, mapped to categories in EntLib config file</param>
 /// <param name="p">Parameters</param>
 public static void LogObjectInfo(Constants.Category c, object m, Constants.Direction direction)
 {
     if (Logger.IsLoggingEnabled())
     {
         // Create a Dictionary of extended properties
         Dictionary <string, object> exProperties = new Dictionary <string, object>();
         exProperties.Add(direction.ToString(), MessageTransform.CreateXML(m));
         LogEntry entry = CreateLogEntryWithObject(m.GetType().Name, c, Constants.Severity.Information, exProperties);
         Logger.Write(entry);
     }
 }
Example #5
0
        /// <summary>
        /// Log a message of severity Error
        /// </summary>
        /// <param name="c">Category, mapped to categories in EntLib config file</param>
        /// <param name="m">Message string logged</param>
        /// <param name="p">Parameters</param>
        public static void LogError(Constants.Category c, Exception ex, LoggingDTO log)
        {
            if (Logger.IsLoggingEnabled())
            {
                log.StackTrace       = ex.StackTrace;
                log.ErrorDescription = ex.ToString();

                Dictionary <string, object> dic = new Dictionary <string, object>();
                dic = log.GetType()
                      .GetProperties(BindingFlags.Instance | BindingFlags.Public)
                      .ToDictionary(prop => prop.Name, prop => prop.GetValue(log, null));

                LogEntry entry = CreateLogEntry(ex.Message, c, Constants.Severity.Error);
                PerformLogging(dic, entry);
            }
        }