Exemple #1
0
        //public bool LogMessage(string message,
        public void LogMessage(string message, LoggingCategory category, LoggingLevel level)
        {
            // TODO: Implement Method - LogManager.LogMessage()
            DataSet objds = new DataSet();

            if (_AuditLogLevel == level || _AuditLogLevel < level)
            {
                //				LogEntry logEntry	= new LogEntry();
                //				logEntry.Message	= message;
                //				logEntry.Category = System.Convert.ToString(category);
                //				Logger.Write(logEntry);

                //
                //				MSDE obj = new MSDE();
                //				obj.InsertIntoLog(logEntry);


                //
                //				obj.InsertIntoLog(dsMgr);
            }

            //			if(_AuditQueueLevel == level  || _AuditQueueLevel < level)
            //			{
            //				//Circular queue;
            //			}

            //return true;
        }
Exemple #2
0
        public void Critical(string message, LoggingCategory category, params object[] parameters)
        {
            ILog log = LogManager.GetLogger(category.ToString());

            //Any idea what to do with the category?
            log.FatalFormat(message, parameters);
        }
Exemple #3
0
 public bool LogException(System.Exception ex, LoggingCategory category, LoggingLevel level, string VerboseMode)
 {
     //ex.Source = VerboseMode;
     ex.Data["CustomExceptionInformation"] = VerboseMode;
     ExceptionManager.Publish(ex);
     return(true);
 }
Exemple #4
0
        private string CreateBaseMessage(LoggingCategory loggingCategory)
        {
            StringBuilder baseMesssageStringBuilder = new StringBuilder();

            baseMesssageStringBuilder.Append("[");
            baseMesssageStringBuilder.Append(DateTime.Now);
            baseMesssageStringBuilder.Append("]");
            baseMesssageStringBuilder.Append(" CATEGORY: ");

            switch (loggingCategory)
            {
            case LoggingCategory.Error:
                baseMesssageStringBuilder.Append("ERROR. ");
                break;

            case LoggingCategory.Information:
                baseMesssageStringBuilder.Append("INFORMATION. ");
                break;

            case LoggingCategory.Warning:
                baseMesssageStringBuilder.Append("WARNING. ");
                break;
            }

            baseMesssageStringBuilder.Append(" MESSAGE: ");

            return(baseMesssageStringBuilder.ToString());
        }
 public void Log(LoggingCategory category, string text)
 {
     if (IsLoggingEnabled(category))
     {
         output.WriteLine("{0}: {1}", DateTime.UtcNow.ToString("yyyy-MM-ddTHH:mm:ss.fffZ"), text);
     }
 }
 public void WriteLineIf(bool condition, string text, LoggingCategory category = LoggingCategory.Debug, [CallerMemberName] string member = "", [CallerLineNumber] int lineNumber = 0)
 {
     if (condition)
     {
         Write(text, category, member, lineNumber);
     }
 }
Exemple #7
0
 public void Log(LoggingCategory category, string text)
 {
     if (IsLoggingEnabled(category))
     {
         output.WriteLine(text);
     }
 }
Exemple #8
0
        private string CreateBaseMessage(LoggingCategory loggingCategory)
        {
            StringBuilder baseMesssageStringBuilder = new StringBuilder();

            baseMesssageStringBuilder.Append("[");
            baseMesssageStringBuilder.Append(DateTime.Now);
            baseMesssageStringBuilder.Append("]");
            baseMesssageStringBuilder.Append(" CATEGORY: ");

            switch (loggingCategory)
            {
                case LoggingCategory.Error:
                    baseMesssageStringBuilder.Append("ERROR. ");
                    break;
                case LoggingCategory.Information:
                    baseMesssageStringBuilder.Append("INFORMATION. ");
                    break;
                case LoggingCategory.Warning:
                    baseMesssageStringBuilder.Append("WARNING. ");
                    break;
            }

            baseMesssageStringBuilder.Append(" MESSAGE: ");

            return baseMesssageStringBuilder.ToString();
        }
 public static void Error(string message, LoggingCategory category, params object[] parameters)
 {
     if (!HasLogger)
     {
         return;
     }
     Logger.Error(message, category, parameters);
 }
 public static void Information(string message, LoggingCategory category, params object[] parameters)
 {
     if (!HasLogger)
     {
         return;
     }
     Logger.Information(message, category, parameters);
 }
 public void Debug(string message, LoggingCategory category, params object[] parameters)
 {
     ILog logger = LogManager.GetLogger(category.ToString());
     if (logger.IsDebugEnabled)
     {
         logger.DebugFormat(message, parameters);
     }
 }
