123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909 |
- #region Apache License
- //
- // Licensed to the Apache Software Foundation (ASF) under one or more
- // contributor license agreements. See the NOTICE file distributed with
- // this work for additional information regarding copyright ownership.
- // The ASF licenses this file to you under the Apache License, Version 2.0
- // (the "License"); you may not use this file except in compliance with
- // the License. You may obtain a copy of the License at
- //
- // http://www.apache.org/licenses/LICENSE-2.0
- //
- // Unless required by applicable law or agreed to in writing, software
- // distributed under the License is distributed on an "AS IS" BASIS,
- // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- // See the License for the specific language governing permissions and
- // limitations under the License.
- //
- #endregion
- using System;
- using System.IO;
- using System.Collections;
- using log4net.Filter;
- using log4net.Util;
- using log4net.Layout;
- using log4net.Core;
- namespace log4net.Appender
- {
- /// <summary>
- /// Abstract base class implementation of <see cref="IAppender"/>.
- /// </summary>
- /// <remarks>
- /// <para>
- /// This class provides the code for common functionality, such
- /// as support for threshold filtering and support for general filters.
- /// </para>
- /// <para>
- /// Appenders can also implement the <see cref="IOptionHandler"/> interface. Therefore
- /// they would require that the <see cref="M:IOptionHandler.ActivateOptions()"/> method
- /// be called after the appenders properties have been configured.
- /// </para>
- /// </remarks>
- /// <author>Nicko Cadell</author>
- /// <author>Gert Driesen</author>
- public abstract class AppenderSkeleton : IAppender, IBulkAppender, IOptionHandler, IFlushable
- {
- #region Protected Instance Constructors
- /// <summary>
- /// Default constructor
- /// </summary>
- /// <remarks>
- /// <para>Empty default constructor</para>
- /// </remarks>
- protected AppenderSkeleton()
- {
- m_errorHandler = new OnlyOnceErrorHandler(this.GetType().Name);
- }
- #endregion Protected Instance Constructors
- #region Finalizer
- /// <summary>
- /// Finalizes this appender by calling the implementation's
- /// <see cref="Close"/> method.
- /// </summary>
- /// <remarks>
- /// <para>
- /// If this appender has not been closed then the <c>Finalize</c> method
- /// will call <see cref="Close"/>.
- /// </para>
- /// </remarks>
- ~AppenderSkeleton()
- {
- // An appender might be closed then garbage collected.
- // There is no point in closing twice.
- if (!m_closed)
- {
- LogLog.Debug(declaringType, "Finalizing appender named ["+m_name+"].");
- Close();
- }
- }
- #endregion Finalizer
- #region Public Instance Properties
- /// <summary>
- /// Gets or sets the threshold <see cref="Level"/> of this appender.
- /// </summary>
- /// <value>
- /// The threshold <see cref="Level"/> of the appender.
- /// </value>
- /// <remarks>
- /// <para>
- /// All log events with lower level than the threshold level are ignored
- /// by the appender.
- /// </para>
- /// <para>
- /// In configuration files this option is specified by setting the
- /// value of the <see cref="Threshold"/> option to a level
- /// string, such as "DEBUG", "INFO" and so on.
- /// </para>
- /// </remarks>
- public Level Threshold
- {
- get { return m_threshold; }
- set { m_threshold = value; }
- }
- /// <summary>
- /// Gets or sets the <see cref="IErrorHandler"/> for this appender.
- /// </summary>
- /// <value>The <see cref="IErrorHandler"/> of the appender</value>
- /// <remarks>
- /// <para>
- /// The <see cref="AppenderSkeleton"/> provides a default
- /// implementation for the <see cref="ErrorHandler"/> property.
- /// </para>
- /// </remarks>
- virtual public IErrorHandler ErrorHandler
- {
- get { return this.m_errorHandler; }
- set
- {
- lock(this)
- {
- if (value == null)
- {
- // We do not throw exception here since the cause is probably a
- // bad config file.
- LogLog.Warn(declaringType, "You have tried to set a null error-handler.");
- }
- else
- {
- m_errorHandler = value;
- }
- }
- }
- }
- /// <summary>
- /// The filter chain.
- /// </summary>
- /// <value>The head of the filter chain filter chain.</value>
- /// <remarks>
- /// <para>
- /// Returns the head Filter. The Filters are organized in a linked list
- /// and so all Filters on this Appender are available through the result.
- /// </para>
- /// </remarks>
- virtual public IFilter FilterHead
- {
- get { return m_headFilter; }
- }
- /// <summary>
- /// Gets or sets the <see cref="ILayout"/> for this appender.
- /// </summary>
- /// <value>The layout of the appender.</value>
- /// <remarks>
- /// <para>
- /// See <see cref="RequiresLayout"/> for more information.
- /// </para>
- /// </remarks>
- /// <seealso cref="RequiresLayout"/>
- virtual public ILayout Layout
- {
- get { return m_layout; }
- set { m_layout = value; }
- }
- #endregion
- #region Implementation of IOptionHandler
- /// <summary>
- /// Initialize the appender based on the options set
- /// </summary>
- /// <remarks>
- /// <para>
- /// This is part of the <see cref="IOptionHandler"/> delayed object
- /// activation scheme. The <see cref="ActivateOptions"/> method must
- /// be called on this object after the configuration properties have
- /// been set. Until <see cref="ActivateOptions"/> is called this
- /// object is in an undefined state and must not be used.
- /// </para>
- /// <para>
- /// If any of the configuration properties are modified then
- /// <see cref="ActivateOptions"/> must be called again.
- /// </para>
- /// </remarks>
- virtual public void ActivateOptions()
- {
- }
- #endregion Implementation of IOptionHandler
- #region Implementation of IAppender
- /// <summary>
- /// Gets or sets the name of this appender.
- /// </summary>
- /// <value>The name of the appender.</value>
- /// <remarks>
- /// <para>
- /// The name uniquely identifies the appender.
- /// </para>
- /// </remarks>
- public string Name
- {
- get { return m_name; }
- set { m_name = value; }
- }
- /// <summary>
- /// Closes the appender and release resources.
- /// </summary>
- /// <remarks>
- /// <para>
- /// Release any resources allocated within the appender such as file handles,
- /// network connections, etc.
- /// </para>
- /// <para>
- /// It is a programming error to append to a closed appender.
- /// </para>
- /// <para>
- /// This method cannot be overridden by subclasses. This method
- /// delegates the closing of the appender to the <see cref="OnClose"/>
- /// method which must be overridden in the subclass.
- /// </para>
- /// </remarks>
- public void Close()
- {
- // This lock prevents the appender being closed while it is still appending
- lock(this)
- {
- if (!m_closed)
- {
- OnClose();
- m_closed = true;
- }
- }
- }
- /// <summary>
- /// Performs threshold checks and invokes filters before
- /// delegating actual logging to the subclasses specific
- /// <see cref="M:Append(LoggingEvent)"/> method.
- /// </summary>
- /// <param name="loggingEvent">The event to log.</param>
- /// <remarks>
- /// <para>
- /// This method cannot be overridden by derived classes. A
- /// derived class should override the <see cref="M:Append(LoggingEvent)"/> method
- /// which is called by this method.
- /// </para>
- /// <para>
- /// The implementation of this method is as follows:
- /// </para>
- /// <para>
- /// <list type="bullet">
- /// <item>
- /// <description>
- /// Checks that the severity of the <paramref name="loggingEvent"/>
- /// is greater than or equal to the <see cref="Threshold"/> of this
- /// appender.</description>
- /// </item>
- /// <item>
- /// <description>
- /// Checks that the <see cref="IFilter"/> chain accepts the
- /// <paramref name="loggingEvent"/>.
- /// </description>
- /// </item>
- /// <item>
- /// <description>
- /// Calls <see cref="M:PreAppendCheck()"/> and checks that
- /// it returns <c>true</c>.</description>
- /// </item>
- /// </list>
- /// </para>
- /// <para>
- /// If all of the above steps succeed then the <paramref name="loggingEvent"/>
- /// will be passed to the abstract <see cref="M:Append(LoggingEvent)"/> method.
- /// </para>
- /// </remarks>
- public void DoAppend(LoggingEvent loggingEvent)
- {
- // This lock is absolutely critical for correct formatting
- // of the message in a multi-threaded environment. Without
- // this, the message may be broken up into elements from
- // multiple thread contexts (like get the wrong thread ID).
- lock(this)
- {
- if (m_closed)
- {
- ErrorHandler.Error("Attempted to append to closed appender named ["+m_name+"].");
- return;
- }
- // prevent re-entry
- if (m_recursiveGuard)
- {
- return;
- }
- try
- {
- m_recursiveGuard = true;
- if (FilterEvent(loggingEvent) && PreAppendCheck())
- {
- this.Append(loggingEvent);
- }
- }
- catch(Exception ex)
- {
- ErrorHandler.Error("Failed in DoAppend", ex);
- }
- #if !MONO && !NET_2_0 && !NETSTANDARD1_3
- // on .NET 2.0 (and higher) and Mono (all profiles),
- // exceptions that do not derive from System.Exception will be
- // wrapped in a RuntimeWrappedException by the runtime, and as
- // such will be catched by the catch clause above
- catch
- {
- // Catch handler for non System.Exception types
- ErrorHandler.Error("Failed in DoAppend (unknown exception)");
- }
- #endif
- finally
- {
- m_recursiveGuard = false;
- }
- }
- }
- #endregion Implementation of IAppender
- #region Implementation of IBulkAppender
- /// <summary>
- /// Performs threshold checks and invokes filters before
- /// delegating actual logging to the subclasses specific
- /// <see cref="M:Append(LoggingEvent[])"/> method.
- /// </summary>
- /// <param name="loggingEvents">The array of events to log.</param>
- /// <remarks>
- /// <para>
- /// This method cannot be overridden by derived classes. A
- /// derived class should override the <see cref="M:Append(LoggingEvent[])"/> method
- /// which is called by this method.
- /// </para>
- /// <para>
- /// The implementation of this method is as follows:
- /// </para>
- /// <para>
- /// <list type="bullet">
- /// <item>
- /// <description>
- /// Checks that the severity of the <paramref name="loggingEvents"/>
- /// is greater than or equal to the <see cref="Threshold"/> of this
- /// appender.</description>
- /// </item>
- /// <item>
- /// <description>
- /// Checks that the <see cref="IFilter"/> chain accepts the
- /// <paramref name="loggingEvents"/>.
- /// </description>
- /// </item>
- /// <item>
- /// <description>
- /// Calls <see cref="M:PreAppendCheck()"/> and checks that
- /// it returns <c>true</c>.</description>
- /// </item>
- /// </list>
- /// </para>
- /// <para>
- /// If all of the above steps succeed then the <paramref name="loggingEvents"/>
- /// will be passed to the <see cref="M:Append(LoggingEvent[])"/> method.
- /// </para>
- /// </remarks>
- public void DoAppend(LoggingEvent[] loggingEvents)
- {
- // This lock is absolutely critical for correct formatting
- // of the message in a multi-threaded environment. Without
- // this, the message may be broken up into elements from
- // multiple thread contexts (like get the wrong thread ID).
- lock(this)
- {
- if (m_closed)
- {
- ErrorHandler.Error("Attempted to append to closed appender named ["+m_name+"].");
- return;
- }
- // prevent re-entry
- if (m_recursiveGuard)
- {
- return;
- }
- try
- {
- m_recursiveGuard = true;
- ArrayList filteredEvents = new ArrayList(loggingEvents.Length);
- foreach(LoggingEvent loggingEvent in loggingEvents)
- {
- if (FilterEvent(loggingEvent))
- {
- filteredEvents.Add(loggingEvent);
- }
- }
- if (filteredEvents.Count > 0 && PreAppendCheck())
- {
- this.Append((LoggingEvent[])filteredEvents.ToArray(typeof(LoggingEvent)));
- }
- }
- catch(Exception ex)
- {
- ErrorHandler.Error("Failed in Bulk DoAppend", ex);
- }
- #if !MONO && !NET_2_0 && !NETSTANDARD1_3
- // on .NET 2.0 (and higher) and Mono (all profiles),
- // exceptions that do not derive from System.Exception will be
- // wrapped in a RuntimeWrappedException by the runtime, and as
- // such will be catched by the catch clause above
- catch
- {
- // Catch handler for non System.Exception types
- ErrorHandler.Error("Failed in Bulk DoAppend (unknown exception)");
- }
- #endif
- finally
- {
- m_recursiveGuard = false;
- }
- }
- }
- #endregion Implementation of IBulkAppender
- /// <summary>
- /// Test if the logging event should we output by this appender
- /// </summary>
- /// <param name="loggingEvent">the event to test</param>
- /// <returns><c>true</c> if the event should be output, <c>false</c> if the event should be ignored</returns>
- /// <remarks>
- /// <para>
- /// This method checks the logging event against the threshold level set
- /// on this appender and also against the filters specified on this
- /// appender.
- /// </para>
- /// <para>
- /// The implementation of this method is as follows:
- /// </para>
- /// <para>
- /// <list type="bullet">
- /// <item>
- /// <description>
- /// Checks that the severity of the <paramref name="loggingEvent"/>
- /// is greater than or equal to the <see cref="Threshold"/> of this
- /// appender.</description>
- /// </item>
- /// <item>
- /// <description>
- /// Checks that the <see cref="IFilter"/> chain accepts the
- /// <paramref name="loggingEvent"/>.
- /// </description>
- /// </item>
- /// </list>
- /// </para>
- /// </remarks>
- virtual protected bool FilterEvent(LoggingEvent loggingEvent)
- {
- if (!IsAsSevereAsThreshold(loggingEvent.Level))
- {
- return false;
- }
- IFilter f = this.FilterHead;
- while(f != null)
- {
- switch(f.Decide(loggingEvent))
- {
- case FilterDecision.Deny:
- return false; // Return without appending
- case FilterDecision.Accept:
- f = null; // Break out of the loop
- break;
- case FilterDecision.Neutral:
- f = f.Next; // Move to next filter
- break;
- }
- }
- return true;
- }
- #region Public Instance Methods
- /// <summary>
- /// Adds a filter to the end of the filter chain.
- /// </summary>
- /// <param name="filter">the filter to add to this appender</param>
- /// <remarks>
- /// <para>
- /// The Filters are organized in a linked list.
- /// </para>
- /// <para>
- /// Setting this property causes the new filter to be pushed onto the
- /// back of the filter chain.
- /// </para>
- /// </remarks>
- virtual public void AddFilter(IFilter filter)
- {
- if (filter == null)
- {
- throw new ArgumentNullException("filter param must not be null");
- }
- if (m_headFilter == null)
- {
- m_headFilter = m_tailFilter = filter;
- }
- else
- {
- m_tailFilter.Next = filter;
- m_tailFilter = filter;
- }
- }
- /// <summary>
- /// Clears the filter list for this appender.
- /// </summary>
- /// <remarks>
- /// <para>
- /// Clears the filter list for this appender.
- /// </para>
- /// </remarks>
- virtual public void ClearFilters()
- {
- m_headFilter = m_tailFilter = null;
- }
- #endregion Public Instance Methods
- #region Protected Instance Methods
- /// <summary>
- /// Checks if the message level is below this appender's threshold.
- /// </summary>
- /// <param name="level"><see cref="Level"/> to test against.</param>
- /// <remarks>
- /// <para>
- /// If there is no threshold set, then the return value is always <c>true</c>.
- /// </para>
- /// </remarks>
- /// <returns>
- /// <c>true</c> if the <paramref name="level"/> meets the <see cref="Threshold"/>
- /// requirements of this appender.
- /// </returns>
- virtual protected bool IsAsSevereAsThreshold(Level level)
- {
- return ((m_threshold == null) || level >= m_threshold);
- }
- /// <summary>
- /// Is called when the appender is closed. Derived classes should override
- /// this method if resources need to be released.
- /// </summary>
- /// <remarks>
- /// <para>
- /// Releases any resources allocated within the appender such as file handles,
- /// network connections, etc.
- /// </para>
- /// <para>
- /// It is a programming error to append to a closed appender.
- /// </para>
- /// </remarks>
- virtual protected void OnClose()
- {
- // Do nothing by default
- }
- /// <summary>
- /// Subclasses of <see cref="AppenderSkeleton"/> should implement this method
- /// to perform actual logging.
- /// </summary>
- /// <param name="loggingEvent">The event to append.</param>
- /// <remarks>
- /// <para>
- /// A subclass must implement this method to perform
- /// logging of the <paramref name="loggingEvent"/>.
- /// </para>
- /// <para>This method will be called by <see cref="M:DoAppend(LoggingEvent)"/>
- /// if all the conditions listed for that method are met.
- /// </para>
- /// <para>
- /// To restrict the logging of events in the appender
- /// override the <see cref="M:PreAppendCheck()"/> method.
- /// </para>
- /// </remarks>
- abstract protected void Append(LoggingEvent loggingEvent);
- /// <summary>
- /// Append a bulk array of logging events.
- /// </summary>
- /// <param name="loggingEvents">the array of logging events</param>
- /// <remarks>
- /// <para>
- /// This base class implementation calls the <see cref="M:Append(LoggingEvent)"/>
- /// method for each element in the bulk array.
- /// </para>
- /// <para>
- /// A sub class that can better process a bulk array of events should
- /// override this method in addition to <see cref="M:Append(LoggingEvent)"/>.
- /// </para>
- /// </remarks>
- virtual protected void Append(LoggingEvent[] loggingEvents)
- {
- foreach(LoggingEvent loggingEvent in loggingEvents)
- {
- Append(loggingEvent);
- }
- }
- /// <summary>
- /// Called before <see cref="M:Append(LoggingEvent)"/> as a precondition.
- /// </summary>
- /// <remarks>
- /// <para>
- /// This method is called by <see cref="M:DoAppend(LoggingEvent)"/>
- /// before the call to the abstract <see cref="M:Append(LoggingEvent)"/> method.
- /// </para>
- /// <para>
- /// This method can be overridden in a subclass to extend the checks
- /// made before the event is passed to the <see cref="M:Append(LoggingEvent)"/> method.
- /// </para>
- /// <para>
- /// A subclass should ensure that they delegate this call to
- /// this base class if it is overridden.
- /// </para>
- /// </remarks>
- /// <returns><c>true</c> if the call to <see cref="M:Append(LoggingEvent)"/> should proceed.</returns>
- virtual protected bool PreAppendCheck()
- {
- if ((m_layout == null) && RequiresLayout)
- {
- ErrorHandler.Error("AppenderSkeleton: No layout set for the appender named ["+m_name+"].");
- return false;
- }
- return true;
- }
- /// <summary>
- /// Renders the <see cref="LoggingEvent"/> to a string.
- /// </summary>
- /// <param name="loggingEvent">The event to render.</param>
- /// <returns>The event rendered as a string.</returns>
- /// <remarks>
- /// <para>
- /// Helper method to render a <see cref="LoggingEvent"/> to
- /// a string. This appender must have a <see cref="Layout"/>
- /// set to render the <paramref name="loggingEvent"/> to
- /// a string.
- /// </para>
- /// <para>If there is exception data in the logging event and
- /// the layout does not process the exception, this method
- /// will append the exception text to the rendered string.
- /// </para>
- /// <para>
- /// Where possible use the alternative version of this method
- /// <see cref="M:RenderLoggingEvent(TextWriter,LoggingEvent)"/>.
- /// That method streams the rendering onto an existing Writer
- /// which can give better performance if the caller already has
- /// a <see cref="TextWriter"/> open and ready for writing.
- /// </para>
- /// </remarks>
- protected string RenderLoggingEvent(LoggingEvent loggingEvent)
- {
- // Create the render writer on first use
- if (m_renderWriter == null)
- {
- m_renderWriter = new ReusableStringWriter(System.Globalization.CultureInfo.InvariantCulture);
- }
- lock (m_renderWriter)
- {
- // Reset the writer so we can reuse it
- m_renderWriter.Reset(c_renderBufferMaxCapacity, c_renderBufferSize);
- RenderLoggingEvent(m_renderWriter, loggingEvent);
- return m_renderWriter.ToString();
- }
- }
- /// <summary>
- /// Renders the <see cref="LoggingEvent"/> to a string.
- /// </summary>
- /// <param name="loggingEvent">The event to render.</param>
- /// <param name="writer">The TextWriter to write the formatted event to</param>
- /// <remarks>
- /// <para>
- /// Helper method to render a <see cref="LoggingEvent"/> to
- /// a string. This appender must have a <see cref="Layout"/>
- /// set to render the <paramref name="loggingEvent"/> to
- /// a string.
- /// </para>
- /// <para>If there is exception data in the logging event and
- /// the layout does not process the exception, this method
- /// will append the exception text to the rendered string.
- /// </para>
- /// <para>
- /// Use this method in preference to <see cref="M:RenderLoggingEvent(LoggingEvent)"/>
- /// where possible. If, however, the caller needs to render the event
- /// to a string then <see cref="M:RenderLoggingEvent(LoggingEvent)"/> does
- /// provide an efficient mechanism for doing so.
- /// </para>
- /// </remarks>
- protected void RenderLoggingEvent(TextWriter writer, LoggingEvent loggingEvent)
- {
- if (m_layout == null)
- {
- throw new InvalidOperationException("A layout must be set");
- }
- if (m_layout.IgnoresException)
- {
- string exceptionStr = loggingEvent.GetExceptionString();
- if (exceptionStr != null && exceptionStr.Length > 0)
- {
- // render the event and the exception
- m_layout.Format(writer, loggingEvent);
- writer.WriteLine(exceptionStr);
- }
- else
- {
- // there is no exception to render
- m_layout.Format(writer, loggingEvent);
- }
- }
- else
- {
- // The layout will render the exception
- m_layout.Format(writer, loggingEvent);
- }
- }
- /// <summary>
- /// Tests if this appender requires a <see cref="Layout"/> to be set.
- /// </summary>
- /// <remarks>
- /// <para>
- /// In the rather exceptional case, where the appender
- /// implementation admits a layout but can also work without it,
- /// then the appender should return <c>true</c>.
- /// </para>
- /// <para>
- /// This default implementation always returns <c>false</c>.
- /// </para>
- /// </remarks>
- /// <returns>
- /// <c>true</c> if the appender requires a layout object, otherwise <c>false</c>.
- /// </returns>
- virtual protected bool RequiresLayout
- {
- get { return false; }
- }
- #endregion
- /// <summary>
- /// Flushes any buffered log data.
- /// </summary>
- /// <remarks>
- /// This implementation doesn't flush anything and always returns true
- /// </remarks>
- /// <returns><c>True</c> if all logging events were flushed successfully, else <c>false</c>.</returns>
- public virtual bool Flush(int millisecondsTimeout)
- {
- return true;
- }
- #region Private Instance Fields
- /// <summary>
- /// The layout of this appender.
- /// </summary>
- /// <remarks>
- /// See <see cref="Layout"/> for more information.
- /// </remarks>
- private ILayout m_layout;
- /// <summary>
- /// The name of this appender.
- /// </summary>
- /// <remarks>
- /// See <see cref="Name"/> for more information.
- /// </remarks>
- private string m_name;
- /// <summary>
- /// The level threshold of this appender.
- /// </summary>
- /// <remarks>
- /// <para>
- /// There is no level threshold filtering by default.
- /// </para>
- /// <para>
- /// See <see cref="Threshold"/> for more information.
- /// </para>
- /// </remarks>
- private Level m_threshold;
- /// <summary>
- /// It is assumed and enforced that errorHandler is never null.
- /// </summary>
- /// <remarks>
- /// <para>
- /// It is assumed and enforced that errorHandler is never null.
- /// </para>
- /// <para>
- /// See <see cref="ErrorHandler"/> for more information.
- /// </para>
- /// </remarks>
- private IErrorHandler m_errorHandler;
- /// <summary>
- /// The first filter in the filter chain.
- /// </summary>
- /// <remarks>
- /// <para>
- /// Set to <c>null</c> initially.
- /// </para>
- /// <para>
- /// See <see cref="IFilter"/> for more information.
- /// </para>
- /// </remarks>
- private IFilter m_headFilter;
- /// <summary>
- /// The last filter in the filter chain.
- /// </summary>
- /// <remarks>
- /// See <see cref="IFilter"/> for more information.
- /// </remarks>
- private IFilter m_tailFilter;
- /// <summary>
- /// Flag indicating if this appender is closed.
- /// </summary>
- /// <remarks>
- /// See <see cref="Close"/> for more information.
- /// </remarks>
- private bool m_closed = false;
- /// <summary>
- /// The guard prevents an appender from repeatedly calling its own DoAppend method
- /// </summary>
- private bool m_recursiveGuard = false;
- /// <summary>
- /// StringWriter used to render events
- /// </summary>
- private ReusableStringWriter m_renderWriter = null;
- #endregion Private Instance Fields
- #region Constants
- /// <summary>
- /// Initial buffer size
- /// </summary>
- private const int c_renderBufferSize = 256;
- /// <summary>
- /// Maximum buffer size before it is recycled
- /// </summary>
- private const int c_renderBufferMaxCapacity = 1024;
- #endregion
- #region Private Static Fields
- /// <summary>
- /// The fully qualified type of the AppenderSkeleton class.
- /// </summary>
- /// <remarks>
- /// Used by the internal logger to record the Type of the
- /// log message.
- /// </remarks>
- private readonly static Type declaringType = typeof(AppenderSkeleton);
- #endregion Private Static Fields
- }
- }
|