/// <summary>
        /// Writes the specified artifact.
        /// </summary>
        /// <param name="artifact">The artifact.</param>
        public override void Write(LogArtifact artifact)
        {
            try
            {
                m_log.WriteEntry(artifact.FormattedMessage, GetEventLogEntryType(artifact.Severity));
            }
            catch (ObjectDisposedException)
            {
                using (EventLog log = new EventLog())
                {
                    log.Source = m_log.Source;
                    log.Log    = m_log.Log;

                    log.WriteEntry(artifact.FormattedMessage, GetEventLogEntryType(artifact.Severity));
                }
            }
        }
        /// <summary>
        /// Actually does the processing of the background thread to call the writes
        /// </summary>
        /// <param name="isFinal">if set to <c>true</c> [is final].</param>
        private static void LoggerThread(bool isFinal)
        {
            lock (s_loggerThreadLock)
            {
                int length = s_artifacts.Count;

                if (length > 0)
                {
                    if (SameLoggers)
                    {
                        LogArtifact[] artifacts = new LogArtifact[length];
                        s_artifacts.CopyTo(0, artifacts, 0, length);
                        artifacts[0].Logger.Write(artifacts);
                    }
                    else
                    {
                        for (int i = 0; i < length; i++)
                        {
                            LogArtifact artifact = s_artifacts[i];
                            try
                            {
                                artifact.Logger.Write(artifact);
                            }
                            catch (Exception ex)
                            {
                                try
                                {
                                    CriticalLogger.Current.LogException(ex);
                                }
                                catch (Exception)
                                {
                                }
                            }
                        }
                    }
                    s_artifacts.RemoveRange(0, length);
                }
            }
        }
        /// <summary>
        /// Writes the internal.
        /// </summary>
        /// <param name="artifacts">The artifacts.</param>
        protected virtual void WriteInternal(params LogArtifact[] artifacts)
        {
            LogArtifact first    = artifacts[0];
            string      fileName = GetFileName(first.Severity, first.Timestamp, first.RawEntry, first.RawFormatParameters, first.FormattedMessage, artifacts);

            if (!string.IsNullOrEmpty(fileName))
            {
                using (FileStream stream = GetStream(fileName))
                {
                    foreach (LogArtifact artifact in artifacts)
                    {
                        byte[] data = Encoding.GetBytes(artifact.FormattedMessage);

                        stream.Write(data, 0, data.Length);
                        if (UseCarriageReturn)
                        {
                            stream.WriteByte((byte)'\r');
                        }
                        stream.WriteByte((byte)'\n');
                    }
                    stream.Flush();
                }
            }
        }
 /// <summary>
 /// Writes the specified artifact.
 /// </summary>
 /// <param name="artifact">The artifact.</param>
 public override void Write(LogArtifact artifact)
 {
     WriteInternal(artifact);
 }
 /// <summary>
 /// Writes the specified artifact.
 /// </summary>
 /// <param name="artifact">The artifact.</param>
 public abstract void Write(LogArtifact artifact);
        /// <summary>
        /// High level final log that is called with all of the detailed information
        /// and the final log line as the last parameter.
        /// </summary>
        /// <param name="severity">The severity.</param>
        /// <param name="timestamp">The timestamp.</param>
        /// <param name="entry">The entry.</param>
        /// <param name="formatParameters">The format parameters.</param>
        /// <param name="logLine">The log line.</param>
        protected virtual void DoLog(LoggerSeverity severity, DateTime timestamp, object entry, object[] formatParameters, string logLine)
        {
            LogArtifact artifact = new LogArtifact(this, severity, timestamp, entry, formatParameters, logLine);

            Logger.PushArtifact(artifact);
        }
 /// <summary>
 /// Pushes the artifact.
 /// </summary>
 /// <param name="artifact">The artifact.</param>
 public static void PushArtifact(LogArtifact artifact)
 {
     s_artifacts.Add(artifact);
 }
 /// <summary>
 /// Writes the specified artifact.
 /// </summary>
 /// <param name="artifact">The artifact.</param>
 public override void Write(LogArtifact artifact)
 {
 }
 /// <summary>
 /// Writes the specified artifact.
 /// </summary>
 /// <param name="artifact">The artifact.</param>
 public override void Write(LogArtifact artifact)
 {
     m_writer.WriteLine(artifact.FormattedMessage);
 }
 /// <summary>
 /// Writes the specified artifact.
 /// </summary>
 /// <param name="artifact">The artifact.</param>
 public override void Write(LogArtifact artifact)
 {
     // should never get here
     throw new NotImplementedException();
 }