Exemple #12
0
        public void Debug(string message, LoggingCategory category, params object[] parameters)
        {
            ILog log = LogManager.GetLogger(category.ToString());

            if (log.IsDebugEnabled)
            {
                log.DebugFormat(message, parameters);
            }
        }
Exemple #13
0
        public void Log(string message, LoggingCategory loggingCategory, LoggingPriority loggingPriority)
        {
            LogEntry entry = new LogEntry();

            entry.Message = message;
            entry.Categories.Add(loggingCategory.ToString());
            entry.Priority = (int)Enum.Parse(typeof(LoggingPriority), loggingPriority.ToString());
            Logger.Write(entry);
        }
Exemple #14
0
        /// <summary>
        /// This Method will log Exception and Display Error message to the user
        /// </summary>
        /// <param name="ex">ex Object, containing Exception Information</param>
        /// <param name="category">Category- General</param>
        /// <param name="level">Logging Level- error, Warning or Information</param>
        /// <returns>bool value- True/False</returns>
        /// <CreatedBy>Piyush</CreatedBy>
        /// <CreatedOn>2nd August 2007</CreatedOn>
        public static bool LogException(System.Exception ex, LoggingCategory category, LoggingLevel level, Control Ctrl)
        {
            BaseActivityPage ObjectActivityPage = null;

            try
            {
                if (ex.GetType().FullName != "System.Threading.ThreadAbortException")
                {
                    ExceptionManager.Publish(ex);
                }
                //ExceptionManager.Publish(ex);
                // Following line of code added by Piyush on 2nd August 2007, so as to check Concurrency and SQl Exception and display the Exception to the user
                ObjectActivityPage = new BaseActivityPage();
                string ParseMessage = ex.Message;

                // Code Added by Piyush on 6th September 2007 so as to check error number emerged in case of business rule voilation
                string ErrorNumber = "";
                if (ParseMessage.IndexOf("*****") > 0)
                {
                    ErrorNumber = ParseMessage.Substring(0, ParseMessage.IndexOf("*****"));
                    Int32 Index = ParseMessage.IndexOf("*****") + 5;
                    ParseMessage = ParseMessage.Substring(Index);
                    ParseMessage = ParseMessage.Substring(0, ParseMessage.IndexOf("*****"));
                    ObjectActivityPage.ShowError(ParseMessage, true, Ctrl);
                }
                // Code Addition ends here by Piyush on 6th September 2007 so as to check error number emerged in case of business rule voilation
                else
                {
                    if (ex.Message.IndexOf("Concurrency") != -1)
                    {
                        ObjectActivityPage.ShowError("The information you are updating has been changed by another user. Please refresh the information you are updating.", true, Ctrl);
                    }
                    else if (ParseMessage.IndexOf("System.Data.SqlClient.SqlException:") > 0)
                    {
                        int SubstringLen = ParseMessage.IndexOf("\n") - ParseMessage.IndexOf("System.Data.SqlClient.SqlException:");
                        ParseMessage = ParseMessage.Substring(ParseMessage.IndexOf("System.Data.SqlClient.SqlException:") + 35, SubstringLen - 35);
                        ObjectActivityPage.ShowError(ParseMessage, true, Ctrl);
                    }

                    else
                    {
                        ObjectActivityPage.ShowError("Error Occurred - Please Contact Your System Administrator!", true, Ctrl);
                    }
                    // Addition ends here by Piyush on 2nd August 2007, so as to check Concurrency and SQl Exception and display the Exception to the user
                }
            }
            catch
            {
                string str = ex.Message.ToString();
            }
            finally
            {
                ObjectActivityPage = null;
            }
            return(true);
        }
