예제 #1
0
        string getClipboardString()
        {
            StringBuilder sb = new StringBuilder();

            sb.Append(Gui.AboutSharpDevelopTabPage.GetVersionInformationString());

            sb.AppendLine();

            if (message != null)
            {
                sb.AppendLine(message);
            }
            if (exceptionThrown != null)
            {
                sb.AppendLine("Exception thrown:");
                sb.AppendLine(exceptionThrown.ToString());
            }
            sb.AppendLine();
            sb.AppendLine("---- Recent log messages:");
            try
            {
                LogMessageRecorder.AppendRecentLogMessages(sb, log4net.LogManager.GetLogger(typeof(log4netLoggingService)));
            }
            catch (Exception ex)
            {
                sb.AppendLine("Failed to append recent log messages.");
                sb.AppendLine(ex.ToString());
            }
            sb.AppendLine();
            sb.AppendLine("---- Post-error application state information:");
            try
            {
                SD.GetRequiredService <ApplicationStateInfoService>().AppendFormatted(sb);
            }
            catch (Exception ex)
            {
                sb.AppendLine("Failed to append application state information.");
                sb.AppendLine(ex.ToString());
            }
            return(sb.ToString());
        }
예제 #2
0
        /// <summary>
        /// Appends the recent log messages recorded by the <see cref="LogMessageRecorder"/>
        /// to the specified <see cref="StringBuilder"/>.
        /// </summary>
        /// <param name="sb">The <see cref="StringBuilder"/> to append the rendered log messages to.</param>
        /// <param name="log">An <see cref="ILog"/> that points to a logger which is in the repository that contains the <see cref="LogMessageRecorder"/> appender.</param>
        public static void AppendRecentLogMessages(StringBuilder sb, ILog log)
        {
            LogMessageRecorder recorder = log.Logger.Repository.GetAppenders().OfType <LogMessageRecorder>().Single();

            foreach (LoggingEvent e in recorder.RecordedEvents)
            {
                sb.Append(e.TimeStamp.ToString(@"HH\:mm\:ss\.fff", CultureInfo.InvariantCulture));
                sb.Append(" [");
                sb.Append(e.ThreadName);
                sb.Append("] ");
                sb.Append(e.Level.Name);
                sb.Append(" - ");
                sb.Append(e.RenderedMessage);
                sb.AppendLine();

                if (e.ExceptionObject != null)
                {
                    sb.AppendLine("--> Exception:");
                    sb.AppendLine(e.GetExceptionString());
                }
            }
        }