Exemple #15
0
        /// <summary>
        /// Sends the message to the raw output callback if the given category has logging enabled.
        /// </summary>
        /// <param name="category">The category of debug event logging.</param>
        /// <param name="message">The message to log.</param>
        /// <param name="data">Logging data to send alongside the message, if any.</param>
        public void WriteRaw(LoggingCategory category, string message, Dictionary <string, object> data = null)
        {
            // Default to logging the message if we haven't set a status for this category.
            if (_isLoggingEnabled.ContainsKey(category) && !_isLoggingEnabled[category])
            {
                return;
            }

            _sendToRawOutput.Invoke(CreateOutputEvent(category, message, data));
        }
        private void WriteTrace(LoggingCategory category, string message)
        {
            // Default to logging the message if we haven't set a status for this category.
            if (_isLoggingEnabled.ContainsKey(category) && !_isLoggingEnabled[category])
            {
                return;
            }

            _traceCallback.Invoke(CreateOutputEvent(category, message));
        }
Exemple #17
0
        public void Write(string message, LoggingCategory loggingCategory)
        {
            if (String.IsNullOrEmpty(message))
                return;

            message = String.Format("{0} {1}", CreateBaseMessage(loggingCategory), message);

            lock(fileWritingLockObject)
                File.AppendAllLines(fileName, new[] {message});
        }
 public void Debug(string message, LoggingCategory category, params object[] parameters)
 {
     if (category == LoggingCategory.Performance)
     {
         Log.Trace(message, parameters);
     }
     else
     {
         Log.Debug(message, parameters);
     }
 }
Exemple #19
0
 public void Debug(string message, LoggingCategory category, params object[] parameters)
 {
     if (category == LoggingCategory.Performance)
     {
         Log.Trace(message, parameters);
     }
     else
     {
         Log.Debug(message, parameters);
     }
 }
Exemple #20
0
 private static bool SafeIsLoggingEnabled(ILogger logger, LoggingCategory category)
 {
     try
     {
         return(logger != null && logger.IsLoggingEnabled(category));
     }
     catch (Exception)
     {
         // Nothing to do here; normally it'd be nice to log an exception, but not if our logger is misbehavin'.
         return(false);
     }
 }
Exemple #21
0
        public void Write(string message, LoggingCategory loggingCategory)
        {
            if (String.IsNullOrEmpty(message))
            {
                return;
            }

            message = String.Format("{0} {1}", CreateBaseMessage(loggingCategory), message);

            lock (fileWritingLockObject)
                File.AppendAllLines(fileName, new[] { message });
        }
        /// <summary>
        /// This Method will log Exception and Display Error message to the user
        /// </summary>
        /// <param name="ex">ex Object, containing Exception Information</param>
        /// <param name="category">Category- General</param>
        /// <param name="level">Logging Level- error, Warning or Information</param>
        /// <returns>bool value- True/False</returns>
        /// <CreatedBy>Chandan</CreatedBy>
        /// <CreatedOn>Feb 13 2008</CreatedOn>
        public static bool LogException(System.Exception ex, LoggingCategory category, LoggingLevel level, Control Ctrl)
        {
            BaseActivityPage ObjectActivityPage = null;

            try
            {
                ExceptionManager.Publish(ex);
                ObjectActivityPage = new BaseActivityPage();
                string ParseMessage = ex.Message;

                string ErrorNumber = "";
                if (ParseMessage.IndexOf("*****") > 0)
                {
                    ErrorNumber = ParseMessage.Substring(0, ParseMessage.IndexOf("*****"));
                    Int32 Index = ParseMessage.IndexOf("*****") + 5;
                    ParseMessage = ParseMessage.Substring(Index);
                    ParseMessage = ParseMessage.Substring(0, ParseMessage.IndexOf("*****"));
                    ObjectActivityPage.ShowError(ParseMessage, true, Ctrl);
                }
                else
                {
                    if (ex.Message.IndexOf("Concurrency") != -1)
                    {
                        ObjectActivityPage.ShowError("The information you are updating has been changed by another user. Please refresh the information you are updating.", true, Ctrl);
                    }
                    else if (ParseMessage.IndexOf("System.Data.SqlClient.SqlException:") > 0)
                    {
                        int SubstringLen = ParseMessage.IndexOf("\n") - ParseMessage.IndexOf("System.Data.SqlClient.SqlException:");
                        ParseMessage = ParseMessage.Substring(ParseMessage.IndexOf("System.Data.SqlClient.SqlException:") + 35, SubstringLen - 35);
                        ObjectActivityPage.ShowError(ParseMessage, true, Ctrl);
                    }

                    else
                    {
                        ObjectActivityPage.ShowError("Error Occurred - Please Contact Your System Administrator!", true, Ctrl);
                    }
                }
            }
            catch
            {
                string str = ex.Message.ToString();
                if (ObjectActivityPage == null)
                {
                    ObjectActivityPage = new BaseActivityPage();
                }
                ObjectActivityPage.ShowError("Error Occurred - Please Contact Your System Administrator!", true);
            }
            finally
            {
                ObjectActivityPage = null;
            }
            return(true);
        }
Exemple #23
0
        void Write(LoggingCategory category, string title, Exception exception, params object[] args)
        {
            var properties = new Dictionary <string, object>();

            for (int i = 0; i < args.Length; i++)
            {
                properties.Add(string.Format("args{0}", i), args[i]);
            }
            LogEntry logent = new LogEntry(exception, category.ToString(), 0, 0, TraceEventType.Verbose, title, properties);

            Write(logent);
        }
 /// <summary>
 /// Logs the specified message.
 /// </summary>
 /// <param name="message">The message.</param>
 /// <param name="loggingCategory">The logging category.</param>
 /// <param name="priority">The priority.</param>
 /// <param name="traceEventType">Type of the trace event.</param>
 /// <param name="className">Name of the class.</param>
 /// <param name="methodName">Name of the method.</param>
 /// <param name="networkId">The fire network identifier.</param>
 private static void Log(string message, LoggingCategory loggingCategory, LogPriorityID priority, System.Diagnostics.TraceEventType traceEventType, string className, string methodName, int networkId)
 {
     Logging.DoLog(new LogEntry()
     {
         MessageDetails = message,
         LogCategory    = loggingCategory,
         LogPriority    = priority,
         LogEventType   = traceEventType,
         ClassName      = "Class Name = " + className,
         MethodName     = "Method Name = " + methodName,
         NetworkId      = networkId
     });
 }
        public void LogMessage(string message, LoggingCategory category = LoggingCategory.Standard)
        {
            if (Logger.IsLoggingEnabled && Logger.IsCategoryEnabled(category))
            {
                var attributes = AttributeList.ToList();
                attributes.Add(new LogAttribute()
                {
                    Name  = nameof(CommonLogAttributes.Message),
                    Value = message
                });

                WriteEntry(LoggingAction.Entry, attributes);
            }
        }
Exemple #26
0
 public void Log(LoggingCategory category, string message)
 {
     try
     {
         var writer = File.AppendText(Path);
         writer.WriteLine(string.Format("Category: {0}, Message: {1}", category.ToString(), message));
         writer.Flush();
     }
     catch (Exception ex)
     {
         //In case the message cannot be written to a file - write it to the EventLog
         EventLog.WriteEntry(Process.GetCurrentProcess().ProcessName,
                             string.Format("CouldNot log the message: {0}, Exception: {1}", message, ex.ToString()), EventLogEntryType.Error);
     }
 }
Exemple #27
0
 public static bool IsCategoryEnabled(LoggingCategory category)
 {
     if (AreAllCategoriesEnabled)
     {
         return(true);
     }
     else if (loggingCategories.Keys.Contains(category))
     {
         return(loggingCategories[category]);
     }
     else
     {
         return(AreNonSetCategoriesEnabled);
     }
 }
        public void TraceLogger_EventHandler(object sender, LogEventArgs args)
        {
            string          message  = args.Message + Environment.NewLine;
            LoggingCategory category = LoggingCategory.DebuggerError;

            if (args.Message.StartsWith("<--  ", StringComparison.Ordinal))
            {
                category = LoggingCategory.AdapterTrace;
            }
            else if (args.Message.StartsWith("--> ", StringComparison.Ordinal))
            {
                category = LoggingCategory.AdapterResponse;
            }

            WriteTrace(category, message);
        }
Exemple #29
0
        private static void SafeLog(ILogger logger, LoggingCategory category, string format, params object[] formatArgs)
        {
            if (logger == null || !SafeIsLoggingEnabled(logger, category))
            {
                return;
            }

            try
            {
                logger.Log(category, String.Format(format, formatArgs));
            }
            catch (Exception)
            {
                // Nothing to do here; normally it'd be nice to log an exception, but not if our logger is misbehavin'.
            }
        }
Exemple #30
0
 public void Log(LoggingCategory category, string message)
 {
     try
     {
         var writer = File.AppendText(Path);
         writer.WriteLine(string.Format("Category: {0}, Message: {1}", category.ToString(), message));
         writer.Flush();
     }
     catch (Exception ex)
     {
         //In case the message cannot be written to a file - write it to the EventLog
         EventLog.WriteEntry(Process.GetCurrentProcess().ProcessName,
             string.Format("CouldNot log the message: {0}, Exception: {1}", message, ex.ToString()),EventLogEntryType.Error);
     }
     
    
 }
        private void Write(string text, LoggingCategory category, string member, int lineNumber)
        {
            string line = string.Format(m_SCHEMA, DateTime.Now, category.ToString(), text);

            if (System.Diagnostics.Debugger.IsAttached)
            {
                System.Diagnostics.Debug.WriteLine(line, category.ToString());
            }

            if (_logFile == null)
            {
                var date = DateTime.Now;
                _logFile = ApplicationData.Current.TemporaryFolder.CreateFileAsync($"log-{date.ToString("yyyy-MM-dd")}.txt", CreationCollisionOption.OpenIfExists).AsTask().Result;
            }

            NotifyTaskCompletion.Create(FileIO.AppendTextAsync(_logFile, line + "\r\n").AsTask());
        }
        public static void Log(LoggingCategory loggingCategory, string message)
        {
            LogDescriptor logDescriptor = new LogDescriptor
            {
                Category = loggingCategory.ToString(),
                Message  = message
            };

            Logger logger = new Logger(c_token, c_httpsEndpoint);

            try
            {
                logger.LogSync(JsonConvert.SerializeObject(logDescriptor), true);
            }
            catch
            {
            }
        }
Exemple #33
0
        public void  Log(LoggingCategory category, string message)
        {
            switch (category)
            {
                case LoggingCategory.Warning:
                    Console.ForegroundColor = ConsoleColor.Yellow;
                    break;
                case LoggingCategory.Error:
                    Console.ForegroundColor = ConsoleColor.Red;
                    break;
                default:
                    Console.ForegroundColor = ConsoleColor.Green;
                    break;
            }

         	Console.WriteLine(category);
            Console.WriteLine(message);           
        }
Exemple #34
0
 private static void Log(string message, LoggingCategory category, TraceEventType severity,
                         params string[] parameters)
 {
     //var logEntry = new LogEntry();
     //logEntry.Categories.Add(category.ToString());
     //logEntry.Severity = severity;
     //if (Logger.ShouldLog(logEntry))
     //{
     //    if (parameters.Length > 0)
     //    {
     //        logEntry.Message = string.Format(message, parameters);
     //    }
     //    else
     //    {
     //        logEntry.Message = message;
     //    }
     //}
     //Logger.Write(logEntry);
 }
Exemple #35
0
        private OutputEvent CreateOutputEvent(LoggingCategory category, string message, Dictionary <string, object> data = null)
        {
            // By default send debugger messages to the standard console.
            OutputEvent.Category outputCategory = OutputEvent.Category.console;
            switch (category)
            {
            case LoggingCategory.StdOut: outputCategory = OutputEvent.Category.stdout; break;

            case LoggingCategory.StdErr: outputCategory = OutputEvent.Category.stderr; break;

            case LoggingCategory.DebuggerError: outputCategory = OutputEvent.Category.stderr; break;

            case LoggingCategory.Telemetry: outputCategory = OutputEvent.Category.telemetry; break;

            default: break;
            }

            return(new OutputEvent(outputCategory, message, data));
        }
 private void Log(string message, LoggingCategory category, TraceEventType severity,
                         params object[] parameters)
 {
     var logEntry = new EntLib.LogEntry();
     logEntry.Categories.Add(category.ToString());
     logEntry.Severity = severity;
     if (EntLib.Logger.ShouldLog(logEntry))
     {
         if (parameters.Length > 0)
         {
             logEntry.Message = string.Format(message, parameters);
         }
         else
         {
             logEntry.Message = message;
         }
     }
     EntLib.Logger.Write(logEntry);
 }
 private static bool SafeIsLoggingEnabled(ILogger logger, LoggingCategory category)
 {
     try
     {
         return(logger != null && logger.IsLoggingEnabled(category));
     }
     catch (Exception e)
     {
         // Try to log a warning about our logger not working, but, this could be a lost cause.
         try
         {
             logger.Log(LoggingCategory.Warning, String.Format("Error occurred while checking is logging enabled: {0}", e));
         }
         catch
         {
             // Well, we tried.
         }
         return(false);
     }
 }
 public void Error(string message, LoggingCategory category, params object[] parameters)
 {
     Log.Error(message, parameters);
 }
 public DefaultLogger(LoggingCategory minimumCategory, TextWriter output)
 {
     this.minimumCategory = minimumCategory;
     this.output = output;
 }
Exemple #40
0
 public static void Critical(string message, LoggingCategory category, params string[] parameters)
 {
     Log(message, category, TraceEventType.Critical, parameters);
 }
Exemple #41
0
 public static void Warning(string message, LoggingCategory category, params string[] parameters)
 {
     Log(message, category, TraceEventType.Warning, parameters);
 }
Exemple #42
0
 public static void Debug(string message, LoggingCategory category, params string[] parameters)
 {
     Log(message, category, TraceEventType.Verbose, parameters);
 }
 public void Critical(string message, LoggingCategory category, params object[] parameters)
 {
     LogManager.GetLogger(category.ToString()).FatalFormat(message, parameters);
 }
 public static void Critical(string message, LoggingCategory category, params object[] parameters)
 {
     if (!HasLogger) return;
     Logger.Critical(message, category, parameters);
 }
 public static void Information(string message, LoggingCategory category, params object[] parameters)
 {
     if (!HasLogger) return;
     Logger.Information(message, category, parameters);
 }
 public void Log(LoggingCategory category, string text)
 {
     if (IsLoggingEnabled(category))
         output.WriteLine(text);
 }
 public bool IsLoggingEnabled(LoggingCategory category)
 {
     return category >= minimumCategory;
 }
 public void Critical(string message, LoggingCategory category, params object[] parameters)
 {
     //throw new NotImplementedException();
 }
 public void Warning(string message, LoggingCategory category, params object[] parameters)
 {
     Log.Warn(message, parameters);
 }
Exemple #50
0
 public void Log(LoggingCategory category, string text)
 {
     if (IsLoggingEnabled(category))
         output.WriteLine("{0}: {1}", DateTime.UtcNow.ToString("yyyy-MM-ddTHH:mm:ss.fffZ"), text);
 }
Exemple #51
0
 public void Log(LoggingCategory category, string message)
 {
     sb.AppendLine(string.Format("Category: {0}, Message: {1}", category.ToString(), message));
 }
Exemple #52
0
 public static void Information(string message, LoggingCategory category, params string[] parameters)
 {
     Log(message, category, TraceEventType.Information, parameters);
 }
 public void Critical(string message, LoggingCategory category, params object[] parameters)
 {
     ILog log = LogManager.GetLogger(category.ToString());
     //Any idea what to do with the category?
     log.FatalFormat(message, parameters);
 }
Exemple #54
0
 public static void Error(string message, LoggingCategory category, params string[] parameters)
 {
     Log(message, category, TraceEventType.Error, parameters);
 }
 public void Warning(string message, LoggingCategory category, params object[] parameters)
 {
     ILog log = LogManager.GetLogger(category.ToString());
     log.WarnFormat(message, parameters);
 }
 public void Information(string message, LoggingCategory category, params object[] parameters)
 {
     Log.Info(message, parameters);
 }
 public void Information(string message, LoggingCategory category, params object[] parameters)
 {
     LogManager.GetLogger(category.ToString()).InfoFormat(message, parameters);
 }