tabs to spaces #111
diff --git a/src/log4net/Appender/AdoNetAppender.cs b/src/log4net/Appender/AdoNetAppender.cs
index c4e3e35..cad90c5 100644
--- a/src/log4net/Appender/AdoNetAppender.cs
+++ b/src/log4net/Appender/AdoNetAppender.cs
@@ -37,1148 +37,1148 @@
namespace log4net.Appender
{
- /// <summary>
- /// Appender that logs to a database.
- /// </summary>
- /// <remarks>
- /// <para>
- /// <see cref="AdoNetAppender"/> appends logging events to a table within a
- /// database. The appender can be configured to specify the connection
- /// string by setting the <see cref="ConnectionString"/> property.
- /// The connection type (provider) can be specified by setting the <see cref="ConnectionType"/>
- /// property. For more information on database connection strings for
- /// your specific database see <a href="http://www.connectionstrings.com/">http://www.connectionstrings.com/</a>.
- /// </para>
- /// <para>
- /// Records are written into the database either using a prepared
- /// statement or a stored procedure. The <see cref="CommandType"/> property
- /// is set to <see cref="System.Data.CommandType.Text"/> (<c>System.Data.CommandType.Text</c>) to specify a prepared statement
- /// or to <see cref="System.Data.CommandType.StoredProcedure"/> (<c>System.Data.CommandType.StoredProcedure</c>) to specify a stored
- /// procedure.
- /// </para>
- /// <para>
- /// The prepared statement text or the name of the stored procedure
- /// must be set in the <see cref="CommandText"/> property.
- /// </para>
- /// <para>
- /// The prepared statement or stored procedure can take a number
- /// of parameters. Parameters are added using the <see cref="AddParameter"/>
- /// method. This adds a single <see cref="AdoNetAppenderParameter"/> to the
- /// ordered list of parameters. The <see cref="AdoNetAppenderParameter"/>
- /// type may be subclassed if required to provide database specific
- /// functionality. The <see cref="AdoNetAppenderParameter"/> specifies
- /// the parameter name, database type, size, and how the value should
- /// be generated using a <see cref="ILayout"/>.
- /// </para>
- /// </remarks>
- /// <example>
- /// An example of a SQL Server table that could be logged to:
- /// <code lang="SQL">
- /// CREATE TABLE [dbo].[Log] (
- /// [ID] [int] IDENTITY (1, 1) NOT NULL ,
- /// [Date] [datetime] NOT NULL ,
- /// [Thread] [varchar] (255) NOT NULL ,
- /// [Level] [varchar] (20) NOT NULL ,
- /// [Logger] [varchar] (255) NOT NULL ,
- /// [Message] [varchar] (4000) NOT NULL
- /// ) ON [PRIMARY]
- /// </code>
- /// </example>
- /// <example>
- /// An example configuration to log to the above table:
- /// <code lang="XML" escaped="true">
- /// <appender name="AdoNetAppender_SqlServer" type="log4net.Appender.AdoNetAppender" >
- /// <connectionType value="System.Data.SqlClient.SqlConnection, System.Data, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
- /// <connectionString value="data source=SQLSVR;initial catalog=test_log4net;integrated security=false;persist security info=True;" />
- /// <commandText value="INSERT INTO Log ([Date],[Thread],[Level],[Logger],[Message]) VALUES (@log_date, @thread, @log_level, @logger, @message)" />
- /// <parameter>
- /// <parameterName value="@log_date" />
- /// <dbType value="DateTime" />
- /// <layout type="log4net.Layout.PatternLayout" value="%date{yyyy'-'MM'-'dd HH':'mm':'ss'.'fff}" />
- /// </parameter>
- /// <parameter>
- /// <parameterName value="@thread" />
- /// <dbType value="String" />
- /// <size value="255" />
- /// <layout type="log4net.Layout.PatternLayout" value="%thread" />
- /// </parameter>
- /// <parameter>
- /// <parameterName value="@log_level" />
- /// <dbType value="String" />
- /// <size value="50" />
- /// <layout type="log4net.Layout.PatternLayout" value="%level" />
- /// </parameter>
- /// <parameter>
- /// <parameterName value="@logger" />
- /// <dbType value="String" />
- /// <size value="255" />
- /// <layout type="log4net.Layout.PatternLayout" value="%logger" />
- /// </parameter>
- /// <parameter>
- /// <parameterName value="@message" />
- /// <dbType value="String" />
- /// <size value="4000" />
- /// <layout type="log4net.Layout.PatternLayout" value="%message" />
- /// </parameter>
- /// </appender>
- /// </code>
- /// </example>
- /// <author>Julian Biddle</author>
- /// <author>Nicko Cadell</author>
- /// <author>Gert Driesen</author>
- /// <author>Lance Nehring</author>
- public class AdoNetAppender : BufferingAppenderSkeleton
- {
- #region Public Instance Constructors
+ /// <summary>
+ /// Appender that logs to a database.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// <see cref="AdoNetAppender"/> appends logging events to a table within a
+ /// database. The appender can be configured to specify the connection
+ /// string by setting the <see cref="ConnectionString"/> property.
+ /// The connection type (provider) can be specified by setting the <see cref="ConnectionType"/>
+ /// property. For more information on database connection strings for
+ /// your specific database see <a href="http://www.connectionstrings.com/">http://www.connectionstrings.com/</a>.
+ /// </para>
+ /// <para>
+ /// Records are written into the database either using a prepared
+ /// statement or a stored procedure. The <see cref="CommandType"/> property
+ /// is set to <see cref="System.Data.CommandType.Text"/> (<c>System.Data.CommandType.Text</c>) to specify a prepared statement
+ /// or to <see cref="System.Data.CommandType.StoredProcedure"/> (<c>System.Data.CommandType.StoredProcedure</c>) to specify a stored
+ /// procedure.
+ /// </para>
+ /// <para>
+ /// The prepared statement text or the name of the stored procedure
+ /// must be set in the <see cref="CommandText"/> property.
+ /// </para>
+ /// <para>
+ /// The prepared statement or stored procedure can take a number
+ /// of parameters. Parameters are added using the <see cref="AddParameter"/>
+ /// method. This adds a single <see cref="AdoNetAppenderParameter"/> to the
+ /// ordered list of parameters. The <see cref="AdoNetAppenderParameter"/>
+ /// type may be subclassed if required to provide database specific
+ /// functionality. The <see cref="AdoNetAppenderParameter"/> specifies
+ /// the parameter name, database type, size, and how the value should
+ /// be generated using a <see cref="ILayout"/>.
+ /// </para>
+ /// </remarks>
+ /// <example>
+ /// An example of a SQL Server table that could be logged to:
+ /// <code lang="SQL">
+ /// CREATE TABLE [dbo].[Log] (
+ /// [ID] [int] IDENTITY (1, 1) NOT NULL ,
+ /// [Date] [datetime] NOT NULL ,
+ /// [Thread] [varchar] (255) NOT NULL ,
+ /// [Level] [varchar] (20) NOT NULL ,
+ /// [Logger] [varchar] (255) NOT NULL ,
+ /// [Message] [varchar] (4000) NOT NULL
+ /// ) ON [PRIMARY]
+ /// </code>
+ /// </example>
+ /// <example>
+ /// An example configuration to log to the above table:
+ /// <code lang="XML" escaped="true">
+ /// <appender name="AdoNetAppender_SqlServer" type="log4net.Appender.AdoNetAppender" >
+ /// <connectionType value="System.Data.SqlClient.SqlConnection, System.Data, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
+ /// <connectionString value="data source=SQLSVR;initial catalog=test_log4net;integrated security=false;persist security info=True;" />
+ /// <commandText value="INSERT INTO Log ([Date],[Thread],[Level],[Logger],[Message]) VALUES (@log_date, @thread, @log_level, @logger, @message)" />
+ /// <parameter>
+ /// <parameterName value="@log_date" />
+ /// <dbType value="DateTime" />
+ /// <layout type="log4net.Layout.PatternLayout" value="%date{yyyy'-'MM'-'dd HH':'mm':'ss'.'fff}" />
+ /// </parameter>
+ /// <parameter>
+ /// <parameterName value="@thread" />
+ /// <dbType value="String" />
+ /// <size value="255" />
+ /// <layout type="log4net.Layout.PatternLayout" value="%thread" />
+ /// </parameter>
+ /// <parameter>
+ /// <parameterName value="@log_level" />
+ /// <dbType value="String" />
+ /// <size value="50" />
+ /// <layout type="log4net.Layout.PatternLayout" value="%level" />
+ /// </parameter>
+ /// <parameter>
+ /// <parameterName value="@logger" />
+ /// <dbType value="String" />
+ /// <size value="255" />
+ /// <layout type="log4net.Layout.PatternLayout" value="%logger" />
+ /// </parameter>
+ /// <parameter>
+ /// <parameterName value="@message" />
+ /// <dbType value="String" />
+ /// <size value="4000" />
+ /// <layout type="log4net.Layout.PatternLayout" value="%message" />
+ /// </parameter>
+ /// </appender>
+ /// </code>
+ /// </example>
+ /// <author>Julian Biddle</author>
+ /// <author>Nicko Cadell</author>
+ /// <author>Gert Driesen</author>
+ /// <author>Lance Nehring</author>
+ public class AdoNetAppender : BufferingAppenderSkeleton
+ {
+ #region Public Instance Constructors
- /// <summary>
- /// Initializes a new instance of the <see cref="AdoNetAppender" /> class.
- /// </summary>
- /// <remarks>
- /// Public default constructor to initialize a new instance of this class.
- /// </remarks>
- public AdoNetAppender()
- {
- ConnectionType = "System.Data.OleDb.OleDbConnection, System.Data, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089";
- UseTransactions = true;
- CommandType = System.Data.CommandType.Text;
- m_parameters = new ArrayList();
- ReconnectOnError = false;
- }
+ /// <summary>
+ /// Initializes a new instance of the <see cref="AdoNetAppender" /> class.
+ /// </summary>
+ /// <remarks>
+ /// Public default constructor to initialize a new instance of this class.
+ /// </remarks>
+ public AdoNetAppender()
+ {
+ ConnectionType = "System.Data.OleDb.OleDbConnection, System.Data, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089";
+ UseTransactions = true;
+ CommandType = System.Data.CommandType.Text;
+ m_parameters = new ArrayList();
+ ReconnectOnError = false;
+ }
- #endregion // Public Instance Constructors
+ #endregion // Public Instance Constructors
- #region Public Instance Properties
+ #region Public Instance Properties
- /// <summary>
- /// Gets or sets the database connection string that is used to connect to
- /// the database.
- /// </summary>
- /// <value>
- /// The database connection string used to connect to the database.
- /// </value>
- /// <remarks>
- /// <para>
- /// The connections string is specific to the connection type.
- /// See <see cref="ConnectionType"/> for more information.
- /// </para>
- /// </remarks>
- /// <example>Connection string for MS Access via ODBC:
- /// <code>"DSN=MS Access Database;UID=admin;PWD=;SystemDB=C:\data\System.mdw;SafeTransactions = 0;FIL=MS Access;DriverID = 25;DBQ=C:\data\train33.mdb"</code>
- /// </example>
- /// <example>Another connection string for MS Access via ODBC:
- /// <code>"Driver={Microsoft Access Driver (*.mdb)};DBQ=C:\Work\cvs_root\log4net-1.2\access.mdb;UID=;PWD=;"</code>
- /// </example>
- /// <example>Connection string for MS Access via OLE DB:
- /// <code>"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Work\cvs_root\log4net-1.2\access.mdb;User Id=;Password=;"</code>
- /// </example>
- public string ConnectionString
- {
- get { return m_connectionString; }
- set { m_connectionString = value; }
- }
+ /// <summary>
+ /// Gets or sets the database connection string that is used to connect to
+ /// the database.
+ /// </summary>
+ /// <value>
+ /// The database connection string used to connect to the database.
+ /// </value>
+ /// <remarks>
+ /// <para>
+ /// The connections string is specific to the connection type.
+ /// See <see cref="ConnectionType"/> for more information.
+ /// </para>
+ /// </remarks>
+ /// <example>Connection string for MS Access via ODBC:
+ /// <code>"DSN=MS Access Database;UID=admin;PWD=;SystemDB=C:\data\System.mdw;SafeTransactions = 0;FIL=MS Access;DriverID = 25;DBQ=C:\data\train33.mdb"</code>
+ /// </example>
+ /// <example>Another connection string for MS Access via ODBC:
+ /// <code>"Driver={Microsoft Access Driver (*.mdb)};DBQ=C:\Work\cvs_root\log4net-1.2\access.mdb;UID=;PWD=;"</code>
+ /// </example>
+ /// <example>Connection string for MS Access via OLE DB:
+ /// <code>"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Work\cvs_root\log4net-1.2\access.mdb;User Id=;Password=;"</code>
+ /// </example>
+ public string ConnectionString
+ {
+ get { return m_connectionString; }
+ set { m_connectionString = value; }
+ }
- /// <summary>
- /// The appSettings key from App.Config that contains the connection string.
- /// </summary>
- public string AppSettingsKey
- {
- get { return m_appSettingsKey; }
- set { m_appSettingsKey = value; }
- }
+ /// <summary>
+ /// The appSettings key from App.Config that contains the connection string.
+ /// </summary>
+ public string AppSettingsKey
+ {
+ get { return m_appSettingsKey; }
+ set { m_appSettingsKey = value; }
+ }
- /// <summary>
- /// The connectionStrings key from App.Config that contains the connection string.
- /// </summary>
- /// <remarks>
- /// This property requires at least .NET 2.0.
- /// </remarks>
- public string ConnectionStringName
- {
- get { return m_connectionStringName; }
- set { m_connectionStringName = value; }
- }
+ /// <summary>
+ /// The connectionStrings key from App.Config that contains the connection string.
+ /// </summary>
+ /// <remarks>
+ /// This property requires at least .NET 2.0.
+ /// </remarks>
+ public string ConnectionStringName
+ {
+ get { return m_connectionStringName; }
+ set { m_connectionStringName = value; }
+ }
- /// <summary>
- /// Gets or sets the type name of the <see cref="IDbConnection"/> connection
- /// that should be created.
- /// </summary>
- /// <value>
- /// The type name of the <see cref="IDbConnection"/> connection.
- /// </value>
- /// <remarks>
- /// <para>
- /// The type name of the ADO.NET provider to use.
- /// </para>
- /// <para>
- /// The default is to use the OLE DB provider.
- /// </para>
- /// </remarks>
- /// <example>Use the OLE DB Provider. This is the default value.
- /// <code>System.Data.OleDb.OleDbConnection, System.Data, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</code>
- /// </example>
- /// <example>Use the MS SQL Server Provider.
- /// <code>System.Data.SqlClient.SqlConnection, System.Data, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</code>
- /// </example>
- /// <example>Use the ODBC Provider.
- /// <code>Microsoft.Data.Odbc.OdbcConnection,Microsoft.Data.Odbc,version=1.0.3300.0,publicKeyToken=b77a5c561934e089,culture=neutral</code>
- /// This is an optional package that you can download from
- /// <a href="http://msdn.microsoft.com/downloads">http://msdn.microsoft.com/downloads</a>
- /// search for <b>ODBC .NET Data Provider</b>.
- /// </example>
- /// <example>Use the Oracle Provider.
- /// <code>System.Data.OracleClient.OracleConnection, System.Data.OracleClient, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</code>
- /// This is an optional package that you can download from
- /// <a href="http://msdn.microsoft.com/downloads">http://msdn.microsoft.com/downloads</a>
- /// search for <b>.NET Managed Provider for Oracle</b>.
- /// </example>
- public string ConnectionType
- {
- get { return m_connectionType; }
- set { m_connectionType = value; }
- }
+ /// <summary>
+ /// Gets or sets the type name of the <see cref="IDbConnection"/> connection
+ /// that should be created.
+ /// </summary>
+ /// <value>
+ /// The type name of the <see cref="IDbConnection"/> connection.
+ /// </value>
+ /// <remarks>
+ /// <para>
+ /// The type name of the ADO.NET provider to use.
+ /// </para>
+ /// <para>
+ /// The default is to use the OLE DB provider.
+ /// </para>
+ /// </remarks>
+ /// <example>Use the OLE DB Provider. This is the default value.
+ /// <code>System.Data.OleDb.OleDbConnection, System.Data, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</code>
+ /// </example>
+ /// <example>Use the MS SQL Server Provider.
+ /// <code>System.Data.SqlClient.SqlConnection, System.Data, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</code>
+ /// </example>
+ /// <example>Use the ODBC Provider.
+ /// <code>Microsoft.Data.Odbc.OdbcConnection,Microsoft.Data.Odbc,version=1.0.3300.0,publicKeyToken=b77a5c561934e089,culture=neutral</code>
+ /// This is an optional package that you can download from
+ /// <a href="http://msdn.microsoft.com/downloads">http://msdn.microsoft.com/downloads</a>
+ /// search for <b>ODBC .NET Data Provider</b>.
+ /// </example>
+ /// <example>Use the Oracle Provider.
+ /// <code>System.Data.OracleClient.OracleConnection, System.Data.OracleClient, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</code>
+ /// This is an optional package that you can download from
+ /// <a href="http://msdn.microsoft.com/downloads">http://msdn.microsoft.com/downloads</a>
+ /// search for <b>.NET Managed Provider for Oracle</b>.
+ /// </example>
+ public string ConnectionType
+ {
+ get { return m_connectionType; }
+ set { m_connectionType = value; }
+ }
- /// <summary>
- /// Gets or sets the command text that is used to insert logging events
- /// into the database.
- /// </summary>
- /// <value>
- /// The command text used to insert logging events into the database.
- /// </value>
- /// <remarks>
- /// <para>
- /// Either the text of the prepared statement or the
- /// name of the stored procedure to execute to write into
- /// the database.
- /// </para>
- /// <para>
- /// The <see cref="CommandType"/> property determines if
- /// this text is a prepared statement or a stored procedure.
- /// </para>
- /// <para>
- /// If this property is not set, the command text is retrieved by invoking
- /// <see cref="GetLogStatement(LoggingEvent)"/>.
- /// </para>
- /// </remarks>
- public string CommandText
- {
- get { return m_commandText; }
- set { m_commandText = value; }
- }
+ /// <summary>
+ /// Gets or sets the command text that is used to insert logging events
+ /// into the database.
+ /// </summary>
+ /// <value>
+ /// The command text used to insert logging events into the database.
+ /// </value>
+ /// <remarks>
+ /// <para>
+ /// Either the text of the prepared statement or the
+ /// name of the stored procedure to execute to write into
+ /// the database.
+ /// </para>
+ /// <para>
+ /// The <see cref="CommandType"/> property determines if
+ /// this text is a prepared statement or a stored procedure.
+ /// </para>
+ /// <para>
+ /// If this property is not set, the command text is retrieved by invoking
+ /// <see cref="GetLogStatement(LoggingEvent)"/>.
+ /// </para>
+ /// </remarks>
+ public string CommandText
+ {
+ get { return m_commandText; }
+ set { m_commandText = value; }
+ }
- /// <summary>
- /// Gets or sets the command type to execute.
- /// </summary>
- /// <value>
- /// The command type to execute.
- /// </value>
- /// <remarks>
- /// <para>
- /// This value may be either <see cref="System.Data.CommandType.Text"/> (<c>System.Data.CommandType.Text</c>) to specify
- /// that the <see cref="CommandText"/> is a prepared statement to execute,
- /// or <see cref="System.Data.CommandType.StoredProcedure"/> (<c>System.Data.CommandType.StoredProcedure</c>) to specify that the
- /// <see cref="CommandText"/> property is the name of a stored procedure
- /// to execute.
- /// </para>
- /// <para>
- /// The default value is <see cref="System.Data.CommandType.Text"/> (<c>System.Data.CommandType.Text</c>).
- /// </para>
- /// </remarks>
- public CommandType CommandType
- {
- get { return m_commandType; }
- set { m_commandType = value; }
- }
+ /// <summary>
+ /// Gets or sets the command type to execute.
+ /// </summary>
+ /// <value>
+ /// The command type to execute.
+ /// </value>
+ /// <remarks>
+ /// <para>
+ /// This value may be either <see cref="System.Data.CommandType.Text"/> (<c>System.Data.CommandType.Text</c>) to specify
+ /// that the <see cref="CommandText"/> is a prepared statement to execute,
+ /// or <see cref="System.Data.CommandType.StoredProcedure"/> (<c>System.Data.CommandType.StoredProcedure</c>) to specify that the
+ /// <see cref="CommandText"/> property is the name of a stored procedure
+ /// to execute.
+ /// </para>
+ /// <para>
+ /// The default value is <see cref="System.Data.CommandType.Text"/> (<c>System.Data.CommandType.Text</c>).
+ /// </para>
+ /// </remarks>
+ public CommandType CommandType
+ {
+ get { return m_commandType; }
+ set { m_commandType = value; }
+ }
- /// <summary>
- /// Should transactions be used to insert logging events in the database.
- /// </summary>
- /// <value>
- /// <c>true</c> if transactions should be used to insert logging events in
- /// the database, otherwise <c>false</c>. The default value is <c>true</c>.
- /// </value>
- /// <remarks>
- /// <para>
- /// Gets or sets a value that indicates whether transactions should be used
- /// to insert logging events in the database.
- /// </para>
- /// <para>
- /// When set a single transaction will be used to insert the buffered events
- /// into the database. Otherwise each event will be inserted without using
- /// an explicit transaction.
- /// </para>
- /// </remarks>
- public bool UseTransactions
- {
- get { return m_useTransactions; }
- set { m_useTransactions = value; }
- }
+ /// <summary>
+ /// Should transactions be used to insert logging events in the database.
+ /// </summary>
+ /// <value>
+ /// <c>true</c> if transactions should be used to insert logging events in
+ /// the database, otherwise <c>false</c>. The default value is <c>true</c>.
+ /// </value>
+ /// <remarks>
+ /// <para>
+ /// Gets or sets a value that indicates whether transactions should be used
+ /// to insert logging events in the database.
+ /// </para>
+ /// <para>
+ /// When set a single transaction will be used to insert the buffered events
+ /// into the database. Otherwise each event will be inserted without using
+ /// an explicit transaction.
+ /// </para>
+ /// </remarks>
+ public bool UseTransactions
+ {
+ get { return m_useTransactions; }
+ set { m_useTransactions = value; }
+ }
- /// <summary>
- /// Gets or sets the <see cref="SecurityContext"/> used to call the NetSend method.
- /// </summary>
- /// <value>
- /// The <see cref="SecurityContext"/> used to call the NetSend method.
- /// </value>
- /// <remarks>
- /// <para>
- /// Unless a <see cref="SecurityContext"/> specified here for this appender
- /// the <see cref="SecurityContextProvider.DefaultProvider"/> is queried for the
- /// security context to use. The default behavior is to use the security context
- /// of the current thread.
- /// </para>
- /// </remarks>
- public SecurityContext SecurityContext
- {
- get { return m_securityContext; }
- set { m_securityContext = value; }
- }
+ /// <summary>
+ /// Gets or sets the <see cref="SecurityContext"/> used to call the NetSend method.
+ /// </summary>
+ /// <value>
+ /// The <see cref="SecurityContext"/> used to call the NetSend method.
+ /// </value>
+ /// <remarks>
+ /// <para>
+ /// Unless a <see cref="SecurityContext"/> specified here for this appender
+ /// the <see cref="SecurityContextProvider.DefaultProvider"/> is queried for the
+ /// security context to use. The default behavior is to use the security context
+ /// of the current thread.
+ /// </para>
+ /// </remarks>
+ public SecurityContext SecurityContext
+ {
+ get { return m_securityContext; }
+ set { m_securityContext = value; }
+ }
- /// <summary>
- /// Should this appender try to reconnect to the database on error.
- /// </summary>
- /// <value>
- /// <c>true</c> if the appender should try to reconnect to the database after an
- /// error has occurred, otherwise <c>false</c>. The default value is <c>false</c>,
- /// i.e. not to try to reconnect.
- /// </value>
- /// <remarks>
- /// <para>
- /// The default behaviour is for the appender not to try to reconnect to the
- /// database if an error occurs. Subsequent logging events are discarded.
- /// </para>
- /// <para>
- /// To force the appender to attempt to reconnect to the database set this
- /// property to <c>true</c>.
- /// </para>
- /// <note>
- /// When the appender attempts to connect to the database there may be a
- /// delay of up to the connection timeout specified in the connection string.
- /// This delay will block the calling application's thread.
- /// Until the connection can be reestablished this potential delay may occur multiple times.
- /// </note>
- /// </remarks>
- public bool ReconnectOnError
- {
- get { return m_reconnectOnError; }
- set { m_reconnectOnError = value; }
- }
+ /// <summary>
+ /// Should this appender try to reconnect to the database on error.
+ /// </summary>
+ /// <value>
+ /// <c>true</c> if the appender should try to reconnect to the database after an
+ /// error has occurred, otherwise <c>false</c>. The default value is <c>false</c>,
+ /// i.e. not to try to reconnect.
+ /// </value>
+ /// <remarks>
+ /// <para>
+ /// The default behaviour is for the appender not to try to reconnect to the
+ /// database if an error occurs. Subsequent logging events are discarded.
+ /// </para>
+ /// <para>
+ /// To force the appender to attempt to reconnect to the database set this
+ /// property to <c>true</c>.
+ /// </para>
+ /// <note>
+ /// When the appender attempts to connect to the database there may be a
+ /// delay of up to the connection timeout specified in the connection string.
+ /// This delay will block the calling application's thread.
+ /// Until the connection can be reestablished this potential delay may occur multiple times.
+ /// </note>
+ /// </remarks>
+ public bool ReconnectOnError
+ {
+ get { return m_reconnectOnError; }
+ set { m_reconnectOnError = value; }
+ }
- #endregion // Public Instance Properties
+ #endregion // Public Instance Properties
- #region Protected Instance Properties
+ #region Protected Instance Properties
- /// <summary>
- /// Gets or sets the underlying <see cref="IDbConnection" />.
- /// </summary>
- /// <value>
- /// The underlying <see cref="IDbConnection" />.
- /// </value>
- /// <remarks>
- /// <see cref="AdoNetAppender" /> creates a <see cref="IDbConnection" /> to insert
- /// logging events into a database. Classes deriving from <see cref="AdoNetAppender" />
- /// can use this property to get or set this <see cref="IDbConnection" />. Use the
- /// underlying <see cref="IDbConnection" /> returned from <see cref="Connection" /> if
- /// you require access beyond that which <see cref="AdoNetAppender" /> provides.
- /// </remarks>
- protected IDbConnection Connection
- {
- get { return m_dbConnection; }
- set { m_dbConnection = value; }
- }
+ /// <summary>
+ /// Gets or sets the underlying <see cref="IDbConnection" />.
+ /// </summary>
+ /// <value>
+ /// The underlying <see cref="IDbConnection" />.
+ /// </value>
+ /// <remarks>
+ /// <see cref="AdoNetAppender" /> creates a <see cref="IDbConnection" /> to insert
+ /// logging events into a database. Classes deriving from <see cref="AdoNetAppender" />
+ /// can use this property to get or set this <see cref="IDbConnection" />. Use the
+ /// underlying <see cref="IDbConnection" /> returned from <see cref="Connection" /> if
+ /// you require access beyond that which <see cref="AdoNetAppender" /> provides.
+ /// </remarks>
+ protected IDbConnection Connection
+ {
+ get { return m_dbConnection; }
+ set { m_dbConnection = value; }
+ }
- #endregion // Protected Instance Properties
+ #endregion // Protected Instance Properties
- #region Implementation of IOptionHandler
+ #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>
- public override void ActivateOptions()
- {
- base.ActivateOptions();
+ /// <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>
+ public override void ActivateOptions()
+ {
+ base.ActivateOptions();
- if (SecurityContext == null)
- {
- SecurityContext = SecurityContextProvider.DefaultProvider.CreateSecurityContext(this);
- }
+ if (SecurityContext == null)
+ {
+ SecurityContext = SecurityContextProvider.DefaultProvider.CreateSecurityContext(this);
+ }
- InitializeDatabaseConnection();
- }
+ InitializeDatabaseConnection();
+ }
- #endregion
+ #endregion
- #region Override implementation of AppenderSkeleton
+ #region Override implementation of AppenderSkeleton
- /// <summary>
- /// Override the parent method to close the database
- /// </summary>
- /// <remarks>
- /// <para>
- /// Closes the database command and database connection.
- /// </para>
- /// </remarks>
- protected override void OnClose()
- {
- base.OnClose();
- DiposeConnection();
- }
+ /// <summary>
+ /// Override the parent method to close the database
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Closes the database command and database connection.
+ /// </para>
+ /// </remarks>
+ protected override void OnClose()
+ {
+ base.OnClose();
+ DiposeConnection();
+ }
- #endregion
+ #endregion
- #region Override implementation of BufferingAppenderSkeleton
+ #region Override implementation of BufferingAppenderSkeleton
- /// <summary>
- /// Inserts the events into the database.
- /// </summary>
- /// <param name="events">The events to insert into the database.</param>
- /// <remarks>
- /// <para>
- /// Insert all the events specified in the <paramref name="events"/>
- /// array into the database.
- /// </para>
- /// </remarks>
- protected override void SendBuffer(LoggingEvent[] events)
- {
- if (ReconnectOnError && (Connection == null || Connection.State != ConnectionState.Open))
- {
- LogLog.Debug(declaringType, "Attempting to reconnect to database. Current Connection State: " + ((Connection == null) ? SystemInfo.NullText : Connection.State.ToString()));
+ /// <summary>
+ /// Inserts the events into the database.
+ /// </summary>
+ /// <param name="events">The events to insert into the database.</param>
+ /// <remarks>
+ /// <para>
+ /// Insert all the events specified in the <paramref name="events"/>
+ /// array into the database.
+ /// </para>
+ /// </remarks>
+ protected override void SendBuffer(LoggingEvent[] events)
+ {
+ if (ReconnectOnError && (Connection == null || Connection.State != ConnectionState.Open))
+ {
+ LogLog.Debug(declaringType, "Attempting to reconnect to database. Current Connection State: " + ((Connection == null) ? SystemInfo.NullText : Connection.State.ToString()));
- InitializeDatabaseConnection();
- }
+ InitializeDatabaseConnection();
+ }
- // Check that the connection exists and is open
- if (Connection != null && Connection.State == ConnectionState.Open)
- {
- if (UseTransactions)
- {
- // Create transaction
- // NJC - Do this on 2 lines because it can confuse the debugger
- using (IDbTransaction dbTran = Connection.BeginTransaction())
- {
- try
- {
- SendBuffer(dbTran, events);
+ // Check that the connection exists and is open
+ if (Connection != null && Connection.State == ConnectionState.Open)
+ {
+ if (UseTransactions)
+ {
+ // Create transaction
+ // NJC - Do this on 2 lines because it can confuse the debugger
+ using (IDbTransaction dbTran = Connection.BeginTransaction())
+ {
+ try
+ {
+ SendBuffer(dbTran, events);
- // commit transaction
- dbTran.Commit();
- }
- catch (Exception ex)
- {
- // rollback the transaction
- try
- {
- dbTran.Rollback();
- }
- catch (Exception)
- {
- // Ignore exception
- }
+ // commit transaction
+ dbTran.Commit();
+ }
+ catch (Exception ex)
+ {
+ // rollback the transaction
+ try
+ {
+ dbTran.Rollback();
+ }
+ catch (Exception)
+ {
+ // Ignore exception
+ }
- // Can't insert into the database. That's a bad thing
- ErrorHandler.Error("Exception while writing to database", ex);
- }
- }
- }
- else
- {
- // Send without transaction
- SendBuffer(null, events);
- }
- }
- }
+ // Can't insert into the database. That's a bad thing
+ ErrorHandler.Error("Exception while writing to database", ex);
+ }
+ }
+ }
+ else
+ {
+ // Send without transaction
+ SendBuffer(null, events);
+ }
+ }
+ }
- #endregion // Override implementation of BufferingAppenderSkeleton
+ #endregion // Override implementation of BufferingAppenderSkeleton
- #region Public Instance Methods
+ #region Public Instance Methods
- /// <summary>
- /// Adds a parameter to the command.
- /// </summary>
- /// <param name="parameter">The parameter to add to the command.</param>
- /// <remarks>
- /// <para>
- /// Adds a parameter to the ordered list of command parameters.
- /// </para>
- /// </remarks>
- public void AddParameter(AdoNetAppenderParameter parameter)
- {
- m_parameters.Add(parameter);
- }
+ /// <summary>
+ /// Adds a parameter to the command.
+ /// </summary>
+ /// <param name="parameter">The parameter to add to the command.</param>
+ /// <remarks>
+ /// <para>
+ /// Adds a parameter to the ordered list of command parameters.
+ /// </para>
+ /// </remarks>
+ public void AddParameter(AdoNetAppenderParameter parameter)
+ {
+ m_parameters.Add(parameter);
+ }
- #endregion // Public Instance Methods
+ #endregion // Public Instance Methods
- #region Protected Instance Methods
+ #region Protected Instance Methods
- /// <summary>
- /// Writes the events to the database using the transaction specified.
- /// </summary>
- /// <param name="dbTran">The transaction that the events will be executed under.</param>
- /// <param name="events">The array of events to insert into the database.</param>
- /// <remarks>
- /// <para>
- /// The transaction argument can be <c>null</c> if the appender has been
- /// configured not to use transactions. See <see cref="UseTransactions"/>
- /// property for more information.
- /// </para>
- /// </remarks>
- protected virtual void SendBuffer(IDbTransaction dbTran, LoggingEvent[] events)
- {
- // string.IsNotNullOrWhiteSpace() does not exist in ancient .NET frameworks
- if (CommandText != null && CommandText.Trim() != "")
- {
- using (IDbCommand dbCmd = Connection.CreateCommand())
- {
- // Set the command string
- dbCmd.CommandText = CommandText;
+ /// <summary>
+ /// Writes the events to the database using the transaction specified.
+ /// </summary>
+ /// <param name="dbTran">The transaction that the events will be executed under.</param>
+ /// <param name="events">The array of events to insert into the database.</param>
+ /// <remarks>
+ /// <para>
+ /// The transaction argument can be <c>null</c> if the appender has been
+ /// configured not to use transactions. See <see cref="UseTransactions"/>
+ /// property for more information.
+ /// </para>
+ /// </remarks>
+ protected virtual void SendBuffer(IDbTransaction dbTran, LoggingEvent[] events)
+ {
+ // string.IsNotNullOrWhiteSpace() does not exist in ancient .NET frameworks
+ if (CommandText != null && CommandText.Trim() != "")
+ {
+ using (IDbCommand dbCmd = Connection.CreateCommand())
+ {
+ // Set the command string
+ dbCmd.CommandText = CommandText;
- // Set the command type
- dbCmd.CommandType = CommandType;
- // Send buffer using the prepared command object
- if (dbTran != null)
- {
- dbCmd.Transaction = dbTran;
- }
+ // Set the command type
+ dbCmd.CommandType = CommandType;
+ // Send buffer using the prepared command object
+ if (dbTran != null)
+ {
+ dbCmd.Transaction = dbTran;
+ }
- try
- {
- // prepare the command, which is significantly faster
- Prepare(dbCmd);
- }
- catch (Exception)
- {
- if (dbTran != null)
- {
- // rethrow exception in transaction mode, cuz now transaction is in failed state
- throw;
- }
+ try
+ {
+ // prepare the command, which is significantly faster
+ Prepare(dbCmd);
+ }
+ catch (Exception)
+ {
+ if (dbTran != null)
+ {
+ // rethrow exception in transaction mode, cuz now transaction is in failed state
+ throw;
+ }
- // ignore prepare exceptions as they can happen without affecting actual logging, eg on npgsql
- }
+ // ignore prepare exceptions as they can happen without affecting actual logging, eg on npgsql
+ }
- // run for all events
- foreach (LoggingEvent e in events)
- {
- // No need to clear dbCmd.Parameters, just use existing.
- // Set the parameter values
- foreach (AdoNetAppenderParameter param in m_parameters)
- {
- param.FormatValue(dbCmd, e);
- }
+ // run for all events
+ foreach (LoggingEvent e in events)
+ {
+ // No need to clear dbCmd.Parameters, just use existing.
+ // Set the parameter values
+ foreach (AdoNetAppenderParameter param in m_parameters)
+ {
+ param.FormatValue(dbCmd, e);
+ }
- // Execute the query
- dbCmd.ExecuteNonQuery();
- }
- }
- }
- else
- {
- // create a new command
- using (IDbCommand dbCmd = Connection.CreateCommand())
- {
- if (dbTran != null)
- {
- dbCmd.Transaction = dbTran;
- }
- // run for all events
- foreach (LoggingEvent e in events)
- {
- // Get the command text from the Layout
- string logStatement = GetLogStatement(e);
+ // Execute the query
+ dbCmd.ExecuteNonQuery();
+ }
+ }
+ }
+ else
+ {
+ // create a new command
+ using (IDbCommand dbCmd = Connection.CreateCommand())
+ {
+ if (dbTran != null)
+ {
+ dbCmd.Transaction = dbTran;
+ }
+ // run for all events
+ foreach (LoggingEvent e in events)
+ {
+ // Get the command text from the Layout
+ string logStatement = GetLogStatement(e);
- LogLog.Debug(declaringType, "LogStatement [" + logStatement + "]");
+ LogLog.Debug(declaringType, "LogStatement [" + logStatement + "]");
- dbCmd.CommandText = logStatement;
- dbCmd.ExecuteNonQuery();
- }
- }
- }
- }
+ dbCmd.CommandText = logStatement;
+ dbCmd.ExecuteNonQuery();
+ }
+ }
+ }
+ }
- /// <summary>
- /// Prepare entire database command object to be executed.
- /// </summary>
- /// <param name="dbCmd">The command to prepare.</param>
- protected virtual void Prepare(IDbCommand dbCmd)
- {
- // npgsql require parameters to prepare command
- foreach (AdoNetAppenderParameter parameter in m_parameters)
- {
- parameter.Prepare(dbCmd);
- }
+ /// <summary>
+ /// Prepare entire database command object to be executed.
+ /// </summary>
+ /// <param name="dbCmd">The command to prepare.</param>
+ protected virtual void Prepare(IDbCommand dbCmd)
+ {
+ // npgsql require parameters to prepare command
+ foreach (AdoNetAppenderParameter parameter in m_parameters)
+ {
+ parameter.Prepare(dbCmd);
+ }
- dbCmd.Prepare();
- }
+ dbCmd.Prepare();
+ }
- /// <summary>
- /// Formats the log message into database statement text.
- /// </summary>
- /// <param name="logEvent">The event being logged.</param>
- /// <remarks>
- /// This method can be overridden by subclasses to provide
- /// more control over the format of the database statement.
- /// </remarks>
- /// <returns>
- /// Text that can be passed to a <see cref="System.Data.IDbCommand"/>.
- /// </returns>
- protected virtual string GetLogStatement(LoggingEvent logEvent)
- {
- if (Layout == null)
- {
- ErrorHandler.Error("AdoNetAppender: No Layout specified.");
- return "";
- }
- else
- {
- using StringWriter writer = new StringWriter(System.Globalization.CultureInfo.InvariantCulture);
- Layout.Format(writer, logEvent);
- return writer.ToString();
- }
- }
+ /// <summary>
+ /// Formats the log message into database statement text.
+ /// </summary>
+ /// <param name="logEvent">The event being logged.</param>
+ /// <remarks>
+ /// This method can be overridden by subclasses to provide
+ /// more control over the format of the database statement.
+ /// </remarks>
+ /// <returns>
+ /// Text that can be passed to a <see cref="System.Data.IDbCommand"/>.
+ /// </returns>
+ protected virtual string GetLogStatement(LoggingEvent logEvent)
+ {
+ if (Layout == null)
+ {
+ ErrorHandler.Error("AdoNetAppender: No Layout specified.");
+ return "";
+ }
+ else
+ {
+ using StringWriter writer = new StringWriter(System.Globalization.CultureInfo.InvariantCulture);
+ Layout.Format(writer, logEvent);
+ return writer.ToString();
+ }
+ }
- /// <summary>
- /// Creates an <see cref="IDbConnection"/> instance used to connect to the database.
- /// </summary>
- /// <remarks>
- /// This method is called whenever a new IDbConnection is needed (i.e. when a reconnect is necessary).
- /// </remarks>
- /// <param name="connectionType">The <see cref="Type"/> of the <see cref="IDbConnection"/> object.</param>
- /// <param name="connectionString">The connectionString output from the ResolveConnectionString method.</param>
- /// <returns>An <see cref="IDbConnection"/> instance with a valid connection string.</returns>
- protected virtual IDbConnection CreateConnection(Type connectionType, string connectionString)
- {
- IDbConnection connection = (IDbConnection)Activator.CreateInstance(connectionType);
- connection.ConnectionString = connectionString;
- return connection;
- }
+ /// <summary>
+ /// Creates an <see cref="IDbConnection"/> instance used to connect to the database.
+ /// </summary>
+ /// <remarks>
+ /// This method is called whenever a new IDbConnection is needed (i.e. when a reconnect is necessary).
+ /// </remarks>
+ /// <param name="connectionType">The <see cref="Type"/> of the <see cref="IDbConnection"/> object.</param>
+ /// <param name="connectionString">The connectionString output from the ResolveConnectionString method.</param>
+ /// <returns>An <see cref="IDbConnection"/> instance with a valid connection string.</returns>
+ protected virtual IDbConnection CreateConnection(Type connectionType, string connectionString)
+ {
+ IDbConnection connection = (IDbConnection)Activator.CreateInstance(connectionType);
+ connection.ConnectionString = connectionString;
+ return connection;
+ }
- /// <summary>
- /// Resolves the connection string from the ConnectionString, ConnectionStringName, or AppSettingsKey
- /// property.
- /// </summary>
- /// <remarks>
- /// ConnectiongStringName is only supported on .NET 2.0 and higher.
- /// </remarks>
- /// <param name="connectionStringContext">Additional information describing the connection string.</param>
- /// <returns>A connection string used to connect to the database.</returns>
- protected virtual string ResolveConnectionString(out string connectionStringContext)
- {
- if (ConnectionString != null && ConnectionString.Length > 0)
- {
- connectionStringContext = "ConnectionString";
- return ConnectionString;
- }
+ /// <summary>
+ /// Resolves the connection string from the ConnectionString, ConnectionStringName, or AppSettingsKey
+ /// property.
+ /// </summary>
+ /// <remarks>
+ /// ConnectiongStringName is only supported on .NET 2.0 and higher.
+ /// </remarks>
+ /// <param name="connectionStringContext">Additional information describing the connection string.</param>
+ /// <returns>A connection string used to connect to the database.</returns>
+ protected virtual string ResolveConnectionString(out string connectionStringContext)
+ {
+ if (ConnectionString != null && ConnectionString.Length > 0)
+ {
+ connectionStringContext = "ConnectionString";
+ return ConnectionString;
+ }
#if !NETSTANDARD1_3
- if (!String.IsNullOrEmpty(ConnectionStringName))
- {
- ConnectionStringSettings settings = ConfigurationManager.ConnectionStrings[ConnectionStringName];
- if (settings != null)
- {
- connectionStringContext = "ConnectionStringName";
- return settings.ConnectionString;
- }
- else
- {
- throw new LogException("Unable to find [" + ConnectionStringName + "] ConfigurationManager.ConnectionStrings item");
- }
- }
+ if (!String.IsNullOrEmpty(ConnectionStringName))
+ {
+ ConnectionStringSettings settings = ConfigurationManager.ConnectionStrings[ConnectionStringName];
+ if (settings != null)
+ {
+ connectionStringContext = "ConnectionStringName";
+ return settings.ConnectionString;
+ }
+ else
+ {
+ throw new LogException("Unable to find [" + ConnectionStringName + "] ConfigurationManager.ConnectionStrings item");
+ }
+ }
#endif
- if (AppSettingsKey != null && AppSettingsKey.Length > 0)
- {
- connectionStringContext = "AppSettingsKey";
- string appSettingsConnectionString = SystemInfo.GetAppSetting(AppSettingsKey);
- if (appSettingsConnectionString == null || appSettingsConnectionString.Length == 0)
- {
- throw new LogException("Unable to find [" + AppSettingsKey + "] AppSettings key.");
- }
- return appSettingsConnectionString;
- }
+ if (AppSettingsKey != null && AppSettingsKey.Length > 0)
+ {
+ connectionStringContext = "AppSettingsKey";
+ string appSettingsConnectionString = SystemInfo.GetAppSetting(AppSettingsKey);
+ if (appSettingsConnectionString == null || appSettingsConnectionString.Length == 0)
+ {
+ throw new LogException("Unable to find [" + AppSettingsKey + "] AppSettings key.");
+ }
+ return appSettingsConnectionString;
+ }
- connectionStringContext = "Unable to resolve connection string from ConnectionString, ConnectionStrings, or AppSettings.";
- return string.Empty;
- }
+ connectionStringContext = "Unable to resolve connection string from ConnectionString, ConnectionStrings, or AppSettings.";
+ return string.Empty;
+ }
- /// <summary>
- /// Retrieves the class type of the ADO.NET provider.
- /// </summary>
- /// <remarks>
- /// <para>
- /// Gets the Type of the ADO.NET provider to use to connect to the
- /// database. This method resolves the type specified in the
- /// <see cref="ConnectionType"/> property.
- /// </para>
- /// <para>
- /// Subclasses can override this method to return a different type
- /// if necessary.
- /// </para>
- /// </remarks>
- /// <returns>The <see cref="Type"/> of the ADO.NET provider</returns>
- protected virtual Type ResolveConnectionType()
- {
- try
- {
+ /// <summary>
+ /// Retrieves the class type of the ADO.NET provider.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Gets the Type of the ADO.NET provider to use to connect to the
+ /// database. This method resolves the type specified in the
+ /// <see cref="ConnectionType"/> property.
+ /// </para>
+ /// <para>
+ /// Subclasses can override this method to return a different type
+ /// if necessary.
+ /// </para>
+ /// </remarks>
+ /// <returns>The <see cref="Type"/> of the ADO.NET provider</returns>
+ protected virtual Type ResolveConnectionType()
+ {
+ try
+ {
#if NETSTANDARD1_3
- // NETSTANDARD1_3 requires comma separated ConnectionType like `System.Data.SqlClient.SqlConnection, System.Data` to work properly.
- return SystemInfo.GetTypeFromString((Assembly)null, ConnectionType, true, false);
+ // NETSTANDARD1_3 requires comma separated ConnectionType like `System.Data.SqlClient.SqlConnection, System.Data` to work properly.
+ return SystemInfo.GetTypeFromString((Assembly)null, ConnectionType, true, false);
#else
- return SystemInfo.GetTypeFromString(ConnectionType, true, false);
+ return SystemInfo.GetTypeFromString(ConnectionType, true, false);
#endif
- }
- catch (Exception ex)
- {
- ErrorHandler.Error("Failed to load connection type [" + ConnectionType + "]", ex);
- throw;
- }
- }
+ }
+ catch (Exception ex)
+ {
+ ErrorHandler.Error("Failed to load connection type [" + ConnectionType + "]", ex);
+ throw;
+ }
+ }
- #endregion // Protected Instance Methods
+ #endregion // Protected Instance Methods
- #region Private Instance Methods
+ #region Private Instance Methods
- /// <summary>
- /// Connects to the database.
- /// </summary>
- private void InitializeDatabaseConnection()
- {
- string connectionStringContext = "Unable to determine connection string context.";
- string resolvedConnectionString = string.Empty;
+ /// <summary>
+ /// Connects to the database.
+ /// </summary>
+ private void InitializeDatabaseConnection()
+ {
+ string connectionStringContext = "Unable to determine connection string context.";
+ string resolvedConnectionString = string.Empty;
- try
- {
- DiposeConnection();
+ try
+ {
+ DiposeConnection();
- // Set the connection string
- resolvedConnectionString = ResolveConnectionString(out connectionStringContext);
+ // Set the connection string
+ resolvedConnectionString = ResolveConnectionString(out connectionStringContext);
- Connection = CreateConnection(ResolveConnectionType(), resolvedConnectionString);
+ Connection = CreateConnection(ResolveConnectionType(), resolvedConnectionString);
- using (SecurityContext.Impersonate(this))
- {
- // Open the database connection
- Connection.Open();
- }
- }
- catch (Exception e)
- {
- // Sadly, your connection string is bad.
- ErrorHandler.Error("Could not open database connection [" + resolvedConnectionString + "]. Connection string context [" + connectionStringContext + "].", e);
+ using (SecurityContext.Impersonate(this))
+ {
+ // Open the database connection
+ Connection.Open();
+ }
+ }
+ catch (Exception e)
+ {
+ // Sadly, your connection string is bad.
+ ErrorHandler.Error("Could not open database connection [" + resolvedConnectionString + "]. Connection string context [" + connectionStringContext + "].", e);
- Connection = null;
- }
- }
+ Connection = null;
+ }
+ }
- /// <summary>
- /// Cleanup the existing connection.
- /// </summary>
- /// <remarks>
- /// Calls the IDbConnection's <see cref="IDbConnection.Close"/> method.
- /// </remarks>
- private void DiposeConnection()
- {
- if (Connection != null)
- {
- try
- {
- Connection.Close();
- }
- catch (Exception ex)
- {
- LogLog.Warn(declaringType, "Exception while disposing cached connection object", ex);
- }
- Connection = null;
- }
- }
+ /// <summary>
+ /// Cleanup the existing connection.
+ /// </summary>
+ /// <remarks>
+ /// Calls the IDbConnection's <see cref="IDbConnection.Close"/> method.
+ /// </remarks>
+ private void DiposeConnection()
+ {
+ if (Connection != null)
+ {
+ try
+ {
+ Connection.Close();
+ }
+ catch (Exception ex)
+ {
+ LogLog.Warn(declaringType, "Exception while disposing cached connection object", ex);
+ }
+ Connection = null;
+ }
+ }
- #endregion // Private Instance Methods
+ #endregion // Private Instance Methods
- #region Protected Instance Fields
+ #region Protected Instance Fields
- /// <summary>
- /// The list of <see cref="AdoNetAppenderParameter"/> objects.
- /// </summary>
- /// <remarks>
- /// <para>
- /// The list of <see cref="AdoNetAppenderParameter"/> objects.
- /// </para>
- /// </remarks>
- protected ArrayList m_parameters;
+ /// <summary>
+ /// The list of <see cref="AdoNetAppenderParameter"/> objects.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// The list of <see cref="AdoNetAppenderParameter"/> objects.
+ /// </para>
+ /// </remarks>
+ protected ArrayList m_parameters;
- #endregion // Protected Instance Fields
+ #endregion // Protected Instance Fields
- #region Private Instance Fields
+ #region Private Instance Fields
- /// <summary>
- /// The security context to use for privileged calls
- /// </summary>
- private SecurityContext m_securityContext;
+ /// <summary>
+ /// The security context to use for privileged calls
+ /// </summary>
+ private SecurityContext m_securityContext;
- /// <summary>
- /// The <see cref="IDbConnection" /> that will be used
- /// to insert logging events into a database.
- /// </summary>
- private IDbConnection m_dbConnection;
+ /// <summary>
+ /// The <see cref="IDbConnection" /> that will be used
+ /// to insert logging events into a database.
+ /// </summary>
+ private IDbConnection m_dbConnection;
- /// <summary>
- /// Database connection string.
- /// </summary>
- private string m_connectionString;
+ /// <summary>
+ /// Database connection string.
+ /// </summary>
+ private string m_connectionString;
- /// <summary>
- /// The appSettings key from App.Config that contains the connection string.
- /// </summary>
- private string m_appSettingsKey;
+ /// <summary>
+ /// The appSettings key from App.Config that contains the connection string.
+ /// </summary>
+ private string m_appSettingsKey;
- /// <summary>
- /// The connectionStrings key from App.Config that contains the connection string.
- /// </summary>
- private string m_connectionStringName;
+ /// <summary>
+ /// The connectionStrings key from App.Config that contains the connection string.
+ /// </summary>
+ private string m_connectionStringName;
- /// <summary>
- /// String type name of the <see cref="IDbConnection"/> type name.
- /// </summary>
- private string m_connectionType;
+ /// <summary>
+ /// String type name of the <see cref="IDbConnection"/> type name.
+ /// </summary>
+ private string m_connectionType;
- /// <summary>
- /// The text of the command.
- /// </summary>
- private string m_commandText;
+ /// <summary>
+ /// The text of the command.
+ /// </summary>
+ private string m_commandText;
- /// <summary>
- /// The command type.
- /// </summary>
- private CommandType m_commandType;
+ /// <summary>
+ /// The command type.
+ /// </summary>
+ private CommandType m_commandType;
- /// <summary>
- /// Indicates whether to use transactions when writing to the database.
- /// </summary>
- private bool m_useTransactions;
+ /// <summary>
+ /// Indicates whether to use transactions when writing to the database.
+ /// </summary>
+ private bool m_useTransactions;
- /// <summary>
- /// Indicates whether to reconnect when a connection is lost.
- /// </summary>
- private bool m_reconnectOnError;
+ /// <summary>
+ /// Indicates whether to reconnect when a connection is lost.
+ /// </summary>
+ private bool m_reconnectOnError;
- #endregion // Private Instance Fields
+ #endregion // Private Instance Fields
- #region Private Static Fields
+ #region Private Static Fields
- /// <summary>
- /// The fully qualified type of the AdoNetAppender class.
- /// </summary>
- /// <remarks>
- /// Used by the internal logger to record the Type of the
- /// log message.
- /// </remarks>
- private static readonly Type declaringType = typeof(AdoNetAppender);
+ /// <summary>
+ /// The fully qualified type of the AdoNetAppender class.
+ /// </summary>
+ /// <remarks>
+ /// Used by the internal logger to record the Type of the
+ /// log message.
+ /// </remarks>
+ private static readonly Type declaringType = typeof(AdoNetAppender);
- #endregion Private Static Fields
- }
+ #endregion Private Static Fields
+ }
- /// <summary>
- /// Parameter type used by the <see cref="AdoNetAppender"/>.
- /// </summary>
- /// <remarks>
- /// <para>
- /// This class provides the basic database parameter properties
- /// as defined by the <see cref="System.Data.IDbDataParameter"/> interface.
- /// </para>
- /// <para>This type can be subclassed to provide database specific
- /// functionality. The two methods that are called externally are
- /// <see cref="Prepare"/> and <see cref="FormatValue"/>.
- /// </para>
- /// </remarks>
- public class AdoNetAppenderParameter
- {
- #region Public Instance Constructors
+ /// <summary>
+ /// Parameter type used by the <see cref="AdoNetAppender"/>.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// This class provides the basic database parameter properties
+ /// as defined by the <see cref="System.Data.IDbDataParameter"/> interface.
+ /// </para>
+ /// <para>This type can be subclassed to provide database specific
+ /// functionality. The two methods that are called externally are
+ /// <see cref="Prepare"/> and <see cref="FormatValue"/>.
+ /// </para>
+ /// </remarks>
+ public class AdoNetAppenderParameter
+ {
+ #region Public Instance Constructors
- /// <summary>
- /// Initializes a new instance of the <see cref="AdoNetAppenderParameter" /> class.
- /// </summary>
- /// <remarks>
- /// Default constructor for the AdoNetAppenderParameter class.
- /// </remarks>
- public AdoNetAppenderParameter()
- {
- Precision = 0;
- Scale = 0;
- Size = 0;
- }
+ /// <summary>
+ /// Initializes a new instance of the <see cref="AdoNetAppenderParameter" /> class.
+ /// </summary>
+ /// <remarks>
+ /// Default constructor for the AdoNetAppenderParameter class.
+ /// </remarks>
+ public AdoNetAppenderParameter()
+ {
+ Precision = 0;
+ Scale = 0;
+ Size = 0;
+ }
- #endregion // Public Instance Constructors
+ #endregion // Public Instance Constructors
- #region Public Instance Properties
+ #region Public Instance Properties
- /// <summary>
- /// Gets or sets the name of this parameter.
- /// </summary>
- /// <value>
- /// The name of this parameter.
- /// </value>
- /// <remarks>
- /// <para>
- /// The name of this parameter. The parameter name
- /// must match up to a named parameter to the SQL stored procedure
- /// or prepared statement.
- /// </para>
- /// </remarks>
- public string ParameterName
- {
- get { return m_parameterName; }
- set { m_parameterName = value; }
- }
+ /// <summary>
+ /// Gets or sets the name of this parameter.
+ /// </summary>
+ /// <value>
+ /// The name of this parameter.
+ /// </value>
+ /// <remarks>
+ /// <para>
+ /// The name of this parameter. The parameter name
+ /// must match up to a named parameter to the SQL stored procedure
+ /// or prepared statement.
+ /// </para>
+ /// </remarks>
+ public string ParameterName
+ {
+ get { return m_parameterName; }
+ set { m_parameterName = value; }
+ }
- /// <summary>
- /// Gets or sets the database type for this parameter.
- /// </summary>
- /// <value>
- /// The database type for this parameter.
- /// </value>
- /// <remarks>
- /// <para>
- /// The database type for this parameter. This property should
- /// be set to the database type from the <see cref="DbType"/>
- /// enumeration. See <see cref="IDataParameter.DbType"/>.
- /// </para>
- /// <para>
- /// This property is optional. If not specified the ADO.NET provider
- /// will attempt to infer the type from the value.
- /// </para>
- /// </remarks>
- /// <seealso cref="IDataParameter.DbType" />
- public DbType DbType
- {
- get { return m_dbType; }
- set
- {
- m_dbType = value;
- m_inferType = false;
- }
- }
+ /// <summary>
+ /// Gets or sets the database type for this parameter.
+ /// </summary>
+ /// <value>
+ /// The database type for this parameter.
+ /// </value>
+ /// <remarks>
+ /// <para>
+ /// The database type for this parameter. This property should
+ /// be set to the database type from the <see cref="DbType"/>
+ /// enumeration. See <see cref="IDataParameter.DbType"/>.
+ /// </para>
+ /// <para>
+ /// This property is optional. If not specified the ADO.NET provider
+ /// will attempt to infer the type from the value.
+ /// </para>
+ /// </remarks>
+ /// <seealso cref="IDataParameter.DbType" />
+ public DbType DbType
+ {
+ get { return m_dbType; }
+ set
+ {
+ m_dbType = value;
+ m_inferType = false;
+ }
+ }
- /// <summary>
- /// Gets or sets the precision for this parameter.
- /// </summary>
- /// <value>
- /// The precision for this parameter.
- /// </value>
- /// <remarks>
- /// <para>
- /// The maximum number of digits used to represent the Value.
- /// </para>
- /// <para>
- /// This property is optional. If not specified the ADO.NET provider
- /// will attempt to infer the precision from the value.
- /// </para>
- /// </remarks>
- /// <seealso cref="IDbDataParameter.Precision" />
- public byte Precision
- {
- get { return m_precision; }
- set { m_precision = value; }
- }
+ /// <summary>
+ /// Gets or sets the precision for this parameter.
+ /// </summary>
+ /// <value>
+ /// The precision for this parameter.
+ /// </value>
+ /// <remarks>
+ /// <para>
+ /// The maximum number of digits used to represent the Value.
+ /// </para>
+ /// <para>
+ /// This property is optional. If not specified the ADO.NET provider
+ /// will attempt to infer the precision from the value.
+ /// </para>
+ /// </remarks>
+ /// <seealso cref="IDbDataParameter.Precision" />
+ public byte Precision
+ {
+ get { return m_precision; }
+ set { m_precision = value; }
+ }
- /// <summary>
- /// Gets or sets the scale for this parameter.
- /// </summary>
- /// <value>
- /// The scale for this parameter.
- /// </value>
- /// <remarks>
- /// <para>
- /// The number of decimal places to which Value is resolved.
- /// </para>
- /// <para>
- /// This property is optional. If not specified the ADO.NET provider
- /// will attempt to infer the scale from the value.
- /// </para>
- /// </remarks>
- /// <seealso cref="IDbDataParameter.Scale" />
- public byte Scale
- {
- get { return m_scale; }
- set { m_scale = value; }
- }
+ /// <summary>
+ /// Gets or sets the scale for this parameter.
+ /// </summary>
+ /// <value>
+ /// The scale for this parameter.
+ /// </value>
+ /// <remarks>
+ /// <para>
+ /// The number of decimal places to which Value is resolved.
+ /// </para>
+ /// <para>
+ /// This property is optional. If not specified the ADO.NET provider
+ /// will attempt to infer the scale from the value.
+ /// </para>
+ /// </remarks>
+ /// <seealso cref="IDbDataParameter.Scale" />
+ public byte Scale
+ {
+ get { return m_scale; }
+ set { m_scale = value; }
+ }
- /// <summary>
- /// Gets or sets the size for this parameter.
- /// </summary>
- /// <value>
- /// The size for this parameter.
- /// </value>
- /// <remarks>
- /// <para>
- /// The maximum size, in bytes, of the data within the column.
- /// </para>
- /// <para>
- /// This property is optional. If not specified the ADO.NET provider
- /// will attempt to infer the size from the value.
- /// </para>
- /// <para>
- /// For BLOB data types like VARCHAR(max) it may be impossible to infer the value automatically, use -1 as the size in this case.
- /// </para>
- /// </remarks>
- /// <seealso cref="IDbDataParameter.Size" />
- public int Size
- {
- get { return m_size; }
- set { m_size = value; }
- }
+ /// <summary>
+ /// Gets or sets the size for this parameter.
+ /// </summary>
+ /// <value>
+ /// The size for this parameter.
+ /// </value>
+ /// <remarks>
+ /// <para>
+ /// The maximum size, in bytes, of the data within the column.
+ /// </para>
+ /// <para>
+ /// This property is optional. If not specified the ADO.NET provider
+ /// will attempt to infer the size from the value.
+ /// </para>
+ /// <para>
+ /// For BLOB data types like VARCHAR(max) it may be impossible to infer the value automatically, use -1 as the size in this case.
+ /// </para>
+ /// </remarks>
+ /// <seealso cref="IDbDataParameter.Size" />
+ public int Size
+ {
+ get { return m_size; }
+ set { m_size = value; }
+ }
- /// <summary>
- /// Gets or sets the <see cref="IRawLayout"/> to use to
- /// render the logging event into an object for this
- /// parameter.
- /// </summary>
- /// <value>
- /// The <see cref="IRawLayout"/> used to render the
- /// logging event into an object for this parameter.
- /// </value>
- /// <remarks>
- /// <para>
- /// The <see cref="IRawLayout"/> that renders the value for this
- /// parameter.
- /// </para>
- /// <para>
- /// The <see cref="RawLayoutConverter"/> can be used to adapt
- /// any <see cref="ILayout"/> into a <see cref="IRawLayout"/>
- /// for use in the property.
- /// </para>
- /// </remarks>
- public IRawLayout Layout
- {
- get { return m_layout; }
- set { m_layout = value; }
- }
+ /// <summary>
+ /// Gets or sets the <see cref="IRawLayout"/> to use to
+ /// render the logging event into an object for this
+ /// parameter.
+ /// </summary>
+ /// <value>
+ /// The <see cref="IRawLayout"/> used to render the
+ /// logging event into an object for this parameter.
+ /// </value>
+ /// <remarks>
+ /// <para>
+ /// The <see cref="IRawLayout"/> that renders the value for this
+ /// parameter.
+ /// </para>
+ /// <para>
+ /// The <see cref="RawLayoutConverter"/> can be used to adapt
+ /// any <see cref="ILayout"/> into a <see cref="IRawLayout"/>
+ /// for use in the property.
+ /// </para>
+ /// </remarks>
+ public IRawLayout Layout
+ {
+ get { return m_layout; }
+ set { m_layout = value; }
+ }
- #endregion // Public Instance Properties
+ #endregion // Public Instance Properties
- #region Public Instance Methods
+ #region Public Instance Methods
- /// <summary>
- /// Prepare the specified database command object.
- /// </summary>
- /// <param name="command">The command to prepare.</param>
- /// <remarks>
- /// <para>
- /// Prepares the database command object by adding
- /// this parameter to its collection of parameters.
- /// </para>
- /// </remarks>
- public virtual void Prepare(IDbCommand command)
- {
- // Create a new parameter
- IDbDataParameter param = command.CreateParameter();
+ /// <summary>
+ /// Prepare the specified database command object.
+ /// </summary>
+ /// <param name="command">The command to prepare.</param>
+ /// <remarks>
+ /// <para>
+ /// Prepares the database command object by adding
+ /// this parameter to its collection of parameters.
+ /// </para>
+ /// </remarks>
+ public virtual void Prepare(IDbCommand command)
+ {
+ // Create a new parameter
+ IDbDataParameter param = command.CreateParameter();
- // Set the parameter properties
- param.ParameterName = ParameterName;
+ // Set the parameter properties
+ param.ParameterName = ParameterName;
- if (!m_inferType)
- {
- param.DbType = DbType;
- }
- if (Precision != 0)
- {
- param.Precision = Precision;
- }
- if (Scale != 0)
- {
- param.Scale = Scale;
- }
- if (Size != 0)
- {
- param.Size = Size;
- }
+ if (!m_inferType)
+ {
+ param.DbType = DbType;
+ }
+ if (Precision != 0)
+ {
+ param.Precision = Precision;
+ }
+ if (Scale != 0)
+ {
+ param.Scale = Scale;
+ }
+ if (Size != 0)
+ {
+ param.Size = Size;
+ }
- // Add the parameter to the collection of params
- command.Parameters.Add(param);
- }
+ // Add the parameter to the collection of params
+ command.Parameters.Add(param);
+ }
- /// <summary>
- /// Renders the logging event and set the parameter value in the command.
- /// </summary>
- /// <param name="command">The command containing the parameter.</param>
- /// <param name="loggingEvent">The event to be rendered.</param>
- /// <remarks>
- /// <para>
- /// Renders the logging event using this parameters layout
- /// object. Sets the value of the parameter on the command object.
- /// </para>
- /// </remarks>
- public virtual void FormatValue(IDbCommand command, LoggingEvent loggingEvent)
- {
- // Lookup the parameter
- IDbDataParameter param = (IDbDataParameter)command.Parameters[ParameterName];
+ /// <summary>
+ /// Renders the logging event and set the parameter value in the command.
+ /// </summary>
+ /// <param name="command">The command containing the parameter.</param>
+ /// <param name="loggingEvent">The event to be rendered.</param>
+ /// <remarks>
+ /// <para>
+ /// Renders the logging event using this parameters layout
+ /// object. Sets the value of the parameter on the command object.
+ /// </para>
+ /// </remarks>
+ public virtual void FormatValue(IDbCommand command, LoggingEvent loggingEvent)
+ {
+ // Lookup the parameter
+ IDbDataParameter param = (IDbDataParameter)command.Parameters[ParameterName];
- // Format the value
- object formattedValue = Layout.Format(loggingEvent);
+ // Format the value
+ object formattedValue = Layout.Format(loggingEvent);
- // If the value is null then convert to a DBNull
- if (formattedValue == null)
- {
- formattedValue = DBNull.Value;
- }
+ // If the value is null then convert to a DBNull
+ if (formattedValue == null)
+ {
+ formattedValue = DBNull.Value;
+ }
- param.Value = formattedValue;
- }
+ param.Value = formattedValue;
+ }
- #endregion // Public Instance Methods
+ #endregion // Public Instance Methods
- #region Private Instance Fields
+ #region Private Instance Fields
- /// <summary>
- /// The name of this parameter.
- /// </summary>
- private string m_parameterName;
+ /// <summary>
+ /// The name of this parameter.
+ /// </summary>
+ private string m_parameterName;
- /// <summary>
- /// The database type for this parameter.
- /// </summary>
- private DbType m_dbType;
+ /// <summary>
+ /// The database type for this parameter.
+ /// </summary>
+ private DbType m_dbType;
- /// <summary>
- /// Flag to infer type rather than use the DbType
- /// </summary>
- private bool m_inferType = true;
+ /// <summary>
+ /// Flag to infer type rather than use the DbType
+ /// </summary>
+ private bool m_inferType = true;
- /// <summary>
- /// The precision for this parameter.
- /// </summary>
- private byte m_precision;
+ /// <summary>
+ /// The precision for this parameter.
+ /// </summary>
+ private byte m_precision;
- /// <summary>
- /// The scale for this parameter.
- /// </summary>
- private byte m_scale;
+ /// <summary>
+ /// The scale for this parameter.
+ /// </summary>
+ private byte m_scale;
- /// <summary>
- /// The size for this parameter.
- /// </summary>
- private int m_size;
+ /// <summary>
+ /// The size for this parameter.
+ /// </summary>
+ private int m_size;
- /// <summary>
- /// The <see cref="IRawLayout"/> to use to render the
- /// logging event into an object for this parameter.
- /// </summary>
- private IRawLayout m_layout;
+ /// <summary>
+ /// The <see cref="IRawLayout"/> to use to render the
+ /// logging event into an object for this parameter.
+ /// </summary>
+ private IRawLayout m_layout;
- #endregion // Private Instance Fields
- }
+ #endregion // Private Instance Fields
+ }
}
#endif // !SSCLI
\ No newline at end of file
diff --git a/src/log4net/Appender/AnsiColorTerminalAppender.cs b/src/log4net/Appender/AnsiColorTerminalAppender.cs
index 50a6875..1331833 100644
--- a/src/log4net/Appender/AnsiColorTerminalAppender.cs
+++ b/src/log4net/Appender/AnsiColorTerminalAppender.cs
@@ -27,548 +27,548 @@
namespace log4net.Appender
{
- /// <summary>
- /// Appends logging events to the terminal using ANSI color escape sequences.
- /// </summary>
- /// <remarks>
- /// <para>
- /// AnsiColorTerminalAppender appends log events to the standard output stream
- /// or the error output stream using a layout specified by the
- /// user. It also allows the color of a specific level of message to be set.
- /// </para>
- /// <note>
- /// This appender expects the terminal to understand the VT100 control set
- /// in order to interpret the color codes. If the terminal or console does not
- /// understand the control codes the behavior is not defined.
- /// </note>
- /// <para>
- /// By default, all output is written to the console's standard output stream.
- /// The <see cref="Target"/> property can be set to direct the output to the
- /// error stream.
- /// </para>
- /// <para>
- /// NOTE: This appender writes each message to the <c>System.Console.Out</c> or
- /// <c>System.Console.Error</c> that is set at the time the event is appended.
- /// Therefore it is possible to programmatically redirect the output of this appender
- /// (for example NUnit does this to capture program output). While this is the desired
- /// behavior of this appender it may have security implications in your application.
- /// </para>
- /// <para>
- /// When configuring the ANSI colored terminal appender, a mapping should be
- /// specified to map a logging level to a color. For example:
- /// </para>
- /// <code lang="XML" escaped="true">
- /// <mapping>
- /// <level value="ERROR" />
- /// <foreColor value="White" />
- /// <backColor value="Red" />
- /// <attributes value="Bright,Underscore" />
- /// </mapping>
- /// <mapping>
- /// <level value="DEBUG" />
- /// <backColor value="Green" />
- /// </mapping>
- /// </code>
- /// <para>
- /// The Level is the standard log4net logging level and ForeColor and BackColor can be any
- /// of the following values:
- /// <list type="bullet">
- /// <item><term>Blue</term><description></description></item>
- /// <item><term>Green</term><description></description></item>
- /// <item><term>Red</term><description></description></item>
- /// <item><term>White</term><description></description></item>
- /// <item><term>Yellow</term><description></description></item>
- /// <item><term>Purple</term><description></description></item>
- /// <item><term>Cyan</term><description></description></item>
- /// </list>
- /// These color values cannot be combined together to make new colors.
- /// </para>
- /// <para>
- /// The attributes can be any combination of the following:
- /// <list type="bullet">
- /// <item><term>Bright</term><description>foreground is brighter</description></item>
- /// <item><term>Dim</term><description>foreground is dimmer</description></item>
- /// <item><term>Underscore</term><description>message is underlined</description></item>
- /// <item><term>Blink</term><description>foreground is blinking (does not work on all terminals)</description></item>
- /// <item><term>Reverse</term><description>foreground and background are reversed</description></item>
- /// <item><term>Hidden</term><description>output is hidden</description></item>
- /// <item><term>Strikethrough</term><description>message has a line through it</description></item>
- /// </list>
- /// While any of these attributes may be combined together not all combinations
- /// work well together, for example setting both <i>Bright</i> and <i>Dim</i> attributes makes
- /// no sense.
- /// </para>
- /// </remarks>
- /// <author>Patrick Wagstrom</author>
- /// <author>Nicko Cadell</author>
- public class AnsiColorTerminalAppender : AppenderSkeleton
- {
- #region Colors Enum
+ /// <summary>
+ /// Appends logging events to the terminal using ANSI color escape sequences.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// AnsiColorTerminalAppender appends log events to the standard output stream
+ /// or the error output stream using a layout specified by the
+ /// user. It also allows the color of a specific level of message to be set.
+ /// </para>
+ /// <note>
+ /// This appender expects the terminal to understand the VT100 control set
+ /// in order to interpret the color codes. If the terminal or console does not
+ /// understand the control codes the behavior is not defined.
+ /// </note>
+ /// <para>
+ /// By default, all output is written to the console's standard output stream.
+ /// The <see cref="Target"/> property can be set to direct the output to the
+ /// error stream.
+ /// </para>
+ /// <para>
+ /// NOTE: This appender writes each message to the <c>System.Console.Out</c> or
+ /// <c>System.Console.Error</c> that is set at the time the event is appended.
+ /// Therefore it is possible to programmatically redirect the output of this appender
+ /// (for example NUnit does this to capture program output). While this is the desired
+ /// behavior of this appender it may have security implications in your application.
+ /// </para>
+ /// <para>
+ /// When configuring the ANSI colored terminal appender, a mapping should be
+ /// specified to map a logging level to a color. For example:
+ /// </para>
+ /// <code lang="XML" escaped="true">
+ /// <mapping>
+ /// <level value="ERROR" />
+ /// <foreColor value="White" />
+ /// <backColor value="Red" />
+ /// <attributes value="Bright,Underscore" />
+ /// </mapping>
+ /// <mapping>
+ /// <level value="DEBUG" />
+ /// <backColor value="Green" />
+ /// </mapping>
+ /// </code>
+ /// <para>
+ /// The Level is the standard log4net logging level and ForeColor and BackColor can be any
+ /// of the following values:
+ /// <list type="bullet">
+ /// <item><term>Blue</term><description></description></item>
+ /// <item><term>Green</term><description></description></item>
+ /// <item><term>Red</term><description></description></item>
+ /// <item><term>White</term><description></description></item>
+ /// <item><term>Yellow</term><description></description></item>
+ /// <item><term>Purple</term><description></description></item>
+ /// <item><term>Cyan</term><description></description></item>
+ /// </list>
+ /// These color values cannot be combined together to make new colors.
+ /// </para>
+ /// <para>
+ /// The attributes can be any combination of the following:
+ /// <list type="bullet">
+ /// <item><term>Bright</term><description>foreground is brighter</description></item>
+ /// <item><term>Dim</term><description>foreground is dimmer</description></item>
+ /// <item><term>Underscore</term><description>message is underlined</description></item>
+ /// <item><term>Blink</term><description>foreground is blinking (does not work on all terminals)</description></item>
+ /// <item><term>Reverse</term><description>foreground and background are reversed</description></item>
+ /// <item><term>Hidden</term><description>output is hidden</description></item>
+ /// <item><term>Strikethrough</term><description>message has a line through it</description></item>
+ /// </list>
+ /// While any of these attributes may be combined together not all combinations
+ /// work well together, for example setting both <i>Bright</i> and <i>Dim</i> attributes makes
+ /// no sense.
+ /// </para>
+ /// </remarks>
+ /// <author>Patrick Wagstrom</author>
+ /// <author>Nicko Cadell</author>
+ public class AnsiColorTerminalAppender : AppenderSkeleton
+ {
+ #region Colors Enum
- /// <summary>
- /// The enum of possible display attributes
- /// </summary>
- /// <remarks>
- /// <para>
- /// The following flags can be combined together to
- /// form the ANSI color attributes.
- /// </para>
- /// </remarks>
- /// <seealso cref="AnsiColorTerminalAppender" />
- [Flags]
- public enum AnsiAttributes : int
- {
- /// <summary>
- /// text is bright
- /// </summary>
- Bright = 1,
- /// <summary>
- /// text is dim
- /// </summary>
- Dim = 2,
+ /// <summary>
+ /// The enum of possible display attributes
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// The following flags can be combined together to
+ /// form the ANSI color attributes.
+ /// </para>
+ /// </remarks>
+ /// <seealso cref="AnsiColorTerminalAppender" />
+ [Flags]
+ public enum AnsiAttributes : int
+ {
+ /// <summary>
+ /// text is bright
+ /// </summary>
+ Bright = 1,
+ /// <summary>
+ /// text is dim
+ /// </summary>
+ Dim = 2,
- /// <summary>
- /// text is underlined
- /// </summary>
- Underscore = 4,
+ /// <summary>
+ /// text is underlined
+ /// </summary>
+ Underscore = 4,
- /// <summary>
- /// text is blinking
- /// </summary>
- /// <remarks>
- /// Not all terminals support this attribute
- /// </remarks>
- Blink = 8,
+ /// <summary>
+ /// text is blinking
+ /// </summary>
+ /// <remarks>
+ /// Not all terminals support this attribute
+ /// </remarks>
+ Blink = 8,
- /// <summary>
- /// text and background colors are reversed
- /// </summary>
- Reverse = 16,
+ /// <summary>
+ /// text and background colors are reversed
+ /// </summary>
+ Reverse = 16,
- /// <summary>
- /// text is hidden
- /// </summary>
- Hidden = 32,
+ /// <summary>
+ /// text is hidden
+ /// </summary>
+ Hidden = 32,
- /// <summary>
- /// text is displayed with a strikethrough
- /// </summary>
- Strikethrough = 64,
+ /// <summary>
+ /// text is displayed with a strikethrough
+ /// </summary>
+ Strikethrough = 64,
- /// <summary>
- /// text color is light
- /// </summary>
- Light = 128
- }
+ /// <summary>
+ /// text color is light
+ /// </summary>
+ Light = 128
+ }
- /// <summary>
- /// The enum of possible foreground or background color values for
- /// use with the color mapping method
- /// </summary>
- /// <remarks>
- /// <para>
- /// The output can be in one for the following ANSI colors.
- /// </para>
- /// </remarks>
- /// <seealso cref="AnsiColorTerminalAppender" />
- public enum AnsiColor : int
- {
- /// <summary>
- /// color is black
- /// </summary>
- Black = 0,
+ /// <summary>
+ /// The enum of possible foreground or background color values for
+ /// use with the color mapping method
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// The output can be in one for the following ANSI colors.
+ /// </para>
+ /// </remarks>
+ /// <seealso cref="AnsiColorTerminalAppender" />
+ public enum AnsiColor : int
+ {
+ /// <summary>
+ /// color is black
+ /// </summary>
+ Black = 0,
- /// <summary>
- /// color is red
- /// </summary>
- Red = 1,
+ /// <summary>
+ /// color is red
+ /// </summary>
+ Red = 1,
- /// <summary>
- /// color is green
- /// </summary>
- Green = 2,
+ /// <summary>
+ /// color is green
+ /// </summary>
+ Green = 2,
- /// <summary>
- /// color is yellow
- /// </summary>
- Yellow = 3,
+ /// <summary>
+ /// color is yellow
+ /// </summary>
+ Yellow = 3,
- /// <summary>
- /// color is blue
- /// </summary>
- Blue = 4,
+ /// <summary>
+ /// color is blue
+ /// </summary>
+ Blue = 4,
- /// <summary>
- /// color is magenta
- /// </summary>
- Magenta = 5,
+ /// <summary>
+ /// color is magenta
+ /// </summary>
+ Magenta = 5,
- /// <summary>
- /// color is cyan
- /// </summary>
- Cyan = 6,
+ /// <summary>
+ /// color is cyan
+ /// </summary>
+ Cyan = 6,
- /// <summary>
- /// color is white
- /// </summary>
- White = 7
- }
+ /// <summary>
+ /// color is white
+ /// </summary>
+ White = 7
+ }
- #endregion
+ #endregion
- #region Public Instance Constructors
+ #region Public Instance Constructors
- /// <summary>
- /// Initializes a new instance of the <see cref="AnsiColorTerminalAppender" /> class.
- /// </summary>
- /// <remarks>
- /// The instance of the <see cref="AnsiColorTerminalAppender" /> class is set up to write
- /// to the standard output stream.
- /// </remarks>
- public AnsiColorTerminalAppender()
- {
- }
+ /// <summary>
+ /// Initializes a new instance of the <see cref="AnsiColorTerminalAppender" /> class.
+ /// </summary>
+ /// <remarks>
+ /// The instance of the <see cref="AnsiColorTerminalAppender" /> class is set up to write
+ /// to the standard output stream.
+ /// </remarks>
+ public AnsiColorTerminalAppender()
+ {
+ }
- #endregion Public Instance Constructors
+ #endregion Public Instance Constructors
- #region Public Instance Properties
+ #region Public Instance Properties
- /// <summary>
- /// Target is the value of the console output stream.
- /// </summary>
- /// <value>
- /// Target is the value of the console output stream.
- /// This is either <c>"Console.Out"</c> or <c>"Console.Error"</c>.
- /// </value>
- /// <remarks>
- /// <para>
- /// Target is the value of the console output stream.
- /// This is either <c>"Console.Out"</c> or <c>"Console.Error"</c>.
- /// </para>
- /// </remarks>
- public virtual string Target
- {
- get { return m_writeToErrorStream ? ConsoleError : ConsoleOut; }
- set
- {
- string trimmedTargetName = value.Trim();
+ /// <summary>
+ /// Target is the value of the console output stream.
+ /// </summary>
+ /// <value>
+ /// Target is the value of the console output stream.
+ /// This is either <c>"Console.Out"</c> or <c>"Console.Error"</c>.
+ /// </value>
+ /// <remarks>
+ /// <para>
+ /// Target is the value of the console output stream.
+ /// This is either <c>"Console.Out"</c> or <c>"Console.Error"</c>.
+ /// </para>
+ /// </remarks>
+ public virtual string Target
+ {
+ get { return m_writeToErrorStream ? ConsoleError : ConsoleOut; }
+ set
+ {
+ string trimmedTargetName = value.Trim();
- if (SystemInfo.EqualsIgnoringCase(ConsoleError, trimmedTargetName))
- {
- m_writeToErrorStream = true;
- }
- else
- {
- m_writeToErrorStream = false;
- }
- }
- }
+ if (SystemInfo.EqualsIgnoringCase(ConsoleError, trimmedTargetName))
+ {
+ m_writeToErrorStream = true;
+ }
+ else
+ {
+ m_writeToErrorStream = false;
+ }
+ }
+ }
- /// <summary>
- /// Add a mapping of level to color
- /// </summary>
- /// <param name="mapping">The mapping to add</param>
- /// <remarks>
- /// <para>
- /// Add a <see cref="LevelColors"/> mapping to this appender.
- /// Each mapping defines the foreground and background colours
- /// for a level.
- /// </para>
- /// </remarks>
- public void AddMapping(LevelColors mapping)
- {
- m_levelMapping.Add(mapping);
- }
+ /// <summary>
+ /// Add a mapping of level to color
+ /// </summary>
+ /// <param name="mapping">The mapping to add</param>
+ /// <remarks>
+ /// <para>
+ /// Add a <see cref="LevelColors"/> mapping to this appender.
+ /// Each mapping defines the foreground and background colours
+ /// for a level.
+ /// </para>
+ /// </remarks>
+ public void AddMapping(LevelColors mapping)
+ {
+ m_levelMapping.Add(mapping);
+ }
- #endregion Public Instance Properties
+ #endregion Public Instance Properties
- #region Override implementation of AppenderSkeleton
+ #region Override implementation of AppenderSkeleton
- /// <summary>
- /// This method is called by the <see cref="M:AppenderSkeleton.DoAppend(LoggingEvent)"/> method.
- /// </summary>
- /// <param name="loggingEvent">The event to log.</param>
- /// <remarks>
- /// <para>
- /// Writes the event to the console.
- /// </para>
- /// <para>
- /// The format of the output will depend on the appender's layout.
- /// </para>
- /// </remarks>
- protected override void Append(log4net.Core.LoggingEvent loggingEvent)
- {
- string loggingMessage = RenderLoggingEvent(loggingEvent);
+ /// <summary>
+ /// This method is called by the <see cref="M:AppenderSkeleton.DoAppend(LoggingEvent)"/> method.
+ /// </summary>
+ /// <param name="loggingEvent">The event to log.</param>
+ /// <remarks>
+ /// <para>
+ /// Writes the event to the console.
+ /// </para>
+ /// <para>
+ /// The format of the output will depend on the appender's layout.
+ /// </para>
+ /// </remarks>
+ protected override void Append(log4net.Core.LoggingEvent loggingEvent)
+ {
+ string loggingMessage = RenderLoggingEvent(loggingEvent);
- // see if there is a specified lookup.
- LevelColors levelColors = m_levelMapping.Lookup(loggingEvent.Level) as LevelColors;
- if (levelColors != null)
- {
- // Prepend the Ansi Color code
- loggingMessage = levelColors.CombinedColor + loggingMessage;
- }
+ // see if there is a specified lookup.
+ LevelColors levelColors = m_levelMapping.Lookup(loggingEvent.Level) as LevelColors;
+ if (levelColors != null)
+ {
+ // Prepend the Ansi Color code
+ loggingMessage = levelColors.CombinedColor + loggingMessage;
+ }
- // on most terminals there are weird effects if we don't clear the background color
- // before the new line. This checks to see if it ends with a newline, and if
- // so, inserts the clear codes before the newline, otherwise the clear codes
- // are inserted afterwards.
- if (loggingMessage.Length > 1)
- {
- if (loggingMessage.EndsWith("\r\n") || loggingMessage.EndsWith("\n\r"))
- {
- loggingMessage = loggingMessage.Insert(loggingMessage.Length - 2, PostEventCodes);
- }
- else if (loggingMessage.EndsWith("\n") || loggingMessage.EndsWith("\r"))
- {
- loggingMessage = loggingMessage.Insert(loggingMessage.Length - 1, PostEventCodes);
- }
- else
- {
- loggingMessage = loggingMessage + PostEventCodes;
- }
- }
- else
- {
- if (loggingMessage[0] == '\n' || loggingMessage[0] == '\r')
- {
- loggingMessage = PostEventCodes + loggingMessage;
- }
- else
- {
- loggingMessage = loggingMessage + PostEventCodes;
- }
- }
+ // on most terminals there are weird effects if we don't clear the background color
+ // before the new line. This checks to see if it ends with a newline, and if
+ // so, inserts the clear codes before the newline, otherwise the clear codes
+ // are inserted afterwards.
+ if (loggingMessage.Length > 1)
+ {
+ if (loggingMessage.EndsWith("\r\n") || loggingMessage.EndsWith("\n\r"))
+ {
+ loggingMessage = loggingMessage.Insert(loggingMessage.Length - 2, PostEventCodes);
+ }
+ else if (loggingMessage.EndsWith("\n") || loggingMessage.EndsWith("\r"))
+ {
+ loggingMessage = loggingMessage.Insert(loggingMessage.Length - 1, PostEventCodes);
+ }
+ else
+ {
+ loggingMessage = loggingMessage + PostEventCodes;
+ }
+ }
+ else
+ {
+ if (loggingMessage[0] == '\n' || loggingMessage[0] == '\r')
+ {
+ loggingMessage = PostEventCodes + loggingMessage;
+ }
+ else
+ {
+ loggingMessage = loggingMessage + PostEventCodes;
+ }
+ }
#if NETCF_1_0
- // Write to the output stream
- Console.Write(loggingMessage);
+ // Write to the output stream
+ Console.Write(loggingMessage);
#else
- if (m_writeToErrorStream)
- {
- // Write to the error stream
- Console.Error.Write(loggingMessage);
- }
- else
- {
- // Write to the output stream
- Console.Write(loggingMessage);
- }
+ if (m_writeToErrorStream)
+ {
+ // Write to the error stream
+ Console.Error.Write(loggingMessage);
+ }
+ else
+ {
+ // Write to the output stream
+ Console.Write(loggingMessage);
+ }
#endif
-
- }
+
+ }
- /// <summary>
- /// This appender requires a <see cref="Layout"/> to be set.
- /// </summary>
- /// <value><c>true</c></value>
- /// <remarks>
- /// <para>
- /// This appender requires a <see cref="Layout"/> to be set.
- /// </para>
- /// </remarks>
- protected override bool RequiresLayout
- {
- get { return true; }
- }
+ /// <summary>
+ /// This appender requires a <see cref="Layout"/> to be set.
+ /// </summary>
+ /// <value><c>true</c></value>
+ /// <remarks>
+ /// <para>
+ /// This appender requires a <see cref="Layout"/> to be set.
+ /// </para>
+ /// </remarks>
+ protected override bool RequiresLayout
+ {
+ get { return true; }
+ }
- /// <summary>
- /// Initialize the options for this appender
- /// </summary>
- /// <remarks>
- /// <para>
- /// Initialize the level to color mappings set on this appender.
- /// </para>
- /// </remarks>
- public override void ActivateOptions()
- {
- base.ActivateOptions();
- m_levelMapping.ActivateOptions();
- }
+ /// <summary>
+ /// Initialize the options for this appender
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Initialize the level to color mappings set on this appender.
+ /// </para>
+ /// </remarks>
+ public override void ActivateOptions()
+ {
+ base.ActivateOptions();
+ m_levelMapping.ActivateOptions();
+ }
- #endregion Override implementation of AppenderSkeleton
+ #endregion Override implementation of AppenderSkeleton
- #region Public Static Fields
+ #region Public Static Fields
- /// <summary>
- /// The <see cref="AnsiColorTerminalAppender.Target"/> to use when writing to the Console
- /// standard output stream.
- /// </summary>
- /// <remarks>
- /// <para>
- /// The <see cref="AnsiColorTerminalAppender.Target"/> to use when writing to the Console
- /// standard output stream.
- /// </para>
- /// </remarks>
- public const string ConsoleOut = "Console.Out";
+ /// <summary>
+ /// The <see cref="AnsiColorTerminalAppender.Target"/> to use when writing to the Console
+ /// standard output stream.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// The <see cref="AnsiColorTerminalAppender.Target"/> to use when writing to the Console
+ /// standard output stream.
+ /// </para>
+ /// </remarks>
+ public const string ConsoleOut = "Console.Out";
- /// <summary>
- /// The <see cref="AnsiColorTerminalAppender.Target"/> to use when writing to the Console
- /// standard error output stream.
- /// </summary>
- /// <remarks>
- /// <para>
- /// The <see cref="AnsiColorTerminalAppender.Target"/> to use when writing to the Console
- /// standard error output stream.
- /// </para>
- /// </remarks>
- public const string ConsoleError = "Console.Error";
+ /// <summary>
+ /// The <see cref="AnsiColorTerminalAppender.Target"/> to use when writing to the Console
+ /// standard error output stream.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// The <see cref="AnsiColorTerminalAppender.Target"/> to use when writing to the Console
+ /// standard error output stream.
+ /// </para>
+ /// </remarks>
+ public const string ConsoleError = "Console.Error";
- #endregion Public Static Fields
+ #endregion Public Static Fields
- #region Private Instances Fields
+ #region Private Instances Fields
- /// <summary>
- /// Flag to write output to the error stream rather than the standard output stream
- /// </summary>
- private bool m_writeToErrorStream = false;
+ /// <summary>
+ /// Flag to write output to the error stream rather than the standard output stream
+ /// </summary>
+ private bool m_writeToErrorStream = false;
- /// <summary>
- /// Mapping from level object to color value
- /// </summary>
- private LevelMapping m_levelMapping = new LevelMapping();
+ /// <summary>
+ /// Mapping from level object to color value
+ /// </summary>
+ private LevelMapping m_levelMapping = new LevelMapping();
- /// <summary>
- /// Ansi code to reset terminal
- /// </summary>
- private const string PostEventCodes = "\x1b[0m";
+ /// <summary>
+ /// Ansi code to reset terminal
+ /// </summary>
+ private const string PostEventCodes = "\x1b[0m";
- #endregion Private Instances Fields
+ #endregion Private Instances Fields
- #region LevelColors LevelMapping Entry
+ #region LevelColors LevelMapping Entry
- /// <summary>
- /// A class to act as a mapping between the level that a logging call is made at and
- /// the color it should be displayed as.
- /// </summary>
- /// <remarks>
- /// <para>
- /// Defines the mapping between a level and the color it should be displayed in.
- /// </para>
- /// </remarks>
- public class LevelColors : LevelMappingEntry
- {
- private AnsiColor m_foreColor;
- private AnsiColor m_backColor;
- private AnsiAttributes m_attributes;
- private string m_combinedColor = "";
+ /// <summary>
+ /// A class to act as a mapping between the level that a logging call is made at and
+ /// the color it should be displayed as.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Defines the mapping between a level and the color it should be displayed in.
+ /// </para>
+ /// </remarks>
+ public class LevelColors : LevelMappingEntry
+ {
+ private AnsiColor m_foreColor;
+ private AnsiColor m_backColor;
+ private AnsiAttributes m_attributes;
+ private string m_combinedColor = "";
- /// <summary>
- /// The mapped foreground color for the specified level
- /// </summary>
- /// <remarks>
- /// <para>
- /// Required property.
- /// The mapped foreground color for the specified level
- /// </para>
- /// </remarks>
- public AnsiColor ForeColor
- {
- get { return m_foreColor; }
- set { m_foreColor = value; }
- }
+ /// <summary>
+ /// The mapped foreground color for the specified level
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Required property.
+ /// The mapped foreground color for the specified level
+ /// </para>
+ /// </remarks>
+ public AnsiColor ForeColor
+ {
+ get { return m_foreColor; }
+ set { m_foreColor = value; }
+ }
- /// <summary>
- /// The mapped background color for the specified level
- /// </summary>
- /// <remarks>
- /// <para>
- /// Required property.
- /// The mapped background color for the specified level
- /// </para>
- /// </remarks>
- public AnsiColor BackColor
- {
- get { return m_backColor; }
- set { m_backColor = value; }
- }
+ /// <summary>
+ /// The mapped background color for the specified level
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Required property.
+ /// The mapped background color for the specified level
+ /// </para>
+ /// </remarks>
+ public AnsiColor BackColor
+ {
+ get { return m_backColor; }
+ set { m_backColor = value; }
+ }
- /// <summary>
- /// The color attributes for the specified level
- /// </summary>
- /// <remarks>
- /// <para>
- /// Required property.
- /// The color attributes for the specified level
- /// </para>
- /// </remarks>
- public AnsiAttributes Attributes
- {
- get { return m_attributes; }
- set { m_attributes = value; }
- }
+ /// <summary>
+ /// The color attributes for the specified level
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Required property.
+ /// The color attributes for the specified level
+ /// </para>
+ /// </remarks>
+ public AnsiAttributes Attributes
+ {
+ get { return m_attributes; }
+ set { m_attributes = value; }
+ }
- /// <summary>
- /// Initialize the options for the object
- /// </summary>
- /// <remarks>
- /// <para>
- /// Combine the <see cref="ForeColor"/> and <see cref="BackColor"/> together
- /// and append the attributes.
- /// </para>
- /// </remarks>
- public override void ActivateOptions()
- {
- base.ActivateOptions();
+ /// <summary>
+ /// Initialize the options for the object
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Combine the <see cref="ForeColor"/> and <see cref="BackColor"/> together
+ /// and append the attributes.
+ /// </para>
+ /// </remarks>
+ public override void ActivateOptions()
+ {
+ base.ActivateOptions();
- StringBuilder buf = new StringBuilder();
+ StringBuilder buf = new StringBuilder();
- // Reset any existing codes
- buf.Append("\x1b[0;");
+ // Reset any existing codes
+ buf.Append("\x1b[0;");
- int lightAdjustment = ((m_attributes & AnsiAttributes.Light) > 0) ? 60 : 0;
-
- // set the foreground color
- buf.Append(30 + lightAdjustment + (int)m_foreColor);
- buf.Append(';');
+ int lightAdjustment = ((m_attributes & AnsiAttributes.Light) > 0) ? 60 : 0;
+
+ // set the foreground color
+ buf.Append(30 + lightAdjustment + (int)m_foreColor);
+ buf.Append(';');
- // set the background color
- buf.Append(40 + lightAdjustment + (int)m_backColor);
+ // set the background color
+ buf.Append(40 + lightAdjustment + (int)m_backColor);
- // set the attributes
- if ((m_attributes & AnsiAttributes.Bright) > 0)
- {
- buf.Append(";1");
- }
- if ((m_attributes & AnsiAttributes.Dim) > 0)
- {
- buf.Append(";2");
- }
- if ((m_attributes & AnsiAttributes.Underscore) > 0)
- {
- buf.Append(";4");
- }
- if ((m_attributes & AnsiAttributes.Blink) > 0)
- {
- buf.Append(";5");
- }
- if ((m_attributes & AnsiAttributes.Reverse) > 0)
- {
- buf.Append(";7");
- }
- if ((m_attributes & AnsiAttributes.Hidden) > 0)
- {
- buf.Append(";8");
- }
- if ((m_attributes & AnsiAttributes.Strikethrough) > 0)
- {
- buf.Append(";9");
- }
+ // set the attributes
+ if ((m_attributes & AnsiAttributes.Bright) > 0)
+ {
+ buf.Append(";1");
+ }
+ if ((m_attributes & AnsiAttributes.Dim) > 0)
+ {
+ buf.Append(";2");
+ }
+ if ((m_attributes & AnsiAttributes.Underscore) > 0)
+ {
+ buf.Append(";4");
+ }
+ if ((m_attributes & AnsiAttributes.Blink) > 0)
+ {
+ buf.Append(";5");
+ }
+ if ((m_attributes & AnsiAttributes.Reverse) > 0)
+ {
+ buf.Append(";7");
+ }
+ if ((m_attributes & AnsiAttributes.Hidden) > 0)
+ {
+ buf.Append(";8");
+ }
+ if ((m_attributes & AnsiAttributes.Strikethrough) > 0)
+ {
+ buf.Append(";9");
+ }
- buf.Append('m');
+ buf.Append('m');
- m_combinedColor = buf.ToString();
- }
+ m_combinedColor = buf.ToString();
+ }
- /// <summary>
- /// The combined <see cref="ForeColor"/>, <see cref="BackColor"/> and
- /// <see cref="Attributes"/> suitable for setting the ansi terminal color.
- /// </summary>
- internal string CombinedColor
- {
- get { return m_combinedColor; }
- }
- }
+ /// <summary>
+ /// The combined <see cref="ForeColor"/>, <see cref="BackColor"/> and
+ /// <see cref="Attributes"/> suitable for setting the ansi terminal color.
+ /// </summary>
+ internal string CombinedColor
+ {
+ get { return m_combinedColor; }
+ }
+ }
- #endregion // LevelColors LevelMapping Entry
- }
+ #endregion // LevelColors LevelMapping Entry
+ }
}
diff --git a/src/log4net/Appender/AppenderCollection.cs b/src/log4net/Appender/AppenderCollection.cs
index 14f2304..9728661 100644
--- a/src/log4net/Appender/AppenderCollection.cs
+++ b/src/log4net/Appender/AppenderCollection.cs
@@ -22,884 +22,884 @@
namespace log4net.Appender
{
- /// <summary>
- /// A strongly-typed collection of <see cref="IAppender"/> objects.
- /// </summary>
- /// <author>Nicko Cadell</author>
- public class AppenderCollection : ICollection, IList, IEnumerable
+ /// <summary>
+ /// A strongly-typed collection of <see cref="IAppender"/> objects.
+ /// </summary>
+ /// <author>Nicko Cadell</author>
+ public class AppenderCollection : ICollection, IList, IEnumerable
#if !NETSTANDARD1_3
- , ICloneable
+ , ICloneable
#endif
- {
- #region Interfaces
- /// <summary>
- /// Supports type-safe iteration over a <see cref="AppenderCollection"/>.
- /// </summary>
- /// <exclude/>
- public interface IAppenderCollectionEnumerator
- {
- /// <summary>
- /// Gets the current element in the collection.
- /// </summary>
- IAppender Current { get; }
+ {
+ #region Interfaces
+ /// <summary>
+ /// Supports type-safe iteration over a <see cref="AppenderCollection"/>.
+ /// </summary>
+ /// <exclude/>
+ public interface IAppenderCollectionEnumerator
+ {
+ /// <summary>
+ /// Gets the current element in the collection.
+ /// </summary>
+ IAppender Current { get; }
- /// <summary>
- /// Advances the enumerator to the next element in the collection.
- /// </summary>
- /// <returns>
- /// <c>true</c> if the enumerator was successfully advanced to the next element;
- /// <c>false</c> if the enumerator has passed the end of the collection.
- /// </returns>
- /// <exception cref="InvalidOperationException">
- /// The collection was modified after the enumerator was created.
- /// </exception>
- bool MoveNext();
+ /// <summary>
+ /// Advances the enumerator to the next element in the collection.
+ /// </summary>
+ /// <returns>
+ /// <c>true</c> if the enumerator was successfully advanced to the next element;
+ /// <c>false</c> if the enumerator has passed the end of the collection.
+ /// </returns>
+ /// <exception cref="InvalidOperationException">
+ /// The collection was modified after the enumerator was created.
+ /// </exception>
+ bool MoveNext();
- /// <summary>
- /// Sets the enumerator to its initial position, before the first element in the collection.
- /// </summary>
- void Reset();
- }
- #endregion
+ /// <summary>
+ /// Sets the enumerator to its initial position, before the first element in the collection.
+ /// </summary>
+ void Reset();
+ }
+ #endregion
- private const int DEFAULT_CAPACITY = 16;
+ private const int DEFAULT_CAPACITY = 16;
- #region Implementation (data)
+ #region Implementation (data)
- private IAppender[] m_array;
- private int m_count = 0;
- private int m_version = 0;
+ private IAppender[] m_array;
+ private int m_count = 0;
+ private int m_version = 0;
- #endregion
-
- #region Static Wrappers
+ #endregion
+
+ #region Static Wrappers
- /// <summary>
- /// Creates a read-only wrapper for a <c>AppenderCollection</c> instance.
- /// </summary>
- /// <param name="list">list to create a readonly wrapper arround</param>
- /// <returns>
- /// An <c>AppenderCollection</c> wrapper that is read-only.
- /// </returns>
- public static AppenderCollection ReadOnly(AppenderCollection list)
- {
- if(list==null) throw new ArgumentNullException("list");
+ /// <summary>
+ /// Creates a read-only wrapper for a <c>AppenderCollection</c> instance.
+ /// </summary>
+ /// <param name="list">list to create a readonly wrapper arround</param>
+ /// <returns>
+ /// An <c>AppenderCollection</c> wrapper that is read-only.
+ /// </returns>
+ public static AppenderCollection ReadOnly(AppenderCollection list)
+ {
+ if(list==null) throw new ArgumentNullException("list");
- return new ReadOnlyAppenderCollection(list);
- }
+ return new ReadOnlyAppenderCollection(list);
+ }
- #endregion
+ #endregion
- #region Static Fields
+ #region Static Fields
- /// <summary>
- /// An empty readonly static AppenderCollection
- /// </summary>
- public static readonly AppenderCollection EmptyCollection = ReadOnly(new AppenderCollection(0));
+ /// <summary>
+ /// An empty readonly static AppenderCollection
+ /// </summary>
+ public static readonly AppenderCollection EmptyCollection = ReadOnly(new AppenderCollection(0));
- #endregion
+ #endregion
- #region Constructors
+ #region Constructors
- /// <summary>
- /// Initializes a new instance of the <c>AppenderCollection</c> class
- /// that is empty and has the default initial capacity.
- /// </summary>
- public AppenderCollection()
- {
- m_array = new IAppender[DEFAULT_CAPACITY];
- }
-
- /// <summary>
- /// Initializes a new instance of the <c>AppenderCollection</c> class
- /// that has the specified initial capacity.
- /// </summary>
- /// <param name="capacity">
- /// The number of elements that the new <c>AppenderCollection</c> is initially capable of storing.
- /// </param>
- public AppenderCollection(int capacity)
- {
- m_array = new IAppender[capacity];
- }
+ /// <summary>
+ /// Initializes a new instance of the <c>AppenderCollection</c> class
+ /// that is empty and has the default initial capacity.
+ /// </summary>
+ public AppenderCollection()
+ {
+ m_array = new IAppender[DEFAULT_CAPACITY];
+ }
+
+ /// <summary>
+ /// Initializes a new instance of the <c>AppenderCollection</c> class
+ /// that has the specified initial capacity.
+ /// </summary>
+ /// <param name="capacity">
+ /// The number of elements that the new <c>AppenderCollection</c> is initially capable of storing.
+ /// </param>
+ public AppenderCollection(int capacity)
+ {
+ m_array = new IAppender[capacity];
+ }
- /// <summary>
- /// Initializes a new instance of the <c>AppenderCollection</c> class
- /// that contains elements copied from the specified <c>AppenderCollection</c>.
- /// </summary>
- /// <param name="c">The <c>AppenderCollection</c> whose elements are copied to the new collection.</param>
- public AppenderCollection(AppenderCollection c)
- {
- m_array = new IAppender[c.Count];
- AddRange(c);
- }
+ /// <summary>
+ /// Initializes a new instance of the <c>AppenderCollection</c> class
+ /// that contains elements copied from the specified <c>AppenderCollection</c>.
+ /// </summary>
+ /// <param name="c">The <c>AppenderCollection</c> whose elements are copied to the new collection.</param>
+ public AppenderCollection(AppenderCollection c)
+ {
+ m_array = new IAppender[c.Count];
+ AddRange(c);
+ }
- /// <summary>
- /// Initializes a new instance of the <c>AppenderCollection</c> class
- /// that contains elements copied from the specified <see cref="IAppender"/> array.
- /// </summary>
- /// <param name="a">The <see cref="IAppender"/> array whose elements are copied to the new list.</param>
- public AppenderCollection(IAppender[] a)
- {
- m_array = new IAppender[a.Length];
- AddRange(a);
- }
-
- /// <summary>
- /// Initializes a new instance of the <c>AppenderCollection</c> class
- /// that contains elements copied from the specified <see cref="IAppender"/> collection.
- /// </summary>
- /// <param name="col">The <see cref="IAppender"/> collection whose elements are copied to the new list.</param>
- public AppenderCollection(ICollection col)
- {
- m_array = new IAppender[col.Count];
- AddRange(col);
- }
+ /// <summary>
+ /// Initializes a new instance of the <c>AppenderCollection</c> class
+ /// that contains elements copied from the specified <see cref="IAppender"/> array.
+ /// </summary>
+ /// <param name="a">The <see cref="IAppender"/> array whose elements are copied to the new list.</param>
+ public AppenderCollection(IAppender[] a)
+ {
+ m_array = new IAppender[a.Length];
+ AddRange(a);
+ }
+
+ /// <summary>
+ /// Initializes a new instance of the <c>AppenderCollection</c> class
+ /// that contains elements copied from the specified <see cref="IAppender"/> collection.
+ /// </summary>
+ /// <param name="col">The <see cref="IAppender"/> collection whose elements are copied to the new list.</param>
+ public AppenderCollection(ICollection col)
+ {
+ m_array = new IAppender[col.Count];
+ AddRange(col);
+ }
- /// <summary>
- /// Type visible only to our subclasses
- /// Used to access protected constructor
- /// </summary>
- /// <exclude/>
- protected internal enum Tag
- {
- /// <summary>
- /// A value
- /// </summary>
- Default
- }
+ /// <summary>
+ /// Type visible only to our subclasses
+ /// Used to access protected constructor
+ /// </summary>
+ /// <exclude/>
+ protected internal enum Tag
+ {
+ /// <summary>
+ /// A value
+ /// </summary>
+ Default
+ }
- /// <summary>
- /// Allow subclasses to avoid our default constructors
- /// </summary>
- /// <param name="tag"></param>
- /// <exclude/>
- protected internal AppenderCollection(Tag tag)
- {
- m_array = null;
- }
+ /// <summary>
+ /// Allow subclasses to avoid our default constructors
+ /// </summary>
+ /// <param name="tag"></param>
+ /// <exclude/>
+ protected internal AppenderCollection(Tag tag)
+ {
+ m_array = null;
+ }
- #endregion
-
- #region Operations (type-safe ICollection)
+ #endregion
+
+ #region Operations (type-safe ICollection)
- /// <summary>
- /// Gets the number of elements actually contained in the <c>AppenderCollection</c>.
- /// </summary>
- public virtual int Count
- {
- get { return m_count; }
- }
+ /// <summary>
+ /// Gets the number of elements actually contained in the <c>AppenderCollection</c>.
+ /// </summary>
+ public virtual int Count
+ {
+ get { return m_count; }
+ }
- /// <summary>
- /// Copies the entire <c>AppenderCollection</c> to a one-dimensional
- /// <see cref="IAppender"/> array.
- /// </summary>
- /// <param name="array">The one-dimensional <see cref="IAppender"/> array to copy to.</param>
- public virtual void CopyTo(IAppender[] array)
- {
- this.CopyTo(array, 0);
- }
+ /// <summary>
+ /// Copies the entire <c>AppenderCollection</c> to a one-dimensional
+ /// <see cref="IAppender"/> array.
+ /// </summary>
+ /// <param name="array">The one-dimensional <see cref="IAppender"/> array to copy to.</param>
+ public virtual void CopyTo(IAppender[] array)
+ {
+ this.CopyTo(array, 0);
+ }
- /// <summary>
- /// Copies the entire <c>AppenderCollection</c> to a one-dimensional
- /// <see cref="IAppender"/> array, starting at the specified index of the target array.
- /// </summary>
- /// <param name="array">The one-dimensional <see cref="IAppender"/> array to copy to.</param>
- /// <param name="start">The zero-based index in <paramref name="array"/> at which copying begins.</param>
- public virtual void CopyTo(IAppender[] array, int start)
- {
- if (m_count > array.GetUpperBound(0) + 1 - start)
- {
- throw new System.ArgumentException("Destination array was not long enough.");
- }
-
- Array.Copy(m_array, 0, array, start, m_count);
- }
+ /// <summary>
+ /// Copies the entire <c>AppenderCollection</c> to a one-dimensional
+ /// <see cref="IAppender"/> array, starting at the specified index of the target array.
+ /// </summary>
+ /// <param name="array">The one-dimensional <see cref="IAppender"/> array to copy to.</param>
+ /// <param name="start">The zero-based index in <paramref name="array"/> at which copying begins.</param>
+ public virtual void CopyTo(IAppender[] array, int start)
+ {
+ if (m_count > array.GetUpperBound(0) + 1 - start)
+ {
+ throw new System.ArgumentException("Destination array was not long enough.");
+ }
+
+ Array.Copy(m_array, 0, array, start, m_count);
+ }
- /// <summary>
- /// Gets a value indicating whether access to the collection is synchronized (thread-safe).
- /// </summary>
- /// <returns>false, because the backing type is an array, which is never thread-safe.</returns>
- public virtual bool IsSynchronized
- {
- get { return false; }
- }
+ /// <summary>
+ /// Gets a value indicating whether access to the collection is synchronized (thread-safe).
+ /// </summary>
+ /// <returns>false, because the backing type is an array, which is never thread-safe.</returns>
+ public virtual bool IsSynchronized
+ {
+ get { return false; }
+ }
- /// <summary>
- /// Gets an object that can be used to synchronize access to the collection.
- /// </summary>
- public virtual object SyncRoot
- {
- get { return m_array; }
- }
+ /// <summary>
+ /// Gets an object that can be used to synchronize access to the collection.
+ /// </summary>
+ public virtual object SyncRoot
+ {
+ get { return m_array; }
+ }
- #endregion
-
- #region Operations (type-safe IList)
+ #endregion
+
+ #region Operations (type-safe IList)
- /// <summary>
- /// Gets or sets the <see cref="IAppender"/> at the specified index.
- /// </summary>
- /// <param name="index">The zero-based index of the element to get or set.</param>
- /// <exception cref="ArgumentOutOfRangeException">
- /// <para><paramref name="index"/> is less than zero</para>
- /// <para>-or-</para>
- /// <para><paramref name="index"/> is equal to or greater than <see cref="AppenderCollection.Count"/>.</para>
- /// </exception>
- public virtual IAppender this[int index]
- {
- get
- {
- ValidateIndex(index); // throws
- return m_array[index];
- }
- set
- {
- ValidateIndex(index); // throws
- ++m_version;
- m_array[index] = value;
- }
- }
+ /// <summary>
+ /// Gets or sets the <see cref="IAppender"/> at the specified index.
+ /// </summary>
+ /// <param name="index">The zero-based index of the element to get or set.</param>
+ /// <exception cref="ArgumentOutOfRangeException">
+ /// <para><paramref name="index"/> is less than zero</para>
+ /// <para>-or-</para>
+ /// <para><paramref name="index"/> is equal to or greater than <see cref="AppenderCollection.Count"/>.</para>
+ /// </exception>
+ public virtual IAppender this[int index]
+ {
+ get
+ {
+ ValidateIndex(index); // throws
+ return m_array[index];
+ }
+ set
+ {
+ ValidateIndex(index); // throws
+ ++m_version;
+ m_array[index] = value;
+ }
+ }
- /// <summary>
- /// Adds a <see cref="IAppender"/> to the end of the <c>AppenderCollection</c>.
- /// </summary>
- /// <param name="item">The <see cref="IAppender"/> to be added to the end of the <c>AppenderCollection</c>.</param>
- /// <returns>The index at which the value has been added.</returns>
- public virtual int Add(IAppender item)
- {
- if (m_count == m_array.Length)
- {
- EnsureCapacity(m_count + 1);
- }
+ /// <summary>
+ /// Adds a <see cref="IAppender"/> to the end of the <c>AppenderCollection</c>.
+ /// </summary>
+ /// <param name="item">The <see cref="IAppender"/> to be added to the end of the <c>AppenderCollection</c>.</param>
+ /// <returns>The index at which the value has been added.</returns>
+ public virtual int Add(IAppender item)
+ {
+ if (m_count == m_array.Length)
+ {
+ EnsureCapacity(m_count + 1);
+ }
- m_array[m_count] = item;
- m_version++;
+ m_array[m_count] = item;
+ m_version++;
- return m_count++;
- }
-
- /// <summary>
- /// Removes all elements from the <c>AppenderCollection</c>.
- /// </summary>
- public virtual void Clear()
- {
- ++m_version;
- m_array = new IAppender[DEFAULT_CAPACITY];
- m_count = 0;
- }
-
- /// <summary>
- /// Creates a shallow copy of the <see cref="AppenderCollection"/>.
- /// </summary>
- /// <returns>A new <see cref="AppenderCollection"/> with a shallow copy of the collection data.</returns>
- public virtual object Clone()
- {
- AppenderCollection newCol = new AppenderCollection(m_count);
- Array.Copy(m_array, 0, newCol.m_array, 0, m_count);
- newCol.m_count = m_count;
- newCol.m_version = m_version;
+ return m_count++;
+ }
+
+ /// <summary>
+ /// Removes all elements from the <c>AppenderCollection</c>.
+ /// </summary>
+ public virtual void Clear()
+ {
+ ++m_version;
+ m_array = new IAppender[DEFAULT_CAPACITY];
+ m_count = 0;
+ }
+
+ /// <summary>
+ /// Creates a shallow copy of the <see cref="AppenderCollection"/>.
+ /// </summary>
+ /// <returns>A new <see cref="AppenderCollection"/> with a shallow copy of the collection data.</returns>
+ public virtual object Clone()
+ {
+ AppenderCollection newCol = new AppenderCollection(m_count);
+ Array.Copy(m_array, 0, newCol.m_array, 0, m_count);
+ newCol.m_count = m_count;
+ newCol.m_version = m_version;
- return newCol;
- }
+ return newCol;
+ }
- /// <summary>
- /// Determines whether a given <see cref="IAppender"/> is in the <c>AppenderCollection</c>.
- /// </summary>
- /// <param name="item">The <see cref="IAppender"/> to check for.</param>
- /// <returns><c>true</c> if <paramref name="item"/> is found in the <c>AppenderCollection</c>; otherwise, <c>false</c>.</returns>
- public virtual bool Contains(IAppender item)
- {
- for (int i=0; i != m_count; ++i)
- {
- if (m_array[i].Equals(item))
- {
- return true;
- }
- }
- return false;
- }
+ /// <summary>
+ /// Determines whether a given <see cref="IAppender"/> is in the <c>AppenderCollection</c>.
+ /// </summary>
+ /// <param name="item">The <see cref="IAppender"/> to check for.</param>
+ /// <returns><c>true</c> if <paramref name="item"/> is found in the <c>AppenderCollection</c>; otherwise, <c>false</c>.</returns>
+ public virtual bool Contains(IAppender item)
+ {
+ for (int i=0; i != m_count; ++i)
+ {
+ if (m_array[i].Equals(item))
+ {
+ return true;
+ }
+ }
+ return false;
+ }
- /// <summary>
- /// Returns the zero-based index of the first occurrence of a <see cref="IAppender"/>
- /// in the <c>AppenderCollection</c>.
- /// </summary>
- /// <param name="item">The <see cref="IAppender"/> to locate in the <c>AppenderCollection</c>.</param>
- /// <returns>
- /// The zero-based index of the first occurrence of <paramref name="item"/>
- /// in the entire <c>AppenderCollection</c>, if found; otherwise, -1.
- /// </returns>
- public virtual int IndexOf(IAppender item)
- {
- for (int i=0; i != m_count; ++i)
- {
- if (m_array[i].Equals(item))
- {
- return i;
- }
- }
- return -1;
- }
+ /// <summary>
+ /// Returns the zero-based index of the first occurrence of a <see cref="IAppender"/>
+ /// in the <c>AppenderCollection</c>.
+ /// </summary>
+ /// <param name="item">The <see cref="IAppender"/> to locate in the <c>AppenderCollection</c>.</param>
+ /// <returns>
+ /// The zero-based index of the first occurrence of <paramref name="item"/>
+ /// in the entire <c>AppenderCollection</c>, if found; otherwise, -1.
+ /// </returns>
+ public virtual int IndexOf(IAppender item)
+ {
+ for (int i=0; i != m_count; ++i)
+ {
+ if (m_array[i].Equals(item))
+ {
+ return i;
+ }
+ }
+ return -1;
+ }
- /// <summary>
- /// Inserts an element into the <c>AppenderCollection</c> at the specified index.
- /// </summary>
- /// <param name="index">The zero-based index at which <paramref name="item"/> should be inserted.</param>
- /// <param name="item">The <see cref="IAppender"/> to insert.</param>
- /// <exception cref="ArgumentOutOfRangeException">
- /// <para><paramref name="index"/> is less than zero</para>
- /// <para>-or-</para>
- /// <para><paramref name="index"/> is equal to or greater than <see cref="AppenderCollection.Count"/>.</para>
- /// </exception>
- public virtual void Insert(int index, IAppender item)
- {
- ValidateIndex(index, true); // throws
-
- if (m_count == m_array.Length)
- {
- EnsureCapacity(m_count + 1);
- }
+ /// <summary>
+ /// Inserts an element into the <c>AppenderCollection</c> at the specified index.
+ /// </summary>
+ /// <param name="index">The zero-based index at which <paramref name="item"/> should be inserted.</param>
+ /// <param name="item">The <see cref="IAppender"/> to insert.</param>
+ /// <exception cref="ArgumentOutOfRangeException">
+ /// <para><paramref name="index"/> is less than zero</para>
+ /// <para>-or-</para>
+ /// <para><paramref name="index"/> is equal to or greater than <see cref="AppenderCollection.Count"/>.</para>
+ /// </exception>
+ public virtual void Insert(int index, IAppender item)
+ {
+ ValidateIndex(index, true); // throws
+
+ if (m_count == m_array.Length)
+ {
+ EnsureCapacity(m_count + 1);
+ }
- if (index < m_count)
- {
- Array.Copy(m_array, index, m_array, index + 1, m_count - index);
- }
+ if (index < m_count)
+ {
+ Array.Copy(m_array, index, m_array, index + 1, m_count - index);
+ }
- m_array[index] = item;
- m_count++;
- m_version++;
- }
+ m_array[index] = item;
+ m_count++;
+ m_version++;
+ }
- /// <summary>
- /// Removes the first occurrence of a specific <see cref="IAppender"/> from the <c>AppenderCollection</c>.
- /// </summary>
- /// <param name="item">The <see cref="IAppender"/> to remove from the <c>AppenderCollection</c>.</param>
- /// <exception cref="ArgumentException">
- /// The specified <see cref="IAppender"/> was not found in the <c>AppenderCollection</c>.
- /// </exception>
- public virtual void Remove(IAppender item)
- {
- int i = IndexOf(item);
- if (i < 0)
- {
- throw new System.ArgumentException("Cannot remove the specified item because it was not found in the specified Collection.");
- }
-
- ++m_version;
- RemoveAt(i);
- }
+ /// <summary>
+ /// Removes the first occurrence of a specific <see cref="IAppender"/> from the <c>AppenderCollection</c>.
+ /// </summary>
+ /// <param name="item">The <see cref="IAppender"/> to remove from the <c>AppenderCollection</c>.</param>
+ /// <exception cref="ArgumentException">
+ /// The specified <see cref="IAppender"/> was not found in the <c>AppenderCollection</c>.
+ /// </exception>
+ public virtual void Remove(IAppender item)
+ {
+ int i = IndexOf(item);
+ if (i < 0)
+ {
+ throw new System.ArgumentException("Cannot remove the specified item because it was not found in the specified Collection.");
+ }
+
+ ++m_version;
+ RemoveAt(i);
+ }
- /// <summary>
- /// Removes the element at the specified index of the <c>AppenderCollection</c>.
- /// </summary>
- /// <param name="index">The zero-based index of the element to remove.</param>
- /// <exception cref="ArgumentOutOfRangeException">
- /// <para><paramref name="index"/> is less than zero</para>
- /// <para>-or-</para>
- /// <para><paramref name="index"/> is equal to or greater than <see cref="AppenderCollection.Count"/>.</para>
- /// </exception>
- public virtual void RemoveAt(int index)
- {
- ValidateIndex(index); // throws
-
- m_count--;
+ /// <summary>
+ /// Removes the element at the specified index of the <c>AppenderCollection</c>.
+ /// </summary>
+ /// <param name="index">The zero-based index of the element to remove.</param>
+ /// <exception cref="ArgumentOutOfRangeException">
+ /// <para><paramref name="index"/> is less than zero</para>
+ /// <para>-or-</para>
+ /// <para><paramref name="index"/> is equal to or greater than <see cref="AppenderCollection.Count"/>.</para>
+ /// </exception>
+ public virtual void RemoveAt(int index)
+ {
+ ValidateIndex(index); // throws
+
+ m_count--;
- if (index < m_count)
- {
- Array.Copy(m_array, index + 1, m_array, index, m_count - index);
- }
-
- // We can't set the deleted entry equal to null, because it might be a value type.
- // Instead, we'll create an empty single-element array of the right type and copy it
- // over the entry we want to erase.
- IAppender[] temp = new IAppender[1];
- Array.Copy(temp, 0, m_array, m_count, 1);
- m_version++;
- }
+ if (index < m_count)
+ {
+ Array.Copy(m_array, index + 1, m_array, index, m_count - index);
+ }
+
+ // We can't set the deleted entry equal to null, because it might be a value type.
+ // Instead, we'll create an empty single-element array of the right type and copy it
+ // over the entry we want to erase.
+ IAppender[] temp = new IAppender[1];
+ Array.Copy(temp, 0, m_array, m_count, 1);
+ m_version++;
+ }
- /// <summary>
- /// Gets a value indicating whether the collection has a fixed size.
- /// </summary>
- /// <value>true if the collection has a fixed size; otherwise, false. The default is false</value>
- public virtual bool IsFixedSize
- {
- get { return false; }
- }
+ /// <summary>
+ /// Gets a value indicating whether the collection has a fixed size.
+ /// </summary>
+ /// <value>true if the collection has a fixed size; otherwise, false. The default is false</value>
+ public virtual bool IsFixedSize
+ {
+ get { return false; }
+ }
- /// <summary>
- /// Gets a value indicating whether the IList is read-only.
- /// </summary>
- /// <value>true if the collection is read-only; otherwise, false. The default is false</value>
- public virtual bool IsReadOnly
- {
- get { return false; }
- }
+ /// <summary>
+ /// Gets a value indicating whether the IList is read-only.
+ /// </summary>
+ /// <value>true if the collection is read-only; otherwise, false. The default is false</value>
+ public virtual bool IsReadOnly
+ {
+ get { return false; }
+ }
- #endregion
+ #endregion
- #region Operations (type-safe IEnumerable)
-
- /// <summary>
- /// Returns an enumerator that can iterate through the <c>AppenderCollection</c>.
- /// </summary>
- /// <returns>An <see cref="Enumerator"/> for the entire <c>AppenderCollection</c>.</returns>
- public virtual IAppenderCollectionEnumerator GetEnumerator()
- {
- return new Enumerator(this);
- }
+ #region Operations (type-safe IEnumerable)
+
+ /// <summary>
+ /// Returns an enumerator that can iterate through the <c>AppenderCollection</c>.
+ /// </summary>
+ /// <returns>An <see cref="Enumerator"/> for the entire <c>AppenderCollection</c>.</returns>
+ public virtual IAppenderCollectionEnumerator GetEnumerator()
+ {
+ return new Enumerator(this);
+ }
- #endregion
+ #endregion
- #region Public helpers (just to mimic some nice features of ArrayList)
-
- /// <summary>
- /// Gets or sets the number of elements the <c>AppenderCollection</c> can contain.
- /// </summary>
- public virtual int Capacity
- {
- get
- {
- return m_array.Length;
- }
- set
- {
- if (value < m_count)
- {
- value = m_count;
- }
+ #region Public helpers (just to mimic some nice features of ArrayList)
+
+ /// <summary>
+ /// Gets or sets the number of elements the <c>AppenderCollection</c> can contain.
+ /// </summary>
+ public virtual int Capacity
+ {
+ get
+ {
+ return m_array.Length;
+ }
+ set
+ {
+ if (value < m_count)
+ {
+ value = m_count;
+ }
- if (value != m_array.Length)
- {
- if (value > 0)
- {
- IAppender[] temp = new IAppender[value];
- Array.Copy(m_array, 0, temp, 0, m_count);
- m_array = temp;
- }
- else
- {
- m_array = new IAppender[DEFAULT_CAPACITY];
- }
- }
- }
- }
+ if (value != m_array.Length)
+ {
+ if (value > 0)
+ {
+ IAppender[] temp = new IAppender[value];
+ Array.Copy(m_array, 0, temp, 0, m_count);
+ m_array = temp;
+ }
+ else
+ {
+ m_array = new IAppender[DEFAULT_CAPACITY];
+ }
+ }
+ }
+ }
- /// <summary>
- /// Adds the elements of another <c>AppenderCollection</c> to the current <c>AppenderCollection</c>.
- /// </summary>
- /// <param name="x">The <c>AppenderCollection</c> whose elements should be added to the end of the current <c>AppenderCollection</c>.</param>
- /// <returns>The new <see cref="AppenderCollection.Count"/> of the <c>AppenderCollection</c>.</returns>
- public virtual int AddRange(AppenderCollection x)
- {
- if (m_count + x.Count >= m_array.Length)
- {
- EnsureCapacity(m_count + x.Count);
- }
-
- Array.Copy(x.m_array, 0, m_array, m_count, x.Count);
- m_count += x.Count;
- m_version++;
+ /// <summary>
+ /// Adds the elements of another <c>AppenderCollection</c> to the current <c>AppenderCollection</c>.
+ /// </summary>
+ /// <param name="x">The <c>AppenderCollection</c> whose elements should be added to the end of the current <c>AppenderCollection</c>.</param>
+ /// <returns>The new <see cref="AppenderCollection.Count"/> of the <c>AppenderCollection</c>.</returns>
+ public virtual int AddRange(AppenderCollection x)
+ {
+ if (m_count + x.Count >= m_array.Length)
+ {
+ EnsureCapacity(m_count + x.Count);
+ }
+
+ Array.Copy(x.m_array, 0, m_array, m_count, x.Count);
+ m_count += x.Count;
+ m_version++;
- return m_count;
- }
+ return m_count;
+ }
- /// <summary>
- /// Adds the elements of a <see cref="IAppender"/> array to the current <c>AppenderCollection</c>.
- /// </summary>
- /// <param name="x">The <see cref="IAppender"/> array whose elements should be added to the end of the <c>AppenderCollection</c>.</param>
- /// <returns>The new <see cref="AppenderCollection.Count"/> of the <c>AppenderCollection</c>.</returns>
- public virtual int AddRange(IAppender[] x)
- {
- if (m_count + x.Length >= m_array.Length)
- {
- EnsureCapacity(m_count + x.Length);
- }
+ /// <summary>
+ /// Adds the elements of a <see cref="IAppender"/> array to the current <c>AppenderCollection</c>.
+ /// </summary>
+ /// <param name="x">The <see cref="IAppender"/> array whose elements should be added to the end of the <c>AppenderCollection</c>.</param>
+ /// <returns>The new <see cref="AppenderCollection.Count"/> of the <c>AppenderCollection</c>.</returns>
+ public virtual int AddRange(IAppender[] x)
+ {
+ if (m_count + x.Length >= m_array.Length)
+ {
+ EnsureCapacity(m_count + x.Length);
+ }
- Array.Copy(x, 0, m_array, m_count, x.Length);
- m_count += x.Length;
- m_version++;
+ Array.Copy(x, 0, m_array, m_count, x.Length);
+ m_count += x.Length;
+ m_version++;
- return m_count;
- }
-
- /// <summary>
- /// Adds the elements of a <see cref="IAppender"/> collection to the current <c>AppenderCollection</c>.
- /// </summary>
- /// <param name="col">The <see cref="IAppender"/> collection whose elements should be added to the end of the <c>AppenderCollection</c>.</param>
- /// <returns>The new <see cref="AppenderCollection.Count"/> of the <c>AppenderCollection</c>.</returns>
- public virtual int AddRange(ICollection col)
- {
- if (m_count + col.Count >= m_array.Length)
- {
- EnsureCapacity(m_count + col.Count);
- }
+ return m_count;
+ }
+
+ /// <summary>
+ /// Adds the elements of a <see cref="IAppender"/> collection to the current <c>AppenderCollection</c>.
+ /// </summary>
+ /// <param name="col">The <see cref="IAppender"/> collection whose elements should be added to the end of the <c>AppenderCollection</c>.</param>
+ /// <returns>The new <see cref="AppenderCollection.Count"/> of the <c>AppenderCollection</c>.</returns>
+ public virtual int AddRange(ICollection col)
+ {
+ if (m_count + col.Count >= m_array.Length)
+ {
+ EnsureCapacity(m_count + col.Count);
+ }
- foreach(object item in col)
- {
- Add((IAppender)item);
- }
+ foreach(object item in col)
+ {
+ Add((IAppender)item);
+ }
- return m_count;
- }
+ return m_count;
+ }
- /// <summary>
- /// Sets the capacity to the actual number of elements.
- /// </summary>
- public virtual void TrimToSize()
- {
- this.Capacity = m_count;
- }
+ /// <summary>
+ /// Sets the capacity to the actual number of elements.
+ /// </summary>
+ public virtual void TrimToSize()
+ {
+ this.Capacity = m_count;
+ }
- /// <summary>
- /// Return the collection elements as an array
- /// </summary>
- /// <returns>the array</returns>
- public virtual IAppender[] ToArray()
- {
- IAppender[] resultArray = new IAppender[m_count];
- if (m_count > 0)
- {
- Array.Copy(m_array, 0, resultArray, 0, m_count);
- }
- return resultArray;
- }
+ /// <summary>
+ /// Return the collection elements as an array
+ /// </summary>
+ /// <returns>the array</returns>
+ public virtual IAppender[] ToArray()
+ {
+ IAppender[] resultArray = new IAppender[m_count];
+ if (m_count > 0)
+ {
+ Array.Copy(m_array, 0, resultArray, 0, m_count);
+ }
+ return resultArray;
+ }
- #endregion
+ #endregion
- #region Implementation (helpers)
+ #region Implementation (helpers)
- /// <exception cref="ArgumentOutOfRangeException">
- /// <para><paramref name="i"/> is less than zero</para>
- /// <para>-or-</para>
- /// <para><paramref name="i"/> is equal to or greater than <see cref="AppenderCollection.Count"/>.</para>
- /// </exception>
- private void ValidateIndex(int i)
- {
- ValidateIndex(i, false);
- }
+ /// <exception cref="ArgumentOutOfRangeException">
+ /// <para><paramref name="i"/> is less than zero</para>
+ /// <para>-or-</para>
+ /// <para><paramref name="i"/> is equal to or greater than <see cref="AppenderCollection.Count"/>.</para>
+ /// </exception>
+ private void ValidateIndex(int i)
+ {
+ ValidateIndex(i, false);
+ }
- /// <exception cref="ArgumentOutOfRangeException">
- /// <para><paramref name="i"/> is less than zero</para>
- /// <para>-or-</para>
- /// <para><paramref name="i"/> is equal to or greater than <see cref="AppenderCollection.Count"/>.</para>
- /// </exception>
- private void ValidateIndex(int i, bool allowEqualEnd)
- {
- int max = (allowEqualEnd) ? (m_count) : (m_count-1);
- if (i < 0 || i > max)
- {
- throw log4net.Util.SystemInfo.CreateArgumentOutOfRangeException("i", (object)i, "Index was out of range. Must be non-negative and less than the size of the collection. [" + (object)i + "] Specified argument was out of the range of valid values.");
- }
- }
+ /// <exception cref="ArgumentOutOfRangeException">
+ /// <para><paramref name="i"/> is less than zero</para>
+ /// <para>-or-</para>
+ /// <para><paramref name="i"/> is equal to or greater than <see cref="AppenderCollection.Count"/>.</para>
+ /// </exception>
+ private void ValidateIndex(int i, bool allowEqualEnd)
+ {
+ int max = (allowEqualEnd) ? (m_count) : (m_count-1);
+ if (i < 0 || i > max)
+ {
+ throw log4net.Util.SystemInfo.CreateArgumentOutOfRangeException("i", (object)i, "Index was out of range. Must be non-negative and less than the size of the collection. [" + (object)i + "] Specified argument was out of the range of valid values.");
+ }
+ }
- private void EnsureCapacity(int min)
- {
- int newCapacity = ((m_array.Length == 0) ? DEFAULT_CAPACITY : m_array.Length * 2);
- if (newCapacity < min)
- {
- newCapacity = min;
- }
+ private void EnsureCapacity(int min)
+ {
+ int newCapacity = ((m_array.Length == 0) ? DEFAULT_CAPACITY : m_array.Length * 2);
+ if (newCapacity < min)
+ {
+ newCapacity = min;
+ }
- this.Capacity = newCapacity;
- }
+ this.Capacity = newCapacity;
+ }
- #endregion
-
- #region Implementation (ICollection)
+ #endregion
+
+ #region Implementation (ICollection)
- void ICollection.CopyTo(Array array, int start)
- {
- if (m_count > 0)
- {
- Array.Copy(m_array, 0, array, start, m_count);
- }
- }
+ void ICollection.CopyTo(Array array, int start)
+ {
+ if (m_count > 0)
+ {
+ Array.Copy(m_array, 0, array, start, m_count);
+ }
+ }
- #endregion
+ #endregion
- #region Implementation (IList)
+ #region Implementation (IList)
- object IList.this[int i]
- {
- get { return (object)this[i]; }
- set { this[i] = (IAppender)value; }
- }
+ object IList.this[int i]
+ {
+ get { return (object)this[i]; }
+ set { this[i] = (IAppender)value; }
+ }
- int IList.Add(object x)
- {
- return this.Add((IAppender)x);
- }
+ int IList.Add(object x)
+ {
+ return this.Add((IAppender)x);
+ }
- bool IList.Contains(object x)
- {
- return this.Contains((IAppender)x);
- }
+ bool IList.Contains(object x)
+ {
+ return this.Contains((IAppender)x);
+ }
- int IList.IndexOf(object x)
- {
- return this.IndexOf((IAppender)x);
- }
+ int IList.IndexOf(object x)
+ {
+ return this.IndexOf((IAppender)x);
+ }
- void IList.Insert(int pos, object x)
- {
- this.Insert(pos, (IAppender)x);
- }
+ void IList.Insert(int pos, object x)
+ {
+ this.Insert(pos, (IAppender)x);
+ }
- void IList.Remove(object x)
- {
- this.Remove((IAppender)x);
- }
+ void IList.Remove(object x)
+ {
+ this.Remove((IAppender)x);
+ }
- void IList.RemoveAt(int pos)
- {
- this.RemoveAt(pos);
- }
+ void IList.RemoveAt(int pos)
+ {
+ this.RemoveAt(pos);
+ }
- #endregion
+ #endregion
- #region Implementation (IEnumerable)
+ #region Implementation (IEnumerable)
- IEnumerator IEnumerable.GetEnumerator()
- {
- return (IEnumerator)(this.GetEnumerator());
- }
+ IEnumerator IEnumerable.GetEnumerator()
+ {
+ return (IEnumerator)(this.GetEnumerator());
+ }
- #endregion
+ #endregion
- #region Nested enumerator class
+ #region Nested enumerator class
- /// <summary>
- /// Supports simple iteration over a <see cref="AppenderCollection"/>.
- /// </summary>
- /// <exclude/>
- private sealed class Enumerator : IEnumerator, IAppenderCollectionEnumerator
- {
- #region Implementation (data)
-
- private readonly AppenderCollection m_collection;
- private int m_index;
- private int m_version;
-
- #endregion
-
- #region Construction
-
- /// <summary>
- /// Initializes a new instance of the <c>Enumerator</c> class.
- /// </summary>
- /// <param name="tc"></param>
- internal Enumerator(AppenderCollection tc)
- {
- m_collection = tc;
- m_index = -1;
- m_version = tc.m_version;
- }
-
- #endregion
-
- #region Operations (type-safe IEnumerator)
-
- /// <summary>
- /// Gets the current element in the collection.
- /// </summary>
- public IAppender Current
- {
- get { return m_collection[m_index]; }
- }
+ /// <summary>
+ /// Supports simple iteration over a <see cref="AppenderCollection"/>.
+ /// </summary>
+ /// <exclude/>
+ private sealed class Enumerator : IEnumerator, IAppenderCollectionEnumerator
+ {
+ #region Implementation (data)
+
+ private readonly AppenderCollection m_collection;
+ private int m_index;
+ private int m_version;
+
+ #endregion
+
+ #region Construction
+
+ /// <summary>
+ /// Initializes a new instance of the <c>Enumerator</c> class.
+ /// </summary>
+ /// <param name="tc"></param>
+ internal Enumerator(AppenderCollection tc)
+ {
+ m_collection = tc;
+ m_index = -1;
+ m_version = tc.m_version;
+ }
+
+ #endregion
+
+ #region Operations (type-safe IEnumerator)
+
+ /// <summary>
+ /// Gets the current element in the collection.
+ /// </summary>
+ public IAppender Current
+ {
+ get { return m_collection[m_index]; }
+ }
- /// <summary>
- /// Advances the enumerator to the next element in the collection.
- /// </summary>
- /// <returns>
- /// <c>true</c> if the enumerator was successfully advanced to the next element;
- /// <c>false</c> if the enumerator has passed the end of the collection.
- /// </returns>
- /// <exception cref="InvalidOperationException">
- /// The collection was modified after the enumerator was created.
- /// </exception>
- public bool MoveNext()
- {
- if (m_version != m_collection.m_version)
- {
- throw new System.InvalidOperationException("Collection was modified; enumeration operation may not execute.");
- }
+ /// <summary>
+ /// Advances the enumerator to the next element in the collection.
+ /// </summary>
+ /// <returns>
+ /// <c>true</c> if the enumerator was successfully advanced to the next element;
+ /// <c>false</c> if the enumerator has passed the end of the collection.
+ /// </returns>
+ /// <exception cref="InvalidOperationException">
+ /// The collection was modified after the enumerator was created.
+ /// </exception>
+ public bool MoveNext()
+ {
+ if (m_version != m_collection.m_version)
+ {
+ throw new System.InvalidOperationException("Collection was modified; enumeration operation may not execute.");
+ }
- ++m_index;
- return (m_index < m_collection.Count);
- }
+ ++m_index;
+ return (m_index < m_collection.Count);
+ }
- /// <summary>
- /// Sets the enumerator to its initial position, before the first element in the collection.
- /// </summary>
- public void Reset()
- {
- m_index = -1;
- }
- #endregion
-
- #region Implementation (IEnumerator)
-
- object IEnumerator.Current
- {
- get { return this.Current; }
- }
-
- #endregion
- }
+ /// <summary>
+ /// Sets the enumerator to its initial position, before the first element in the collection.
+ /// </summary>
+ public void Reset()
+ {
+ m_index = -1;
+ }
+ #endregion
+
+ #region Implementation (IEnumerator)
+
+ object IEnumerator.Current
+ {
+ get { return this.Current; }
+ }
+
+ #endregion
+ }
- #endregion
+ #endregion
- #region Nested Read Only Wrapper class
+ #region Nested Read Only Wrapper class
- /// <exclude/>
- private sealed class ReadOnlyAppenderCollection : AppenderCollection, ICollection
- {
- #region Implementation (data)
+ /// <exclude/>
+ private sealed class ReadOnlyAppenderCollection : AppenderCollection, ICollection
+ {
+ #region Implementation (data)
- private readonly AppenderCollection m_collection;
+ private readonly AppenderCollection m_collection;
- #endregion
+ #endregion
- #region Construction
+ #region Construction
- internal ReadOnlyAppenderCollection(AppenderCollection list) : base(Tag.Default)
- {
- m_collection = list;
- }
+ internal ReadOnlyAppenderCollection(AppenderCollection list) : base(Tag.Default)
+ {
+ m_collection = list;
+ }
- #endregion
+ #endregion
- #region Type-safe ICollection
+ #region Type-safe ICollection
- public override void CopyTo(IAppender[] array)
- {
- m_collection.CopyTo(array);
- }
+ public override void CopyTo(IAppender[] array)
+ {
+ m_collection.CopyTo(array);
+ }
- public override void CopyTo(IAppender[] array, int start)
- {
- m_collection.CopyTo(array,start);
- }
+ public override void CopyTo(IAppender[] array, int start)
+ {
+ m_collection.CopyTo(array,start);
+ }
- void ICollection.CopyTo(Array array, int start)
- {
- ((ICollection)m_collection).CopyTo(array, start);
- }
+ void ICollection.CopyTo(Array array, int start)
+ {
+ ((ICollection)m_collection).CopyTo(array, start);
+ }
- public override int Count
- {
- get { return m_collection.Count; }
- }
+ public override int Count
+ {
+ get { return m_collection.Count; }
+ }
- public override bool IsSynchronized
- {
- get { return m_collection.IsSynchronized; }
- }
+ public override bool IsSynchronized
+ {
+ get { return m_collection.IsSynchronized; }
+ }
- public override object SyncRoot
- {
- get { return this.m_collection.SyncRoot; }
- }
+ public override object SyncRoot
+ {
+ get { return this.m_collection.SyncRoot; }
+ }
- #endregion
+ #endregion
- #region Type-safe IList
+ #region Type-safe IList
- public override IAppender this[int i]
- {
- get { return m_collection[i]; }
- set { throw new NotSupportedException("This is a Read Only Collection and can not be modified"); }
- }
+ public override IAppender this[int i]
+ {
+ get { return m_collection[i]; }
+ set { throw new NotSupportedException("This is a Read Only Collection and can not be modified"); }
+ }
- public override int Add(IAppender x)
- {
- throw new NotSupportedException("This is a Read Only Collection and can not be modified");
- }
+ public override int Add(IAppender x)
+ {
+ throw new NotSupportedException("This is a Read Only Collection and can not be modified");
+ }
- public override void Clear()
- {
- throw new NotSupportedException("This is a Read Only Collection and can not be modified");
- }
+ public override void Clear()
+ {
+ throw new NotSupportedException("This is a Read Only Collection and can not be modified");
+ }
- public override bool Contains(IAppender x)
- {
- return m_collection.Contains(x);
- }
+ public override bool Contains(IAppender x)
+ {
+ return m_collection.Contains(x);
+ }
- public override int IndexOf(IAppender x)
- {
- return m_collection.IndexOf(x);
- }
+ public override int IndexOf(IAppender x)
+ {
+ return m_collection.IndexOf(x);
+ }
- public override void Insert(int pos, IAppender x)
- {
- throw new NotSupportedException("This is a Read Only Collection and can not be modified");
- }
+ public override void Insert(int pos, IAppender x)
+ {
+ throw new NotSupportedException("This is a Read Only Collection and can not be modified");
+ }
- public override void Remove(IAppender x)
- {
- throw new NotSupportedException("This is a Read Only Collection and can not be modified");
- }
+ public override void Remove(IAppender x)
+ {
+ throw new NotSupportedException("This is a Read Only Collection and can not be modified");
+ }
- public override void RemoveAt(int pos)
- {
- throw new NotSupportedException("This is a Read Only Collection and can not be modified");
- }
+ public override void RemoveAt(int pos)
+ {
+ throw new NotSupportedException("This is a Read Only Collection and can not be modified");
+ }
- public override bool IsFixedSize
- {
- get { return true; }
- }
+ public override bool IsFixedSize
+ {
+ get { return true; }
+ }
- public override bool IsReadOnly
- {
- get { return true; }
- }
+ public override bool IsReadOnly
+ {
+ get { return true; }
+ }
- #endregion
+ #endregion
- #region Type-safe IEnumerable
+ #region Type-safe IEnumerable
- public override IAppenderCollectionEnumerator GetEnumerator()
- {
- return m_collection.GetEnumerator();
- }
+ public override IAppenderCollectionEnumerator GetEnumerator()
+ {
+ return m_collection.GetEnumerator();
+ }
- #endregion
+ #endregion
- #region Public Helpers
+ #region Public Helpers
- // (just to mimic some nice features of ArrayList)
- public override int Capacity
- {
- get { return m_collection.Capacity; }
- set { throw new NotSupportedException("This is a Read Only Collection and can not be modified"); }
- }
+ // (just to mimic some nice features of ArrayList)
+ public override int Capacity
+ {
+ get { return m_collection.Capacity; }
+ set { throw new NotSupportedException("This is a Read Only Collection and can not be modified"); }
+ }
- public override int AddRange(AppenderCollection x)
- {
- throw new NotSupportedException("This is a Read Only Collection and can not be modified");
- }
+ public override int AddRange(AppenderCollection x)
+ {
+ throw new NotSupportedException("This is a Read Only Collection and can not be modified");
+ }
- public override int AddRange(IAppender[] x)
- {
- throw new NotSupportedException("This is a Read Only Collection and can not be modified");
- }
+ public override int AddRange(IAppender[] x)
+ {
+ throw new NotSupportedException("This is a Read Only Collection and can not be modified");
+ }
- public override IAppender[] ToArray()
- {
- return m_collection.ToArray();
- }
+ public override IAppender[] ToArray()
+ {
+ return m_collection.ToArray();
+ }
- public override void TrimToSize()
- {
- throw new NotSupportedException("This is a Read Only Collection and can not be modified");
- }
+ public override void TrimToSize()
+ {
+ throw new NotSupportedException("This is a Read Only Collection and can not be modified");
+ }
- #endregion
- }
+ #endregion
+ }
- #endregion
- }
+ #endregion
+ }
}
diff --git a/src/log4net/Appender/AppenderSkeleton.cs b/src/log4net/Appender/AppenderSkeleton.cs
index 44b68c7..0ababc3 100644
--- a/src/log4net/Appender/AppenderSkeleton.cs
+++ b/src/log4net/Appender/AppenderSkeleton.cs
@@ -28,674 +28,674 @@
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>
+ /// 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);
- }
+ /// <summary>
+ /// Default constructor
+ /// </summary>
+ /// <remarks>
+ /// <para>Empty default constructor</para>
+ /// </remarks>
+ protected AppenderSkeleton()
+ {
+ m_errorHandler = new OnlyOnceErrorHandler(this.GetType().Name);
+ }
- #endregion Protected Instance Constructors
+ #endregion Protected Instance Constructors
- #region Finalizer
+ #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();
- }
- }
+ /// <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
+ #endregion Finalizer
- #region Public Instance Properties
+ #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 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>
- public virtual 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>
+ /// 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>
+ public virtual 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>
- public virtual IFilter FilterHead
- {
- get { return m_headFilter; }
- }
+ /// <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>
+ public virtual 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"/>
- public virtual ILayout Layout
- {
- get { return m_layout; }
- set { m_layout = value; }
- }
+ /// <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"/>
+ public virtual ILayout Layout
+ {
+ get { return m_layout; }
+ set { m_layout = value; }
+ }
- #endregion
+ #endregion
- #region Implementation of IOptionHandler
+ #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>
- public virtual void ActivateOptions()
- {
- }
+ /// <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>
+ public virtual void ActivateOptions()
+ {
+ }
- #endregion Implementation of IOptionHandler
+ #endregion Implementation of IOptionHandler
- #region Implementation of IAppender
+ #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>
+ /// 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>
+ /// 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).
+ /// <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;
- }
+ lock(this)
+ {
+ if (m_closed)
+ {
+ ErrorHandler.Error("Attempted to append to closed appender named ["+m_name+"].");
+ return;
+ }
- // prevent re-entry
- if (m_recursiveGuard)
- {
- return;
- }
+ // prevent re-entry
+ if (m_recursiveGuard)
+ {
+ return;
+ }
- try
- {
- m_recursiveGuard = true;
+ try
+ {
+ m_recursiveGuard = true;
- if (FilterEvent(loggingEvent) && PreAppendCheck())
- {
- this.Append(loggingEvent);
- }
- }
- catch(Exception ex)
- {
- ErrorHandler.Error("Failed in DoAppend", ex);
- }
+ if (FilterEvent(loggingEvent) && PreAppendCheck())
+ {
+ this.Append(loggingEvent);
+ }
+ }
+ catch(Exception ex)
+ {
+ ErrorHandler.Error("Failed in DoAppend", ex);
+ }
#if !MONO && !NET_2_0 && !NETSTANDARD
- // 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)");
- }
+ // 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;
- }
- }
- }
+ finally
+ {
+ m_recursiveGuard = false;
+ }
+ }
+ }
- #endregion Implementation of IAppender
+ #endregion Implementation of IAppender
- #region Implementation of IBulkAppender
+ #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).
+ /// <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;
- }
+ lock(this)
+ {
+ if (m_closed)
+ {
+ ErrorHandler.Error("Attempted to append to closed appender named ["+m_name+"].");
+ return;
+ }
- // prevent re-entry
- if (m_recursiveGuard)
- {
- return;
- }
+ // prevent re-entry
+ if (m_recursiveGuard)
+ {
+ return;
+ }
- try
- {
- m_recursiveGuard = true;
+ try
+ {
+ m_recursiveGuard = true;
- ArrayList filteredEvents = new ArrayList(loggingEvents.Length);
+ ArrayList filteredEvents = new ArrayList(loggingEvents.Length);
- foreach(LoggingEvent loggingEvent in loggingEvents)
- {
- if (FilterEvent(loggingEvent))
- {
- filteredEvents.Add(loggingEvent);
- }
- }
+ 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 (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 && !NETSTANDARD
- // 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)");
- }
+ // 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;
- }
- }
- }
+ finally
+ {
+ m_recursiveGuard = false;
+ }
+ }
+ }
- #endregion Implementation of IBulkAppender
+ #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>
- protected virtual bool FilterEvent(LoggingEvent loggingEvent)
- {
- if (!IsAsSevereAsThreshold(loggingEvent.Level))
- {
- return false;
- }
+ /// <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>
+ protected virtual bool FilterEvent(LoggingEvent loggingEvent)
+ {
+ if (!IsAsSevereAsThreshold(loggingEvent.Level))
+ {
+ return false;
+ }
- IFilter f = this.FilterHead;
+ IFilter f = this.FilterHead;
- while(f != null)
- {
- switch(f.Decide(loggingEvent))
- {
- case FilterDecision.Deny:
- return false; // Return without appending
+ 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.Accept:
+ f = null; // Break out of the loop
+ break;
- case FilterDecision.Neutral:
- f = f.Next; // Move to next filter
- break;
- }
- }
+ case FilterDecision.Neutral:
+ f = f.Next; // Move to next filter
+ break;
+ }
+ }
- return true;
- }
+ return true;
+ }
- #region Public Instance Methods
+ #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>
- public virtual void AddFilter(IFilter filter)
- {
- if (filter == null)
- {
- throw new ArgumentNullException("filter param must not be null");
- }
+ /// <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>
+ public virtual 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;
- }
- }
+ 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>
- public virtual void ClearFilters()
- {
- m_headFilter = m_tailFilter = null;
- }
+ /// <summary>
+ /// Clears the filter list for this appender.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Clears the filter list for this appender.
+ /// </para>
+ /// </remarks>
+ public virtual void ClearFilters()
+ {
+ m_headFilter = m_tailFilter = null;
+ }
- #endregion Public Instance Methods
+ #endregion Public Instance Methods
- #region Protected 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>
- protected virtual bool IsAsSevereAsThreshold(Level level)
- {
- return ((m_threshold == null) || level >= m_threshold);
- }
+ /// <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>
+ protected virtual 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>
- protected virtual void OnClose()
- {
- // Do nothing by default
- }
+ /// <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>
+ protected virtual 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>
- protected abstract void Append(LoggingEvent loggingEvent);
+ /// <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>
+ protected abstract 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>
- protected virtual void Append(LoggingEvent[] loggingEvents)
- {
- foreach(LoggingEvent loggingEvent in loggingEvents)
- {
- Append(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>
+ protected virtual 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>
- protected virtual bool PreAppendCheck()
- {
- if ((m_layout == null) && RequiresLayout)
- {
- ErrorHandler.Error("AppenderSkeleton: No layout set for the appender named ["+m_name+"].");
- return false;
- }
+ /// <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>
+ protected virtual bool PreAppendCheck()
+ {
+ if ((m_layout == null) && RequiresLayout)
+ {
+ ErrorHandler.Error("AppenderSkeleton: No layout set for the appender named ["+m_name+"].");
+ return false;
+ }
- return true;
- }
+ 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);
- }
+ /// <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)
{
@@ -705,205 +705,205 @@
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");
- }
+ /// <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);
- }
- }
+ 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>
- protected virtual bool RequiresLayout
- {
- get { return false; }
- }
+ /// <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>
+ protected virtual bool RequiresLayout
+ {
+ get { return false; }
+ }
- #endregion
+ #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;
- }
+ /// <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
+ #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 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 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>
+ /// 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>
+ /// 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 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>
+ /// 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>
+ /// 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>
+ /// 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;
+ /// <summary>
+ /// StringWriter used to render events
+ /// </summary>
+ private ReusableStringWriter m_renderWriter = null;
- #endregion Private Instance Fields
+ #endregion Private Instance Fields
- #region Constants
+ #region Constants
- /// <summary>
- /// Initial buffer size
- /// </summary>
- private const int c_renderBufferSize = 256;
+ /// <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;
+ /// <summary>
+ /// Maximum buffer size before it is recycled
+ /// </summary>
+ private const int c_renderBufferMaxCapacity = 1024;
- #endregion
+ #endregion
- #region Private Static Fields
+ #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 static readonly Type declaringType = typeof(AppenderSkeleton);
+ /// <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 static readonly Type declaringType = typeof(AppenderSkeleton);
- #endregion Private Static Fields
- }
+ #endregion Private Static Fields
+ }
}
diff --git a/src/log4net/Appender/AspNetTraceAppender.cs b/src/log4net/Appender/AspNetTraceAppender.cs
index bffa045..addd4c1 100644
--- a/src/log4net/Appender/AspNetTraceAppender.cs
+++ b/src/log4net/Appender/AspNetTraceAppender.cs
@@ -29,97 +29,97 @@
namespace log4net.Appender
{
- /// <summary>
- /// <para>
- /// Appends log events to the ASP.NET <see cref="TraceContext"/> system.
- /// </para>
- /// </summary>
- /// <remarks>
- /// <para>
- /// Diagnostic information and tracing messages that you specify are appended to the output
- /// of the page that is sent to the requesting browser. Optionally, you can view this information
- /// from a separate trace viewer (Trace.axd) that displays trace information for every page in a
- /// given application.
- /// </para>
- /// <para>
- /// Trace statements are processed and displayed only when tracing is enabled. You can control
- /// whether tracing is displayed to a page, to the trace viewer, or both.
- /// </para>
- /// <para>
- /// The logging event is passed to the <see cref="M:TraceContext.Write(string)"/> or
- /// <see cref="M:TraceContext.Warn(string)"/> method depending on the level of the logging event.
+ /// <summary>
+ /// <para>
+ /// Appends log events to the ASP.NET <see cref="TraceContext"/> system.
+ /// </para>
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Diagnostic information and tracing messages that you specify are appended to the output
+ /// of the page that is sent to the requesting browser. Optionally, you can view this information
+ /// from a separate trace viewer (Trace.axd) that displays trace information for every page in a
+ /// given application.
+ /// </para>
+ /// <para>
+ /// Trace statements are processed and displayed only when tracing is enabled. You can control
+ /// whether tracing is displayed to a page, to the trace viewer, or both.
+ /// </para>
+ /// <para>
+ /// The logging event is passed to the <see cref="M:TraceContext.Write(string)"/> or
+ /// <see cref="M:TraceContext.Warn(string)"/> method depending on the level of the logging event.
/// The event's logger name is the default value for the category parameter of the Write/Warn method.
- /// </para>
- /// </remarks>
- /// <author>Nicko Cadell</author>
- /// <author>Gert Driesen</author>
- /// <author>Ron Grabowski</author>
- public class AspNetTraceAppender : AppenderSkeleton
- {
- #region Public Instances Constructors
+ /// </para>
+ /// </remarks>
+ /// <author>Nicko Cadell</author>
+ /// <author>Gert Driesen</author>
+ /// <author>Ron Grabowski</author>
+ public class AspNetTraceAppender : AppenderSkeleton
+ {
+ #region Public Instances Constructors
- /// <summary>
- /// Initializes a new instance of the <see cref="AspNetTraceAppender" /> class.
- /// </summary>
- /// <remarks>
- /// <para>
- /// Default constructor.
- /// </para>
- /// </remarks>
- public AspNetTraceAppender()
- {
- }
+ /// <summary>
+ /// Initializes a new instance of the <see cref="AspNetTraceAppender" /> class.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Default constructor.
+ /// </para>
+ /// </remarks>
+ public AspNetTraceAppender()
+ {
+ }
- #endregion // Public Instances Constructors
+ #endregion // Public Instances Constructors
- #region Override implementation of AppenderSkeleton
+ #region Override implementation of AppenderSkeleton
- /// <summary>
- /// Write the logging event to the ASP.NET trace
- /// </summary>
- /// <param name="loggingEvent">the event to log</param>
- /// <remarks>
- /// <para>
- /// Write the logging event to the ASP.NET trace
- /// <c>HttpContext.Current.Trace</c>
- /// (<see cref="TraceContext"/>).
- /// </para>
- /// </remarks>
- protected override void Append(LoggingEvent loggingEvent)
- {
- // check if log4net is running in the context of an ASP.NET application
- if (HttpContext.Current != null)
- {
- // check if tracing is enabled for the current context
- if (HttpContext.Current.Trace.IsEnabled)
- {
- if (loggingEvent.Level >= Level.Warn)
- {
+ /// <summary>
+ /// Write the logging event to the ASP.NET trace
+ /// </summary>
+ /// <param name="loggingEvent">the event to log</param>
+ /// <remarks>
+ /// <para>
+ /// Write the logging event to the ASP.NET trace
+ /// <c>HttpContext.Current.Trace</c>
+ /// (<see cref="TraceContext"/>).
+ /// </para>
+ /// </remarks>
+ protected override void Append(LoggingEvent loggingEvent)
+ {
+ // check if log4net is running in the context of an ASP.NET application
+ if (HttpContext.Current != null)
+ {
+ // check if tracing is enabled for the current context
+ if (HttpContext.Current.Trace.IsEnabled)
+ {
+ if (loggingEvent.Level >= Level.Warn)
+ {
HttpContext.Current.Trace.Warn(m_category.Format(loggingEvent), RenderLoggingEvent(loggingEvent));
- }
- else
- {
+ }
+ else
+ {
HttpContext.Current.Trace.Write(m_category.Format(loggingEvent), RenderLoggingEvent(loggingEvent));
- }
- }
- }
- }
+ }
+ }
+ }
+ }
- /// <summary>
- /// This appender requires a <see cref="Layout"/> to be set.
- /// </summary>
- /// <value><c>true</c></value>
- /// <remarks>
- /// <para>
- /// This appender requires a <see cref="Layout"/> to be set.
- /// </para>
- /// </remarks>
- protected override bool RequiresLayout
- {
- get { return true; }
- }
+ /// <summary>
+ /// This appender requires a <see cref="Layout"/> to be set.
+ /// </summary>
+ /// <value><c>true</c></value>
+ /// <remarks>
+ /// <para>
+ /// This appender requires a <see cref="Layout"/> to be set.
+ /// </para>
+ /// </remarks>
+ protected override bool RequiresLayout
+ {
+ get { return true; }
+ }
- #endregion // Override implementation of AppenderSkeleton
+ #endregion // Override implementation of AppenderSkeleton
#region Public Instance Properties
@@ -140,17 +140,17 @@
set { m_category = value; }
}
- #endregion
+ #endregion
- #region Private Instance Fields
+ #region Private Instance Fields
- /// <summary>
- /// Defaults to %logger
- /// </summary>
- private PatternLayout m_category = new PatternLayout("%logger");
+ /// <summary>
+ /// Defaults to %logger
+ /// </summary>
+ private PatternLayout m_category = new PatternLayout("%logger");
- #endregion
- }
+ #endregion
+ }
}
#endif // !NETCF && !SSCLI
diff --git a/src/log4net/Appender/BufferingAppenderSkeleton.cs b/src/log4net/Appender/BufferingAppenderSkeleton.cs
index c49d838..e8f8e49 100644
--- a/src/log4net/Appender/BufferingAppenderSkeleton.cs
+++ b/src/log4net/Appender/BufferingAppenderSkeleton.cs
@@ -25,242 +25,242 @@
namespace log4net.Appender
{
- /// <summary>
- /// Abstract base class implementation of <see cref="IAppender"/> that
- /// buffers events in a fixed size buffer.
- /// </summary>
- /// <remarks>
- /// <para>
- /// This base class should be used by appenders that need to buffer a
- /// number of events before logging them.
- /// For example the <see cref="AdoNetAppender"/>
- /// buffers events and then submits the entire contents of the buffer to
- /// the underlying database in one go.
- /// </para>
- /// <para>
- /// Subclasses should override the <see cref="M:SendBuffer(LoggingEvent[])"/>
- /// method to deliver the buffered events.
- /// </para>
- /// <para>The BufferingAppenderSkeleton maintains a fixed size cyclic
- /// buffer of events. The size of the buffer is set using
- /// the <see cref="BufferSize"/> property.
- /// </para>
- /// <para>A <see cref="ITriggeringEventEvaluator"/> is used to inspect
- /// each event as it arrives in the appender. If the <see cref="Evaluator"/>
- /// triggers, then the current buffer is sent immediately
- /// (see <see cref="M:SendBuffer(LoggingEvent[])"/>). Otherwise the event
- /// is stored in the buffer. For example, an evaluator can be used to
- /// deliver the events immediately when an ERROR event arrives.
- /// </para>
- /// <para>
- /// The buffering appender can be configured in a <see cref="Lossy"/> mode.
- /// By default the appender is NOT lossy. When the buffer is full all
- /// the buffered events are sent with <see cref="M:SendBuffer(LoggingEvent[])"/>.
- /// If the <see cref="Lossy"/> property is set to <c>true</c> then the
- /// buffer will not be sent when it is full, and new events arriving
- /// in the appender will overwrite the oldest event in the buffer.
- /// In lossy mode the buffer will only be sent when the <see cref="Evaluator"/>
- /// triggers. This can be useful behavior when you need to know about
- /// ERROR events but not about events with a lower level, configure an
- /// evaluator that will trigger when an ERROR event arrives, the whole
- /// buffer will be sent which gives a history of events leading up to
- /// the ERROR event.
- /// </para>
- /// </remarks>
- /// <author>Nicko Cadell</author>
- /// <author>Gert Driesen</author>
+ /// <summary>
+ /// Abstract base class implementation of <see cref="IAppender"/> that
+ /// buffers events in a fixed size buffer.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// This base class should be used by appenders that need to buffer a
+ /// number of events before logging them.
+ /// For example the <see cref="AdoNetAppender"/>
+ /// buffers events and then submits the entire contents of the buffer to
+ /// the underlying database in one go.
+ /// </para>
+ /// <para>
+ /// Subclasses should override the <see cref="M:SendBuffer(LoggingEvent[])"/>
+ /// method to deliver the buffered events.
+ /// </para>
+ /// <para>The BufferingAppenderSkeleton maintains a fixed size cyclic
+ /// buffer of events. The size of the buffer is set using
+ /// the <see cref="BufferSize"/> property.
+ /// </para>
+ /// <para>A <see cref="ITriggeringEventEvaluator"/> is used to inspect
+ /// each event as it arrives in the appender. If the <see cref="Evaluator"/>
+ /// triggers, then the current buffer is sent immediately
+ /// (see <see cref="M:SendBuffer(LoggingEvent[])"/>). Otherwise the event
+ /// is stored in the buffer. For example, an evaluator can be used to
+ /// deliver the events immediately when an ERROR event arrives.
+ /// </para>
+ /// <para>
+ /// The buffering appender can be configured in a <see cref="Lossy"/> mode.
+ /// By default the appender is NOT lossy. When the buffer is full all
+ /// the buffered events are sent with <see cref="M:SendBuffer(LoggingEvent[])"/>.
+ /// If the <see cref="Lossy"/> property is set to <c>true</c> then the
+ /// buffer will not be sent when it is full, and new events arriving
+ /// in the appender will overwrite the oldest event in the buffer.
+ /// In lossy mode the buffer will only be sent when the <see cref="Evaluator"/>
+ /// triggers. This can be useful behavior when you need to know about
+ /// ERROR events but not about events with a lower level, configure an
+ /// evaluator that will trigger when an ERROR event arrives, the whole
+ /// buffer will be sent which gives a history of events leading up to
+ /// the ERROR event.
+ /// </para>
+ /// </remarks>
+ /// <author>Nicko Cadell</author>
+ /// <author>Gert Driesen</author>
public abstract class BufferingAppenderSkeleton : AppenderSkeleton
- {
- #region Protected Instance Constructors
+ {
+ #region Protected Instance Constructors
- /// <summary>
- /// Initializes a new instance of the <see cref="BufferingAppenderSkeleton" /> class.
- /// </summary>
- /// <remarks>
- /// <para>
- /// Protected default constructor to allow subclassing.
- /// </para>
- /// </remarks>
- protected BufferingAppenderSkeleton() : this(true)
- {
- }
+ /// <summary>
+ /// Initializes a new instance of the <see cref="BufferingAppenderSkeleton" /> class.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Protected default constructor to allow subclassing.
+ /// </para>
+ /// </remarks>
+ protected BufferingAppenderSkeleton() : this(true)
+ {
+ }
- /// <summary>
- /// Initializes a new instance of the <see cref="BufferingAppenderSkeleton" /> class.
- /// </summary>
- /// <param name="eventMustBeFixed">the events passed through this appender must be
- /// fixed by the time that they arrive in the derived class' <c>SendBuffer</c> method.</param>
- /// <remarks>
- /// <para>
- /// Protected constructor to allow subclassing.
- /// </para>
- /// <para>
- /// The <paramref name="eventMustBeFixed"/> should be set if the subclass
- /// expects the events delivered to be fixed even if the
- /// <see cref="BufferSize"/> is set to zero, i.e. when no buffering occurs.
- /// </para>
- /// </remarks>
- protected BufferingAppenderSkeleton(bool eventMustBeFixed) : base()
- {
- m_eventMustBeFixed = eventMustBeFixed;
- }
+ /// <summary>
+ /// Initializes a new instance of the <see cref="BufferingAppenderSkeleton" /> class.
+ /// </summary>
+ /// <param name="eventMustBeFixed">the events passed through this appender must be
+ /// fixed by the time that they arrive in the derived class' <c>SendBuffer</c> method.</param>
+ /// <remarks>
+ /// <para>
+ /// Protected constructor to allow subclassing.
+ /// </para>
+ /// <para>
+ /// The <paramref name="eventMustBeFixed"/> should be set if the subclass
+ /// expects the events delivered to be fixed even if the
+ /// <see cref="BufferSize"/> is set to zero, i.e. when no buffering occurs.
+ /// </para>
+ /// </remarks>
+ protected BufferingAppenderSkeleton(bool eventMustBeFixed) : base()
+ {
+ m_eventMustBeFixed = eventMustBeFixed;
+ }
- #endregion Protected Instance Constructors
+ #endregion Protected Instance Constructors
- #region Public Instance Properties
+ #region Public Instance Properties
- /// <summary>
- /// Gets or sets a value that indicates whether the appender is lossy.
- /// </summary>
- /// <value>
- /// <c>true</c> if the appender is lossy, otherwise <c>false</c>. The default is <c>false</c>.
- /// </value>
- /// <remarks>
- /// <para>
- /// This appender uses a buffer to store logging events before
- /// delivering them. A triggering event causes the whole buffer
- /// to be send to the remote sink. If the buffer overruns before
- /// a triggering event then logging events could be lost. Set
- /// <see cref="Lossy"/> to <c>false</c> to prevent logging events
- /// from being lost.
- /// </para>
- /// <para>If <see cref="Lossy"/> is set to <c>true</c> then an
- /// <see cref="Evaluator"/> must be specified.</para>
- /// </remarks>
- public bool Lossy
- {
- get { return m_lossy; }
- set { m_lossy = value; }
- }
+ /// <summary>
+ /// Gets or sets a value that indicates whether the appender is lossy.
+ /// </summary>
+ /// <value>
+ /// <c>true</c> if the appender is lossy, otherwise <c>false</c>. The default is <c>false</c>.
+ /// </value>
+ /// <remarks>
+ /// <para>
+ /// This appender uses a buffer to store logging events before
+ /// delivering them. A triggering event causes the whole buffer
+ /// to be send to the remote sink. If the buffer overruns before
+ /// a triggering event then logging events could be lost. Set
+ /// <see cref="Lossy"/> to <c>false</c> to prevent logging events
+ /// from being lost.
+ /// </para>
+ /// <para>If <see cref="Lossy"/> is set to <c>true</c> then an
+ /// <see cref="Evaluator"/> must be specified.</para>
+ /// </remarks>
+ public bool Lossy
+ {
+ get { return m_lossy; }
+ set { m_lossy = value; }
+ }
- /// <summary>
- /// Gets or sets the size of the cyclic buffer used to hold the
- /// logging events.
- /// </summary>
- /// <value>
- /// The size of the cyclic buffer used to hold the logging events.
- /// </value>
- /// <remarks>
- /// <para>
- /// The <see cref="BufferSize"/> option takes a positive integer
- /// representing the maximum number of logging events to collect in
- /// a cyclic buffer. When the <see cref="BufferSize"/> is reached,
- /// oldest events are deleted as new events are added to the
- /// buffer. By default the size of the cyclic buffer is 512 events.
- /// </para>
- /// <para>
- /// If the <see cref="BufferSize"/> is set to a value less than
- /// or equal to 1 then no buffering will occur. The logging event
- /// will be delivered synchronously (depending on the <see cref="Lossy"/>
- /// and <see cref="Evaluator"/> properties). Otherwise the event will
- /// be buffered.
- /// </para>
- /// </remarks>
- public int BufferSize
- {
- get { return m_bufferSize; }
- set { m_bufferSize = value; }
- }
+ /// <summary>
+ /// Gets or sets the size of the cyclic buffer used to hold the
+ /// logging events.
+ /// </summary>
+ /// <value>
+ /// The size of the cyclic buffer used to hold the logging events.
+ /// </value>
+ /// <remarks>
+ /// <para>
+ /// The <see cref="BufferSize"/> option takes a positive integer
+ /// representing the maximum number of logging events to collect in
+ /// a cyclic buffer. When the <see cref="BufferSize"/> is reached,
+ /// oldest events are deleted as new events are added to the
+ /// buffer. By default the size of the cyclic buffer is 512 events.
+ /// </para>
+ /// <para>
+ /// If the <see cref="BufferSize"/> is set to a value less than
+ /// or equal to 1 then no buffering will occur. The logging event
+ /// will be delivered synchronously (depending on the <see cref="Lossy"/>
+ /// and <see cref="Evaluator"/> properties). Otherwise the event will
+ /// be buffered.
+ /// </para>
+ /// </remarks>
+ public int BufferSize
+ {
+ get { return m_bufferSize; }
+ set { m_bufferSize = value; }
+ }
- /// <summary>
- /// Gets or sets the <see cref="ITriggeringEventEvaluator"/> that causes the
- /// buffer to be sent immediately.
- /// </summary>
- /// <value>
- /// The <see cref="ITriggeringEventEvaluator"/> that causes the buffer to be
- /// sent immediately.
- /// </value>
- /// <remarks>
- /// <para>
- /// The evaluator will be called for each event that is appended to this
- /// appender. If the evaluator triggers then the current buffer will
- /// immediately be sent (see <see cref="M:SendBuffer(LoggingEvent[])"/>).
- /// </para>
- /// <para>If <see cref="Lossy"/> is set to <c>true</c> then an
- /// <see cref="Evaluator"/> must be specified.</para>
- /// </remarks>
- public ITriggeringEventEvaluator Evaluator
- {
- get { return m_evaluator; }
- set { m_evaluator = value; }
- }
+ /// <summary>
+ /// Gets or sets the <see cref="ITriggeringEventEvaluator"/> that causes the
+ /// buffer to be sent immediately.
+ /// </summary>
+ /// <value>
+ /// The <see cref="ITriggeringEventEvaluator"/> that causes the buffer to be
+ /// sent immediately.
+ /// </value>
+ /// <remarks>
+ /// <para>
+ /// The evaluator will be called for each event that is appended to this
+ /// appender. If the evaluator triggers then the current buffer will
+ /// immediately be sent (see <see cref="M:SendBuffer(LoggingEvent[])"/>).
+ /// </para>
+ /// <para>If <see cref="Lossy"/> is set to <c>true</c> then an
+ /// <see cref="Evaluator"/> must be specified.</para>
+ /// </remarks>
+ public ITriggeringEventEvaluator Evaluator
+ {
+ get { return m_evaluator; }
+ set { m_evaluator = value; }
+ }
- /// <summary>
- /// Gets or sets the value of the <see cref="ITriggeringEventEvaluator"/> to use.
- /// </summary>
- /// <value>
- /// The value of the <see cref="ITriggeringEventEvaluator"/> to use.
- /// </value>
- /// <remarks>
- /// <para>
- /// The evaluator will be called for each event that is discarded from this
- /// appender. If the evaluator triggers then the current buffer will immediately
- /// be sent (see <see cref="M:SendBuffer(LoggingEvent[])"/>).
- /// </para>
- /// </remarks>
- public ITriggeringEventEvaluator LossyEvaluator
- {
- get { return m_lossyEvaluator; }
- set { m_lossyEvaluator = value; }
- }
+ /// <summary>
+ /// Gets or sets the value of the <see cref="ITriggeringEventEvaluator"/> to use.
+ /// </summary>
+ /// <value>
+ /// The value of the <see cref="ITriggeringEventEvaluator"/> to use.
+ /// </value>
+ /// <remarks>
+ /// <para>
+ /// The evaluator will be called for each event that is discarded from this
+ /// appender. If the evaluator triggers then the current buffer will immediately
+ /// be sent (see <see cref="M:SendBuffer(LoggingEvent[])"/>).
+ /// </para>
+ /// </remarks>
+ public ITriggeringEventEvaluator LossyEvaluator
+ {
+ get { return m_lossyEvaluator; }
+ set { m_lossyEvaluator = value; }
+ }
- /// <summary>
- /// Gets or sets a value indicating if only part of the logging event data
- /// should be fixed.
- /// </summary>
- /// <value>
- /// <c>true</c> if the appender should only fix part of the logging event
- /// data, otherwise <c>false</c>. The default is <c>false</c>.
- /// </value>
- /// <remarks>
- /// <para>
- /// Setting this property to <c>true</c> will cause only part of the
- /// event data to be fixed and serialized. This will improve performance.
- /// </para>
- /// <para>
- /// See <see cref="M:LoggingEvent.FixVolatileData(FixFlags)"/> for more information.
- /// </para>
- /// </remarks>
- [Obsolete("Use Fix property")]
- public virtual bool OnlyFixPartialEventData
- {
- get { return (Fix == FixFlags.Partial); }
- set
- {
- if (value)
- {
- Fix = FixFlags.Partial;
- }
- else
- {
- Fix = FixFlags.All;
- }
- }
- }
+ /// <summary>
+ /// Gets or sets a value indicating if only part of the logging event data
+ /// should be fixed.
+ /// </summary>
+ /// <value>
+ /// <c>true</c> if the appender should only fix part of the logging event
+ /// data, otherwise <c>false</c>. The default is <c>false</c>.
+ /// </value>
+ /// <remarks>
+ /// <para>
+ /// Setting this property to <c>true</c> will cause only part of the
+ /// event data to be fixed and serialized. This will improve performance.
+ /// </para>
+ /// <para>
+ /// See <see cref="M:LoggingEvent.FixVolatileData(FixFlags)"/> for more information.
+ /// </para>
+ /// </remarks>
+ [Obsolete("Use Fix property")]
+ public virtual bool OnlyFixPartialEventData
+ {
+ get { return (Fix == FixFlags.Partial); }
+ set
+ {
+ if (value)
+ {
+ Fix = FixFlags.Partial;
+ }
+ else
+ {
+ Fix = FixFlags.All;
+ }
+ }
+ }
- /// <summary>
- /// Gets or sets a the fields that will be fixed in the event
- /// </summary>
- /// <value>
- /// The event fields that will be fixed before the event is buffered
- /// </value>
- /// <remarks>
- /// <para>
- /// The logging event needs to have certain thread specific values
- /// captured before it can be buffered. See <see cref="LoggingEvent.Fix"/>
- /// for details.
- /// </para>
- /// </remarks>
- /// <seealso cref="LoggingEvent.Fix"/>
- public virtual FixFlags Fix
- {
- get { return m_fixFlags; }
- set { m_fixFlags = value; }
- }
+ /// <summary>
+ /// Gets or sets a the fields that will be fixed in the event
+ /// </summary>
+ /// <value>
+ /// The event fields that will be fixed before the event is buffered
+ /// </value>
+ /// <remarks>
+ /// <para>
+ /// The logging event needs to have certain thread specific values
+ /// captured before it can be buffered. See <see cref="LoggingEvent.Fix"/>
+ /// for details.
+ /// </para>
+ /// </remarks>
+ /// <seealso cref="LoggingEvent.Fix"/>
+ public virtual FixFlags Fix
+ {
+ get { return m_fixFlags; }
+ set { m_fixFlags = value; }
+ }
- #endregion Public Instance Properties
+ #endregion Public Instance Properties
- #region Public Methods
+ #region Public Methods
/// <summary>
/// Flushes any buffered log data.
@@ -273,387 +273,387 @@
return true;
}
- /// <summary>
- /// Flush the currently buffered events
- /// </summary>
- /// <remarks>
- /// <para>
- /// Flushes any events that have been buffered.
- /// </para>
- /// <para>
- /// If the appender is buffering in <see cref="Lossy"/> mode then the contents
- /// of the buffer will NOT be flushed to the appender.
- /// </para>
- /// </remarks>
- public virtual void Flush()
- {
- Flush(false);
- }
+ /// <summary>
+ /// Flush the currently buffered events
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Flushes any events that have been buffered.
+ /// </para>
+ /// <para>
+ /// If the appender is buffering in <see cref="Lossy"/> mode then the contents
+ /// of the buffer will NOT be flushed to the appender.
+ /// </para>
+ /// </remarks>
+ public virtual void Flush()
+ {
+ Flush(false);
+ }
- /// <summary>
- /// Flush the currently buffered events
- /// </summary>
- /// <param name="flushLossyBuffer">set to <c>true</c> to flush the buffer of lossy events</param>
- /// <remarks>
- /// <para>
- /// Flushes events that have been buffered. If <paramref name="flushLossyBuffer" /> is
- /// <c>false</c> then events will only be flushed if this buffer is non-lossy mode.
- /// </para>
- /// <para>
- /// If the appender is buffering in <see cref="Lossy"/> mode then the contents
- /// of the buffer will only be flushed if <paramref name="flushLossyBuffer" /> is <c>true</c>.
- /// In this case the contents of the buffer will be tested against the
- /// <see cref="LossyEvaluator"/> and if triggering will be output. All other buffered
- /// events will be discarded.
- /// </para>
- /// <para>
- /// If <paramref name="flushLossyBuffer" /> is <c>true</c> then the buffer will always
- /// be emptied by calling this method.
- /// </para>
- /// </remarks>
- public virtual void Flush(bool flushLossyBuffer)
- {
- // This method will be called outside of the AppenderSkeleton DoAppend() method
- // therefore it needs to be protected by its own lock. This will block any
- // Appends while the buffer is flushed.
- lock(this)
- {
- if (m_cb != null && m_cb.Length > 0)
- {
- if (m_lossy)
- {
- // If we are allowed to eagerly flush from the lossy buffer
- if (flushLossyBuffer)
- {
- if (m_lossyEvaluator != null)
- {
- // Test the contents of the buffer against the lossy evaluator
- LoggingEvent[] bufferedEvents = m_cb.PopAll();
- ArrayList filteredEvents = new ArrayList(bufferedEvents.Length);
+ /// <summary>
+ /// Flush the currently buffered events
+ /// </summary>
+ /// <param name="flushLossyBuffer">set to <c>true</c> to flush the buffer of lossy events</param>
+ /// <remarks>
+ /// <para>
+ /// Flushes events that have been buffered. If <paramref name="flushLossyBuffer" /> is
+ /// <c>false</c> then events will only be flushed if this buffer is non-lossy mode.
+ /// </para>
+ /// <para>
+ /// If the appender is buffering in <see cref="Lossy"/> mode then the contents
+ /// of the buffer will only be flushed if <paramref name="flushLossyBuffer" /> is <c>true</c>.
+ /// In this case the contents of the buffer will be tested against the
+ /// <see cref="LossyEvaluator"/> and if triggering will be output. All other buffered
+ /// events will be discarded.
+ /// </para>
+ /// <para>
+ /// If <paramref name="flushLossyBuffer" /> is <c>true</c> then the buffer will always
+ /// be emptied by calling this method.
+ /// </para>
+ /// </remarks>
+ public virtual void Flush(bool flushLossyBuffer)
+ {
+ // This method will be called outside of the AppenderSkeleton DoAppend() method
+ // therefore it needs to be protected by its own lock. This will block any
+ // Appends while the buffer is flushed.
+ lock(this)
+ {
+ if (m_cb != null && m_cb.Length > 0)
+ {
+ if (m_lossy)
+ {
+ // If we are allowed to eagerly flush from the lossy buffer
+ if (flushLossyBuffer)
+ {
+ if (m_lossyEvaluator != null)
+ {
+ // Test the contents of the buffer against the lossy evaluator
+ LoggingEvent[] bufferedEvents = m_cb.PopAll();
+ ArrayList filteredEvents = new ArrayList(bufferedEvents.Length);
- foreach(LoggingEvent loggingEvent in bufferedEvents)
- {
- if (m_lossyEvaluator.IsTriggeringEvent(loggingEvent))
- {
- filteredEvents.Add(loggingEvent);
- }
- }
+ foreach(LoggingEvent loggingEvent in bufferedEvents)
+ {
+ if (m_lossyEvaluator.IsTriggeringEvent(loggingEvent))
+ {
+ filteredEvents.Add(loggingEvent);
+ }
+ }
- // Send the events that meet the lossy evaluator criteria
- if (filteredEvents.Count > 0)
- {
- SendBuffer((LoggingEvent[])filteredEvents.ToArray(typeof(LoggingEvent)));
- }
- }
- else
- {
- // No lossy evaluator, all buffered events are discarded
- m_cb.Clear();
- }
- }
- }
- else
- {
- // Not lossy, send whole buffer
- SendFromBuffer(null, m_cb);
- }
- }
- }
- }
+ // Send the events that meet the lossy evaluator criteria
+ if (filteredEvents.Count > 0)
+ {
+ SendBuffer((LoggingEvent[])filteredEvents.ToArray(typeof(LoggingEvent)));
+ }
+ }
+ else
+ {
+ // No lossy evaluator, all buffered events are discarded
+ m_cb.Clear();
+ }
+ }
+ }
+ else
+ {
+ // Not lossy, send whole buffer
+ SendFromBuffer(null, m_cb);
+ }
+ }
+ }
+ }
- #endregion Public Methods
+ #endregion Public Methods
- #region Implementation of IOptionHandler
+ #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>
- public override void ActivateOptions()
- {
- base.ActivateOptions();
+ /// <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>
+ public override void ActivateOptions()
+ {
+ base.ActivateOptions();
- // If the appender is in Lossy mode then we will
- // only send the buffer when the Evaluator triggers
- // therefore check we have an evaluator.
- if (m_lossy && m_evaluator == null)
- {
- ErrorHandler.Error("Appender ["+Name+"] is Lossy but has no Evaluator. The buffer will never be sent!");
- }
+ // If the appender is in Lossy mode then we will
+ // only send the buffer when the Evaluator triggers
+ // therefore check we have an evaluator.
+ if (m_lossy && m_evaluator == null)
+ {
+ ErrorHandler.Error("Appender ["+Name+"] is Lossy but has no Evaluator. The buffer will never be sent!");
+ }
- if (m_bufferSize > 1)
- {
- m_cb = new CyclicBuffer(m_bufferSize);
- }
- else
- {
- m_cb = null;
- }
- }
+ if (m_bufferSize > 1)
+ {
+ m_cb = new CyclicBuffer(m_bufferSize);
+ }
+ else
+ {
+ m_cb = null;
+ }
+ }
- #endregion Implementation of IOptionHandler
+ #endregion Implementation of IOptionHandler
- #region Override implementation of AppenderSkeleton
+ #region Override implementation of AppenderSkeleton
- /// <summary>
- /// Close this appender instance.
- /// </summary>
- /// <remarks>
- /// <para>
- /// Close this appender instance. If this appender is marked
- /// as not <see cref="Lossy"/> then the remaining events in
- /// the buffer must be sent when the appender is closed.
- /// </para>
- /// </remarks>
- protected override void OnClose()
- {
- // Flush the buffer on close
- Flush(true);
- }
+ /// <summary>
+ /// Close this appender instance.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Close this appender instance. If this appender is marked
+ /// as not <see cref="Lossy"/> then the remaining events in
+ /// the buffer must be sent when the appender is closed.
+ /// </para>
+ /// </remarks>
+ protected override void OnClose()
+ {
+ // Flush the buffer on close
+ Flush(true);
+ }
- /// <summary>
- /// This method is called by the <see cref="M:AppenderSkeleton.DoAppend(LoggingEvent)"/> method.
- /// </summary>
- /// <param name="loggingEvent">the event to log</param>
- /// <remarks>
- /// <para>
- /// Stores the <paramref name="loggingEvent"/> in the cyclic buffer.
- /// </para>
- /// <para>
- /// The buffer will be sent (i.e. passed to the <see cref="SendBuffer"/>
- /// method) if one of the following conditions is met:
- /// </para>
- /// <list type="bullet">
- /// <item>
- /// <description>The cyclic buffer is full and this appender is
- /// marked as not lossy (see <see cref="Lossy"/>)</description>
- /// </item>
- /// <item>
- /// <description>An <see cref="Evaluator"/> is set and
- /// it is triggered for the <paramref name="loggingEvent"/>
- /// specified.</description>
- /// </item>
- /// </list>
- /// <para>
- /// Before the event is stored in the buffer it is fixed
- /// (see <see cref="M:LoggingEvent.FixVolatileData(FixFlags)"/>) to ensure that
- /// any data referenced by the event will be valid when the buffer
- /// is processed.
- /// </para>
- /// </remarks>
- protected override void Append(LoggingEvent loggingEvent)
- {
- // If the buffer size is set to 1 or less then the buffer will be
- // sent immediately because there is not enough space in the buffer
- // to buffer up more than 1 event. Therefore as a special case
- // we don't use the buffer at all.
- if (m_cb == null || m_bufferSize <= 1)
- {
- // Only send the event if we are in non lossy mode or the event is a triggering event
- if ((!m_lossy) ||
- (m_evaluator != null && m_evaluator.IsTriggeringEvent(loggingEvent)) ||
- (m_lossyEvaluator != null && m_lossyEvaluator.IsTriggeringEvent(loggingEvent)))
- {
- if (m_eventMustBeFixed)
- {
- // Derive class expects fixed events
- loggingEvent.Fix = this.Fix;
- }
+ /// <summary>
+ /// This method is called by the <see cref="M:AppenderSkeleton.DoAppend(LoggingEvent)"/> method.
+ /// </summary>
+ /// <param name="loggingEvent">the event to log</param>
+ /// <remarks>
+ /// <para>
+ /// Stores the <paramref name="loggingEvent"/> in the cyclic buffer.
+ /// </para>
+ /// <para>
+ /// The buffer will be sent (i.e. passed to the <see cref="SendBuffer"/>
+ /// method) if one of the following conditions is met:
+ /// </para>
+ /// <list type="bullet">
+ /// <item>
+ /// <description>The cyclic buffer is full and this appender is
+ /// marked as not lossy (see <see cref="Lossy"/>)</description>
+ /// </item>
+ /// <item>
+ /// <description>An <see cref="Evaluator"/> is set and
+ /// it is triggered for the <paramref name="loggingEvent"/>
+ /// specified.</description>
+ /// </item>
+ /// </list>
+ /// <para>
+ /// Before the event is stored in the buffer it is fixed
+ /// (see <see cref="M:LoggingEvent.FixVolatileData(FixFlags)"/>) to ensure that
+ /// any data referenced by the event will be valid when the buffer
+ /// is processed.
+ /// </para>
+ /// </remarks>
+ protected override void Append(LoggingEvent loggingEvent)
+ {
+ // If the buffer size is set to 1 or less then the buffer will be
+ // sent immediately because there is not enough space in the buffer
+ // to buffer up more than 1 event. Therefore as a special case
+ // we don't use the buffer at all.
+ if (m_cb == null || m_bufferSize <= 1)
+ {
+ // Only send the event if we are in non lossy mode or the event is a triggering event
+ if ((!m_lossy) ||
+ (m_evaluator != null && m_evaluator.IsTriggeringEvent(loggingEvent)) ||
+ (m_lossyEvaluator != null && m_lossyEvaluator.IsTriggeringEvent(loggingEvent)))
+ {
+ if (m_eventMustBeFixed)
+ {
+ // Derive class expects fixed events
+ loggingEvent.Fix = this.Fix;
+ }
- // Not buffering events, send immediately
- SendBuffer(new LoggingEvent[] { loggingEvent } );
- }
- }
- else
- {
- // Because we are caching the LoggingEvent beyond the
- // lifetime of the Append() method we must fix any
- // volatile data in the event.
- loggingEvent.Fix = this.Fix;
+ // Not buffering events, send immediately
+ SendBuffer(new LoggingEvent[] { loggingEvent } );
+ }
+ }
+ else
+ {
+ // Because we are caching the LoggingEvent beyond the
+ // lifetime of the Append() method we must fix any
+ // volatile data in the event.
+ loggingEvent.Fix = this.Fix;
- // Add to the buffer, returns the event discarded from the buffer if there is no space remaining after the append
- LoggingEvent discardedLoggingEvent = m_cb.Append(loggingEvent);
+ // Add to the buffer, returns the event discarded from the buffer if there is no space remaining after the append
+ LoggingEvent discardedLoggingEvent = m_cb.Append(loggingEvent);
- if (discardedLoggingEvent != null)
- {
- // Buffer is full and has had to discard an event
- if (!m_lossy)
- {
- // Not lossy, must send all events
- SendFromBuffer(discardedLoggingEvent, m_cb);
- }
- else
- {
- // Check if the discarded event should not be logged
- if (m_lossyEvaluator == null || !m_lossyEvaluator.IsTriggeringEvent(discardedLoggingEvent))
- {
- // Clear the discarded event as we should not forward it
- discardedLoggingEvent = null;
- }
+ if (discardedLoggingEvent != null)
+ {
+ // Buffer is full and has had to discard an event
+ if (!m_lossy)
+ {
+ // Not lossy, must send all events
+ SendFromBuffer(discardedLoggingEvent, m_cb);
+ }
+ else
+ {
+ // Check if the discarded event should not be logged
+ if (m_lossyEvaluator == null || !m_lossyEvaluator.IsTriggeringEvent(discardedLoggingEvent))
+ {
+ // Clear the discarded event as we should not forward it
+ discardedLoggingEvent = null;
+ }
- // Check if the event should trigger the whole buffer to be sent
- if (m_evaluator != null && m_evaluator.IsTriggeringEvent(loggingEvent))
- {
- SendFromBuffer(discardedLoggingEvent, m_cb);
- }
- else if (discardedLoggingEvent != null)
- {
- // Just send the discarded event
- SendBuffer(new LoggingEvent[] { discardedLoggingEvent } );
- }
- }
- }
- else
- {
- // Buffer is not yet full
+ // Check if the event should trigger the whole buffer to be sent
+ if (m_evaluator != null && m_evaluator.IsTriggeringEvent(loggingEvent))
+ {
+ SendFromBuffer(discardedLoggingEvent, m_cb);
+ }
+ else if (discardedLoggingEvent != null)
+ {
+ // Just send the discarded event
+ SendBuffer(new LoggingEvent[] { discardedLoggingEvent } );
+ }
+ }
+ }
+ else
+ {
+ // Buffer is not yet full
- // Check if the event should trigger the whole buffer to be sent
- if (m_evaluator != null && m_evaluator.IsTriggeringEvent(loggingEvent))
- {
- SendFromBuffer(null, m_cb);
- }
- }
- }
- }
+ // Check if the event should trigger the whole buffer to be sent
+ if (m_evaluator != null && m_evaluator.IsTriggeringEvent(loggingEvent))
+ {
+ SendFromBuffer(null, m_cb);
+ }
+ }
+ }
+ }
- #endregion Override implementation of AppenderSkeleton
+ #endregion Override implementation of AppenderSkeleton
- #region Protected Instance Methods
+ #region Protected Instance Methods
- /// <summary>
- /// Sends the contents of the buffer.
- /// </summary>
- /// <param name="firstLoggingEvent">The first logging event.</param>
- /// <param name="buffer">The buffer containing the events that need to be send.</param>
- /// <remarks>
- /// <para>
- /// The subclass must override <see cref="M:SendBuffer(LoggingEvent[])"/>.
- /// </para>
- /// </remarks>
- protected virtual void SendFromBuffer(LoggingEvent firstLoggingEvent, CyclicBuffer buffer)
- {
- LoggingEvent[] bufferEvents = buffer.PopAll();
+ /// <summary>
+ /// Sends the contents of the buffer.
+ /// </summary>
+ /// <param name="firstLoggingEvent">The first logging event.</param>
+ /// <param name="buffer">The buffer containing the events that need to be send.</param>
+ /// <remarks>
+ /// <para>
+ /// The subclass must override <see cref="M:SendBuffer(LoggingEvent[])"/>.
+ /// </para>
+ /// </remarks>
+ protected virtual void SendFromBuffer(LoggingEvent firstLoggingEvent, CyclicBuffer buffer)
+ {
+ LoggingEvent[] bufferEvents = buffer.PopAll();
- if (firstLoggingEvent == null)
- {
- SendBuffer(bufferEvents);
- }
- else if (bufferEvents.Length == 0)
- {
- SendBuffer(new LoggingEvent[] { firstLoggingEvent } );
- }
- else
- {
- // Create new array with the firstLoggingEvent at the head
- LoggingEvent[] events = new LoggingEvent[bufferEvents.Length + 1];
- Array.Copy(bufferEvents, 0, events, 1, bufferEvents.Length);
- events[0] = firstLoggingEvent;
+ if (firstLoggingEvent == null)
+ {
+ SendBuffer(bufferEvents);
+ }
+ else if (bufferEvents.Length == 0)
+ {
+ SendBuffer(new LoggingEvent[] { firstLoggingEvent } );
+ }
+ else
+ {
+ // Create new array with the firstLoggingEvent at the head
+ LoggingEvent[] events = new LoggingEvent[bufferEvents.Length + 1];
+ Array.Copy(bufferEvents, 0, events, 1, bufferEvents.Length);
+ events[0] = firstLoggingEvent;
- SendBuffer(events);
- }
- }
+ SendBuffer(events);
+ }
+ }
- #endregion Protected Instance Methods
+ #endregion Protected Instance Methods
- /// <summary>
- /// Sends the events.
- /// </summary>
- /// <param name="events">The events that need to be send.</param>
- /// <remarks>
- /// <para>
- /// The subclass must override this method to process the buffered events.
- /// </para>
- /// </remarks>
- protected abstract void SendBuffer(LoggingEvent[] events);
+ /// <summary>
+ /// Sends the events.
+ /// </summary>
+ /// <param name="events">The events that need to be send.</param>
+ /// <remarks>
+ /// <para>
+ /// The subclass must override this method to process the buffered events.
+ /// </para>
+ /// </remarks>
+ protected abstract void SendBuffer(LoggingEvent[] events);
- #region Private Static Fields
+ #region Private Static Fields
- /// <summary>
- /// The default buffer size.
- /// </summary>
- /// <remarks>
- /// The default size of the cyclic buffer used to store events.
- /// This is set to 512 by default.
- /// </remarks>
- private const int DEFAULT_BUFFER_SIZE = 512;
+ /// <summary>
+ /// The default buffer size.
+ /// </summary>
+ /// <remarks>
+ /// The default size of the cyclic buffer used to store events.
+ /// This is set to 512 by default.
+ /// </remarks>
+ private const int DEFAULT_BUFFER_SIZE = 512;
- #endregion Private Static Fields
+ #endregion Private Static Fields
- #region Private Instance Fields
+ #region Private Instance Fields
- /// <summary>
- /// The size of the cyclic buffer used to hold the logging events.
- /// </summary>
- /// <remarks>
- /// Set to <see cref="DEFAULT_BUFFER_SIZE"/> by default.
- /// </remarks>
- private int m_bufferSize = DEFAULT_BUFFER_SIZE;
+ /// <summary>
+ /// The size of the cyclic buffer used to hold the logging events.
+ /// </summary>
+ /// <remarks>
+ /// Set to <see cref="DEFAULT_BUFFER_SIZE"/> by default.
+ /// </remarks>
+ private int m_bufferSize = DEFAULT_BUFFER_SIZE;
- /// <summary>
- /// The cyclic buffer used to store the logging events.
- /// </summary>
- private CyclicBuffer m_cb;
+ /// <summary>
+ /// The cyclic buffer used to store the logging events.
+ /// </summary>
+ private CyclicBuffer m_cb;
- /// <summary>
- /// The triggering event evaluator that causes the buffer to be sent immediately.
- /// </summary>
- /// <remarks>
- /// The object that is used to determine if an event causes the entire
- /// buffer to be sent immediately. This field can be <c>null</c>, which
- /// indicates that event triggering is not to be done. The evaluator
- /// can be set using the <see cref="Evaluator"/> property. If this appender
- /// has the <see cref="m_lossy"/> (<see cref="Lossy"/> property) set to
- /// <c>true</c> then an <see cref="Evaluator"/> must be set.
- /// </remarks>
- private ITriggeringEventEvaluator m_evaluator;
+ /// <summary>
+ /// The triggering event evaluator that causes the buffer to be sent immediately.
+ /// </summary>
+ /// <remarks>
+ /// The object that is used to determine if an event causes the entire
+ /// buffer to be sent immediately. This field can be <c>null</c>, which
+ /// indicates that event triggering is not to be done. The evaluator
+ /// can be set using the <see cref="Evaluator"/> property. If this appender
+ /// has the <see cref="m_lossy"/> (<see cref="Lossy"/> property) set to
+ /// <c>true</c> then an <see cref="Evaluator"/> must be set.
+ /// </remarks>
+ private ITriggeringEventEvaluator m_evaluator;
- /// <summary>
- /// Indicates if the appender should overwrite events in the cyclic buffer
- /// when it becomes full, or if the buffer should be flushed when the
- /// buffer is full.
- /// </summary>
- /// <remarks>
- /// If this field is set to <c>true</c> then an <see cref="Evaluator"/> must
- /// be set.
- /// </remarks>
- private bool m_lossy = false;
+ /// <summary>
+ /// Indicates if the appender should overwrite events in the cyclic buffer
+ /// when it becomes full, or if the buffer should be flushed when the
+ /// buffer is full.
+ /// </summary>
+ /// <remarks>
+ /// If this field is set to <c>true</c> then an <see cref="Evaluator"/> must
+ /// be set.
+ /// </remarks>
+ private bool m_lossy = false;
- /// <summary>
- /// The triggering event evaluator filters discarded events.
- /// </summary>
- /// <remarks>
- /// The object that is used to determine if an event that is discarded should
- /// really be discarded or if it should be sent to the appenders.
- /// This field can be <c>null</c>, which indicates that all discarded events will
- /// be discarded.
- /// </remarks>
- private ITriggeringEventEvaluator m_lossyEvaluator;
+ /// <summary>
+ /// The triggering event evaluator filters discarded events.
+ /// </summary>
+ /// <remarks>
+ /// The object that is used to determine if an event that is discarded should
+ /// really be discarded or if it should be sent to the appenders.
+ /// This field can be <c>null</c>, which indicates that all discarded events will
+ /// be discarded.
+ /// </remarks>
+ private ITriggeringEventEvaluator m_lossyEvaluator;
- /// <summary>
- /// Value indicating which fields in the event should be fixed
- /// </summary>
- /// <remarks>
- /// By default all fields are fixed
- /// </remarks>
- private FixFlags m_fixFlags = FixFlags.All;
+ /// <summary>
+ /// Value indicating which fields in the event should be fixed
+ /// </summary>
+ /// <remarks>
+ /// By default all fields are fixed
+ /// </remarks>
+ private FixFlags m_fixFlags = FixFlags.All;
- /// <summary>
- /// The events delivered to the subclass must be fixed.
- /// </summary>
- private readonly bool m_eventMustBeFixed;
+ /// <summary>
+ /// The events delivered to the subclass must be fixed.
+ /// </summary>
+ private readonly bool m_eventMustBeFixed;
- #endregion Private Instance Fields
- }
+ #endregion Private Instance Fields
+ }
}
diff --git a/src/log4net/Appender/BufferingForwardingAppender.cs b/src/log4net/Appender/BufferingForwardingAppender.cs
index 20c3624..c228b22 100644
--- a/src/log4net/Appender/BufferingForwardingAppender.cs
+++ b/src/log4net/Appender/BufferingForwardingAppender.cs
@@ -25,250 +25,250 @@
namespace log4net.Appender
{
- /// <summary>
- /// Buffers events and then forwards them to attached appenders.
- /// </summary>
- /// <remarks>
- /// <para>
- /// The events are buffered in this appender until conditions are
- /// met to allow the appender to deliver the events to the attached
- /// appenders. See <see cref="BufferingAppenderSkeleton"/> for the
- /// conditions that cause the buffer to be sent.
- /// </para>
- /// <para>The forwarding appender can be used to specify different
- /// thresholds and filters for the same appender at different locations
- /// within the hierarchy.
- /// </para>
- /// </remarks>
- /// <author>Nicko Cadell</author>
- /// <author>Gert Driesen</author>
- public class BufferingForwardingAppender : BufferingAppenderSkeleton, IAppenderAttachable
- {
- #region Public Instance Constructors
+ /// <summary>
+ /// Buffers events and then forwards them to attached appenders.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// The events are buffered in this appender until conditions are
+ /// met to allow the appender to deliver the events to the attached
+ /// appenders. See <see cref="BufferingAppenderSkeleton"/> for the
+ /// conditions that cause the buffer to be sent.
+ /// </para>
+ /// <para>The forwarding appender can be used to specify different
+ /// thresholds and filters for the same appender at different locations
+ /// within the hierarchy.
+ /// </para>
+ /// </remarks>
+ /// <author>Nicko Cadell</author>
+ /// <author>Gert Driesen</author>
+ public class BufferingForwardingAppender : BufferingAppenderSkeleton, IAppenderAttachable
+ {
+ #region Public Instance Constructors
- /// <summary>
- /// Initializes a new instance of the <see cref="BufferingForwardingAppender" /> class.
- /// </summary>
- /// <remarks>
- /// <para>
- /// Default constructor.
- /// </para>
- /// </remarks>
- public BufferingForwardingAppender()
- {
- }
+ /// <summary>
+ /// Initializes a new instance of the <see cref="BufferingForwardingAppender" /> class.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Default constructor.
+ /// </para>
+ /// </remarks>
+ public BufferingForwardingAppender()
+ {
+ }
- #endregion Public Instance Constructors
+ #endregion Public Instance Constructors
- #region Override implementation of AppenderSkeleton
+ #region Override implementation of AppenderSkeleton
- /// <summary>
- /// Closes the appender and releases resources.
- /// </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>
- protected override void OnClose()
- {
- // Remove all the attached appenders
- lock(this)
- {
- // Delegate to base, which will flush buffers
- base.OnClose();
+ /// <summary>
+ /// Closes the appender and releases resources.
+ /// </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>
+ protected override void OnClose()
+ {
+ // Remove all the attached appenders
+ lock(this)
+ {
+ // Delegate to base, which will flush buffers
+ base.OnClose();
- if (m_appenderAttachedImpl != null)
- {
- m_appenderAttachedImpl.RemoveAllAppenders();
- }
- }
- }
+ if (m_appenderAttachedImpl != null)
+ {
+ m_appenderAttachedImpl.RemoveAllAppenders();
+ }
+ }
+ }
- #endregion Override implementation of AppenderSkeleton
+ #endregion Override implementation of AppenderSkeleton
- #region Override implementation of BufferingAppenderSkeleton
+ #region Override implementation of BufferingAppenderSkeleton
- /// <summary>
- /// Send the events.
- /// </summary>
- /// <param name="events">The events that need to be send.</param>
- /// <remarks>
- /// <para>
- /// Forwards the events to the attached appenders.
- /// </para>
- /// </remarks>
- protected override void SendBuffer(LoggingEvent[] events)
- {
- // Pass the logging event on to the attached appenders
- if (m_appenderAttachedImpl != null)
- {
- m_appenderAttachedImpl.AppendLoopOnAppenders(events);
- }
- }
+ /// <summary>
+ /// Send the events.
+ /// </summary>
+ /// <param name="events">The events that need to be send.</param>
+ /// <remarks>
+ /// <para>
+ /// Forwards the events to the attached appenders.
+ /// </para>
+ /// </remarks>
+ protected override void SendBuffer(LoggingEvent[] events)
+ {
+ // Pass the logging event on to the attached appenders
+ if (m_appenderAttachedImpl != null)
+ {
+ m_appenderAttachedImpl.AppendLoopOnAppenders(events);
+ }
+ }
- #endregion Override implementation of BufferingAppenderSkeleton
+ #endregion Override implementation of BufferingAppenderSkeleton
- #region Implementation of IAppenderAttachable
+ #region Implementation of IAppenderAttachable
- /// <summary>
- /// Adds an <see cref="IAppender" /> to the list of appenders of this
- /// instance.
- /// </summary>
- /// <param name="newAppender">The <see cref="IAppender" /> to add to this appender.</param>
- /// <remarks>
- /// <para>
- /// If the specified <see cref="IAppender" /> is already in the list of
- /// appenders, then it won't be added again.
- /// </para>
- /// </remarks>
- public virtual void AddAppender(IAppender newAppender)
- {
- if (newAppender == null)
- {
- throw new ArgumentNullException("newAppender");
- }
- lock(this)
- {
- if (m_appenderAttachedImpl == null)
- {
- m_appenderAttachedImpl = new log4net.Util.AppenderAttachedImpl();
- }
- m_appenderAttachedImpl.AddAppender(newAppender);
- }
- }
+ /// <summary>
+ /// Adds an <see cref="IAppender" /> to the list of appenders of this
+ /// instance.
+ /// </summary>
+ /// <param name="newAppender">The <see cref="IAppender" /> to add to this appender.</param>
+ /// <remarks>
+ /// <para>
+ /// If the specified <see cref="IAppender" /> is already in the list of
+ /// appenders, then it won't be added again.
+ /// </para>
+ /// </remarks>
+ public virtual void AddAppender(IAppender newAppender)
+ {
+ if (newAppender == null)
+ {
+ throw new ArgumentNullException("newAppender");
+ }
+ lock(this)
+ {
+ if (m_appenderAttachedImpl == null)
+ {
+ m_appenderAttachedImpl = new log4net.Util.AppenderAttachedImpl();
+ }
+ m_appenderAttachedImpl.AddAppender(newAppender);
+ }
+ }
- /// <summary>
- /// Gets the appenders contained in this appender as an
- /// <see cref="System.Collections.ICollection"/>.
- /// </summary>
- /// <remarks>
- /// If no appenders can be found, then an <see cref="EmptyCollection"/>
- /// is returned.
- /// </remarks>
- /// <returns>
- /// A collection of the appenders in this appender.
- /// </returns>
- public virtual AppenderCollection Appenders
- {
- get
- {
- lock(this)
- {
- if (m_appenderAttachedImpl == null)
- {
- return AppenderCollection.EmptyCollection;
- }
- else
- {
- return m_appenderAttachedImpl.Appenders;
- }
- }
- }
- }
+ /// <summary>
+ /// Gets the appenders contained in this appender as an
+ /// <see cref="System.Collections.ICollection"/>.
+ /// </summary>
+ /// <remarks>
+ /// If no appenders can be found, then an <see cref="EmptyCollection"/>
+ /// is returned.
+ /// </remarks>
+ /// <returns>
+ /// A collection of the appenders in this appender.
+ /// </returns>
+ public virtual AppenderCollection Appenders
+ {
+ get
+ {
+ lock(this)
+ {
+ if (m_appenderAttachedImpl == null)
+ {
+ return AppenderCollection.EmptyCollection;
+ }
+ else
+ {
+ return m_appenderAttachedImpl.Appenders;
+ }
+ }
+ }
+ }
- /// <summary>
- /// Looks for the appender with the specified name.
- /// </summary>
- /// <param name="name">The name of the appender to lookup.</param>
- /// <returns>
- /// The appender with the specified name, or <c>null</c>.
- /// </returns>
- /// <remarks>
- /// <para>
- /// Get the named appender attached to this buffering appender.
- /// </para>
- /// </remarks>
- public virtual IAppender GetAppender(string name)
- {
- lock(this)
- {
- if (m_appenderAttachedImpl == null || name == null)
- {
- return null;
- }
+ /// <summary>
+ /// Looks for the appender with the specified name.
+ /// </summary>
+ /// <param name="name">The name of the appender to lookup.</param>
+ /// <returns>
+ /// The appender with the specified name, or <c>null</c>.
+ /// </returns>
+ /// <remarks>
+ /// <para>
+ /// Get the named appender attached to this buffering appender.
+ /// </para>
+ /// </remarks>
+ public virtual IAppender GetAppender(string name)
+ {
+ lock(this)
+ {
+ if (m_appenderAttachedImpl == null || name == null)
+ {
+ return null;
+ }
- return m_appenderAttachedImpl.GetAppender(name);
- }
- }
+ return m_appenderAttachedImpl.GetAppender(name);
+ }
+ }
- /// <summary>
- /// Removes all previously added appenders from this appender.
- /// </summary>
- /// <remarks>
- /// <para>
- /// This is useful when re-reading configuration information.
- /// </para>
- /// </remarks>
- public virtual void RemoveAllAppenders()
- {
- lock(this)
- {
- if (m_appenderAttachedImpl != null)
- {
- m_appenderAttachedImpl.RemoveAllAppenders();
- m_appenderAttachedImpl = null;
- }
- }
- }
+ /// <summary>
+ /// Removes all previously added appenders from this appender.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// This is useful when re-reading configuration information.
+ /// </para>
+ /// </remarks>
+ public virtual void RemoveAllAppenders()
+ {
+ lock(this)
+ {
+ if (m_appenderAttachedImpl != null)
+ {
+ m_appenderAttachedImpl.RemoveAllAppenders();
+ m_appenderAttachedImpl = null;
+ }
+ }
+ }
- /// <summary>
- /// Removes the specified appender from the list of appenders.
- /// </summary>
- /// <param name="appender">The appender to remove.</param>
- /// <returns>The appender removed from the list</returns>
- /// <remarks>
- /// The appender removed is not closed.
- /// If you are discarding the appender you must call
- /// <see cref="IAppender.Close"/> on the appender removed.
- /// </remarks>
- public virtual IAppender RemoveAppender(IAppender appender)
- {
- lock(this)
- {
- if (appender != null && m_appenderAttachedImpl != null)
- {
- return m_appenderAttachedImpl.RemoveAppender(appender);
- }
- }
- return null;
- }
+ /// <summary>
+ /// Removes the specified appender from the list of appenders.
+ /// </summary>
+ /// <param name="appender">The appender to remove.</param>
+ /// <returns>The appender removed from the list</returns>
+ /// <remarks>
+ /// The appender removed is not closed.
+ /// If you are discarding the appender you must call
+ /// <see cref="IAppender.Close"/> on the appender removed.
+ /// </remarks>
+ public virtual IAppender RemoveAppender(IAppender appender)
+ {
+ lock(this)
+ {
+ if (appender != null && m_appenderAttachedImpl != null)
+ {
+ return m_appenderAttachedImpl.RemoveAppender(appender);
+ }
+ }
+ return null;
+ }
- /// <summary>
- /// Removes the appender with the specified name from the list of appenders.
- /// </summary>
- /// <param name="name">The name of the appender to remove.</param>
- /// <returns>The appender removed from the list</returns>
- /// <remarks>
- /// The appender removed is not closed.
- /// If you are discarding the appender you must call
- /// <see cref="IAppender.Close"/> on the appender removed.
- /// </remarks>
- public virtual IAppender RemoveAppender(string name)
- {
- lock(this)
- {
- if (name != null && m_appenderAttachedImpl != null)
- {
- return m_appenderAttachedImpl.RemoveAppender(name);
- }
- }
- return null;
- }
+ /// <summary>
+ /// Removes the appender with the specified name from the list of appenders.
+ /// </summary>
+ /// <param name="name">The name of the appender to remove.</param>
+ /// <returns>The appender removed from the list</returns>
+ /// <remarks>
+ /// The appender removed is not closed.
+ /// If you are discarding the appender you must call
+ /// <see cref="IAppender.Close"/> on the appender removed.
+ /// </remarks>
+ public virtual IAppender RemoveAppender(string name)
+ {
+ lock(this)
+ {
+ if (name != null && m_appenderAttachedImpl != null)
+ {
+ return m_appenderAttachedImpl.RemoveAppender(name);
+ }
+ }
+ return null;
+ }
- #endregion Implementation of IAppenderAttachable
+ #endregion Implementation of IAppenderAttachable
- #region Private Instance Fields
+ #region Private Instance Fields
- /// <summary>
- /// Implementation of the <see cref="IAppenderAttachable"/> interface
- /// </summary>
- private AppenderAttachedImpl m_appenderAttachedImpl;
+ /// <summary>
+ /// Implementation of the <see cref="IAppenderAttachable"/> interface
+ /// </summary>
+ private AppenderAttachedImpl m_appenderAttachedImpl;
- #endregion Private Instance Fields
- }
+ #endregion Private Instance Fields
+ }
}
diff --git a/src/log4net/Appender/ColoredConsoleAppender.cs b/src/log4net/Appender/ColoredConsoleAppender.cs
index cbcc875..c90cf5f 100644
--- a/src/log4net/Appender/ColoredConsoleAppender.cs
+++ b/src/log4net/Appender/ColoredConsoleAppender.cs
@@ -38,627 +38,627 @@
namespace log4net.Appender
{
- /// <summary>
- /// Appends logging events to the console.
- /// </summary>
- /// <remarks>
- /// <para>
- /// ColoredConsoleAppender appends log events to the standard output stream
- /// or the error output stream using a layout specified by the
- /// user. It also allows the color of a specific type of message to be set.
- /// </para>
- /// <para>
- /// By default, all output is written to the console's standard output stream.
- /// The <see cref="Target"/> property can be set to direct the output to the
- /// error stream.
- /// </para>
- /// <para>
- /// NOTE: This appender writes directly to the application's attached console
- /// not to the <c>System.Console.Out</c> or <c>System.Console.Error</c> <c>TextWriter</c>.
- /// The <c>System.Console.Out</c> and <c>System.Console.Error</c> streams can be
- /// programmatically redirected (for example NUnit does this to capture program output).
- /// This appender will ignore these redirections because it needs to use Win32
- /// API calls to colorize the output. To respect these redirections the <see cref="ConsoleAppender"/>
- /// must be used.
- /// </para>
- /// <para>
- /// When configuring the colored console appender, mapping should be
- /// specified to map a logging level to a color. For example:
- /// </para>
- /// <code lang="XML" escaped="true">
- /// <mapping>
- /// <level value="ERROR" />
- /// <foreColor value="White" />
- /// <backColor value="Red, HighIntensity" />
- /// </mapping>
- /// <mapping>
- /// <level value="DEBUG" />
- /// <backColor value="Green" />
- /// </mapping>
- /// </code>
- /// <para>
- /// The Level is the standard log4net logging level and ForeColor and BackColor can be any
- /// combination of the following values:
- /// <list type="bullet">
- /// <item><term>Blue</term><description></description></item>
- /// <item><term>Green</term><description></description></item>
- /// <item><term>Red</term><description></description></item>
- /// <item><term>White</term><description></description></item>
- /// <item><term>Yellow</term><description></description></item>
- /// <item><term>Purple</term><description></description></item>
- /// <item><term>Cyan</term><description></description></item>
- /// <item><term>HighIntensity</term><description></description></item>
- /// </list>
- /// </para>
- /// </remarks>
- /// <author>Rick Hobbs</author>
- /// <author>Nicko Cadell</author>
- public class ColoredConsoleAppender : AppenderSkeleton
- {
- #region Colors Enum
+ /// <summary>
+ /// Appends logging events to the console.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// ColoredConsoleAppender appends log events to the standard output stream
+ /// or the error output stream using a layout specified by the
+ /// user. It also allows the color of a specific type of message to be set.
+ /// </para>
+ /// <para>
+ /// By default, all output is written to the console's standard output stream.
+ /// The <see cref="Target"/> property can be set to direct the output to the
+ /// error stream.
+ /// </para>
+ /// <para>
+ /// NOTE: This appender writes directly to the application's attached console
+ /// not to the <c>System.Console.Out</c> or <c>System.Console.Error</c> <c>TextWriter</c>.
+ /// The <c>System.Console.Out</c> and <c>System.Console.Error</c> streams can be
+ /// programmatically redirected (for example NUnit does this to capture program output).
+ /// This appender will ignore these redirections because it needs to use Win32
+ /// API calls to colorize the output. To respect these redirections the <see cref="ConsoleAppender"/>
+ /// must be used.
+ /// </para>
+ /// <para>
+ /// When configuring the colored console appender, mapping should be
+ /// specified to map a logging level to a color. For example:
+ /// </para>
+ /// <code lang="XML" escaped="true">
+ /// <mapping>
+ /// <level value="ERROR" />
+ /// <foreColor value="White" />
+ /// <backColor value="Red, HighIntensity" />
+ /// </mapping>
+ /// <mapping>
+ /// <level value="DEBUG" />
+ /// <backColor value="Green" />
+ /// </mapping>
+ /// </code>
+ /// <para>
+ /// The Level is the standard log4net logging level and ForeColor and BackColor can be any
+ /// combination of the following values:
+ /// <list type="bullet">
+ /// <item><term>Blue</term><description></description></item>
+ /// <item><term>Green</term><description></description></item>
+ /// <item><term>Red</term><description></description></item>
+ /// <item><term>White</term><description></description></item>
+ /// <item><term>Yellow</term><description></description></item>
+ /// <item><term>Purple</term><description></description></item>
+ /// <item><term>Cyan</term><description></description></item>
+ /// <item><term>HighIntensity</term><description></description></item>
+ /// </list>
+ /// </para>
+ /// </remarks>
+ /// <author>Rick Hobbs</author>
+ /// <author>Nicko Cadell</author>
+ public class ColoredConsoleAppender : AppenderSkeleton
+ {
+ #region Colors Enum
- /// <summary>
- /// The enum of possible color values for use with the color mapping method
- /// </summary>
- /// <remarks>
- /// <para>
- /// The following flags can be combined together to
- /// form the colors.
- /// </para>
- /// </remarks>
- /// <seealso cref="ColoredConsoleAppender" />
- [Flags]
- public enum Colors : int
- {
- /// <summary>
- /// color is blue
- /// </summary>
- Blue = 0x0001,
+ /// <summary>
+ /// The enum of possible color values for use with the color mapping method
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// The following flags can be combined together to
+ /// form the colors.
+ /// </para>
+ /// </remarks>
+ /// <seealso cref="ColoredConsoleAppender" />
+ [Flags]
+ public enum Colors : int
+ {
+ /// <summary>
+ /// color is blue
+ /// </summary>
+ Blue = 0x0001,
- /// <summary>
- /// color is green
- /// </summary>
- Green = 0x0002,
+ /// <summary>
+ /// color is green
+ /// </summary>
+ Green = 0x0002,
- /// <summary>
- /// color is red
- /// </summary>
- Red = 0x0004,
+ /// <summary>
+ /// color is red
+ /// </summary>
+ Red = 0x0004,
- /// <summary>
- /// color is white
- /// </summary>
- White = Blue | Green | Red,
+ /// <summary>
+ /// color is white
+ /// </summary>
+ White = Blue | Green | Red,
- /// <summary>
- /// color is yellow
- /// </summary>
- Yellow = Red | Green,
+ /// <summary>
+ /// color is yellow
+ /// </summary>
+ Yellow = Red | Green,
- /// <summary>
- /// color is purple
- /// </summary>
- Purple = Red | Blue,
+ /// <summary>
+ /// color is purple
+ /// </summary>
+ Purple = Red | Blue,
- /// <summary>
- /// color is cyan
- /// </summary>
- Cyan = Green | Blue,
+ /// <summary>
+ /// color is cyan
+ /// </summary>
+ Cyan = Green | Blue,
- /// <summary>
- /// color is intensified
- /// </summary>
- HighIntensity = 0x0008,
- }
+ /// <summary>
+ /// color is intensified
+ /// </summary>
+ HighIntensity = 0x0008,
+ }
- #endregion // Colors Enum
+ #endregion // Colors Enum
- #region Public Instance Constructors
+ #region Public Instance Constructors
- /// <summary>
- /// Initializes a new instance of the <see cref="ColoredConsoleAppender" /> class.
- /// </summary>
- /// <remarks>
- /// The instance of the <see cref="ColoredConsoleAppender" /> class is set up to write
- /// to the standard output stream.
- /// </remarks>
- public ColoredConsoleAppender()
- {
- }
+ /// <summary>
+ /// Initializes a new instance of the <see cref="ColoredConsoleAppender" /> class.
+ /// </summary>
+ /// <remarks>
+ /// The instance of the <see cref="ColoredConsoleAppender" /> class is set up to write
+ /// to the standard output stream.
+ /// </remarks>
+ public ColoredConsoleAppender()
+ {
+ }
- /// <summary>
- /// Initializes a new instance of the <see cref="ColoredConsoleAppender" /> class
- /// with the specified layout.
- /// </summary>
- /// <param name="layout">the layout to use for this appender</param>
- /// <remarks>
- /// The instance of the <see cref="ColoredConsoleAppender" /> class is set up to write
- /// to the standard output stream.
- /// </remarks>
- [Obsolete("Instead use the default constructor and set the Layout property")]
- public ColoredConsoleAppender(ILayout layout) : this(layout, false)
- {
- }
+ /// <summary>
+ /// Initializes a new instance of the <see cref="ColoredConsoleAppender" /> class
+ /// with the specified layout.
+ /// </summary>
+ /// <param name="layout">the layout to use for this appender</param>
+ /// <remarks>
+ /// The instance of the <see cref="ColoredConsoleAppender" /> class is set up to write
+ /// to the standard output stream.
+ /// </remarks>
+ [Obsolete("Instead use the default constructor and set the Layout property")]
+ public ColoredConsoleAppender(ILayout layout) : this(layout, false)
+ {
+ }
- /// <summary>
- /// Initializes a new instance of the <see cref="ColoredConsoleAppender" /> class
- /// with the specified layout.
- /// </summary>
- /// <param name="layout">the layout to use for this appender</param>
- /// <param name="writeToErrorStream">flag set to <c>true</c> to write to the console error stream</param>
- /// <remarks>
- /// When <paramref name="writeToErrorStream" /> is set to <c>true</c>, output is written to
- /// the standard error output stream. Otherwise, output is written to the standard
- /// output stream.
- /// </remarks>
- [Obsolete("Instead use the default constructor and set the Layout & Target properties")]
- public ColoredConsoleAppender(ILayout layout, bool writeToErrorStream)
- {
- Layout = layout;
- m_writeToErrorStream = writeToErrorStream;
- }
+ /// <summary>
+ /// Initializes a new instance of the <see cref="ColoredConsoleAppender" /> class
+ /// with the specified layout.
+ /// </summary>
+ /// <param name="layout">the layout to use for this appender</param>
+ /// <param name="writeToErrorStream">flag set to <c>true</c> to write to the console error stream</param>
+ /// <remarks>
+ /// When <paramref name="writeToErrorStream" /> is set to <c>true</c>, output is written to
+ /// the standard error output stream. Otherwise, output is written to the standard
+ /// output stream.
+ /// </remarks>
+ [Obsolete("Instead use the default constructor and set the Layout & Target properties")]
+ public ColoredConsoleAppender(ILayout layout, bool writeToErrorStream)
+ {
+ Layout = layout;
+ m_writeToErrorStream = writeToErrorStream;
+ }
- #endregion // Public Instance Constructors
+ #endregion // Public Instance Constructors
- #region Public Instance Properties
+ #region Public Instance Properties
- /// <summary>
- /// Target is the value of the console output stream.
- /// This is either <c>"Console.Out"</c> or <c>"Console.Error"</c>.
- /// </summary>
- /// <value>
- /// Target is the value of the console output stream.
- /// This is either <c>"Console.Out"</c> or <c>"Console.Error"</c>.
- /// </value>
- /// <remarks>
- /// <para>
- /// Target is the value of the console output stream.
- /// This is either <c>"Console.Out"</c> or <c>"Console.Error"</c>.
- /// </para>
- /// </remarks>
- public virtual string Target
- {
- get { return m_writeToErrorStream ? ConsoleError : ConsoleOut; }
- set
- {
- string v = value.Trim();
-
- if (string.Compare(ConsoleError, v, true, CultureInfo.InvariantCulture) == 0)
- {
- m_writeToErrorStream = true;
- }
- else
- {
- m_writeToErrorStream = false;
- }
- }
- }
+ /// <summary>
+ /// Target is the value of the console output stream.
+ /// This is either <c>"Console.Out"</c> or <c>"Console.Error"</c>.
+ /// </summary>
+ /// <value>
+ /// Target is the value of the console output stream.
+ /// This is either <c>"Console.Out"</c> or <c>"Console.Error"</c>.
+ /// </value>
+ /// <remarks>
+ /// <para>
+ /// Target is the value of the console output stream.
+ /// This is either <c>"Console.Out"</c> or <c>"Console.Error"</c>.
+ /// </para>
+ /// </remarks>
+ public virtual string Target
+ {
+ get { return m_writeToErrorStream ? ConsoleError : ConsoleOut; }
+ set
+ {
+ string v = value.Trim();
+
+ if (string.Compare(ConsoleError, v, true, CultureInfo.InvariantCulture) == 0)
+ {
+ m_writeToErrorStream = true;
+ }
+ else
+ {
+ m_writeToErrorStream = false;
+ }
+ }
+ }
- /// <summary>
- /// Add a mapping of level to color - done by the config file
- /// </summary>
- /// <param name="mapping">The mapping to add</param>
- /// <remarks>
- /// <para>
- /// Add a <see cref="LevelColors"/> mapping to this appender.
- /// Each mapping defines the foreground and background colors
- /// for a level.
- /// </para>
- /// </remarks>
- public void AddMapping(LevelColors mapping)
- {
- m_levelMapping.Add(mapping);
- }
+ /// <summary>
+ /// Add a mapping of level to color - done by the config file
+ /// </summary>
+ /// <param name="mapping">The mapping to add</param>
+ /// <remarks>
+ /// <para>
+ /// Add a <see cref="LevelColors"/> mapping to this appender.
+ /// Each mapping defines the foreground and background colors
+ /// for a level.
+ /// </para>
+ /// </remarks>
+ public void AddMapping(LevelColors mapping)
+ {
+ m_levelMapping.Add(mapping);
+ }
- #endregion // Public Instance Properties
+ #endregion // Public Instance Properties
- #region Override implementation of AppenderSkeleton
+ #region Override implementation of AppenderSkeleton
- /// <summary>
- /// This method is called by the <see cref="M:AppenderSkeleton.DoAppend(log4net.Core.LoggingEvent)"/> method.
- /// </summary>
- /// <param name="loggingEvent">The event to log.</param>
- /// <remarks>
- /// <para>
- /// Writes the event to the console.
- /// </para>
- /// <para>
- /// The format of the output will depend on the appender's layout.
- /// </para>
- /// </remarks>
+ /// <summary>
+ /// This method is called by the <see cref="M:AppenderSkeleton.DoAppend(log4net.Core.LoggingEvent)"/> method.
+ /// </summary>
+ /// <param name="loggingEvent">The event to log.</param>
+ /// <remarks>
+ /// <para>
+ /// Writes the event to the console.
+ /// </para>
+ /// <para>
+ /// The format of the output will depend on the appender's layout.
+ /// </para>
+ /// </remarks>
#if NET_4_0 || MONO_4_0 || NETSTANDARD
- [System.Security.SecuritySafeCritical]
+ [System.Security.SecuritySafeCritical]
#endif
- [System.Security.Permissions.SecurityPermission(System.Security.Permissions.SecurityAction.Demand, UnmanagedCode = true)]
- protected override void Append(log4net.Core.LoggingEvent loggingEvent)
- {
- if (m_consoleOutputWriter != null)
- {
- IntPtr consoleHandle = IntPtr.Zero;
- if (m_writeToErrorStream)
- {
- // Write to the error stream
- consoleHandle = GetStdHandle(STD_ERROR_HANDLE);
- }
- else
- {
- // Write to the output stream
- consoleHandle = GetStdHandle(STD_OUTPUT_HANDLE);
- }
+ [System.Security.Permissions.SecurityPermission(System.Security.Permissions.SecurityAction.Demand, UnmanagedCode = true)]
+ protected override void Append(log4net.Core.LoggingEvent loggingEvent)
+ {
+ if (m_consoleOutputWriter != null)
+ {
+ IntPtr consoleHandle = IntPtr.Zero;
+ if (m_writeToErrorStream)
+ {
+ // Write to the error stream
+ consoleHandle = GetStdHandle(STD_ERROR_HANDLE);
+ }
+ else
+ {
+ // Write to the output stream
+ consoleHandle = GetStdHandle(STD_OUTPUT_HANDLE);
+ }
- // Default to white on black
- ushort colorInfo = (ushort)Colors.White;
+ // Default to white on black
+ ushort colorInfo = (ushort)Colors.White;
- // see if there is a specified lookup
- LevelColors levelColors = m_levelMapping.Lookup(loggingEvent.Level) as LevelColors;
- if (levelColors != null)
- {
- colorInfo = levelColors.CombinedColor;
- }
+ // see if there is a specified lookup
+ LevelColors levelColors = m_levelMapping.Lookup(loggingEvent.Level) as LevelColors;
+ if (levelColors != null)
+ {
+ colorInfo = levelColors.CombinedColor;
+ }
- // Render the event to a string
- string strLoggingMessage = RenderLoggingEvent(loggingEvent);
+ // Render the event to a string
+ string strLoggingMessage = RenderLoggingEvent(loggingEvent);
- // get the current console color - to restore later
- CONSOLE_SCREEN_BUFFER_INFO bufferInfo;
- GetConsoleScreenBufferInfo(consoleHandle, out bufferInfo);
+ // get the current console color - to restore later
+ CONSOLE_SCREEN_BUFFER_INFO bufferInfo;
+ GetConsoleScreenBufferInfo(consoleHandle, out bufferInfo);
- // set the console colors
- SetConsoleTextAttribute(consoleHandle, colorInfo);
+ // set the console colors
+ SetConsoleTextAttribute(consoleHandle, colorInfo);
- // Using WriteConsoleW seems to be unreliable.
- // If a large buffer is written, say 15,000 chars
- // Followed by a larger buffer, say 20,000 chars
- // then WriteConsoleW will fail, last error 8
- // 'Not enough storage is available to process this command.'
- //
- // Although the documentation states that the buffer must
- // be less that 64KB (i.e. 32,000 WCHARs) the longest string
- // that I can write out a the first call to WriteConsoleW
- // is only 30,704 chars.
- //
- // Unlike the WriteFile API the WriteConsoleW method does not
- // seem to be able to partially write out from the input buffer.
- // It does have a lpNumberOfCharsWritten parameter, but this is
- // either the length of the input buffer if any output was written,
- // or 0 when an error occurs.
- //
- // All results above were observed on Windows XP SP1 running
- // .NET runtime 1.1 SP1.
- //
- // Old call to WriteConsoleW:
- //
- // WriteConsoleW(
- // consoleHandle,
- // strLoggingMessage,
- // (UInt32)strLoggingMessage.Length,
- // out (UInt32)ignoreWrittenCount,
- // IntPtr.Zero);
- //
- // Instead of calling WriteConsoleW we use WriteFile which
- // handles large buffers correctly. Because WriteFile does not
- // handle the codepage conversion as WriteConsoleW does we
- // need to use a System.IO.StreamWriter with the appropriate
- // Encoding. The WriteFile calls are wrapped up in the
- // System.IO.__ConsoleStream internal class obtained through
- // the System.Console.OpenStandardOutput method.
- //
- // See the ActivateOptions method below for the code that
- // retrieves and wraps the stream.
+ // Using WriteConsoleW seems to be unreliable.
+ // If a large buffer is written, say 15,000 chars
+ // Followed by a larger buffer, say 20,000 chars
+ // then WriteConsoleW will fail, last error 8
+ // 'Not enough storage is available to process this command.'
+ //
+ // Although the documentation states that the buffer must
+ // be less that 64KB (i.e. 32,000 WCHARs) the longest string
+ // that I can write out a the first call to WriteConsoleW
+ // is only 30,704 chars.
+ //
+ // Unlike the WriteFile API the WriteConsoleW method does not
+ // seem to be able to partially write out from the input buffer.
+ // It does have a lpNumberOfCharsWritten parameter, but this is
+ // either the length of the input buffer if any output was written,
+ // or 0 when an error occurs.
+ //
+ // All results above were observed on Windows XP SP1 running
+ // .NET runtime 1.1 SP1.
+ //
+ // Old call to WriteConsoleW:
+ //
+ // WriteConsoleW(
+ // consoleHandle,
+ // strLoggingMessage,
+ // (UInt32)strLoggingMessage.Length,
+ // out (UInt32)ignoreWrittenCount,
+ // IntPtr.Zero);
+ //
+ // Instead of calling WriteConsoleW we use WriteFile which
+ // handles large buffers correctly. Because WriteFile does not
+ // handle the codepage conversion as WriteConsoleW does we
+ // need to use a System.IO.StreamWriter with the appropriate
+ // Encoding. The WriteFile calls are wrapped up in the
+ // System.IO.__ConsoleStream internal class obtained through
+ // the System.Console.OpenStandardOutput method.
+ //
+ // See the ActivateOptions method below for the code that
+ // retrieves and wraps the stream.
- // The windows console uses ScrollConsoleScreenBuffer internally to
- // scroll the console buffer when the display buffer of the console
- // has been used up. ScrollConsoleScreenBuffer fills the area uncovered
- // by moving the current content with the background color
- // currently specified on the console. This means that it fills the
- // whole line in front of the cursor position with the current
- // background color.
- // This causes an issue when writing out text with a non default
- // background color. For example; We write a message with a Blue
- // background color and the scrollable area of the console is full.
- // When we write the newline at the end of the message the console
- // needs to scroll the buffer to make space available for the new line.
- // The ScrollConsoleScreenBuffer internals will fill the newly created
- // space with the current background color: Blue.
- // We then change the console color back to default (White text on a
- // Black background). We write some text to the console, the text is
- // written correctly in White with a Black background, however the
- // remainder of the line still has a Blue background.
- //
- // This causes a disjointed appearance to the output where the background
- // colors change.
- //
- // This can be remedied by restoring the console colors before causing
- // the buffer to scroll, i.e. before writing the last newline. This does
- // assume that the rendered message will end with a newline.
- //
- // Therefore we identify a trailing newline in the message and don't
- // write this to the output, then we restore the console color and write
- // a newline. Note that we must AutoFlush before we restore the console
- // color otherwise we will have no effect.
- //
- // There will still be a slight artefact for the last line of the message
- // will have the background extended to the end of the line, however this
- // is unlikely to cause any user issues.
- //
- // Note that none of the above is visible while the console buffer is scrollable
- // within the console window viewport, the effects only arise when the actual
- // buffer is full and needs to be scrolled.
+ // The windows console uses ScrollConsoleScreenBuffer internally to
+ // scroll the console buffer when the display buffer of the console
+ // has been used up. ScrollConsoleScreenBuffer fills the area uncovered
+ // by moving the current content with the background color
+ // currently specified on the console. This means that it fills the
+ // whole line in front of the cursor position with the current
+ // background color.
+ // This causes an issue when writing out text with a non default
+ // background color. For example; We write a message with a Blue
+ // background color and the scrollable area of the console is full.
+ // When we write the newline at the end of the message the console
+ // needs to scroll the buffer to make space available for the new line.
+ // The ScrollConsoleScreenBuffer internals will fill the newly created
+ // space with the current background color: Blue.
+ // We then change the console color back to default (White text on a
+ // Black background). We write some text to the console, the text is
+ // written correctly in White with a Black background, however the
+ // remainder of the line still has a Blue background.
+ //
+ // This causes a disjointed appearance to the output where the background
+ // colors change.
+ //
+ // This can be remedied by restoring the console colors before causing
+ // the buffer to scroll, i.e. before writing the last newline. This does
+ // assume that the rendered message will end with a newline.
+ //
+ // Therefore we identify a trailing newline in the message and don't
+ // write this to the output, then we restore the console color and write
+ // a newline. Note that we must AutoFlush before we restore the console
+ // color otherwise we will have no effect.
+ //
+ // There will still be a slight artefact for the last line of the message
+ // will have the background extended to the end of the line, however this
+ // is unlikely to cause any user issues.
+ //
+ // Note that none of the above is visible while the console buffer is scrollable
+ // within the console window viewport, the effects only arise when the actual
+ // buffer is full and needs to be scrolled.
- char[] messageCharArray = strLoggingMessage.ToCharArray();
- int arrayLength = messageCharArray.Length;
- bool appendNewline = false;
+ char[] messageCharArray = strLoggingMessage.ToCharArray();
+ int arrayLength = messageCharArray.Length;
+ bool appendNewline = false;
- // Trim off last newline, if it exists
- if (arrayLength > 1 && messageCharArray[arrayLength-2] == '\r' && messageCharArray[arrayLength-1] == '\n')
- {
- arrayLength -= 2;
- appendNewline = true;
- }
+ // Trim off last newline, if it exists
+ if (arrayLength > 1 && messageCharArray[arrayLength-2] == '\r' && messageCharArray[arrayLength-1] == '\n')
+ {
+ arrayLength -= 2;
+ appendNewline = true;
+ }
- // Write to the output stream
- m_consoleOutputWriter.Write(messageCharArray, 0, arrayLength);
+ // Write to the output stream
+ m_consoleOutputWriter.Write(messageCharArray, 0, arrayLength);
- // Restore the console back to its previous color scheme
- SetConsoleTextAttribute(consoleHandle, bufferInfo.wAttributes);
+ // Restore the console back to its previous color scheme
+ SetConsoleTextAttribute(consoleHandle, bufferInfo.wAttributes);
- if (appendNewline)
- {
- // Write the newline, after changing the color scheme
- m_consoleOutputWriter.Write(s_windowsNewline, 0, 2);
- }
- }
- }
+ if (appendNewline)
+ {
+ // Write the newline, after changing the color scheme
+ m_consoleOutputWriter.Write(s_windowsNewline, 0, 2);
+ }
+ }
+ }
- private static readonly char[] s_windowsNewline = {'\r', '\n'};
+ private static readonly char[] s_windowsNewline = {'\r', '\n'};
- /// <summary>
- /// This appender requires a <see cref="Layout"/> to be set.
- /// </summary>
- /// <value><c>true</c></value>
- /// <remarks>
- /// <para>
- /// This appender requires a <see cref="Layout"/> to be set.
- /// </para>
- /// </remarks>
- protected override bool RequiresLayout
- {
- get { return true; }
- }
+ /// <summary>
+ /// This appender requires a <see cref="Layout"/> to be set.
+ /// </summary>
+ /// <value><c>true</c></value>
+ /// <remarks>
+ /// <para>
+ /// This appender requires a <see cref="Layout"/> to be set.
+ /// </para>
+ /// </remarks>
+ protected override bool RequiresLayout
+ {
+ get { return true; }
+ }
- /// <summary>
- /// Initialize the options for this appender
- /// </summary>
- /// <remarks>
- /// <para>
- /// Initialize the level to color mappings set on this appender.
- /// </para>
- /// </remarks>
+ /// <summary>
+ /// Initialize the options for this appender
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Initialize the level to color mappings set on this appender.
+ /// </para>
+ /// </remarks>
#if NET_4_0 || MONO_4_0 || NETSTANDARD
- [System.Security.SecuritySafeCritical]
+ [System.Security.SecuritySafeCritical]
#endif
- [System.Security.Permissions.SecurityPermission(System.Security.Permissions.SecurityAction.Demand, UnmanagedCode = true)]
- public override void ActivateOptions()
- {
- base.ActivateOptions();
- m_levelMapping.ActivateOptions();
+ [System.Security.Permissions.SecurityPermission(System.Security.Permissions.SecurityAction.Demand, UnmanagedCode = true)]
+ public override void ActivateOptions()
+ {
+ base.ActivateOptions();
+ m_levelMapping.ActivateOptions();
- System.IO.Stream consoleOutputStream = null;
+ System.IO.Stream consoleOutputStream = null;
- // Use the Console methods to open a Stream over the console std handle
- if (m_writeToErrorStream)
- {
- // Write to the error stream
- consoleOutputStream = Console.OpenStandardError();
- }
- else
- {
- // Write to the output stream
- consoleOutputStream = Console.OpenStandardOutput();
- }
+ // Use the Console methods to open a Stream over the console std handle
+ if (m_writeToErrorStream)
+ {
+ // Write to the error stream
+ consoleOutputStream = Console.OpenStandardError();
+ }
+ else
+ {
+ // Write to the output stream
+ consoleOutputStream = Console.OpenStandardOutput();
+ }
- // Lookup the codepage encoding for the console
- System.Text.Encoding consoleEncoding = System.Text.Encoding.GetEncoding(GetConsoleOutputCP());
+ // Lookup the codepage encoding for the console
+ System.Text.Encoding consoleEncoding = System.Text.Encoding.GetEncoding(GetConsoleOutputCP());
- // Create a writer around the console stream
- m_consoleOutputWriter = new System.IO.StreamWriter(consoleOutputStream, consoleEncoding, 0x100);
+ // Create a writer around the console stream
+ m_consoleOutputWriter = new System.IO.StreamWriter(consoleOutputStream, consoleEncoding, 0x100);
- m_consoleOutputWriter.AutoFlush = true;
+ m_consoleOutputWriter.AutoFlush = true;
- // SuppressFinalize on m_consoleOutputWriter because all it will do is flush
- // and close the file handle. Because we have set AutoFlush the additional flush
- // is not required. The console file handle should not be closed, so we don't call
- // Dispose, Close or the finalizer.
- GC.SuppressFinalize(m_consoleOutputWriter);
- }
+ // SuppressFinalize on m_consoleOutputWriter because all it will do is flush
+ // and close the file handle. Because we have set AutoFlush the additional flush
+ // is not required. The console file handle should not be closed, so we don't call
+ // Dispose, Close or the finalizer.
+ GC.SuppressFinalize(m_consoleOutputWriter);
+ }
- #endregion // Override implementation of AppenderSkeleton
+ #endregion // Override implementation of AppenderSkeleton
- #region Public Static Fields
+ #region Public Static Fields
- /// <summary>
- /// The <see cref="ColoredConsoleAppender.Target"/> to use when writing to the Console
- /// standard output stream.
- /// </summary>
- /// <remarks>
- /// <para>
- /// The <see cref="ColoredConsoleAppender.Target"/> to use when writing to the Console
- /// standard output stream.
- /// </para>
- /// </remarks>
- public const string ConsoleOut = "Console.Out";
+ /// <summary>
+ /// The <see cref="ColoredConsoleAppender.Target"/> to use when writing to the Console
+ /// standard output stream.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// The <see cref="ColoredConsoleAppender.Target"/> to use when writing to the Console
+ /// standard output stream.
+ /// </para>
+ /// </remarks>
+ public const string ConsoleOut = "Console.Out";
- /// <summary>
- /// The <see cref="ColoredConsoleAppender.Target"/> to use when writing to the Console
- /// standard error output stream.
- /// </summary>
- /// <remarks>
- /// <para>
- /// The <see cref="ColoredConsoleAppender.Target"/> to use when writing to the Console
- /// standard error output stream.
- /// </para>
- /// </remarks>
- public const string ConsoleError = "Console.Error";
+ /// <summary>
+ /// The <see cref="ColoredConsoleAppender.Target"/> to use when writing to the Console
+ /// standard error output stream.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// The <see cref="ColoredConsoleAppender.Target"/> to use when writing to the Console
+ /// standard error output stream.
+ /// </para>
+ /// </remarks>
+ public const string ConsoleError = "Console.Error";
- #endregion // Public Static Fields
+ #endregion // Public Static Fields
- #region Private Instances Fields
+ #region Private Instances Fields
- /// <summary>
- /// Flag to write output to the error stream rather than the standard output stream
- /// </summary>
- private bool m_writeToErrorStream = false;
+ /// <summary>
+ /// Flag to write output to the error stream rather than the standard output stream
+ /// </summary>
+ private bool m_writeToErrorStream = false;
- /// <summary>
- /// Mapping from level object to color value
- /// </summary>
- private LevelMapping m_levelMapping = new LevelMapping();
+ /// <summary>
+ /// Mapping from level object to color value
+ /// </summary>
+ private LevelMapping m_levelMapping = new LevelMapping();
- /// <summary>
- /// The console output stream writer to write to
- /// </summary>
- /// <remarks>
- /// <para>
- /// This writer is not thread safe.
- /// </para>
- /// </remarks>
- private System.IO.StreamWriter m_consoleOutputWriter = null;
+ /// <summary>
+ /// The console output stream writer to write to
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// This writer is not thread safe.
+ /// </para>
+ /// </remarks>
+ private System.IO.StreamWriter m_consoleOutputWriter = null;
- #endregion // Private Instances Fields
+ #endregion // Private Instances Fields
- #region Win32 Methods
+ #region Win32 Methods
- [DllImport("Kernel32.dll", SetLastError=true, CharSet=CharSet.Auto)]
- private static extern int GetConsoleOutputCP();
+ [DllImport("Kernel32.dll", SetLastError=true, CharSet=CharSet.Auto)]
+ private static extern int GetConsoleOutputCP();
- [DllImport("Kernel32.dll", SetLastError=true, CharSet=CharSet.Auto)]
- private static extern bool SetConsoleTextAttribute(
- IntPtr consoleHandle,
- ushort attributes);
+ [DllImport("Kernel32.dll", SetLastError=true, CharSet=CharSet.Auto)]
+ private static extern bool SetConsoleTextAttribute(
+ IntPtr consoleHandle,
+ ushort attributes);
- [DllImport("Kernel32.dll", SetLastError=true, CharSet=CharSet.Auto)]
- private static extern bool GetConsoleScreenBufferInfo(
- IntPtr consoleHandle,
- out CONSOLE_SCREEN_BUFFER_INFO bufferInfo);
+ [DllImport("Kernel32.dll", SetLastError=true, CharSet=CharSet.Auto)]
+ private static extern bool GetConsoleScreenBufferInfo(
+ IntPtr consoleHandle,
+ out CONSOLE_SCREEN_BUFFER_INFO bufferInfo);
-// [DllImport("Kernel32.dll", SetLastError=true, CharSet=CharSet.Unicode)]
-// private static extern bool WriteConsoleW(
-// IntPtr hConsoleHandle,
-// [MarshalAs(UnmanagedType.LPWStr)] string strBuffer,
-// UInt32 bufferLen,
-// out UInt32 written,
-// IntPtr reserved);
+// [DllImport("Kernel32.dll", SetLastError=true, CharSet=CharSet.Unicode)]
+// private static extern bool WriteConsoleW(
+// IntPtr hConsoleHandle,
+// [MarshalAs(UnmanagedType.LPWStr)] string strBuffer,
+// UInt32 bufferLen,
+// out UInt32 written,
+// IntPtr reserved);
- //private const UInt32 STD_INPUT_HANDLE = unchecked((UInt32)(-10));
- private const UInt32 STD_OUTPUT_HANDLE = unchecked((UInt32)(-11));
- private const UInt32 STD_ERROR_HANDLE = unchecked((UInt32)(-12));
+ //private const UInt32 STD_INPUT_HANDLE = unchecked((UInt32)(-10));
+ private const UInt32 STD_OUTPUT_HANDLE = unchecked((UInt32)(-11));
+ private const UInt32 STD_ERROR_HANDLE = unchecked((UInt32)(-12));
- [DllImport("Kernel32.dll", SetLastError=true, CharSet=CharSet.Auto)]
- private static extern IntPtr GetStdHandle(
- UInt32 type);
+ [DllImport("Kernel32.dll", SetLastError=true, CharSet=CharSet.Auto)]
+ private static extern IntPtr GetStdHandle(
+ UInt32 type);
- [StructLayout(LayoutKind.Sequential)]
- private struct COORD
- {
- public UInt16 x;
- public UInt16 y;
- }
+ [StructLayout(LayoutKind.Sequential)]
+ private struct COORD
+ {
+ public UInt16 x;
+ public UInt16 y;
+ }
- [StructLayout(LayoutKind.Sequential)]
- private struct SMALL_RECT
- {
- public UInt16 Left;
- public UInt16 Top;
- public UInt16 Right;
- public UInt16 Bottom;
- }
+ [StructLayout(LayoutKind.Sequential)]
+ private struct SMALL_RECT
+ {
+ public UInt16 Left;
+ public UInt16 Top;
+ public UInt16 Right;
+ public UInt16 Bottom;
+ }
- [StructLayout(LayoutKind.Sequential)]
- private struct CONSOLE_SCREEN_BUFFER_INFO
- {
- public COORD dwSize;
- public COORD dwCursorPosition;
- public ushort wAttributes;
- public SMALL_RECT srWindow;
- public COORD dwMaximumWindowSize;
- }
+ [StructLayout(LayoutKind.Sequential)]
+ private struct CONSOLE_SCREEN_BUFFER_INFO
+ {
+ public COORD dwSize;
+ public COORD dwCursorPosition;
+ public ushort wAttributes;
+ public SMALL_RECT srWindow;
+ public COORD dwMaximumWindowSize;
+ }
- #endregion // Win32 Methods
+ #endregion // Win32 Methods
- #region LevelColors LevelMapping Entry
+ #region LevelColors LevelMapping Entry
- /// <summary>
- /// A class to act as a mapping between the level that a logging call is made at and
- /// the color it should be displayed as.
- /// </summary>
- /// <remarks>
- /// <para>
- /// Defines the mapping between a level and the color it should be displayed in.
- /// </para>
- /// </remarks>
- public class LevelColors : LevelMappingEntry
- {
- private Colors m_foreColor;
- private Colors m_backColor;
- private ushort m_combinedColor = 0;
+ /// <summary>
+ /// A class to act as a mapping between the level that a logging call is made at and
+ /// the color it should be displayed as.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Defines the mapping between a level and the color it should be displayed in.
+ /// </para>
+ /// </remarks>
+ public class LevelColors : LevelMappingEntry
+ {
+ private Colors m_foreColor;
+ private Colors m_backColor;
+ private ushort m_combinedColor = 0;
- /// <summary>
- /// The mapped foreground color for the specified level
- /// </summary>
- /// <remarks>
- /// <para>
- /// Required property.
- /// The mapped foreground color for the specified level.
- /// </para>
- /// </remarks>
- public Colors ForeColor
- {
- get { return m_foreColor; }
- set { m_foreColor = value; }
- }
+ /// <summary>
+ /// The mapped foreground color for the specified level
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Required property.
+ /// The mapped foreground color for the specified level.
+ /// </para>
+ /// </remarks>
+ public Colors ForeColor
+ {
+ get { return m_foreColor; }
+ set { m_foreColor = value; }
+ }
- /// <summary>
- /// The mapped background color for the specified level
- /// </summary>
- /// <remarks>
- /// <para>
- /// Required property.
- /// The mapped background color for the specified level.
- /// </para>
- /// </remarks>
- public Colors BackColor
- {
- get { return m_backColor; }
- set { m_backColor = value; }
- }
+ /// <summary>
+ /// The mapped background color for the specified level
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Required property.
+ /// The mapped background color for the specified level.
+ /// </para>
+ /// </remarks>
+ public Colors BackColor
+ {
+ get { return m_backColor; }
+ set { m_backColor = value; }
+ }
- /// <summary>
- /// Initialize the options for the object
- /// </summary>
- /// <remarks>
- /// <para>
- /// Combine the <see cref="ForeColor"/> and <see cref="BackColor"/> together.
- /// </para>
- /// </remarks>
- public override void ActivateOptions()
- {
- base.ActivateOptions();
- m_combinedColor = (ushort)( (int)m_foreColor + (((int)m_backColor) << 4) );
- }
+ /// <summary>
+ /// Initialize the options for the object
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Combine the <see cref="ForeColor"/> and <see cref="BackColor"/> together.
+ /// </para>
+ /// </remarks>
+ public override void ActivateOptions()
+ {
+ base.ActivateOptions();
+ m_combinedColor = (ushort)( (int)m_foreColor + (((int)m_backColor) << 4) );
+ }
- /// <summary>
- /// The combined <see cref="ForeColor"/> and <see cref="BackColor"/> suitable for
- /// setting the console color.
- /// </summary>
- internal ushort CombinedColor
- {
- get { return m_combinedColor; }
- }
- }
+ /// <summary>
+ /// The combined <see cref="ForeColor"/> and <see cref="BackColor"/> suitable for
+ /// setting the console color.
+ /// </summary>
+ internal ushort CombinedColor
+ {
+ get { return m_combinedColor; }
+ }
+ }
- #endregion // LevelColors LevelMapping Entry
- }
+ #endregion // LevelColors LevelMapping Entry
+ }
}
#endif // !CLI_1_0
diff --git a/src/log4net/Appender/ConsoleAppender.cs b/src/log4net/Appender/ConsoleAppender.cs
index 760aace..7964391 100644
--- a/src/log4net/Appender/ConsoleAppender.cs
+++ b/src/log4net/Appender/ConsoleAppender.cs
@@ -26,196 +26,196 @@
namespace log4net.Appender
{
- /// <summary>
- /// Appends logging events to the console.
- /// </summary>
- /// <remarks>
- /// <para>
- /// ConsoleAppender appends log events to the standard output stream
- /// or the error output stream using a layout specified by the
- /// user.
- /// </para>
- /// <para>
- /// By default, all output is written to the console's standard output stream.
- /// The <see cref="Target"/> property can be set to direct the output to the
- /// error stream.
- /// </para>
- /// <para>
- /// NOTE: This appender writes each message to the <c>System.Console.Out</c> or
- /// <c>System.Console.Error</c> that is set at the time the event is appended.
- /// Therefore it is possible to programmatically redirect the output of this appender
- /// (for example NUnit does this to capture program output). While this is the desired
- /// behavior of this appender it may have security implications in your application.
- /// </para>
- /// </remarks>
- /// <author>Nicko Cadell</author>
- /// <author>Gert Driesen</author>
- public class ConsoleAppender : AppenderSkeleton
- {
- #region Public Instance Constructors
+ /// <summary>
+ /// Appends logging events to the console.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// ConsoleAppender appends log events to the standard output stream
+ /// or the error output stream using a layout specified by the
+ /// user.
+ /// </para>
+ /// <para>
+ /// By default, all output is written to the console's standard output stream.
+ /// The <see cref="Target"/> property can be set to direct the output to the
+ /// error stream.
+ /// </para>
+ /// <para>
+ /// NOTE: This appender writes each message to the <c>System.Console.Out</c> or
+ /// <c>System.Console.Error</c> that is set at the time the event is appended.
+ /// Therefore it is possible to programmatically redirect the output of this appender
+ /// (for example NUnit does this to capture program output). While this is the desired
+ /// behavior of this appender it may have security implications in your application.
+ /// </para>
+ /// </remarks>
+ /// <author>Nicko Cadell</author>
+ /// <author>Gert Driesen</author>
+ public class ConsoleAppender : AppenderSkeleton
+ {
+ #region Public Instance Constructors
- /// <summary>
- /// Initializes a new instance of the <see cref="ConsoleAppender" /> class.
- /// </summary>
- /// <remarks>
- /// The instance of the <see cref="ConsoleAppender" /> class is set up to write
- /// to the standard output stream.
- /// </remarks>
- public ConsoleAppender()
- {
- }
+ /// <summary>
+ /// Initializes a new instance of the <see cref="ConsoleAppender" /> class.
+ /// </summary>
+ /// <remarks>
+ /// The instance of the <see cref="ConsoleAppender" /> class is set up to write
+ /// to the standard output stream.
+ /// </remarks>
+ public ConsoleAppender()
+ {
+ }
- /// <summary>
- /// Initializes a new instance of the <see cref="ConsoleAppender" /> class
- /// with the specified layout.
- /// </summary>
- /// <param name="layout">the layout to use for this appender</param>
- /// <remarks>
- /// The instance of the <see cref="ConsoleAppender" /> class is set up to write
- /// to the standard output stream.
- /// </remarks>
- [Obsolete("Instead use the default constructor and set the Layout property")]
- public ConsoleAppender(ILayout layout) : this(layout, false)
- {
- }
+ /// <summary>
+ /// Initializes a new instance of the <see cref="ConsoleAppender" /> class
+ /// with the specified layout.
+ /// </summary>
+ /// <param name="layout">the layout to use for this appender</param>
+ /// <remarks>
+ /// The instance of the <see cref="ConsoleAppender" /> class is set up to write
+ /// to the standard output stream.
+ /// </remarks>
+ [Obsolete("Instead use the default constructor and set the Layout property")]
+ public ConsoleAppender(ILayout layout) : this(layout, false)
+ {
+ }
- /// <summary>
- /// Initializes a new instance of the <see cref="ConsoleAppender" /> class
- /// with the specified layout.
- /// </summary>
- /// <param name="layout">the layout to use for this appender</param>
- /// <param name="writeToErrorStream">flag set to <c>true</c> to write to the console error stream</param>
- /// <remarks>
- /// When <paramref name="writeToErrorStream" /> is set to <c>true</c>, output is written to
- /// the standard error output stream. Otherwise, output is written to the standard
- /// output stream.
- /// </remarks>
- [Obsolete("Instead use the default constructor and set the Layout & Target properties")]
- public ConsoleAppender(ILayout layout, bool writeToErrorStream)
- {
- Layout = layout;
- m_writeToErrorStream = writeToErrorStream;
- }
+ /// <summary>
+ /// Initializes a new instance of the <see cref="ConsoleAppender" /> class
+ /// with the specified layout.
+ /// </summary>
+ /// <param name="layout">the layout to use for this appender</param>
+ /// <param name="writeToErrorStream">flag set to <c>true</c> to write to the console error stream</param>
+ /// <remarks>
+ /// When <paramref name="writeToErrorStream" /> is set to <c>true</c>, output is written to
+ /// the standard error output stream. Otherwise, output is written to the standard
+ /// output stream.
+ /// </remarks>
+ [Obsolete("Instead use the default constructor and set the Layout & Target properties")]
+ public ConsoleAppender(ILayout layout, bool writeToErrorStream)
+ {
+ Layout = layout;
+ m_writeToErrorStream = writeToErrorStream;
+ }
- #endregion Public Instance Constructors
+ #endregion Public Instance Constructors
- #region Public Instance Properties
+ #region Public Instance Properties
- /// <summary>
- /// Target is the value of the console output stream.
- /// This is either <c>"Console.Out"</c> or <c>"Console.Error"</c>.
- /// </summary>
- /// <value>
- /// Target is the value of the console output stream.
- /// This is either <c>"Console.Out"</c> or <c>"Console.Error"</c>.
- /// </value>
- /// <remarks>
- /// <para>
- /// Target is the value of the console output stream.
- /// This is either <c>"Console.Out"</c> or <c>"Console.Error"</c>.
- /// </para>
- /// </remarks>
- public virtual string Target
- {
- get { return m_writeToErrorStream ? ConsoleError : ConsoleOut; }
- set
- {
- string v = value.Trim();
+ /// <summary>
+ /// Target is the value of the console output stream.
+ /// This is either <c>"Console.Out"</c> or <c>"Console.Error"</c>.
+ /// </summary>
+ /// <value>
+ /// Target is the value of the console output stream.
+ /// This is either <c>"Console.Out"</c> or <c>"Console.Error"</c>.
+ /// </value>
+ /// <remarks>
+ /// <para>
+ /// Target is the value of the console output stream.
+ /// This is either <c>"Console.Out"</c> or <c>"Console.Error"</c>.
+ /// </para>
+ /// </remarks>
+ public virtual string Target
+ {
+ get { return m_writeToErrorStream ? ConsoleError : ConsoleOut; }
+ set
+ {
+ string v = value.Trim();
- if (SystemInfo.EqualsIgnoringCase(ConsoleError, v))
- {
- m_writeToErrorStream = true;
- }
- else
- {
- m_writeToErrorStream = false;
- }
- }
- }
+ if (SystemInfo.EqualsIgnoringCase(ConsoleError, v))
+ {
+ m_writeToErrorStream = true;
+ }
+ else
+ {
+ m_writeToErrorStream = false;
+ }
+ }
+ }
- #endregion Public Instance Properties
+ #endregion Public Instance Properties
- #region Override implementation of AppenderSkeleton
+ #region Override implementation of AppenderSkeleton
- /// <summary>
- /// This method is called by the <see cref="M:AppenderSkeleton.DoAppend(LoggingEvent)"/> method.
- /// </summary>
- /// <param name="loggingEvent">The event to log.</param>
- /// <remarks>
- /// <para>
- /// Writes the event to the console.
- /// </para>
- /// <para>
- /// The format of the output will depend on the appender's layout.
- /// </para>
- /// </remarks>
- protected override void Append(LoggingEvent loggingEvent)
- {
+ /// <summary>
+ /// This method is called by the <see cref="M:AppenderSkeleton.DoAppend(LoggingEvent)"/> method.
+ /// </summary>
+ /// <param name="loggingEvent">The event to log.</param>
+ /// <remarks>
+ /// <para>
+ /// Writes the event to the console.
+ /// </para>
+ /// <para>
+ /// The format of the output will depend on the appender's layout.
+ /// </para>
+ /// </remarks>
+ protected override void Append(LoggingEvent loggingEvent)
+ {
#if NETCF_1_0
- // Write to the output stream
- Console.Write(RenderLoggingEvent(loggingEvent));
+ // Write to the output stream
+ Console.Write(RenderLoggingEvent(loggingEvent));
#else
- if (m_writeToErrorStream)
- {
- // Write to the error stream
- Console.Error.Write(RenderLoggingEvent(loggingEvent));
- }
- else
- {
- // Write to the output stream
- Console.Write(RenderLoggingEvent(loggingEvent));
- }
+ if (m_writeToErrorStream)
+ {
+ // Write to the error stream
+ Console.Error.Write(RenderLoggingEvent(loggingEvent));
+ }
+ else
+ {
+ // Write to the output stream
+ Console.Write(RenderLoggingEvent(loggingEvent));
+ }
#endif
- }
+ }
- /// <summary>
- /// This appender requires a <see cref="Layout"/> to be set.
- /// </summary>
- /// <value><c>true</c></value>
- /// <remarks>
- /// <para>
- /// This appender requires a <see cref="Layout"/> to be set.
- /// </para>
- /// </remarks>
- protected override bool RequiresLayout
- {
- get { return true; }
- }
+ /// <summary>
+ /// This appender requires a <see cref="Layout"/> to be set.
+ /// </summary>
+ /// <value><c>true</c></value>
+ /// <remarks>
+ /// <para>
+ /// This appender requires a <see cref="Layout"/> to be set.
+ /// </para>
+ /// </remarks>
+ protected override bool RequiresLayout
+ {
+ get { return true; }
+ }
- #endregion Override implementation of AppenderSkeleton
+ #endregion Override implementation of AppenderSkeleton
- #region Public Static Fields
+ #region Public Static Fields
- /// <summary>
- /// The <see cref="ConsoleAppender.Target"/> to use when writing to the Console
- /// standard output stream.
- /// </summary>
- /// <remarks>
- /// <para>
- /// The <see cref="ConsoleAppender.Target"/> to use when writing to the Console
- /// standard output stream.
- /// </para>
- /// </remarks>
- public const string ConsoleOut = "Console.Out";
+ /// <summary>
+ /// The <see cref="ConsoleAppender.Target"/> to use when writing to the Console
+ /// standard output stream.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// The <see cref="ConsoleAppender.Target"/> to use when writing to the Console
+ /// standard output stream.
+ /// </para>
+ /// </remarks>
+ public const string ConsoleOut = "Console.Out";
- /// <summary>
- /// The <see cref="ConsoleAppender.Target"/> to use when writing to the Console
- /// standard error output stream.
- /// </summary>
- /// <remarks>
- /// <para>
- /// The <see cref="ConsoleAppender.Target"/> to use when writing to the Console
- /// standard error output stream.
- /// </para>
- /// </remarks>
- public const string ConsoleError = "Console.Error";
+ /// <summary>
+ /// The <see cref="ConsoleAppender.Target"/> to use when writing to the Console
+ /// standard error output stream.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// The <see cref="ConsoleAppender.Target"/> to use when writing to the Console
+ /// standard error output stream.
+ /// </para>
+ /// </remarks>
+ public const string ConsoleError = "Console.Error";
- #endregion Public Static Fields
+ #endregion Public Static Fields
- #region Private Instances Fields
+ #region Private Instances Fields
- private bool m_writeToErrorStream = false;
+ private bool m_writeToErrorStream = false;
- #endregion Private Instances Fields
- }
+ #endregion Private Instances Fields
+ }
}
diff --git a/src/log4net/Appender/DebugAppender.cs b/src/log4net/Appender/DebugAppender.cs
index c1eda99..668d622 100644
--- a/src/log4net/Appender/DebugAppender.cs
+++ b/src/log4net/Appender/DebugAppender.cs
@@ -24,82 +24,82 @@
namespace log4net.Appender
{
- /// <summary>
- /// Appends log events to the <see cref="System.Diagnostics.Debug"/> system.
- /// </summary>
- /// <remarks>
- /// <para>
- /// The application configuration file can be used to control what listeners
- /// are actually used. See the MSDN documentation for the
- /// <see cref="System.Diagnostics.Debug"/> class for details on configuring the
- /// debug system.
- /// </para>
- /// <para>
- /// Events are written using the <see cref="M:System.Diagnostics.Debug.Write(string,string)"/>
- /// method. The event's logger name is passed as the value for the category name to the Write method.
- /// </para>
- /// </remarks>
- /// <author>Nicko Cadell</author>
- public class DebugAppender : AppenderSkeleton
- {
- #region Public Instance Constructors
+ /// <summary>
+ /// Appends log events to the <see cref="System.Diagnostics.Debug"/> system.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// The application configuration file can be used to control what listeners
+ /// are actually used. See the MSDN documentation for the
+ /// <see cref="System.Diagnostics.Debug"/> class for details on configuring the
+ /// debug system.
+ /// </para>
+ /// <para>
+ /// Events are written using the <see cref="M:System.Diagnostics.Debug.Write(string,string)"/>
+ /// method. The event's logger name is passed as the value for the category name to the Write method.
+ /// </para>
+ /// </remarks>
+ /// <author>Nicko Cadell</author>
+ public class DebugAppender : AppenderSkeleton
+ {
+ #region Public Instance Constructors
- /// <summary>
- /// Initializes a new instance of the <see cref="DebugAppender" />.
- /// </summary>
- /// <remarks>
- /// <para>
- /// Default constructor.
- /// </para>
- /// </remarks>
- public DebugAppender()
- {
- }
+ /// <summary>
+ /// Initializes a new instance of the <see cref="DebugAppender" />.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Default constructor.
+ /// </para>
+ /// </remarks>
+ public DebugAppender()
+ {
+ }
- /// <summary>
- /// Initializes a new instance of the <see cref="DebugAppender" />
- /// with a specified layout.
- /// </summary>
- /// <param name="layout">The layout to use with this appender.</param>
- /// <remarks>
- /// <para>
- /// Obsolete constructor.
- /// </para>
- /// </remarks>
- [System.Obsolete("Instead use the default constructor and set the Layout property")]
- public DebugAppender(ILayout layout)
- {
- Layout = layout;
- }
+ /// <summary>
+ /// Initializes a new instance of the <see cref="DebugAppender" />
+ /// with a specified layout.
+ /// </summary>
+ /// <param name="layout">The layout to use with this appender.</param>
+ /// <remarks>
+ /// <para>
+ /// Obsolete constructor.
+ /// </para>
+ /// </remarks>
+ [System.Obsolete("Instead use the default constructor and set the Layout property")]
+ public DebugAppender(ILayout layout)
+ {
+ Layout = layout;
+ }
- #endregion Public Instance Constructors
+ #endregion Public Instance Constructors
- #region Public Instance Properties
-
+ #region Public Instance Properties
+
#if !NETSTANDARD1_3 // System.Diagnostics.Debug has no Flush() in netstandard1.3
- /// <summary>
- /// Gets or sets a value that indicates whether the appender will
- /// flush at the end of each write.
- /// </summary>
- /// <remarks>
- /// <para>The default behavior is to flush at the end of each
- /// write. If the option is set to<c>false</c>, then the underlying
- /// stream can defer writing to physical medium to a later time.
- /// </para>
- /// <para>
- /// Avoiding the flush operation at the end of each append results
- /// in a performance gain of 10 to 20 percent. However, there is safety
- /// trade-off involved in skipping flushing. Indeed, when flushing is
- /// skipped, then it is likely that the last few log events will not
- /// be recorded on disk when the application exits. This is a high
- /// price to pay even for a 20% performance gain.
- /// </para>
- /// </remarks>
- public bool ImmediateFlush
- {
- get { return m_immediateFlush; }
- set { m_immediateFlush = value; }
- }
+ /// <summary>
+ /// Gets or sets a value that indicates whether the appender will
+ /// flush at the end of each write.
+ /// </summary>
+ /// <remarks>
+ /// <para>The default behavior is to flush at the end of each
+ /// write. If the option is set to<c>false</c>, then the underlying
+ /// stream can defer writing to physical medium to a later time.
+ /// </para>
+ /// <para>
+ /// Avoiding the flush operation at the end of each append results
+ /// in a performance gain of 10 to 20 percent. However, there is safety
+ /// trade-off involved in skipping flushing. Indeed, when flushing is
+ /// skipped, then it is likely that the last few log events will not
+ /// be recorded on disk when the application exits. This is a high
+ /// price to pay even for a 20% performance gain.
+ /// </para>
+ /// </remarks>
+ public bool ImmediateFlush
+ {
+ get { return m_immediateFlush; }
+ set { m_immediateFlush = value; }
+ }
#endif // !NETSTANDARD1_3
/// <summary>
@@ -119,7 +119,7 @@
set { m_category = value; }
}
- #endregion Public Instance Properties
+ #endregion Public Instance Properties
#if !NETSTANDARD1_3
/// <summary>
@@ -139,36 +139,36 @@
}
#endif
- #region Override implementation of AppenderSkeleton
-
+ #region Override implementation of AppenderSkeleton
+
#if NETSTANDARD1_3
- /// <summary>
- /// Writes the logging event to the <see cref="System.Diagnostics.Debug"/> system.
- /// </summary>
- /// <param name="loggingEvent">The event to log.</param>
- /// <remarks>
- /// <para>
- /// Writes the logging event to the <see cref="System.Diagnostics.Debug"/> system.
- /// </para>
- /// </remarks>
+ /// <summary>
+ /// Writes the logging event to the <see cref="System.Diagnostics.Debug"/> system.
+ /// </summary>
+ /// <param name="loggingEvent">The event to log.</param>
+ /// <remarks>
+ /// <para>
+ /// Writes the logging event to the <see cref="System.Diagnostics.Debug"/> system.
+ /// </para>
+ /// </remarks>
#else
- /// <summary>
- /// Writes the logging event to the <see cref="System.Diagnostics.Debug"/> system.
- /// </summary>
- /// <param name="loggingEvent">The event to log.</param>
- /// <remarks>
- /// <para>
- /// Writes the logging event to the <see cref="System.Diagnostics.Debug"/> system.
- /// If <see cref="ImmediateFlush"/> is <c>true</c> then the <see cref="System.Diagnostics.Debug.Flush"/>
- /// is called.
- /// </para>
- /// </remarks>
+ /// <summary>
+ /// Writes the logging event to the <see cref="System.Diagnostics.Debug"/> system.
+ /// </summary>
+ /// <param name="loggingEvent">The event to log.</param>
+ /// <remarks>
+ /// <para>
+ /// Writes the logging event to the <see cref="System.Diagnostics.Debug"/> system.
+ /// If <see cref="ImmediateFlush"/> is <c>true</c> then the <see cref="System.Diagnostics.Debug.Flush"/>
+ /// is called.
+ /// </para>
+ /// </remarks>
#endif
- protected override void Append(LoggingEvent loggingEvent)
- {
- //
- // Write the string to the Debug system
- //
+ protected override void Append(LoggingEvent loggingEvent)
+ {
+ //
+ // Write the string to the Debug system
+ //
if(m_category == null)
{
System.Diagnostics.Debug.Write(RenderLoggingEvent(loggingEvent));
@@ -186,51 +186,51 @@
}
}
#if !NETSTANDARD1_3
- //
- // Flush the Debug system if needed
- //
- if (m_immediateFlush)
- {
- System.Diagnostics.Debug.Flush();
- }
+ //
+ // Flush the Debug system if needed
+ //
+ if (m_immediateFlush)
+ {
+ System.Diagnostics.Debug.Flush();
+ }
#endif
- }
+ }
- /// <summary>
- /// This appender requires a <see cref="Layout"/> to be set.
- /// </summary>
- /// <value><c>true</c></value>
- /// <remarks>
- /// <para>
- /// This appender requires a <see cref="Layout"/> to be set.
- /// </para>
- /// </remarks>
- protected override bool RequiresLayout
- {
- get { return true; }
- }
+ /// <summary>
+ /// This appender requires a <see cref="Layout"/> to be set.
+ /// </summary>
+ /// <value><c>true</c></value>
+ /// <remarks>
+ /// <para>
+ /// This appender requires a <see cref="Layout"/> to be set.
+ /// </para>
+ /// </remarks>
+ protected override bool RequiresLayout
+ {
+ get { return true; }
+ }
- #endregion Override implementation of AppenderSkeleton
+ #endregion Override implementation of AppenderSkeleton
- #region Private Instance Fields
-
-#if !NETSTANDARD1_3
- /// <summary>
- /// Immediate flush means that the underlying writer or output stream
- /// will be flushed at the end of each append operation.
- /// </summary>
- /// <remarks>
- /// <para>
- /// Immediate flush is slower but ensures that each append request is
- /// actually written. If <see cref="ImmediateFlush"/> is set to
- /// <c>false</c>, then there is a good chance that the last few
- /// logs events are not actually written to persistent media if and
- /// when the application crashes.
- /// </para>
- /// <para>
- /// The default value is <c>true</c>.</para>
- /// </remarks>
- private bool m_immediateFlush = true;
+ #region Private Instance Fields
+
+#if !NETSTANDARD1_3
+ /// <summary>
+ /// Immediate flush means that the underlying writer or output stream
+ /// will be flushed at the end of each append operation.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Immediate flush is slower but ensures that each append request is
+ /// actually written. If <see cref="ImmediateFlush"/> is set to
+ /// <c>false</c>, then there is a good chance that the last few
+ /// logs events are not actually written to persistent media if and
+ /// when the application crashes.
+ /// </para>
+ /// <para>
+ /// The default value is <c>true</c>.</para>
+ /// </remarks>
+ private bool m_immediateFlush = true;
#endif
/// <summary>
@@ -238,6 +238,6 @@
/// </summary>
private PatternLayout m_category = new PatternLayout("%logger");
- #endregion Private Instance Fields
- }
+ #endregion Private Instance Fields
+ }
}
diff --git a/src/log4net/Appender/EventLogAppender.cs b/src/log4net/Appender/EventLogAppender.cs
index 0d1f3c8..2de708b 100644
--- a/src/log4net/Appender/EventLogAppender.cs
+++ b/src/log4net/Appender/EventLogAppender.cs
@@ -36,191 +36,191 @@
namespace log4net.Appender
{
- /// <summary>
- /// Writes events to the system event log.
- /// </summary>
- /// <remarks>
+ /// <summary>
+ /// Writes events to the system event log.
+ /// </summary>
+ /// <remarks>
/// <para>
/// The appender will fail if you try to write using an event source that doesn't exist unless it is running with local administrator privileges.
/// See also http://logging.apache.org/log4net/release/faq.html#trouble-EventLog
/// </para>
- /// <para>
- /// The <c>EventID</c> of the event log entry can be
- /// set using the <c>EventID</c> property (<see cref="LoggingEvent.Properties"/>)
- /// on the <see cref="LoggingEvent"/>.
- /// </para>
+ /// <para>
+ /// The <c>EventID</c> of the event log entry can be
+ /// set using the <c>EventID</c> property (<see cref="LoggingEvent.Properties"/>)
+ /// on the <see cref="LoggingEvent"/>.
+ /// </para>
/// <para>
/// The <c>Category</c> of the event log entry can be
- /// set using the <c>Category</c> property (<see cref="LoggingEvent.Properties"/>)
- /// on the <see cref="LoggingEvent"/>.
- /// </para>
- /// <para>
- /// There is a limit of 32K characters for an event log message
- /// </para>
- /// <para>
- /// When configuring the EventLogAppender a mapping can be
- /// specified to map a logging level to an event log entry type. For example:
- /// </para>
- /// <code lang="XML">
- /// <mapping>
- /// <level value="ERROR" />
- /// <eventLogEntryType value="Error" />
- /// </mapping>
- /// <mapping>
- /// <level value="DEBUG" />
- /// <eventLogEntryType value="Information" />
- /// </mapping>
- /// </code>
- /// <para>
- /// The Level is the standard log4net logging level and eventLogEntryType can be any value
- /// from the <see cref="EventLogEntryType"/> enum, i.e.:
- /// <list type="bullet">
- /// <item><term>Error</term><description>an error event</description></item>
- /// <item><term>Warning</term><description>a warning event</description></item>
- /// <item><term>Information</term><description>an informational event</description></item>
- /// </list>
- /// </para>
- /// </remarks>
- /// <author>Aspi Havewala</author>
- /// <author>Douglas de la Torre</author>
- /// <author>Nicko Cadell</author>
- /// <author>Gert Driesen</author>
- /// <author>Thomas Voss</author>
- public class EventLogAppender : AppenderSkeleton
- {
- #region Public Instance Constructors
+ /// set using the <c>Category</c> property (<see cref="LoggingEvent.Properties"/>)
+ /// on the <see cref="LoggingEvent"/>.
+ /// </para>
+ /// <para>
+ /// There is a limit of 32K characters for an event log message
+ /// </para>
+ /// <para>
+ /// When configuring the EventLogAppender a mapping can be
+ /// specified to map a logging level to an event log entry type. For example:
+ /// </para>
+ /// <code lang="XML">
+ /// <mapping>
+ /// <level value="ERROR" />
+ /// <eventLogEntryType value="Error" />
+ /// </mapping>
+ /// <mapping>
+ /// <level value="DEBUG" />
+ /// <eventLogEntryType value="Information" />
+ /// </mapping>
+ /// </code>
+ /// <para>
+ /// The Level is the standard log4net logging level and eventLogEntryType can be any value
+ /// from the <see cref="EventLogEntryType"/> enum, i.e.:
+ /// <list type="bullet">
+ /// <item><term>Error</term><description>an error event</description></item>
+ /// <item><term>Warning</term><description>a warning event</description></item>
+ /// <item><term>Information</term><description>an informational event</description></item>
+ /// </list>
+ /// </para>
+ /// </remarks>
+ /// <author>Aspi Havewala</author>
+ /// <author>Douglas de la Torre</author>
+ /// <author>Nicko Cadell</author>
+ /// <author>Gert Driesen</author>
+ /// <author>Thomas Voss</author>
+ public class EventLogAppender : AppenderSkeleton
+ {
+ #region Public Instance Constructors
- /// <summary>
- /// Initializes a new instance of the <see cref="EventLogAppender" /> class.
- /// </summary>
- /// <remarks>
- /// <para>
- /// Default constructor.
- /// </para>
- /// </remarks>
- public EventLogAppender()
- {
- m_applicationName = System.Threading.Thread.GetDomain().FriendlyName;
- m_logName = "Application"; // Defaults to application log
- m_machineName = "."; // Only log on the local machine
- }
+ /// <summary>
+ /// Initializes a new instance of the <see cref="EventLogAppender" /> class.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Default constructor.
+ /// </para>
+ /// </remarks>
+ public EventLogAppender()
+ {
+ m_applicationName = System.Threading.Thread.GetDomain().FriendlyName;
+ m_logName = "Application"; // Defaults to application log
+ m_machineName = "."; // Only log on the local machine
+ }
- /// <summary>
- /// Initializes a new instance of the <see cref="EventLogAppender" /> class
- /// with the specified <see cref="ILayout" />.
- /// </summary>
- /// <param name="layout">The <see cref="ILayout" /> to use with this appender.</param>
- /// <remarks>
- /// <para>
- /// Obsolete constructor.
- /// </para>
- /// </remarks>
- [Obsolete("Instead use the default constructor and set the Layout property")]
- public EventLogAppender(ILayout layout) : this()
- {
- Layout = layout;
- }
+ /// <summary>
+ /// Initializes a new instance of the <see cref="EventLogAppender" /> class
+ /// with the specified <see cref="ILayout" />.
+ /// </summary>
+ /// <param name="layout">The <see cref="ILayout" /> to use with this appender.</param>
+ /// <remarks>
+ /// <para>
+ /// Obsolete constructor.
+ /// </para>
+ /// </remarks>
+ [Obsolete("Instead use the default constructor and set the Layout property")]
+ public EventLogAppender(ILayout layout) : this()
+ {
+ Layout = layout;
+ }
- #endregion // Public Instance Constructors
+ #endregion // Public Instance Constructors
- #region Public Instance Properties
+ #region Public Instance Properties
- /// <summary>
- /// The name of the log where messages will be stored.
- /// </summary>
- /// <value>
- /// The string name of the log where messages will be stored.
- /// </value>
- /// <remarks>
- /// <para>This is the name of the log as it appears in the Event Viewer
- /// tree. The default value is to log into the <c>Application</c>
- /// log, this is where most applications write their events. However
- /// if you need a separate log for your application (or applications)
- /// then you should set the <see cref="LogName"/> appropriately.</para>
- /// <para>This should not be used to distinguish your event log messages
- /// from those of other applications, the <see cref="ApplicationName"/>
- /// property should be used to distinguish events. This property should be
- /// used to group together events into a single log.
- /// </para>
- /// </remarks>
- public string LogName
- {
- get { return m_logName; }
- set { m_logName = value; }
- }
+ /// <summary>
+ /// The name of the log where messages will be stored.
+ /// </summary>
+ /// <value>
+ /// The string name of the log where messages will be stored.
+ /// </value>
+ /// <remarks>
+ /// <para>This is the name of the log as it appears in the Event Viewer
+ /// tree. The default value is to log into the <c>Application</c>
+ /// log, this is where most applications write their events. However
+ /// if you need a separate log for your application (or applications)
+ /// then you should set the <see cref="LogName"/> appropriately.</para>
+ /// <para>This should not be used to distinguish your event log messages
+ /// from those of other applications, the <see cref="ApplicationName"/>
+ /// property should be used to distinguish events. This property should be
+ /// used to group together events into a single log.
+ /// </para>
+ /// </remarks>
+ public string LogName
+ {
+ get { return m_logName; }
+ set { m_logName = value; }
+ }
- /// <summary>
- /// Property used to set the Application name. This appears in the
- /// event logs when logging.
- /// </summary>
- /// <value>
- /// The string used to distinguish events from different sources.
- /// </value>
- /// <remarks>
- /// Sets the event log source property.
- /// </remarks>
- public string ApplicationName
- {
- get { return m_applicationName; }
- set { m_applicationName = value; }
- }
+ /// <summary>
+ /// Property used to set the Application name. This appears in the
+ /// event logs when logging.
+ /// </summary>
+ /// <value>
+ /// The string used to distinguish events from different sources.
+ /// </value>
+ /// <remarks>
+ /// Sets the event log source property.
+ /// </remarks>
+ public string ApplicationName
+ {
+ get { return m_applicationName; }
+ set { m_applicationName = value; }
+ }
- /// <summary>
- /// This property is used to return the name of the computer to use
- /// when accessing the event logs. Currently, this is the current
- /// computer, denoted by a dot "."
- /// </summary>
- /// <value>
- /// The string name of the machine holding the event log that
- /// will be logged into.
- /// </value>
- /// <remarks>
- /// This property cannot be changed. It is currently set to '.'
- /// i.e. the local machine. This may be changed in future.
- /// </remarks>
- public string MachineName
- {
- get { return m_machineName; }
- set { /* Currently we do not allow the machine name to be changed */; }
- }
+ /// <summary>
+ /// This property is used to return the name of the computer to use
+ /// when accessing the event logs. Currently, this is the current
+ /// computer, denoted by a dot "."
+ /// </summary>
+ /// <value>
+ /// The string name of the machine holding the event log that
+ /// will be logged into.
+ /// </value>
+ /// <remarks>
+ /// This property cannot be changed. It is currently set to '.'
+ /// i.e. the local machine. This may be changed in future.
+ /// </remarks>
+ public string MachineName
+ {
+ get { return m_machineName; }
+ set { /* Currently we do not allow the machine name to be changed */; }
+ }
- /// <summary>
- /// Add a mapping of level to <see cref="EventLogEntryType"/> - done by the config file
- /// </summary>
- /// <param name="mapping">The mapping to add</param>
- /// <remarks>
- /// <para>
- /// Add a <see cref="Level2EventLogEntryType"/> mapping to this appender.
- /// Each mapping defines the event log entry type for a level.
- /// </para>
- /// </remarks>
- public void AddMapping(Level2EventLogEntryType mapping)
- {
- m_levelMapping.Add(mapping);
- }
+ /// <summary>
+ /// Add a mapping of level to <see cref="EventLogEntryType"/> - done by the config file
+ /// </summary>
+ /// <param name="mapping">The mapping to add</param>
+ /// <remarks>
+ /// <para>
+ /// Add a <see cref="Level2EventLogEntryType"/> mapping to this appender.
+ /// Each mapping defines the event log entry type for a level.
+ /// </para>
+ /// </remarks>
+ public void AddMapping(Level2EventLogEntryType mapping)
+ {
+ m_levelMapping.Add(mapping);
+ }
- /// <summary>
- /// Gets or sets the <see cref="SecurityContext"/> used to write to the EventLog.
- /// </summary>
- /// <value>
- /// The <see cref="SecurityContext"/> used to write to the EventLog.
- /// </value>
- /// <remarks>
- /// <para>
- /// The system security context used to write to the EventLog.
- /// </para>
- /// <para>
- /// Unless a <see cref="SecurityContext"/> specified here for this appender
- /// the <see cref="SecurityContextProvider.DefaultProvider"/> is queried for the
- /// security context to use. The default behavior is to use the security context
- /// of the current thread.
- /// </para>
- /// </remarks>
- public SecurityContext SecurityContext
- {
- get { return m_securityContext; }
- set { m_securityContext = value; }
- }
+ /// <summary>
+ /// Gets or sets the <see cref="SecurityContext"/> used to write to the EventLog.
+ /// </summary>
+ /// <value>
+ /// The <see cref="SecurityContext"/> used to write to the EventLog.
+ /// </value>
+ /// <remarks>
+ /// <para>
+ /// The system security context used to write to the EventLog.
+ /// </para>
+ /// <para>
+ /// Unless a <see cref="SecurityContext"/> specified here for this appender
+ /// the <see cref="SecurityContextProvider.DefaultProvider"/> is queried for the
+ /// security context to use. The default behavior is to use the security context
+ /// of the current thread.
+ /// </para>
+ /// </remarks>
+ public SecurityContext SecurityContext
+ {
+ get { return m_securityContext; }
+ set { m_securityContext = value; }
+ }
/// <summary>
/// Gets or sets the <c>EventId</c> to use unless one is explicitly specified via the <c>LoggingEvent</c>'s properties.
@@ -228,8 +228,8 @@
/// <remarks>
/// <para>
/// The <c>EventID</c> of the event log entry will normally be
- /// set using the <c>EventID</c> property (<see cref="LoggingEvent.Properties"/>)
- /// on the <see cref="LoggingEvent"/>.
+ /// set using the <c>EventID</c> property (<see cref="LoggingEvent.Properties"/>)
+ /// on the <see cref="LoggingEvent"/>.
/// This property provides the fallback value which defaults to 0.
/// </para>
/// </remarks>
@@ -245,8 +245,8 @@
/// <remarks>
/// <para>
/// The <c>Category</c> of the event log entry will normally be
- /// set using the <c>Category</c> property (<see cref="LoggingEvent.Properties"/>)
- /// on the <see cref="LoggingEvent"/>.
+ /// set using the <c>Category</c> property (<see cref="LoggingEvent.Properties"/>)
+ /// on the <see cref="LoggingEvent"/>.
/// This property provides the fallback value which defaults to 0.
/// </para>
/// </remarks>
@@ -257,26 +257,26 @@
}
#endregion // Public Instance Properties
- #region Implementation of IOptionHandler
+ #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>
- public override void ActivateOptions()
- {
+ /// <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>
+ public override void ActivateOptions()
+ {
try
{
base.ActivateOptions();
@@ -342,82 +342,82 @@
ex);
Threshold = Level.Off;
}
- }
+ }
- #endregion // Implementation of IOptionHandler
+ #endregion // Implementation of IOptionHandler
- /// <summary>
- /// Create an event log source
- /// </summary>
- /// <remarks>
- /// Uses different API calls under NET_2_0
- /// </remarks>
- private static void CreateEventSource(string source, string logName, string machineName)
- {
+ /// <summary>
+ /// Create an event log source
+ /// </summary>
+ /// <remarks>
+ /// Uses different API calls under NET_2_0
+ /// </remarks>
+ private static void CreateEventSource(string source, string logName, string machineName)
+ {
#if NET_2_0
- EventSourceCreationData eventSourceCreationData = new EventSourceCreationData(source, logName);
- eventSourceCreationData.MachineName = machineName;
- EventLog.CreateEventSource(eventSourceCreationData);
+ EventSourceCreationData eventSourceCreationData = new EventSourceCreationData(source, logName);
+ eventSourceCreationData.MachineName = machineName;
+ EventLog.CreateEventSource(eventSourceCreationData);
#else
- EventLog.CreateEventSource(source, logName, machineName);
+ EventLog.CreateEventSource(source, logName, machineName);
#endif
- }
+ }
- #region Override implementation of AppenderSkeleton
+ #region Override implementation of AppenderSkeleton
- /// <summary>
- /// This method is called by the <see cref="M:AppenderSkeleton.DoAppend(LoggingEvent)"/>
- /// method.
- /// </summary>
- /// <param name="loggingEvent">the event to log</param>
- /// <remarks>
- /// <para>Writes the event to the system event log using the
- /// <see cref="ApplicationName"/>.</para>
- ///
- /// <para>If the event has an <c>EventID</c> property (see <see cref="LoggingEvent.Properties"/>)
- /// set then this integer will be used as the event log event id.</para>
- ///
- /// <para>
- /// There is a limit of 32K characters for an event log message
- /// </para>
- /// </remarks>
- protected override void Append(LoggingEvent loggingEvent)
- {
- //
- // Write the resulting string to the event log system
- //
- int eventID = m_eventId;
+ /// <summary>
+ /// This method is called by the <see cref="M:AppenderSkeleton.DoAppend(LoggingEvent)"/>
+ /// method.
+ /// </summary>
+ /// <param name="loggingEvent">the event to log</param>
+ /// <remarks>
+ /// <para>Writes the event to the system event log using the
+ /// <see cref="ApplicationName"/>.</para>
+ ///
+ /// <para>If the event has an <c>EventID</c> property (see <see cref="LoggingEvent.Properties"/>)
+ /// set then this integer will be used as the event log event id.</para>
+ ///
+ /// <para>
+ /// There is a limit of 32K characters for an event log message
+ /// </para>
+ /// </remarks>
+ protected override void Append(LoggingEvent loggingEvent)
+ {
+ //
+ // Write the resulting string to the event log system
+ //
+ int eventID = m_eventId;
- // Look for the EventID property
- object eventIDPropertyObj = loggingEvent.LookupProperty("EventID");
- if (eventIDPropertyObj != null)
- {
- if (eventIDPropertyObj is int)
- {
- eventID = (int)eventIDPropertyObj;
- }
- else
- {
- string eventIDPropertyString = eventIDPropertyObj as string;
+ // Look for the EventID property
+ object eventIDPropertyObj = loggingEvent.LookupProperty("EventID");
+ if (eventIDPropertyObj != null)
+ {
+ if (eventIDPropertyObj is int)
+ {
+ eventID = (int)eventIDPropertyObj;
+ }
+ else
+ {
+ string eventIDPropertyString = eventIDPropertyObj as string;
if (eventIDPropertyString == null)
{
eventIDPropertyString = eventIDPropertyObj.ToString();
}
- if (eventIDPropertyString != null && eventIDPropertyString.Length > 0)
- {
- // Read the string property into a number
- int intVal;
- if (SystemInfo.TryParse(eventIDPropertyString, out intVal))
- {
- eventID = intVal;
- }
- else
- {
- ErrorHandler.Error("Unable to parse event ID property [" + eventIDPropertyString + "].");
- }
- }
- }
- }
+ if (eventIDPropertyString != null && eventIDPropertyString.Length > 0)
+ {
+ // Read the string property into a number
+ int intVal;
+ if (SystemInfo.TryParse(eventIDPropertyString, out intVal))
+ {
+ eventID = intVal;
+ }
+ else
+ {
+ ErrorHandler.Error("Unable to parse event ID property [" + eventIDPropertyString + "].");
+ }
+ }
+ }
+ }
short category = m_category;
// Look for the Category property
@@ -451,114 +451,114 @@
}
}
- // Write to the event log
- try
- {
- string eventTxt = RenderLoggingEvent(loggingEvent);
+ // Write to the event log
+ try
+ {
+ string eventTxt = RenderLoggingEvent(loggingEvent);
- // There is a limit of about 32K characters for an event log message
- if (eventTxt.Length > MAX_EVENTLOG_MESSAGE_SIZE)
- {
- eventTxt = eventTxt.Substring(0, MAX_EVENTLOG_MESSAGE_SIZE);
- }
+ // There is a limit of about 32K characters for an event log message
+ if (eventTxt.Length > MAX_EVENTLOG_MESSAGE_SIZE)
+ {
+ eventTxt = eventTxt.Substring(0, MAX_EVENTLOG_MESSAGE_SIZE);
+ }
- EventLogEntryType entryType = GetEntryType(loggingEvent.Level);
+ EventLogEntryType entryType = GetEntryType(loggingEvent.Level);
- using(SecurityContext.Impersonate(this))
- {
- EventLog.WriteEntry(m_applicationName, eventTxt, entryType, eventID, category);
- }
- }
- catch(Exception ex)
- {
- ErrorHandler.Error("Unable to write to event log [" + m_logName + "] using source [" + m_applicationName + "]", ex);
- }
- }
+ using(SecurityContext.Impersonate(this))
+ {
+ EventLog.WriteEntry(m_applicationName, eventTxt, entryType, eventID, category);
+ }
+ }
+ catch(Exception ex)
+ {
+ ErrorHandler.Error("Unable to write to event log [" + m_logName + "] using source [" + m_applicationName + "]", ex);
+ }
+ }
- /// <summary>
- /// This appender requires a <see cref="Layout"/> to be set.
- /// </summary>
- /// <value><c>true</c></value>
- /// <remarks>
- /// <para>
- /// This appender requires a <see cref="Layout"/> to be set.
- /// </para>
- /// </remarks>
- protected override bool RequiresLayout
- {
- get { return true; }
- }
+ /// <summary>
+ /// This appender requires a <see cref="Layout"/> to be set.
+ /// </summary>
+ /// <value><c>true</c></value>
+ /// <remarks>
+ /// <para>
+ /// This appender requires a <see cref="Layout"/> to be set.
+ /// </para>
+ /// </remarks>
+ protected override bool RequiresLayout
+ {
+ get { return true; }
+ }
- #endregion // Override implementation of AppenderSkeleton
+ #endregion // Override implementation of AppenderSkeleton
- #region Protected Instance Methods
+ #region Protected Instance Methods
- /// <summary>
- /// Get the equivalent <see cref="EventLogEntryType"/> for a <see cref="Level"/> <paramref name="level"/>
- /// </summary>
- /// <param name="level">the Level to convert to an EventLogEntryType</param>
- /// <returns>The equivalent <see cref="EventLogEntryType"/> for a <see cref="Level"/> <paramref name="level"/></returns>
- /// <remarks>
- /// Because there are fewer applicable <see cref="EventLogEntryType"/>
- /// values to use in logging levels than there are in the
- /// <see cref="Level"/> this is a one way mapping. There is
- /// a loss of information during the conversion.
- /// </remarks>
- protected virtual EventLogEntryType GetEntryType(Level level)
- {
- // see if there is a specified lookup.
- Level2EventLogEntryType entryType = m_levelMapping.Lookup(level) as Level2EventLogEntryType;
- if (entryType != null)
- {
- return entryType.EventLogEntryType;
- }
+ /// <summary>
+ /// Get the equivalent <see cref="EventLogEntryType"/> for a <see cref="Level"/> <paramref name="level"/>
+ /// </summary>
+ /// <param name="level">the Level to convert to an EventLogEntryType</param>
+ /// <returns>The equivalent <see cref="EventLogEntryType"/> for a <see cref="Level"/> <paramref name="level"/></returns>
+ /// <remarks>
+ /// Because there are fewer applicable <see cref="EventLogEntryType"/>
+ /// values to use in logging levels than there are in the
+ /// <see cref="Level"/> this is a one way mapping. There is
+ /// a loss of information during the conversion.
+ /// </remarks>
+ protected virtual EventLogEntryType GetEntryType(Level level)
+ {
+ // see if there is a specified lookup.
+ Level2EventLogEntryType entryType = m_levelMapping.Lookup(level) as Level2EventLogEntryType;
+ if (entryType != null)
+ {
+ return entryType.EventLogEntryType;
+ }
- // Use default behavior
+ // Use default behavior
- if (level >= Level.Error)
- {
- return EventLogEntryType.Error;
- }
- else if (level == Level.Warn)
- {
- return EventLogEntryType.Warning;
- }
+ if (level >= Level.Error)
+ {
+ return EventLogEntryType.Error;
+ }
+ else if (level == Level.Warn)
+ {
+ return EventLogEntryType.Warning;
+ }
- // Default setting
- return EventLogEntryType.Information;
- }
+ // Default setting
+ return EventLogEntryType.Information;
+ }
- #endregion // Protected Instance Methods
+ #endregion // Protected Instance Methods
- #region Private Instance Fields
+ #region Private Instance Fields
- /// <summary>
- /// The log name is the section in the event logs where the messages
- /// are stored.
- /// </summary>
- private string m_logName;
+ /// <summary>
+ /// The log name is the section in the event logs where the messages
+ /// are stored.
+ /// </summary>
+ private string m_logName;
- /// <summary>
- /// Name of the application to use when logging. This appears in the
- /// application column of the event log named by <see cref="m_logName"/>.
- /// </summary>
- private string m_applicationName;
+ /// <summary>
+ /// Name of the application to use when logging. This appears in the
+ /// application column of the event log named by <see cref="m_logName"/>.
+ /// </summary>
+ private string m_applicationName;
- /// <summary>
- /// The name of the machine which holds the event log. This is
- /// currently only allowed to be '.' i.e. the current machine.
- /// </summary>
- private string m_machineName;
+ /// <summary>
+ /// The name of the machine which holds the event log. This is
+ /// currently only allowed to be '.' i.e. the current machine.
+ /// </summary>
+ private string m_machineName;
- /// <summary>
- /// Mapping from level object to EventLogEntryType
- /// </summary>
- private LevelMapping m_levelMapping = new LevelMapping();
+ /// <summary>
+ /// Mapping from level object to EventLogEntryType
+ /// </summary>
+ private LevelMapping m_levelMapping = new LevelMapping();
- /// <summary>
- /// The security context to use for privileged calls
- /// </summary>
- private SecurityContext m_securityContext;
+ /// <summary>
+ /// The security context to use for privileged calls
+ /// </summary>
+ private SecurityContext m_securityContext;
/// <summary>
/// The event ID to use unless one is explicitly specified via the <c>LoggingEvent</c>'s properties.
@@ -572,120 +572,120 @@
#endregion // Private Instance Fields
- #region Level2EventLogEntryType LevelMapping Entry
+ #region Level2EventLogEntryType LevelMapping Entry
- /// <summary>
- /// A class to act as a mapping between the level that a logging call is made at and
- /// the color it should be displayed as.
- /// </summary>
- /// <remarks>
- /// <para>
- /// Defines the mapping between a level and its event log entry type.
- /// </para>
- /// </remarks>
- public class Level2EventLogEntryType : LevelMappingEntry
- {
- private EventLogEntryType m_entryType;
+ /// <summary>
+ /// A class to act as a mapping between the level that a logging call is made at and
+ /// the color it should be displayed as.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Defines the mapping between a level and its event log entry type.
+ /// </para>
+ /// </remarks>
+ public class Level2EventLogEntryType : LevelMappingEntry
+ {
+ private EventLogEntryType m_entryType;
- /// <summary>
- /// The <see cref="EventLogEntryType"/> for this entry
- /// </summary>
- /// <remarks>
- /// <para>
- /// Required property.
- /// The <see cref="EventLogEntryType"/> for this entry
- /// </para>
- /// </remarks>
- public EventLogEntryType EventLogEntryType
- {
- get { return m_entryType; }
- set { m_entryType = value; }
- }
- }
+ /// <summary>
+ /// The <see cref="EventLogEntryType"/> for this entry
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Required property.
+ /// The <see cref="EventLogEntryType"/> for this entry
+ /// </para>
+ /// </remarks>
+ public EventLogEntryType EventLogEntryType
+ {
+ get { return m_entryType; }
+ set { m_entryType = value; }
+ }
+ }
- #endregion // LevelColors LevelMapping Entry
+ #endregion // LevelColors LevelMapping Entry
- #region Private Static Fields
+ #region Private Static Fields
- /// <summary>
- /// The fully qualified type of the EventLogAppender class.
- /// </summary>
- /// <remarks>
- /// Used by the internal logger to record the Type of the
- /// log message.
- /// </remarks>
- private static readonly Type declaringType = typeof(EventLogAppender);
+ /// <summary>
+ /// The fully qualified type of the EventLogAppender class.
+ /// </summary>
+ /// <remarks>
+ /// Used by the internal logger to record the Type of the
+ /// log message.
+ /// </remarks>
+ private static readonly Type declaringType = typeof(EventLogAppender);
- /// <summary>
- /// The maximum size supported by default.
- /// </summary>
- /// <remarks>
- /// http://msdn.microsoft.com/en-us/library/xzwc042w(v=vs.100).aspx
- /// The 32766 documented max size is two bytes shy of 32K (I'm assuming 32766
- /// may leave space for a two byte null terminator of #0#0). The 32766 max
- /// length is what the .NET 4.0 source code checks for, but this is WRONG!
- /// Strings with a length > 31839 on Windows Vista or higher can CORRUPT
- /// the event log! See: System.Diagnostics.EventLogInternal.InternalWriteEvent()
- /// for the use of the 32766 max size.
- /// </remarks>
- private static readonly int MAX_EVENTLOG_MESSAGE_SIZE_DEFAULT = 32766;
+ /// <summary>
+ /// The maximum size supported by default.
+ /// </summary>
+ /// <remarks>
+ /// http://msdn.microsoft.com/en-us/library/xzwc042w(v=vs.100).aspx
+ /// The 32766 documented max size is two bytes shy of 32K (I'm assuming 32766
+ /// may leave space for a two byte null terminator of #0#0). The 32766 max
+ /// length is what the .NET 4.0 source code checks for, but this is WRONG!
+ /// Strings with a length > 31839 on Windows Vista or higher can CORRUPT
+ /// the event log! See: System.Diagnostics.EventLogInternal.InternalWriteEvent()
+ /// for the use of the 32766 max size.
+ /// </remarks>
+ private static readonly int MAX_EVENTLOG_MESSAGE_SIZE_DEFAULT = 32766;
- /// <summary>
- /// The maximum size supported by a windows operating system that is vista
- /// or newer.
- /// </summary>
- /// <remarks>
- /// See ReportEvent API:
- /// http://msdn.microsoft.com/en-us/library/aa363679(VS.85).aspx
- /// ReportEvent's lpStrings parameter:
- /// "A pointer to a buffer containing an array of
- /// null-terminated strings that are merged into the message before Event Viewer
- /// displays the string to the user. This parameter must be a valid pointer
- /// (or NULL), even if wNumStrings is zero. Each string is limited to 31,839 characters."
- ///
- /// Going beyond the size of 31839 will (at some point) corrupt the event log on Windows
- /// Vista or higher! It may succeed for a while...but you will eventually run into the
- /// error: "System.ComponentModel.Win32Exception : A device attached to the system is
- /// not functioning", and the event log will then be corrupt (I was able to corrupt
- /// an event log using a length of 31877 on Windows 7).
- ///
- /// The max size for Windows Vista or higher is documented here:
- /// http://msdn.microsoft.com/en-us/library/xzwc042w(v=vs.100).aspx.
- /// Going over this size may succeed a few times but the buffer will overrun and
- /// eventually corrupt the log (based on testing).
- ///
- /// The maxEventMsgSize size is based on the max buffer size of the lpStrings parameter of the ReportEvent API.
- /// The documented max size for EventLog.WriteEntry for Windows Vista and higher is 31839, but I'm leaving room for a
- /// terminator of #0#0, as we cannot see the source of ReportEvent (though we could use an API monitor to examine the
- /// buffer, given enough time).
- /// </remarks>
- private static readonly int MAX_EVENTLOG_MESSAGE_SIZE_VISTA_OR_NEWER = 31839 - 2;
+ /// <summary>
+ /// The maximum size supported by a windows operating system that is vista
+ /// or newer.
+ /// </summary>
+ /// <remarks>
+ /// See ReportEvent API:
+ /// http://msdn.microsoft.com/en-us/library/aa363679(VS.85).aspx
+ /// ReportEvent's lpStrings parameter:
+ /// "A pointer to a buffer containing an array of
+ /// null-terminated strings that are merged into the message before Event Viewer
+ /// displays the string to the user. This parameter must be a valid pointer
+ /// (or NULL), even if wNumStrings is zero. Each string is limited to 31,839 characters."
+ ///
+ /// Going beyond the size of 31839 will (at some point) corrupt the event log on Windows
+ /// Vista or higher! It may succeed for a while...but you will eventually run into the
+ /// error: "System.ComponentModel.Win32Exception : A device attached to the system is
+ /// not functioning", and the event log will then be corrupt (I was able to corrupt
+ /// an event log using a length of 31877 on Windows 7).
+ ///
+ /// The max size for Windows Vista or higher is documented here:
+ /// http://msdn.microsoft.com/en-us/library/xzwc042w(v=vs.100).aspx.
+ /// Going over this size may succeed a few times but the buffer will overrun and
+ /// eventually corrupt the log (based on testing).
+ ///
+ /// The maxEventMsgSize size is based on the max buffer size of the lpStrings parameter of the ReportEvent API.
+ /// The documented max size for EventLog.WriteEntry for Windows Vista and higher is 31839, but I'm leaving room for a
+ /// terminator of #0#0, as we cannot see the source of ReportEvent (though we could use an API monitor to examine the
+ /// buffer, given enough time).
+ /// </remarks>
+ private static readonly int MAX_EVENTLOG_MESSAGE_SIZE_VISTA_OR_NEWER = 31839 - 2;
- /// <summary>
- /// The maximum size that the operating system supports for
- /// a event log message.
- /// </summary>
- /// <remarks>
- /// Used to determine the maximum string length that can be written
- /// to the operating system event log and eventually truncate a string
- /// that exceeds the limits.
- /// </remarks>
- private static readonly int MAX_EVENTLOG_MESSAGE_SIZE = GetMaxEventLogMessageSize();
+ /// <summary>
+ /// The maximum size that the operating system supports for
+ /// a event log message.
+ /// </summary>
+ /// <remarks>
+ /// Used to determine the maximum string length that can be written
+ /// to the operating system event log and eventually truncate a string
+ /// that exceeds the limits.
+ /// </remarks>
+ private static readonly int MAX_EVENTLOG_MESSAGE_SIZE = GetMaxEventLogMessageSize();
- /// <summary>
- /// This method determines the maximum event log message size allowed for
- /// the current environment.
- /// </summary>
- /// <returns></returns>
- private static int GetMaxEventLogMessageSize()
- {
- if (Environment.OSVersion.Platform == PlatformID.Win32NT && Environment.OSVersion.Version.Major >= 6)
- return MAX_EVENTLOG_MESSAGE_SIZE_VISTA_OR_NEWER;
- return MAX_EVENTLOG_MESSAGE_SIZE_DEFAULT;
- }
+ /// <summary>
+ /// This method determines the maximum event log message size allowed for
+ /// the current environment.
+ /// </summary>
+ /// <returns></returns>
+ private static int GetMaxEventLogMessageSize()
+ {
+ if (Environment.OSVersion.Platform == PlatformID.Win32NT && Environment.OSVersion.Version.Major >= 6)
+ return MAX_EVENTLOG_MESSAGE_SIZE_VISTA_OR_NEWER;
+ return MAX_EVENTLOG_MESSAGE_SIZE_DEFAULT;
+ }
- #endregion Private Static Fields
- }
+ #endregion Private Static Fields
+ }
}
#endif // !SSCLI
diff --git a/src/log4net/Appender/FileAppender.cs b/src/log4net/Appender/FileAppender.cs
index af0b387..a9cce8e 100644
--- a/src/log4net/Appender/FileAppender.cs
+++ b/src/log4net/Appender/FileAppender.cs
@@ -85,53 +85,53 @@
/// <author>Douglas de la Torre</author>
/// <author>Niall Daley</author>
#else
- /// <summary>
- /// Appends logging events to a file.
- /// </summary>
- /// <remarks>
- /// <para>
- /// Logging events are sent to the file specified by
- /// the <see cref="File"/> property.
- /// </para>
- /// <para>
- /// The file can be opened in either append or overwrite mode
- /// by specifying the <see cref="AppendToFile"/> property.
- /// If the file path is relative it is taken as relative from
- /// the application base directory. The file encoding can be
- /// specified by setting the <see cref="Encoding"/> property.
- /// </para>
- /// <para>
- /// The layout's <see cref="ILayout.Header"/> and <see cref="ILayout.Footer"/>
- /// values will be written each time the file is opened and closed
- /// respectively. If the <see cref="AppendToFile"/> property is <see langword="true"/>
- /// then the file may contain multiple copies of the header and footer.
- /// </para>
- /// <para>
- /// This appender will first try to open the file for writing when <see cref="ActivateOptions"/>
- /// is called. This will typically be during configuration.
- /// If the file cannot be opened for writing the appender will attempt
- /// to open the file again each time a message is logged to the appender.
- /// If the file cannot be opened for writing when a message is logged then
- /// the message will be discarded by this appender.
- /// </para>
- /// <para>
- /// The <see cref="FileAppender"/> supports pluggable file locking models via
- /// the <see cref="LockingModel"/> property.
- /// The default behavior, implemented by <see cref="FileAppender.ExclusiveLock"/>
- /// is to obtain an exclusive write lock on the file until this appender is closed.
- /// The alternative model only holds a
- /// write lock while the appender is writing a logging event (<see cref="FileAppender.MinimalLock"/>).
- /// </para>
- /// <para>
- /// All locking strategies have issues and you should seriously consider using a different strategy that
- /// avoids having multiple processes logging to the same file.
- /// </para>
- /// </remarks>
- /// <author>Nicko Cadell</author>
- /// <author>Gert Driesen</author>
- /// <author>Rodrigo B. de Oliveira</author>
- /// <author>Douglas de la Torre</author>
- /// <author>Niall Daley</author>
+ /// <summary>
+ /// Appends logging events to a file.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Logging events are sent to the file specified by
+ /// the <see cref="File"/> property.
+ /// </para>
+ /// <para>
+ /// The file can be opened in either append or overwrite mode
+ /// by specifying the <see cref="AppendToFile"/> property.
+ /// If the file path is relative it is taken as relative from
+ /// the application base directory. The file encoding can be
+ /// specified by setting the <see cref="Encoding"/> property.
+ /// </para>
+ /// <para>
+ /// The layout's <see cref="ILayout.Header"/> and <see cref="ILayout.Footer"/>
+ /// values will be written each time the file is opened and closed
+ /// respectively. If the <see cref="AppendToFile"/> property is <see langword="true"/>
+ /// then the file may contain multiple copies of the header and footer.
+ /// </para>
+ /// <para>
+ /// This appender will first try to open the file for writing when <see cref="ActivateOptions"/>
+ /// is called. This will typically be during configuration.
+ /// If the file cannot be opened for writing the appender will attempt
+ /// to open the file again each time a message is logged to the appender.
+ /// If the file cannot be opened for writing when a message is logged then
+ /// the message will be discarded by this appender.
+ /// </para>
+ /// <para>
+ /// The <see cref="FileAppender"/> supports pluggable file locking models via
+ /// the <see cref="LockingModel"/> property.
+ /// The default behavior, implemented by <see cref="FileAppender.ExclusiveLock"/>
+ /// is to obtain an exclusive write lock on the file until this appender is closed.
+ /// The alternative model only holds a
+ /// write lock while the appender is writing a logging event (<see cref="FileAppender.MinimalLock"/>).
+ /// </para>
+ /// <para>
+ /// All locking strategies have issues and you should seriously consider using a different strategy that
+ /// avoids having multiple processes logging to the same file.
+ /// </para>
+ /// </remarks>
+ /// <author>Nicko Cadell</author>
+ /// <author>Gert Driesen</author>
+ /// <author>Rodrigo B. de Oliveira</author>
+ /// <author>Douglas de la Torre</author>
+ /// <author>Niall Daley</author>
#endif
public class FileAppender : TextWriterAppender
{
@@ -186,11 +186,11 @@
#region Override Implementation of Stream
#if NETSTANDARD
- protected override void Dispose(bool disposing)
- {
- m_lockingModel.CloseFile();
- base.Dispose(disposing);
- }
+ protected override void Dispose(bool disposing)
+ {
+ m_lockingModel.CloseFile();
+ base.Dispose(disposing);
+ }
#else
private int m_readTotal = -1;
@@ -241,17 +241,17 @@
#endif
#if NET_4_5 || NETSTANDARD
- public override Task<int> ReadAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken)
- {
- AssertLocked();
- return m_realStream.ReadAsync(buffer, offset, count, cancellationToken);
- }
+ public override Task<int> ReadAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken)
+ {
+ AssertLocked();
+ return m_realStream.ReadAsync(buffer, offset, count, cancellationToken);
+ }
- public override Task WriteAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken)
- {
- AssertLocked();
- return base.WriteAsync(buffer, offset, count, cancellationToken);
- }
+ public override Task WriteAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken)
+ {
+ AssertLocked();
+ return base.WriteAsync(buffer, offset, count, cancellationToken);
+ }
#endif
public override void Flush()
@@ -285,7 +285,7 @@
void IDisposable.Dispose()
{
#if NETSTANDARD
- Dispose(true);
+ Dispose(true);
#else
Close();
#endif
@@ -792,7 +792,7 @@
/// </para>
/// </remarks>
#if NET_4_0 || MONO_4_0 || NETSTANDARD
- [System.Security.SecuritySafeCritical]
+ [System.Security.SecuritySafeCritical]
#endif
public override void OpenFile(string filename, bool append, Encoding encoding)
{
@@ -916,7 +916,7 @@
if (m_mutex != null)
{
#if NET_4_0 || MONO_4_0 || NETSTANDARD
- m_mutex.Dispose();
+ m_mutex.Dispose();
#else
m_mutex.Close();
#endif
@@ -1178,26 +1178,26 @@
}
#if NETCF
- /// <summary>
- /// Gets or sets the <see cref="FileAppender.LockingModel"/> used to handle locking of the file.
- /// </summary>
- /// <value>
- /// The <see cref="FileAppender.LockingModel"/> used to lock the file.
- /// </value>
- /// <remarks>
- /// <para>
- /// Gets or sets the <see cref="FileAppender.LockingModel"/> used to handle locking of the file.
- /// </para>
- /// <para>
- /// There are two built in locking models, <see cref="FileAppender.ExclusiveLock"/> and <see cref="FileAppender.MinimalLock"/>.
- /// The first locks the file from the start of logging to the end, the
- /// second locks only for the minimal amount of time when logging each message
- /// and the last synchronizes processes using a named system wide Mutex.
- /// </para>
- /// <para>
- /// The default locking model is the <see cref="FileAppender.ExclusiveLock"/>.
- /// </para>
- /// </remarks>
+ /// <summary>
+ /// Gets or sets the <see cref="FileAppender.LockingModel"/> used to handle locking of the file.
+ /// </summary>
+ /// <value>
+ /// The <see cref="FileAppender.LockingModel"/> used to lock the file.
+ /// </value>
+ /// <remarks>
+ /// <para>
+ /// Gets or sets the <see cref="FileAppender.LockingModel"/> used to handle locking of the file.
+ /// </para>
+ /// <para>
+ /// There are two built in locking models, <see cref="FileAppender.ExclusiveLock"/> and <see cref="FileAppender.MinimalLock"/>.
+ /// The first locks the file from the start of logging to the end, the
+ /// second locks only for the minimal amount of time when logging each message
+ /// and the last synchronizes processes using a named system wide Mutex.
+ /// </para>
+ /// <para>
+ /// The default locking model is the <see cref="FileAppender.ExclusiveLock"/>.
+ /// </para>
+ /// </remarks>
#else
/// <summary>
/// Gets or sets the <see cref="FileAppender.LockingModel"/> used to handle locking of the file.
diff --git a/src/log4net/Appender/ForwardingAppender.cs b/src/log4net/Appender/ForwardingAppender.cs
index 20a99cc..f1a1396 100644
--- a/src/log4net/Appender/ForwardingAppender.cs
+++ b/src/log4net/Appender/ForwardingAppender.cs
@@ -25,255 +25,255 @@
namespace log4net.Appender
{
- /// <summary>
- /// This appender forwards logging events to attached appenders.
- /// </summary>
- /// <remarks>
- /// <para>
- /// The forwarding appender can be used to specify different thresholds
- /// and filters for the same appender at different locations within the hierarchy.
- /// </para>
- /// </remarks>
- /// <author>Nicko Cadell</author>
- /// <author>Gert Driesen</author>
- public class ForwardingAppender : AppenderSkeleton, IAppenderAttachable
- {
- #region Public Instance Constructors
+ /// <summary>
+ /// This appender forwards logging events to attached appenders.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// The forwarding appender can be used to specify different thresholds
+ /// and filters for the same appender at different locations within the hierarchy.
+ /// </para>
+ /// </remarks>
+ /// <author>Nicko Cadell</author>
+ /// <author>Gert Driesen</author>
+ public class ForwardingAppender : AppenderSkeleton, IAppenderAttachable
+ {
+ #region Public Instance Constructors
- /// <summary>
- /// Initializes a new instance of the <see cref="ForwardingAppender" /> class.
- /// </summary>
- /// <remarks>
- /// <para>
- /// Default constructor.
- /// </para>
- /// </remarks>
- public ForwardingAppender()
- {
- }
+ /// <summary>
+ /// Initializes a new instance of the <see cref="ForwardingAppender" /> class.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Default constructor.
+ /// </para>
+ /// </remarks>
+ public ForwardingAppender()
+ {
+ }
- #endregion Public Instance Constructors
+ #endregion Public Instance Constructors
- #region Override implementation of AppenderSkeleton
+ #region Override implementation of AppenderSkeleton
- /// <summary>
- /// Closes the appender and releases resources.
- /// </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>
- protected override void OnClose()
- {
- // Remove all the attached appenders
- lock(this)
- {
- if (m_appenderAttachedImpl != null)
- {
- m_appenderAttachedImpl.RemoveAllAppenders();
- }
- }
- }
+ /// <summary>
+ /// Closes the appender and releases resources.
+ /// </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>
+ protected override void OnClose()
+ {
+ // Remove all the attached appenders
+ lock(this)
+ {
+ if (m_appenderAttachedImpl != null)
+ {
+ m_appenderAttachedImpl.RemoveAllAppenders();
+ }
+ }
+ }
- /// <summary>
- /// Forward the logging event to the attached appenders
- /// </summary>
- /// <param name="loggingEvent">The event to log.</param>
- /// <remarks>
- /// <para>
- /// Delivers the logging event to all the attached appenders.
- /// </para>
- /// </remarks>
- protected override void Append(LoggingEvent loggingEvent)
- {
- // Pass the logging event on the the attached appenders
- if (m_appenderAttachedImpl != null)
- {
- m_appenderAttachedImpl.AppendLoopOnAppenders(loggingEvent);
- }
- }
+ /// <summary>
+ /// Forward the logging event to the attached appenders
+ /// </summary>
+ /// <param name="loggingEvent">The event to log.</param>
+ /// <remarks>
+ /// <para>
+ /// Delivers the logging event to all the attached appenders.
+ /// </para>
+ /// </remarks>
+ protected override void Append(LoggingEvent loggingEvent)
+ {
+ // Pass the logging event on the the attached appenders
+ if (m_appenderAttachedImpl != null)
+ {
+ m_appenderAttachedImpl.AppendLoopOnAppenders(loggingEvent);
+ }
+ }
- /// <summary>
- /// Forward the logging events to the attached appenders
- /// </summary>
- /// <param name="loggingEvents">The array of events to log.</param>
- /// <remarks>
- /// <para>
- /// Delivers the logging events to all the attached appenders.
- /// </para>
- /// </remarks>
- protected override void Append(LoggingEvent[] loggingEvents)
- {
- // Pass the logging event on the the attached appenders
- if (m_appenderAttachedImpl != null)
- {
- m_appenderAttachedImpl.AppendLoopOnAppenders(loggingEvents);
- }
- }
+ /// <summary>
+ /// Forward the logging events to the attached appenders
+ /// </summary>
+ /// <param name="loggingEvents">The array of events to log.</param>
+ /// <remarks>
+ /// <para>
+ /// Delivers the logging events to all the attached appenders.
+ /// </para>
+ /// </remarks>
+ protected override void Append(LoggingEvent[] loggingEvents)
+ {
+ // Pass the logging event on the the attached appenders
+ if (m_appenderAttachedImpl != null)
+ {
+ m_appenderAttachedImpl.AppendLoopOnAppenders(loggingEvents);
+ }
+ }
- #endregion Override implementation of AppenderSkeleton
+ #endregion Override implementation of AppenderSkeleton
- #region Implementation of IAppenderAttachable
+ #region Implementation of IAppenderAttachable
- /// <summary>
- /// Adds an <see cref="IAppender" /> to the list of appenders of this
- /// instance.
- /// </summary>
- /// <param name="newAppender">The <see cref="IAppender" /> to add to this appender.</param>
- /// <remarks>
- /// <para>
- /// If the specified <see cref="IAppender" /> is already in the list of
- /// appenders, then it won't be added again.
- /// </para>
- /// </remarks>
- public virtual void AddAppender(IAppender newAppender)
- {
- if (newAppender == null)
- {
- throw new ArgumentNullException("newAppender");
- }
- lock(this)
- {
- if (m_appenderAttachedImpl == null)
- {
- m_appenderAttachedImpl = new log4net.Util.AppenderAttachedImpl();
- }
- m_appenderAttachedImpl.AddAppender(newAppender);
- }
- }
+ /// <summary>
+ /// Adds an <see cref="IAppender" /> to the list of appenders of this
+ /// instance.
+ /// </summary>
+ /// <param name="newAppender">The <see cref="IAppender" /> to add to this appender.</param>
+ /// <remarks>
+ /// <para>
+ /// If the specified <see cref="IAppender" /> is already in the list of
+ /// appenders, then it won't be added again.
+ /// </para>
+ /// </remarks>
+ public virtual void AddAppender(IAppender newAppender)
+ {
+ if (newAppender == null)
+ {
+ throw new ArgumentNullException("newAppender");
+ }
+ lock(this)
+ {
+ if (m_appenderAttachedImpl == null)
+ {
+ m_appenderAttachedImpl = new log4net.Util.AppenderAttachedImpl();
+ }
+ m_appenderAttachedImpl.AddAppender(newAppender);
+ }
+ }
- /// <summary>
- /// Gets the appenders contained in this appender as an
- /// <see cref="System.Collections.ICollection"/>.
- /// </summary>
- /// <remarks>
- /// If no appenders can be found, then an <see cref="EmptyCollection"/>
- /// is returned.
- /// </remarks>
- /// <returns>
- /// A collection of the appenders in this appender.
- /// </returns>
- public virtual AppenderCollection Appenders
- {
- get
- {
- lock(this)
- {
- if (m_appenderAttachedImpl == null)
- {
- return AppenderCollection.EmptyCollection;
- }
- else
- {
- return m_appenderAttachedImpl.Appenders;
- }
- }
- }
- }
+ /// <summary>
+ /// Gets the appenders contained in this appender as an
+ /// <see cref="System.Collections.ICollection"/>.
+ /// </summary>
+ /// <remarks>
+ /// If no appenders can be found, then an <see cref="EmptyCollection"/>
+ /// is returned.
+ /// </remarks>
+ /// <returns>
+ /// A collection of the appenders in this appender.
+ /// </returns>
+ public virtual AppenderCollection Appenders
+ {
+ get
+ {
+ lock(this)
+ {
+ if (m_appenderAttachedImpl == null)
+ {
+ return AppenderCollection.EmptyCollection;
+ }
+ else
+ {
+ return m_appenderAttachedImpl.Appenders;
+ }
+ }
+ }
+ }
- /// <summary>
- /// Looks for the appender with the specified name.
- /// </summary>
- /// <param name="name">The name of the appender to lookup.</param>
- /// <returns>
- /// The appender with the specified name, or <c>null</c>.
- /// </returns>
- /// <remarks>
- /// <para>
- /// Get the named appender attached to this appender.
- /// </para>
- /// </remarks>
- public virtual IAppender GetAppender(string name)
- {
- lock(this)
- {
- if (m_appenderAttachedImpl == null || name == null)
- {
- return null;
- }
+ /// <summary>
+ /// Looks for the appender with the specified name.
+ /// </summary>
+ /// <param name="name">The name of the appender to lookup.</param>
+ /// <returns>
+ /// The appender with the specified name, or <c>null</c>.
+ /// </returns>
+ /// <remarks>
+ /// <para>
+ /// Get the named appender attached to this appender.
+ /// </para>
+ /// </remarks>
+ public virtual IAppender GetAppender(string name)
+ {
+ lock(this)
+ {
+ if (m_appenderAttachedImpl == null || name == null)
+ {
+ return null;
+ }
- return m_appenderAttachedImpl.GetAppender(name);
- }
- }
+ return m_appenderAttachedImpl.GetAppender(name);
+ }
+ }
- /// <summary>
- /// Removes all previously added appenders from this appender.
- /// </summary>
- /// <remarks>
- /// <para>
- /// This is useful when re-reading configuration information.
- /// </para>
- /// </remarks>
- public virtual void RemoveAllAppenders()
- {
- lock(this)
- {
- if (m_appenderAttachedImpl != null)
- {
- m_appenderAttachedImpl.RemoveAllAppenders();
- m_appenderAttachedImpl = null;
- }
- }
- }
+ /// <summary>
+ /// Removes all previously added appenders from this appender.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// This is useful when re-reading configuration information.
+ /// </para>
+ /// </remarks>
+ public virtual void RemoveAllAppenders()
+ {
+ lock(this)
+ {
+ if (m_appenderAttachedImpl != null)
+ {
+ m_appenderAttachedImpl.RemoveAllAppenders();
+ m_appenderAttachedImpl = null;
+ }
+ }
+ }
- /// <summary>
- /// Removes the specified appender from the list of appenders.
- /// </summary>
- /// <param name="appender">The appender to remove.</param>
- /// <returns>The appender removed from the list</returns>
- /// <remarks>
- /// The appender removed is not closed.
- /// If you are discarding the appender you must call
- /// <see cref="IAppender.Close"/> on the appender removed.
- /// </remarks>
- public virtual IAppender RemoveAppender(IAppender appender)
- {
- lock(this)
- {
- if (appender != null && m_appenderAttachedImpl != null)
- {
- return m_appenderAttachedImpl.RemoveAppender(appender);
- }
- }
- return null;
- }
+ /// <summary>
+ /// Removes the specified appender from the list of appenders.
+ /// </summary>
+ /// <param name="appender">The appender to remove.</param>
+ /// <returns>The appender removed from the list</returns>
+ /// <remarks>
+ /// The appender removed is not closed.
+ /// If you are discarding the appender you must call
+ /// <see cref="IAppender.Close"/> on the appender removed.
+ /// </remarks>
+ public virtual IAppender RemoveAppender(IAppender appender)
+ {
+ lock(this)
+ {
+ if (appender != null && m_appenderAttachedImpl != null)
+ {
+ return m_appenderAttachedImpl.RemoveAppender(appender);
+ }
+ }
+ return null;
+ }
- /// <summary>
- /// Removes the appender with the specified name from the list of appenders.
- /// </summary>
- /// <param name="name">The name of the appender to remove.</param>
- /// <returns>The appender removed from the list</returns>
- /// <remarks>
- /// The appender removed is not closed.
- /// If you are discarding the appender you must call
- /// <see cref="IAppender.Close"/> on the appender removed.
- /// </remarks>
- public virtual IAppender RemoveAppender(string name)
- {
- lock(this)
- {
- if (name != null && m_appenderAttachedImpl != null)
- {
- return m_appenderAttachedImpl.RemoveAppender(name);
- }
- }
- return null;
- }
+ /// <summary>
+ /// Removes the appender with the specified name from the list of appenders.
+ /// </summary>
+ /// <param name="name">The name of the appender to remove.</param>
+ /// <returns>The appender removed from the list</returns>
+ /// <remarks>
+ /// The appender removed is not closed.
+ /// If you are discarding the appender you must call
+ /// <see cref="IAppender.Close"/> on the appender removed.
+ /// </remarks>
+ public virtual IAppender RemoveAppender(string name)
+ {
+ lock(this)
+ {
+ if (name != null && m_appenderAttachedImpl != null)
+ {
+ return m_appenderAttachedImpl.RemoveAppender(name);
+ }
+ }
+ return null;
+ }
- #endregion Implementation of IAppenderAttachable
+ #endregion Implementation of IAppenderAttachable
- #region Private Instance Fields
+ #region Private Instance Fields
- /// <summary>
- /// Implementation of the <see cref="IAppenderAttachable"/> interface
- /// </summary>
- private AppenderAttachedImpl m_appenderAttachedImpl;
+ /// <summary>
+ /// Implementation of the <see cref="IAppenderAttachable"/> interface
+ /// </summary>
+ private AppenderAttachedImpl m_appenderAttachedImpl;
- #endregion Private Instance Fields
- }
+ #endregion Private Instance Fields
+ }
}
diff --git a/src/log4net/Appender/IAppender.cs b/src/log4net/Appender/IAppender.cs
index a644f07..3f2fb0b 100644
--- a/src/log4net/Appender/IAppender.cs
+++ b/src/log4net/Appender/IAppender.cs
@@ -23,56 +23,56 @@
namespace log4net.Appender
{
- /// <summary>
- /// Implement this interface for your own strategies for printing log statements.
- /// </summary>
- /// <remarks>
- /// <para>
- /// Implementors should consider extending the <see cref="AppenderSkeleton"/>
- /// class which provides a default implementation of this interface.
- /// </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 interface IAppender
- {
- /// <summary>
- /// Closes the appender and releases resources.
- /// </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>
- void Close();
+ /// <summary>
+ /// Implement this interface for your own strategies for printing log statements.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Implementors should consider extending the <see cref="AppenderSkeleton"/>
+ /// class which provides a default implementation of this interface.
+ /// </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 interface IAppender
+ {
+ /// <summary>
+ /// Closes the appender and releases resources.
+ /// </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>
+ void Close();
- /// <summary>
- /// Log the logging event in Appender specific way.
- /// </summary>
- /// <param name="loggingEvent">The event to log</param>
- /// <remarks>
- /// <para>
- /// This method is called to log a message into this appender.
- /// </para>
- /// </remarks>
- void DoAppend(LoggingEvent loggingEvent);
+ /// <summary>
+ /// Log the logging event in Appender specific way.
+ /// </summary>
+ /// <param name="loggingEvent">The event to log</param>
+ /// <remarks>
+ /// <para>
+ /// This method is called to log a message into this appender.
+ /// </para>
+ /// </remarks>
+ void DoAppend(LoggingEvent loggingEvent);
- /// <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>
- string Name { get; set; }
- }
+ /// <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>
+ string Name { get; set; }
+ }
}
diff --git a/src/log4net/Appender/IBulkAppender.cs b/src/log4net/Appender/IBulkAppender.cs
index 469eb85..9ccb1e8 100644
--- a/src/log4net/Appender/IBulkAppender.cs
+++ b/src/log4net/Appender/IBulkAppender.cs
@@ -21,28 +21,28 @@
namespace log4net.Appender
{
- /// <summary>
- /// Interface for appenders that support bulk logging.
- /// </summary>
- /// <remarks>
- /// <para>
- /// This interface extends the <see cref="IAppender"/> interface to
- /// support bulk logging of <see cref="LoggingEvent"/> objects. Appenders
- /// should only implement this interface if they can bulk log efficiently.
- /// </para>
- /// </remarks>
- /// <author>Nicko Cadell</author>
- public interface IBulkAppender : IAppender
- {
- /// <summary>
- /// Log the array of logging events in Appender specific way.
- /// </summary>
- /// <param name="loggingEvents">The events to log</param>
- /// <remarks>
- /// <para>
- /// This method is called to log an array of events into this appender.
- /// </para>
- /// </remarks>
- void DoAppend(LoggingEvent[] loggingEvents);
- }
+ /// <summary>
+ /// Interface for appenders that support bulk logging.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// This interface extends the <see cref="IAppender"/> interface to
+ /// support bulk logging of <see cref="LoggingEvent"/> objects. Appenders
+ /// should only implement this interface if they can bulk log efficiently.
+ /// </para>
+ /// </remarks>
+ /// <author>Nicko Cadell</author>
+ public interface IBulkAppender : IAppender
+ {
+ /// <summary>
+ /// Log the array of logging events in Appender specific way.
+ /// </summary>
+ /// <param name="loggingEvents">The events to log</param>
+ /// <remarks>
+ /// <para>
+ /// This method is called to log an array of events into this appender.
+ /// </para>
+ /// </remarks>
+ void DoAppend(LoggingEvent[] loggingEvents);
+ }
}
diff --git a/src/log4net/Appender/LocalSyslogAppender.cs b/src/log4net/Appender/LocalSyslogAppender.cs
index ad31b5d..3cd0c16 100644
--- a/src/log4net/Appender/LocalSyslogAppender.cs
+++ b/src/log4net/Appender/LocalSyslogAppender.cs
@@ -29,577 +29,577 @@
namespace log4net.Appender
{
- /// <summary>
- /// Logs events to a local syslog service.
- /// </summary>
- /// <remarks>
- /// <note>
- /// This appender uses the POSIX libc library functions <c>openlog</c>, <c>syslog</c>, and <c>closelog</c>.
- /// If these functions are not available on the local system then this appender will not work!
- /// </note>
- /// <para>
- /// The functions <c>openlog</c>, <c>syslog</c>, and <c>closelog</c> are specified in SUSv2 and
- /// POSIX 1003.1-2001 standards. These are used to log messages to the local syslog service.
- /// </para>
- /// <para>
- /// This appender talks to a local syslog service. If you need to log to a remote syslog
- /// daemon and you cannot configure your local syslog service to do this you may be
- /// able to use the <see cref="RemoteSyslogAppender"/> to log via UDP.
- /// </para>
- /// <para>
- /// Syslog messages must have a facility and and a severity. The severity
- /// is derived from the Level of the logging event.
- /// The facility must be chosen from the set of defined syslog
- /// <see cref="SyslogFacility"/> values. The facilities list is predefined
- /// and cannot be extended.
- /// </para>
- /// <para>
- /// An identifier is specified with each log message. This can be specified
- /// by setting the <see cref="Identity"/> property. The identity (also know
- /// as the tag) must not contain white space. The default value for the
- /// identity is the application name (from <see cref="SystemInfo.ApplicationFriendlyName"/>).
- /// </para>
- /// </remarks>
- /// <author>Rob Lyon</author>
- /// <author>Nicko Cadell</author>
- public class LocalSyslogAppender : AppenderSkeleton
- {
- #region Enumerations
+ /// <summary>
+ /// Logs events to a local syslog service.
+ /// </summary>
+ /// <remarks>
+ /// <note>
+ /// This appender uses the POSIX libc library functions <c>openlog</c>, <c>syslog</c>, and <c>closelog</c>.
+ /// If these functions are not available on the local system then this appender will not work!
+ /// </note>
+ /// <para>
+ /// The functions <c>openlog</c>, <c>syslog</c>, and <c>closelog</c> are specified in SUSv2 and
+ /// POSIX 1003.1-2001 standards. These are used to log messages to the local syslog service.
+ /// </para>
+ /// <para>
+ /// This appender talks to a local syslog service. If you need to log to a remote syslog
+ /// daemon and you cannot configure your local syslog service to do this you may be
+ /// able to use the <see cref="RemoteSyslogAppender"/> to log via UDP.
+ /// </para>
+ /// <para>
+ /// Syslog messages must have a facility and and a severity. The severity
+ /// is derived from the Level of the logging event.
+ /// The facility must be chosen from the set of defined syslog
+ /// <see cref="SyslogFacility"/> values. The facilities list is predefined
+ /// and cannot be extended.
+ /// </para>
+ /// <para>
+ /// An identifier is specified with each log message. This can be specified
+ /// by setting the <see cref="Identity"/> property. The identity (also know
+ /// as the tag) must not contain white space. The default value for the
+ /// identity is the application name (from <see cref="SystemInfo.ApplicationFriendlyName"/>).
+ /// </para>
+ /// </remarks>
+ /// <author>Rob Lyon</author>
+ /// <author>Nicko Cadell</author>
+ public class LocalSyslogAppender : AppenderSkeleton
+ {
+ #region Enumerations
- /// <summary>
- /// syslog severities
- /// </summary>
- /// <remarks>
- /// <para>
- /// The log4net Level maps to a syslog severity using the
- /// <see cref="LocalSyslogAppender.AddMapping"/> method and the <see cref="LevelSeverity"/>
- /// class. The severity is set on <see cref="LevelSeverity.Severity"/>.
- /// </para>
- /// </remarks>
- public enum SyslogSeverity
- {
- /// <summary>
- /// system is unusable
- /// </summary>
- Emergency = 0,
+ /// <summary>
+ /// syslog severities
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// The log4net Level maps to a syslog severity using the
+ /// <see cref="LocalSyslogAppender.AddMapping"/> method and the <see cref="LevelSeverity"/>
+ /// class. The severity is set on <see cref="LevelSeverity.Severity"/>.
+ /// </para>
+ /// </remarks>
+ public enum SyslogSeverity
+ {
+ /// <summary>
+ /// system is unusable
+ /// </summary>
+ Emergency = 0,
- /// <summary>
- /// action must be taken immediately
- /// </summary>
- Alert = 1,
+ /// <summary>
+ /// action must be taken immediately
+ /// </summary>
+ Alert = 1,
- /// <summary>
- /// critical conditions
- /// </summary>
- Critical = 2,
+ /// <summary>
+ /// critical conditions
+ /// </summary>
+ Critical = 2,
- /// <summary>
- /// error conditions
- /// </summary>
- Error = 3,
+ /// <summary>
+ /// error conditions
+ /// </summary>
+ Error = 3,
- /// <summary>
- /// warning conditions
- /// </summary>
- Warning = 4,
+ /// <summary>
+ /// warning conditions
+ /// </summary>
+ Warning = 4,
- /// <summary>
- /// normal but significant condition
- /// </summary>
- Notice = 5,
+ /// <summary>
+ /// normal but significant condition
+ /// </summary>
+ Notice = 5,
- /// <summary>
- /// informational
- /// </summary>
- Informational = 6,
+ /// <summary>
+ /// informational
+ /// </summary>
+ Informational = 6,
- /// <summary>
- /// debug-level messages
- /// </summary>
- Debug = 7
- };
+ /// <summary>
+ /// debug-level messages
+ /// </summary>
+ Debug = 7
+ };
- /// <summary>
- /// syslog facilities
- /// </summary>
- /// <remarks>
- /// <para>
- /// The syslog facility defines which subsystem the logging comes from.
- /// This is set on the <see cref="Facility"/> property.
- /// </para>
- /// </remarks>
- public enum SyslogFacility
- {
- /// <summary>
- /// kernel messages
- /// </summary>
- Kernel = 0,
+ /// <summary>
+ /// syslog facilities
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// The syslog facility defines which subsystem the logging comes from.
+ /// This is set on the <see cref="Facility"/> property.
+ /// </para>
+ /// </remarks>
+ public enum SyslogFacility
+ {
+ /// <summary>
+ /// kernel messages
+ /// </summary>
+ Kernel = 0,
- /// <summary>
- /// random user-level messages
- /// </summary>
- User = 1,
+ /// <summary>
+ /// random user-level messages
+ /// </summary>
+ User = 1,
- /// <summary>
- /// mail system
- /// </summary>
- Mail = 2,
+ /// <summary>
+ /// mail system
+ /// </summary>
+ Mail = 2,
- /// <summary>
- /// system daemons
- /// </summary>
- Daemons = 3,
+ /// <summary>
+ /// system daemons
+ /// </summary>
+ Daemons = 3,
- /// <summary>
- /// security/authorization messages
- /// </summary>
- Authorization = 4,
+ /// <summary>
+ /// security/authorization messages
+ /// </summary>
+ Authorization = 4,
- /// <summary>
- /// messages generated internally by syslogd
- /// </summary>
- Syslog = 5,
+ /// <summary>
+ /// messages generated internally by syslogd
+ /// </summary>
+ Syslog = 5,
- /// <summary>
- /// line printer subsystem
- /// </summary>
- Printer = 6,
+ /// <summary>
+ /// line printer subsystem
+ /// </summary>
+ Printer = 6,
- /// <summary>
- /// network news subsystem
- /// </summary>
- News = 7,
+ /// <summary>
+ /// network news subsystem
+ /// </summary>
+ News = 7,
- /// <summary>
- /// UUCP subsystem
- /// </summary>
- Uucp = 8,
+ /// <summary>
+ /// UUCP subsystem
+ /// </summary>
+ Uucp = 8,
- /// <summary>
- /// clock (cron/at) daemon
- /// </summary>
- Clock = 9,
+ /// <summary>
+ /// clock (cron/at) daemon
+ /// </summary>
+ Clock = 9,
- /// <summary>
- /// security/authorization messages (private)
- /// </summary>
- Authorization2 = 10,
+ /// <summary>
+ /// security/authorization messages (private)
+ /// </summary>
+ Authorization2 = 10,
- /// <summary>
- /// ftp daemon
- /// </summary>
- Ftp = 11,
+ /// <summary>
+ /// ftp daemon
+ /// </summary>
+ Ftp = 11,
- /// <summary>
- /// NTP subsystem
- /// </summary>
- Ntp = 12,
+ /// <summary>
+ /// NTP subsystem
+ /// </summary>
+ Ntp = 12,
- /// <summary>
- /// log audit
- /// </summary>
- Audit = 13,
+ /// <summary>
+ /// log audit
+ /// </summary>
+ Audit = 13,
- /// <summary>
- /// log alert
- /// </summary>
- Alert = 14,
+ /// <summary>
+ /// log alert
+ /// </summary>
+ Alert = 14,
- /// <summary>
- /// clock daemon
- /// </summary>
- Clock2 = 15,
+ /// <summary>
+ /// clock daemon
+ /// </summary>
+ Clock2 = 15,
- /// <summary>
- /// reserved for local use
- /// </summary>
- Local0 = 16,
+ /// <summary>
+ /// reserved for local use
+ /// </summary>
+ Local0 = 16,
- /// <summary>
- /// reserved for local use
- /// </summary>
- Local1 = 17,
+ /// <summary>
+ /// reserved for local use
+ /// </summary>
+ Local1 = 17,
- /// <summary>
- /// reserved for local use
- /// </summary>
- Local2 = 18,
+ /// <summary>
+ /// reserved for local use
+ /// </summary>
+ Local2 = 18,
- /// <summary>
- /// reserved for local use
- /// </summary>
- Local3 = 19,
+ /// <summary>
+ /// reserved for local use
+ /// </summary>
+ Local3 = 19,
- /// <summary>
- /// reserved for local use
- /// </summary>
- Local4 = 20,
+ /// <summary>
+ /// reserved for local use
+ /// </summary>
+ Local4 = 20,
- /// <summary>
- /// reserved for local use
- /// </summary>
- Local5 = 21,
+ /// <summary>
+ /// reserved for local use
+ /// </summary>
+ Local5 = 21,
- /// <summary>
- /// reserved for local use
- /// </summary>
- Local6 = 22,
+ /// <summary>
+ /// reserved for local use
+ /// </summary>
+ Local6 = 22,
- /// <summary>
- /// reserved for local use
- /// </summary>
- Local7 = 23
- }
+ /// <summary>
+ /// reserved for local use
+ /// </summary>
+ Local7 = 23
+ }
- #endregion // Enumerations
+ #endregion // Enumerations
- #region Public Instance Constructors
+ #region Public Instance Constructors
- /// <summary>
- /// Initializes a new instance of the <see cref="LocalSyslogAppender" /> class.
- /// </summary>
- /// <remarks>
- /// This instance of the <see cref="LocalSyslogAppender" /> class is set up to write
- /// to a local syslog service.
- /// </remarks>
- public LocalSyslogAppender()
- {
- }
+ /// <summary>
+ /// Initializes a new instance of the <see cref="LocalSyslogAppender" /> class.
+ /// </summary>
+ /// <remarks>
+ /// This instance of the <see cref="LocalSyslogAppender" /> class is set up to write
+ /// to a local syslog service.
+ /// </remarks>
+ public LocalSyslogAppender()
+ {
+ }
- #endregion // Public Instance Constructors
+ #endregion // Public Instance Constructors
- #region Public Instance Properties
-
- /// <summary>
- /// Message identity
- /// </summary>
- /// <remarks>
- /// <para>
- /// An identifier is specified with each log message. This can be specified
- /// by setting the <see cref="Identity"/> property. The identity (also know
- /// as the tag) must not contain white space. The default value for the
- /// identity is the application name (from <see cref="SystemInfo.ApplicationFriendlyName"/>).
- /// </para>
- /// </remarks>
- public string Identity
- {
- get { return m_identity; }
- set { m_identity = value; }
- }
+ #region Public Instance Properties
+
+ /// <summary>
+ /// Message identity
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// An identifier is specified with each log message. This can be specified
+ /// by setting the <see cref="Identity"/> property. The identity (also know
+ /// as the tag) must not contain white space. The default value for the
+ /// identity is the application name (from <see cref="SystemInfo.ApplicationFriendlyName"/>).
+ /// </para>
+ /// </remarks>
+ public string Identity
+ {
+ get { return m_identity; }
+ set { m_identity = value; }
+ }
- /// <summary>
- /// Syslog facility
- /// </summary>
- /// <remarks>
- /// Set to one of the <see cref="SyslogFacility"/> values. The list of
- /// facilities is predefined and cannot be extended. The default value
- /// is <see cref="SyslogFacility.User"/>.
- /// </remarks>
- public SyslogFacility Facility
- {
- get { return m_facility; }
- set { m_facility = value; }
- }
-
- #endregion // Public Instance Properties
+ /// <summary>
+ /// Syslog facility
+ /// </summary>
+ /// <remarks>
+ /// Set to one of the <see cref="SyslogFacility"/> values. The list of
+ /// facilities is predefined and cannot be extended. The default value
+ /// is <see cref="SyslogFacility.User"/>.
+ /// </remarks>
+ public SyslogFacility Facility
+ {
+ get { return m_facility; }
+ set { m_facility = value; }
+ }
+
+ #endregion // Public Instance Properties
- /// <summary>
- /// Add a mapping of level to severity
- /// </summary>
- /// <param name="mapping">The mapping to add</param>
- /// <remarks>
- /// <para>
- /// Adds a <see cref="LevelSeverity"/> to this appender.
- /// </para>
- /// </remarks>
- public void AddMapping(LevelSeverity mapping)
- {
- m_levelMapping.Add(mapping);
- }
+ /// <summary>
+ /// Add a mapping of level to severity
+ /// </summary>
+ /// <param name="mapping">The mapping to add</param>
+ /// <remarks>
+ /// <para>
+ /// Adds a <see cref="LevelSeverity"/> to this appender.
+ /// </para>
+ /// </remarks>
+ public void AddMapping(LevelSeverity mapping)
+ {
+ m_levelMapping.Add(mapping);
+ }
- #region IOptionHandler Implementation
+ #region IOptionHandler Implementation
- /// <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>
+ /// <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>
#if NET_4_0 || MONO_4_0 || NETSTANDARD
- [System.Security.SecuritySafeCritical]
+ [System.Security.SecuritySafeCritical]
#endif
- public override void ActivateOptions()
- {
- base.ActivateOptions();
-
- m_levelMapping.ActivateOptions();
+ public override void ActivateOptions()
+ {
+ base.ActivateOptions();
+
+ m_levelMapping.ActivateOptions();
- string identString = m_identity;
- if (identString == null)
- {
- // Set to app name by default
- identString = SystemInfo.ApplicationFriendlyName;
- }
+ string identString = m_identity;
+ if (identString == null)
+ {
+ // Set to app name by default
+ identString = SystemInfo.ApplicationFriendlyName;
+ }
- // create the native heap ansi string. Note this is a copy of our string
- // so we do not need to hold on to the string itself, holding on to the
- // handle will keep the heap ansi string alive.
- m_handleToIdentity = Marshal.StringToHGlobalAnsi(identString);
+ // create the native heap ansi string. Note this is a copy of our string
+ // so we do not need to hold on to the string itself, holding on to the
+ // handle will keep the heap ansi string alive.
+ m_handleToIdentity = Marshal.StringToHGlobalAnsi(identString);
- // open syslog
- openlog(m_handleToIdentity, 1, m_facility);
- }
+ // open syslog
+ openlog(m_handleToIdentity, 1, m_facility);
+ }
- #endregion // IOptionHandler Implementation
+ #endregion // IOptionHandler Implementation
- #region AppenderSkeleton Implementation
+ #region AppenderSkeleton Implementation
- /// <summary>
- /// This method is called by the <see cref="M:AppenderSkeleton.DoAppend(LoggingEvent)"/> method.
- /// </summary>
- /// <param name="loggingEvent">The event to log.</param>
- /// <remarks>
- /// <para>
- /// Writes the event to a remote syslog daemon.
- /// </para>
- /// <para>
- /// The format of the output will depend on the appender's layout.
- /// </para>
- /// </remarks>
+ /// <summary>
+ /// This method is called by the <see cref="M:AppenderSkeleton.DoAppend(LoggingEvent)"/> method.
+ /// </summary>
+ /// <param name="loggingEvent">The event to log.</param>
+ /// <remarks>
+ /// <para>
+ /// Writes the event to a remote syslog daemon.
+ /// </para>
+ /// <para>
+ /// The format of the output will depend on the appender's layout.
+ /// </para>
+ /// </remarks>
#if NET_4_0 || MONO_4_0 || NETSTANDARD
- [System.Security.SecuritySafeCritical]
+ [System.Security.SecuritySafeCritical]
#endif
#if !NETSTANDARD1_3
- [System.Security.Permissions.SecurityPermission(System.Security.Permissions.SecurityAction.Demand, UnmanagedCode = true)]
+ [System.Security.Permissions.SecurityPermission(System.Security.Permissions.SecurityAction.Demand, UnmanagedCode = true)]
#endif
- protected override void Append(LoggingEvent loggingEvent)
- {
- int priority = GeneratePriority(m_facility, GetSeverity(loggingEvent.Level));
- string message = RenderLoggingEvent(loggingEvent);
+ protected override void Append(LoggingEvent loggingEvent)
+ {
+ int priority = GeneratePriority(m_facility, GetSeverity(loggingEvent.Level));
+ string message = RenderLoggingEvent(loggingEvent);
- // Call the local libc syslog method
- // The second argument is a printf style format string
- syslog(priority, "%s", message);
- }
+ // Call the local libc syslog method
+ // The second argument is a printf style format string
+ syslog(priority, "%s", message);
+ }
- /// <summary>
- /// Close the syslog when the appender is closed
- /// </summary>
- /// <remarks>
- /// <para>
- /// Close the syslog when the appender is closed
- /// </para>
- /// </remarks>
+ /// <summary>
+ /// Close the syslog when the appender is closed
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Close the syslog when the appender is closed
+ /// </para>
+ /// </remarks>
#if NET_4_0 || MONO_4_0 || NETSTANDARD
- [System.Security.SecuritySafeCritical]
+ [System.Security.SecuritySafeCritical]
#endif
- protected override void OnClose()
- {
- base.OnClose();
+ protected override void OnClose()
+ {
+ base.OnClose();
- try
- {
- // close syslog
- closelog();
- }
- catch(DllNotFoundException)
- {
- // Ignore dll not found at this point
- }
-
- if (m_handleToIdentity != IntPtr.Zero)
- {
- // free global ident
- Marshal.FreeHGlobal(m_handleToIdentity);
- }
- }
+ try
+ {
+ // close syslog
+ closelog();
+ }
+ catch(DllNotFoundException)
+ {
+ // Ignore dll not found at this point
+ }
+
+ if (m_handleToIdentity != IntPtr.Zero)
+ {
+ // free global ident
+ Marshal.FreeHGlobal(m_handleToIdentity);
+ }
+ }
- /// <summary>
- /// This appender requires a <see cref="AppenderSkeleton.Layout"/> to be set.
- /// </summary>
- /// <value><c>true</c></value>
- /// <remarks>
- /// <para>
- /// This appender requires a <see cref="AppenderSkeleton.Layout"/> to be set.
- /// </para>
- /// </remarks>
- protected override bool RequiresLayout
- {
- get { return true; }
- }
+ /// <summary>
+ /// This appender requires a <see cref="AppenderSkeleton.Layout"/> to be set.
+ /// </summary>
+ /// <value><c>true</c></value>
+ /// <remarks>
+ /// <para>
+ /// This appender requires a <see cref="AppenderSkeleton.Layout"/> to be set.
+ /// </para>
+ /// </remarks>
+ protected override bool RequiresLayout
+ {
+ get { return true; }
+ }
- #endregion // AppenderSkeleton Implementation
+ #endregion // AppenderSkeleton Implementation
- #region Protected Members
+ #region Protected Members
- /// <summary>
- /// Translates a log4net level to a syslog severity.
- /// </summary>
- /// <param name="level">A log4net level.</param>
- /// <returns>A syslog severity.</returns>
- /// <remarks>
- /// <para>
- /// Translates a log4net level to a syslog severity.
- /// </para>
- /// </remarks>
- protected virtual SyslogSeverity GetSeverity(Level level)
- {
- LevelSeverity levelSeverity = m_levelMapping.Lookup(level) as LevelSeverity;
- if (levelSeverity != null)
- {
- return levelSeverity.Severity;
- }
+ /// <summary>
+ /// Translates a log4net level to a syslog severity.
+ /// </summary>
+ /// <param name="level">A log4net level.</param>
+ /// <returns>A syslog severity.</returns>
+ /// <remarks>
+ /// <para>
+ /// Translates a log4net level to a syslog severity.
+ /// </para>
+ /// </remarks>
+ protected virtual SyslogSeverity GetSeverity(Level level)
+ {
+ LevelSeverity levelSeverity = m_levelMapping.Lookup(level) as LevelSeverity;
+ if (levelSeverity != null)
+ {
+ return levelSeverity.Severity;
+ }
- //
- // Fallback to sensible default values
- //
+ //
+ // Fallback to sensible default values
+ //
- if (level >= Level.Alert)
- {
- return SyslogSeverity.Alert;
- }
- else if (level >= Level.Critical)
- {
- return SyslogSeverity.Critical;
- }
- else if (level >= Level.Error)
- {
- return SyslogSeverity.Error;
- }
- else if (level >= Level.Warn)
- {
- return SyslogSeverity.Warning;
- }
- else if (level >= Level.Notice)
- {
- return SyslogSeverity.Notice;
- }
- else if (level >= Level.Info)
- {
- return SyslogSeverity.Informational;
- }
- // Default setting
- return SyslogSeverity.Debug;
- }
+ if (level >= Level.Alert)
+ {
+ return SyslogSeverity.Alert;
+ }
+ else if (level >= Level.Critical)
+ {
+ return SyslogSeverity.Critical;
+ }
+ else if (level >= Level.Error)
+ {
+ return SyslogSeverity.Error;
+ }
+ else if (level >= Level.Warn)
+ {
+ return SyslogSeverity.Warning;
+ }
+ else if (level >= Level.Notice)
+ {
+ return SyslogSeverity.Notice;
+ }
+ else if (level >= Level.Info)
+ {
+ return SyslogSeverity.Informational;
+ }
+ // Default setting
+ return SyslogSeverity.Debug;
+ }
- #endregion // Protected Members
+ #endregion // Protected Members
- #region Public Static Members
+ #region Public Static Members
- /// <summary>
- /// Generate a syslog priority.
- /// </summary>
- /// <param name="facility">The syslog facility.</param>
- /// <param name="severity">The syslog severity.</param>
- /// <returns>A syslog priority.</returns>
- private static int GeneratePriority(SyslogFacility facility, SyslogSeverity severity)
- {
- return ((int)facility * 8) + (int)severity;
- }
+ /// <summary>
+ /// Generate a syslog priority.
+ /// </summary>
+ /// <param name="facility">The syslog facility.</param>
+ /// <param name="severity">The syslog severity.</param>
+ /// <returns>A syslog priority.</returns>
+ private static int GeneratePriority(SyslogFacility facility, SyslogSeverity severity)
+ {
+ return ((int)facility * 8) + (int)severity;
+ }
- #endregion // Public Static Members
+ #endregion // Public Static Members
- #region Private Instances Fields
+ #region Private Instances Fields
- /// <summary>
- /// The facility. The default facility is <see cref="SyslogFacility.User"/>.
- /// </summary>
- private SyslogFacility m_facility = SyslogFacility.User;
+ /// <summary>
+ /// The facility. The default facility is <see cref="SyslogFacility.User"/>.
+ /// </summary>
+ private SyslogFacility m_facility = SyslogFacility.User;
- /// <summary>
- /// The message identity
- /// </summary>
- private string m_identity;
+ /// <summary>
+ /// The message identity
+ /// </summary>
+ private string m_identity;
- /// <summary>
- /// Marshaled handle to the identity string. We have to hold on to the
- /// string as the <c>openlog</c> and <c>syslog</c> APIs just hold the
- /// pointer to the ident and dereference it for each log message.
- /// </summary>
- private IntPtr m_handleToIdentity = IntPtr.Zero;
+ /// <summary>
+ /// Marshaled handle to the identity string. We have to hold on to the
+ /// string as the <c>openlog</c> and <c>syslog</c> APIs just hold the
+ /// pointer to the ident and dereference it for each log message.
+ /// </summary>
+ private IntPtr m_handleToIdentity = IntPtr.Zero;
- /// <summary>
- /// Mapping from level object to syslog severity
- /// </summary>
- private LevelMapping m_levelMapping = new LevelMapping();
+ /// <summary>
+ /// Mapping from level object to syslog severity
+ /// </summary>
+ private LevelMapping m_levelMapping = new LevelMapping();
- #endregion // Private Instances Fields
+ #endregion // Private Instances Fields
- #region External Members
-
- /// <summary>
- /// Open connection to system logger.
- /// </summary>
- [DllImport("libc")]
- private static extern void openlog(IntPtr ident, int option, SyslogFacility facility);
+ #region External Members
+
+ /// <summary>
+ /// Open connection to system logger.
+ /// </summary>
+ [DllImport("libc")]
+ private static extern void openlog(IntPtr ident, int option, SyslogFacility facility);
- /// <summary>
- /// Generate a log message.
- /// </summary>
- /// <remarks>
- /// <para>
- /// The libc syslog method takes a format string and a variable argument list similar
- /// to the classic printf function. As this type of vararg list is not supported
- /// by C# we need to specify the arguments explicitly. Here we have specified the
- /// format string with a single message argument. The caller must set the format
- /// string to <c>"%s"</c>.
- /// </para>
- /// </remarks>
- [DllImport("libc", CharSet=CharSet.Ansi, CallingConvention=CallingConvention.Cdecl)]
- private static extern void syslog(int priority, string format, string message);
+ /// <summary>
+ /// Generate a log message.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// The libc syslog method takes a format string and a variable argument list similar
+ /// to the classic printf function. As this type of vararg list is not supported
+ /// by C# we need to specify the arguments explicitly. Here we have specified the
+ /// format string with a single message argument. The caller must set the format
+ /// string to <c>"%s"</c>.
+ /// </para>
+ /// </remarks>
+ [DllImport("libc", CharSet=CharSet.Ansi, CallingConvention=CallingConvention.Cdecl)]
+ private static extern void syslog(int priority, string format, string message);
- /// <summary>
- /// Close descriptor used to write to system logger.
- /// </summary>
- [DllImport("libc")]
- private static extern void closelog();
+ /// <summary>
+ /// Close descriptor used to write to system logger.
+ /// </summary>
+ [DllImport("libc")]
+ private static extern void closelog();
- #endregion // External Members
+ #endregion // External Members
- #region LevelSeverity LevelMapping Entry
+ #region LevelSeverity LevelMapping Entry
- /// <summary>
- /// A class to act as a mapping between the level that a logging call is made at and
- /// the syslog severity that is should be logged at.
- /// </summary>
- /// <remarks>
- /// <para>
- /// A class to act as a mapping between the level that a logging call is made at and
- /// the syslog severity that is should be logged at.
- /// </para>
- /// </remarks>
- public class LevelSeverity : LevelMappingEntry
- {
- private SyslogSeverity m_severity;
+ /// <summary>
+ /// A class to act as a mapping between the level that a logging call is made at and
+ /// the syslog severity that is should be logged at.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// A class to act as a mapping between the level that a logging call is made at and
+ /// the syslog severity that is should be logged at.
+ /// </para>
+ /// </remarks>
+ public class LevelSeverity : LevelMappingEntry
+ {
+ private SyslogSeverity m_severity;
- /// <summary>
- /// The mapped syslog severity for the specified level
- /// </summary>
- /// <remarks>
- /// <para>
- /// Required property.
- /// The mapped syslog severity for the specified level
- /// </para>
- /// </remarks>
- public SyslogSeverity Severity
- {
- get { return m_severity; }
- set { m_severity = value; }
- }
- }
+ /// <summary>
+ /// The mapped syslog severity for the specified level
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Required property.
+ /// The mapped syslog severity for the specified level
+ /// </para>
+ /// </remarks>
+ public SyslogSeverity Severity
+ {
+ get { return m_severity; }
+ set { m_severity = value; }
+ }
+ }
- #endregion // LevelSeverity LevelMapping Entry
- }
+ #endregion // LevelSeverity LevelMapping Entry
+ }
}
#endif
diff --git a/src/log4net/Appender/ManagedColoredConsoleAppender.cs b/src/log4net/Appender/ManagedColoredConsoleAppender.cs
index 9edfce5..ecc6949 100644
--- a/src/log4net/Appender/ManagedColoredConsoleAppender.cs
+++ b/src/log4net/Appender/ManagedColoredConsoleAppender.cs
@@ -18,7 +18,7 @@
#endregion
// Compatibility:
-// http://msdn.microsoft.com/en-us/library/system.console.foregroundcolor.aspx
+// http://msdn.microsoft.com/en-us/library/system.console.foregroundcolor.aspx
// Disable for unsupported targets
#if !NETCF
#if !SSCLI
@@ -48,294 +48,294 @@
namespace log4net.Appender
{
- /// <summary>
- /// Appends colorful logging events to the console, using the .NET 2
- /// built-in capabilities.
- /// </summary>
- /// <remarks>
- /// <para>
- /// ManagedColoredConsoleAppender appends log events to the standard output stream
- /// or the error output stream using a layout specified by the
- /// user. It also allows the color of a specific type of message to be set.
- /// </para>
- /// <para>
- /// By default, all output is written to the console's standard output stream.
- /// The <see cref="Target"/> property can be set to direct the output to the
- /// error stream.
- /// </para>
- /// <para>
- /// When configuring the colored console appender, mappings should be
- /// specified to map logging levels to colors. For example:
- /// </para>
- /// <code lang="XML" escaped="true">
- /// <mapping>
- /// <level value="ERROR" />
- /// <foreColor value="DarkRed" />
- /// <backColor value="White" />
- /// </mapping>
- /// <mapping>
- /// <level value="WARN" />
- /// <foreColor value="Yellow" />
- /// </mapping>
- /// <mapping>
- /// <level value="INFO" />
- /// <foreColor value="White" />
- /// </mapping>
- /// <mapping>
- /// <level value="DEBUG" />
- /// <foreColor value="Blue" />
- /// </mapping>
- /// </code>
- /// <para>
- /// The Level is the standard log4net logging level while
- /// ForeColor and BackColor are the values of <see cref="System.ConsoleColor"/>
- /// enumeration.
- /// </para>
- /// <para>
- /// Based on the ColoredConsoleAppender
- /// </para>
- /// </remarks>
- /// <author>Rick Hobbs</author>
- /// <author>Nicko Cadell</author>
- /// <author>Pavlos Touboulidis</author>
- public class ManagedColoredConsoleAppender: AppenderSkeleton
- {
- /// <summary>
- /// Initializes a new instance of the <see cref="ManagedColoredConsoleAppender" /> class.
- /// </summary>
- /// <remarks>
- /// The instance of the <see cref="ManagedColoredConsoleAppender" /> class is set up to write
- /// to the standard output stream.
- /// </remarks>
- public ManagedColoredConsoleAppender()
- {
- }
-
- #region Public Instance Properties
- /// <summary>
- /// Target is the value of the console output stream.
- /// This is either <c>"Console.Out"</c> or <c>"Console.Error"</c>.
- /// </summary>
- /// <value>
- /// Target is the value of the console output stream.
- /// This is either <c>"Console.Out"</c> or <c>"Console.Error"</c>.
- /// </value>
- /// <remarks>
- /// <para>
- /// Target is the value of the console output stream.
- /// This is either <c>"Console.Out"</c> or <c>"Console.Error"</c>.
- /// </para>
- /// </remarks>
- public virtual string Target
- {
- get { return m_writeToErrorStream ? ConsoleError : ConsoleOut; }
- set
- {
- string v = value.Trim();
+ /// <summary>
+ /// Appends colorful logging events to the console, using the .NET 2
+ /// built-in capabilities.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// ManagedColoredConsoleAppender appends log events to the standard output stream
+ /// or the error output stream using a layout specified by the
+ /// user. It also allows the color of a specific type of message to be set.
+ /// </para>
+ /// <para>
+ /// By default, all output is written to the console's standard output stream.
+ /// The <see cref="Target"/> property can be set to direct the output to the
+ /// error stream.
+ /// </para>
+ /// <para>
+ /// When configuring the colored console appender, mappings should be
+ /// specified to map logging levels to colors. For example:
+ /// </para>
+ /// <code lang="XML" escaped="true">
+ /// <mapping>
+ /// <level value="ERROR" />
+ /// <foreColor value="DarkRed" />
+ /// <backColor value="White" />
+ /// </mapping>
+ /// <mapping>
+ /// <level value="WARN" />
+ /// <foreColor value="Yellow" />
+ /// </mapping>
+ /// <mapping>
+ /// <level value="INFO" />
+ /// <foreColor value="White" />
+ /// </mapping>
+ /// <mapping>
+ /// <level value="DEBUG" />
+ /// <foreColor value="Blue" />
+ /// </mapping>
+ /// </code>
+ /// <para>
+ /// The Level is the standard log4net logging level while
+ /// ForeColor and BackColor are the values of <see cref="System.ConsoleColor"/>
+ /// enumeration.
+ /// </para>
+ /// <para>
+ /// Based on the ColoredConsoleAppender
+ /// </para>
+ /// </remarks>
+ /// <author>Rick Hobbs</author>
+ /// <author>Nicko Cadell</author>
+ /// <author>Pavlos Touboulidis</author>
+ public class ManagedColoredConsoleAppender: AppenderSkeleton
+ {
+ /// <summary>
+ /// Initializes a new instance of the <see cref="ManagedColoredConsoleAppender" /> class.
+ /// </summary>
+ /// <remarks>
+ /// The instance of the <see cref="ManagedColoredConsoleAppender" /> class is set up to write
+ /// to the standard output stream.
+ /// </remarks>
+ public ManagedColoredConsoleAppender()
+ {
+ }
+
+ #region Public Instance Properties
+ /// <summary>
+ /// Target is the value of the console output stream.
+ /// This is either <c>"Console.Out"</c> or <c>"Console.Error"</c>.
+ /// </summary>
+ /// <value>
+ /// Target is the value of the console output stream.
+ /// This is either <c>"Console.Out"</c> or <c>"Console.Error"</c>.
+ /// </value>
+ /// <remarks>
+ /// <para>
+ /// Target is the value of the console output stream.
+ /// This is either <c>"Console.Out"</c> or <c>"Console.Error"</c>.
+ /// </para>
+ /// </remarks>
+ public virtual string Target
+ {
+ get { return m_writeToErrorStream ? ConsoleError : ConsoleOut; }
+ set
+ {
+ string v = value.Trim();
- if (SystemInfo.EqualsIgnoringCase(ConsoleError, v))
- {
- m_writeToErrorStream = true;
- }
- else
- {
- m_writeToErrorStream = false;
- }
- }
- }
+ if (SystemInfo.EqualsIgnoringCase(ConsoleError, v))
+ {
+ m_writeToErrorStream = true;
+ }
+ else
+ {
+ m_writeToErrorStream = false;
+ }
+ }
+ }
- /// <summary>
- /// Add a mapping of level to color - done by the config file
- /// </summary>
- /// <param name="mapping">The mapping to add</param>
- /// <remarks>
- /// <para>
- /// Add a <see cref="LevelColors"/> mapping to this appender.
- /// Each mapping defines the foreground and background colors
- /// for a level.
- /// </para>
- /// </remarks>
- public void AddMapping(LevelColors mapping)
- {
- m_levelMapping.Add(mapping);
- }
- #endregion // Public Instance Properties
+ /// <summary>
+ /// Add a mapping of level to color - done by the config file
+ /// </summary>
+ /// <param name="mapping">The mapping to add</param>
+ /// <remarks>
+ /// <para>
+ /// Add a <see cref="LevelColors"/> mapping to this appender.
+ /// Each mapping defines the foreground and background colors
+ /// for a level.
+ /// </para>
+ /// </remarks>
+ public void AddMapping(LevelColors mapping)
+ {
+ m_levelMapping.Add(mapping);
+ }
+ #endregion // Public Instance Properties
- #region Override implementation of AppenderSkeleton
- /// <summary>
- /// This method is called by the <see cref="M:AppenderSkeleton.DoAppend(log4net.Core.LoggingEvent)"/> method.
- /// </summary>
- /// <param name="loggingEvent">The event to log.</param>
- /// <remarks>
- /// <para>
- /// Writes the event to the console.
- /// </para>
- /// <para>
- /// The format of the output will depend on the appender's layout.
- /// </para>
- /// </remarks>
- protected override void Append(log4net.Core.LoggingEvent loggingEvent)
- {
- System.IO.TextWriter writer;
-
- if (m_writeToErrorStream)
- writer = Console.Error;
- else
- writer = Console.Out;
-
- // Reset color
- Console.ResetColor();
-
- // see if there is a specified lookup
- LevelColors levelColors = m_levelMapping.Lookup(loggingEvent.Level) as LevelColors;
- if (levelColors != null)
- {
- // if the backColor has been explicitly set
- if (levelColors.HasBackColor)
- Console.BackgroundColor = levelColors.BackColor;
- // if the foreColor has been explicitly set
- if (levelColors.HasForeColor)
- Console.ForegroundColor = levelColors.ForeColor;
- }
-
- // Render the event to a string
- string strLoggingMessage = RenderLoggingEvent(loggingEvent);
- // and write it
- writer.Write(strLoggingMessage);
+ #region Override implementation of AppenderSkeleton
+ /// <summary>
+ /// This method is called by the <see cref="M:AppenderSkeleton.DoAppend(log4net.Core.LoggingEvent)"/> method.
+ /// </summary>
+ /// <param name="loggingEvent">The event to log.</param>
+ /// <remarks>
+ /// <para>
+ /// Writes the event to the console.
+ /// </para>
+ /// <para>
+ /// The format of the output will depend on the appender's layout.
+ /// </para>
+ /// </remarks>
+ protected override void Append(log4net.Core.LoggingEvent loggingEvent)
+ {
+ System.IO.TextWriter writer;
+
+ if (m_writeToErrorStream)
+ writer = Console.Error;
+ else
+ writer = Console.Out;
+
+ // Reset color
+ Console.ResetColor();
+
+ // see if there is a specified lookup
+ LevelColors levelColors = m_levelMapping.Lookup(loggingEvent.Level) as LevelColors;
+ if (levelColors != null)
+ {
+ // if the backColor has been explicitly set
+ if (levelColors.HasBackColor)
+ Console.BackgroundColor = levelColors.BackColor;
+ // if the foreColor has been explicitly set
+ if (levelColors.HasForeColor)
+ Console.ForegroundColor = levelColors.ForeColor;
+ }
+
+ // Render the event to a string
+ string strLoggingMessage = RenderLoggingEvent(loggingEvent);
+ // and write it
+ writer.Write(strLoggingMessage);
- // Reset color again
- Console.ResetColor();
- }
+ // Reset color again
+ Console.ResetColor();
+ }
- /// <summary>
- /// This appender requires a <see cref="Layout"/> to be set.
- /// </summary>
- /// <value><c>true</c></value>
- /// <remarks>
- /// <para>
- /// This appender requires a <see cref="Layout"/> to be set.
- /// </para>
- /// </remarks>
- protected override bool RequiresLayout
- {
- get { return true; }
- }
+ /// <summary>
+ /// This appender requires a <see cref="Layout"/> to be set.
+ /// </summary>
+ /// <value><c>true</c></value>
+ /// <remarks>
+ /// <para>
+ /// This appender requires a <see cref="Layout"/> to be set.
+ /// </para>
+ /// </remarks>
+ protected override bool RequiresLayout
+ {
+ get { return true; }
+ }
- /// <summary>
- /// Initialize the options for this appender
- /// </summary>
- /// <remarks>
- /// <para>
- /// Initialize the level to color mappings set on this appender.
- /// </para>
- /// </remarks>
- public override void ActivateOptions()
- {
- base.ActivateOptions();
- m_levelMapping.ActivateOptions();
- }
- #endregion // Override implementation of AppenderSkeleton
+ /// <summary>
+ /// Initialize the options for this appender
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Initialize the level to color mappings set on this appender.
+ /// </para>
+ /// </remarks>
+ public override void ActivateOptions()
+ {
+ base.ActivateOptions();
+ m_levelMapping.ActivateOptions();
+ }
+ #endregion // Override implementation of AppenderSkeleton
- #region Public Static Fields
- /// <summary>
- /// The <see cref="ManagedColoredConsoleAppender.Target"/> to use when writing to the Console
- /// standard output stream.
- /// </summary>
- /// <remarks>
- /// <para>
- /// The <see cref="ManagedColoredConsoleAppender.Target"/> to use when writing to the Console
- /// standard output stream.
- /// </para>
- /// </remarks>
- public const string ConsoleOut = "Console.Out";
+ #region Public Static Fields
+ /// <summary>
+ /// The <see cref="ManagedColoredConsoleAppender.Target"/> to use when writing to the Console
+ /// standard output stream.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// The <see cref="ManagedColoredConsoleAppender.Target"/> to use when writing to the Console
+ /// standard output stream.
+ /// </para>
+ /// </remarks>
+ public const string ConsoleOut = "Console.Out";
- /// <summary>
- /// The <see cref="ManagedColoredConsoleAppender.Target"/> to use when writing to the Console
- /// standard error output stream.
- /// </summary>
- /// <remarks>
- /// <para>
- /// The <see cref="ManagedColoredConsoleAppender.Target"/> to use when writing to the Console
- /// standard error output stream.
- /// </para>
- /// </remarks>
- public const string ConsoleError = "Console.Error";
- #endregion // Public Static Fields
+ /// <summary>
+ /// The <see cref="ManagedColoredConsoleAppender.Target"/> to use when writing to the Console
+ /// standard error output stream.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// The <see cref="ManagedColoredConsoleAppender.Target"/> to use when writing to the Console
+ /// standard error output stream.
+ /// </para>
+ /// </remarks>
+ public const string ConsoleError = "Console.Error";
+ #endregion // Public Static Fields
- #region Private Instances Fields
- /// <summary>
- /// Flag to write output to the error stream rather than the standard output stream
- /// </summary>
- private bool m_writeToErrorStream = false;
+ #region Private Instances Fields
+ /// <summary>
+ /// Flag to write output to the error stream rather than the standard output stream
+ /// </summary>
+ private bool m_writeToErrorStream = false;
- /// <summary>
- /// Mapping from level object to color value
- /// </summary>
- private LevelMapping m_levelMapping = new LevelMapping();
- #endregion // Private Instances Fields
+ /// <summary>
+ /// Mapping from level object to color value
+ /// </summary>
+ private LevelMapping m_levelMapping = new LevelMapping();
+ #endregion // Private Instances Fields
- #region LevelColors LevelMapping Entry
- /// <summary>
- /// A class to act as a mapping between the level that a logging call is made at and
- /// the color it should be displayed as.
- /// </summary>
- /// <remarks>
- /// <para>
- /// Defines the mapping between a level and the color it should be displayed in.
- /// </para>
- /// </remarks>
- public class LevelColors : LevelMappingEntry
- {
- /// <summary>
- /// The mapped foreground color for the specified level
- /// </summary>
- /// <remarks>
- /// <para>
- /// Required property.
- /// The mapped foreground color for the specified level.
- /// </para>
- /// </remarks>
- public ConsoleColor ForeColor
- {
- get { return (this.foreColor); }
- // Keep a flag that the color has been set
- // and is no longer the default.
- set { this.foreColor = value; this.hasForeColor = true; }
- }
- private ConsoleColor foreColor;
- private bool hasForeColor;
+ #region LevelColors LevelMapping Entry
+ /// <summary>
+ /// A class to act as a mapping between the level that a logging call is made at and
+ /// the color it should be displayed as.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Defines the mapping between a level and the color it should be displayed in.
+ /// </para>
+ /// </remarks>
+ public class LevelColors : LevelMappingEntry
+ {
+ /// <summary>
+ /// The mapped foreground color for the specified level
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Required property.
+ /// The mapped foreground color for the specified level.
+ /// </para>
+ /// </remarks>
+ public ConsoleColor ForeColor
+ {
+ get { return (this.foreColor); }
+ // Keep a flag that the color has been set
+ // and is no longer the default.
+ set { this.foreColor = value; this.hasForeColor = true; }
+ }
+ private ConsoleColor foreColor;
+ private bool hasForeColor;
internal bool HasForeColor {
get {
return hasForeColor;
}
}
- /// <summary>
- /// The mapped background color for the specified level
- /// </summary>
- /// <remarks>
- /// <para>
- /// Required property.
- /// The mapped background color for the specified level.
- /// </para>
- /// </remarks>
- public ConsoleColor BackColor
- {
- get { return (this.backColor); }
- // Keep a flag that the color has been set
- // and is no longer the default.
- set { this.backColor = value; this.hasBackColor = true; }
- }
- private ConsoleColor backColor;
+ /// <summary>
+ /// The mapped background color for the specified level
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Required property.
+ /// The mapped background color for the specified level.
+ /// </para>
+ /// </remarks>
+ public ConsoleColor BackColor
+ {
+ get { return (this.backColor); }
+ // Keep a flag that the color has been set
+ // and is no longer the default.
+ set { this.backColor = value; this.hasBackColor = true; }
+ }
+ private ConsoleColor backColor;
private bool hasBackColor;
internal bool HasBackColor {
get {
return hasBackColor;
}
}
- }
- #endregion // LevelColors LevelMapping Entry
- }
+ }
+ #endregion // LevelColors LevelMapping Entry
+ }
}
#endif
diff --git a/src/log4net/Appender/MemoryAppender.cs b/src/log4net/Appender/MemoryAppender.cs
index 441569c..5c30c2b 100644
--- a/src/log4net/Appender/MemoryAppender.cs
+++ b/src/log4net/Appender/MemoryAppender.cs
@@ -24,165 +24,165 @@
namespace log4net.Appender
{
- /// <summary>
- /// Stores logging events in an array.
- /// </summary>
- /// <remarks>
- /// <para>
- /// The memory appender stores all the logging events
- /// that are appended in an in-memory array.
- /// </para>
- /// <para>
- /// Use the <see cref="M:PopAllEvents()"/> method to get
- /// and clear the current list of events that have been appended.
- /// </para>
- /// <para>
- /// Use the <see cref="M:GetEvents()"/> method to get the current
- /// list of events that have been appended. Note there is a
- /// race-condition when calling <see cref="M:GetEvents()"/> and
- /// <see cref="M:Clear()"/> in pairs, you better use <see
- /// mref="M:PopAllEvents()"/> in that case.
- /// </para>
- /// <para>
- /// Use the <see cref="M:Clear()"/> method to clear the
- /// current list of events. Note there is a
- /// race-condition when calling <see cref="M:GetEvents()"/> and
- /// <see cref="M:Clear()"/> in pairs, you better use <see
- /// mref="M:PopAllEvents()"/> in that case.
- /// </para>
- /// </remarks>
- /// <author>Julian Biddle</author>
- /// <author>Nicko Cadell</author>
- /// <author>Gert Driesen</author>
- public class MemoryAppender : AppenderSkeleton
- {
- #region Public Instance Constructors
+ /// <summary>
+ /// Stores logging events in an array.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// The memory appender stores all the logging events
+ /// that are appended in an in-memory array.
+ /// </para>
+ /// <para>
+ /// Use the <see cref="M:PopAllEvents()"/> method to get
+ /// and clear the current list of events that have been appended.
+ /// </para>
+ /// <para>
+ /// Use the <see cref="M:GetEvents()"/> method to get the current
+ /// list of events that have been appended. Note there is a
+ /// race-condition when calling <see cref="M:GetEvents()"/> and
+ /// <see cref="M:Clear()"/> in pairs, you better use <see
+ /// mref="M:PopAllEvents()"/> in that case.
+ /// </para>
+ /// <para>
+ /// Use the <see cref="M:Clear()"/> method to clear the
+ /// current list of events. Note there is a
+ /// race-condition when calling <see cref="M:GetEvents()"/> and
+ /// <see cref="M:Clear()"/> in pairs, you better use <see
+ /// mref="M:PopAllEvents()"/> in that case.
+ /// </para>
+ /// </remarks>
+ /// <author>Julian Biddle</author>
+ /// <author>Nicko Cadell</author>
+ /// <author>Gert Driesen</author>
+ public class MemoryAppender : AppenderSkeleton
+ {
+ #region Public Instance Constructors
- /// <summary>
- /// Initializes a new instance of the <see cref="MemoryAppender" /> class.
- /// </summary>
- /// <remarks>
- /// <para>
- /// Default constructor.
- /// </para>
- /// </remarks>
- public MemoryAppender() : base()
- {
- m_eventsList = new ArrayList();
- }
+ /// <summary>
+ /// Initializes a new instance of the <see cref="MemoryAppender" /> class.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Default constructor.
+ /// </para>
+ /// </remarks>
+ public MemoryAppender() : base()
+ {
+ m_eventsList = new ArrayList();
+ }
- #endregion Protected Instance Constructors
+ #endregion Protected Instance Constructors
- #region Public Instance Properties
+ #region Public Instance Properties
- /// <summary>
- /// Gets the events that have been logged.
- /// </summary>
- /// <returns>The events that have been logged</returns>
- /// <remarks>
- /// <para>
- /// Gets the events that have been logged.
- /// </para>
- /// </remarks>
- public virtual LoggingEvent[] GetEvents()
- {
+ /// <summary>
+ /// Gets the events that have been logged.
+ /// </summary>
+ /// <returns>The events that have been logged</returns>
+ /// <remarks>
+ /// <para>
+ /// Gets the events that have been logged.
+ /// </para>
+ /// </remarks>
+ public virtual LoggingEvent[] GetEvents()
+ {
lock (m_eventsList.SyncRoot)
{
return (LoggingEvent[]) m_eventsList.ToArray(typeof(LoggingEvent));
}
- }
+ }
- /// <summary>
- /// Gets or sets a value indicating whether only part of the logging event
- /// data should be fixed.
- /// </summary>
- /// <value>
- /// <c>true</c> if the appender should only fix part of the logging event
- /// data, otherwise <c>false</c>. The default is <c>false</c>.
- /// </value>
- /// <remarks>
- /// <para>
- /// Setting this property to <c>true</c> will cause only part of the event
- /// data to be fixed and stored in the appender, hereby improving performance.
- /// </para>
- /// <para>
- /// See <see cref="M:LoggingEvent.FixVolatileData(bool)"/> for more information.
- /// </para>
- /// </remarks>
- [Obsolete("Use Fix property")]
- public virtual bool OnlyFixPartialEventData
- {
- get { return (Fix == FixFlags.Partial); }
- set
- {
- if (value)
- {
- Fix = FixFlags.Partial;
- }
- else
- {
- Fix = FixFlags.All;
- }
- }
- }
+ /// <summary>
+ /// Gets or sets a value indicating whether only part of the logging event
+ /// data should be fixed.
+ /// </summary>
+ /// <value>
+ /// <c>true</c> if the appender should only fix part of the logging event
+ /// data, otherwise <c>false</c>. The default is <c>false</c>.
+ /// </value>
+ /// <remarks>
+ /// <para>
+ /// Setting this property to <c>true</c> will cause only part of the event
+ /// data to be fixed and stored in the appender, hereby improving performance.
+ /// </para>
+ /// <para>
+ /// See <see cref="M:LoggingEvent.FixVolatileData(bool)"/> for more information.
+ /// </para>
+ /// </remarks>
+ [Obsolete("Use Fix property")]
+ public virtual bool OnlyFixPartialEventData
+ {
+ get { return (Fix == FixFlags.Partial); }
+ set
+ {
+ if (value)
+ {
+ Fix = FixFlags.Partial;
+ }
+ else
+ {
+ Fix = FixFlags.All;
+ }
+ }
+ }
- /// <summary>
- /// Gets or sets the fields that will be fixed in the event
- /// </summary>
- /// <remarks>
- /// <para>
- /// The logging event needs to have certain thread specific values
- /// captured before it can be buffered. See <see cref="LoggingEvent.Fix"/>
- /// for details.
- /// </para>
- /// </remarks>
- public virtual FixFlags Fix
- {
- get { return m_fixFlags; }
- set { m_fixFlags = value; }
- }
+ /// <summary>
+ /// Gets or sets the fields that will be fixed in the event
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// The logging event needs to have certain thread specific values
+ /// captured before it can be buffered. See <see cref="LoggingEvent.Fix"/>
+ /// for details.
+ /// </para>
+ /// </remarks>
+ public virtual FixFlags Fix
+ {
+ get { return m_fixFlags; }
+ set { m_fixFlags = value; }
+ }
- #endregion Public Instance Properties
+ #endregion Public Instance Properties
- #region Override implementation of AppenderSkeleton
+ #region Override implementation of AppenderSkeleton
- /// <summary>
- /// This method is called by the <see cref="M:AppenderSkeleton.DoAppend(LoggingEvent)"/> method.
- /// </summary>
- /// <param name="loggingEvent">the event to log</param>
- /// <remarks>
- /// <para>Stores the <paramref name="loggingEvent"/> in the events list.</para>
- /// </remarks>
- protected override void Append(LoggingEvent loggingEvent)
- {
- // Because we are caching the LoggingEvent beyond the
- // lifetime of the Append() method we must fix any
- // volatile data in the event.
- loggingEvent.Fix = this.Fix;
+ /// <summary>
+ /// This method is called by the <see cref="M:AppenderSkeleton.DoAppend(LoggingEvent)"/> method.
+ /// </summary>
+ /// <param name="loggingEvent">the event to log</param>
+ /// <remarks>
+ /// <para>Stores the <paramref name="loggingEvent"/> in the events list.</para>
+ /// </remarks>
+ protected override void Append(LoggingEvent loggingEvent)
+ {
+ // Because we are caching the LoggingEvent beyond the
+ // lifetime of the Append() method we must fix any
+ // volatile data in the event.
+ loggingEvent.Fix = this.Fix;
lock (m_eventsList.SyncRoot)
{
m_eventsList.Add(loggingEvent);
}
- }
+ }
- #endregion Override implementation of AppenderSkeleton
+ #endregion Override implementation of AppenderSkeleton
- #region Public Instance Methods
+ #region Public Instance Methods
- /// <summary>
- /// Clear the list of events
- /// </summary>
- /// <remarks>
- /// Clear the list of events
- /// </remarks>
- public virtual void Clear()
- {
+ /// <summary>
+ /// Clear the list of events
+ /// </summary>
+ /// <remarks>
+ /// Clear the list of events
+ /// </remarks>
+ public virtual void Clear()
+ {
lock (m_eventsList.SyncRoot)
{
m_eventsList.Clear();
}
- }
+ }
/// <summary>
/// Gets the events that have been logged and clears the list of events.
@@ -203,23 +203,23 @@
}
}
- #endregion Public Instance Methods
+ #endregion Public Instance Methods
- #region Protected Instance Fields
+ #region Protected Instance Fields
- /// <summary>
- /// The list of events that have been appended.
- /// </summary>
- protected ArrayList m_eventsList;
+ /// <summary>
+ /// The list of events that have been appended.
+ /// </summary>
+ protected ArrayList m_eventsList;
- /// <summary>
- /// Value indicating which fields in the event should be fixed
- /// </summary>
- /// <remarks>
- /// By default all fields are fixed
- /// </remarks>
- protected FixFlags m_fixFlags = FixFlags.All;
+ /// <summary>
+ /// Value indicating which fields in the event should be fixed
+ /// </summary>
+ /// <remarks>
+ /// By default all fields are fixed
+ /// </remarks>
+ protected FixFlags m_fixFlags = FixFlags.All;
- #endregion Protected Instance Fields
- }
+ #endregion Protected Instance Fields
+ }
}
diff --git a/src/log4net/Appender/NetSendAppender.cs b/src/log4net/Appender/NetSendAppender.cs
index b03d21d..f6fdbb5 100644
--- a/src/log4net/Appender/NetSendAppender.cs
+++ b/src/log4net/Appender/NetSendAppender.cs
@@ -37,386 +37,386 @@
namespace log4net.Appender
{
- /// <summary>
- /// Logs entries by sending network messages using the
- /// <see cref="NetMessageBufferSend" /> native function.
- /// </summary>
- /// <remarks>
- /// <para>
- /// You can send messages only to names that are active
- /// on the network. If you send the message to a user name,
- /// that user must be logged on and running the Messenger
- /// service to receive the message.
- /// </para>
- /// <para>
- /// The receiver will get a top most window displaying the
- /// messages one at a time, therefore this appender should
- /// not be used to deliver a high volume of messages.
- /// </para>
- /// <para>
- /// The following table lists some possible uses for this appender :
- /// </para>
- /// <para>
- /// <list type="table">
- /// <listheader>
- /// <term>Action</term>
- /// <description>Property Value(s)</description>
- /// </listheader>
- /// <item>
- /// <term>Send a message to a user account on the local machine</term>
- /// <description>
- /// <para>
- /// <see cref="NetSendAppender.Server"/> = <name of the local machine>
- /// </para>
- /// <para>
- /// <see cref="NetSendAppender.Recipient"/> = <user name>
- /// </para>
- /// </description>
- /// </item>
- /// <item>
- /// <term>Send a message to a user account on a remote machine</term>
- /// <description>
- /// <para>
- /// <see cref="NetSendAppender.Server"/> = <name of the remote machine>
- /// </para>
- /// <para>
- /// <see cref="NetSendAppender.Recipient"/> = <user name>
- /// </para>
- /// </description>
- /// </item>
- /// <item>
- /// <term>Send a message to a domain user account</term>
- /// <description>
- /// <para>
- /// <see cref="NetSendAppender.Server"/> = <name of a domain controller | uninitialized>
- /// </para>
- /// <para>
- /// <see cref="NetSendAppender.Recipient"/> = <user name>
- /// </para>
- /// </description>
- /// </item>
- /// <item>
- /// <term>Send a message to all the names in a workgroup or domain</term>
- /// <description>
- /// <para>
- /// <see cref="NetSendAppender.Recipient"/> = <workgroup name | domain name>*
- /// </para>
- /// </description>
- /// </item>
- /// <item>
- /// <term>Send a message from the local machine to a remote machine</term>
- /// <description>
- /// <para>
- /// <see cref="NetSendAppender.Server"/> = <name of the local machine | uninitialized>
- /// </para>
- /// <para>
- /// <see cref="NetSendAppender.Recipient"/> = <name of the remote machine>
- /// </para>
- /// </description>
- /// </item>
- /// </list>
- /// </para>
- /// <para>
- /// <b>Note :</b> security restrictions apply for sending
- /// network messages, see <see cref="NetMessageBufferSend" />
- /// for more information.
- /// </para>
- /// </remarks>
- /// <example>
- /// <para>
- /// An example configuration section to log information
- /// using this appender from the local machine, named
- /// LOCAL_PC, to machine OPERATOR_PC :
- /// </para>
- /// <code lang="XML" escaped="true">
- /// <appender name="NetSendAppender_Operator" type="log4net.Appender.NetSendAppender">
- /// <server value="LOCAL_PC" />
- /// <recipient value="OPERATOR_PC" />
- /// <layout type="log4net.Layout.PatternLayout" value="%-5p %c [%x] - %m%n" />
- /// </appender>
- /// </code>
- /// </example>
- /// <author>Nicko Cadell</author>
- /// <author>Gert Driesen</author>
- public class NetSendAppender : AppenderSkeleton
- {
- #region Member Variables
+ /// <summary>
+ /// Logs entries by sending network messages using the
+ /// <see cref="NetMessageBufferSend" /> native function.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// You can send messages only to names that are active
+ /// on the network. If you send the message to a user name,
+ /// that user must be logged on and running the Messenger
+ /// service to receive the message.
+ /// </para>
+ /// <para>
+ /// The receiver will get a top most window displaying the
+ /// messages one at a time, therefore this appender should
+ /// not be used to deliver a high volume of messages.
+ /// </para>
+ /// <para>
+ /// The following table lists some possible uses for this appender :
+ /// </para>
+ /// <para>
+ /// <list type="table">
+ /// <listheader>
+ /// <term>Action</term>
+ /// <description>Property Value(s)</description>
+ /// </listheader>
+ /// <item>
+ /// <term>Send a message to a user account on the local machine</term>
+ /// <description>
+ /// <para>
+ /// <see cref="NetSendAppender.Server"/> = <name of the local machine>
+ /// </para>
+ /// <para>
+ /// <see cref="NetSendAppender.Recipient"/> = <user name>
+ /// </para>
+ /// </description>
+ /// </item>
+ /// <item>
+ /// <term>Send a message to a user account on a remote machine</term>
+ /// <description>
+ /// <para>
+ /// <see cref="NetSendAppender.Server"/> = <name of the remote machine>
+ /// </para>
+ /// <para>
+ /// <see cref="NetSendAppender.Recipient"/> = <user name>
+ /// </para>
+ /// </description>
+ /// </item>
+ /// <item>
+ /// <term>Send a message to a domain user account</term>
+ /// <description>
+ /// <para>
+ /// <see cref="NetSendAppender.Server"/> = <name of a domain controller | uninitialized>
+ /// </para>
+ /// <para>
+ /// <see cref="NetSendAppender.Recipient"/> = <user name>
+ /// </para>
+ /// </description>
+ /// </item>
+ /// <item>
+ /// <term>Send a message to all the names in a workgroup or domain</term>
+ /// <description>
+ /// <para>
+ /// <see cref="NetSendAppender.Recipient"/> = <workgroup name | domain name>*
+ /// </para>
+ /// </description>
+ /// </item>
+ /// <item>
+ /// <term>Send a message from the local machine to a remote machine</term>
+ /// <description>
+ /// <para>
+ /// <see cref="NetSendAppender.Server"/> = <name of the local machine | uninitialized>
+ /// </para>
+ /// <para>
+ /// <see cref="NetSendAppender.Recipient"/> = <name of the remote machine>
+ /// </para>
+ /// </description>
+ /// </item>
+ /// </list>
+ /// </para>
+ /// <para>
+ /// <b>Note :</b> security restrictions apply for sending
+ /// network messages, see <see cref="NetMessageBufferSend" />
+ /// for more information.
+ /// </para>
+ /// </remarks>
+ /// <example>
+ /// <para>
+ /// An example configuration section to log information
+ /// using this appender from the local machine, named
+ /// LOCAL_PC, to machine OPERATOR_PC :
+ /// </para>
+ /// <code lang="XML" escaped="true">
+ /// <appender name="NetSendAppender_Operator" type="log4net.Appender.NetSendAppender">
+ /// <server value="LOCAL_PC" />
+ /// <recipient value="OPERATOR_PC" />
+ /// <layout type="log4net.Layout.PatternLayout" value="%-5p %c [%x] - %m%n" />
+ /// </appender>
+ /// </code>
+ /// </example>
+ /// <author>Nicko Cadell</author>
+ /// <author>Gert Driesen</author>
+ public class NetSendAppender : AppenderSkeleton
+ {
+ #region Member Variables
- /// <summary>
- /// The DNS or NetBIOS name of the server on which the function is to execute.
- /// </summary>
- private string m_server;
+ /// <summary>
+ /// The DNS or NetBIOS name of the server on which the function is to execute.
+ /// </summary>
+ private string m_server;
- /// <summary>
- /// The sender of the network message.
- /// </summary>
- private string m_sender;
+ /// <summary>
+ /// The sender of the network message.
+ /// </summary>
+ private string m_sender;
- /// <summary>
- /// The message alias to which the message should be sent.
- /// </summary>
- private string m_recipient;
+ /// <summary>
+ /// The message alias to which the message should be sent.
+ /// </summary>
+ private string m_recipient;
- /// <summary>
- /// The security context to use for privileged calls
- /// </summary>
- private SecurityContext m_securityContext;
+ /// <summary>
+ /// The security context to use for privileged calls
+ /// </summary>
+ private SecurityContext m_securityContext;
- #endregion
+ #endregion
- #region Constructors
+ #region Constructors
- /// <summary>
- /// Initializes the appender.
- /// </summary>
- /// <remarks>
- /// The default constructor initializes all fields to their default values.
- /// </remarks>
- public NetSendAppender()
- {
- }
+ /// <summary>
+ /// Initializes the appender.
+ /// </summary>
+ /// <remarks>
+ /// The default constructor initializes all fields to their default values.
+ /// </remarks>
+ public NetSendAppender()
+ {
+ }
- #endregion
+ #endregion
- #region Properties
+ #region Properties
- /// <summary>
- /// Gets or sets the sender of the message.
- /// </summary>
- /// <value>
- /// The sender of the message.
- /// </value>
- /// <remarks>
- /// If this property is not specified, the message is sent from the local computer.
- /// </remarks>
- public string Sender
- {
- get { return m_sender; }
- set { m_sender = value; }
- }
+ /// <summary>
+ /// Gets or sets the sender of the message.
+ /// </summary>
+ /// <value>
+ /// The sender of the message.
+ /// </value>
+ /// <remarks>
+ /// If this property is not specified, the message is sent from the local computer.
+ /// </remarks>
+ public string Sender
+ {
+ get { return m_sender; }
+ set { m_sender = value; }
+ }
- /// <summary>
- /// Gets or sets the message alias to which the message should be sent.
- /// </summary>
- /// <value>
- /// The recipient of the message.
- /// </value>
- /// <remarks>
- /// This property should always be specified in order to send a message.
- /// </remarks>
- public string Recipient
- {
- get { return m_recipient; }
- set { m_recipient = value; }
- }
-
- /// <summary>
- /// Gets or sets the DNS or NetBIOS name of the remote server on which the function is to execute.
- /// </summary>
- /// <value>
- /// DNS or NetBIOS name of the remote server on which the function is to execute.
- /// </value>
- /// <remarks>
- /// <para>
- /// For Windows NT 4.0 and earlier, the string should begin with \\.
- /// </para>
- /// <para>
- /// If this property is not specified, the local computer is used.
- /// </para>
- /// </remarks>
- public string Server
- {
- get { return m_server; }
- set { m_server = value; }
- }
+ /// <summary>
+ /// Gets or sets the message alias to which the message should be sent.
+ /// </summary>
+ /// <value>
+ /// The recipient of the message.
+ /// </value>
+ /// <remarks>
+ /// This property should always be specified in order to send a message.
+ /// </remarks>
+ public string Recipient
+ {
+ get { return m_recipient; }
+ set { m_recipient = value; }
+ }
+
+ /// <summary>
+ /// Gets or sets the DNS or NetBIOS name of the remote server on which the function is to execute.
+ /// </summary>
+ /// <value>
+ /// DNS or NetBIOS name of the remote server on which the function is to execute.
+ /// </value>
+ /// <remarks>
+ /// <para>
+ /// For Windows NT 4.0 and earlier, the string should begin with \\.
+ /// </para>
+ /// <para>
+ /// If this property is not specified, the local computer is used.
+ /// </para>
+ /// </remarks>
+ public string Server
+ {
+ get { return m_server; }
+ set { m_server = value; }
+ }
- /// <summary>
- /// Gets or sets the <see cref="SecurityContext"/> used to call the NetSend method.
- /// </summary>
- /// <value>
- /// The <see cref="SecurityContext"/> used to call the NetSend method.
- /// </value>
- /// <remarks>
- /// <para>
- /// Unless a <see cref="SecurityContext"/> specified here for this appender
- /// the <see cref="SecurityContextProvider.DefaultProvider"/> is queried for the
- /// security context to use. The default behavior is to use the security context
- /// of the current thread.
- /// </para>
- /// </remarks>
- public SecurityContext SecurityContext
- {
- get { return m_securityContext; }
- set { m_securityContext = value; }
- }
+ /// <summary>
+ /// Gets or sets the <see cref="SecurityContext"/> used to call the NetSend method.
+ /// </summary>
+ /// <value>
+ /// The <see cref="SecurityContext"/> used to call the NetSend method.
+ /// </value>
+ /// <remarks>
+ /// <para>
+ /// Unless a <see cref="SecurityContext"/> specified here for this appender
+ /// the <see cref="SecurityContextProvider.DefaultProvider"/> is queried for the
+ /// security context to use. The default behavior is to use the security context
+ /// of the current thread.
+ /// </para>
+ /// </remarks>
+ public SecurityContext SecurityContext
+ {
+ get { return m_securityContext; }
+ set { m_securityContext = value; }
+ }
- #endregion
+ #endregion
- #region Implementation of IOptionHandler
+ #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>
- /// <para>
- /// The appender will be ignored if no <see cref="Recipient" /> was specified.
- /// </para>
- /// </remarks>
- /// <exception cref="ArgumentNullException">The required property <see cref="Recipient" /> was not specified.</exception>
- public override void ActivateOptions()
- {
- base.ActivateOptions();
-
- if (this.Recipient == null)
- {
- throw new ArgumentNullException("Recipient", "The required property 'Recipient' was not specified.");
- }
+ /// <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>
+ /// <para>
+ /// The appender will be ignored if no <see cref="Recipient" /> was specified.
+ /// </para>
+ /// </remarks>
+ /// <exception cref="ArgumentNullException">The required property <see cref="Recipient" /> was not specified.</exception>
+ public override void ActivateOptions()
+ {
+ base.ActivateOptions();
+
+ if (this.Recipient == null)
+ {
+ throw new ArgumentNullException("Recipient", "The required property 'Recipient' was not specified.");
+ }
- if (m_securityContext == null)
- {
- m_securityContext = SecurityContextProvider.DefaultProvider.CreateSecurityContext(this);
- }
- }
+ if (m_securityContext == null)
+ {
+ m_securityContext = SecurityContextProvider.DefaultProvider.CreateSecurityContext(this);
+ }
+ }
- #endregion
+ #endregion
- #region Override implementation of AppenderSkeleton
+ #region Override implementation of AppenderSkeleton
- /// <summary>
- /// This method is called by the <see cref="M:AppenderSkeleton.DoAppend(LoggingEvent)"/> method.
- /// </summary>
- /// <param name="loggingEvent">The event to log.</param>
- /// <remarks>
- /// <para>
- /// Sends the event using a network message.
- /// </para>
- /// </remarks>
+ /// <summary>
+ /// This method is called by the <see cref="M:AppenderSkeleton.DoAppend(LoggingEvent)"/> method.
+ /// </summary>
+ /// <param name="loggingEvent">The event to log.</param>
+ /// <remarks>
+ /// <para>
+ /// Sends the event using a network message.
+ /// </para>
+ /// </remarks>
#if NET_4_0 || MONO_4_0 || NETSTANDARD
- [System.Security.SecuritySafeCritical]
+ [System.Security.SecuritySafeCritical]
#endif
#if !NETSTANDARD1_3
- [System.Security.Permissions.SecurityPermission(System.Security.Permissions.SecurityAction.Demand, UnmanagedCode = true)]
+ [System.Security.Permissions.SecurityPermission(System.Security.Permissions.SecurityAction.Demand, UnmanagedCode = true)]
#endif
- protected override void Append(LoggingEvent loggingEvent)
- {
- NativeError nativeError = null;
+ protected override void Append(LoggingEvent loggingEvent)
+ {
+ NativeError nativeError = null;
- // Render the event in the callers security context
- string renderedLoggingEvent = RenderLoggingEvent(loggingEvent);
+ // Render the event in the callers security context
+ string renderedLoggingEvent = RenderLoggingEvent(loggingEvent);
- using(m_securityContext.Impersonate(this))
- {
- // Send the message
- int returnValue = NetMessageBufferSend(this.Server, this.Recipient, this.Sender, renderedLoggingEvent, renderedLoggingEvent.Length * Marshal.SystemDefaultCharSize);
+ using(m_securityContext.Impersonate(this))
+ {
+ // Send the message
+ int returnValue = NetMessageBufferSend(this.Server, this.Recipient, this.Sender, renderedLoggingEvent, renderedLoggingEvent.Length * Marshal.SystemDefaultCharSize);
- // Log the error if the message could not be sent
- if (returnValue != 0)
- {
- // Lookup the native error
- nativeError = NativeError.GetError(returnValue);
- }
- }
+ // Log the error if the message could not be sent
+ if (returnValue != 0)
+ {
+ // Lookup the native error
+ nativeError = NativeError.GetError(returnValue);
+ }
+ }
- if (nativeError != null)
- {
- // Handle the error over to the ErrorHandler
- ErrorHandler.Error(nativeError.ToString() + " (Params: Server=" + this.Server + ", Recipient=" + this.Recipient + ", Sender=" + this.Sender + ")");
- }
- }
+ if (nativeError != null)
+ {
+ // Handle the error over to the ErrorHandler
+ ErrorHandler.Error(nativeError.ToString() + " (Params: Server=" + this.Server + ", Recipient=" + this.Recipient + ", Sender=" + this.Sender + ")");
+ }
+ }
- /// <summary>
- /// This appender requires a <see cref="Layout"/> to be set.
- /// </summary>
- /// <value><c>true</c></value>
- /// <remarks>
- /// <para>
- /// This appender requires a <see cref="Layout"/> to be set.
- /// </para>
- /// </remarks>
- protected override bool RequiresLayout
- {
- get { return true; }
- }
+ /// <summary>
+ /// This appender requires a <see cref="Layout"/> to be set.
+ /// </summary>
+ /// <value><c>true</c></value>
+ /// <remarks>
+ /// <para>
+ /// This appender requires a <see cref="Layout"/> to be set.
+ /// </para>
+ /// </remarks>
+ protected override bool RequiresLayout
+ {
+ get { return true; }
+ }
- #endregion
+ #endregion
- #region Stubs For Native Function Calls
+ #region Stubs For Native Function Calls
- /// <summary>
- /// Sends a buffer of information to a registered message alias.
- /// </summary>
- /// <param name="serverName">The DNS or NetBIOS name of the server on which the function is to execute.</param>
- /// <param name="msgName">The message alias to which the message buffer should be sent</param>
- /// <param name="fromName">The originator of the message.</param>
- /// <param name="buffer">The message text.</param>
- /// <param name="bufferSize">The length, in bytes, of the message text.</param>
- /// <remarks>
- /// <para>
- /// The following restrictions apply for sending network messages:
- /// </para>
- /// <para>
- /// <list type="table">
- /// <listheader>
- /// <term>Platform</term>
- /// <description>Requirements</description>
- /// </listheader>
- /// <item>
- /// <term>Windows NT</term>
- /// <description>
- /// <para>
- /// No special group membership is required to send a network message.
- /// </para>
- /// <para>
- /// Admin, Accounts, Print, or Server Operator group membership is required to
- /// successfully send a network message on a remote server.
- /// </para>
- /// </description>
- /// </item>
- /// <item>
- /// <term>Windows 2000 or later</term>
- /// <description>
- /// <para>
- /// If you send a message on a domain controller that is running Active Directory,
- /// access is allowed or denied based on the access control list (ACL) for the securable
- /// object. The default ACL permits only Domain Admins and Account Operators to send a network message.
- /// </para>
- /// <para>
- /// On a member server or workstation, only Administrators and Server Operators can send a network message.
- /// </para>
- /// </description>
- /// </item>
- /// </list>
- /// </para>
- /// <para>
- /// For more information see <a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/netmgmt/netmgmt/security_requirements_for_the_network_management_functions.asp">Security Requirements for the Network Management Functions</a>.
- /// </para>
- /// </remarks>
- /// <returns>
- /// <para>
- /// If the function succeeds, the return value is zero.
- /// </para>
- /// </returns>
- [DllImport("netapi32.dll", SetLastError=true)]
- protected static extern int NetMessageBufferSend(
- [MarshalAs(UnmanagedType.LPWStr)] string serverName,
- [MarshalAs(UnmanagedType.LPWStr)] string msgName,
- [MarshalAs(UnmanagedType.LPWStr)] string fromName,
- [MarshalAs(UnmanagedType.LPWStr)] string buffer,
- int bufferSize);
+ /// <summary>
+ /// Sends a buffer of information to a registered message alias.
+ /// </summary>
+ /// <param name="serverName">The DNS or NetBIOS name of the server on which the function is to execute.</param>
+ /// <param name="msgName">The message alias to which the message buffer should be sent</param>
+ /// <param name="fromName">The originator of the message.</param>
+ /// <param name="buffer">The message text.</param>
+ /// <param name="bufferSize">The length, in bytes, of the message text.</param>
+ /// <remarks>
+ /// <para>
+ /// The following restrictions apply for sending network messages:
+ /// </para>
+ /// <para>
+ /// <list type="table">
+ /// <listheader>
+ /// <term>Platform</term>
+ /// <description>Requirements</description>
+ /// </listheader>
+ /// <item>
+ /// <term>Windows NT</term>
+ /// <description>
+ /// <para>
+ /// No special group membership is required to send a network message.
+ /// </para>
+ /// <para>
+ /// Admin, Accounts, Print, or Server Operator group membership is required to
+ /// successfully send a network message on a remote server.
+ /// </para>
+ /// </description>
+ /// </item>
+ /// <item>
+ /// <term>Windows 2000 or later</term>
+ /// <description>
+ /// <para>
+ /// If you send a message on a domain controller that is running Active Directory,
+ /// access is allowed or denied based on the access control list (ACL) for the securable
+ /// object. The default ACL permits only Domain Admins and Account Operators to send a network message.
+ /// </para>
+ /// <para>
+ /// On a member server or workstation, only Administrators and Server Operators can send a network message.
+ /// </para>
+ /// </description>
+ /// </item>
+ /// </list>
+ /// </para>
+ /// <para>
+ /// For more information see <a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/netmgmt/netmgmt/security_requirements_for_the_network_management_functions.asp">Security Requirements for the Network Management Functions</a>.
+ /// </para>
+ /// </remarks>
+ /// <returns>
+ /// <para>
+ /// If the function succeeds, the return value is zero.
+ /// </para>
+ /// </returns>
+ [DllImport("netapi32.dll", SetLastError=true)]
+ protected static extern int NetMessageBufferSend(
+ [MarshalAs(UnmanagedType.LPWStr)] string serverName,
+ [MarshalAs(UnmanagedType.LPWStr)] string msgName,
+ [MarshalAs(UnmanagedType.LPWStr)] string fromName,
+ [MarshalAs(UnmanagedType.LPWStr)] string buffer,
+ int bufferSize);
- #endregion
- }
+ #endregion
+ }
}
#endif // !CLI_1_0
diff --git a/src/log4net/Appender/OutputDebugStringAppender.cs b/src/log4net/Appender/OutputDebugStringAppender.cs
index 1a13512..7a074f0 100644
--- a/src/log4net/Appender/OutputDebugStringAppender.cs
+++ b/src/log4net/Appender/OutputDebugStringAppender.cs
@@ -30,104 +30,104 @@
namespace log4net.Appender
{
- /// <summary>
- /// Appends log events to the OutputDebugString system.
- /// </summary>
- /// <remarks>
- /// <para>
- /// OutputDebugStringAppender appends log events to the
- /// OutputDebugString system.
- /// </para>
- /// <para>
- /// The string is passed to the native <c>OutputDebugString</c>
- /// function.
- /// </para>
- /// </remarks>
- /// <author>Nicko Cadell</author>
- /// <author>Gert Driesen</author>
- public class OutputDebugStringAppender : AppenderSkeleton
- {
- #region Public Instance Constructors
+ /// <summary>
+ /// Appends log events to the OutputDebugString system.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// OutputDebugStringAppender appends log events to the
+ /// OutputDebugString system.
+ /// </para>
+ /// <para>
+ /// The string is passed to the native <c>OutputDebugString</c>
+ /// function.
+ /// </para>
+ /// </remarks>
+ /// <author>Nicko Cadell</author>
+ /// <author>Gert Driesen</author>
+ public class OutputDebugStringAppender : AppenderSkeleton
+ {
+ #region Public Instance Constructors
- /// <summary>
- /// Initializes a new instance of the <see cref="OutputDebugStringAppender" /> class.
- /// </summary>
- /// <remarks>
- /// <para>
- /// Default constructor.
- /// </para>
- /// </remarks>
- public OutputDebugStringAppender()
- {
- }
+ /// <summary>
+ /// Initializes a new instance of the <see cref="OutputDebugStringAppender" /> class.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Default constructor.
+ /// </para>
+ /// </remarks>
+ public OutputDebugStringAppender()
+ {
+ }
- #endregion // Public Instance Constructors
+ #endregion // Public Instance Constructors
- #region Override implementation of AppenderSkeleton
+ #region Override implementation of AppenderSkeleton
- /// <summary>
- /// Write the logging event to the output debug string API
- /// </summary>
- /// <param name="loggingEvent">the event to log</param>
- /// <remarks>
- /// <para>
- /// Write the logging event to the output debug string API
- /// </para>
- /// </remarks>
+ /// <summary>
+ /// Write the logging event to the output debug string API
+ /// </summary>
+ /// <param name="loggingEvent">the event to log</param>
+ /// <remarks>
+ /// <para>
+ /// Write the logging event to the output debug string API
+ /// </para>
+ /// </remarks>
#if NET_4_0 || MONO_4_0 || NETSTANDARD
- [System.Security.SecuritySafeCritical]
+ [System.Security.SecuritySafeCritical]
#endif
#if !NETCF && !NETSTANDARD1_3
- [System.Security.Permissions.SecurityPermission(System.Security.Permissions.SecurityAction.Demand, UnmanagedCode = true)]
+ [System.Security.Permissions.SecurityPermission(System.Security.Permissions.SecurityAction.Demand, UnmanagedCode = true)]
#endif
- protected override void Append(LoggingEvent loggingEvent)
- {
+ protected override void Append(LoggingEvent loggingEvent)
+ {
#if NETSTANDARD
- if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
- {
- throw new System.PlatformNotSupportedException("OutputDebugString is only available on Windows");
- }
+ if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
+ {
+ throw new System.PlatformNotSupportedException("OutputDebugString is only available on Windows");
+ }
#endif
- OutputDebugString(RenderLoggingEvent(loggingEvent));
- }
+ OutputDebugString(RenderLoggingEvent(loggingEvent));
+ }
- /// <summary>
- /// This appender requires a <see cref="Layout"/> to be set.
- /// </summary>
- /// <value><c>true</c></value>
- /// <remarks>
- /// <para>
- /// This appender requires a <see cref="Layout"/> to be set.
- /// </para>
- /// </remarks>
- protected override bool RequiresLayout
- {
- get { return true; }
- }
+ /// <summary>
+ /// This appender requires a <see cref="Layout"/> to be set.
+ /// </summary>
+ /// <value><c>true</c></value>
+ /// <remarks>
+ /// <para>
+ /// This appender requires a <see cref="Layout"/> to be set.
+ /// </para>
+ /// </remarks>
+ protected override bool RequiresLayout
+ {
+ get { return true; }
+ }
- #endregion // Override implementation of AppenderSkeleton
+ #endregion // Override implementation of AppenderSkeleton
- #region Protected Static Methods
+ #region Protected Static Methods
- /// <summary>
- /// Stub for OutputDebugString native method
- /// </summary>
- /// <param name="message">the string to output</param>
- /// <remarks>
- /// <para>
- /// Stub for OutputDebugString native method
- /// </para>
- /// </remarks>
+ /// <summary>
+ /// Stub for OutputDebugString native method
+ /// </summary>
+ /// <param name="message">the string to output</param>
+ /// <remarks>
+ /// <para>
+ /// Stub for OutputDebugString native method
+ /// </para>
+ /// </remarks>
#if NETCF || NETSTANDARD
- [DllImport("CoreDll.dll")]
+ [DllImport("CoreDll.dll")]
#else
- [DllImport("Kernel32.dll")]
+ [DllImport("Kernel32.dll")]
#endif
- protected static extern void OutputDebugString(string message);
+ protected static extern void OutputDebugString(string message);
- #endregion // Protected Static Methods
- }
+ #endregion // Protected Static Methods
+ }
}
#endif // !CLI_1_0
diff --git a/src/log4net/Appender/RemoteSyslogAppender.cs b/src/log4net/Appender/RemoteSyslogAppender.cs
index b67abd3..83e8de0 100644
--- a/src/log4net/Appender/RemoteSyslogAppender.cs
+++ b/src/log4net/Appender/RemoteSyslogAppender.cs
@@ -27,580 +27,580 @@
namespace log4net.Appender
{
- /// <summary>
- /// Logs events to a remote syslog daemon.
- /// </summary>
- /// <remarks>
- /// <para>
- /// The BSD syslog protocol is used to remotely log to
- /// a syslog daemon. The syslogd listens for for messages
- /// on UDP port 514.
- /// </para>
- /// <para>
- /// The syslog UDP protocol is not authenticated. Most syslog daemons
- /// do not accept remote log messages because of the security implications.
- /// You may be able to use the LocalSyslogAppender to talk to a local
- /// syslog service.
- /// </para>
- /// <para>
- /// There is an RFC 3164 that claims to document the BSD Syslog Protocol.
- /// This RFC can be seen here: http://www.faqs.org/rfcs/rfc3164.html.
- /// This appender generates what the RFC calls an "Original Device Message",
- /// i.e. does not include the TIMESTAMP or HOSTNAME fields. By observation
- /// this format of message will be accepted by all current syslog daemon
- /// implementations. The daemon will attach the current time and the source
- /// hostname or IP address to any messages received.
- /// </para>
- /// <para>
- /// Syslog messages must have a facility and and a severity. The severity
- /// is derived from the Level of the logging event.
- /// The facility must be chosen from the set of defined syslog
- /// <see cref="SyslogFacility"/> values. The facilities list is predefined
- /// and cannot be extended.
- /// </para>
- /// <para>
- /// An identifier is specified with each log message. This can be specified
- /// by setting the <see cref="Identity"/> property. The identity (also know
- /// as the tag) must not contain white space. The default value for the
- /// identity is the application name (from <see cref="LoggingEvent.Domain"/>).
- /// </para>
- /// </remarks>
- /// <author>Rob Lyon</author>
- /// <author>Nicko Cadell</author>
- public class RemoteSyslogAppender : UdpAppender
- {
- /// <summary>
- /// Syslog port 514
- /// </summary>
- private const int DefaultSyslogPort = 514;
+ /// <summary>
+ /// Logs events to a remote syslog daemon.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// The BSD syslog protocol is used to remotely log to
+ /// a syslog daemon. The syslogd listens for for messages
+ /// on UDP port 514.
+ /// </para>
+ /// <para>
+ /// The syslog UDP protocol is not authenticated. Most syslog daemons
+ /// do not accept remote log messages because of the security implications.
+ /// You may be able to use the LocalSyslogAppender to talk to a local
+ /// syslog service.
+ /// </para>
+ /// <para>
+ /// There is an RFC 3164 that claims to document the BSD Syslog Protocol.
+ /// This RFC can be seen here: http://www.faqs.org/rfcs/rfc3164.html.
+ /// This appender generates what the RFC calls an "Original Device Message",
+ /// i.e. does not include the TIMESTAMP or HOSTNAME fields. By observation
+ /// this format of message will be accepted by all current syslog daemon
+ /// implementations. The daemon will attach the current time and the source
+ /// hostname or IP address to any messages received.
+ /// </para>
+ /// <para>
+ /// Syslog messages must have a facility and and a severity. The severity
+ /// is derived from the Level of the logging event.
+ /// The facility must be chosen from the set of defined syslog
+ /// <see cref="SyslogFacility"/> values. The facilities list is predefined
+ /// and cannot be extended.
+ /// </para>
+ /// <para>
+ /// An identifier is specified with each log message. This can be specified
+ /// by setting the <see cref="Identity"/> property. The identity (also know
+ /// as the tag) must not contain white space. The default value for the
+ /// identity is the application name (from <see cref="LoggingEvent.Domain"/>).
+ /// </para>
+ /// </remarks>
+ /// <author>Rob Lyon</author>
+ /// <author>Nicko Cadell</author>
+ public class RemoteSyslogAppender : UdpAppender
+ {
+ /// <summary>
+ /// Syslog port 514
+ /// </summary>
+ private const int DefaultSyslogPort = 514;
- #region Enumerations
+ #region Enumerations
- /// <summary>
- /// syslog severities
- /// </summary>
- /// <remarks>
- /// <para>
- /// The syslog severities.
- /// </para>
- /// </remarks>
- public enum SyslogSeverity
- {
- /// <summary>
- /// system is unusable
- /// </summary>
- Emergency = 0,
+ /// <summary>
+ /// syslog severities
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// The syslog severities.
+ /// </para>
+ /// </remarks>
+ public enum SyslogSeverity
+ {
+ /// <summary>
+ /// system is unusable
+ /// </summary>
+ Emergency = 0,
- /// <summary>
- /// action must be taken immediately
- /// </summary>
- Alert = 1,
+ /// <summary>
+ /// action must be taken immediately
+ /// </summary>
+ Alert = 1,
- /// <summary>
- /// critical conditions
- /// </summary>
- Critical = 2,
+ /// <summary>
+ /// critical conditions
+ /// </summary>
+ Critical = 2,
- /// <summary>
- /// error conditions
- /// </summary>
- Error = 3,
+ /// <summary>
+ /// error conditions
+ /// </summary>
+ Error = 3,
- /// <summary>
- /// warning conditions
- /// </summary>
- Warning = 4,
+ /// <summary>
+ /// warning conditions
+ /// </summary>
+ Warning = 4,
- /// <summary>
- /// normal but significant condition
- /// </summary>
- Notice = 5,
+ /// <summary>
+ /// normal but significant condition
+ /// </summary>
+ Notice = 5,
- /// <summary>
- /// informational
- /// </summary>
- Informational = 6,
+ /// <summary>
+ /// informational
+ /// </summary>
+ Informational = 6,
- /// <summary>
- /// debug-level messages
- /// </summary>
- Debug = 7
- };
+ /// <summary>
+ /// debug-level messages
+ /// </summary>
+ Debug = 7
+ };
- /// <summary>
- /// syslog facilities
- /// </summary>
- /// <remarks>
- /// <para>
- /// The syslog facilities
- /// </para>
- /// </remarks>
- public enum SyslogFacility
- {
- /// <summary>
- /// kernel messages
- /// </summary>
- Kernel = 0,
+ /// <summary>
+ /// syslog facilities
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// The syslog facilities
+ /// </para>
+ /// </remarks>
+ public enum SyslogFacility
+ {
+ /// <summary>
+ /// kernel messages
+ /// </summary>
+ Kernel = 0,
- /// <summary>
- /// random user-level messages
- /// </summary>
- User = 1,
+ /// <summary>
+ /// random user-level messages
+ /// </summary>
+ User = 1,
- /// <summary>
- /// mail system
- /// </summary>
- Mail = 2,
+ /// <summary>
+ /// mail system
+ /// </summary>
+ Mail = 2,
- /// <summary>
- /// system daemons
- /// </summary>
- Daemons = 3,
+ /// <summary>
+ /// system daemons
+ /// </summary>
+ Daemons = 3,
- /// <summary>
- /// security/authorization messages
- /// </summary>
- Authorization = 4,
+ /// <summary>
+ /// security/authorization messages
+ /// </summary>
+ Authorization = 4,
- /// <summary>
- /// messages generated internally by syslogd
- /// </summary>
- Syslog = 5,
+ /// <summary>
+ /// messages generated internally by syslogd
+ /// </summary>
+ Syslog = 5,
- /// <summary>
- /// line printer subsystem
- /// </summary>
- Printer = 6,
+ /// <summary>
+ /// line printer subsystem
+ /// </summary>
+ Printer = 6,
- /// <summary>
- /// network news subsystem
- /// </summary>
- News = 7,
+ /// <summary>
+ /// network news subsystem
+ /// </summary>
+ News = 7,
- /// <summary>
- /// UUCP subsystem
- /// </summary>
- Uucp = 8,
+ /// <summary>
+ /// UUCP subsystem
+ /// </summary>
+ Uucp = 8,
- /// <summary>
- /// clock (cron/at) daemon
- /// </summary>
- Clock = 9,
+ /// <summary>
+ /// clock (cron/at) daemon
+ /// </summary>
+ Clock = 9,
- /// <summary>
- /// security/authorization messages (private)
- /// </summary>
- Authorization2 = 10,
+ /// <summary>
+ /// security/authorization messages (private)
+ /// </summary>
+ Authorization2 = 10,
- /// <summary>
- /// ftp daemon
- /// </summary>
- Ftp = 11,
+ /// <summary>
+ /// ftp daemon
+ /// </summary>
+ Ftp = 11,
- /// <summary>
- /// NTP subsystem
- /// </summary>
- Ntp = 12,
+ /// <summary>
+ /// NTP subsystem
+ /// </summary>
+ Ntp = 12,
- /// <summary>
- /// log audit
- /// </summary>
- Audit = 13,
+ /// <summary>
+ /// log audit
+ /// </summary>
+ Audit = 13,
- /// <summary>
- /// log alert
- /// </summary>
- Alert = 14,
+ /// <summary>
+ /// log alert
+ /// </summary>
+ Alert = 14,
- /// <summary>
- /// clock daemon
- /// </summary>
- Clock2 = 15,
+ /// <summary>
+ /// clock daemon
+ /// </summary>
+ Clock2 = 15,
- /// <summary>
- /// reserved for local use
- /// </summary>
- Local0 = 16,
+ /// <summary>
+ /// reserved for local use
+ /// </summary>
+ Local0 = 16,
- /// <summary>
- /// reserved for local use
- /// </summary>
- Local1 = 17,
+ /// <summary>
+ /// reserved for local use
+ /// </summary>
+ Local1 = 17,
- /// <summary>
- /// reserved for local use
- /// </summary>
- Local2 = 18,
+ /// <summary>
+ /// reserved for local use
+ /// </summary>
+ Local2 = 18,
- /// <summary>
- /// reserved for local use
- /// </summary>
- Local3 = 19,
+ /// <summary>
+ /// reserved for local use
+ /// </summary>
+ Local3 = 19,
- /// <summary>
- /// reserved for local use
- /// </summary>
- Local4 = 20,
+ /// <summary>
+ /// reserved for local use
+ /// </summary>
+ Local4 = 20,
- /// <summary>
- /// reserved for local use
- /// </summary>
- Local5 = 21,
+ /// <summary>
+ /// reserved for local use
+ /// </summary>
+ Local5 = 21,
- /// <summary>
- /// reserved for local use
- /// </summary>
- Local6 = 22,
+ /// <summary>
+ /// reserved for local use
+ /// </summary>
+ Local6 = 22,
- /// <summary>
- /// reserved for local use
- /// </summary>
- Local7 = 23
- }
+ /// <summary>
+ /// reserved for local use
+ /// </summary>
+ Local7 = 23
+ }
- #endregion Enumerations
+ #endregion Enumerations
- #region Public Instance Constructors
+ #region Public Instance Constructors
- /// <summary>
- /// Initializes a new instance of the <see cref="RemoteSyslogAppender" /> class.
- /// </summary>
- /// <remarks>
- /// This instance of the <see cref="RemoteSyslogAppender" /> class is set up to write
- /// to a remote syslog daemon.
- /// </remarks>
- public RemoteSyslogAppender()
- {
- // syslog udp defaults
- this.RemotePort = DefaultSyslogPort;
- this.RemoteAddress = System.Net.IPAddress.Parse("127.0.0.1");
- this.Encoding = System.Text.Encoding.ASCII;
- }
+ /// <summary>
+ /// Initializes a new instance of the <see cref="RemoteSyslogAppender" /> class.
+ /// </summary>
+ /// <remarks>
+ /// This instance of the <see cref="RemoteSyslogAppender" /> class is set up to write
+ /// to a remote syslog daemon.
+ /// </remarks>
+ public RemoteSyslogAppender()
+ {
+ // syslog udp defaults
+ this.RemotePort = DefaultSyslogPort;
+ this.RemoteAddress = System.Net.IPAddress.Parse("127.0.0.1");
+ this.Encoding = System.Text.Encoding.ASCII;
+ }
- #endregion Public Instance Constructors
+ #endregion Public Instance Constructors
- #region Public Instance Properties
+ #region Public Instance Properties
- /// <summary>
- /// Message identity
- /// </summary>
- /// <remarks>
- /// <para>
- /// An identifier is specified with each log message. This can be specified
- /// by setting the <see cref="Identity"/> property. The identity (also know
- /// as the tag) must not contain white space. The default value for the
- /// identity is the application name (from <see cref="LoggingEvent.Domain"/>).
- /// </para>
- /// </remarks>
- public PatternLayout Identity
- {
- get { return m_identity; }
- set { m_identity = value; }
- }
+ /// <summary>
+ /// Message identity
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// An identifier is specified with each log message. This can be specified
+ /// by setting the <see cref="Identity"/> property. The identity (also know
+ /// as the tag) must not contain white space. The default value for the
+ /// identity is the application name (from <see cref="LoggingEvent.Domain"/>).
+ /// </para>
+ /// </remarks>
+ public PatternLayout Identity
+ {
+ get { return m_identity; }
+ set { m_identity = value; }
+ }
- /// <summary>
- /// Syslog facility
- /// </summary>
- /// <remarks>
- /// Set to one of the <see cref="SyslogFacility"/> values. The list of
- /// facilities is predefined and cannot be extended. The default value
- /// is <see cref="SyslogFacility.User"/>.
- /// </remarks>
- public SyslogFacility Facility
- {
- get { return m_facility; }
- set { m_facility = value; }
- }
+ /// <summary>
+ /// Syslog facility
+ /// </summary>
+ /// <remarks>
+ /// Set to one of the <see cref="SyslogFacility"/> values. The list of
+ /// facilities is predefined and cannot be extended. The default value
+ /// is <see cref="SyslogFacility.User"/>.
+ /// </remarks>
+ public SyslogFacility Facility
+ {
+ get { return m_facility; }
+ set { m_facility = value; }
+ }
- #endregion Public Instance Properties
+ #endregion Public Instance Properties
- /// <summary>
- /// Add a mapping of level to severity
- /// </summary>
- /// <param name="mapping">The mapping to add</param>
- /// <remarks>
- /// <para>
- /// Add a <see cref="LevelSeverity"/> mapping to this appender.
- /// </para>
- /// </remarks>
- public void AddMapping(LevelSeverity mapping)
- {
- m_levelMapping.Add(mapping);
- }
+ /// <summary>
+ /// Add a mapping of level to severity
+ /// </summary>
+ /// <param name="mapping">The mapping to add</param>
+ /// <remarks>
+ /// <para>
+ /// Add a <see cref="LevelSeverity"/> mapping to this appender.
+ /// </para>
+ /// </remarks>
+ public void AddMapping(LevelSeverity mapping)
+ {
+ m_levelMapping.Add(mapping);
+ }
- #region AppenderSkeleton Implementation
+ #region AppenderSkeleton Implementation
- /// <summary>
- /// This method is called by the <see cref="M:AppenderSkeleton.DoAppend(LoggingEvent)"/> method.
- /// </summary>
- /// <param name="loggingEvent">The event to log.</param>
- /// <remarks>
- /// <para>
- /// Writes the event to a remote syslog daemon.
- /// </para>
- /// <para>
- /// The format of the output will depend on the appender's layout.
- /// </para>
- /// </remarks>
- protected override void Append(LoggingEvent loggingEvent)
- {
- try
- {
- // Priority
- int priority = GeneratePriority(m_facility, GetSeverity(loggingEvent.Level));
+ /// <summary>
+ /// This method is called by the <see cref="M:AppenderSkeleton.DoAppend(LoggingEvent)"/> method.
+ /// </summary>
+ /// <param name="loggingEvent">The event to log.</param>
+ /// <remarks>
+ /// <para>
+ /// Writes the event to a remote syslog daemon.
+ /// </para>
+ /// <para>
+ /// The format of the output will depend on the appender's layout.
+ /// </para>
+ /// </remarks>
+ protected override void Append(LoggingEvent loggingEvent)
+ {
+ try
+ {
+ // Priority
+ int priority = GeneratePriority(m_facility, GetSeverity(loggingEvent.Level));
- // Identity
- string identity;
+ // Identity
+ string identity;
- if (m_identity != null)
- {
- identity = m_identity.Format(loggingEvent);
- }
- else
- {
- identity = loggingEvent.Domain;
- }
+ if (m_identity != null)
+ {
+ identity = m_identity.Format(loggingEvent);
+ }
+ else
+ {
+ identity = loggingEvent.Domain;
+ }
- // Message. The message goes after the tag/identity
- string message = RenderLoggingEvent(loggingEvent);
+ // Message. The message goes after the tag/identity
+ string message = RenderLoggingEvent(loggingEvent);
- byte[] buffer;
- int i = 0;
+ byte[] buffer;
+ int i = 0;
- StringBuilder builder = new StringBuilder();
+ StringBuilder builder = new StringBuilder();
- while (i < message.Length)
- {
- // Clear StringBuilder
- builder.Length = 0;
+ while (i < message.Length)
+ {
+ // Clear StringBuilder
+ builder.Length = 0;
- // Write priority
- builder.Append('<');
- builder.Append(priority);
- builder.Append('>');
+ // Write priority
+ builder.Append('<');
+ builder.Append(priority);
+ builder.Append('>');
- // Write identity
- builder.Append(identity);
- builder.Append(": ");
+ // Write identity
+ builder.Append(identity);
+ builder.Append(": ");
- AppendMessage(message, ref i, builder);
+ AppendMessage(message, ref i, builder);
- // Grab as a byte array
- buffer = this.Encoding.GetBytes(builder.ToString());
+ // Grab as a byte array
+ buffer = this.Encoding.GetBytes(builder.ToString());
#if NET_4_5 || NETSTANDARD
- Client.SendAsync(buffer, buffer.Length, RemoteEndPoint).Wait();
+ Client.SendAsync(buffer, buffer.Length, RemoteEndPoint).Wait();
#else
- this.Client.Send(buffer, buffer.Length, this.RemoteEndPoint);
+ this.Client.Send(buffer, buffer.Length, this.RemoteEndPoint);
#endif
- }
- }
- catch (Exception e)
- {
- ErrorHandler.Error(
- "Unable to send logging event to remote syslog " +
- this.RemoteAddress.ToString() +
- " on port " +
- this.RemotePort + ".",
- e,
- ErrorCode.WriteFailure);
- }
- }
+ }
+ }
+ catch (Exception e)
+ {
+ ErrorHandler.Error(
+ "Unable to send logging event to remote syslog " +
+ this.RemoteAddress.ToString() +
+ " on port " +
+ this.RemotePort + ".",
+ e,
+ ErrorCode.WriteFailure);
+ }
+ }
- /// <summary>
- /// Appends the rendered message to the buffer
- /// </summary>
- /// <param name="message">rendered message</param>
- /// <param name="characterIndex">index of the current character in the message</param>
- /// <param name="builder">buffer</param>
- protected virtual void AppendMessage(string message, ref int characterIndex, StringBuilder builder)
- {
- for (; characterIndex < message.Length; characterIndex++)
- {
- char c = message[characterIndex];
+ /// <summary>
+ /// Appends the rendered message to the buffer
+ /// </summary>
+ /// <param name="message">rendered message</param>
+ /// <param name="characterIndex">index of the current character in the message</param>
+ /// <param name="builder">buffer</param>
+ protected virtual void AppendMessage(string message, ref int characterIndex, StringBuilder builder)
+ {
+ for (; characterIndex < message.Length; characterIndex++)
+ {
+ char c = message[characterIndex];
- // Accept only visible ASCII characters and space. See RFC 3164 section 4.1.3
- if (((int)c >= 32) && ((int)c <= 126))
- {
- builder.Append(c);
- }
- // If character is newline, break and send the current line
- else if ((c == '\r') || (c == '\n'))
- {
- // Check the next character to handle \r\n or \n\r
- if ((message.Length > characterIndex + 1) && ((message[characterIndex + 1] == '\r') || (message[characterIndex + 1] == '\n')))
- {
- characterIndex++;
- }
- characterIndex++;
- break;
- }
- }
- }
+ // Accept only visible ASCII characters and space. See RFC 3164 section 4.1.3
+ if (((int)c >= 32) && ((int)c <= 126))
+ {
+ builder.Append(c);
+ }
+ // If character is newline, break and send the current line
+ else if ((c == '\r') || (c == '\n'))
+ {
+ // Check the next character to handle \r\n or \n\r
+ if ((message.Length > characterIndex + 1) && ((message[characterIndex + 1] == '\r') || (message[characterIndex + 1] == '\n')))
+ {
+ characterIndex++;
+ }
+ characterIndex++;
+ break;
+ }
+ }
+ }
- /// <summary>
- /// Initialize the options for this appender
- /// </summary>
- /// <remarks>
- /// <para>
- /// Initialize the level to syslog severity mappings set on this appender.
- /// </para>
- /// </remarks>
- public override void ActivateOptions()
- {
- base.ActivateOptions();
- m_levelMapping.ActivateOptions();
- }
+ /// <summary>
+ /// Initialize the options for this appender
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Initialize the level to syslog severity mappings set on this appender.
+ /// </para>
+ /// </remarks>
+ public override void ActivateOptions()
+ {
+ base.ActivateOptions();
+ m_levelMapping.ActivateOptions();
+ }
- #endregion AppenderSkeleton Implementation
+ #endregion AppenderSkeleton Implementation
- #region Protected Members
+ #region Protected Members
- /// <summary>
- /// Translates a log4net level to a syslog severity.
- /// </summary>
- /// <param name="level">A log4net level.</param>
- /// <returns>A syslog severity.</returns>
- /// <remarks>
- /// <para>
- /// Translates a log4net level to a syslog severity.
- /// </para>
- /// </remarks>
- protected virtual SyslogSeverity GetSeverity(Level level)
- {
- LevelSeverity levelSeverity = m_levelMapping.Lookup(level) as LevelSeverity;
- if (levelSeverity != null)
- {
- return levelSeverity.Severity;
- }
+ /// <summary>
+ /// Translates a log4net level to a syslog severity.
+ /// </summary>
+ /// <param name="level">A log4net level.</param>
+ /// <returns>A syslog severity.</returns>
+ /// <remarks>
+ /// <para>
+ /// Translates a log4net level to a syslog severity.
+ /// </para>
+ /// </remarks>
+ protected virtual SyslogSeverity GetSeverity(Level level)
+ {
+ LevelSeverity levelSeverity = m_levelMapping.Lookup(level) as LevelSeverity;
+ if (levelSeverity != null)
+ {
+ return levelSeverity.Severity;
+ }
- //
- // Fallback to sensible default values
- //
+ //
+ // Fallback to sensible default values
+ //
- if (level >= Level.Alert)
- {
- return SyslogSeverity.Alert;
- }
- else if (level >= Level.Critical)
- {
- return SyslogSeverity.Critical;
- }
- else if (level >= Level.Error)
- {
- return SyslogSeverity.Error;
- }
- else if (level >= Level.Warn)
- {
- return SyslogSeverity.Warning;
- }
- else if (level >= Level.Notice)
- {
- return SyslogSeverity.Notice;
- }
- else if (level >= Level.Info)
- {
- return SyslogSeverity.Informational;
- }
- // Default setting
- return SyslogSeverity.Debug;
- }
+ if (level >= Level.Alert)
+ {
+ return SyslogSeverity.Alert;
+ }
+ else if (level >= Level.Critical)
+ {
+ return SyslogSeverity.Critical;
+ }
+ else if (level >= Level.Error)
+ {
+ return SyslogSeverity.Error;
+ }
+ else if (level >= Level.Warn)
+ {
+ return SyslogSeverity.Warning;
+ }
+ else if (level >= Level.Notice)
+ {
+ return SyslogSeverity.Notice;
+ }
+ else if (level >= Level.Info)
+ {
+ return SyslogSeverity.Informational;
+ }
+ // Default setting
+ return SyslogSeverity.Debug;
+ }
- #endregion Protected Members
+ #endregion Protected Members
- #region Public Static Members
+ #region Public Static Members
- /// <summary>
- /// Generate a syslog priority.
- /// </summary>
- /// <param name="facility">The syslog facility.</param>
- /// <param name="severity">The syslog severity.</param>
- /// <returns>A syslog priority.</returns>
- /// <remarks>
- /// <para>
- /// Generate a syslog priority.
- /// </para>
- /// </remarks>
- public static int GeneratePriority(SyslogFacility facility, SyslogSeverity severity)
- {
- if (facility < SyslogFacility.Kernel || facility > SyslogFacility.Local7)
- {
- throw new ArgumentException("SyslogFacility out of range", "facility");
- }
+ /// <summary>
+ /// Generate a syslog priority.
+ /// </summary>
+ /// <param name="facility">The syslog facility.</param>
+ /// <param name="severity">The syslog severity.</param>
+ /// <returns>A syslog priority.</returns>
+ /// <remarks>
+ /// <para>
+ /// Generate a syslog priority.
+ /// </para>
+ /// </remarks>
+ public static int GeneratePriority(SyslogFacility facility, SyslogSeverity severity)
+ {
+ if (facility < SyslogFacility.Kernel || facility > SyslogFacility.Local7)
+ {
+ throw new ArgumentException("SyslogFacility out of range", "facility");
+ }
- if (severity < SyslogSeverity.Emergency || severity > SyslogSeverity.Debug)
- {
- throw new ArgumentException("SyslogSeverity out of range", "severity");
- }
+ if (severity < SyslogSeverity.Emergency || severity > SyslogSeverity.Debug)
+ {
+ throw new ArgumentException("SyslogSeverity out of range", "severity");
+ }
- unchecked
- {
- return ((int)facility * 8) + (int)severity;
- }
- }
+ unchecked
+ {
+ return ((int)facility * 8) + (int)severity;
+ }
+ }
- #endregion Public Static Members
+ #endregion Public Static Members
- #region Private Instances Fields
+ #region Private Instances Fields
- /// <summary>
- /// The facility. The default facility is <see cref="SyslogFacility.User"/>.
- /// </summary>
- private SyslogFacility m_facility = SyslogFacility.User;
+ /// <summary>
+ /// The facility. The default facility is <see cref="SyslogFacility.User"/>.
+ /// </summary>
+ private SyslogFacility m_facility = SyslogFacility.User;
- /// <summary>
- /// The message identity
- /// </summary>
- private PatternLayout m_identity;
+ /// <summary>
+ /// The message identity
+ /// </summary>
+ private PatternLayout m_identity;
- /// <summary>
- /// Mapping from level object to syslog severity
- /// </summary>
- private LevelMapping m_levelMapping = new LevelMapping();
+ /// <summary>
+ /// Mapping from level object to syslog severity
+ /// </summary>
+ private LevelMapping m_levelMapping = new LevelMapping();
- /// <summary>
- /// Initial buffer size
- /// </summary>
- private const int c_renderBufferSize = 256;
+ /// <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;
+ /// <summary>
+ /// Maximum buffer size before it is recycled
+ /// </summary>
+ private const int c_renderBufferMaxCapacity = 1024;
- #endregion Private Instances Fields
+ #endregion Private Instances Fields
- #region LevelSeverity LevelMapping Entry
- /// <summary>
- /// A class to act as a mapping between the level that a logging call is made at and
- /// the syslog severity that is should be logged at.
- /// </summary>
- /// <remarks>
- /// <para>
- /// A class to act as a mapping between the level that a logging call is made at and
- /// the syslog severity that is should be logged at.
- /// </para>
- /// </remarks>
- public class LevelSeverity : LevelMappingEntry
- {
- private SyslogSeverity m_severity;
+ #region LevelSeverity LevelMapping Entry
+ /// <summary>
+ /// A class to act as a mapping between the level that a logging call is made at and
+ /// the syslog severity that is should be logged at.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// A class to act as a mapping between the level that a logging call is made at and
+ /// the syslog severity that is should be logged at.
+ /// </para>
+ /// </remarks>
+ public class LevelSeverity : LevelMappingEntry
+ {
+ private SyslogSeverity m_severity;
- /// <summary>
- /// The mapped syslog severity for the specified level
- /// </summary>
- /// <remarks>
- /// <para>
- /// Required property.
- /// The mapped syslog severity for the specified level
- /// </para>
- /// </remarks>
- public SyslogSeverity Severity
- {
- get { return m_severity; }
- set { m_severity = value; }
- }
- }
+ /// <summary>
+ /// The mapped syslog severity for the specified level
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Required property.
+ /// The mapped syslog severity for the specified level
+ /// </para>
+ /// </remarks>
+ public SyslogSeverity Severity
+ {
+ get { return m_severity; }
+ set { m_severity = value; }
+ }
+ }
- #endregion // LevelSeverity LevelMapping Entry
- }
+ #endregion // LevelSeverity LevelMapping Entry
+ }
}
diff --git a/src/log4net/Appender/RemotingAppender.cs b/src/log4net/Appender/RemotingAppender.cs
index 7c095f8..7a9fd77 100644
--- a/src/log4net/Appender/RemotingAppender.cs
+++ b/src/log4net/Appender/RemotingAppender.cs
@@ -32,308 +32,308 @@
namespace log4net.Appender
{
- /// <summary>
- /// Delivers logging events to a remote logging sink.
- /// </summary>
- /// <remarks>
- /// <para>
- /// This Appender is designed to deliver events to a remote sink.
- /// That is any object that implements the <see cref="IRemoteLoggingSink"/>
- /// interface. It delivers the events using .NET remoting. The
- /// object to deliver events to is specified by setting the
- /// appenders <see cref="RemotingAppender.Sink"/> property.</para>
- /// <para>
- /// The RemotingAppender buffers events before sending them. This allows it to
- /// make more efficient use of the remoting infrastructure.</para>
- /// <para>
- /// Once the buffer is full the events are still not sent immediately.
- /// They are scheduled to be sent using a pool thread. The effect is that
- /// the send occurs asynchronously. This is very important for a
- /// number of non obvious reasons. The remoting infrastructure will
- /// flow thread local variables (stored in the <see cref="CallContext"/>),
- /// if they are marked as <see cref="ILogicalThreadAffinative"/>, across the
- /// remoting boundary. If the server is not contactable then
- /// the remoting infrastructure will clear the <see cref="ILogicalThreadAffinative"/>
- /// objects from the <see cref="CallContext"/>. To prevent a logging failure from
- /// having side effects on the calling application the remoting call must be made
- /// from a separate thread to the one used by the application. A <see cref="ThreadPool"/>
- /// thread is used for this. If no <see cref="ThreadPool"/> thread is available then
- /// the events will block in the thread pool manager until a thread is available.</para>
- /// <para>
- /// Because the events are sent asynchronously using pool threads it is possible to close
- /// this appender before all the queued events have been sent.
- /// When closing the appender attempts to wait until all the queued events have been sent, but
- /// this will timeout after 30 seconds regardless.</para>
- /// <para>
- /// If this appender is being closed because the <see cref="AppDomain.ProcessExit"/>
- /// event has fired it may not be possible to send all the queued events. During process
- /// exit the runtime limits the time that a <see cref="AppDomain.ProcessExit"/>
- /// event handler is allowed to run for. If the runtime terminates the threads before
- /// the queued events have been sent then they will be lost. To ensure that all events
- /// are sent the appender must be closed before the application exits. See
- /// <see cref="log4net.Core.LoggerManager.Shutdown"/> for details on how to shutdown
- /// log4net programmatically.</para>
- /// </remarks>
- /// <seealso cref="IRemoteLoggingSink" />
- /// <author>Nicko Cadell</author>
- /// <author>Gert Driesen</author>
- /// <author>Daniel Cazzulino</author>
- public class RemotingAppender : BufferingAppenderSkeleton
- {
- #region Public Instance Constructors
+ /// <summary>
+ /// Delivers logging events to a remote logging sink.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// This Appender is designed to deliver events to a remote sink.
+ /// That is any object that implements the <see cref="IRemoteLoggingSink"/>
+ /// interface. It delivers the events using .NET remoting. The
+ /// object to deliver events to is specified by setting the
+ /// appenders <see cref="RemotingAppender.Sink"/> property.</para>
+ /// <para>
+ /// The RemotingAppender buffers events before sending them. This allows it to
+ /// make more efficient use of the remoting infrastructure.</para>
+ /// <para>
+ /// Once the buffer is full the events are still not sent immediately.
+ /// They are scheduled to be sent using a pool thread. The effect is that
+ /// the send occurs asynchronously. This is very important for a
+ /// number of non obvious reasons. The remoting infrastructure will
+ /// flow thread local variables (stored in the <see cref="CallContext"/>),
+ /// if they are marked as <see cref="ILogicalThreadAffinative"/>, across the
+ /// remoting boundary. If the server is not contactable then
+ /// the remoting infrastructure will clear the <see cref="ILogicalThreadAffinative"/>
+ /// objects from the <see cref="CallContext"/>. To prevent a logging failure from
+ /// having side effects on the calling application the remoting call must be made
+ /// from a separate thread to the one used by the application. A <see cref="ThreadPool"/>
+ /// thread is used for this. If no <see cref="ThreadPool"/> thread is available then
+ /// the events will block in the thread pool manager until a thread is available.</para>
+ /// <para>
+ /// Because the events are sent asynchronously using pool threads it is possible to close
+ /// this appender before all the queued events have been sent.
+ /// When closing the appender attempts to wait until all the queued events have been sent, but
+ /// this will timeout after 30 seconds regardless.</para>
+ /// <para>
+ /// If this appender is being closed because the <see cref="AppDomain.ProcessExit"/>
+ /// event has fired it may not be possible to send all the queued events. During process
+ /// exit the runtime limits the time that a <see cref="AppDomain.ProcessExit"/>
+ /// event handler is allowed to run for. If the runtime terminates the threads before
+ /// the queued events have been sent then they will be lost. To ensure that all events
+ /// are sent the appender must be closed before the application exits. See
+ /// <see cref="log4net.Core.LoggerManager.Shutdown"/> for details on how to shutdown
+ /// log4net programmatically.</para>
+ /// </remarks>
+ /// <seealso cref="IRemoteLoggingSink" />
+ /// <author>Nicko Cadell</author>
+ /// <author>Gert Driesen</author>
+ /// <author>Daniel Cazzulino</author>
+ public class RemotingAppender : BufferingAppenderSkeleton
+ {
+ #region Public Instance Constructors
- /// <summary>
- /// Initializes a new instance of the <see cref="RemotingAppender" /> class.
- /// </summary>
- /// <remarks>
- /// <para>
- /// Default constructor.
- /// </para>
- /// </remarks>
- public RemotingAppender()
- {
- }
+ /// <summary>
+ /// Initializes a new instance of the <see cref="RemotingAppender" /> class.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Default constructor.
+ /// </para>
+ /// </remarks>
+ public RemotingAppender()
+ {
+ }
- #endregion Public Instance Constructors
+ #endregion Public Instance Constructors
- #region Public Instance Properties
+ #region Public Instance Properties
- /// <summary>
- /// Gets or sets the URL of the well-known object that will accept
- /// the logging events.
- /// </summary>
- /// <value>
- /// The well-known URL of the remote sink.
- /// </value>
- /// <remarks>
- /// <para>
- /// The URL of the remoting sink that will accept logging events.
- /// The sink must implement the <see cref="IRemoteLoggingSink"/>
- /// interface.
- /// </para>
- /// </remarks>
- public string Sink
- {
- get { return m_sinkUrl; }
- set { m_sinkUrl = value; }
- }
+ /// <summary>
+ /// Gets or sets the URL of the well-known object that will accept
+ /// the logging events.
+ /// </summary>
+ /// <value>
+ /// The well-known URL of the remote sink.
+ /// </value>
+ /// <remarks>
+ /// <para>
+ /// The URL of the remoting sink that will accept logging events.
+ /// The sink must implement the <see cref="IRemoteLoggingSink"/>
+ /// interface.
+ /// </para>
+ /// </remarks>
+ public string Sink
+ {
+ get { return m_sinkUrl; }
+ set { m_sinkUrl = value; }
+ }
- #endregion Public Instance Properties
+ #endregion Public Instance Properties
- #region Implementation of IOptionHandler
+ #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>
+ /// <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>
#if NET_4_0 || MONO_4_0
[System.Security.SecuritySafeCritical]
#endif
public override void ActivateOptions()
- {
- base.ActivateOptions();
+ {
+ base.ActivateOptions();
- IDictionary channelProperties = new Hashtable();
- channelProperties["typeFilterLevel"] = "Full";
+ IDictionary channelProperties = new Hashtable();
+ channelProperties["typeFilterLevel"] = "Full";
- m_sinkObj = (IRemoteLoggingSink)Activator.GetObject(typeof(IRemoteLoggingSink), m_sinkUrl, channelProperties);
- }
+ m_sinkObj = (IRemoteLoggingSink)Activator.GetObject(typeof(IRemoteLoggingSink), m_sinkUrl, channelProperties);
+ }
- #endregion
+ #endregion
- #region Override implementation of BufferingAppenderSkeleton
+ #region Override implementation of BufferingAppenderSkeleton
- /// <summary>
- /// Send the contents of the buffer to the remote sink.
- /// </summary>
- /// <remarks>
- /// The events are not sent immediately. They are scheduled to be sent
- /// using a pool thread. The effect is that the send occurs asynchronously.
- /// This is very important for a number of non obvious reasons. The remoting
- /// infrastructure will flow thread local variables (stored in the <see cref="CallContext"/>),
- /// if they are marked as <see cref="ILogicalThreadAffinative"/>, across the
- /// remoting boundary. If the server is not contactable then
- /// the remoting infrastructure will clear the <see cref="ILogicalThreadAffinative"/>
- /// objects from the <see cref="CallContext"/>. To prevent a logging failure from
- /// having side effects on the calling application the remoting call must be made
- /// from a separate thread to the one used by the application. A <see cref="ThreadPool"/>
- /// thread is used for this. If no <see cref="ThreadPool"/> thread is available then
- /// the events will block in the thread pool manager until a thread is available.
- /// </remarks>
- /// <param name="events">The events to send.</param>
- protected override void SendBuffer(LoggingEvent[] events)
- {
- // Setup for an async send
- BeginAsyncSend();
+ /// <summary>
+ /// Send the contents of the buffer to the remote sink.
+ /// </summary>
+ /// <remarks>
+ /// The events are not sent immediately. They are scheduled to be sent
+ /// using a pool thread. The effect is that the send occurs asynchronously.
+ /// This is very important for a number of non obvious reasons. The remoting
+ /// infrastructure will flow thread local variables (stored in the <see cref="CallContext"/>),
+ /// if they are marked as <see cref="ILogicalThreadAffinative"/>, across the
+ /// remoting boundary. If the server is not contactable then
+ /// the remoting infrastructure will clear the <see cref="ILogicalThreadAffinative"/>
+ /// objects from the <see cref="CallContext"/>. To prevent a logging failure from
+ /// having side effects on the calling application the remoting call must be made
+ /// from a separate thread to the one used by the application. A <see cref="ThreadPool"/>
+ /// thread is used for this. If no <see cref="ThreadPool"/> thread is available then
+ /// the events will block in the thread pool manager until a thread is available.
+ /// </remarks>
+ /// <param name="events">The events to send.</param>
+ protected override void SendBuffer(LoggingEvent[] events)
+ {
+ // Setup for an async send
+ BeginAsyncSend();
- // Send the events
- if (!ThreadPool.QueueUserWorkItem(new WaitCallback(SendBufferCallback), events))
- {
- // Cancel the async send
- EndAsyncSend();
+ // Send the events
+ if (!ThreadPool.QueueUserWorkItem(new WaitCallback(SendBufferCallback), events))
+ {
+ // Cancel the async send
+ EndAsyncSend();
- ErrorHandler.Error("RemotingAppender ["+Name+"] failed to ThreadPool.QueueUserWorkItem logging events in SendBuffer.");
- }
- }
+ ErrorHandler.Error("RemotingAppender ["+Name+"] failed to ThreadPool.QueueUserWorkItem logging events in SendBuffer.");
+ }
+ }
- /// <summary>
- /// Override base class close.
- /// </summary>
- /// <remarks>
- /// <para>
- /// This method waits while there are queued work items. The events are
- /// sent asynchronously using <see cref="ThreadPool"/> work items. These items
- /// will be sent once a thread pool thread is available to send them, therefore
- /// it is possible to close the appender before all the queued events have been
- /// sent.</para>
- /// <para>
- /// This method attempts to wait until all the queued events have been sent, but this
- /// method will timeout after 30 seconds regardless.</para>
- /// <para>
- /// If the appender is being closed because the <see cref="AppDomain.ProcessExit"/>
- /// event has fired it may not be possible to send all the queued events. During process
- /// exit the runtime limits the time that a <see cref="AppDomain.ProcessExit"/>
- /// event handler is allowed to run for.</para>
- /// </remarks>
- protected override void OnClose()
- {
- base.OnClose();
+ /// <summary>
+ /// Override base class close.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// This method waits while there are queued work items. The events are
+ /// sent asynchronously using <see cref="ThreadPool"/> work items. These items
+ /// will be sent once a thread pool thread is available to send them, therefore
+ /// it is possible to close the appender before all the queued events have been
+ /// sent.</para>
+ /// <para>
+ /// This method attempts to wait until all the queued events have been sent, but this
+ /// method will timeout after 30 seconds regardless.</para>
+ /// <para>
+ /// If the appender is being closed because the <see cref="AppDomain.ProcessExit"/>
+ /// event has fired it may not be possible to send all the queued events. During process
+ /// exit the runtime limits the time that a <see cref="AppDomain.ProcessExit"/>
+ /// event handler is allowed to run for.</para>
+ /// </remarks>
+ protected override void OnClose()
+ {
+ base.OnClose();
- // Wait for the work queue to become empty before closing, timeout 30 seconds
- if (!m_workQueueEmptyEvent.WaitOne(30 * 1000, false))
- {
- ErrorHandler.Error("RemotingAppender ["+Name+"] failed to send all queued events before close, in OnClose.");
- }
- }
+ // Wait for the work queue to become empty before closing, timeout 30 seconds
+ if (!m_workQueueEmptyEvent.WaitOne(30 * 1000, false))
+ {
+ ErrorHandler.Error("RemotingAppender ["+Name+"] failed to send all queued events before close, in OnClose.");
+ }
+ }
- /// <summary>
- /// Flushes any buffered log data.
- /// </summary>
- /// <param name="millisecondsTimeout">The maximum time to wait for logging events to be flushed.</param>
- /// <returns><c>True</c> if all logging events were flushed successfully, else <c>false</c>.</returns>
- public override bool Flush(int millisecondsTimeout)
- {
- base.Flush();
- return m_workQueueEmptyEvent.WaitOne(millisecondsTimeout, false);
- }
+ /// <summary>
+ /// Flushes any buffered log data.
+ /// </summary>
+ /// <param name="millisecondsTimeout">The maximum time to wait for logging events to be flushed.</param>
+ /// <returns><c>True</c> if all logging events were flushed successfully, else <c>false</c>.</returns>
+ public override bool Flush(int millisecondsTimeout)
+ {
+ base.Flush();
+ return m_workQueueEmptyEvent.WaitOne(millisecondsTimeout, false);
+ }
- #endregion
+ #endregion
- /// <summary>
- /// A work item is being queued into the thread pool
- /// </summary>
- private void BeginAsyncSend()
- {
- // The work queue is not empty
- m_workQueueEmptyEvent.Reset();
+ /// <summary>
+ /// A work item is being queued into the thread pool
+ /// </summary>
+ private void BeginAsyncSend()
+ {
+ // The work queue is not empty
+ m_workQueueEmptyEvent.Reset();
- // Increment the queued count
- Interlocked.Increment(ref m_queuedCallbackCount);
- }
+ // Increment the queued count
+ Interlocked.Increment(ref m_queuedCallbackCount);
+ }
- /// <summary>
- /// A work item from the thread pool has completed
- /// </summary>
- private void EndAsyncSend()
- {
- // Decrement the queued count
- if (Interlocked.Decrement(ref m_queuedCallbackCount) <= 0)
- {
- // If the work queue is empty then set the event
- m_workQueueEmptyEvent.Set();
- }
- }
+ /// <summary>
+ /// A work item from the thread pool has completed
+ /// </summary>
+ private void EndAsyncSend()
+ {
+ // Decrement the queued count
+ if (Interlocked.Decrement(ref m_queuedCallbackCount) <= 0)
+ {
+ // If the work queue is empty then set the event
+ m_workQueueEmptyEvent.Set();
+ }
+ }
- /// <summary>
- /// Send the contents of the buffer to the remote sink.
- /// </summary>
- /// <remarks>
- /// This method is designed to be used with the <see cref="ThreadPool"/>.
- /// This method expects to be passed an array of <see cref="LoggingEvent"/>
- /// objects in the state param.
- /// </remarks>
- /// <param name="state">the logging events to send</param>
- private void SendBufferCallback(object state)
- {
- try
- {
- LoggingEvent[] events = (LoggingEvent[])state;
+ /// <summary>
+ /// Send the contents of the buffer to the remote sink.
+ /// </summary>
+ /// <remarks>
+ /// This method is designed to be used with the <see cref="ThreadPool"/>.
+ /// This method expects to be passed an array of <see cref="LoggingEvent"/>
+ /// objects in the state param.
+ /// </remarks>
+ /// <param name="state">the logging events to send</param>
+ private void SendBufferCallback(object state)
+ {
+ try
+ {
+ LoggingEvent[] events = (LoggingEvent[])state;
- // Send the events
- m_sinkObj.LogEvents(events);
- }
- catch(Exception ex)
- {
- ErrorHandler.Error("Failed in SendBufferCallback", ex);
- }
- finally
- {
- EndAsyncSend();
- }
- }
+ // Send the events
+ m_sinkObj.LogEvents(events);
+ }
+ catch(Exception ex)
+ {
+ ErrorHandler.Error("Failed in SendBufferCallback", ex);
+ }
+ finally
+ {
+ EndAsyncSend();
+ }
+ }
- #region Private Instance Fields
+ #region Private Instance Fields
- /// <summary>
- /// The URL of the remote sink.
- /// </summary>
- private string m_sinkUrl;
+ /// <summary>
+ /// The URL of the remote sink.
+ /// </summary>
+ private string m_sinkUrl;
- /// <summary>
- /// The local proxy (.NET remoting) for the remote logging sink.
- /// </summary>
- private IRemoteLoggingSink m_sinkObj;
+ /// <summary>
+ /// The local proxy (.NET remoting) for the remote logging sink.
+ /// </summary>
+ private IRemoteLoggingSink m_sinkObj;
- /// <summary>
- /// The number of queued callbacks currently waiting or executing
- /// </summary>
- private int m_queuedCallbackCount = 0;
+ /// <summary>
+ /// The number of queued callbacks currently waiting or executing
+ /// </summary>
+ private int m_queuedCallbackCount = 0;
- /// <summary>
- /// Event used to signal when there are no queued work items
- /// </summary>
- /// <remarks>
- /// This event is set when there are no queued work items. In this
- /// state it is safe to close the appender.
- /// </remarks>
- private ManualResetEvent m_workQueueEmptyEvent = new ManualResetEvent(true);
+ /// <summary>
+ /// Event used to signal when there are no queued work items
+ /// </summary>
+ /// <remarks>
+ /// This event is set when there are no queued work items. In this
+ /// state it is safe to close the appender.
+ /// </remarks>
+ private ManualResetEvent m_workQueueEmptyEvent = new ManualResetEvent(true);
- #endregion Private Instance Fields
+ #endregion Private Instance Fields
- /// <summary>
- /// Interface used to deliver <see cref="LoggingEvent"/> objects to a remote sink.
- /// </summary>
- /// <remarks>
- /// This interface must be implemented by a remoting sink
- /// if the <see cref="RemotingAppender"/> is to be used
- /// to deliver logging events to the sink.
- /// </remarks>
- public interface IRemoteLoggingSink
- {
- /// <summary>
- /// Delivers logging events to the remote sink
- /// </summary>
- /// <param name="events">Array of events to log.</param>
- /// <remarks>
- /// <para>
- /// Delivers logging events to the remote sink
- /// </para>
- /// </remarks>
- void LogEvents(LoggingEvent[] events);
- }
- }
+ /// <summary>
+ /// Interface used to deliver <see cref="LoggingEvent"/> objects to a remote sink.
+ /// </summary>
+ /// <remarks>
+ /// This interface must be implemented by a remoting sink
+ /// if the <see cref="RemotingAppender"/> is to be used
+ /// to deliver logging events to the sink.
+ /// </remarks>
+ public interface IRemoteLoggingSink
+ {
+ /// <summary>
+ /// Delivers logging events to the remote sink
+ /// </summary>
+ /// <param name="events">Array of events to log.</param>
+ /// <remarks>
+ /// <para>
+ /// Delivers logging events to the remote sink
+ /// </para>
+ /// </remarks>
+ void LogEvents(LoggingEvent[] events);
+ }
+ }
}
#endif // NET_2_0
\ No newline at end of file
diff --git a/src/log4net/Appender/RollingFileAppender.cs b/src/log4net/Appender/RollingFileAppender.cs
index d6aef10..b1943d7 100644
--- a/src/log4net/Appender/RollingFileAppender.cs
+++ b/src/log4net/Appender/RollingFileAppender.cs
@@ -29,467 +29,467 @@
namespace log4net.Appender
{
#if CONFIRM_WIN32_FILE_SHAREMODES
- // The following sounds good, and I though it was the case, but after
- // further testing on Windows I have not been able to confirm it.
+ // The following sounds good, and I though it was the case, but after
+ // further testing on Windows I have not been able to confirm it.
- /// On the Windows platform if another process has a write lock on the file
- /// that is to be deleted, but allows shared read access to the file then the
- /// file can be moved, but cannot be deleted. If the other process also allows
- /// shared delete access to the file then the file will be deleted once that
- /// process closes the file. If it is necessary to open the log file or any
- /// of the backup files outside of this appender for either read or
- /// write access please ensure that read and delete share modes are enabled.
+ /// On the Windows platform if another process has a write lock on the file
+ /// that is to be deleted, but allows shared read access to the file then the
+ /// file can be moved, but cannot be deleted. If the other process also allows
+ /// shared delete access to the file then the file will be deleted once that
+ /// process closes the file. If it is necessary to open the log file or any
+ /// of the backup files outside of this appender for either read or
+ /// write access please ensure that read and delete share modes are enabled.
#endif
- /// <summary>
- /// Appender that rolls log files based on size or date or both.
- /// </summary>
- /// <remarks>
- /// <para>
- /// RollingFileAppender can roll log files based on size or date or both
- /// depending on the setting of the <see cref="RollingStyle"/> property.
- /// When set to <see cref="RollingMode.Size"/> the log file will be rolled
- /// once its size exceeds the <see cref="MaximumFileSize"/>.
- /// When set to <see cref="RollingMode.Date"/> the log file will be rolled
- /// once the date boundary specified in the <see cref="DatePattern"/> property
- /// is crossed.
- /// When set to <see cref="RollingMode.Composite"/> the log file will be
- /// rolled once the date boundary specified in the <see cref="DatePattern"/> property
- /// is crossed, but within a date boundary the file will also be rolled
- /// once its size exceeds the <see cref="MaximumFileSize"/>.
- /// When set to <see cref="RollingMode.Once"/> the log file will be rolled when
- /// the appender is configured. This effectively means that the log file can be
- /// rolled once per program execution.
- /// </para>
- /// <para>
- /// A of few additional optional features have been added:
- /// <list type="bullet">
- /// <item>Attach date pattern for current log file <see cref="StaticLogFileName"/></item>
- /// <item>Backup number increments for newer files <see cref="CountDirection"/></item>
- /// <item>Infinite number of backups by file size <see cref="MaxSizeRollBackups"/></item>
- /// </list>
- /// </para>
- ///
- /// <note>
- /// <para>
- /// For large or infinite numbers of backup files a <see cref="CountDirection"/>
- /// greater than zero is highly recommended, otherwise all the backup files need
- /// to be renamed each time a new backup is created.
- /// </para>
- /// <para>
- /// When Date/Time based rolling is used setting <see cref="StaticLogFileName"/>
- /// to <see langword="true"/> will reduce the number of file renamings to few or none.
- /// </para>
- /// </note>
- ///
- /// <note type="caution">
- /// <para>
- /// Changing <see cref="StaticLogFileName"/> or <see cref="CountDirection"/> without clearing
- /// the log file directory of backup files will cause unexpected and unwanted side effects.
- /// </para>
- /// </note>
- ///
- /// <para>
- /// If Date/Time based rolling is enabled this appender will attempt to roll existing files
- /// in the directory without a Date/Time tag based on the last write date of the base log file.
- /// The appender only rolls the log file when a message is logged. If Date/Time based rolling
- /// is enabled then the appender will not roll the log file at the Date/Time boundary but
- /// at the point when the next message is logged after the boundary has been crossed.
- /// </para>
- ///
- /// <para>
- /// The <see cref="RollingFileAppender"/> extends the <see cref="FileAppender"/> and
- /// has the same behavior when opening the log file.
- /// The appender will first try to open the file for writing when <see cref="ActivateOptions"/>
- /// is called. This will typically be during configuration.
- /// If the file cannot be opened for writing the appender will attempt
- /// to open the file again each time a message is logged to the appender.
- /// If the file cannot be opened for writing when a message is logged then
- /// the message will be discarded by this appender.
- /// </para>
- /// <para>
- /// When rolling a backup file necessitates deleting an older backup file the
- /// file to be deleted is moved to a temporary name before being deleted.
- /// </para>
- ///
- /// <note type="caution">
- /// <para>
- /// A maximum number of backup files when rolling on date/time boundaries is not supported.
- /// </para>
- /// </note>
- /// </remarks>
- /// <author>Nicko Cadell</author>
- /// <author>Gert Driesen</author>
- /// <author>Aspi Havewala</author>
- /// <author>Douglas de la Torre</author>
- /// <author>Edward Smit</author>
- public class RollingFileAppender : FileAppender
+ /// <summary>
+ /// Appender that rolls log files based on size or date or both.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// RollingFileAppender can roll log files based on size or date or both
+ /// depending on the setting of the <see cref="RollingStyle"/> property.
+ /// When set to <see cref="RollingMode.Size"/> the log file will be rolled
+ /// once its size exceeds the <see cref="MaximumFileSize"/>.
+ /// When set to <see cref="RollingMode.Date"/> the log file will be rolled
+ /// once the date boundary specified in the <see cref="DatePattern"/> property
+ /// is crossed.
+ /// When set to <see cref="RollingMode.Composite"/> the log file will be
+ /// rolled once the date boundary specified in the <see cref="DatePattern"/> property
+ /// is crossed, but within a date boundary the file will also be rolled
+ /// once its size exceeds the <see cref="MaximumFileSize"/>.
+ /// When set to <see cref="RollingMode.Once"/> the log file will be rolled when
+ /// the appender is configured. This effectively means that the log file can be
+ /// rolled once per program execution.
+ /// </para>
+ /// <para>
+ /// A of few additional optional features have been added:
+ /// <list type="bullet">
+ /// <item>Attach date pattern for current log file <see cref="StaticLogFileName"/></item>
+ /// <item>Backup number increments for newer files <see cref="CountDirection"/></item>
+ /// <item>Infinite number of backups by file size <see cref="MaxSizeRollBackups"/></item>
+ /// </list>
+ /// </para>
+ ///
+ /// <note>
+ /// <para>
+ /// For large or infinite numbers of backup files a <see cref="CountDirection"/>
+ /// greater than zero is highly recommended, otherwise all the backup files need
+ /// to be renamed each time a new backup is created.
+ /// </para>
+ /// <para>
+ /// When Date/Time based rolling is used setting <see cref="StaticLogFileName"/>
+ /// to <see langword="true"/> will reduce the number of file renamings to few or none.
+ /// </para>
+ /// </note>
+ ///
+ /// <note type="caution">
+ /// <para>
+ /// Changing <see cref="StaticLogFileName"/> or <see cref="CountDirection"/> without clearing
+ /// the log file directory of backup files will cause unexpected and unwanted side effects.
+ /// </para>
+ /// </note>
+ ///
+ /// <para>
+ /// If Date/Time based rolling is enabled this appender will attempt to roll existing files
+ /// in the directory without a Date/Time tag based on the last write date of the base log file.
+ /// The appender only rolls the log file when a message is logged. If Date/Time based rolling
+ /// is enabled then the appender will not roll the log file at the Date/Time boundary but
+ /// at the point when the next message is logged after the boundary has been crossed.
+ /// </para>
+ ///
+ /// <para>
+ /// The <see cref="RollingFileAppender"/> extends the <see cref="FileAppender"/> and
+ /// has the same behavior when opening the log file.
+ /// The appender will first try to open the file for writing when <see cref="ActivateOptions"/>
+ /// is called. This will typically be during configuration.
+ /// If the file cannot be opened for writing the appender will attempt
+ /// to open the file again each time a message is logged to the appender.
+ /// If the file cannot be opened for writing when a message is logged then
+ /// the message will be discarded by this appender.
+ /// </para>
+ /// <para>
+ /// When rolling a backup file necessitates deleting an older backup file the
+ /// file to be deleted is moved to a temporary name before being deleted.
+ /// </para>
+ ///
+ /// <note type="caution">
+ /// <para>
+ /// A maximum number of backup files when rolling on date/time boundaries is not supported.
+ /// </para>
+ /// </note>
+ /// </remarks>
+ /// <author>Nicko Cadell</author>
+ /// <author>Gert Driesen</author>
+ /// <author>Aspi Havewala</author>
+ /// <author>Douglas de la Torre</author>
+ /// <author>Edward Smit</author>
+ public class RollingFileAppender : FileAppender
{
#region Public Enums
/// <summary>
- /// Style of rolling to use
- /// </summary>
- /// <remarks>
- /// <para>
- /// Style of rolling to use
- /// </para>
- /// </remarks>
- public enum RollingMode
- {
- /// <summary>
- /// Roll files once per program execution
- /// </summary>
- /// <remarks>
- /// <para>
- /// Roll files once per program execution.
- /// Well really once each time this appender is
- /// configured.
- /// </para>
- /// <para>
- /// Setting this option also sets <c>AppendToFile</c> to
- /// <c>false</c> on the <c>RollingFileAppender</c>, otherwise
- /// this appender would just be a normal file appender.
- /// </para>
- /// </remarks>
- Once = 0,
+ /// Style of rolling to use
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Style of rolling to use
+ /// </para>
+ /// </remarks>
+ public enum RollingMode
+ {
+ /// <summary>
+ /// Roll files once per program execution
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Roll files once per program execution.
+ /// Well really once each time this appender is
+ /// configured.
+ /// </para>
+ /// <para>
+ /// Setting this option also sets <c>AppendToFile</c> to
+ /// <c>false</c> on the <c>RollingFileAppender</c>, otherwise
+ /// this appender would just be a normal file appender.
+ /// </para>
+ /// </remarks>
+ Once = 0,
- /// <summary>
- /// Roll files based only on the size of the file
- /// </summary>
- Size = 1,
+ /// <summary>
+ /// Roll files based only on the size of the file
+ /// </summary>
+ Size = 1,
- /// <summary>
- /// Roll files based only on the date
- /// </summary>
- Date = 2,
+ /// <summary>
+ /// Roll files based only on the date
+ /// </summary>
+ Date = 2,
- /// <summary>
- /// Roll files based on both the size and date of the file
- /// </summary>
- Composite = 3
- }
+ /// <summary>
+ /// Roll files based on both the size and date of the file
+ /// </summary>
+ Composite = 3
+ }
- #endregion
+ #endregion
- #region Protected Enums
+ #region Protected Enums
- /// <summary>
- /// The code assumes that the following 'time' constants are in a increasing sequence.
- /// </summary>
- /// <remarks>
- /// <para>
- /// The code assumes that the following 'time' constants are in a increasing sequence.
- /// </para>
- /// </remarks>
- protected enum RollPoint
- {
- /// <summary>
- /// Roll the log not based on the date
- /// </summary>
- InvalidRollPoint =-1,
+ /// <summary>
+ /// The code assumes that the following 'time' constants are in a increasing sequence.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// The code assumes that the following 'time' constants are in a increasing sequence.
+ /// </para>
+ /// </remarks>
+ protected enum RollPoint
+ {
+ /// <summary>
+ /// Roll the log not based on the date
+ /// </summary>
+ InvalidRollPoint =-1,
- /// <summary>
- /// Roll the log for each minute
- /// </summary>
- TopOfMinute = 0,
+ /// <summary>
+ /// Roll the log for each minute
+ /// </summary>
+ TopOfMinute = 0,
- /// <summary>
- /// Roll the log for each hour
- /// </summary>
- TopOfHour = 1,
+ /// <summary>
+ /// Roll the log for each hour
+ /// </summary>
+ TopOfHour = 1,
- /// <summary>
- /// Roll the log twice a day (midday and midnight)
- /// </summary>
- HalfDay = 2,
+ /// <summary>
+ /// Roll the log twice a day (midday and midnight)
+ /// </summary>
+ HalfDay = 2,
- /// <summary>
- /// Roll the log each day (midnight)
- /// </summary>
- TopOfDay = 3,
+ /// <summary>
+ /// Roll the log each day (midnight)
+ /// </summary>
+ TopOfDay = 3,
- /// <summary>
- /// Roll the log each week
- /// </summary>
- TopOfWeek = 4,
+ /// <summary>
+ /// Roll the log each week
+ /// </summary>
+ TopOfWeek = 4,
- /// <summary>
- /// Roll the log each month
- /// </summary>
- TopOfMonth = 5
- }
+ /// <summary>
+ /// Roll the log each month
+ /// </summary>
+ TopOfMonth = 5
+ }
- #endregion Protected Enums
+ #endregion Protected Enums
- #region Public Instance Constructors
+ #region Public Instance Constructors
- /// <summary>
- /// Initializes a new instance of the <see cref="RollingFileAppender" /> class.
- /// </summary>
- /// <remarks>
- /// <para>
- /// Default constructor.
- /// </para>
- /// </remarks>
- public RollingFileAppender()
- {
- }
+ /// <summary>
+ /// Initializes a new instance of the <see cref="RollingFileAppender" /> class.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Default constructor.
+ /// </para>
+ /// </remarks>
+ public RollingFileAppender()
+ {
+ }
- /// <summary>
- /// Cleans up all resources used by this appender.
- /// </summary>
- ~RollingFileAppender()
- {
+ /// <summary>
+ /// Cleans up all resources used by this appender.
+ /// </summary>
+ ~RollingFileAppender()
+ {
#if !NETCF
- if (m_mutexForRolling != null)
- {
+ if (m_mutexForRolling != null)
+ {
#if NET_4_0 || MONO_4_0 || NETSTANDARD
- m_mutexForRolling.Dispose();
+ m_mutexForRolling.Dispose();
#else
- m_mutexForRolling.Close();
+ m_mutexForRolling.Close();
#endif
- m_mutexForRolling = null;
- }
+ m_mutexForRolling = null;
+ }
#endif
- }
+ }
- #endregion Public Instance Constructors
+ #endregion Public Instance Constructors
- #region Public Instance Properties
+ #region Public Instance Properties
#if !NET_1_0 && !CLI_1_0 && !NETCF
/// <summary>
- /// Gets or sets the strategy for determining the current date and time. The default
- /// implementation is to use LocalDateTime which internally calls through to DateTime.Now.
- /// DateTime.UtcNow may be used on frameworks newer than .NET 1.0 by specifying
- /// <see cref="RollingFileAppender.UniversalDateTime"/>.
- /// </summary>
- /// <value>
- /// An implementation of the <see cref="RollingFileAppender.IDateTime"/> interface which returns the current date and time.
- /// </value>
- /// <remarks>
- /// <para>
- /// Gets or sets the <see cref="RollingFileAppender.IDateTime"/> used to return the current date and time.
- /// </para>
+ /// Gets or sets the strategy for determining the current date and time. The default
+ /// implementation is to use LocalDateTime which internally calls through to DateTime.Now.
+ /// DateTime.UtcNow may be used on frameworks newer than .NET 1.0 by specifying
+ /// <see cref="RollingFileAppender.UniversalDateTime"/>.
+ /// </summary>
+ /// <value>
+ /// An implementation of the <see cref="RollingFileAppender.IDateTime"/> interface which returns the current date and time.
+ /// </value>
+ /// <remarks>
+ /// <para>
+ /// Gets or sets the <see cref="RollingFileAppender.IDateTime"/> used to return the current date and time.
+ /// </para>
/// <para>
/// There are two built strategies for determining the current date and time,
- /// <see cref="RollingFileAppender.LocalDateTime"/>
+ /// <see cref="RollingFileAppender.LocalDateTime"/>
/// and <see cref="RollingFileAppender.UniversalDateTime"/>.
/// </para>
/// <para>
- /// The default strategy is <see cref="RollingFileAppender.LocalDateTime"/>.
- /// </para>
- /// </remarks>
+ /// The default strategy is <see cref="RollingFileAppender.LocalDateTime"/>.
+ /// </para>
+ /// </remarks>
#else
/// <summary>
- /// Gets or sets the strategy for determining the current date and time. The default
- /// implementation is to use LocalDateTime which internally calls through to DateTime.Now.
- /// </summary>
- /// <value>
- /// An implementation of the <see cref="RollingFileAppender.IDateTime"/> interface which returns the current date and time.
- /// </value>
- /// <remarks>
- /// <para>
- /// Gets or sets the <see cref="RollingFileAppender.IDateTime"/> used to return the current date and time.
- /// </para>
+ /// Gets or sets the strategy for determining the current date and time. The default
+ /// implementation is to use LocalDateTime which internally calls through to DateTime.Now.
+ /// </summary>
+ /// <value>
+ /// An implementation of the <see cref="RollingFileAppender.IDateTime"/> interface which returns the current date and time.
+ /// </value>
+ /// <remarks>
+ /// <para>
+ /// Gets or sets the <see cref="RollingFileAppender.IDateTime"/> used to return the current date and time.
+ /// </para>
/// <para>
- /// The default strategy is <see cref="RollingFileAppender.LocalDateTime"/>.
- /// </para>
- /// </remarks>
+ /// The default strategy is <see cref="RollingFileAppender.LocalDateTime"/>.
+ /// </para>
+ /// </remarks>
#endif
public IDateTime DateTimeStrategy
- {
- get { return m_dateTime; }
- set { m_dateTime = value; }
- }
+ {
+ get { return m_dateTime; }
+ set { m_dateTime = value; }
+ }
- /// <summary>
- /// Gets or sets the date pattern to be used for generating file names
- /// when rolling over on date.
- /// </summary>
- /// <value>
- /// The date pattern to be used for generating file names when rolling
- /// over on date.
- /// </value>
- /// <remarks>
- /// <para>
- /// Takes a string in the same format as expected by
- /// <see cref="log4net.DateFormatter.SimpleDateFormatter" />.
- /// </para>
- /// <para>
- /// This property determines the rollover schedule when rolling over
- /// on date.
- /// </para>
- /// </remarks>
- public string DatePattern
- {
- get { return m_datePattern; }
- set { m_datePattern = value; }
- }
+ /// <summary>
+ /// Gets or sets the date pattern to be used for generating file names
+ /// when rolling over on date.
+ /// </summary>
+ /// <value>
+ /// The date pattern to be used for generating file names when rolling
+ /// over on date.
+ /// </value>
+ /// <remarks>
+ /// <para>
+ /// Takes a string in the same format as expected by
+ /// <see cref="log4net.DateFormatter.SimpleDateFormatter" />.
+ /// </para>
+ /// <para>
+ /// This property determines the rollover schedule when rolling over
+ /// on date.
+ /// </para>
+ /// </remarks>
+ public string DatePattern
+ {
+ get { return m_datePattern; }
+ set { m_datePattern = value; }
+ }
- /// <summary>
- /// Gets or sets the maximum number of backup files that are kept before
- /// the oldest is erased.
- /// </summary>
- /// <value>
- /// The maximum number of backup files that are kept before the oldest is
- /// erased.
- /// </value>
- /// <remarks>
- /// <para>
- /// If set to zero, then there will be no backup files and the log file
- /// will be truncated when it reaches <see cref="MaxFileSize"/>.
- /// </para>
- /// <para>
- /// If a negative number is supplied then no deletions will be made. Note
- /// that this could result in very slow performance as a large number of
- /// files are rolled over unless <see cref="CountDirection"/> is used.
- /// </para>
- /// <para>
- /// The maximum applies to <b>each</b> time based group of files and
- /// <b>not</b> the total.
- /// </para>
- /// </remarks>
- public int MaxSizeRollBackups
- {
- get { return m_maxSizeRollBackups; }
- set { m_maxSizeRollBackups = value; }
- }
+ /// <summary>
+ /// Gets or sets the maximum number of backup files that are kept before
+ /// the oldest is erased.
+ /// </summary>
+ /// <value>
+ /// The maximum number of backup files that are kept before the oldest is
+ /// erased.
+ /// </value>
+ /// <remarks>
+ /// <para>
+ /// If set to zero, then there will be no backup files and the log file
+ /// will be truncated when it reaches <see cref="MaxFileSize"/>.
+ /// </para>
+ /// <para>
+ /// If a negative number is supplied then no deletions will be made. Note
+ /// that this could result in very slow performance as a large number of
+ /// files are rolled over unless <see cref="CountDirection"/> is used.
+ /// </para>
+ /// <para>
+ /// The maximum applies to <b>each</b> time based group of files and
+ /// <b>not</b> the total.
+ /// </para>
+ /// </remarks>
+ public int MaxSizeRollBackups
+ {
+ get { return m_maxSizeRollBackups; }
+ set { m_maxSizeRollBackups = value; }
+ }
- /// <summary>
- /// Gets or sets the maximum size that the output file is allowed to reach
- /// before being rolled over to backup files.
- /// </summary>
- /// <value>
- /// The maximum size in bytes that the output file is allowed to reach before being
- /// rolled over to backup files.
- /// </value>
- /// <remarks>
- /// <para>
- /// This property is equivalent to <see cref="MaximumFileSize"/> except
- /// that it is required for differentiating the setter taking a
- /// <see cref="long"/> argument from the setter taking a <see cref="string"/>
- /// argument.
- /// </para>
- /// <para>
- /// The default maximum file size is 10MB (10*1024*1024).
- /// </para>
- /// </remarks>
- public long MaxFileSize
- {
- get { return m_maxFileSize; }
- set { m_maxFileSize = value; }
- }
+ /// <summary>
+ /// Gets or sets the maximum size that the output file is allowed to reach
+ /// before being rolled over to backup files.
+ /// </summary>
+ /// <value>
+ /// The maximum size in bytes that the output file is allowed to reach before being
+ /// rolled over to backup files.
+ /// </value>
+ /// <remarks>
+ /// <para>
+ /// This property is equivalent to <see cref="MaximumFileSize"/> except
+ /// that it is required for differentiating the setter taking a
+ /// <see cref="long"/> argument from the setter taking a <see cref="string"/>
+ /// argument.
+ /// </para>
+ /// <para>
+ /// The default maximum file size is 10MB (10*1024*1024).
+ /// </para>
+ /// </remarks>
+ public long MaxFileSize
+ {
+ get { return m_maxFileSize; }
+ set { m_maxFileSize = value; }
+ }
- /// <summary>
- /// Gets or sets the maximum size that the output file is allowed to reach
- /// before being rolled over to backup files.
- /// </summary>
- /// <value>
- /// The maximum size that the output file is allowed to reach before being
- /// rolled over to backup files.
- /// </value>
- /// <remarks>
- /// <para>
- /// This property allows you to specify the maximum size with the
- /// suffixes "KB", "MB" or "GB" so that the size is interpreted being
- /// expressed respectively in kilobytes, megabytes or gigabytes.
- /// </para>
- /// <para>
- /// For example, the value "10KB" will be interpreted as 10240 bytes.
- /// </para>
- /// <para>
- /// The default maximum file size is 10MB.
- /// </para>
- /// <para>
- /// If you have the option to set the maximum file size programmatically
- /// consider using the <see cref="MaxFileSize"/> property instead as this
- /// allows you to set the size in bytes as a <see cref="Int64"/>.
- /// </para>
- /// </remarks>
- public string MaximumFileSize
- {
- get { return m_maxFileSize.ToString(NumberFormatInfo.InvariantInfo); }
- set { m_maxFileSize = OptionConverter.ToFileSize(value, m_maxFileSize + 1); }
- }
+ /// <summary>
+ /// Gets or sets the maximum size that the output file is allowed to reach
+ /// before being rolled over to backup files.
+ /// </summary>
+ /// <value>
+ /// The maximum size that the output file is allowed to reach before being
+ /// rolled over to backup files.
+ /// </value>
+ /// <remarks>
+ /// <para>
+ /// This property allows you to specify the maximum size with the
+ /// suffixes "KB", "MB" or "GB" so that the size is interpreted being
+ /// expressed respectively in kilobytes, megabytes or gigabytes.
+ /// </para>
+ /// <para>
+ /// For example, the value "10KB" will be interpreted as 10240 bytes.
+ /// </para>
+ /// <para>
+ /// The default maximum file size is 10MB.
+ /// </para>
+ /// <para>
+ /// If you have the option to set the maximum file size programmatically
+ /// consider using the <see cref="MaxFileSize"/> property instead as this
+ /// allows you to set the size in bytes as a <see cref="Int64"/>.
+ /// </para>
+ /// </remarks>
+ public string MaximumFileSize
+ {
+ get { return m_maxFileSize.ToString(NumberFormatInfo.InvariantInfo); }
+ set { m_maxFileSize = OptionConverter.ToFileSize(value, m_maxFileSize + 1); }
+ }
- /// <summary>
- /// Gets or sets the rolling file count direction.
- /// </summary>
- /// <value>
- /// The rolling file count direction.
- /// </value>
- /// <remarks>
- /// <para>
- /// Indicates if the current file is the lowest numbered file or the
- /// highest numbered file.
- /// </para>
- /// <para>
- /// By default newer files have lower numbers (<see cref="CountDirection" /> < 0),
- /// i.e. log.1 is most recent, log.5 is the 5th backup, etc...
- /// </para>
- /// <para>
- /// <see cref="CountDirection" /> >= 0 does the opposite i.e.
- /// log.1 is the first backup made, log.5 is the 5th backup made, etc.
- /// For infinite backups use <see cref="CountDirection" /> >= 0 to reduce
- /// rollover costs.
- /// </para>
- /// <para>The default file count direction is -1.</para>
- /// </remarks>
- public int CountDirection
- {
- get { return m_countDirection; }
- set { m_countDirection = value; }
- }
+ /// <summary>
+ /// Gets or sets the rolling file count direction.
+ /// </summary>
+ /// <value>
+ /// The rolling file count direction.
+ /// </value>
+ /// <remarks>
+ /// <para>
+ /// Indicates if the current file is the lowest numbered file or the
+ /// highest numbered file.
+ /// </para>
+ /// <para>
+ /// By default newer files have lower numbers (<see cref="CountDirection" /> < 0),
+ /// i.e. log.1 is most recent, log.5 is the 5th backup, etc...
+ /// </para>
+ /// <para>
+ /// <see cref="CountDirection" /> >= 0 does the opposite i.e.
+ /// log.1 is the first backup made, log.5 is the 5th backup made, etc.
+ /// For infinite backups use <see cref="CountDirection" /> >= 0 to reduce
+ /// rollover costs.
+ /// </para>
+ /// <para>The default file count direction is -1.</para>
+ /// </remarks>
+ public int CountDirection
+ {
+ get { return m_countDirection; }
+ set { m_countDirection = value; }
+ }
- /// <summary>
- /// Gets or sets the rolling style.
- /// </summary>
- /// <value>The rolling style.</value>
- /// <remarks>
- /// <para>
- /// The default rolling style is <see cref="RollingMode.Composite" />.
- /// </para>
- /// <para>
- /// When set to <see cref="RollingMode.Once"/> this appender's
- /// <see cref="FileAppender.AppendToFile"/> property is set to <c>false</c>, otherwise
- /// the appender would append to a single file rather than rolling
- /// the file each time it is opened.
- /// </para>
- /// </remarks>
- public RollingMode RollingStyle
- {
- get { return m_rollingStyle; }
- set
- {
- m_rollingStyle = value;
- switch (m_rollingStyle)
- {
- case RollingMode.Once:
- m_rollDate = false;
- m_rollSize = false;
+ /// <summary>
+ /// Gets or sets the rolling style.
+ /// </summary>
+ /// <value>The rolling style.</value>
+ /// <remarks>
+ /// <para>
+ /// The default rolling style is <see cref="RollingMode.Composite" />.
+ /// </para>
+ /// <para>
+ /// When set to <see cref="RollingMode.Once"/> this appender's
+ /// <see cref="FileAppender.AppendToFile"/> property is set to <c>false</c>, otherwise
+ /// the appender would append to a single file rather than rolling
+ /// the file each time it is opened.
+ /// </para>
+ /// </remarks>
+ public RollingMode RollingStyle
+ {
+ get { return m_rollingStyle; }
+ set
+ {
+ m_rollingStyle = value;
+ switch (m_rollingStyle)
+ {
+ case RollingMode.Once:
+ m_rollDate = false;
+ m_rollSize = false;
- AppendToFile = false;
- break;
+ AppendToFile = false;
+ break;
- case RollingMode.Size:
- m_rollDate = false;
- m_rollSize = true;
- break;
+ case RollingMode.Size:
+ m_rollDate = false;
+ m_rollSize = true;
+ break;
- case RollingMode.Date:
- m_rollDate = true;
- m_rollSize = false;
- break;
+ case RollingMode.Date:
+ m_rollDate = true;
+ m_rollSize = false;
+ break;
- case RollingMode.Composite:
- m_rollDate = true;
- m_rollSize = true;
- break;
- }
- }
- }
+ case RollingMode.Composite:
+ m_rollDate = true;
+ m_rollSize = true;
+ break;
+ }
+ }
+ }
/// <summary>
/// Gets or sets a value indicating whether to preserve the file name extension when rolling.
@@ -511,270 +511,270 @@
set { m_preserveLogFileNameExtension = value; }
}
- /// <summary>
- /// Gets or sets a value indicating whether to always log to
- /// the same file.
- /// </summary>
- /// <value>
- /// <c>true</c> if always should be logged to the same file, otherwise <c>false</c>.
- /// </value>
- /// <remarks>
- /// <para>
- /// By default file.log is always the current file. Optionally
- /// file.log.yyyy-mm-dd for current formatted datePattern can by the currently
- /// logging file (or file.log.curSizeRollBackup or even
- /// file.log.yyyy-mm-dd.curSizeRollBackup).
- /// </para>
- /// <para>
- /// This will make time based rollovers with a large number of backups
- /// much faster as the appender it won't have to rename all the backups!
- /// </para>
- /// </remarks>
- public bool StaticLogFileName
- {
- get { return m_staticLogFileName; }
- set { m_staticLogFileName = value; }
- }
+ /// <summary>
+ /// Gets or sets a value indicating whether to always log to
+ /// the same file.
+ /// </summary>
+ /// <value>
+ /// <c>true</c> if always should be logged to the same file, otherwise <c>false</c>.
+ /// </value>
+ /// <remarks>
+ /// <para>
+ /// By default file.log is always the current file. Optionally
+ /// file.log.yyyy-mm-dd for current formatted datePattern can by the currently
+ /// logging file (or file.log.curSizeRollBackup or even
+ /// file.log.yyyy-mm-dd.curSizeRollBackup).
+ /// </para>
+ /// <para>
+ /// This will make time based rollovers with a large number of backups
+ /// much faster as the appender it won't have to rename all the backups!
+ /// </para>
+ /// </remarks>
+ public bool StaticLogFileName
+ {
+ get { return m_staticLogFileName; }
+ set { m_staticLogFileName = value; }
+ }
- #endregion Public Instance Properties
+ #endregion Public Instance Properties
- #region Private Static Fields
+ #region Private Static Fields
- /// <summary>
- /// The fully qualified type of the RollingFileAppender class.
- /// </summary>
- /// <remarks>
- /// Used by the internal logger to record the Type of the
- /// log message.
- /// </remarks>
- private static readonly Type declaringType = typeof(RollingFileAppender);
+ /// <summary>
+ /// The fully qualified type of the RollingFileAppender class.
+ /// </summary>
+ /// <remarks>
+ /// Used by the internal logger to record the Type of the
+ /// log message.
+ /// </remarks>
+ private static readonly Type declaringType = typeof(RollingFileAppender);
- #endregion Private Static Fields
+ #endregion Private Static Fields
- #region Override implementation of FileAppender
+ #region Override implementation of FileAppender
- /// <summary>
- /// Sets the quiet writer being used.
- /// </summary>
- /// <remarks>
- /// This method can be overridden by sub classes.
- /// </remarks>
- /// <param name="writer">the writer to set</param>
- protected override void SetQWForFiles(TextWriter writer)
- {
- QuietWriter = new CountingQuietTextWriter(writer, ErrorHandler);
- }
+ /// <summary>
+ /// Sets the quiet writer being used.
+ /// </summary>
+ /// <remarks>
+ /// This method can be overridden by sub classes.
+ /// </remarks>
+ /// <param name="writer">the writer to set</param>
+ protected override void SetQWForFiles(TextWriter writer)
+ {
+ QuietWriter = new CountingQuietTextWriter(writer, ErrorHandler);
+ }
- /// <summary>
- /// Write out a logging event.
- /// </summary>
- /// <param name="loggingEvent">the event to write to file.</param>
- /// <remarks>
- /// <para>
- /// Handles append time behavior for RollingFileAppender. This checks
- /// if a roll over either by date (checked first) or time (checked second)
- /// is need and then appends to the file last.
- /// </para>
- /// </remarks>
- protected override void Append(LoggingEvent loggingEvent)
- {
- AdjustFileBeforeAppend();
- base.Append(loggingEvent);
- }
+ /// <summary>
+ /// Write out a logging event.
+ /// </summary>
+ /// <param name="loggingEvent">the event to write to file.</param>
+ /// <remarks>
+ /// <para>
+ /// Handles append time behavior for RollingFileAppender. This checks
+ /// if a roll over either by date (checked first) or time (checked second)
+ /// is need and then appends to the file last.
+ /// </para>
+ /// </remarks>
+ protected override void Append(LoggingEvent loggingEvent)
+ {
+ AdjustFileBeforeAppend();
+ base.Append(loggingEvent);
+ }
- /// <summary>
- /// Write out an array of logging events.
- /// </summary>
- /// <param name="loggingEvents">the events to write to file.</param>
- /// <remarks>
- /// <para>
- /// Handles append time behavior for RollingFileAppender. This checks
- /// if a roll over either by date (checked first) or time (checked second)
- /// is need and then appends to the file last.
- /// </para>
- /// </remarks>
- protected override void Append(LoggingEvent[] loggingEvents)
- {
- AdjustFileBeforeAppend();
- base.Append(loggingEvents);
- }
+ /// <summary>
+ /// Write out an array of logging events.
+ /// </summary>
+ /// <param name="loggingEvents">the events to write to file.</param>
+ /// <remarks>
+ /// <para>
+ /// Handles append time behavior for RollingFileAppender. This checks
+ /// if a roll over either by date (checked first) or time (checked second)
+ /// is need and then appends to the file last.
+ /// </para>
+ /// </remarks>
+ protected override void Append(LoggingEvent[] loggingEvents)
+ {
+ AdjustFileBeforeAppend();
+ base.Append(loggingEvents);
+ }
- /// <summary>
- /// Performs any required rolling before outputting the next event
- /// </summary>
- /// <remarks>
- /// <para>
- /// Handles append time behavior for RollingFileAppender. This checks
- /// if a roll over either by date (checked first) or time (checked second)
- /// is need and then appends to the file last.
- /// </para>
- /// </remarks>
- protected virtual void AdjustFileBeforeAppend()
- {
- // reuse the file appenders locking model to lock the rolling
+ /// <summary>
+ /// Performs any required rolling before outputting the next event
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Handles append time behavior for RollingFileAppender. This checks
+ /// if a roll over either by date (checked first) or time (checked second)
+ /// is need and then appends to the file last.
+ /// </para>
+ /// </remarks>
+ protected virtual void AdjustFileBeforeAppend()
+ {
+ // reuse the file appenders locking model to lock the rolling
#if !NETCF
- try
- {
- // if rolling should be locked, acquire the lock
- if (m_mutexForRolling != null)
- {
- m_mutexForRolling.WaitOne();
- }
+ try
+ {
+ // if rolling should be locked, acquire the lock
+ if (m_mutexForRolling != null)
+ {
+ m_mutexForRolling.WaitOne();
+ }
#endif
- if (m_rollDate)
- {
- var n = m_dateTime.Now;
- if (n >= m_nextCheck)
- {
- m_now = n;
- m_nextCheck = NextCheckDate(m_now, m_rollPoint);
+ if (m_rollDate)
+ {
+ var n = m_dateTime.Now;
+ if (n >= m_nextCheck)
+ {
+ m_now = n;
+ m_nextCheck = NextCheckDate(m_now, m_rollPoint);
- RollOverTime(true);
- }
- }
+ RollOverTime(true);
+ }
+ }
- if (m_rollSize)
- {
- if ((File != null) && ((CountingQuietTextWriter)QuietWriter).Count >= m_maxFileSize)
- {
- RollOverSize();
- }
- }
+ if (m_rollSize)
+ {
+ if ((File != null) && ((CountingQuietTextWriter)QuietWriter).Count >= m_maxFileSize)
+ {
+ RollOverSize();
+ }
+ }
#if !NETCF
- }
- finally
- {
- // if rolling should be locked, release the lock
- if (m_mutexForRolling != null)
- {
- m_mutexForRolling.ReleaseMutex();
- }
- }
+ }
+ finally
+ {
+ // if rolling should be locked, release the lock
+ if (m_mutexForRolling != null)
+ {
+ m_mutexForRolling.ReleaseMutex();
+ }
+ }
#endif
- }
+ }
- /// <summary>
- /// Creates and opens the file for logging. If <see cref="StaticLogFileName"/>
- /// is false then the fully qualified name is determined and used.
- /// </summary>
- /// <param name="fileName">the name of the file to open</param>
- /// <param name="append">true to append to existing file</param>
- /// <remarks>
- /// <para>This method will ensure that the directory structure
- /// for the <paramref name="fileName"/> specified exists.</para>
- /// </remarks>
- protected override void OpenFile(string fileName, bool append)
- {
- lock(this)
- {
- fileName = GetNextOutputFileName(fileName);
+ /// <summary>
+ /// Creates and opens the file for logging. If <see cref="StaticLogFileName"/>
+ /// is false then the fully qualified name is determined and used.
+ /// </summary>
+ /// <param name="fileName">the name of the file to open</param>
+ /// <param name="append">true to append to existing file</param>
+ /// <remarks>
+ /// <para>This method will ensure that the directory structure
+ /// for the <paramref name="fileName"/> specified exists.</para>
+ /// </remarks>
+ protected override void OpenFile(string fileName, bool append)
+ {
+ lock(this)
+ {
+ fileName = GetNextOutputFileName(fileName);
- // Calculate the current size of the file
- long currentCount = 0;
- if (append)
- {
- using(SecurityContext.Impersonate(this))
- {
- if (System.IO.File.Exists(fileName))
- {
- currentCount = (new FileInfo(fileName)).Length;
- }
- }
- }
- else
- {
- if (LogLog.IsErrorEnabled)
- {
- // Internal check that the file is not being overwritten
- // If not Appending to an existing file we should have rolled the file out of the
- // way. Therefore we should not be over-writing an existing file.
- // The only exception is if we are not allowed to roll the existing file away.
- if (m_maxSizeRollBackups != 0 && FileExists(fileName))
- {
- LogLog.Error(declaringType, "RollingFileAppender: INTERNAL ERROR. Append is False but OutputFile ["+fileName+"] already exists.");
- }
- }
- }
+ // Calculate the current size of the file
+ long currentCount = 0;
+ if (append)
+ {
+ using(SecurityContext.Impersonate(this))
+ {
+ if (System.IO.File.Exists(fileName))
+ {
+ currentCount = (new FileInfo(fileName)).Length;
+ }
+ }
+ }
+ else
+ {
+ if (LogLog.IsErrorEnabled)
+ {
+ // Internal check that the file is not being overwritten
+ // If not Appending to an existing file we should have rolled the file out of the
+ // way. Therefore we should not be over-writing an existing file.
+ // The only exception is if we are not allowed to roll the existing file away.
+ if (m_maxSizeRollBackups != 0 && FileExists(fileName))
+ {
+ LogLog.Error(declaringType, "RollingFileAppender: INTERNAL ERROR. Append is False but OutputFile ["+fileName+"] already exists.");
+ }
+ }
+ }
- if (!m_staticLogFileName)
- {
- m_scheduledFilename = fileName;
- }
+ if (!m_staticLogFileName)
+ {
+ m_scheduledFilename = fileName;
+ }
- // Open the file (call the base class to do it)
- base.OpenFile(fileName, append);
+ // Open the file (call the base class to do it)
+ base.OpenFile(fileName, append);
- // Set the file size onto the counting writer
- ((CountingQuietTextWriter)QuietWriter).Count = currentCount;
- }
- }
+ // Set the file size onto the counting writer
+ ((CountingQuietTextWriter)QuietWriter).Count = currentCount;
+ }
+ }
- /// <summary>
- /// Get the current output file name
- /// </summary>
- /// <param name="fileName">the base file name</param>
- /// <returns>the output file name</returns>
- /// <remarks>
- /// The output file name is based on the base fileName specified.
- /// If <see cref="StaticLogFileName"/> is set then the output
- /// file name is the same as the base file passed in. Otherwise
- /// the output file depends on the date pattern, on the count
- /// direction or both.
- /// </remarks>
- protected string GetNextOutputFileName(string fileName)
- {
- if (!m_staticLogFileName)
- {
- fileName = fileName.Trim();
+ /// <summary>
+ /// Get the current output file name
+ /// </summary>
+ /// <param name="fileName">the base file name</param>
+ /// <returns>the output file name</returns>
+ /// <remarks>
+ /// The output file name is based on the base fileName specified.
+ /// If <see cref="StaticLogFileName"/> is set then the output
+ /// file name is the same as the base file passed in. Otherwise
+ /// the output file depends on the date pattern, on the count
+ /// direction or both.
+ /// </remarks>
+ protected string GetNextOutputFileName(string fileName)
+ {
+ if (!m_staticLogFileName)
+ {
+ fileName = fileName.Trim();
- if (m_rollDate)
- {
+ if (m_rollDate)
+ {
fileName = CombinePath(fileName, m_now.ToString(m_datePattern, DateTimeFormatInfo.InvariantInfo));
- }
+ }
- if (m_countDirection >= 0)
- {
+ if (m_countDirection >= 0)
+ {
fileName = CombinePath(fileName, "." + m_curSizeRollBackups);
- }
- }
+ }
+ }
- return fileName;
- }
+ return fileName;
+ }
- #endregion
+ #endregion
- #region Initialize Options
+ #region Initialize Options
- /// <summary>
- /// Determines curSizeRollBackups (only within the current roll point)
- /// </summary>
- private void DetermineCurSizeRollBackups()
- {
- m_curSizeRollBackups = 0;
-
- string fullPath = null;
- string fileName = null;
+ /// <summary>
+ /// Determines curSizeRollBackups (only within the current roll point)
+ /// </summary>
+ private void DetermineCurSizeRollBackups()
+ {
+ m_curSizeRollBackups = 0;
+
+ string fullPath = null;
+ string fileName = null;
- using(SecurityContext.Impersonate(this))
- {
- fullPath = Path.GetFullPath(m_baseFileName);
- fileName = Path.GetFileName(fullPath);
- }
+ using(SecurityContext.Impersonate(this))
+ {
+ fullPath = Path.GetFullPath(m_baseFileName);
+ fileName = Path.GetFileName(fullPath);
+ }
- var arrayFiles = GetExistingFiles(fullPath);
- InitializeRollBackups(fileName, arrayFiles);
+ var arrayFiles = GetExistingFiles(fullPath);
+ InitializeRollBackups(fileName, arrayFiles);
- LogLog.Debug(declaringType, "curSizeRollBackups starts at ["+m_curSizeRollBackups+"]");
- }
+ LogLog.Debug(declaringType, "curSizeRollBackups starts at ["+m_curSizeRollBackups+"]");
+ }
- /// <summary>
- /// Generates a wildcard pattern that can be used to find all files
- /// that are similar to the base file name.
- /// </summary>
- /// <param name="baseFileName"></param>
- /// <returns></returns>
- private string GetWildcardPatternForFile(string baseFileName)
- {
+ /// <summary>
+ /// Generates a wildcard pattern that can be used to find all files
+ /// that are similar to the base file name.
+ /// </summary>
+ /// <param name="baseFileName"></param>
+ /// <returns></returns>
+ private string GetWildcardPatternForFile(string baseFileName)
+ {
if (m_preserveLogFileNameExtension)
{
return Path.GetFileNameWithoutExtension(baseFileName) + "*" + Path.GetExtension(baseFileName);
@@ -783,178 +783,178 @@
{
return baseFileName + '*';
}
- }
+ }
- /// <summary>
- /// Builds a list of filenames for all files matching the base filename plus a file
- /// pattern.
- /// </summary>
- /// <param name="baseFilePath"></param>
- /// <returns></returns>
- private ArrayList GetExistingFiles(string baseFilePath)
- {
- var alFiles = new ArrayList();
+ /// <summary>
+ /// Builds a list of filenames for all files matching the base filename plus a file
+ /// pattern.
+ /// </summary>
+ /// <param name="baseFilePath"></param>
+ /// <returns></returns>
+ private ArrayList GetExistingFiles(string baseFilePath)
+ {
+ var alFiles = new ArrayList();
- string directory = null;
+ string directory = null;
- using(SecurityContext.Impersonate(this))
- {
- var fullPath = Path.GetFullPath(baseFilePath);
+ using(SecurityContext.Impersonate(this))
+ {
+ var fullPath = Path.GetFullPath(baseFilePath);
- directory = Path.GetDirectoryName(fullPath);
- if (Directory.Exists(directory))
- {
- var baseFileName = Path.GetFileName(fullPath);
+ directory = Path.GetDirectoryName(fullPath);
+ if (Directory.Exists(directory))
+ {
+ var baseFileName = Path.GetFileName(fullPath);
- var files = Directory.GetFiles(directory, GetWildcardPatternForFile(baseFileName));
-
- if (files != null)
- {
- for (var i = 0; i < files.Length; i++)
- {
- var curFileName = Path.GetFileName(files[i]);
- if (curFileName.StartsWith(Path.GetFileNameWithoutExtension(baseFileName)))
- {
- alFiles.Add(curFileName);
- }
- }
- }
- }
- }
- LogLog.Debug(declaringType, "Searched for existing files in ["+directory+"]");
- return alFiles;
- }
+ var files = Directory.GetFiles(directory, GetWildcardPatternForFile(baseFileName));
+
+ if (files != null)
+ {
+ for (var i = 0; i < files.Length; i++)
+ {
+ var curFileName = Path.GetFileName(files[i]);
+ if (curFileName.StartsWith(Path.GetFileNameWithoutExtension(baseFileName)))
+ {
+ alFiles.Add(curFileName);
+ }
+ }
+ }
+ }
+ }
+ LogLog.Debug(declaringType, "Searched for existing files in ["+directory+"]");
+ return alFiles;
+ }
- /// <summary>
- /// Initiates a roll over if needed for crossing a date boundary since the last run.
- /// </summary>
- private void RollOverIfDateBoundaryCrossing()
- {
- if (m_staticLogFileName && m_rollDate)
- {
- if (FileExists(m_baseFileName))
- {
- DateTime last;
- using(SecurityContext.Impersonate(this)) {
+ /// <summary>
+ /// Initiates a roll over if needed for crossing a date boundary since the last run.
+ /// </summary>
+ private void RollOverIfDateBoundaryCrossing()
+ {
+ if (m_staticLogFileName && m_rollDate)
+ {
+ if (FileExists(m_baseFileName))
+ {
+ DateTime last;
+ using(SecurityContext.Impersonate(this)) {
#if !NET_1_0 && !CLI_1_0 && !NETCF
if (DateTimeStrategy is UniversalDateTime)
- {
- last = System.IO.File.GetLastWriteTimeUtc(m_baseFileName);
- }
- else
- {
+ {
+ last = System.IO.File.GetLastWriteTimeUtc(m_baseFileName);
+ }
+ else
+ {
#endif
- last = System.IO.File.GetLastWriteTime(m_baseFileName);
+ last = System.IO.File.GetLastWriteTime(m_baseFileName);
#if !NET_1_0 && !CLI_1_0 && !NETCF
}
#endif
}
- LogLog.Debug(declaringType, "["+last.ToString(m_datePattern,DateTimeFormatInfo.InvariantInfo)+"] vs. ["+m_now.ToString(m_datePattern,DateTimeFormatInfo.InvariantInfo)+"]");
+ LogLog.Debug(declaringType, "["+last.ToString(m_datePattern,DateTimeFormatInfo.InvariantInfo)+"] vs. ["+m_now.ToString(m_datePattern,DateTimeFormatInfo.InvariantInfo)+"]");
- if (!(last.ToString(m_datePattern,DateTimeFormatInfo.InvariantInfo).Equals(m_now.ToString(m_datePattern, DateTimeFormatInfo.InvariantInfo))))
- {
- m_scheduledFilename = CombinePath(m_baseFileName, last.ToString(m_datePattern, DateTimeFormatInfo.InvariantInfo));
- LogLog.Debug(declaringType, "Initial roll over to ["+m_scheduledFilename+"]");
- RollOverTime(false);
- LogLog.Debug(declaringType, "curSizeRollBackups after rollOver at ["+m_curSizeRollBackups+"]");
- }
- }
- }
- }
+ if (!(last.ToString(m_datePattern,DateTimeFormatInfo.InvariantInfo).Equals(m_now.ToString(m_datePattern, DateTimeFormatInfo.InvariantInfo))))
+ {
+ m_scheduledFilename = CombinePath(m_baseFileName, last.ToString(m_datePattern, DateTimeFormatInfo.InvariantInfo));
+ LogLog.Debug(declaringType, "Initial roll over to ["+m_scheduledFilename+"]");
+ RollOverTime(false);
+ LogLog.Debug(declaringType, "curSizeRollBackups after rollOver at ["+m_curSizeRollBackups+"]");
+ }
+ }
+ }
+ }
- /// <summary>
- /// Initializes based on existing conditions at time of <see cref="ActivateOptions"/>.
- /// </summary>
- /// <remarks>
- /// <para>
- /// Initializes based on existing conditions at time of <see cref="ActivateOptions"/>.
- /// The following is done
- /// <list type="bullet">
- /// <item>determine curSizeRollBackups (only within the current roll point)</item>
- /// <item>initiates a roll over if needed for crossing a date boundary since the last run.</item>
- /// </list>
- /// </para>
- /// </remarks>
- protected void ExistingInit()
- {
- DetermineCurSizeRollBackups();
- RollOverIfDateBoundaryCrossing();
+ /// <summary>
+ /// Initializes based on existing conditions at time of <see cref="ActivateOptions"/>.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Initializes based on existing conditions at time of <see cref="ActivateOptions"/>.
+ /// The following is done
+ /// <list type="bullet">
+ /// <item>determine curSizeRollBackups (only within the current roll point)</item>
+ /// <item>initiates a roll over if needed for crossing a date boundary since the last run.</item>
+ /// </list>
+ /// </para>
+ /// </remarks>
+ protected void ExistingInit()
+ {
+ DetermineCurSizeRollBackups();
+ RollOverIfDateBoundaryCrossing();
- // If file exists and we are not appending then roll it out of the way
- if (AppendToFile != false)
- {
- return;
- }
+ // If file exists and we are not appending then roll it out of the way
+ if (AppendToFile != false)
+ {
+ return;
+ }
- bool fileExists;
- var fileName = GetNextOutputFileName(m_baseFileName);
+ bool fileExists;
+ var fileName = GetNextOutputFileName(m_baseFileName);
- using(SecurityContext.Impersonate(this))
- {
- fileExists = System.IO.File.Exists(fileName);
- }
+ using(SecurityContext.Impersonate(this))
+ {
+ fileExists = System.IO.File.Exists(fileName);
+ }
- if (!fileExists)
- {
- return;
- }
+ if (!fileExists)
+ {
+ return;
+ }
- if (m_maxSizeRollBackups == 0)
- {
- LogLog.Debug(declaringType, "Output file ["+fileName+"] already exists. MaxSizeRollBackups is 0; cannot roll. Overwriting existing file.");
- }
- else
- {
- LogLog.Debug(declaringType, "Output file ["+fileName+"] already exists. Not appending to file. Rolling existing file out of the way.");
+ if (m_maxSizeRollBackups == 0)
+ {
+ LogLog.Debug(declaringType, "Output file ["+fileName+"] already exists. MaxSizeRollBackups is 0; cannot roll. Overwriting existing file.");
+ }
+ else
+ {
+ LogLog.Debug(declaringType, "Output file ["+fileName+"] already exists. Not appending to file. Rolling existing file out of the way.");
- RollOverRenameFiles(fileName);
- }
- }
+ RollOverRenameFiles(fileName);
+ }
+ }
- /// <summary>
- /// Does the work of bumping the 'current' file counter higher
- /// to the highest count when an incremental file name is seen.
- /// The highest count is either the first file (when count direction
- /// is greater than 0) or the last file (when count direction less than 0).
- /// In either case, we want to know the highest count that is present.
- /// </summary>
- /// <param name="baseFile"></param>
- /// <param name="curFileName"></param>
- private void InitializeFromOneFile(string baseFile, string curFileName)
- {
- curFileName = curFileName.ToLower();
- baseFile = baseFile.ToLower();
+ /// <summary>
+ /// Does the work of bumping the 'current' file counter higher
+ /// to the highest count when an incremental file name is seen.
+ /// The highest count is either the first file (when count direction
+ /// is greater than 0) or the last file (when count direction less than 0).
+ /// In either case, we want to know the highest count that is present.
+ /// </summary>
+ /// <param name="baseFile"></param>
+ /// <param name="curFileName"></param>
+ private void InitializeFromOneFile(string baseFile, string curFileName)
+ {
+ curFileName = curFileName.ToLower();
+ baseFile = baseFile.ToLower();
if (curFileName.StartsWith(Path.GetFileNameWithoutExtension(baseFile)) == false)
- {
- // This is not a log file, so ignore
- return;
- }
- if (curFileName.Equals(baseFile))
- {
- // Base log file is not an incremented logfile (.1 or .2, etc)
- return;
- }
-
- // Only look for files in the current roll point
- if (m_rollDate && !m_staticLogFileName)
- {
- var date = m_dateTime.Now.ToString(m_datePattern, DateTimeFormatInfo.InvariantInfo).ToLower();
- var prefix = (m_preserveLogFileNameExtension
- ? Path.GetFileNameWithoutExtension(baseFile) + date
- : baseFile + date).ToLower();
- var suffix = m_preserveLogFileNameExtension
- ? Path.GetExtension(baseFile).ToLower()
- : "";
- if (!curFileName.StartsWith(prefix) || !curFileName.EndsWith(suffix))
- {
- LogLog.Debug(declaringType, "Ignoring file ["+curFileName+"] because it is from a different date period");
- return;
- }
- }
+ {
+ // This is not a log file, so ignore
+ return;
+ }
+ if (curFileName.Equals(baseFile))
+ {
+ // Base log file is not an incremented logfile (.1 or .2, etc)
+ return;
+ }
+
+ // Only look for files in the current roll point
+ if (m_rollDate && !m_staticLogFileName)
+ {
+ var date = m_dateTime.Now.ToString(m_datePattern, DateTimeFormatInfo.InvariantInfo).ToLower();
+ var prefix = (m_preserveLogFileNameExtension
+ ? Path.GetFileNameWithoutExtension(baseFile) + date
+ : baseFile + date).ToLower();
+ var suffix = m_preserveLogFileNameExtension
+ ? Path.GetExtension(baseFile).ToLower()
+ : "";
+ if (!curFileName.StartsWith(prefix) || !curFileName.EndsWith(suffix))
+ {
+ LogLog.Debug(declaringType, "Ignoring file ["+curFileName+"] because it is from a different date period");
+ return;
+ }
+ }
- try
- {
- // Bump the counter up to the highest count seen so far
+ try
+ {
+ // Bump the counter up to the highest count seen so far
var backup = GetBackUpIndex(curFileName);
// caution: we might get a false positive when certain
@@ -991,14 +991,14 @@
}
LogLog.Debug(declaringType, "File name [" + curFileName + "] moves current count to [" + m_curSizeRollBackups + "]");
}
- }
- catch(FormatException)
- {
- //this happens when file.log -> file.log.yyyy-MM-dd which is normal
- //when staticLogFileName == false
- LogLog.Debug(declaringType, "Encountered a backup file not ending in .x ["+curFileName+"]");
- }
- }
+ }
+ catch(FormatException)
+ {
+ //this happens when file.log -> file.log.yyyy-MM-dd which is normal
+ //when staticLogFileName == false
+ LogLog.Debug(declaringType, "Encountered a backup file not ending in .x ["+curFileName+"]");
+ }
+ }
/// <summary>
/// Attempts to extract a number from the end of the file name that indicates
@@ -1009,8 +1009,8 @@
/// </remarks>
/// <param name="curFileName"></param>
/// <returns></returns>
- private int GetBackUpIndex(string curFileName)
- {
+ private int GetBackUpIndex(string curFileName)
+ {
var backUpIndex = -1;
var fileName = curFileName;
@@ -1028,156 +1028,156 @@
}
return backUpIndex;
- }
+ }
- /// <summary>
- /// Takes a list of files and a base file name, and looks for
- /// 'incremented' versions of the base file. Bumps the max
- /// count up to the highest count seen.
- /// </summary>
- /// <param name="baseFile"></param>
- /// <param name="arrayFiles"></param>
- private void InitializeRollBackups(string baseFile, ArrayList arrayFiles)
- {
- if (null != arrayFiles)
- {
- var baseFileLower = baseFile.ToLowerInvariant();
+ /// <summary>
+ /// Takes a list of files and a base file name, and looks for
+ /// 'incremented' versions of the base file. Bumps the max
+ /// count up to the highest count seen.
+ /// </summary>
+ /// <param name="baseFile"></param>
+ /// <param name="arrayFiles"></param>
+ private void InitializeRollBackups(string baseFile, ArrayList arrayFiles)
+ {
+ if (null != arrayFiles)
+ {
+ var baseFileLower = baseFile.ToLowerInvariant();
- foreach(string curFileName in arrayFiles)
- {
- InitializeFromOneFile(baseFileLower, curFileName.ToLowerInvariant());
- }
- }
- }
+ foreach(string curFileName in arrayFiles)
+ {
+ InitializeFromOneFile(baseFileLower, curFileName.ToLowerInvariant());
+ }
+ }
+ }
- /// <summary>
- /// Calculates the RollPoint for the datePattern supplied.
- /// </summary>
- /// <param name="datePattern">the date pattern to calculate the check period for</param>
- /// <returns>The RollPoint that is most accurate for the date pattern supplied</returns>
- /// <remarks>
- /// Essentially the date pattern is examined to determine what the
- /// most suitable roll point is. The roll point chosen is the roll point
- /// with the smallest period that can be detected using the date pattern
- /// supplied. i.e. if the date pattern only outputs the year, month, day
- /// and hour then the smallest roll point that can be detected would be
- /// and hourly roll point as minutes could not be detected.
- /// </remarks>
- private RollPoint ComputeCheckPeriod(string datePattern)
- {
- // s_date1970 is 1970-01-01 00:00:00 this is UniversalSortableDateTimePattern
- // (based on ISO 8601) using universal time. This date is used for reference
- // purposes to calculate the resolution of the date pattern.
+ /// <summary>
+ /// Calculates the RollPoint for the datePattern supplied.
+ /// </summary>
+ /// <param name="datePattern">the date pattern to calculate the check period for</param>
+ /// <returns>The RollPoint that is most accurate for the date pattern supplied</returns>
+ /// <remarks>
+ /// Essentially the date pattern is examined to determine what the
+ /// most suitable roll point is. The roll point chosen is the roll point
+ /// with the smallest period that can be detected using the date pattern
+ /// supplied. i.e. if the date pattern only outputs the year, month, day
+ /// and hour then the smallest roll point that can be detected would be
+ /// and hourly roll point as minutes could not be detected.
+ /// </remarks>
+ private RollPoint ComputeCheckPeriod(string datePattern)
+ {
+ // s_date1970 is 1970-01-01 00:00:00 this is UniversalSortableDateTimePattern
+ // (based on ISO 8601) using universal time. This date is used for reference
+ // purposes to calculate the resolution of the date pattern.
- // Get string representation of base line date
- var r0 = s_date1970.ToString(datePattern, DateTimeFormatInfo.InvariantInfo);
+ // Get string representation of base line date
+ var r0 = s_date1970.ToString(datePattern, DateTimeFormatInfo.InvariantInfo);
- // Check each type of rolling mode starting with the smallest increment.
- for(var i = (int)RollPoint.TopOfMinute; i <= (int)RollPoint.TopOfMonth; i++)
- {
- // Get string representation of next pattern
- var r1 = NextCheckDate(s_date1970, (RollPoint)i).ToString(datePattern, DateTimeFormatInfo.InvariantInfo);
+ // Check each type of rolling mode starting with the smallest increment.
+ for(var i = (int)RollPoint.TopOfMinute; i <= (int)RollPoint.TopOfMonth; i++)
+ {
+ // Get string representation of next pattern
+ var r1 = NextCheckDate(s_date1970, (RollPoint)i).ToString(datePattern, DateTimeFormatInfo.InvariantInfo);
- LogLog.Debug(declaringType, "Type = ["+i+"], r0 = ["+r0+"], r1 = ["+r1+"]");
+ LogLog.Debug(declaringType, "Type = ["+i+"], r0 = ["+r0+"], r1 = ["+r1+"]");
- // Check if the string representations are different
- if (r0 != null && r1 != null && !r0.Equals(r1))
- {
- // Found highest precision roll point
- return (RollPoint)i;
- }
- }
+ // Check if the string representations are different
+ if (r0 != null && r1 != null && !r0.Equals(r1))
+ {
+ // Found highest precision roll point
+ return (RollPoint)i;
+ }
+ }
- return RollPoint.InvalidRollPoint; // Deliberately head for trouble...
- }
+ return RollPoint.InvalidRollPoint; // Deliberately head for trouble...
+ }
- /// <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>
- /// <para>
- /// Sets initial conditions including date/time roll over information, first check,
- /// scheduledFilename, and calls <see cref="ExistingInit"/> to initialize
- /// the current number of backups.
- /// </para>
- /// </remarks>
- public override void ActivateOptions()
- {
- if (m_dateTime == null)
- {
- m_dateTime = new LocalDateTime();
- }
+ /// <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>
+ /// <para>
+ /// Sets initial conditions including date/time roll over information, first check,
+ /// scheduledFilename, and calls <see cref="ExistingInit"/> to initialize
+ /// the current number of backups.
+ /// </para>
+ /// </remarks>
+ public override void ActivateOptions()
+ {
+ if (m_dateTime == null)
+ {
+ m_dateTime = new LocalDateTime();
+ }
- if (m_rollDate && m_datePattern != null)
- {
- m_now = m_dateTime.Now;
- m_rollPoint = ComputeCheckPeriod(m_datePattern);
+ if (m_rollDate && m_datePattern != null)
+ {
+ m_now = m_dateTime.Now;
+ m_rollPoint = ComputeCheckPeriod(m_datePattern);
- if (m_rollPoint == RollPoint.InvalidRollPoint)
- {
- throw new ArgumentException("Invalid RollPoint, unable to parse ["+m_datePattern+"]");
- }
+ if (m_rollPoint == RollPoint.InvalidRollPoint)
+ {
+ throw new ArgumentException("Invalid RollPoint, unable to parse ["+m_datePattern+"]");
+ }
- // next line added as this removes the name check in rollOver
- m_nextCheck = NextCheckDate(m_now, m_rollPoint);
- }
- else
- {
- if (m_rollDate)
- {
- ErrorHandler.Error("Either DatePattern or rollingStyle options are not set for ["+Name+"].");
- }
- }
+ // next line added as this removes the name check in rollOver
+ m_nextCheck = NextCheckDate(m_now, m_rollPoint);
+ }
+ else
+ {
+ if (m_rollDate)
+ {
+ ErrorHandler.Error("Either DatePattern or rollingStyle options are not set for ["+Name+"].");
+ }
+ }
- if (SecurityContext == null)
- {
- SecurityContext = SecurityContextProvider.DefaultProvider.CreateSecurityContext(this);
- }
+ if (SecurityContext == null)
+ {
+ SecurityContext = SecurityContextProvider.DefaultProvider.CreateSecurityContext(this);
+ }
- using(SecurityContext.Impersonate(this))
- {
- // Must convert the FileAppender's m_filePath to an absolute path before we
- // call ExistingInit(). This will be done by the base.ActivateOptions() but
- // we need to duplicate that functionality here first.
- base.File = ConvertToFullPath(base.File.Trim());
+ using(SecurityContext.Impersonate(this))
+ {
+ // Must convert the FileAppender's m_filePath to an absolute path before we
+ // call ExistingInit(). This will be done by the base.ActivateOptions() but
+ // we need to duplicate that functionality here first.
+ base.File = ConvertToFullPath(base.File.Trim());
- // Store fully qualified base file name
- m_baseFileName = base.File;
- }
+ // Store fully qualified base file name
+ m_baseFileName = base.File;
+ }
#if !NETCF
- // initialize the mutex that is used to lock rolling
- m_mutexForRolling = new Mutex(false, m_baseFileName
- .Replace("\\", "_")
- .Replace(":", "_")
- .Replace("/", "_") + "_rolling"
- );
+ // initialize the mutex that is used to lock rolling
+ m_mutexForRolling = new Mutex(false, m_baseFileName
+ .Replace("\\", "_")
+ .Replace(":", "_")
+ .Replace("/", "_") + "_rolling"
+ );
#endif
- if (m_rollDate && File != null && m_scheduledFilename == null)
- {
+ if (m_rollDate && File != null && m_scheduledFilename == null)
+ {
m_scheduledFilename = CombinePath(File, m_now.ToString(m_datePattern, DateTimeFormatInfo.InvariantInfo));
- }
+ }
- ExistingInit();
-
- base.ActivateOptions();
- }
-
- #endregion
+ ExistingInit();
- #region Roll File
+ base.ActivateOptions();
+ }
+
+ #endregion
+
+ #region Roll File
/// <summary>
///
@@ -1198,596 +1198,596 @@
}
}
- /// <summary>
- /// Rollover the file(s) to date/time tagged file(s).
- /// </summary>
- /// <param name="fileIsOpen">set to true if the file to be rolled is currently open</param>
- /// <remarks>
- /// <para>
- /// Rollover the file(s) to date/time tagged file(s).
- /// Resets curSizeRollBackups.
- /// If fileIsOpen is set then the new file is opened (through SafeOpenFile).
- /// </para>
- /// </remarks>
- protected void RollOverTime(bool fileIsOpen)
- {
- if (m_staticLogFileName)
- {
- // Compute filename, but only if datePattern is specified
- if (m_datePattern == null)
- {
- ErrorHandler.Error("Missing DatePattern option in rollOver().");
- return;
- }
-
- //is the new file name equivalent to the 'current' one
- //something has gone wrong if we hit this -- we should only
- //roll over if the new file will be different from the old
- var dateFormat = m_now.ToString(m_datePattern, DateTimeFormatInfo.InvariantInfo);
+ /// <summary>
+ /// Rollover the file(s) to date/time tagged file(s).
+ /// </summary>
+ /// <param name="fileIsOpen">set to true if the file to be rolled is currently open</param>
+ /// <remarks>
+ /// <para>
+ /// Rollover the file(s) to date/time tagged file(s).
+ /// Resets curSizeRollBackups.
+ /// If fileIsOpen is set then the new file is opened (through SafeOpenFile).
+ /// </para>
+ /// </remarks>
+ protected void RollOverTime(bool fileIsOpen)
+ {
+ if (m_staticLogFileName)
+ {
+ // Compute filename, but only if datePattern is specified
+ if (m_datePattern == null)
+ {
+ ErrorHandler.Error("Missing DatePattern option in rollOver().");
+ return;
+ }
+
+ //is the new file name equivalent to the 'current' one
+ //something has gone wrong if we hit this -- we should only
+ //roll over if the new file will be different from the old
+ var dateFormat = m_now.ToString(m_datePattern, DateTimeFormatInfo.InvariantInfo);
if (m_scheduledFilename.Equals(CombinePath(File, dateFormat)))
- {
+ {
ErrorHandler.Error("Compare " + m_scheduledFilename + " : " + CombinePath(File, dateFormat));
- return;
- }
-
- if (fileIsOpen)
- {
- // close current file, and rename it to datedFilename
- CloseFile();
- }
-
- //we may have to roll over a large number of backups here
- for (var i = 1; i <= m_curSizeRollBackups; i++)
- {
+ return;
+ }
+
+ if (fileIsOpen)
+ {
+ // close current file, and rename it to datedFilename
+ CloseFile();
+ }
+
+ //we may have to roll over a large number of backups here
+ for (var i = 1; i <= m_curSizeRollBackups; i++)
+ {
var from = CombinePath(File, "." + i);
var to = CombinePath(m_scheduledFilename, "." + i);
- RollFile(from, to);
- }
-
- RollFile(File, m_scheduledFilename);
- }
-
- //We've cleared out the old date and are ready for the new
- m_curSizeRollBackups = 0;
-
- //new scheduled name
+ RollFile(from, to);
+ }
+
+ RollFile(File, m_scheduledFilename);
+ }
+
+ //We've cleared out the old date and are ready for the new
+ m_curSizeRollBackups = 0;
+
+ //new scheduled name
m_scheduledFilename = CombinePath(File, m_now.ToString(m_datePattern, DateTimeFormatInfo.InvariantInfo));
- if (fileIsOpen)
- {
- // This will also close the file. This is OK since multiple close operations are safe.
- SafeOpenFile(m_baseFileName, false);
- }
- }
+ if (fileIsOpen)
+ {
+ // This will also close the file. This is OK since multiple close operations are safe.
+ SafeOpenFile(m_baseFileName, false);
+ }
+ }
- /// <summary>
- /// Renames file <paramref name="fromFile"/> to file <paramref name="toFile"/>.
- /// </summary>
- /// <param name="fromFile">Name of existing file to roll.</param>
- /// <param name="toFile">New name for file.</param>
- /// <remarks>
- /// <para>
- /// Renames file <paramref name="fromFile"/> to file <paramref name="toFile"/>. It
- /// also checks for existence of target file and deletes if it does.
- /// </para>
- /// </remarks>
- protected void RollFile(string fromFile, string toFile)
- {
- if (FileExists(fromFile))
- {
- // Delete the toFile if it exists
- DeleteFile(toFile);
+ /// <summary>
+ /// Renames file <paramref name="fromFile"/> to file <paramref name="toFile"/>.
+ /// </summary>
+ /// <param name="fromFile">Name of existing file to roll.</param>
+ /// <param name="toFile">New name for file.</param>
+ /// <remarks>
+ /// <para>
+ /// Renames file <paramref name="fromFile"/> to file <paramref name="toFile"/>. It
+ /// also checks for existence of target file and deletes if it does.
+ /// </para>
+ /// </remarks>
+ protected void RollFile(string fromFile, string toFile)
+ {
+ if (FileExists(fromFile))
+ {
+ // Delete the toFile if it exists
+ DeleteFile(toFile);
- // We may not have permission to move the file, or the file may be locked
- try
- {
- LogLog.Debug(declaringType, "Moving [" + fromFile + "] -> [" + toFile + "]");
- using(SecurityContext.Impersonate(this))
- {
- System.IO.File.Move(fromFile, toFile);
- }
- }
- catch(Exception moveEx)
- {
- ErrorHandler.Error("Exception while rolling file [" + fromFile + "] -> [" + toFile + "]", moveEx, ErrorCode.GenericFailure);
- }
- }
- else
- {
- LogLog.Warn(declaringType, "Cannot RollFile [" + fromFile + "] -> [" + toFile + "]. Source does not exist");
- }
- }
+ // We may not have permission to move the file, or the file may be locked
+ try
+ {
+ LogLog.Debug(declaringType, "Moving [" + fromFile + "] -> [" + toFile + "]");
+ using(SecurityContext.Impersonate(this))
+ {
+ System.IO.File.Move(fromFile, toFile);
+ }
+ }
+ catch(Exception moveEx)
+ {
+ ErrorHandler.Error("Exception while rolling file [" + fromFile + "] -> [" + toFile + "]", moveEx, ErrorCode.GenericFailure);
+ }
+ }
+ else
+ {
+ LogLog.Warn(declaringType, "Cannot RollFile [" + fromFile + "] -> [" + toFile + "]. Source does not exist");
+ }
+ }
- /// <summary>
- /// Test if a file exists at a specified path
- /// </summary>
- /// <param name="path">the path to the file</param>
- /// <returns>true if the file exists</returns>
- /// <remarks>
- /// <para>
- /// Test if a file exists at a specified path
- /// </para>
- /// </remarks>
- protected bool FileExists(string path)
- {
- using(SecurityContext.Impersonate(this))
- {
- return System.IO.File.Exists(path);
- }
- }
+ /// <summary>
+ /// Test if a file exists at a specified path
+ /// </summary>
+ /// <param name="path">the path to the file</param>
+ /// <returns>true if the file exists</returns>
+ /// <remarks>
+ /// <para>
+ /// Test if a file exists at a specified path
+ /// </para>
+ /// </remarks>
+ protected bool FileExists(string path)
+ {
+ using(SecurityContext.Impersonate(this))
+ {
+ return System.IO.File.Exists(path);
+ }
+ }
- /// <summary>
- /// Deletes the specified file if it exists.
- /// </summary>
- /// <param name="fileName">The file to delete.</param>
- /// <remarks>
- /// <para>
- /// Delete a file if is exists.
- /// The file is first moved to a new filename then deleted.
- /// This allows the file to be removed even when it cannot
- /// be deleted, but it still can be moved.
- /// </para>
- /// </remarks>
- protected void DeleteFile(string fileName)
- {
- if (FileExists(fileName))
- {
- // We may not have permission to delete the file, or the file may be locked
+ /// <summary>
+ /// Deletes the specified file if it exists.
+ /// </summary>
+ /// <param name="fileName">The file to delete.</param>
+ /// <remarks>
+ /// <para>
+ /// Delete a file if is exists.
+ /// The file is first moved to a new filename then deleted.
+ /// This allows the file to be removed even when it cannot
+ /// be deleted, but it still can be moved.
+ /// </para>
+ /// </remarks>
+ protected void DeleteFile(string fileName)
+ {
+ if (FileExists(fileName))
+ {
+ // We may not have permission to delete the file, or the file may be locked
- var fileToDelete = fileName;
+ var fileToDelete = fileName;
- // Try to move the file to temp name.
- // If the file is locked we may still be able to move it
- var tempFileName = fileName + "." + Environment.TickCount + ".DeletePending";
- try
- {
- using(SecurityContext.Impersonate(this))
- {
- System.IO.File.Move(fileName, tempFileName);
- }
- fileToDelete = tempFileName;
- }
- catch(Exception moveEx)
- {
- LogLog.Debug(declaringType, "Exception while moving file to be deleted [" + fileName + "] -> [" + tempFileName + "]", moveEx);
- }
+ // Try to move the file to temp name.
+ // If the file is locked we may still be able to move it
+ var tempFileName = fileName + "." + Environment.TickCount + ".DeletePending";
+ try
+ {
+ using(SecurityContext.Impersonate(this))
+ {
+ System.IO.File.Move(fileName, tempFileName);
+ }
+ fileToDelete = tempFileName;
+ }
+ catch(Exception moveEx)
+ {
+ LogLog.Debug(declaringType, "Exception while moving file to be deleted [" + fileName + "] -> [" + tempFileName + "]", moveEx);
+ }
- // Try to delete the file (either the original or the moved file)
- try
- {
- using(SecurityContext.Impersonate(this))
- {
- System.IO.File.Delete(fileToDelete);
- }
- LogLog.Debug(declaringType, "Deleted file [" + fileName + "]");
- }
- catch(Exception deleteEx)
- {
- if (fileToDelete == fileName)
- {
- // Unable to move or delete the file
- ErrorHandler.Error("Exception while deleting file [" + fileToDelete + "]", deleteEx, ErrorCode.GenericFailure);
- }
- else
- {
- // Moved the file, but the delete failed. File is probably locked.
- // The file should automatically be deleted when the lock is released.
- LogLog.Debug(declaringType, "Exception while deleting temp file [" + fileToDelete + "]", deleteEx);
- }
- }
- }
- }
+ // Try to delete the file (either the original or the moved file)
+ try
+ {
+ using(SecurityContext.Impersonate(this))
+ {
+ System.IO.File.Delete(fileToDelete);
+ }
+ LogLog.Debug(declaringType, "Deleted file [" + fileName + "]");
+ }
+ catch(Exception deleteEx)
+ {
+ if (fileToDelete == fileName)
+ {
+ // Unable to move or delete the file
+ ErrorHandler.Error("Exception while deleting file [" + fileToDelete + "]", deleteEx, ErrorCode.GenericFailure);
+ }
+ else
+ {
+ // Moved the file, but the delete failed. File is probably locked.
+ // The file should automatically be deleted when the lock is released.
+ LogLog.Debug(declaringType, "Exception while deleting temp file [" + fileToDelete + "]", deleteEx);
+ }
+ }
+ }
+ }
- /// <summary>
- /// Implements file roll base on file size.
- /// </summary>
- /// <remarks>
- /// <para>
- /// If the maximum number of size based backups is reached
- /// (<c>curSizeRollBackups == maxSizeRollBackups</c>) then the oldest
- /// file is deleted -- its index determined by the sign of countDirection.
- /// If <c>countDirection</c> < 0, then files
- /// {<c>File.1</c>, ..., <c>File.curSizeRollBackups -1</c>}
- /// are renamed to {<c>File.2</c>, ...,
- /// <c>File.curSizeRollBackups</c>}. Moreover, <c>File</c> is
- /// renamed <c>File.1</c> and closed.
- /// </para>
- /// <para>
- /// A new file is created to receive further log output.
- /// </para>
- /// <para>
- /// If <c>maxSizeRollBackups</c> is equal to zero, then the
- /// <c>File</c> is truncated with no backup files created.
- /// </para>
- /// <para>
- /// If <c>maxSizeRollBackups</c> < 0, then <c>File</c> is
- /// renamed if needed and no files are deleted.
- /// </para>
- /// </remarks>
- protected void RollOverSize()
- {
- CloseFile(); // keep windows happy.
-
- LogLog.Debug(declaringType, "rolling over count ["+((CountingQuietTextWriter)QuietWriter).Count+"]");
- LogLog.Debug(declaringType, "maxSizeRollBackups ["+m_maxSizeRollBackups+"]");
- LogLog.Debug(declaringType, "curSizeRollBackups ["+m_curSizeRollBackups+"]");
- LogLog.Debug(declaringType, "countDirection ["+m_countDirection+"]");
+ /// <summary>
+ /// Implements file roll base on file size.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// If the maximum number of size based backups is reached
+ /// (<c>curSizeRollBackups == maxSizeRollBackups</c>) then the oldest
+ /// file is deleted -- its index determined by the sign of countDirection.
+ /// If <c>countDirection</c> < 0, then files
+ /// {<c>File.1</c>, ..., <c>File.curSizeRollBackups -1</c>}
+ /// are renamed to {<c>File.2</c>, ...,
+ /// <c>File.curSizeRollBackups</c>}. Moreover, <c>File</c> is
+ /// renamed <c>File.1</c> and closed.
+ /// </para>
+ /// <para>
+ /// A new file is created to receive further log output.
+ /// </para>
+ /// <para>
+ /// If <c>maxSizeRollBackups</c> is equal to zero, then the
+ /// <c>File</c> is truncated with no backup files created.
+ /// </para>
+ /// <para>
+ /// If <c>maxSizeRollBackups</c> < 0, then <c>File</c> is
+ /// renamed if needed and no files are deleted.
+ /// </para>
+ /// </remarks>
+ protected void RollOverSize()
+ {
+ CloseFile(); // keep windows happy.
+
+ LogLog.Debug(declaringType, "rolling over count ["+((CountingQuietTextWriter)QuietWriter).Count+"]");
+ LogLog.Debug(declaringType, "maxSizeRollBackups ["+m_maxSizeRollBackups+"]");
+ LogLog.Debug(declaringType, "curSizeRollBackups ["+m_curSizeRollBackups+"]");
+ LogLog.Debug(declaringType, "countDirection ["+m_countDirection+"]");
- RollOverRenameFiles(File);
-
- if (!m_staticLogFileName && m_countDirection >= 0)
- {
- m_curSizeRollBackups++;
- }
+ RollOverRenameFiles(File);
+
+ if (!m_staticLogFileName && m_countDirection >= 0)
+ {
+ m_curSizeRollBackups++;
+ }
- // This will also close the file. This is OK since multiple close operations are safe.
- SafeOpenFile(m_baseFileName, false);
- }
+ // This will also close the file. This is OK since multiple close operations are safe.
+ SafeOpenFile(m_baseFileName, false);
+ }
- /// <summary>
- /// Implements file roll.
- /// </summary>
- /// <param name="baseFileName">the base name to rename</param>
- /// <remarks>
- /// <para>
- /// If the maximum number of size based backups is reached
- /// (<c>curSizeRollBackups == maxSizeRollBackups</c>) then the oldest
- /// file is deleted -- its index determined by the sign of countDirection.
- /// If <c>countDirection</c> < 0, then files
- /// {<c>File.1</c>, ..., <c>File.curSizeRollBackups -1</c>}
- /// are renamed to {<c>File.2</c>, ...,
- /// <c>File.curSizeRollBackups</c>}.
- /// </para>
- /// <para>
- /// If <c>maxSizeRollBackups</c> is equal to zero, then the
- /// <c>File</c> is truncated with no backup files created.
- /// </para>
- /// <para>
- /// If <c>maxSizeRollBackups</c> < 0, then <c>File</c> is
- /// renamed if needed and no files are deleted.
- /// </para>
- /// <para>
- /// This is called by <see cref="RollOverSize"/> to rename the files.
- /// </para>
- /// </remarks>
- protected void RollOverRenameFiles(string baseFileName)
- {
- // If maxBackups <= 0, then there is no file renaming to be done.
- if (m_maxSizeRollBackups != 0)
- {
- if (m_countDirection < 0)
- {
- // Delete the oldest file, to keep Windows happy.
- if (m_curSizeRollBackups == m_maxSizeRollBackups)
- {
+ /// <summary>
+ /// Implements file roll.
+ /// </summary>
+ /// <param name="baseFileName">the base name to rename</param>
+ /// <remarks>
+ /// <para>
+ /// If the maximum number of size based backups is reached
+ /// (<c>curSizeRollBackups == maxSizeRollBackups</c>) then the oldest
+ /// file is deleted -- its index determined by the sign of countDirection.
+ /// If <c>countDirection</c> < 0, then files
+ /// {<c>File.1</c>, ..., <c>File.curSizeRollBackups -1</c>}
+ /// are renamed to {<c>File.2</c>, ...,
+ /// <c>File.curSizeRollBackups</c>}.
+ /// </para>
+ /// <para>
+ /// If <c>maxSizeRollBackups</c> is equal to zero, then the
+ /// <c>File</c> is truncated with no backup files created.
+ /// </para>
+ /// <para>
+ /// If <c>maxSizeRollBackups</c> < 0, then <c>File</c> is
+ /// renamed if needed and no files are deleted.
+ /// </para>
+ /// <para>
+ /// This is called by <see cref="RollOverSize"/> to rename the files.
+ /// </para>
+ /// </remarks>
+ protected void RollOverRenameFiles(string baseFileName)
+ {
+ // If maxBackups <= 0, then there is no file renaming to be done.
+ if (m_maxSizeRollBackups != 0)
+ {
+ if (m_countDirection < 0)
+ {
+ // Delete the oldest file, to keep Windows happy.
+ if (m_curSizeRollBackups == m_maxSizeRollBackups)
+ {
DeleteFile(CombinePath(baseFileName, "." + m_maxSizeRollBackups));
- m_curSizeRollBackups--;
- }
-
- // Map {(maxBackupIndex - 1), ..., 2, 1} to {maxBackupIndex, ..., 3, 2}
- for (var i = m_curSizeRollBackups; i >= 1; i--)
- {
+ m_curSizeRollBackups--;
+ }
+
+ // Map {(maxBackupIndex - 1), ..., 2, 1} to {maxBackupIndex, ..., 3, 2}
+ for (var i = m_curSizeRollBackups; i >= 1; i--)
+ {
RollFile((CombinePath(baseFileName, "." + i)), (CombinePath(baseFileName, "." + (i + 1))));
- }
-
- m_curSizeRollBackups++;
+ }
+
+ m_curSizeRollBackups++;
- // Rename fileName to fileName.1
+ // Rename fileName to fileName.1
RollFile(baseFileName, CombinePath(baseFileName, ".1"));
- }
- else
- {
- //countDirection >= 0
- if (m_curSizeRollBackups >= m_maxSizeRollBackups && m_maxSizeRollBackups > 0)
- {
- //delete the first and keep counting up.
- var oldestFileIndex = m_curSizeRollBackups - m_maxSizeRollBackups;
+ }
+ else
+ {
+ //countDirection >= 0
+ if (m_curSizeRollBackups >= m_maxSizeRollBackups && m_maxSizeRollBackups > 0)
+ {
+ //delete the first and keep counting up.
+ var oldestFileIndex = m_curSizeRollBackups - m_maxSizeRollBackups;
- // If static then there is 1 file without a number, therefore 1 less archive
- if (m_staticLogFileName)
- {
- oldestFileIndex++;
- }
+ // If static then there is 1 file without a number, therefore 1 less archive
+ if (m_staticLogFileName)
+ {
+ oldestFileIndex++;
+ }
- // If using a static log file then the base for the numbered sequence is the baseFileName passed in
- // If not using a static log file then the baseFileName will already have a numbered postfix which
- // we must remove, however it may have a date postfix which we must keep!
- var archiveFileBaseName = baseFileName;
- if (!m_staticLogFileName)
- {
+ // If using a static log file then the base for the numbered sequence is the baseFileName passed in
+ // If not using a static log file then the baseFileName will already have a numbered postfix which
+ // we must remove, however it may have a date postfix which we must keep!
+ var archiveFileBaseName = baseFileName;
+ if (!m_staticLogFileName)
+ {
if (m_preserveLogFileNameExtension)
{
var extension = Path.GetExtension(archiveFileBaseName);
var baseName = Path.GetFileNameWithoutExtension(archiveFileBaseName);
- var lastDotIndex = baseName.LastIndexOf(".");
- if (lastDotIndex >= 0)
- {
- archiveFileBaseName = baseName.Substring(0, lastDotIndex) + extension;
- }
+ var lastDotIndex = baseName.LastIndexOf(".");
+ if (lastDotIndex >= 0)
+ {
+ archiveFileBaseName = baseName.Substring(0, lastDotIndex) + extension;
+ }
}
else
{
- var lastDotIndex = archiveFileBaseName.LastIndexOf(".");
- if (lastDotIndex >= 0)
- {
- archiveFileBaseName = archiveFileBaseName.Substring(0, lastDotIndex);
- }
+ var lastDotIndex = archiveFileBaseName.LastIndexOf(".");
+ if (lastDotIndex >= 0)
+ {
+ archiveFileBaseName = archiveFileBaseName.Substring(0, lastDotIndex);
+ }
}
- }
+ }
- // Delete the archive file
+ // Delete the archive file
DeleteFile(CombinePath(archiveFileBaseName, "." + oldestFileIndex));
- }
-
- if (m_staticLogFileName)
- {
- m_curSizeRollBackups++;
+ }
+
+ if (m_staticLogFileName)
+ {
+ m_curSizeRollBackups++;
RollFile(baseFileName, CombinePath(baseFileName, "." + m_curSizeRollBackups));
- }
- }
- }
- }
+ }
+ }
+ }
+ }
- #endregion
+ #endregion
- #region NextCheckDate
+ #region NextCheckDate
- /// <summary>
- /// Get the start time of the next window for the current rollpoint
- /// </summary>
- /// <param name="currentDateTime">the current date</param>
- /// <param name="rollPoint">the type of roll point we are working with</param>
- /// <returns>the start time for the next roll point an interval after the currentDateTime date</returns>
- /// <remarks>
- /// <para>
- /// Returns the date of the next roll point after the currentDateTime date passed to the method.
- /// </para>
- /// <para>
- /// The basic strategy is to subtract the time parts that are less significant
- /// than the rollpoint from the current time. This should roll the time back to
- /// the start of the time window for the current rollpoint. Then we add 1 window
- /// worth of time and get the start time of the next window for the rollpoint.
- /// </para>
- /// </remarks>
- protected DateTime NextCheckDate(DateTime currentDateTime, RollPoint rollPoint)
- {
- // Local variable to work on (this does not look very efficient)
- var current = currentDateTime;
+ /// <summary>
+ /// Get the start time of the next window for the current rollpoint
+ /// </summary>
+ /// <param name="currentDateTime">the current date</param>
+ /// <param name="rollPoint">the type of roll point we are working with</param>
+ /// <returns>the start time for the next roll point an interval after the currentDateTime date</returns>
+ /// <remarks>
+ /// <para>
+ /// Returns the date of the next roll point after the currentDateTime date passed to the method.
+ /// </para>
+ /// <para>
+ /// The basic strategy is to subtract the time parts that are less significant
+ /// than the rollpoint from the current time. This should roll the time back to
+ /// the start of the time window for the current rollpoint. Then we add 1 window
+ /// worth of time and get the start time of the next window for the rollpoint.
+ /// </para>
+ /// </remarks>
+ protected DateTime NextCheckDate(DateTime currentDateTime, RollPoint rollPoint)
+ {
+ // Local variable to work on (this does not look very efficient)
+ var current = currentDateTime;
- // Do slightly different things depending on what the type of roll point we want.
- switch(rollPoint)
- {
- case RollPoint.TopOfMinute:
- current = current.AddMilliseconds(-current.Millisecond);
- current = current.AddSeconds(-current.Second);
- current = current.AddMinutes(1);
- break;
+ // Do slightly different things depending on what the type of roll point we want.
+ switch(rollPoint)
+ {
+ case RollPoint.TopOfMinute:
+ current = current.AddMilliseconds(-current.Millisecond);
+ current = current.AddSeconds(-current.Second);
+ current = current.AddMinutes(1);
+ break;
- case RollPoint.TopOfHour:
- current = current.AddMilliseconds(-current.Millisecond);
- current = current.AddSeconds(-current.Second);
- current = current.AddMinutes(-current.Minute);
- current = current.AddHours(1);
- break;
+ case RollPoint.TopOfHour:
+ current = current.AddMilliseconds(-current.Millisecond);
+ current = current.AddSeconds(-current.Second);
+ current = current.AddMinutes(-current.Minute);
+ current = current.AddHours(1);
+ break;
- case RollPoint.HalfDay:
- current = current.AddMilliseconds(-current.Millisecond);
- current = current.AddSeconds(-current.Second);
- current = current.AddMinutes(-current.Minute);
+ case RollPoint.HalfDay:
+ current = current.AddMilliseconds(-current.Millisecond);
+ current = current.AddSeconds(-current.Second);
+ current = current.AddMinutes(-current.Minute);
- if (current.Hour < 12)
- {
- current = current.AddHours(12 - current.Hour);
- }
- else
- {
- current = current.AddHours(-current.Hour);
- current = current.AddDays(1);
- }
- break;
+ if (current.Hour < 12)
+ {
+ current = current.AddHours(12 - current.Hour);
+ }
+ else
+ {
+ current = current.AddHours(-current.Hour);
+ current = current.AddDays(1);
+ }
+ break;
- case RollPoint.TopOfDay:
- current = current.AddMilliseconds(-current.Millisecond);
- current = current.AddSeconds(-current.Second);
- current = current.AddMinutes(-current.Minute);
- current = current.AddHours(-current.Hour);
- current = current.AddDays(1);
- break;
+ case RollPoint.TopOfDay:
+ current = current.AddMilliseconds(-current.Millisecond);
+ current = current.AddSeconds(-current.Second);
+ current = current.AddMinutes(-current.Minute);
+ current = current.AddHours(-current.Hour);
+ current = current.AddDays(1);
+ break;
- case RollPoint.TopOfWeek:
- current = current.AddMilliseconds(-current.Millisecond);
- current = current.AddSeconds(-current.Second);
- current = current.AddMinutes(-current.Minute);
- current = current.AddHours(-current.Hour);
- current = current.AddDays(7 - (int)current.DayOfWeek);
- break;
+ case RollPoint.TopOfWeek:
+ current = current.AddMilliseconds(-current.Millisecond);
+ current = current.AddSeconds(-current.Second);
+ current = current.AddMinutes(-current.Minute);
+ current = current.AddHours(-current.Hour);
+ current = current.AddDays(7 - (int)current.DayOfWeek);
+ break;
- case RollPoint.TopOfMonth:
- current = current.AddMilliseconds(-current.Millisecond);
- current = current.AddSeconds(-current.Second);
- current = current.AddMinutes(-current.Minute);
- current = current.AddHours(-current.Hour);
- current = current.AddDays(1 - current.Day); /* first day of month is 1 not 0 */
- current = current.AddMonths(1);
- break;
- }
- return current;
- }
+ case RollPoint.TopOfMonth:
+ current = current.AddMilliseconds(-current.Millisecond);
+ current = current.AddSeconds(-current.Second);
+ current = current.AddMinutes(-current.Minute);
+ current = current.AddHours(-current.Hour);
+ current = current.AddDays(1 - current.Day); /* first day of month is 1 not 0 */
+ current = current.AddMonths(1);
+ break;
+ }
+ return current;
+ }
- #endregion
+ #endregion
- #region Private Instance Fields
+ #region Private Instance Fields
- /// <summary>
- /// This object supplies the current date/time. Allows test code to plug in
- /// a method to control this class when testing date/time based rolling. The default
- /// implementation uses the underlying value of DateTime.Now.
- /// </summary>
- private IDateTime m_dateTime = null;
+ /// <summary>
+ /// This object supplies the current date/time. Allows test code to plug in
+ /// a method to control this class when testing date/time based rolling. The default
+ /// implementation uses the underlying value of DateTime.Now.
+ /// </summary>
+ private IDateTime m_dateTime = null;
- /// <summary>
- /// The date pattern. By default, the pattern is set to <c>".yyyy-MM-dd"</c>
- /// meaning daily rollover.
- /// </summary>
- private string m_datePattern = ".yyyy-MM-dd";
+ /// <summary>
+ /// The date pattern. By default, the pattern is set to <c>".yyyy-MM-dd"</c>
+ /// meaning daily rollover.
+ /// </summary>
+ private string m_datePattern = ".yyyy-MM-dd";
- /// <summary>
- /// The actual formatted filename that is currently being written to
- /// or will be the file transferred to on roll over
- /// (based on staticLogFileName).
- /// </summary>
- private string m_scheduledFilename = null;
+ /// <summary>
+ /// The actual formatted filename that is currently being written to
+ /// or will be the file transferred to on roll over
+ /// (based on staticLogFileName).
+ /// </summary>
+ private string m_scheduledFilename = null;
- /// <summary>
- /// The timestamp when we shall next recompute the filename.
- /// </summary>
- private DateTime m_nextCheck = DateTime.MaxValue;
+ /// <summary>
+ /// The timestamp when we shall next recompute the filename.
+ /// </summary>
+ private DateTime m_nextCheck = DateTime.MaxValue;
- /// <summary>
- /// Holds date of last roll over
- /// </summary>
- private DateTime m_now;
+ /// <summary>
+ /// Holds date of last roll over
+ /// </summary>
+ private DateTime m_now;
- /// <summary>
- /// The type of rolling done
- /// </summary>
- private RollPoint m_rollPoint;
+ /// <summary>
+ /// The type of rolling done
+ /// </summary>
+ private RollPoint m_rollPoint;
- /// <summary>
- /// The default maximum file size is 10MB
- /// </summary>
- private long m_maxFileSize = 10*1024*1024;
+ /// <summary>
+ /// The default maximum file size is 10MB
+ /// </summary>
+ private long m_maxFileSize = 10*1024*1024;
- /// <summary>
- /// There is zero backup files by default
- /// </summary>
- private int m_maxSizeRollBackups = 0;
+ /// <summary>
+ /// There is zero backup files by default
+ /// </summary>
+ private int m_maxSizeRollBackups = 0;
- /// <summary>
- /// How many sized based backups have been made so far
- /// </summary>
- private int m_curSizeRollBackups = 0;
+ /// <summary>
+ /// How many sized based backups have been made so far
+ /// </summary>
+ private int m_curSizeRollBackups = 0;
- /// <summary>
- /// The rolling file count direction.
- /// </summary>
- private int m_countDirection = -1;
+ /// <summary>
+ /// The rolling file count direction.
+ /// </summary>
+ private int m_countDirection = -1;
- /// <summary>
- /// The rolling mode used in this appender.
- /// </summary>
- private RollingMode m_rollingStyle = RollingMode.Composite;
+ /// <summary>
+ /// The rolling mode used in this appender.
+ /// </summary>
+ private RollingMode m_rollingStyle = RollingMode.Composite;
- /// <summary>
- /// Cache flag set if we are rolling by date.
- /// </summary>
- private bool m_rollDate = true;
+ /// <summary>
+ /// Cache flag set if we are rolling by date.
+ /// </summary>
+ private bool m_rollDate = true;
- /// <summary>
- /// Cache flag set if we are rolling by size.
- /// </summary>
- private bool m_rollSize = true;
+ /// <summary>
+ /// Cache flag set if we are rolling by size.
+ /// </summary>
+ private bool m_rollSize = true;
- /// <summary>
- /// Value indicating whether to always log to the same file.
- /// </summary>
- private bool m_staticLogFileName = true;
+ /// <summary>
+ /// Value indicating whether to always log to the same file.
+ /// </summary>
+ private bool m_staticLogFileName = true;
- /// <summary>
- /// Value indicating whether to preserve the file name extension when rolling.
- /// </summary>
- private bool m_preserveLogFileNameExtension = false;
+ /// <summary>
+ /// Value indicating whether to preserve the file name extension when rolling.
+ /// </summary>
+ private bool m_preserveLogFileNameExtension = false;
- /// <summary>
- /// FileName provided in configuration. Used for rolling properly
- /// </summary>
- private string m_baseFileName;
+ /// <summary>
+ /// FileName provided in configuration. Used for rolling properly
+ /// </summary>
+ private string m_baseFileName;
#if !NETCF
- /// <summary>
- /// A mutex that is used to lock rolling of files.
- /// </summary>
- private Mutex m_mutexForRolling;
+ /// <summary>
+ /// A mutex that is used to lock rolling of files.
+ /// </summary>
+ private Mutex m_mutexForRolling;
#endif
- #endregion Private Instance Fields
+ #endregion Private Instance Fields
- #region Static Members
+ #region Static Members
- /// <summary>
- /// The 1st of January 1970 in UTC
- /// </summary>
- private static readonly DateTime s_date1970 = new DateTime(1970, 1, 1);
+ /// <summary>
+ /// The 1st of January 1970 in UTC
+ /// </summary>
+ private static readonly DateTime s_date1970 = new DateTime(1970, 1, 1);
- #endregion
+ #endregion
- #region DateTime
+ #region DateTime
- /// <summary>
- /// This interface is used to supply Date/Time information to the <see cref="RollingFileAppender"/>.
- /// </summary>
- /// <remarks>
- /// This interface is used to supply Date/Time information to the <see cref="RollingFileAppender"/>.
- /// Used primarily to allow test classes to plug themselves in so they can
- /// supply test date/times.
- /// </remarks>
- public interface IDateTime
- {
- /// <summary>
- /// Gets the <i>current</i> time.
- /// </summary>
- /// <value>The <i>current</i> time.</value>
- /// <remarks>
- /// <para>
- /// Gets the <i>current</i> time.
- /// </para>
- /// </remarks>
- DateTime Now { get; }
- }
+ /// <summary>
+ /// This interface is used to supply Date/Time information to the <see cref="RollingFileAppender"/>.
+ /// </summary>
+ /// <remarks>
+ /// This interface is used to supply Date/Time information to the <see cref="RollingFileAppender"/>.
+ /// Used primarily to allow test classes to plug themselves in so they can
+ /// supply test date/times.
+ /// </remarks>
+ public interface IDateTime
+ {
+ /// <summary>
+ /// Gets the <i>current</i> time.
+ /// </summary>
+ /// <value>The <i>current</i> time.</value>
+ /// <remarks>
+ /// <para>
+ /// Gets the <i>current</i> time.
+ /// </para>
+ /// </remarks>
+ DateTime Now { get; }
+ }
- /// <summary>
- /// Default implementation of <see cref="IDateTime"/> that returns the current time.
- /// </summary>
- private class LocalDateTime : IDateTime
- {
- /// <summary>
- /// Gets the <b>current</b> time.
- /// </summary>
- /// <value>The <b>current</b> time.</value>
- /// <remarks>
- /// <para>
- /// Gets the <b>current</b> time.
- /// </para>
- /// </remarks>
- public DateTime Now
- {
- get { return DateTime.Now; }
- }
- }
+ /// <summary>
+ /// Default implementation of <see cref="IDateTime"/> that returns the current time.
+ /// </summary>
+ private class LocalDateTime : IDateTime
+ {
+ /// <summary>
+ /// Gets the <b>current</b> time.
+ /// </summary>
+ /// <value>The <b>current</b> time.</value>
+ /// <remarks>
+ /// <para>
+ /// Gets the <b>current</b> time.
+ /// </para>
+ /// </remarks>
+ public DateTime Now
+ {
+ get { return DateTime.Now; }
+ }
+ }
#if !NET_1_0 && !CLI_1_0 && !NETCF
/// <summary>
- /// Implementation of <see cref="IDateTime"/> that returns the current time as the coordinated universal time (UTC).
- /// </summary>
- private class UniversalDateTime : IDateTime
- {
- /// <summary>
- /// Gets the <b>current</b> time.
- /// </summary>
- /// <value>The <b>current</b> time.</value>
- /// <remarks>
- /// <para>
- /// Gets the <b>current</b> time.
- /// </para>
- /// </remarks>
- public DateTime Now
- {
- get { return DateTime.UtcNow; }
- }
- }
+ /// Implementation of <see cref="IDateTime"/> that returns the current time as the coordinated universal time (UTC).
+ /// </summary>
+ private class UniversalDateTime : IDateTime
+ {
+ /// <summary>
+ /// Gets the <b>current</b> time.
+ /// </summary>
+ /// <value>The <b>current</b> time.</value>
+ /// <remarks>
+ /// <para>
+ /// Gets the <b>current</b> time.
+ /// </para>
+ /// </remarks>
+ public DateTime Now
+ {
+ get { return DateTime.UtcNow; }
+ }
+ }
#endif
#endregion DateTime
- }
+ }
}
diff --git a/src/log4net/Appender/SmtpAppender.cs b/src/log4net/Appender/SmtpAppender.cs
index 98b6bb6..c0d1246 100644
--- a/src/log4net/Appender/SmtpAppender.cs
+++ b/src/log4net/Appender/SmtpAppender.cs
@@ -36,633 +36,633 @@
namespace log4net.Appender
{
- /// <summary>
- /// Send an e-mail when a specific logging event occurs, typically on errors
- /// or fatal errors.
- /// </summary>
- /// <remarks>
- /// <para>
- /// The number of logging events delivered in this e-mail depend on
- /// the value of <see cref="BufferingAppenderSkeleton.BufferSize"/> option. The
- /// <see cref="SmtpAppender"/> keeps only the last
- /// <see cref="BufferingAppenderSkeleton.BufferSize"/> logging events in its
- /// cyclic buffer. This keeps memory requirements at a reasonable level while
- /// still delivering useful application context.
- /// </para>
- /// <note type="caution">
- /// Authentication and setting the server Port are only available on the MS .NET 1.1 runtime.
- /// For these features to be enabled you need to ensure that you are using a version of
- /// the log4net assembly that is built against the MS .NET 1.1 framework and that you are
- /// running the your application on the MS .NET 1.1 runtime. On all other platforms only sending
- /// unauthenticated messages to a server listening on port 25 (the default) is supported.
- /// </note>
- /// <para>
- /// Authentication is supported by setting the <see cref="Authentication"/> property to
- /// either <see cref="SmtpAuthentication.Basic"/> or <see cref="SmtpAuthentication.Ntlm"/>.
- /// If using <see cref="SmtpAuthentication.Basic"/> authentication then the <see cref="Username"/>
- /// and <see cref="Password"/> properties must also be set.
- /// </para>
- /// <para>
- /// To set the SMTP server port use the <see cref="Port"/> property. The default port is 25.
- /// </para>
- /// </remarks>
- /// <author>Nicko Cadell</author>
- /// <author>Gert Driesen</author>
- public class SmtpAppender : BufferingAppenderSkeleton
- {
- #region Public Instance Constructors
+ /// <summary>
+ /// Send an e-mail when a specific logging event occurs, typically on errors
+ /// or fatal errors.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// The number of logging events delivered in this e-mail depend on
+ /// the value of <see cref="BufferingAppenderSkeleton.BufferSize"/> option. The
+ /// <see cref="SmtpAppender"/> keeps only the last
+ /// <see cref="BufferingAppenderSkeleton.BufferSize"/> logging events in its
+ /// cyclic buffer. This keeps memory requirements at a reasonable level while
+ /// still delivering useful application context.
+ /// </para>
+ /// <note type="caution">
+ /// Authentication and setting the server Port are only available on the MS .NET 1.1 runtime.
+ /// For these features to be enabled you need to ensure that you are using a version of
+ /// the log4net assembly that is built against the MS .NET 1.1 framework and that you are
+ /// running the your application on the MS .NET 1.1 runtime. On all other platforms only sending
+ /// unauthenticated messages to a server listening on port 25 (the default) is supported.
+ /// </note>
+ /// <para>
+ /// Authentication is supported by setting the <see cref="Authentication"/> property to
+ /// either <see cref="SmtpAuthentication.Basic"/> or <see cref="SmtpAuthentication.Ntlm"/>.
+ /// If using <see cref="SmtpAuthentication.Basic"/> authentication then the <see cref="Username"/>
+ /// and <see cref="Password"/> properties must also be set.
+ /// </para>
+ /// <para>
+ /// To set the SMTP server port use the <see cref="Port"/> property. The default port is 25.
+ /// </para>
+ /// </remarks>
+ /// <author>Nicko Cadell</author>
+ /// <author>Gert Driesen</author>
+ public class SmtpAppender : BufferingAppenderSkeleton
+ {
+ #region Public Instance Constructors
- /// <summary>
- /// Default constructor
- /// </summary>
- /// <remarks>
- /// <para>
- /// Default constructor
- /// </para>
- /// </remarks>
- public SmtpAppender()
- {
- }
+ /// <summary>
+ /// Default constructor
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Default constructor
+ /// </para>
+ /// </remarks>
+ public SmtpAppender()
+ {
+ }
- #endregion // Public Instance Constructors
+ #endregion // Public Instance Constructors
- #region Public Instance Properties
+ #region Public Instance Properties
- /// <summary>
- /// Gets or sets a comma- or semicolon-delimited list of recipient e-mail addresses (use semicolon on .NET 1.1 and comma for later versions).
- /// </summary>
- /// <value>
- /// <para>
- /// For .NET 1.1 (System.Web.Mail): A semicolon-delimited list of e-mail addresses.
- /// </para>
- /// <para>
- /// For .NET 2.0 (System.Net.Mail): A comma-delimited list of e-mail addresses.
- /// </para>
- /// </value>
- /// <remarks>
- /// <para>
- /// For .NET 1.1 (System.Web.Mail): A semicolon-delimited list of e-mail addresses.
- /// </para>
- /// <para>
- /// For .NET 2.0 (System.Net.Mail): A comma-delimited list of e-mail addresses.
- /// </para>
- /// </remarks>
- public string To
- {
- get { return m_to; }
- set { m_to = MaybeTrimSeparators(value); }
- }
+ /// <summary>
+ /// Gets or sets a comma- or semicolon-delimited list of recipient e-mail addresses (use semicolon on .NET 1.1 and comma for later versions).
+ /// </summary>
+ /// <value>
+ /// <para>
+ /// For .NET 1.1 (System.Web.Mail): A semicolon-delimited list of e-mail addresses.
+ /// </para>
+ /// <para>
+ /// For .NET 2.0 (System.Net.Mail): A comma-delimited list of e-mail addresses.
+ /// </para>
+ /// </value>
+ /// <remarks>
+ /// <para>
+ /// For .NET 1.1 (System.Web.Mail): A semicolon-delimited list of e-mail addresses.
+ /// </para>
+ /// <para>
+ /// For .NET 2.0 (System.Net.Mail): A comma-delimited list of e-mail addresses.
+ /// </para>
+ /// </remarks>
+ public string To
+ {
+ get { return m_to; }
+ set { m_to = MaybeTrimSeparators(value); }
+ }
- /// <summary>
- /// Gets or sets a comma- or semicolon-delimited list of recipient e-mail addresses
- /// that will be carbon copied (use semicolon on .NET 1.1 and comma for later versions).
- /// </summary>
- /// <value>
- /// <para>
- /// For .NET 1.1 (System.Web.Mail): A semicolon-delimited list of e-mail addresses.
- /// </para>
- /// <para>
- /// For .NET 2.0 (System.Net.Mail): A comma-delimited list of e-mail addresses.
- /// </para>
- /// </value>
- /// <remarks>
- /// <para>
- /// For .NET 1.1 (System.Web.Mail): A semicolon-delimited list of e-mail addresses.
- /// </para>
- /// <para>
- /// For .NET 2.0 (System.Net.Mail): A comma-delimited list of e-mail addresses.
- /// </para>
- /// </remarks>
- public string Cc
- {
- get { return m_cc; }
- set { m_cc = MaybeTrimSeparators(value); }
- }
+ /// <summary>
+ /// Gets or sets a comma- or semicolon-delimited list of recipient e-mail addresses
+ /// that will be carbon copied (use semicolon on .NET 1.1 and comma for later versions).
+ /// </summary>
+ /// <value>
+ /// <para>
+ /// For .NET 1.1 (System.Web.Mail): A semicolon-delimited list of e-mail addresses.
+ /// </para>
+ /// <para>
+ /// For .NET 2.0 (System.Net.Mail): A comma-delimited list of e-mail addresses.
+ /// </para>
+ /// </value>
+ /// <remarks>
+ /// <para>
+ /// For .NET 1.1 (System.Web.Mail): A semicolon-delimited list of e-mail addresses.
+ /// </para>
+ /// <para>
+ /// For .NET 2.0 (System.Net.Mail): A comma-delimited list of e-mail addresses.
+ /// </para>
+ /// </remarks>
+ public string Cc
+ {
+ get { return m_cc; }
+ set { m_cc = MaybeTrimSeparators(value); }
+ }
- /// <summary>
- /// Gets or sets a semicolon-delimited list of recipient e-mail addresses
- /// that will be blind carbon copied.
- /// </summary>
- /// <value>
- /// A semicolon-delimited list of e-mail addresses.
- /// </value>
- /// <remarks>
- /// <para>
- /// A semicolon-delimited list of recipient e-mail addresses.
- /// </para>
- /// </remarks>
- public string Bcc
- {
- get { return m_bcc; }
- set { m_bcc = MaybeTrimSeparators(value); }
- }
+ /// <summary>
+ /// Gets or sets a semicolon-delimited list of recipient e-mail addresses
+ /// that will be blind carbon copied.
+ /// </summary>
+ /// <value>
+ /// A semicolon-delimited list of e-mail addresses.
+ /// </value>
+ /// <remarks>
+ /// <para>
+ /// A semicolon-delimited list of recipient e-mail addresses.
+ /// </para>
+ /// </remarks>
+ public string Bcc
+ {
+ get { return m_bcc; }
+ set { m_bcc = MaybeTrimSeparators(value); }
+ }
- /// <summary>
- /// Gets or sets the e-mail address of the sender.
- /// </summary>
- /// <value>
- /// The e-mail address of the sender.
- /// </value>
- /// <remarks>
- /// <para>
- /// The e-mail address of the sender.
- /// </para>
- /// </remarks>
- public string From
- {
- get { return m_from; }
- set { m_from = value; }
- }
+ /// <summary>
+ /// Gets or sets the e-mail address of the sender.
+ /// </summary>
+ /// <value>
+ /// The e-mail address of the sender.
+ /// </value>
+ /// <remarks>
+ /// <para>
+ /// The e-mail address of the sender.
+ /// </para>
+ /// </remarks>
+ public string From
+ {
+ get { return m_from; }
+ set { m_from = value; }
+ }
- /// <summary>
- /// Gets or sets the subject line of the e-mail message.
- /// </summary>
- /// <value>
- /// The subject line of the e-mail message.
- /// </value>
- /// <remarks>
- /// <para>
- /// The subject line of the e-mail message.
- /// </para>
- /// </remarks>
- public string Subject
- {
- get { return m_subject; }
- set { m_subject = value; }
- }
+ /// <summary>
+ /// Gets or sets the subject line of the e-mail message.
+ /// </summary>
+ /// <value>
+ /// The subject line of the e-mail message.
+ /// </value>
+ /// <remarks>
+ /// <para>
+ /// The subject line of the e-mail message.
+ /// </para>
+ /// </remarks>
+ public string Subject
+ {
+ get { return m_subject; }
+ set { m_subject = value; }
+ }
- /// <summary>
- /// Gets or sets the name of the SMTP relay mail server to use to send
- /// the e-mail messages.
- /// </summary>
- /// <value>
- /// The name of the e-mail relay server. If SmtpServer is not set, the
- /// name of the local SMTP server is used.
- /// </value>
- /// <remarks>
- /// <para>
- /// The name of the e-mail relay server. If SmtpServer is not set, the
- /// name of the local SMTP server is used.
- /// </para>
- /// </remarks>
- public string SmtpHost
- {
- get { return m_smtpHost; }
- set { m_smtpHost = value; }
- }
+ /// <summary>
+ /// Gets or sets the name of the SMTP relay mail server to use to send
+ /// the e-mail messages.
+ /// </summary>
+ /// <value>
+ /// The name of the e-mail relay server. If SmtpServer is not set, the
+ /// name of the local SMTP server is used.
+ /// </value>
+ /// <remarks>
+ /// <para>
+ /// The name of the e-mail relay server. If SmtpServer is not set, the
+ /// name of the local SMTP server is used.
+ /// </para>
+ /// </remarks>
+ public string SmtpHost
+ {
+ get { return m_smtpHost; }
+ set { m_smtpHost = value; }
+ }
- /// <summary>
- /// Obsolete
- /// </summary>
- /// <remarks>
- /// Use the BufferingAppenderSkeleton Fix methods instead
- /// </remarks>
- /// <remarks>
- /// <para>
- /// Obsolete property.
- /// </para>
- /// </remarks>
- [Obsolete("Use the BufferingAppenderSkeleton Fix methods")]
- public bool LocationInfo
- {
- get { return false; }
- set { ; }
- }
+ /// <summary>
+ /// Obsolete
+ /// </summary>
+ /// <remarks>
+ /// Use the BufferingAppenderSkeleton Fix methods instead
+ /// </remarks>
+ /// <remarks>
+ /// <para>
+ /// Obsolete property.
+ /// </para>
+ /// </remarks>
+ [Obsolete("Use the BufferingAppenderSkeleton Fix methods")]
+ public bool LocationInfo
+ {
+ get { return false; }
+ set { ; }
+ }
- /// <summary>
- /// The mode to use to authentication with the SMTP server
- /// </summary>
- /// <remarks>
- /// <note type="caution">Authentication is only available on the MS .NET 1.1 runtime.</note>
- /// <para>
- /// Valid Authentication mode values are: <see cref="SmtpAuthentication.None"/>,
- /// <see cref="SmtpAuthentication.Basic"/>, and <see cref="SmtpAuthentication.Ntlm"/>.
- /// The default value is <see cref="SmtpAuthentication.None"/>. When using
- /// <see cref="SmtpAuthentication.Basic"/> you must specify the <see cref="Username"/>
- /// and <see cref="Password"/> to use to authenticate.
- /// When using <see cref="SmtpAuthentication.Ntlm"/> the Windows credentials for the current
- /// thread, if impersonating, or the process will be used to authenticate.
- /// </para>
- /// </remarks>
- public SmtpAuthentication Authentication
- {
- get { return m_authentication; }
- set { m_authentication = value; }
- }
+ /// <summary>
+ /// The mode to use to authentication with the SMTP server
+ /// </summary>
+ /// <remarks>
+ /// <note type="caution">Authentication is only available on the MS .NET 1.1 runtime.</note>
+ /// <para>
+ /// Valid Authentication mode values are: <see cref="SmtpAuthentication.None"/>,
+ /// <see cref="SmtpAuthentication.Basic"/>, and <see cref="SmtpAuthentication.Ntlm"/>.
+ /// The default value is <see cref="SmtpAuthentication.None"/>. When using
+ /// <see cref="SmtpAuthentication.Basic"/> you must specify the <see cref="Username"/>
+ /// and <see cref="Password"/> to use to authenticate.
+ /// When using <see cref="SmtpAuthentication.Ntlm"/> the Windows credentials for the current
+ /// thread, if impersonating, or the process will be used to authenticate.
+ /// </para>
+ /// </remarks>
+ public SmtpAuthentication Authentication
+ {
+ get { return m_authentication; }
+ set { m_authentication = value; }
+ }
- /// <summary>
- /// The username to use to authenticate with the SMTP server
- /// </summary>
- /// <remarks>
- /// <note type="caution">Authentication is only available on the MS .NET 1.1 runtime.</note>
- /// <para>
- /// A <see cref="Username"/> and <see cref="Password"/> must be specified when
- /// <see cref="Authentication"/> is set to <see cref="SmtpAuthentication.Basic"/>,
- /// otherwise the username will be ignored.
- /// </para>
- /// </remarks>
- public string Username
- {
- get { return m_username; }
- set { m_username = value; }
- }
+ /// <summary>
+ /// The username to use to authenticate with the SMTP server
+ /// </summary>
+ /// <remarks>
+ /// <note type="caution">Authentication is only available on the MS .NET 1.1 runtime.</note>
+ /// <para>
+ /// A <see cref="Username"/> and <see cref="Password"/> must be specified when
+ /// <see cref="Authentication"/> is set to <see cref="SmtpAuthentication.Basic"/>,
+ /// otherwise the username will be ignored.
+ /// </para>
+ /// </remarks>
+ public string Username
+ {
+ get { return m_username; }
+ set { m_username = value; }
+ }
- /// <summary>
- /// The password to use to authenticate with the SMTP server
- /// </summary>
- /// <remarks>
- /// <note type="caution">Authentication is only available on the MS .NET 1.1 runtime.</note>
- /// <para>
- /// A <see cref="Username"/> and <see cref="Password"/> must be specified when
- /// <see cref="Authentication"/> is set to <see cref="SmtpAuthentication.Basic"/>,
- /// otherwise the password will be ignored.
- /// </para>
- /// </remarks>
- public string Password
- {
- get { return m_password; }
- set { m_password = value; }
- }
+ /// <summary>
+ /// The password to use to authenticate with the SMTP server
+ /// </summary>
+ /// <remarks>
+ /// <note type="caution">Authentication is only available on the MS .NET 1.1 runtime.</note>
+ /// <para>
+ /// A <see cref="Username"/> and <see cref="Password"/> must be specified when
+ /// <see cref="Authentication"/> is set to <see cref="SmtpAuthentication.Basic"/>,
+ /// otherwise the password will be ignored.
+ /// </para>
+ /// </remarks>
+ public string Password
+ {
+ get { return m_password; }
+ set { m_password = value; }
+ }
- /// <summary>
- /// The port on which the SMTP server is listening
- /// </summary>
- /// <remarks>
- /// <note type="caution">Server Port is only available on the MS .NET 1.1 runtime.</note>
- /// <para>
- /// The port on which the SMTP server is listening. The default
- /// port is <c>25</c>. The Port can only be changed when running on
- /// the MS .NET 1.1 runtime.
- /// </para>
- /// </remarks>
- public int Port
- {
- get { return m_port; }
- set { m_port = value; }
- }
+ /// <summary>
+ /// The port on which the SMTP server is listening
+ /// </summary>
+ /// <remarks>
+ /// <note type="caution">Server Port is only available on the MS .NET 1.1 runtime.</note>
+ /// <para>
+ /// The port on which the SMTP server is listening. The default
+ /// port is <c>25</c>. The Port can only be changed when running on
+ /// the MS .NET 1.1 runtime.
+ /// </para>
+ /// </remarks>
+ public int Port
+ {
+ get { return m_port; }
+ set { m_port = value; }
+ }
- /// <summary>
- /// Gets or sets the priority of the e-mail message
- /// </summary>
- /// <value>
- /// One of the <see cref="MailPriority"/> values.
- /// </value>
- /// <remarks>
- /// <para>
- /// Sets the priority of the e-mails generated by this
- /// appender. The default priority is <see cref="MailPriority.Normal"/>.
- /// </para>
- /// <para>
- /// If you are using this appender to report errors then
- /// you may want to set the priority to <see cref="MailPriority.High"/>.
- /// </para>
- /// </remarks>
- public MailPriority Priority
- {
- get { return m_mailPriority; }
- set { m_mailPriority = value; }
- }
+ /// <summary>
+ /// Gets or sets the priority of the e-mail message
+ /// </summary>
+ /// <value>
+ /// One of the <see cref="MailPriority"/> values.
+ /// </value>
+ /// <remarks>
+ /// <para>
+ /// Sets the priority of the e-mails generated by this
+ /// appender. The default priority is <see cref="MailPriority.Normal"/>.
+ /// </para>
+ /// <para>
+ /// If you are using this appender to report errors then
+ /// you may want to set the priority to <see cref="MailPriority.High"/>.
+ /// </para>
+ /// </remarks>
+ public MailPriority Priority
+ {
+ get { return m_mailPriority; }
+ set { m_mailPriority = value; }
+ }
#if NET_2_0 || MONO_2_0 || NETSTANDARD2_0
- /// <summary>
- /// Enable or disable use of SSL when sending e-mail message
- /// </summary>
- /// <remarks>
- /// This is available on MS .NET 2.0 runtime and higher
- /// </remarks>
- public bool EnableSsl
- {
- get { return m_enableSsl; }
- set { m_enableSsl = value; }
- }
+ /// <summary>
+ /// Enable or disable use of SSL when sending e-mail message
+ /// </summary>
+ /// <remarks>
+ /// This is available on MS .NET 2.0 runtime and higher
+ /// </remarks>
+ public bool EnableSsl
+ {
+ get { return m_enableSsl; }
+ set { m_enableSsl = value; }
+ }
- /// <summary>
- /// Gets or sets the reply-to e-mail address.
- /// </summary>
- /// <remarks>
- /// This is available on MS .NET 2.0 runtime and higher
- /// </remarks>
- public string ReplyTo
- {
- get { return m_replyTo; }
- set { m_replyTo = value; }
- }
+ /// <summary>
+ /// Gets or sets the reply-to e-mail address.
+ /// </summary>
+ /// <remarks>
+ /// This is available on MS .NET 2.0 runtime and higher
+ /// </remarks>
+ public string ReplyTo
+ {
+ get { return m_replyTo; }
+ set { m_replyTo = value; }
+ }
#endif
- /// <summary>
- /// Gets or sets the subject encoding to be used.
- /// </summary>
- /// <remarks>
- /// The default encoding is the operating system's current ANSI codepage.
- /// </remarks>
- public Encoding SubjectEncoding
- {
- get { return m_subjectEncoding; }
- set { m_subjectEncoding = value; }
- }
+ /// <summary>
+ /// Gets or sets the subject encoding to be used.
+ /// </summary>
+ /// <remarks>
+ /// The default encoding is the operating system's current ANSI codepage.
+ /// </remarks>
+ public Encoding SubjectEncoding
+ {
+ get { return m_subjectEncoding; }
+ set { m_subjectEncoding = value; }
+ }
- /// <summary>
- /// Gets or sets the body encoding to be used.
- /// </summary>
- /// <remarks>
- /// The default encoding is the operating system's current ANSI codepage.
- /// </remarks>
- public Encoding BodyEncoding
- {
- get { return m_bodyEncoding; }
- set { m_bodyEncoding = value; }
- }
+ /// <summary>
+ /// Gets or sets the body encoding to be used.
+ /// </summary>
+ /// <remarks>
+ /// The default encoding is the operating system's current ANSI codepage.
+ /// </remarks>
+ public Encoding BodyEncoding
+ {
+ get { return m_bodyEncoding; }
+ set { m_bodyEncoding = value; }
+ }
- #endregion // Public Instance Properties
+ #endregion // Public Instance Properties
- #region Override implementation of BufferingAppenderSkeleton
+ #region Override implementation of BufferingAppenderSkeleton
- /// <summary>
- /// Sends the contents of the cyclic buffer as an e-mail message.
- /// </summary>
- /// <param name="events">The logging events to send.</param>
- protected override void SendBuffer(LoggingEvent[] events)
- {
- // Note: this code already owns the monitor for this
- // appender. This frees us from needing to synchronize again.
- try
- {
- using StringWriter writer = new StringWriter(System.Globalization.CultureInfo.InvariantCulture);
+ /// <summary>
+ /// Sends the contents of the cyclic buffer as an e-mail message.
+ /// </summary>
+ /// <param name="events">The logging events to send.</param>
+ protected override void SendBuffer(LoggingEvent[] events)
+ {
+ // Note: this code already owns the monitor for this
+ // appender. This frees us from needing to synchronize again.
+ try
+ {
+ using StringWriter writer = new StringWriter(System.Globalization.CultureInfo.InvariantCulture);
- string t = Layout.Header;
- if (t != null)
- {
- writer.Write(t);
- }
+ string t = Layout.Header;
+ if (t != null)
+ {
+ writer.Write(t);
+ }
- for(int i = 0; i < events.Length; i++)
- {
- // Render the event and append the text to the buffer
- RenderLoggingEvent(writer, events[i]);
- }
+ for(int i = 0; i < events.Length; i++)
+ {
+ // Render the event and append the text to the buffer
+ RenderLoggingEvent(writer, events[i]);
+ }
- t = Layout.Footer;
- if (t != null)
- {
- writer.Write(t);
- }
+ t = Layout.Footer;
+ if (t != null)
+ {
+ writer.Write(t);
+ }
- SendEmail(writer.ToString());
- }
- catch(Exception e)
- {
- ErrorHandler.Error("Error occurred while sending e-mail notification.", e);
- }
- }
+ SendEmail(writer.ToString());
+ }
+ catch(Exception e)
+ {
+ ErrorHandler.Error("Error occurred while sending e-mail notification.", e);
+ }
+ }
- #endregion // Override implementation of BufferingAppenderSkeleton
+ #endregion // Override implementation of BufferingAppenderSkeleton
- #region Override implementation of AppenderSkeleton
+ #region Override implementation of AppenderSkeleton
- /// <summary>
- /// This appender requires a <see cref="Layout"/> to be set.
- /// </summary>
- /// <value><c>true</c></value>
- /// <remarks>
- /// <para>
- /// This appender requires a <see cref="Layout"/> to be set.
- /// </para>
- /// </remarks>
- protected override bool RequiresLayout
- {
- get { return true; }
- }
+ /// <summary>
+ /// This appender requires a <see cref="Layout"/> to be set.
+ /// </summary>
+ /// <value><c>true</c></value>
+ /// <remarks>
+ /// <para>
+ /// This appender requires a <see cref="Layout"/> to be set.
+ /// </para>
+ /// </remarks>
+ protected override bool RequiresLayout
+ {
+ get { return true; }
+ }
- #endregion // Override implementation of AppenderSkeleton
+ #endregion // Override implementation of AppenderSkeleton
- #region Protected Methods
+ #region Protected Methods
- /// <summary>
- /// Send the email message
- /// </summary>
- /// <param name="messageBody">the body text to include in the mail</param>
- protected virtual void SendEmail(string messageBody)
- {
+ /// <summary>
+ /// Send the email message
+ /// </summary>
+ /// <param name="messageBody">the body text to include in the mail</param>
+ protected virtual void SendEmail(string messageBody)
+ {
#if NET_2_0 || MONO_2_0 || NETSTANDARD2_0
- // .NET 2.0 has a new API for SMTP email System.Net.Mail
- // This API supports credentials and multiple hosts correctly.
- // The old API is deprecated.
+ // .NET 2.0 has a new API for SMTP email System.Net.Mail
+ // This API supports credentials and multiple hosts correctly.
+ // The old API is deprecated.
- // Create and configure the smtp client
+ // Create and configure the smtp client
#if NET_4_0 || MONO_4_0 || NETSTANDARD2_0
- using SmtpClient smtpClient = new SmtpClient();
+ using SmtpClient smtpClient = new SmtpClient();
#else
- SmtpClient smtpClient = new SmtpClient();
+ SmtpClient smtpClient = new SmtpClient();
#endif
- if (!String.IsNullOrEmpty(m_smtpHost))
- {
- smtpClient.Host = m_smtpHost;
- }
- smtpClient.Port = m_port;
- smtpClient.DeliveryMethod = SmtpDeliveryMethod.Network;
- smtpClient.EnableSsl = m_enableSsl;
+ if (!String.IsNullOrEmpty(m_smtpHost))
+ {
+ smtpClient.Host = m_smtpHost;
+ }
+ smtpClient.Port = m_port;
+ smtpClient.DeliveryMethod = SmtpDeliveryMethod.Network;
+ smtpClient.EnableSsl = m_enableSsl;
- if (m_authentication == SmtpAuthentication.Basic)
- {
- // Perform basic authentication
- smtpClient.Credentials = new System.Net.NetworkCredential(m_username, m_password);
- }
- else if (m_authentication == SmtpAuthentication.Ntlm)
- {
- // Perform integrated authentication (NTLM)
- smtpClient.Credentials = System.Net.CredentialCache.DefaultNetworkCredentials;
- }
+ if (m_authentication == SmtpAuthentication.Basic)
+ {
+ // Perform basic authentication
+ smtpClient.Credentials = new System.Net.NetworkCredential(m_username, m_password);
+ }
+ else if (m_authentication == SmtpAuthentication.Ntlm)
+ {
+ // Perform integrated authentication (NTLM)
+ smtpClient.Credentials = System.Net.CredentialCache.DefaultNetworkCredentials;
+ }
- using (MailMessage mailMessage = new MailMessage())
- {
- mailMessage.Body = messageBody;
- mailMessage.BodyEncoding = m_bodyEncoding;
- mailMessage.From = new MailAddress(m_from);
- mailMessage.To.Add(m_to);
- if (!String.IsNullOrEmpty(m_cc))
- {
- mailMessage.CC.Add(m_cc);
- }
- if (!String.IsNullOrEmpty(m_bcc))
- {
- mailMessage.Bcc.Add(m_bcc);
- }
- if (!String.IsNullOrEmpty(m_replyTo))
- {
- // .NET 4.0 warning CS0618: 'System.Net.Mail.MailMessage.ReplyTo' is obsolete:
- // 'ReplyTo is obsoleted for this type. Please use ReplyToList instead which can accept multiple addresses. http://go.microsoft.com/fwlink/?linkid=14202'
+ using (MailMessage mailMessage = new MailMessage())
+ {
+ mailMessage.Body = messageBody;
+ mailMessage.BodyEncoding = m_bodyEncoding;
+ mailMessage.From = new MailAddress(m_from);
+ mailMessage.To.Add(m_to);
+ if (!String.IsNullOrEmpty(m_cc))
+ {
+ mailMessage.CC.Add(m_cc);
+ }
+ if (!String.IsNullOrEmpty(m_bcc))
+ {
+ mailMessage.Bcc.Add(m_bcc);
+ }
+ if (!String.IsNullOrEmpty(m_replyTo))
+ {
+ // .NET 4.0 warning CS0618: 'System.Net.Mail.MailMessage.ReplyTo' is obsolete:
+ // 'ReplyTo is obsoleted for this type. Please use ReplyToList instead which can accept multiple addresses. http://go.microsoft.com/fwlink/?linkid=14202'
#if !NET_4_0 && !MONO_4_0 && !NETSTANDARD2_0
- mailMessage.ReplyTo = new MailAddress(m_replyTo);
+ mailMessage.ReplyTo = new MailAddress(m_replyTo);
#else
- mailMessage.ReplyToList.Add(new MailAddress(m_replyTo));
+ mailMessage.ReplyToList.Add(new MailAddress(m_replyTo));
#endif
- }
- mailMessage.Subject = m_subject;
- mailMessage.SubjectEncoding = m_subjectEncoding;
- mailMessage.Priority = m_mailPriority;
+ }
+ mailMessage.Subject = m_subject;
+ mailMessage.SubjectEncoding = m_subjectEncoding;
+ mailMessage.Priority = m_mailPriority;
- // TODO: Consider using SendAsync to send the message without blocking. This would be a change in
- // behaviour compared to .NET 1.x. We would need a SendCompletedCallback to log errors.
- smtpClient.Send(mailMessage);
- }
+ // TODO: Consider using SendAsync to send the message without blocking. This would be a change in
+ // behaviour compared to .NET 1.x. We would need a SendCompletedCallback to log errors.
+ smtpClient.Send(mailMessage);
+ }
#else
- // .NET 1.x uses the System.Web.Mail API for sending Mail
+ // .NET 1.x uses the System.Web.Mail API for sending Mail
- MailMessage mailMessage = new MailMessage();
- mailMessage.Body = messageBody;
- mailMessage.BodyEncoding = m_bodyEncoding;
- mailMessage.From = m_from;
- mailMessage.To = m_to;
- if (m_cc != null && m_cc.Length > 0)
- {
- mailMessage.Cc = m_cc;
- }
- if (m_bcc != null && m_bcc.Length > 0)
- {
- mailMessage.Bcc = m_bcc;
- }
- mailMessage.Subject = m_subject;
+ MailMessage mailMessage = new MailMessage();
+ mailMessage.Body = messageBody;
+ mailMessage.BodyEncoding = m_bodyEncoding;
+ mailMessage.From = m_from;
+ mailMessage.To = m_to;
+ if (m_cc != null && m_cc.Length > 0)
+ {
+ mailMessage.Cc = m_cc;
+ }
+ if (m_bcc != null && m_bcc.Length > 0)
+ {
+ mailMessage.Bcc = m_bcc;
+ }
+ mailMessage.Subject = m_subject;
#if !MONO && !NET_1_0 && !NET_1_1 && !CLI_1_0
- mailMessage.SubjectEncoding = m_subjectEncoding;
+ mailMessage.SubjectEncoding = m_subjectEncoding;
#endif
- mailMessage.Priority = m_mailPriority;
+ mailMessage.Priority = m_mailPriority;
#if NET_1_1
- // The Fields property on the MailMessage allows the CDO properties to be set directly.
- // This property is only available on .NET Framework 1.1 and the implementation must understand
- // the CDO properties. For details of the fields available in CDO see:
- //
- // http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cdosys/html/_cdosys_configuration_coclass.asp
- //
+ // The Fields property on the MailMessage allows the CDO properties to be set directly.
+ // This property is only available on .NET Framework 1.1 and the implementation must understand
+ // the CDO properties. For details of the fields available in CDO see:
+ //
+ // http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cdosys/html/_cdosys_configuration_coclass.asp
+ //
- try
- {
- if (m_authentication == SmtpAuthentication.Basic)
- {
- // Perform basic authentication
- mailMessage.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", 1);
- mailMessage.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", m_username);
- mailMessage.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", m_password);
- }
- else if (m_authentication == SmtpAuthentication.Ntlm)
- {
- // Perform integrated authentication (NTLM)
- mailMessage.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", 2);
- }
+ try
+ {
+ if (m_authentication == SmtpAuthentication.Basic)
+ {
+ // Perform basic authentication
+ mailMessage.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", 1);
+ mailMessage.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", m_username);
+ mailMessage.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", m_password);
+ }
+ else if (m_authentication == SmtpAuthentication.Ntlm)
+ {
+ // Perform integrated authentication (NTLM)
+ mailMessage.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", 2);
+ }
- // Set the port if not the default value
- if (m_port != 25)
- {
- mailMessage.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpserverport", m_port);
- }
- }
- catch(MissingMethodException missingMethodException)
- {
- // If we were compiled against .NET 1.1 but are running against .NET 1.0 then
- // we will get a MissingMethodException when accessing the MailMessage.Fields property.
+ // Set the port if not the default value
+ if (m_port != 25)
+ {
+ mailMessage.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpserverport", m_port);
+ }
+ }
+ catch(MissingMethodException missingMethodException)
+ {
+ // If we were compiled against .NET 1.1 but are running against .NET 1.0 then
+ // we will get a MissingMethodException when accessing the MailMessage.Fields property.
- ErrorHandler.Error("SmtpAppender: Authentication and server Port are only supported when running on the MS .NET 1.1 framework", missingMethodException);
- }
+ ErrorHandler.Error("SmtpAppender: Authentication and server Port are only supported when running on the MS .NET 1.1 framework", missingMethodException);
+ }
#else
- if (m_authentication != SmtpAuthentication.None)
- {
- ErrorHandler.Error("SmtpAppender: Authentication is only supported on the MS .NET 1.1 or MS .NET 2.0 builds of log4net");
- }
+ if (m_authentication != SmtpAuthentication.None)
+ {
+ ErrorHandler.Error("SmtpAppender: Authentication is only supported on the MS .NET 1.1 or MS .NET 2.0 builds of log4net");
+ }
- if (m_port != 25)
- {
- ErrorHandler.Error("SmtpAppender: Server Port is only supported on the MS .NET 1.1 or MS .NET 2.0 builds of log4net");
- }
+ if (m_port != 25)
+ {
+ ErrorHandler.Error("SmtpAppender: Server Port is only supported on the MS .NET 1.1 or MS .NET 2.0 builds of log4net");
+ }
#endif // if NET_1_1
- if (m_smtpHost != null && m_smtpHost.Length > 0)
- {
- SmtpMail.SmtpServer = m_smtpHost;
- }
+ if (m_smtpHost != null && m_smtpHost.Length > 0)
+ {
+ SmtpMail.SmtpServer = m_smtpHost;
+ }
- SmtpMail.Send(mailMessage);
+ SmtpMail.Send(mailMessage);
#endif // if NET_2_0
- }
+ }
- #endregion // Protected Methods
+ #endregion // Protected Methods
- #region Private Instance Fields
+ #region Private Instance Fields
- private string m_to;
- private string m_cc;
- private string m_bcc;
- private string m_from;
- private string m_subject;
- private string m_smtpHost;
- private Encoding m_subjectEncoding = Encoding.UTF8;
- private Encoding m_bodyEncoding = Encoding.UTF8;
+ private string m_to;
+ private string m_cc;
+ private string m_bcc;
+ private string m_from;
+ private string m_subject;
+ private string m_smtpHost;
+ private Encoding m_subjectEncoding = Encoding.UTF8;
+ private Encoding m_bodyEncoding = Encoding.UTF8;
- // authentication fields
- private SmtpAuthentication m_authentication = SmtpAuthentication.None;
- private string m_username;
- private string m_password;
+ // authentication fields
+ private SmtpAuthentication m_authentication = SmtpAuthentication.None;
+ private string m_username;
+ private string m_password;
- // server port, default port 25
- private int m_port = 25;
+ // server port, default port 25
+ private int m_port = 25;
- private MailPriority m_mailPriority = MailPriority.Normal;
+ private MailPriority m_mailPriority = MailPriority.Normal;
#if NET_2_0 || MONO_2_0 || NETSTANDARD2_0
- private bool m_enableSsl = false;
- private string m_replyTo;
+ private bool m_enableSsl = false;
+ private string m_replyTo;
#endif
- #endregion // Private Instance Fields
+ #endregion // Private Instance Fields
- #region SmtpAuthentication Enum
+ #region SmtpAuthentication Enum
- /// <summary>
- /// Values for the <see cref="SmtpAppender.Authentication"/> property.
- /// </summary>
- /// <remarks>
- /// <para>
- /// SMTP authentication modes.
- /// </para>
- /// </remarks>
- public enum SmtpAuthentication
- {
- /// <summary>
- /// No authentication
- /// </summary>
- None,
+ /// <summary>
+ /// Values for the <see cref="SmtpAppender.Authentication"/> property.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// SMTP authentication modes.
+ /// </para>
+ /// </remarks>
+ public enum SmtpAuthentication
+ {
+ /// <summary>
+ /// No authentication
+ /// </summary>
+ None,
- /// <summary>
- /// Basic authentication.
- /// </summary>
- /// <remarks>
- /// Requires a username and password to be supplied
- /// </remarks>
- Basic,
+ /// <summary>
+ /// Basic authentication.
+ /// </summary>
+ /// <remarks>
+ /// Requires a username and password to be supplied
+ /// </remarks>
+ Basic,
- /// <summary>
- /// Integrated authentication
- /// </summary>
- /// <remarks>
- /// Uses the Windows credentials from the current thread or process to authenticate.
- /// </remarks>
- Ntlm
- }
+ /// <summary>
+ /// Integrated authentication
+ /// </summary>
+ /// <remarks>
+ /// Uses the Windows credentials from the current thread or process to authenticate.
+ /// </remarks>
+ Ntlm
+ }
- #endregion // SmtpAuthentication Enum
+ #endregion // SmtpAuthentication Enum
- private static readonly char[] ADDRESS_DELIMITERS = new char[] { ',', ';' };
-
- /// <summary>
- /// trims leading and trailing commas or semicolons
- /// </summary>
- private static string MaybeTrimSeparators(string s) {
+ private static readonly char[] ADDRESS_DELIMITERS = new char[] { ',', ';' };
+
+ /// <summary>
+ /// trims leading and trailing commas or semicolons
+ /// </summary>
+ private static string MaybeTrimSeparators(string s) {
#if NET_2_0 || MONO_2_0 || NETSTANDARD2_0
- return string.IsNullOrEmpty(s) ? s : s.Trim(ADDRESS_DELIMITERS);
+ return string.IsNullOrEmpty(s) ? s : s.Trim(ADDRESS_DELIMITERS);
#else
- return s != null && s.Length > 0 ? s : s.Trim(ADDRESS_DELIMITERS);
+ return s != null && s.Length > 0 ? s : s.Trim(ADDRESS_DELIMITERS);
#endif
- }
- }
+ }
+ }
}
#endif // !NETCF && !SSCLI
diff --git a/src/log4net/Appender/SmtpPickupDirAppender.cs b/src/log4net/Appender/SmtpPickupDirAppender.cs
index 17a6af4..f3f3aa0 100644
--- a/src/log4net/Appender/SmtpPickupDirAppender.cs
+++ b/src/log4net/Appender/SmtpPickupDirAppender.cs
@@ -25,327 +25,327 @@
namespace log4net.Appender
{
- /// <summary>
- /// Send an email when a specific logging event occurs, typically on errors
- /// or fatal errors. Rather than sending via smtp it writes a file into the
- /// directory specified by <see cref="PickupDir"/>. This allows services such
- /// as the IIS SMTP agent to manage sending the messages.
- /// </summary>
- /// <remarks>
- /// <para>
- /// The configuration for this appender is identical to that of the <c>SMTPAppender</c>,
- /// except that instead of specifying the <c>SMTPAppender.SMTPHost</c> you specify
- /// <see cref="PickupDir"/>.
- /// </para>
- /// <para>
- /// The number of logging events delivered in this e-mail depend on
- /// the value of <see cref="BufferingAppenderSkeleton.BufferSize"/> option. The
- /// <see cref="SmtpPickupDirAppender"/> keeps only the last
- /// <see cref="BufferingAppenderSkeleton.BufferSize"/> logging events in its
- /// cyclic buffer. This keeps memory requirements at a reasonable level while
- /// still delivering useful application context.
- /// </para>
- /// </remarks>
- /// <author>Niall Daley</author>
- /// <author>Nicko Cadell</author>
- public class SmtpPickupDirAppender : BufferingAppenderSkeleton
- {
- #region Public Instance Constructors
+ /// <summary>
+ /// Send an email when a specific logging event occurs, typically on errors
+ /// or fatal errors. Rather than sending via smtp it writes a file into the
+ /// directory specified by <see cref="PickupDir"/>. This allows services such
+ /// as the IIS SMTP agent to manage sending the messages.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// The configuration for this appender is identical to that of the <c>SMTPAppender</c>,
+ /// except that instead of specifying the <c>SMTPAppender.SMTPHost</c> you specify
+ /// <see cref="PickupDir"/>.
+ /// </para>
+ /// <para>
+ /// The number of logging events delivered in this e-mail depend on
+ /// the value of <see cref="BufferingAppenderSkeleton.BufferSize"/> option. The
+ /// <see cref="SmtpPickupDirAppender"/> keeps only the last
+ /// <see cref="BufferingAppenderSkeleton.BufferSize"/> logging events in its
+ /// cyclic buffer. This keeps memory requirements at a reasonable level while
+ /// still delivering useful application context.
+ /// </para>
+ /// </remarks>
+ /// <author>Niall Daley</author>
+ /// <author>Nicko Cadell</author>
+ public class SmtpPickupDirAppender : BufferingAppenderSkeleton
+ {
+ #region Public Instance Constructors
- /// <summary>
- /// Default constructor
- /// </summary>
- /// <remarks>
- /// <para>
- /// Default constructor
- /// </para>
- /// </remarks>
- public SmtpPickupDirAppender()
- {
- m_fileExtension = string.Empty; // Default to empty string, not null
- }
+ /// <summary>
+ /// Default constructor
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Default constructor
+ /// </para>
+ /// </remarks>
+ public SmtpPickupDirAppender()
+ {
+ m_fileExtension = string.Empty; // Default to empty string, not null
+ }
- #endregion Public Instance Constructors
+ #endregion Public Instance Constructors
- #region Public Instance Properties
+ #region Public Instance Properties
- /// <summary>
- /// Gets or sets a semicolon-delimited list of recipient e-mail addresses.
- /// </summary>
- /// <value>
- /// A semicolon-delimited list of e-mail addresses.
- /// </value>
- /// <remarks>
- /// <para>
- /// A semicolon-delimited list of e-mail addresses.
- /// </para>
- /// </remarks>
- public string To
- {
- get { return m_to; }
- set { m_to = value; }
- }
+ /// <summary>
+ /// Gets or sets a semicolon-delimited list of recipient e-mail addresses.
+ /// </summary>
+ /// <value>
+ /// A semicolon-delimited list of e-mail addresses.
+ /// </value>
+ /// <remarks>
+ /// <para>
+ /// A semicolon-delimited list of e-mail addresses.
+ /// </para>
+ /// </remarks>
+ public string To
+ {
+ get { return m_to; }
+ set { m_to = value; }
+ }
- /// <summary>
- /// Gets or sets the e-mail address of the sender.
- /// </summary>
- /// <value>
- /// The e-mail address of the sender.
- /// </value>
- /// <remarks>
- /// <para>
- /// The e-mail address of the sender.
- /// </para>
- /// </remarks>
- public string From
- {
- get { return m_from; }
- set { m_from = value; }
- }
+ /// <summary>
+ /// Gets or sets the e-mail address of the sender.
+ /// </summary>
+ /// <value>
+ /// The e-mail address of the sender.
+ /// </value>
+ /// <remarks>
+ /// <para>
+ /// The e-mail address of the sender.
+ /// </para>
+ /// </remarks>
+ public string From
+ {
+ get { return m_from; }
+ set { m_from = value; }
+ }
- /// <summary>
- /// Gets or sets the subject line of the e-mail message.
- /// </summary>
- /// <value>
- /// The subject line of the e-mail message.
- /// </value>
- /// <remarks>
- /// <para>
- /// The subject line of the e-mail message.
- /// </para>
- /// </remarks>
- public string Subject
- {
- get { return m_subject; }
- set { m_subject = value; }
- }
+ /// <summary>
+ /// Gets or sets the subject line of the e-mail message.
+ /// </summary>
+ /// <value>
+ /// The subject line of the e-mail message.
+ /// </value>
+ /// <remarks>
+ /// <para>
+ /// The subject line of the e-mail message.
+ /// </para>
+ /// </remarks>
+ public string Subject
+ {
+ get { return m_subject; }
+ set { m_subject = value; }
+ }
- /// <summary>
- /// Gets or sets the path to write the messages to.
- /// </summary>
- /// <remarks>
- /// <para>
- /// Gets or sets the path to write the messages to. This should be the same
- /// as that used by the agent sending the messages.
- /// </para>
- /// </remarks>
- public string PickupDir
- {
- get { return m_pickupDir; }
- set { m_pickupDir = value; }
- }
+ /// <summary>
+ /// Gets or sets the path to write the messages to.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Gets or sets the path to write the messages to. This should be the same
+ /// as that used by the agent sending the messages.
+ /// </para>
+ /// </remarks>
+ public string PickupDir
+ {
+ get { return m_pickupDir; }
+ set { m_pickupDir = value; }
+ }
- /// <summary>
- /// Gets or sets the file extension for the generated files
- /// </summary>
- /// <value>
- /// The file extension for the generated files
- /// </value>
- /// <remarks>
- /// <para>
- /// The file extension for the generated files
- /// </para>
- /// </remarks>
- public string FileExtension
- {
- get { return m_fileExtension; }
- set
- {
- m_fileExtension = value;
- if (m_fileExtension == null)
- {
- m_fileExtension = string.Empty;
- }
- // Make sure any non empty extension starts with a dot
+ /// <summary>
+ /// Gets or sets the file extension for the generated files
+ /// </summary>
+ /// <value>
+ /// The file extension for the generated files
+ /// </value>
+ /// <remarks>
+ /// <para>
+ /// The file extension for the generated files
+ /// </para>
+ /// </remarks>
+ public string FileExtension
+ {
+ get { return m_fileExtension; }
+ set
+ {
+ m_fileExtension = value;
+ if (m_fileExtension == null)
+ {
+ m_fileExtension = string.Empty;
+ }
+ // Make sure any non empty extension starts with a dot
#if NET_2_0 || MONO_2_0 || NETSTANDARD
- if (!string.IsNullOrEmpty(m_fileExtension) && !m_fileExtension.StartsWith("."))
+ if (!string.IsNullOrEmpty(m_fileExtension) && !m_fileExtension.StartsWith("."))
#else
- if (m_fileExtension != null && m_fileExtension.Length > 0 && !m_fileExtension.StartsWith("."))
+ if (m_fileExtension != null && m_fileExtension.Length > 0 && !m_fileExtension.StartsWith("."))
#endif
- {
- m_fileExtension = "." + m_fileExtension;
- }
- }
- }
+ {
+ m_fileExtension = "." + m_fileExtension;
+ }
+ }
+ }
- /// <summary>
- /// Gets or sets the <see cref="SecurityContext"/> used to write to the pickup directory.
- /// </summary>
- /// <value>
- /// The <see cref="SecurityContext"/> used to write to the pickup directory.
- /// </value>
- /// <remarks>
- /// <para>
- /// Unless a <see cref="SecurityContext"/> specified here for this appender
- /// the <see cref="SecurityContextProvider.DefaultProvider"/> is queried for the
- /// security context to use. The default behavior is to use the security context
- /// of the current thread.
- /// </para>
- /// </remarks>
- public SecurityContext SecurityContext
- {
- get { return m_securityContext; }
- set { m_securityContext = value; }
- }
+ /// <summary>
+ /// Gets or sets the <see cref="SecurityContext"/> used to write to the pickup directory.
+ /// </summary>
+ /// <value>
+ /// The <see cref="SecurityContext"/> used to write to the pickup directory.
+ /// </value>
+ /// <remarks>
+ /// <para>
+ /// Unless a <see cref="SecurityContext"/> specified here for this appender
+ /// the <see cref="SecurityContextProvider.DefaultProvider"/> is queried for the
+ /// security context to use. The default behavior is to use the security context
+ /// of the current thread.
+ /// </para>
+ /// </remarks>
+ public SecurityContext SecurityContext
+ {
+ get { return m_securityContext; }
+ set { m_securityContext = value; }
+ }
- #endregion Public Instance Properties
+ #endregion Public Instance Properties
- #region Override implementation of BufferingAppenderSkeleton
+ #region Override implementation of BufferingAppenderSkeleton
- /// <summary>
- /// Sends the contents of the cyclic buffer as an e-mail message.
- /// </summary>
- /// <param name="events">The logging events to send.</param>
- /// <remarks>
- /// <para>
- /// Sends the contents of the cyclic buffer as an e-mail message.
- /// </para>
- /// </remarks>
- protected override void SendBuffer(LoggingEvent[] events)
- {
- // Note: this code already owns the monitor for this
- // appender. This frees us from needing to synchronize again.
- try
- {
- string filePath = null;
- StreamWriter writer = null;
+ /// <summary>
+ /// Sends the contents of the cyclic buffer as an e-mail message.
+ /// </summary>
+ /// <param name="events">The logging events to send.</param>
+ /// <remarks>
+ /// <para>
+ /// Sends the contents of the cyclic buffer as an e-mail message.
+ /// </para>
+ /// </remarks>
+ protected override void SendBuffer(LoggingEvent[] events)
+ {
+ // Note: this code already owns the monitor for this
+ // appender. This frees us from needing to synchronize again.
+ try
+ {
+ string filePath = null;
+ StreamWriter writer = null;
- // Impersonate to open the file
- using(SecurityContext.Impersonate(this))
- {
- filePath = Path.Combine(m_pickupDir, SystemInfo.NewGuid().ToString("N") + m_fileExtension);
- writer = File.CreateText(filePath);
- }
+ // Impersonate to open the file
+ using(SecurityContext.Impersonate(this))
+ {
+ filePath = Path.Combine(m_pickupDir, SystemInfo.NewGuid().ToString("N") + m_fileExtension);
+ writer = File.CreateText(filePath);
+ }
- if (writer == null)
- {
- ErrorHandler.Error("Failed to create output file for writing ["+filePath+"]", null, ErrorCode.FileOpenFailure);
- }
- else
- {
- using(writer)
- {
- writer.WriteLine("To: " + m_to);
- writer.WriteLine("From: " + m_from);
- writer.WriteLine("Subject: " + m_subject);
- writer.WriteLine("Date: " + DateTime.UtcNow.ToString("r"));
- writer.WriteLine("");
+ if (writer == null)
+ {
+ ErrorHandler.Error("Failed to create output file for writing ["+filePath+"]", null, ErrorCode.FileOpenFailure);
+ }
+ else
+ {
+ using(writer)
+ {
+ writer.WriteLine("To: " + m_to);
+ writer.WriteLine("From: " + m_from);
+ writer.WriteLine("Subject: " + m_subject);
+ writer.WriteLine("Date: " + DateTime.UtcNow.ToString("r"));
+ writer.WriteLine("");
- string t = Layout.Header;
- if (t != null)
- {
- writer.Write(t);
- }
+ string t = Layout.Header;
+ if (t != null)
+ {
+ writer.Write(t);
+ }
- for(int i = 0; i < events.Length; i++)
- {
- // Render the event and append the text to the buffer
- RenderLoggingEvent(writer, events[i]);
- }
+ for(int i = 0; i < events.Length; i++)
+ {
+ // Render the event and append the text to the buffer
+ RenderLoggingEvent(writer, events[i]);
+ }
- t = Layout.Footer;
- if (t != null)
- {
- writer.Write(t);
- }
+ t = Layout.Footer;
+ if (t != null)
+ {
+ writer.Write(t);
+ }
- writer.WriteLine("");
- writer.WriteLine(".");
- }
- }
- }
- catch(Exception e)
- {
- ErrorHandler.Error("Error occurred while sending e-mail notification.", e);
- }
- }
+ writer.WriteLine("");
+ writer.WriteLine(".");
+ }
+ }
+ }
+ catch(Exception e)
+ {
+ ErrorHandler.Error("Error occurred while sending e-mail notification.", e);
+ }
+ }
- #endregion Override implementation of BufferingAppenderSkeleton
+ #endregion Override implementation of BufferingAppenderSkeleton
- #region Override implementation of AppenderSkeleton
+ #region Override implementation of AppenderSkeleton
- /// <summary>
- /// Activate the options on this appender.
- /// </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>
- public override void ActivateOptions()
- {
- base.ActivateOptions();
+ /// <summary>
+ /// Activate the options on this appender.
+ /// </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>
+ public override void ActivateOptions()
+ {
+ base.ActivateOptions();
- if (m_securityContext == null)
- {
- m_securityContext = SecurityContextProvider.DefaultProvider.CreateSecurityContext(this);
- }
+ if (m_securityContext == null)
+ {
+ m_securityContext = SecurityContextProvider.DefaultProvider.CreateSecurityContext(this);
+ }
- using(SecurityContext.Impersonate(this))
- {
- m_pickupDir = ConvertToFullPath(m_pickupDir.Trim());
- }
- }
+ using(SecurityContext.Impersonate(this))
+ {
+ m_pickupDir = ConvertToFullPath(m_pickupDir.Trim());
+ }
+ }
- /// <summary>
- /// This appender requires a <see cref="Layout"/> to be set.
- /// </summary>
- /// <value><c>true</c></value>
- /// <remarks>
- /// <para>
- /// This appender requires a <see cref="Layout"/> to be set.
- /// </para>
- /// </remarks>
- protected override bool RequiresLayout
- {
- get { return true; }
- }
+ /// <summary>
+ /// This appender requires a <see cref="Layout"/> to be set.
+ /// </summary>
+ /// <value><c>true</c></value>
+ /// <remarks>
+ /// <para>
+ /// This appender requires a <see cref="Layout"/> to be set.
+ /// </para>
+ /// </remarks>
+ protected override bool RequiresLayout
+ {
+ get { return true; }
+ }
- #endregion Override implementation of AppenderSkeleton
+ #endregion Override implementation of AppenderSkeleton
- #region Protected Static Methods
+ #region Protected Static Methods
- /// <summary>
- /// Convert a path into a fully qualified path.
- /// </summary>
- /// <param name="path">The path to convert.</param>
- /// <returns>The fully qualified path.</returns>
- /// <remarks>
- /// <para>
- /// Converts the path specified to a fully
- /// qualified path. If the path is relative it is
- /// taken as relative from the application base
- /// directory.
- /// </para>
- /// </remarks>
- protected static string ConvertToFullPath(string path)
- {
- return SystemInfo.ConvertToFullPath(path);
- }
+ /// <summary>
+ /// Convert a path into a fully qualified path.
+ /// </summary>
+ /// <param name="path">The path to convert.</param>
+ /// <returns>The fully qualified path.</returns>
+ /// <remarks>
+ /// <para>
+ /// Converts the path specified to a fully
+ /// qualified path. If the path is relative it is
+ /// taken as relative from the application base
+ /// directory.
+ /// </para>
+ /// </remarks>
+ protected static string ConvertToFullPath(string path)
+ {
+ return SystemInfo.ConvertToFullPath(path);
+ }
- #endregion Protected Static Methods
+ #endregion Protected Static Methods
- #region Private Instance Fields
+ #region Private Instance Fields
- private string m_to;
- private string m_from;
- private string m_subject;
- private string m_pickupDir;
- private string m_fileExtension;
+ private string m_to;
+ private string m_from;
+ private string m_subject;
+ private string m_pickupDir;
+ private string m_fileExtension;
- /// <summary>
- /// The security context to use for privileged calls
- /// </summary>
- private SecurityContext m_securityContext;
+ /// <summary>
+ /// The security context to use for privileged calls
+ /// </summary>
+ private SecurityContext m_securityContext;
- #endregion Private Instance Fields
- }
+ #endregion Private Instance Fields
+ }
}
diff --git a/src/log4net/Appender/TelnetAppender.cs b/src/log4net/Appender/TelnetAppender.cs
index 0d61a00..9aa503e 100644
--- a/src/log4net/Appender/TelnetAppender.cs
+++ b/src/log4net/Appender/TelnetAppender.cs
@@ -32,511 +32,511 @@
namespace log4net.Appender
{
- /// <summary>
- /// Appender that allows clients to connect via Telnet to receive log messages
- /// </summary>
- /// <remarks>
- /// <para>
- /// The TelnetAppender accepts socket connections and streams logging messages
- /// back to the client.
- /// The output is provided in a telnet-friendly way so that a log can be monitored
- /// over a TCP/IP socket.
- /// This allows simple remote monitoring of application logging.
- /// </para>
- /// <para>
- /// The default <see cref="Port"/> is 23 (the telnet port).
- /// </para>
- /// </remarks>
- /// <author>Keith Long</author>
- /// <author>Nicko Cadell</author>
- public class TelnetAppender : AppenderSkeleton
- {
- private SocketHandler m_handler;
- private int m_listeningPort = 23;
+ /// <summary>
+ /// Appender that allows clients to connect via Telnet to receive log messages
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// The TelnetAppender accepts socket connections and streams logging messages
+ /// back to the client.
+ /// The output is provided in a telnet-friendly way so that a log can be monitored
+ /// over a TCP/IP socket.
+ /// This allows simple remote monitoring of application logging.
+ /// </para>
+ /// <para>
+ /// The default <see cref="Port"/> is 23 (the telnet port).
+ /// </para>
+ /// </remarks>
+ /// <author>Keith Long</author>
+ /// <author>Nicko Cadell</author>
+ public class TelnetAppender : AppenderSkeleton
+ {
+ private SocketHandler m_handler;
+ private int m_listeningPort = 23;
- #region Constructor
+ #region Constructor
- /// <summary>
- /// Default constructor
- /// </summary>
- /// <remarks>
- /// <para>
- /// Default constructor
- /// </para>
- /// </remarks>
- public TelnetAppender()
- {
- }
+ /// <summary>
+ /// Default constructor
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Default constructor
+ /// </para>
+ /// </remarks>
+ public TelnetAppender()
+ {
+ }
- #endregion
+ #endregion
- #region Private Static Fields
+ #region Private Static Fields
- /// <summary>
- /// The fully qualified type of the TelnetAppender class.
- /// </summary>
- /// <remarks>
- /// Used by the internal logger to record the Type of the
- /// log message.
- /// </remarks>
- private static readonly Type declaringType = typeof(TelnetAppender);
+ /// <summary>
+ /// The fully qualified type of the TelnetAppender class.
+ /// </summary>
+ /// <remarks>
+ /// Used by the internal logger to record the Type of the
+ /// log message.
+ /// </remarks>
+ private static readonly Type declaringType = typeof(TelnetAppender);
- #endregion Private Static Fields
+ #endregion Private Static Fields
- /// <summary>
- /// Gets or sets the TCP port number on which this <see cref="TelnetAppender"/> will listen for connections.
- /// </summary>
- /// <value>
- /// An integer value in the range <see cref="IPEndPoint.MinPort" /> to <see cref="IPEndPoint.MaxPort" />
- /// indicating the TCP port number on which this <see cref="TelnetAppender"/> will listen for connections.
- /// </value>
- /// <remarks>
- /// <para>
- /// The default value is 23 (the telnet port).
- /// </para>
- /// </remarks>
- /// <exception cref="ArgumentOutOfRangeException">The value specified is less than <see cref="IPEndPoint.MinPort" />
- /// or greater than <see cref="IPEndPoint.MaxPort" />.</exception>
- public int Port
- {
- get
- {
- return m_listeningPort;
- }
- set
- {
- if (value < IPEndPoint.MinPort || value > IPEndPoint.MaxPort)
- {
- throw log4net.Util.SystemInfo.CreateArgumentOutOfRangeException("value", (object)value,
- "The value specified for Port is less than " +
- IPEndPoint.MinPort.ToString(NumberFormatInfo.InvariantInfo) +
- " or greater than " +
- IPEndPoint.MaxPort.ToString(NumberFormatInfo.InvariantInfo) + ".");
- }
- else
- {
- m_listeningPort = value;
- }
- }
- }
+ /// <summary>
+ /// Gets or sets the TCP port number on which this <see cref="TelnetAppender"/> will listen for connections.
+ /// </summary>
+ /// <value>
+ /// An integer value in the range <see cref="IPEndPoint.MinPort" /> to <see cref="IPEndPoint.MaxPort" />
+ /// indicating the TCP port number on which this <see cref="TelnetAppender"/> will listen for connections.
+ /// </value>
+ /// <remarks>
+ /// <para>
+ /// The default value is 23 (the telnet port).
+ /// </para>
+ /// </remarks>
+ /// <exception cref="ArgumentOutOfRangeException">The value specified is less than <see cref="IPEndPoint.MinPort" />
+ /// or greater than <see cref="IPEndPoint.MaxPort" />.</exception>
+ public int Port
+ {
+ get
+ {
+ return m_listeningPort;
+ }
+ set
+ {
+ if (value < IPEndPoint.MinPort || value > IPEndPoint.MaxPort)
+ {
+ throw log4net.Util.SystemInfo.CreateArgumentOutOfRangeException("value", (object)value,
+ "The value specified for Port is less than " +
+ IPEndPoint.MinPort.ToString(NumberFormatInfo.InvariantInfo) +
+ " or greater than " +
+ IPEndPoint.MaxPort.ToString(NumberFormatInfo.InvariantInfo) + ".");
+ }
+ else
+ {
+ m_listeningPort = value;
+ }
+ }
+ }
- #region Override implementation of AppenderSkeleton
+ #region Override implementation of AppenderSkeleton
- /// <summary>
- /// Overrides the parent method to close the socket handler
- /// </summary>
- /// <remarks>
- /// <para>
- /// Closes all the outstanding connections.
- /// </para>
- /// </remarks>
- protected override void OnClose()
- {
- base.OnClose();
+ /// <summary>
+ /// Overrides the parent method to close the socket handler
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Closes all the outstanding connections.
+ /// </para>
+ /// </remarks>
+ protected override void OnClose()
+ {
+ base.OnClose();
- if (m_handler != null)
- {
- m_handler.Dispose();
- m_handler = null;
- }
- }
+ if (m_handler != null)
+ {
+ m_handler.Dispose();
+ m_handler = null;
+ }
+ }
- /// <summary>
- /// This appender requires a <see cref="Layout"/> to be set.
- /// </summary>
- /// <value><c>true</c></value>
- /// <remarks>
- /// <para>
- /// This appender requires a <see cref="Layout"/> to be set.
- /// </para>
- /// </remarks>
- protected override bool RequiresLayout
- {
- get { return true; }
- }
+ /// <summary>
+ /// This appender requires a <see cref="Layout"/> to be set.
+ /// </summary>
+ /// <value><c>true</c></value>
+ /// <remarks>
+ /// <para>
+ /// This appender requires a <see cref="Layout"/> to be set.
+ /// </para>
+ /// </remarks>
+ protected override bool RequiresLayout
+ {
+ get { return true; }
+ }
- /// <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>
- /// <para>
- /// Create the socket handler and wait for connections
- /// </para>
- /// </remarks>
- public override void ActivateOptions()
- {
- base.ActivateOptions();
- try
- {
- LogLog.Debug(declaringType, "Creating SocketHandler to listen on port ["+m_listeningPort+"]");
- m_handler = new SocketHandler(m_listeningPort);
- }
- catch(Exception ex)
- {
- LogLog.Error(declaringType, "Failed to create SocketHandler", ex);
- throw;
- }
- }
+ /// <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>
+ /// <para>
+ /// Create the socket handler and wait for connections
+ /// </para>
+ /// </remarks>
+ public override void ActivateOptions()
+ {
+ base.ActivateOptions();
+ try
+ {
+ LogLog.Debug(declaringType, "Creating SocketHandler to listen on port ["+m_listeningPort+"]");
+ m_handler = new SocketHandler(m_listeningPort);
+ }
+ catch(Exception ex)
+ {
+ LogLog.Error(declaringType, "Failed to create SocketHandler", ex);
+ throw;
+ }
+ }
- /// <summary>
- /// Writes the logging event to each connected client.
- /// </summary>
- /// <param name="loggingEvent">The event to log.</param>
- /// <remarks>
- /// <para>
- /// Writes the logging event to each connected client.
- /// </para>
- /// </remarks>
- protected override void Append(LoggingEvent loggingEvent)
- {
- if (m_handler != null && m_handler.HasConnections)
- {
- m_handler.Send(RenderLoggingEvent(loggingEvent));
- }
- }
+ /// <summary>
+ /// Writes the logging event to each connected client.
+ /// </summary>
+ /// <param name="loggingEvent">The event to log.</param>
+ /// <remarks>
+ /// <para>
+ /// Writes the logging event to each connected client.
+ /// </para>
+ /// </remarks>
+ protected override void Append(LoggingEvent loggingEvent)
+ {
+ if (m_handler != null && m_handler.HasConnections)
+ {
+ m_handler.Send(RenderLoggingEvent(loggingEvent));
+ }
+ }
- #endregion
+ #endregion
- #region SocketHandler helper class
+ #region SocketHandler helper class
- /// <summary>
- /// Helper class to manage connected clients
- /// </summary>
- /// <remarks>
- /// <para>
- /// The SocketHandler class is used to accept connections from
- /// clients. It is threaded so that clients can connect/disconnect
- /// asynchronously.
- /// </para>
- /// </remarks>
- protected class SocketHandler : IDisposable
- {
- private const int MAX_CONNECTIONS = 20;
+ /// <summary>
+ /// Helper class to manage connected clients
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// The SocketHandler class is used to accept connections from
+ /// clients. It is threaded so that clients can connect/disconnect
+ /// asynchronously.
+ /// </para>
+ /// </remarks>
+ protected class SocketHandler : IDisposable
+ {
+ private const int MAX_CONNECTIONS = 20;
- private Socket m_serverSocket;
- private ArrayList m_clients = new ArrayList();
+ private Socket m_serverSocket;
+ private ArrayList m_clients = new ArrayList();
- /// <summary>
- /// Class that represents a client connected to this handler
- /// </summary>
- /// <remarks>
- /// <para>
- /// Class that represents a client connected to this handler
- /// </para>
- /// </remarks>
- protected class SocketClient : IDisposable
- {
- private Socket m_socket;
- private StreamWriter m_writer;
+ /// <summary>
+ /// Class that represents a client connected to this handler
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Class that represents a client connected to this handler
+ /// </para>
+ /// </remarks>
+ protected class SocketClient : IDisposable
+ {
+ private Socket m_socket;
+ private StreamWriter m_writer;
- /// <summary>
- /// Create this <see cref="SocketClient"/> for the specified <see cref="Socket"/>
- /// </summary>
- /// <param name="socket">the client's socket</param>
- /// <remarks>
- /// <para>
- /// Opens a stream writer on the socket.
- /// </para>
- /// </remarks>
- public SocketClient(Socket socket)
- {
- m_socket = socket;
+ /// <summary>
+ /// Create this <see cref="SocketClient"/> for the specified <see cref="Socket"/>
+ /// </summary>
+ /// <param name="socket">the client's socket</param>
+ /// <remarks>
+ /// <para>
+ /// Opens a stream writer on the socket.
+ /// </para>
+ /// </remarks>
+ public SocketClient(Socket socket)
+ {
+ m_socket = socket;
- try
- {
- m_writer = new StreamWriter(new NetworkStream(socket));
- }
- catch
- {
- Dispose();
- throw;
- }
- }
+ try
+ {
+ m_writer = new StreamWriter(new NetworkStream(socket));
+ }
+ catch
+ {
+ Dispose();
+ throw;
+ }
+ }
- /// <summary>
- /// Write a string to the client
- /// </summary>
- /// <param name="message">string to send</param>
- /// <remarks>
- /// <para>
- /// Write a string to the client
- /// </para>
- /// </remarks>
- public void Send(String message)
- {
- m_writer.Write(message);
- m_writer.Flush();
- }
+ /// <summary>
+ /// Write a string to the client
+ /// </summary>
+ /// <param name="message">string to send</param>
+ /// <remarks>
+ /// <para>
+ /// Write a string to the client
+ /// </para>
+ /// </remarks>
+ public void Send(String message)
+ {
+ m_writer.Write(message);
+ m_writer.Flush();
+ }
- #region IDisposable Members
+ #region IDisposable Members
- /// <summary>
- /// Cleanup the clients connection
- /// </summary>
- /// <remarks>
- /// <para>
- /// Close the socket connection.
- /// </para>
- /// </remarks>
- public void Dispose()
- {
- try
- {
- if (m_writer != null)
- {
- m_writer.Dispose();
- m_writer = null;
- }
- }
- catch { }
+ /// <summary>
+ /// Cleanup the clients connection
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Close the socket connection.
+ /// </para>
+ /// </remarks>
+ public void Dispose()
+ {
+ try
+ {
+ if (m_writer != null)
+ {
+ m_writer.Dispose();
+ m_writer = null;
+ }
+ }
+ catch { }
- if (m_socket != null)
- {
- try
- {
- m_socket.Shutdown(SocketShutdown.Both);
- }
- catch { }
+ if (m_socket != null)
+ {
+ try
+ {
+ m_socket.Shutdown(SocketShutdown.Both);
+ }
+ catch { }
- try
- {
+ try
+ {
#if NET_4_0 || NETSTANDARD
- m_socket.Dispose();
+ m_socket.Dispose();
#else
- m_socket.Close();
+ m_socket.Close();
#endif
- }
- catch { }
+ }
+ catch { }
- m_socket = null;
- }
- }
+ m_socket = null;
+ }
+ }
- #endregion
- }
-
- /// <summary>
- /// Opens a new server port on <paramref ref="port"/>
- /// </summary>
- /// <param name="port">the local port to listen on for connections</param>
- /// <remarks>
- /// <para>
- /// Creates a socket handler on the specified local server port.
- /// </para>
- /// </remarks>
- public SocketHandler(int port)
- {
- m_serverSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
+ #endregion
+ }
+
+ /// <summary>
+ /// Opens a new server port on <paramref ref="port"/>
+ /// </summary>
+ /// <param name="port">the local port to listen on for connections</param>
+ /// <remarks>
+ /// <para>
+ /// Creates a socket handler on the specified local server port.
+ /// </para>
+ /// </remarks>
+ public SocketHandler(int port)
+ {
+ m_serverSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
- m_serverSocket.Bind(new IPEndPoint(IPAddress.Any, port));
- m_serverSocket.Listen(5);
- AcceptConnection();
- }
+ m_serverSocket.Bind(new IPEndPoint(IPAddress.Any, port));
+ m_serverSocket.Listen(5);
+ AcceptConnection();
+ }
- private void AcceptConnection()
- {
+ private void AcceptConnection()
+ {
#if NETSTANDARD
- m_serverSocket.AcceptAsync().ContinueWith(OnConnect, TaskScheduler.Default);
+ m_serverSocket.AcceptAsync().ContinueWith(OnConnect, TaskScheduler.Default);
#else
- m_serverSocket.BeginAccept(new AsyncCallback(OnConnect), null);
+ m_serverSocket.BeginAccept(new AsyncCallback(OnConnect), null);
#endif
- }
+ }
- /// <summary>
- /// Sends a string message to each of the connected clients
- /// </summary>
- /// <param name="message">the text to send</param>
- /// <remarks>
- /// <para>
- /// Sends a string message to each of the connected clients
- /// </para>
- /// </remarks>
- public void Send(String message)
- {
- ArrayList localClients = m_clients;
+ /// <summary>
+ /// Sends a string message to each of the connected clients
+ /// </summary>
+ /// <param name="message">the text to send</param>
+ /// <remarks>
+ /// <para>
+ /// Sends a string message to each of the connected clients
+ /// </para>
+ /// </remarks>
+ public void Send(String message)
+ {
+ ArrayList localClients = m_clients;
- foreach (SocketClient client in localClients)
- {
- try
- {
- client.Send(message);
- }
- catch (Exception)
- {
- // The client has closed the connection, remove it from our list
- client.Dispose();
- RemoveClient(client);
- }
- }
- }
+ foreach (SocketClient client in localClients)
+ {
+ try
+ {
+ client.Send(message);
+ }
+ catch (Exception)
+ {
+ // The client has closed the connection, remove it from our list
+ client.Dispose();
+ RemoveClient(client);
+ }
+ }
+ }
- /// <summary>
- /// Add a client to the internal clients list
- /// </summary>
- /// <param name="client">client to add</param>
- private void AddClient(SocketClient client)
- {
- lock(this)
- {
- ArrayList clientsCopy = (ArrayList)m_clients.Clone();
- clientsCopy.Add(client);
- m_clients = clientsCopy;
- }
- }
+ /// <summary>
+ /// Add a client to the internal clients list
+ /// </summary>
+ /// <param name="client">client to add</param>
+ private void AddClient(SocketClient client)
+ {
+ lock(this)
+ {
+ ArrayList clientsCopy = (ArrayList)m_clients.Clone();
+ clientsCopy.Add(client);
+ m_clients = clientsCopy;
+ }
+ }
- /// <summary>
- /// Remove a client from the internal clients list
- /// </summary>
- /// <param name="client">client to remove</param>
- private void RemoveClient(SocketClient client)
- {
- lock(this)
- {
- ArrayList clientsCopy = (ArrayList)m_clients.Clone();
- clientsCopy.Remove(client);
- m_clients = clientsCopy;
- }
- }
+ /// <summary>
+ /// Remove a client from the internal clients list
+ /// </summary>
+ /// <param name="client">client to remove</param>
+ private void RemoveClient(SocketClient client)
+ {
+ lock(this)
+ {
+ ArrayList clientsCopy = (ArrayList)m_clients.Clone();
+ clientsCopy.Remove(client);
+ m_clients = clientsCopy;
+ }
+ }
- /// <summary>
- /// Test if this handler has active connections
- /// </summary>
- /// <value>
- /// <c>true</c> if this handler has active connections
- /// </value>
- /// <remarks>
- /// <para>
- /// This property will be <c>true</c> while this handler has
- /// active connections, that is at least one connection that
- /// the handler will attempt to send a message to.
- /// </para>
- /// </remarks>
- public bool HasConnections
- {
- get
- {
- ArrayList localClients = m_clients;
+ /// <summary>
+ /// Test if this handler has active connections
+ /// </summary>
+ /// <value>
+ /// <c>true</c> if this handler has active connections
+ /// </value>
+ /// <remarks>
+ /// <para>
+ /// This property will be <c>true</c> while this handler has
+ /// active connections, that is at least one connection that
+ /// the handler will attempt to send a message to.
+ /// </para>
+ /// </remarks>
+ public bool HasConnections
+ {
+ get
+ {
+ ArrayList localClients = m_clients;
- return (localClients != null && localClients.Count > 0);
- }
- }
-
+ return (localClients != null && localClients.Count > 0);
+ }
+ }
+
#if NETSTANDARD
- private void OnConnect(Task<Socket> acceptTask)
+ private void OnConnect(Task<Socket> acceptTask)
#else
- /// <summary>
- /// Callback used to accept a connection on the server socket
- /// </summary>
- /// <param name="asyncResult">The result of the asynchronous operation</param>
- /// <remarks>
- /// <para>
- /// On connection adds to the list of connections
- /// if there are two many open connections you will be disconnected
- /// </para>
- /// </remarks>
- private void OnConnect(IAsyncResult asyncResult)
+ /// <summary>
+ /// Callback used to accept a connection on the server socket
+ /// </summary>
+ /// <param name="asyncResult">The result of the asynchronous operation</param>
+ /// <remarks>
+ /// <para>
+ /// On connection adds to the list of connections
+ /// if there are two many open connections you will be disconnected
+ /// </para>
+ /// </remarks>
+ private void OnConnect(IAsyncResult asyncResult)
#endif
- {
- try
- {
+ {
+ try
+ {
#if NETSTANDARD
- Socket socket = acceptTask.GetAwaiter().GetResult();
+ Socket socket = acceptTask.GetAwaiter().GetResult();
#else
- // Block until a client connects
- Socket socket = m_serverSocket.EndAccept(asyncResult);
+ // Block until a client connects
+ Socket socket = m_serverSocket.EndAccept(asyncResult);
#endif
- LogLog.Debug(declaringType, "Accepting connection from ["+socket.RemoteEndPoint.ToString()+"]");
- SocketClient client = new SocketClient(socket);
+ LogLog.Debug(declaringType, "Accepting connection from ["+socket.RemoteEndPoint.ToString()+"]");
+ SocketClient client = new SocketClient(socket);
- int currentActiveConnectionsCount = m_clients.Count;
- if (currentActiveConnectionsCount < MAX_CONNECTIONS)
- {
- try
- {
- client.Send("TelnetAppender v1.0 (" + (currentActiveConnectionsCount + 1) + " active connections)\r\n\r\n");
- AddClient(client);
- }
- catch
- {
- client.Dispose();
- }
- }
- else
- {
- client.Send("Sorry - Too many connections.\r\n");
- client.Dispose();
- }
- }
- catch
- {
- }
- finally
- {
- if (m_serverSocket != null)
- {
- AcceptConnection();
- }
- }
- }
+ int currentActiveConnectionsCount = m_clients.Count;
+ if (currentActiveConnectionsCount < MAX_CONNECTIONS)
+ {
+ try
+ {
+ client.Send("TelnetAppender v1.0 (" + (currentActiveConnectionsCount + 1) + " active connections)\r\n\r\n");
+ AddClient(client);
+ }
+ catch
+ {
+ client.Dispose();
+ }
+ }
+ else
+ {
+ client.Send("Sorry - Too many connections.\r\n");
+ client.Dispose();
+ }
+ }
+ catch
+ {
+ }
+ finally
+ {
+ if (m_serverSocket != null)
+ {
+ AcceptConnection();
+ }
+ }
+ }
- #region IDisposable Members
+ #region IDisposable Members
- /// <summary>
- /// Close all network connections
- /// </summary>
- /// <remarks>
- /// <para>
- /// Make sure we close all network connections
- /// </para>
- /// </remarks>
- public void Dispose()
- {
- ArrayList localClients = m_clients;
+ /// <summary>
+ /// Close all network connections
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Make sure we close all network connections
+ /// </para>
+ /// </remarks>
+ public void Dispose()
+ {
+ ArrayList localClients = m_clients;
- foreach (SocketClient client in localClients)
- {
- client.Dispose();
- }
- m_clients.Clear();
+ foreach (SocketClient client in localClients)
+ {
+ client.Dispose();
+ }
+ m_clients.Clear();
- Socket localSocket = m_serverSocket;
- m_serverSocket = null;
- try
- {
- localSocket.Shutdown(SocketShutdown.Both);
- }
- catch
- {
- }
+ Socket localSocket = m_serverSocket;
+ m_serverSocket = null;
+ try
+ {
+ localSocket.Shutdown(SocketShutdown.Both);
+ }
+ catch
+ {
+ }
- try
- {
+ try
+ {
#if NET_2_0
- localSocket.Close();
+ localSocket.Close();
#else
- localSocket.Dispose();
+ localSocket.Dispose();
#endif
- }
- catch
- {
- }
- }
+ }
+ catch
+ {
+ }
+ }
- #endregion
- }
+ #endregion
+ }
- #endregion
- }
+ #endregion
+ }
}
diff --git a/src/log4net/Appender/TextWriterAppender.cs b/src/log4net/Appender/TextWriterAppender.cs
index 6eb943c..b047be2 100644
--- a/src/log4net/Appender/TextWriterAppender.cs
+++ b/src/log4net/Appender/TextWriterAppender.cs
@@ -26,417 +26,417 @@
namespace log4net.Appender
{
- /// <summary>
- /// Sends logging events to a <see cref="TextWriter"/>.
- /// </summary>
- /// <remarks>
- /// <para>
- /// An Appender that writes to a <see cref="TextWriter"/>.
- /// </para>
- /// <para>
- /// This appender may be used stand alone if initialized with an appropriate
- /// writer, however it is typically used as a base class for an appender that
- /// can open a <see cref="TextWriter"/> to write to.
- /// </para>
- /// </remarks>
- /// <author>Nicko Cadell</author>
- /// <author>Gert Driesen</author>
- /// <author>Douglas de la Torre</author>
+ /// <summary>
+ /// Sends logging events to a <see cref="TextWriter"/>.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// An Appender that writes to a <see cref="TextWriter"/>.
+ /// </para>
+ /// <para>
+ /// This appender may be used stand alone if initialized with an appropriate
+ /// writer, however it is typically used as a base class for an appender that
+ /// can open a <see cref="TextWriter"/> to write to.
+ /// </para>
+ /// </remarks>
+ /// <author>Nicko Cadell</author>
+ /// <author>Gert Driesen</author>
+ /// <author>Douglas de la Torre</author>
public class TextWriterAppender : AppenderSkeleton
- {
- #region Public Instance Constructors
+ {
+ #region Public Instance Constructors
- /// <summary>
- /// Initializes a new instance of the <see cref="TextWriterAppender" /> class.
- /// </summary>
- /// <remarks>
- /// <para>
- /// Default constructor.
- /// </para>
- /// </remarks>
- public TextWriterAppender()
- {
- }
+ /// <summary>
+ /// Initializes a new instance of the <see cref="TextWriterAppender" /> class.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Default constructor.
+ /// </para>
+ /// </remarks>
+ public TextWriterAppender()
+ {
+ }
- /// <summary>
- /// Initializes a new instance of the <see cref="TextWriterAppender" /> class and
- /// sets the output destination to a new <see cref="StreamWriter"/> initialized
- /// with the specified <see cref="Stream"/>.
- /// </summary>
- /// <param name="layout">The layout to use with this appender.</param>
- /// <param name="os">The <see cref="Stream"/> to output to.</param>
- /// <remarks>
- /// <para>
- /// Obsolete constructor.
- /// </para>
- /// </remarks>
- [Obsolete("Instead use the default constructor and set the Layout & Writer properties")]
- public TextWriterAppender(ILayout layout, Stream os) : this(layout, new StreamWriter(os))
- {
- }
+ /// <summary>
+ /// Initializes a new instance of the <see cref="TextWriterAppender" /> class and
+ /// sets the output destination to a new <see cref="StreamWriter"/> initialized
+ /// with the specified <see cref="Stream"/>.
+ /// </summary>
+ /// <param name="layout">The layout to use with this appender.</param>
+ /// <param name="os">The <see cref="Stream"/> to output to.</param>
+ /// <remarks>
+ /// <para>
+ /// Obsolete constructor.
+ /// </para>
+ /// </remarks>
+ [Obsolete("Instead use the default constructor and set the Layout & Writer properties")]
+ public TextWriterAppender(ILayout layout, Stream os) : this(layout, new StreamWriter(os))
+ {
+ }
- /// <summary>
- /// Initializes a new instance of the <see cref="TextWriterAppender" /> class and sets
- /// the output destination to the specified <see cref="StreamWriter" />.
- /// </summary>
- /// <param name="layout">The layout to use with this appender</param>
- /// <param name="writer">The <see cref="TextWriter" /> to output to</param>
- /// <remarks>
- /// The <see cref="TextWriter" /> must have been previously opened.
- /// </remarks>
- /// <remarks>
- /// <para>
- /// Obsolete constructor.
- /// </para>
- /// </remarks>
- [Obsolete("Instead use the default constructor and set the Layout & Writer properties")]
- public TextWriterAppender(ILayout layout, TextWriter writer)
- {
- Layout = layout;
- Writer = writer;
- }
+ /// <summary>
+ /// Initializes a new instance of the <see cref="TextWriterAppender" /> class and sets
+ /// the output destination to the specified <see cref="StreamWriter" />.
+ /// </summary>
+ /// <param name="layout">The layout to use with this appender</param>
+ /// <param name="writer">The <see cref="TextWriter" /> to output to</param>
+ /// <remarks>
+ /// The <see cref="TextWriter" /> must have been previously opened.
+ /// </remarks>
+ /// <remarks>
+ /// <para>
+ /// Obsolete constructor.
+ /// </para>
+ /// </remarks>
+ [Obsolete("Instead use the default constructor and set the Layout & Writer properties")]
+ public TextWriterAppender(ILayout layout, TextWriter writer)
+ {
+ Layout = layout;
+ Writer = writer;
+ }
- #endregion
+ #endregion
- #region Public Instance Properties
+ #region Public Instance Properties
- /// <summary>
- /// Gets or set whether the appender will flush at the end
- /// of each append operation.
- /// </summary>
- /// <value>
- /// <para>
- /// The default behavior is to flush at the end of each
- /// append operation.
- /// </para>
- /// <para>
- /// If this option is set to <c>false</c>, then the underlying
- /// stream can defer persisting the logging event to a later
- /// time.
- /// </para>
- /// </value>
- /// <remarks>
- /// Avoiding the flush operation at the end of each append results in
- /// a performance gain of 10 to 20 percent. However, there is safety
- /// trade-off involved in skipping flushing. Indeed, when flushing is
- /// skipped, then it is likely that the last few log events will not
- /// be recorded on disk when the application exits. This is a high
- /// price to pay even for a 20% performance gain.
- /// </remarks>
- public bool ImmediateFlush
- {
- get { return m_immediateFlush; }
- set { m_immediateFlush = value; }
- }
+ /// <summary>
+ /// Gets or set whether the appender will flush at the end
+ /// of each append operation.
+ /// </summary>
+ /// <value>
+ /// <para>
+ /// The default behavior is to flush at the end of each
+ /// append operation.
+ /// </para>
+ /// <para>
+ /// If this option is set to <c>false</c>, then the underlying
+ /// stream can defer persisting the logging event to a later
+ /// time.
+ /// </para>
+ /// </value>
+ /// <remarks>
+ /// Avoiding the flush operation at the end of each append results in
+ /// a performance gain of 10 to 20 percent. However, there is safety
+ /// trade-off involved in skipping flushing. Indeed, when flushing is
+ /// skipped, then it is likely that the last few log events will not
+ /// be recorded on disk when the application exits. This is a high
+ /// price to pay even for a 20% performance gain.
+ /// </remarks>
+ public bool ImmediateFlush
+ {
+ get { return m_immediateFlush; }
+ set { m_immediateFlush = value; }
+ }
- /// <summary>
- /// Sets the <see cref="TextWriter"/> where the log output will go.
- /// </summary>
- /// <remarks>
- /// <para>
- /// The specified <see cref="TextWriter"/> must be open and writable.
- /// </para>
- /// <para>
- /// The <see cref="TextWriter"/> will be closed when the appender
- /// instance is closed.
- /// </para>
- /// <para>
- /// <b>Note:</b> Logging to an unopened <see cref="TextWriter"/> will fail.
- /// </para>
- /// </remarks>
- public virtual TextWriter Writer
- {
- get { return m_qtw; }
- set
- {
- lock(this)
- {
- Reset();
- if (value != null)
- {
- m_qtw = new QuietTextWriter(value, ErrorHandler);
- WriteHeader();
- }
- }
- }
- }
+ /// <summary>
+ /// Sets the <see cref="TextWriter"/> where the log output will go.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// The specified <see cref="TextWriter"/> must be open and writable.
+ /// </para>
+ /// <para>
+ /// The <see cref="TextWriter"/> will be closed when the appender
+ /// instance is closed.
+ /// </para>
+ /// <para>
+ /// <b>Note:</b> Logging to an unopened <see cref="TextWriter"/> will fail.
+ /// </para>
+ /// </remarks>
+ public virtual TextWriter Writer
+ {
+ get { return m_qtw; }
+ set
+ {
+ lock(this)
+ {
+ Reset();
+ if (value != null)
+ {
+ m_qtw = new QuietTextWriter(value, ErrorHandler);
+ WriteHeader();
+ }
+ }
+ }
+ }
- #endregion Public Instance Properties
+ #endregion Public Instance Properties
- #region Override implementation of AppenderSkeleton
+ #region Override implementation of AppenderSkeleton
- /// <summary>
- /// This method determines if there is a sense in attempting to append.
- /// </summary>
- /// <remarks>
- /// <para>
- /// This method checks if an output target has been set and if a
- /// layout has been set.
- /// </para>
- /// </remarks>
- /// <returns><c>false</c> if any of the preconditions fail.</returns>
- protected override bool PreAppendCheck()
- {
- if (!base.PreAppendCheck())
- {
- return false;
- }
+ /// <summary>
+ /// This method determines if there is a sense in attempting to append.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// This method checks if an output target has been set and if a
+ /// layout has been set.
+ /// </para>
+ /// </remarks>
+ /// <returns><c>false</c> if any of the preconditions fail.</returns>
+ protected override bool PreAppendCheck()
+ {
+ if (!base.PreAppendCheck())
+ {
+ return false;
+ }
- if (m_qtw == null)
- {
- // Allow subclass to lazily create the writer
- PrepareWriter();
+ if (m_qtw == null)
+ {
+ // Allow subclass to lazily create the writer
+ PrepareWriter();
- if (m_qtw == null)
- {
- ErrorHandler.Error("No output stream or file set for the appender named ["+ Name +"].");
- return false;
- }
- }
- if (m_qtw.Closed)
- {
- ErrorHandler.Error("Output stream for appender named ["+ Name +"] has been closed.");
- return false;
- }
+ if (m_qtw == null)
+ {
+ ErrorHandler.Error("No output stream or file set for the appender named ["+ Name +"].");
+ return false;
+ }
+ }
+ if (m_qtw.Closed)
+ {
+ ErrorHandler.Error("Output stream for appender named ["+ Name +"] has been closed.");
+ return false;
+ }
- return true;
- }
+ return true;
+ }
- /// <summary>
- /// This method is called by the <see cref="M:AppenderSkeleton.DoAppend(LoggingEvent)"/>
- /// method.
- /// </summary>
- /// <param name="loggingEvent">The event to log.</param>
- /// <remarks>
- /// <para>
- /// Writes a log statement to the output stream if the output stream exists
- /// and is writable.
- /// </para>
- /// <para>
- /// The format of the output will depend on the appender's layout.
- /// </para>
- /// </remarks>
- protected override void Append(LoggingEvent loggingEvent)
- {
- RenderLoggingEvent(m_qtw, loggingEvent);
+ /// <summary>
+ /// This method is called by the <see cref="M:AppenderSkeleton.DoAppend(LoggingEvent)"/>
+ /// method.
+ /// </summary>
+ /// <param name="loggingEvent">The event to log.</param>
+ /// <remarks>
+ /// <para>
+ /// Writes a log statement to the output stream if the output stream exists
+ /// and is writable.
+ /// </para>
+ /// <para>
+ /// The format of the output will depend on the appender's layout.
+ /// </para>
+ /// </remarks>
+ protected override void Append(LoggingEvent loggingEvent)
+ {
+ RenderLoggingEvent(m_qtw, loggingEvent);
- if (m_immediateFlush)
- {
- m_qtw.Flush();
- }
- }
+ if (m_immediateFlush)
+ {
+ m_qtw.Flush();
+ }
+ }
- /// <summary>
- /// This method is called by the <see cref="M:AppenderSkeleton.DoAppend(LoggingEvent[])"/>
- /// method.
- /// </summary>
- /// <param name="loggingEvents">The array of events to log.</param>
- /// <remarks>
- /// <para>
- /// This method writes all the bulk logged events to the output writer
- /// before flushing the stream.
- /// </para>
- /// </remarks>
- protected override void Append(LoggingEvent[] loggingEvents)
- {
- foreach(LoggingEvent loggingEvent in loggingEvents)
- {
- RenderLoggingEvent(m_qtw, loggingEvent);
- }
+ /// <summary>
+ /// This method is called by the <see cref="M:AppenderSkeleton.DoAppend(LoggingEvent[])"/>
+ /// method.
+ /// </summary>
+ /// <param name="loggingEvents">The array of events to log.</param>
+ /// <remarks>
+ /// <para>
+ /// This method writes all the bulk logged events to the output writer
+ /// before flushing the stream.
+ /// </para>
+ /// </remarks>
+ protected override void Append(LoggingEvent[] loggingEvents)
+ {
+ foreach(LoggingEvent loggingEvent in loggingEvents)
+ {
+ RenderLoggingEvent(m_qtw, loggingEvent);
+ }
- if (m_immediateFlush)
- {
- m_qtw.Flush();
- }
- }
+ if (m_immediateFlush)
+ {
+ m_qtw.Flush();
+ }
+ }
- /// <summary>
- /// Close this appender instance. The underlying stream or writer is also closed.
- /// </summary>
- /// <remarks>
- /// Closed appenders cannot be reused.
- /// </remarks>
- protected override void OnClose()
- {
- lock(this)
- {
- Reset();
- }
- }
+ /// <summary>
+ /// Close this appender instance. The underlying stream or writer is also closed.
+ /// </summary>
+ /// <remarks>
+ /// Closed appenders cannot be reused.
+ /// </remarks>
+ protected override void OnClose()
+ {
+ lock(this)
+ {
+ Reset();
+ }
+ }
- /// <summary>
- /// Gets or set the <see cref="IErrorHandler"/> and the underlying
- /// <see cref="QuietTextWriter"/>, if any, for this appender.
- /// </summary>
- /// <value>
- /// The <see cref="IErrorHandler"/> for this appender.
- /// </value>
- public override IErrorHandler ErrorHandler
- {
- get { return base.ErrorHandler; }
- set
- {
- lock(this)
- {
- if (value == null)
- {
- LogLog.Warn(declaringType, "TextWriterAppender: You have tried to set a null error-handler.");
- }
- else
- {
- base.ErrorHandler = value;
- if (m_qtw != null)
- {
- m_qtw.ErrorHandler = value;
- }
- }
- }
- }
- }
+ /// <summary>
+ /// Gets or set the <see cref="IErrorHandler"/> and the underlying
+ /// <see cref="QuietTextWriter"/>, if any, for this appender.
+ /// </summary>
+ /// <value>
+ /// The <see cref="IErrorHandler"/> for this appender.
+ /// </value>
+ public override IErrorHandler ErrorHandler
+ {
+ get { return base.ErrorHandler; }
+ set
+ {
+ lock(this)
+ {
+ if (value == null)
+ {
+ LogLog.Warn(declaringType, "TextWriterAppender: You have tried to set a null error-handler.");
+ }
+ else
+ {
+ base.ErrorHandler = value;
+ if (m_qtw != null)
+ {
+ m_qtw.ErrorHandler = value;
+ }
+ }
+ }
+ }
+ }
- /// <summary>
- /// This appender requires a <see cref="Layout"/> to be set.
- /// </summary>
- /// <value><c>true</c></value>
- /// <remarks>
- /// <para>
- /// This appender requires a <see cref="Layout"/> to be set.
- /// </para>
- /// </remarks>
- protected override bool RequiresLayout
- {
- get { return true; }
- }
+ /// <summary>
+ /// This appender requires a <see cref="Layout"/> to be set.
+ /// </summary>
+ /// <value><c>true</c></value>
+ /// <remarks>
+ /// <para>
+ /// This appender requires a <see cref="Layout"/> to be set.
+ /// </para>
+ /// </remarks>
+ protected override bool RequiresLayout
+ {
+ get { return true; }
+ }
- #endregion Override implementation of AppenderSkeleton
+ #endregion Override implementation of AppenderSkeleton
- #region Protected Instance Methods
+ #region Protected Instance Methods
- /// <summary>
- /// Writes the footer and closes the underlying <see cref="TextWriter"/>.
- /// </summary>
- /// <remarks>
- /// <para>
- /// Writes the footer and closes the underlying <see cref="TextWriter"/>.
- /// </para>
- /// </remarks>
- protected virtual void WriteFooterAndCloseWriter()
- {
- WriteFooter();
- CloseWriter();
- }
+ /// <summary>
+ /// Writes the footer and closes the underlying <see cref="TextWriter"/>.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Writes the footer and closes the underlying <see cref="TextWriter"/>.
+ /// </para>
+ /// </remarks>
+ protected virtual void WriteFooterAndCloseWriter()
+ {
+ WriteFooter();
+ CloseWriter();
+ }
- /// <summary>
- /// Closes the underlying <see cref="TextWriter"/>.
- /// </summary>
- /// <remarks>
- /// <para>
- /// Closes the underlying <see cref="TextWriter"/>.
- /// </para>
- /// </remarks>
- protected virtual void CloseWriter()
- {
- if (m_qtw != null)
- {
- try
- {
- m_qtw.Close();
- }
- catch(Exception e)
- {
- ErrorHandler.Error("Could not close writer ["+m_qtw+"]", e);
- // do need to invoke an error handler
- // at this late stage
- }
- }
- }
+ /// <summary>
+ /// Closes the underlying <see cref="TextWriter"/>.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Closes the underlying <see cref="TextWriter"/>.
+ /// </para>
+ /// </remarks>
+ protected virtual void CloseWriter()
+ {
+ if (m_qtw != null)
+ {
+ try
+ {
+ m_qtw.Close();
+ }
+ catch(Exception e)
+ {
+ ErrorHandler.Error("Could not close writer ["+m_qtw+"]", e);
+ // do need to invoke an error handler
+ // at this late stage
+ }
+ }
+ }
- /// <summary>
- /// Clears internal references to the underlying <see cref="TextWriter" />
- /// and other variables.
- /// </summary>
- /// <remarks>
- /// <para>
- /// Subclasses can override this method for an alternate closing behavior.
- /// </para>
- /// </remarks>
- protected virtual void Reset()
- {
- WriteFooterAndCloseWriter();
- m_qtw = null;
- }
+ /// <summary>
+ /// Clears internal references to the underlying <see cref="TextWriter" />
+ /// and other variables.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Subclasses can override this method for an alternate closing behavior.
+ /// </para>
+ /// </remarks>
+ protected virtual void Reset()
+ {
+ WriteFooterAndCloseWriter();
+ m_qtw = null;
+ }
- /// <summary>
- /// Writes a footer as produced by the embedded layout's <see cref="ILayout.Footer"/> property.
- /// </summary>
- /// <remarks>
- /// <para>
- /// Writes a footer as produced by the embedded layout's <see cref="ILayout.Footer"/> property.
- /// </para>
- /// </remarks>
- protected virtual void WriteFooter()
- {
- if (Layout != null && m_qtw != null && !m_qtw.Closed)
- {
- string f = Layout.Footer;
- if (f != null)
- {
- m_qtw.Write(f);
- }
- }
- }
+ /// <summary>
+ /// Writes a footer as produced by the embedded layout's <see cref="ILayout.Footer"/> property.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Writes a footer as produced by the embedded layout's <see cref="ILayout.Footer"/> property.
+ /// </para>
+ /// </remarks>
+ protected virtual void WriteFooter()
+ {
+ if (Layout != null && m_qtw != null && !m_qtw.Closed)
+ {
+ string f = Layout.Footer;
+ if (f != null)
+ {
+ m_qtw.Write(f);
+ }
+ }
+ }
- /// <summary>
- /// Writes a header produced by the embedded layout's <see cref="ILayout.Header"/> property.
- /// </summary>
- /// <remarks>
- /// <para>
- /// Writes a header produced by the embedded layout's <see cref="ILayout.Header"/> property.
- /// </para>
- /// </remarks>
- protected virtual void WriteHeader()
- {
- if (Layout != null && m_qtw != null && !m_qtw.Closed)
- {
- string h = Layout.Header;
- if (h != null)
- {
- m_qtw.Write(h);
- }
- }
- }
+ /// <summary>
+ /// Writes a header produced by the embedded layout's <see cref="ILayout.Header"/> property.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Writes a header produced by the embedded layout's <see cref="ILayout.Header"/> property.
+ /// </para>
+ /// </remarks>
+ protected virtual void WriteHeader()
+ {
+ if (Layout != null && m_qtw != null && !m_qtw.Closed)
+ {
+ string h = Layout.Header;
+ if (h != null)
+ {
+ m_qtw.Write(h);
+ }
+ }
+ }
- /// <summary>
- /// Called to allow a subclass to lazily initialize the writer
- /// </summary>
- /// <remarks>
- /// <para>
- /// This method is called when an event is logged and the <see cref="Writer"/> or
- /// <see cref="QuietWriter"/> have not been set. This allows a subclass to
- /// attempt to initialize the writer multiple times.
- /// </para>
- /// </remarks>
- protected virtual void PrepareWriter()
- {
- }
+ /// <summary>
+ /// Called to allow a subclass to lazily initialize the writer
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// This method is called when an event is logged and the <see cref="Writer"/> or
+ /// <see cref="QuietWriter"/> have not been set. This allows a subclass to
+ /// attempt to initialize the writer multiple times.
+ /// </para>
+ /// </remarks>
+ protected virtual void PrepareWriter()
+ {
+ }
- /// <summary>
- /// Gets or sets the <see cref="log4net.Util.QuietTextWriter"/> where logging events
- /// will be written to.
- /// </summary>
- /// <value>
- /// The <see cref="log4net.Util.QuietTextWriter"/> where logging events are written.
- /// </value>
- /// <remarks>
- /// <para>
- /// This is the <see cref="log4net.Util.QuietTextWriter"/> where logging events
- /// will be written to.
- /// </para>
- /// </remarks>
- protected QuietTextWriter QuietWriter
- {
- get { return m_qtw; }
- set { m_qtw = value; }
+ /// <summary>
+ /// Gets or sets the <see cref="log4net.Util.QuietTextWriter"/> where logging events
+ /// will be written to.
+ /// </summary>
+ /// <value>
+ /// The <see cref="log4net.Util.QuietTextWriter"/> where logging events are written.
+ /// </value>
+ /// <remarks>
+ /// <para>
+ /// This is the <see cref="log4net.Util.QuietTextWriter"/> where logging events
+ /// will be written to.
+ /// </para>
+ /// </remarks>
+ protected QuietTextWriter QuietWriter
+ {
+ get { return m_qtw; }
+ set { m_qtw = value; }
}
#endregion Protected Instance Methods
@@ -444,43 +444,43 @@
#region Private Instance Fields
/// <summary>
- /// This is the <see cref="log4net.Util.QuietTextWriter"/> where logging events
- /// will be written to.
- /// </summary>
- private QuietTextWriter m_qtw;
+ /// This is the <see cref="log4net.Util.QuietTextWriter"/> where logging events
+ /// will be written to.
+ /// </summary>
+ private QuietTextWriter m_qtw;
- /// <summary>
- /// Immediate flush means that the underlying <see cref="TextWriter" />
- /// or output stream will be flushed at the end of each append operation.
- /// </summary>
- /// <remarks>
- /// <para>
- /// Immediate flush is slower but ensures that each append request is
- /// actually written. If <see cref="ImmediateFlush"/> is set to
- /// <c>false</c>, then there is a good chance that the last few
- /// logging events are not actually persisted if and when the application
- /// crashes.
- /// </para>
- /// <para>
- /// The default value is <c>true</c>.
- /// </para>
- /// </remarks>
- private bool m_immediateFlush = true;
+ /// <summary>
+ /// Immediate flush means that the underlying <see cref="TextWriter" />
+ /// or output stream will be flushed at the end of each append operation.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Immediate flush is slower but ensures that each append request is
+ /// actually written. If <see cref="ImmediateFlush"/> is set to
+ /// <c>false</c>, then there is a good chance that the last few
+ /// logging events are not actually persisted if and when the application
+ /// crashes.
+ /// </para>
+ /// <para>
+ /// The default value is <c>true</c>.
+ /// </para>
+ /// </remarks>
+ private bool m_immediateFlush = true;
- #endregion Private Instance Fields
+ #endregion Private Instance Fields
- #region Private Static Fields
+ #region Private Static Fields
- /// <summary>
- /// The fully qualified type of the TextWriterAppender class.
- /// </summary>
- /// <remarks>
- /// Used by the internal logger to record the Type of the
- /// log message.
- /// </remarks>
- private static readonly Type declaringType = typeof(TextWriterAppender);
+ /// <summary>
+ /// The fully qualified type of the TextWriterAppender class.
+ /// </summary>
+ /// <remarks>
+ /// Used by the internal logger to record the Type of the
+ /// log message.
+ /// </remarks>
+ private static readonly Type declaringType = typeof(TextWriterAppender);
- #endregion Private Static Fields
+ #endregion Private Static Fields
/// <summary>
/// Flushes any buffered log data.
@@ -500,5 +500,5 @@
return true;
}
- }
+ }
}
diff --git a/src/log4net/Appender/TraceAppender.cs b/src/log4net/Appender/TraceAppender.cs
index 8e6cb7f..e266f4b 100644
--- a/src/log4net/Appender/TraceAppender.cs
+++ b/src/log4net/Appender/TraceAppender.cs
@@ -24,92 +24,92 @@
namespace log4net.Appender
{
- /// <summary>
- /// Appends log events to the <see cref="System.Diagnostics.Trace"/> system.
- /// </summary>
- /// <remarks>
- /// <para>
- /// The application configuration file can be used to control what listeners
- /// are actually used. See the MSDN documentation for the
- /// <see cref="System.Diagnostics.Trace"/> class for details on configuring the
- /// trace system.
- /// </para>
- /// <para>
- /// Events are written using the <c>System.Diagnostics.Trace.Write(string,string)</c>
- /// method. The event's logger name is the default value for the category parameter
+ /// <summary>
+ /// Appends log events to the <see cref="System.Diagnostics.Trace"/> system.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// The application configuration file can be used to control what listeners
+ /// are actually used. See the MSDN documentation for the
+ /// <see cref="System.Diagnostics.Trace"/> class for details on configuring the
+ /// trace system.
+ /// </para>
+ /// <para>
+ /// Events are written using the <c>System.Diagnostics.Trace.Write(string,string)</c>
+ /// method. The event's logger name is the default value for the category parameter
/// of the Write method.
- /// </para>
- /// <para>
- /// <b>Compact Framework</b><br />
- /// The Compact Framework does not support the <see cref="System.Diagnostics.Trace"/>
- /// class for any operation except <c>Assert</c>. When using the Compact Framework this
- /// appender will write to the <see cref="System.Diagnostics.Debug"/> system rather than
- /// the Trace system. This appender will therefore behave like the <see cref="DebugAppender"/>.
- /// </para>
- /// </remarks>
- /// <author>Douglas de la Torre</author>
- /// <author>Nicko Cadell</author>
- /// <author>Gert Driesen</author>
+ /// </para>
+ /// <para>
+ /// <b>Compact Framework</b><br />
+ /// The Compact Framework does not support the <see cref="System.Diagnostics.Trace"/>
+ /// class for any operation except <c>Assert</c>. When using the Compact Framework this
+ /// appender will write to the <see cref="System.Diagnostics.Debug"/> system rather than
+ /// the Trace system. This appender will therefore behave like the <see cref="DebugAppender"/>.
+ /// </para>
+ /// </remarks>
+ /// <author>Douglas de la Torre</author>
+ /// <author>Nicko Cadell</author>
+ /// <author>Gert Driesen</author>
/// <author>Ron Grabowski</author>
- public class TraceAppender : AppenderSkeleton
- {
- #region Public Instance Constructors
+ public class TraceAppender : AppenderSkeleton
+ {
+ #region Public Instance Constructors
- /// <summary>
- /// Initializes a new instance of the <see cref="TraceAppender" />.
- /// </summary>
- /// <remarks>
- /// <para>
- /// Default constructor.
- /// </para>
- /// </remarks>
- public TraceAppender()
- {
- }
+ /// <summary>
+ /// Initializes a new instance of the <see cref="TraceAppender" />.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Default constructor.
+ /// </para>
+ /// </remarks>
+ public TraceAppender()
+ {
+ }
- /// <summary>
- /// Initializes a new instance of the <see cref="TraceAppender" />
- /// with a specified layout.
- /// </summary>
- /// <param name="layout">The layout to use with this appender.</param>
- /// <remarks>
- /// <para>
- /// Obsolete constructor.
- /// </para>
- /// </remarks>
- [System.Obsolete("Instead use the default constructor and set the Layout property")]
- public TraceAppender(ILayout layout)
- {
- Layout = layout;
- }
+ /// <summary>
+ /// Initializes a new instance of the <see cref="TraceAppender" />
+ /// with a specified layout.
+ /// </summary>
+ /// <param name="layout">The layout to use with this appender.</param>
+ /// <remarks>
+ /// <para>
+ /// Obsolete constructor.
+ /// </para>
+ /// </remarks>
+ [System.Obsolete("Instead use the default constructor and set the Layout property")]
+ public TraceAppender(ILayout layout)
+ {
+ Layout = layout;
+ }
- #endregion Public Instance Constructors
+ #endregion Public Instance Constructors
- #region Public Instance Properties
+ #region Public Instance Properties
- /// <summary>
- /// Gets or sets a value that indicates whether the appender will
- /// flush at the end of each write.
- /// </summary>
- /// <remarks>
- /// <para>The default behavior is to flush at the end of each
- /// write. If the option is set to<c>false</c>, then the underlying
- /// stream can defer writing to physical medium to a later time.
- /// </para>
- /// <para>
- /// Avoiding the flush operation at the end of each append results
- /// in a performance gain of 10 to 20 percent. However, there is safety
- /// trade-off involved in skipping flushing. Indeed, when flushing is
- /// skipped, then it is likely that the last few log events will not
- /// be recorded on disk when the application exits. This is a high
- /// price to pay even for a 20% performance gain.
- /// </para>
- /// </remarks>
- public bool ImmediateFlush
- {
- get { return m_immediateFlush; }
- set { m_immediateFlush = value; }
- }
+ /// <summary>
+ /// Gets or sets a value that indicates whether the appender will
+ /// flush at the end of each write.
+ /// </summary>
+ /// <remarks>
+ /// <para>The default behavior is to flush at the end of each
+ /// write. If the option is set to<c>false</c>, then the underlying
+ /// stream can defer writing to physical medium to a later time.
+ /// </para>
+ /// <para>
+ /// Avoiding the flush operation at the end of each append results
+ /// in a performance gain of 10 to 20 percent. However, there is safety
+ /// trade-off involved in skipping flushing. Indeed, when flushing is
+ /// skipped, then it is likely that the last few log events will not
+ /// be recorded on disk when the application exits. This is a high
+ /// price to pay even for a 20% performance gain.
+ /// </para>
+ /// </remarks>
+ public bool ImmediateFlush
+ {
+ get { return m_immediateFlush; }
+ set { m_immediateFlush = value; }
+ }
/// <summary>
/// The category parameter sent to the Trace method.
@@ -122,90 +122,90 @@
/// <para>
/// </para>
/// </remarks>
- public PatternLayout Category
- {
- get { return m_category; }
- set { m_category = value; }
- }
+ public PatternLayout Category
+ {
+ get { return m_category; }
+ set { m_category = value; }
+ }
- #endregion Public Instance Properties
+ #endregion Public Instance Properties
- #region Override implementation of AppenderSkeleton
+ #region Override implementation of AppenderSkeleton
- /// <summary>
- /// Writes the logging event to the <see cref="System.Diagnostics.Trace"/> system.
- /// </summary>
- /// <param name="loggingEvent">The event to log.</param>
- /// <remarks>
- /// <para>
- /// Writes the logging event to the <see cref="System.Diagnostics.Trace"/> system.
- /// </para>
- /// </remarks>
- protected override void Append(LoggingEvent loggingEvent)
- {
- //
- // Write the string to the Trace system
- //
+ /// <summary>
+ /// Writes the logging event to the <see cref="System.Diagnostics.Trace"/> system.
+ /// </summary>
+ /// <param name="loggingEvent">The event to log.</param>
+ /// <remarks>
+ /// <para>
+ /// Writes the logging event to the <see cref="System.Diagnostics.Trace"/> system.
+ /// </para>
+ /// </remarks>
+ protected override void Append(LoggingEvent loggingEvent)
+ {
+ //
+ // Write the string to the Trace system
+ //
#if NETCF
- System.Diagnostics.Debug.Write(RenderLoggingEvent(loggingEvent), m_category.Format(loggingEvent));
+ System.Diagnostics.Debug.Write(RenderLoggingEvent(loggingEvent), m_category.Format(loggingEvent));
#else
System.Diagnostics.Trace.Write(RenderLoggingEvent(loggingEvent), m_category.Format(loggingEvent));
#endif
-
- //
- // Flush the Trace system if needed
- //
- if (m_immediateFlush)
- {
+
+ //
+ // Flush the Trace system if needed
+ //
+ if (m_immediateFlush)
+ {
#if NETCF
- System.Diagnostics.Debug.Flush();
+ System.Diagnostics.Debug.Flush();
#else
- System.Diagnostics.Trace.Flush();
+ System.Diagnostics.Trace.Flush();
#endif
- }
- }
+ }
+ }
- /// <summary>
- /// This appender requires a <see cref="Layout"/> to be set.
- /// </summary>
- /// <value><c>true</c></value>
- /// <remarks>
- /// <para>
- /// This appender requires a <see cref="Layout"/> to be set.
- /// </para>
- /// </remarks>
- protected override bool RequiresLayout
- {
- get { return true; }
- }
+ /// <summary>
+ /// This appender requires a <see cref="Layout"/> to be set.
+ /// </summary>
+ /// <value><c>true</c></value>
+ /// <remarks>
+ /// <para>
+ /// This appender requires a <see cref="Layout"/> to be set.
+ /// </para>
+ /// </remarks>
+ protected override bool RequiresLayout
+ {
+ get { return true; }
+ }
- #endregion Override implementation of AppenderSkeleton
+ #endregion Override implementation of AppenderSkeleton
- #region Private Instance Fields
+ #region Private Instance Fields
- /// <summary>
- /// Immediate flush means that the underlying writer or output stream
- /// will be flushed at the end of each append operation.
- /// </summary>
- /// <remarks>
- /// <para>
- /// Immediate flush is slower but ensures that each append request is
- /// actually written. If <see cref="ImmediateFlush"/> is set to
- /// <c>false</c>, then there is a good chance that the last few
- /// logs events are not actually written to persistent media if and
- /// when the application crashes.
- /// </para>
- /// <para>
- /// The default value is <c>true</c>.</para>
- /// </remarks>
- private bool m_immediateFlush = true;
+ /// <summary>
+ /// Immediate flush means that the underlying writer or output stream
+ /// will be flushed at the end of each append operation.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Immediate flush is slower but ensures that each append request is
+ /// actually written. If <see cref="ImmediateFlush"/> is set to
+ /// <c>false</c>, then there is a good chance that the last few
+ /// logs events are not actually written to persistent media if and
+ /// when the application crashes.
+ /// </para>
+ /// <para>
+ /// The default value is <c>true</c>.</para>
+ /// </remarks>
+ private bool m_immediateFlush = true;
/// <summary>
/// Defaults to %logger
/// </summary>
private PatternLayout m_category = new PatternLayout("%logger");
- #endregion Private Instance Fields
+ #endregion Private Instance Fields
/// <summary>
/// Flushes any buffered log data.
@@ -219,7 +219,7 @@
// System.Diagnostics.Trace and System.Diagnostics.Debug are thread-safe, so no need for lock(this).
#if NETCF
- System.Diagnostics.Debug.Flush();
+ System.Diagnostics.Debug.Flush();
#else
System.Diagnostics.Trace.Flush();
#endif
diff --git a/src/log4net/Appender/UdpAppender.cs b/src/log4net/Appender/UdpAppender.cs
index e2cafe4..70acff0 100644
--- a/src/log4net/Appender/UdpAppender.cs
+++ b/src/log4net/Appender/UdpAppender.cs
@@ -27,522 +27,522 @@
namespace log4net.Appender
{
- /// <summary>
- /// Sends logging events as connectionless UDP datagrams to a remote host or a
- /// multicast group using an <see cref="UdpClient" />.
- /// </summary>
- /// <remarks>
- /// <para>
- /// UDP guarantees neither that messages arrive, nor that they arrive in the correct order.
- /// </para>
- /// <para>
- /// To view the logging results, a custom application can be developed that listens for logging
- /// events.
- /// </para>
- /// <para>
- /// When decoding events send via this appender remember to use the same encoding
- /// to decode the events as was used to send the events. See the <see cref="Encoding"/>
- /// property to specify the encoding to use.
- /// </para>
- /// </remarks>
- /// <example>
- /// This example shows how to log receive logging events that are sent
- /// on IP address 244.0.0.1 and port 8080 to the console. The event is
- /// encoded in the packet as a unicode string and it is decoded as such.
- /// <code lang="C#">
- /// IPEndPoint remoteEndPoint = new IPEndPoint(IPAddress.Any, 0);
- /// UdpClient udpClient;
- /// byte[] buffer;
- /// string loggingEvent;
- ///
- /// try
- /// {
- /// udpClient = new UdpClient(8080);
- ///
- /// while(true)
- /// {
- /// buffer = udpClient.Receive(ref remoteEndPoint);
- /// loggingEvent = System.Text.Encoding.Unicode.GetString(buffer);
- /// Console.WriteLine(loggingEvent);
- /// }
- /// }
- /// catch(Exception e)
- /// {
- /// Console.WriteLine(e.ToString());
- /// }
- /// </code>
- /// <code lang="Visual Basic">
- /// Dim remoteEndPoint as IPEndPoint
- /// Dim udpClient as UdpClient
- /// Dim buffer as Byte()
- /// Dim loggingEvent as String
- ///
- /// Try
- /// remoteEndPoint = new IPEndPoint(IPAddress.Any, 0)
- /// udpClient = new UdpClient(8080)
- ///
- /// While True
- /// buffer = udpClient.Receive(ByRef remoteEndPoint)
- /// loggingEvent = System.Text.Encoding.Unicode.GetString(buffer)
- /// Console.WriteLine(loggingEvent)
- /// Wend
- /// Catch e As Exception
- /// Console.WriteLine(e.ToString())
- /// End Try
- /// </code>
- /// <para>
- /// An example configuration section to log information using this appender to the
- /// IP 224.0.0.1 on port 8080:
- /// </para>
- /// <code lang="XML" escaped="true">
- /// <appender name="UdpAppender" type="log4net.Appender.UdpAppender">
- /// <remoteAddress value="224.0.0.1" />
- /// <remotePort value="8080" />
- /// <layout type="log4net.Layout.PatternLayout" value="%-5level %logger [%ndc] - %message%newline" />
- /// </appender>
- /// </code>
- /// </example>
- /// <author>Gert Driesen</author>
- /// <author>Nicko Cadell</author>
- public class UdpAppender : AppenderSkeleton
- {
- #region Public Instance Constructors
+ /// <summary>
+ /// Sends logging events as connectionless UDP datagrams to a remote host or a
+ /// multicast group using an <see cref="UdpClient" />.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// UDP guarantees neither that messages arrive, nor that they arrive in the correct order.
+ /// </para>
+ /// <para>
+ /// To view the logging results, a custom application can be developed that listens for logging
+ /// events.
+ /// </para>
+ /// <para>
+ /// When decoding events send via this appender remember to use the same encoding
+ /// to decode the events as was used to send the events. See the <see cref="Encoding"/>
+ /// property to specify the encoding to use.
+ /// </para>
+ /// </remarks>
+ /// <example>
+ /// This example shows how to log receive logging events that are sent
+ /// on IP address 244.0.0.1 and port 8080 to the console. The event is
+ /// encoded in the packet as a unicode string and it is decoded as such.
+ /// <code lang="C#">
+ /// IPEndPoint remoteEndPoint = new IPEndPoint(IPAddress.Any, 0);
+ /// UdpClient udpClient;
+ /// byte[] buffer;
+ /// string loggingEvent;
+ ///
+ /// try
+ /// {
+ /// udpClient = new UdpClient(8080);
+ ///
+ /// while(true)
+ /// {
+ /// buffer = udpClient.Receive(ref remoteEndPoint);
+ /// loggingEvent = System.Text.Encoding.Unicode.GetString(buffer);
+ /// Console.WriteLine(loggingEvent);
+ /// }
+ /// }
+ /// catch(Exception e)
+ /// {
+ /// Console.WriteLine(e.ToString());
+ /// }
+ /// </code>
+ /// <code lang="Visual Basic">
+ /// Dim remoteEndPoint as IPEndPoint
+ /// Dim udpClient as UdpClient
+ /// Dim buffer as Byte()
+ /// Dim loggingEvent as String
+ ///
+ /// Try
+ /// remoteEndPoint = new IPEndPoint(IPAddress.Any, 0)
+ /// udpClient = new UdpClient(8080)
+ ///
+ /// While True
+ /// buffer = udpClient.Receive(ByRef remoteEndPoint)
+ /// loggingEvent = System.Text.Encoding.Unicode.GetString(buffer)
+ /// Console.WriteLine(loggingEvent)
+ /// Wend
+ /// Catch e As Exception
+ /// Console.WriteLine(e.ToString())
+ /// End Try
+ /// </code>
+ /// <para>
+ /// An example configuration section to log information using this appender to the
+ /// IP 224.0.0.1 on port 8080:
+ /// </para>
+ /// <code lang="XML" escaped="true">
+ /// <appender name="UdpAppender" type="log4net.Appender.UdpAppender">
+ /// <remoteAddress value="224.0.0.1" />
+ /// <remotePort value="8080" />
+ /// <layout type="log4net.Layout.PatternLayout" value="%-5level %logger [%ndc] - %message%newline" />
+ /// </appender>
+ /// </code>
+ /// </example>
+ /// <author>Gert Driesen</author>
+ /// <author>Nicko Cadell</author>
+ public class UdpAppender : AppenderSkeleton
+ {
+ #region Public Instance Constructors
- /// <summary>
- /// Initializes a new instance of the <see cref="UdpAppender" /> class.
- /// </summary>
- /// <remarks>
- /// The default constructor initializes all fields to their default values.
- /// </remarks>
- public UdpAppender()
- {
- }
+ /// <summary>
+ /// Initializes a new instance of the <see cref="UdpAppender" /> class.
+ /// </summary>
+ /// <remarks>
+ /// The default constructor initializes all fields to their default values.
+ /// </remarks>
+ public UdpAppender()
+ {
+ }
- #endregion Public Instance Constructors
+ #endregion Public Instance Constructors
- #region Public Instance Properties
+ #region Public Instance Properties
- /// <summary>
- /// Gets or sets the IP address of the remote host or multicast group to which
- /// the underlying <see cref="UdpClient" /> should sent the logging event.
- /// </summary>
- /// <value>
- /// The IP address of the remote host or multicast group to which the logging event
- /// will be sent.
- /// </value>
- /// <remarks>
- /// <para>
- /// Multicast addresses are identified by IP class <b>D</b> addresses (in the range 224.0.0.0 to
- /// 239.255.255.255). Multicast packets can pass across different networks through routers, so
- /// it is possible to use multicasts in an Internet scenario as long as your network provider
- /// supports multicasting.
- /// </para>
- /// <para>
- /// Hosts that want to receive particular multicast messages must register their interest by joining
- /// the multicast group. Multicast messages are not sent to networks where no host has joined
- /// the multicast group. Class <b>D</b> IP addresses are used for multicast groups, to differentiate
- /// them from normal host addresses, allowing nodes to easily detect if a message is of interest.
- /// </para>
- /// <para>
- /// Static multicast addresses that are needed globally are assigned by IANA. A few examples are listed in the table below:
- /// </para>
- /// <para>
- /// <list type="table">
- /// <listheader>
- /// <term>IP Address</term>
- /// <description>Description</description>
- /// </listheader>
- /// <item>
- /// <term>224.0.0.1</term>
- /// <description>
- /// <para>
- /// Sends a message to all system on the subnet.
- /// </para>
- /// </description>
- /// </item>
- /// <item>
- /// <term>224.0.0.2</term>
- /// <description>
- /// <para>
- /// Sends a message to all routers on the subnet.
- /// </para>
- /// </description>
- /// </item>
- /// <item>
- /// <term>224.0.0.12</term>
- /// <description>
- /// <para>
- /// The DHCP server answers messages on the IP address 224.0.0.12, but only on a subnet.
- /// </para>
- /// </description>
- /// </item>
- /// </list>
- /// </para>
- /// <para>
- /// A complete list of actually reserved multicast addresses and their owners in the ranges
- /// defined by RFC 3171 can be found at the <A href="http://www.iana.org/assignments/multicast-addresses">IANA web site</A>.
- /// </para>
- /// <para>
- /// The address range 239.0.0.0 to 239.255.255.255 is reserved for administrative scope-relative
- /// addresses. These addresses can be reused with other local groups. Routers are typically
- /// configured with filters to prevent multicast traffic in this range from flowing outside
- /// of the local network.
- /// </para>
- /// </remarks>
- public IPAddress RemoteAddress
- {
- get { return m_remoteAddress; }
- set { m_remoteAddress = value; }
- }
+ /// <summary>
+ /// Gets or sets the IP address of the remote host or multicast group to which
+ /// the underlying <see cref="UdpClient" /> should sent the logging event.
+ /// </summary>
+ /// <value>
+ /// The IP address of the remote host or multicast group to which the logging event
+ /// will be sent.
+ /// </value>
+ /// <remarks>
+ /// <para>
+ /// Multicast addresses are identified by IP class <b>D</b> addresses (in the range 224.0.0.0 to
+ /// 239.255.255.255). Multicast packets can pass across different networks through routers, so
+ /// it is possible to use multicasts in an Internet scenario as long as your network provider
+ /// supports multicasting.
+ /// </para>
+ /// <para>
+ /// Hosts that want to receive particular multicast messages must register their interest by joining
+ /// the multicast group. Multicast messages are not sent to networks where no host has joined
+ /// the multicast group. Class <b>D</b> IP addresses are used for multicast groups, to differentiate
+ /// them from normal host addresses, allowing nodes to easily detect if a message is of interest.
+ /// </para>
+ /// <para>
+ /// Static multicast addresses that are needed globally are assigned by IANA. A few examples are listed in the table below:
+ /// </para>
+ /// <para>
+ /// <list type="table">
+ /// <listheader>
+ /// <term>IP Address</term>
+ /// <description>Description</description>
+ /// </listheader>
+ /// <item>
+ /// <term>224.0.0.1</term>
+ /// <description>
+ /// <para>
+ /// Sends a message to all system on the subnet.
+ /// </para>
+ /// </description>
+ /// </item>
+ /// <item>
+ /// <term>224.0.0.2</term>
+ /// <description>
+ /// <para>
+ /// Sends a message to all routers on the subnet.
+ /// </para>
+ /// </description>
+ /// </item>
+ /// <item>
+ /// <term>224.0.0.12</term>
+ /// <description>
+ /// <para>
+ /// The DHCP server answers messages on the IP address 224.0.0.12, but only on a subnet.
+ /// </para>
+ /// </description>
+ /// </item>
+ /// </list>
+ /// </para>
+ /// <para>
+ /// A complete list of actually reserved multicast addresses and their owners in the ranges
+ /// defined by RFC 3171 can be found at the <A href="http://www.iana.org/assignments/multicast-addresses">IANA web site</A>.
+ /// </para>
+ /// <para>
+ /// The address range 239.0.0.0 to 239.255.255.255 is reserved for administrative scope-relative
+ /// addresses. These addresses can be reused with other local groups. Routers are typically
+ /// configured with filters to prevent multicast traffic in this range from flowing outside
+ /// of the local network.
+ /// </para>
+ /// </remarks>
+ public IPAddress RemoteAddress
+ {
+ get { return m_remoteAddress; }
+ set { m_remoteAddress = value; }
+ }
- /// <summary>
- /// Gets or sets the TCP port number of the remote host or multicast group to which
- /// the underlying <see cref="UdpClient" /> should sent the logging event.
- /// </summary>
- /// <value>
- /// An integer value in the range <see cref="IPEndPoint.MinPort" /> to <see cref="IPEndPoint.MaxPort" />
- /// indicating the TCP port number of the remote host or multicast group to which the logging event
- /// will be sent.
- /// </value>
- /// <remarks>
- /// The underlying <see cref="UdpClient" /> will send messages to this TCP port number
- /// on the remote host or multicast group.
- /// </remarks>
- /// <exception cref="ArgumentOutOfRangeException">The value specified is less than <see cref="IPEndPoint.MinPort" /> or greater than <see cref="IPEndPoint.MaxPort" />.</exception>
- public int RemotePort
- {
- get { return m_remotePort; }
- set
- {
- if (value < IPEndPoint.MinPort || value > IPEndPoint.MaxPort)
- {
- throw log4net.Util.SystemInfo.CreateArgumentOutOfRangeException("value", (object)value,
- "The value specified is less than " +
- IPEndPoint.MinPort.ToString(NumberFormatInfo.InvariantInfo) +
- " or greater than " +
- IPEndPoint.MaxPort.ToString(NumberFormatInfo.InvariantInfo) + ".");
- }
- else
- {
- m_remotePort = value;
- }
- }
- }
+ /// <summary>
+ /// Gets or sets the TCP port number of the remote host or multicast group to which
+ /// the underlying <see cref="UdpClient" /> should sent the logging event.
+ /// </summary>
+ /// <value>
+ /// An integer value in the range <see cref="IPEndPoint.MinPort" /> to <see cref="IPEndPoint.MaxPort" />
+ /// indicating the TCP port number of the remote host or multicast group to which the logging event
+ /// will be sent.
+ /// </value>
+ /// <remarks>
+ /// The underlying <see cref="UdpClient" /> will send messages to this TCP port number
+ /// on the remote host or multicast group.
+ /// </remarks>
+ /// <exception cref="ArgumentOutOfRangeException">The value specified is less than <see cref="IPEndPoint.MinPort" /> or greater than <see cref="IPEndPoint.MaxPort" />.</exception>
+ public int RemotePort
+ {
+ get { return m_remotePort; }
+ set
+ {
+ if (value < IPEndPoint.MinPort || value > IPEndPoint.MaxPort)
+ {
+ throw log4net.Util.SystemInfo.CreateArgumentOutOfRangeException("value", (object)value,
+ "The value specified is less than " +
+ IPEndPoint.MinPort.ToString(NumberFormatInfo.InvariantInfo) +
+ " or greater than " +
+ IPEndPoint.MaxPort.ToString(NumberFormatInfo.InvariantInfo) + ".");
+ }
+ else
+ {
+ m_remotePort = value;
+ }
+ }
+ }
- /// <summary>
- /// Gets or sets the TCP port number from which the underlying <see cref="UdpClient" /> will communicate.
- /// </summary>
- /// <value>
- /// An integer value in the range <see cref="IPEndPoint.MinPort" /> to <see cref="IPEndPoint.MaxPort" />
- /// indicating the TCP port number from which the underlying <see cref="UdpClient" /> will communicate.
- /// </value>
- /// <remarks>
- /// <para>
- /// The underlying <see cref="UdpClient" /> will bind to this port for sending messages.
- /// </para>
- /// <para>
- /// Setting the value to 0 (the default) will cause the udp client not to bind to
- /// a local port.
- /// </para>
- /// </remarks>
- /// <exception cref="ArgumentOutOfRangeException">The value specified is less than <see cref="IPEndPoint.MinPort" /> or greater than <see cref="IPEndPoint.MaxPort" />.</exception>
- public int LocalPort
- {
- get { return m_localPort; }
- set
- {
- if (value != 0 && (value < IPEndPoint.MinPort || value > IPEndPoint.MaxPort))
- {
- throw log4net.Util.SystemInfo.CreateArgumentOutOfRangeException("value", (object)value,
- "The value specified is less than " +
- IPEndPoint.MinPort.ToString(NumberFormatInfo.InvariantInfo) +
- " or greater than " +
- IPEndPoint.MaxPort.ToString(NumberFormatInfo.InvariantInfo) + ".");
- }
- else
- {
- m_localPort = value;
- }
- }
- }
+ /// <summary>
+ /// Gets or sets the TCP port number from which the underlying <see cref="UdpClient" /> will communicate.
+ /// </summary>
+ /// <value>
+ /// An integer value in the range <see cref="IPEndPoint.MinPort" /> to <see cref="IPEndPoint.MaxPort" />
+ /// indicating the TCP port number from which the underlying <see cref="UdpClient" /> will communicate.
+ /// </value>
+ /// <remarks>
+ /// <para>
+ /// The underlying <see cref="UdpClient" /> will bind to this port for sending messages.
+ /// </para>
+ /// <para>
+ /// Setting the value to 0 (the default) will cause the udp client not to bind to
+ /// a local port.
+ /// </para>
+ /// </remarks>
+ /// <exception cref="ArgumentOutOfRangeException">The value specified is less than <see cref="IPEndPoint.MinPort" /> or greater than <see cref="IPEndPoint.MaxPort" />.</exception>
+ public int LocalPort
+ {
+ get { return m_localPort; }
+ set
+ {
+ if (value != 0 && (value < IPEndPoint.MinPort || value > IPEndPoint.MaxPort))
+ {
+ throw log4net.Util.SystemInfo.CreateArgumentOutOfRangeException("value", (object)value,
+ "The value specified is less than " +
+ IPEndPoint.MinPort.ToString(NumberFormatInfo.InvariantInfo) +
+ " or greater than " +
+ IPEndPoint.MaxPort.ToString(NumberFormatInfo.InvariantInfo) + ".");
+ }
+ else
+ {
+ m_localPort = value;
+ }
+ }
+ }
- /// <summary>
- /// Gets or sets <see cref="Encoding"/> used to write the packets.
- /// </summary>
- /// <value>
- /// The <see cref="Encoding"/> used to write the packets.
- /// </value>
- /// <remarks>
- /// <para>
- /// The <see cref="Encoding"/> used to write the packets.
- /// </para>
- /// </remarks>
- public Encoding Encoding
- {
- get { return m_encoding; }
- set { m_encoding = value; }
- }
+ /// <summary>
+ /// Gets or sets <see cref="Encoding"/> used to write the packets.
+ /// </summary>
+ /// <value>
+ /// The <see cref="Encoding"/> used to write the packets.
+ /// </value>
+ /// <remarks>
+ /// <para>
+ /// The <see cref="Encoding"/> used to write the packets.
+ /// </para>
+ /// </remarks>
+ public Encoding Encoding
+ {
+ get { return m_encoding; }
+ set { m_encoding = value; }
+ }
- #endregion Public Instance Properties
+ #endregion Public Instance Properties
- #region Protected Instance Properties
+ #region Protected Instance Properties
- /// <summary>
- /// Gets or sets the underlying <see cref="UdpClient" />.
- /// </summary>
- /// <value>
- /// The underlying <see cref="UdpClient" />.
- /// </value>
- /// <remarks>
- /// <see cref="UdpAppender" /> creates a <see cref="UdpClient" /> to send logging events
- /// over a network. Classes deriving from <see cref="UdpAppender" /> can use this
- /// property to get or set this <see cref="UdpClient" />. Use the underlying <see cref="UdpClient" />
- /// returned from <see cref="Client" /> if you require access beyond that which
- /// <see cref="UdpAppender" /> provides.
- /// </remarks>
- protected UdpClient Client
- {
- get { return this.m_client; }
- set { this.m_client = value; }
- }
+ /// <summary>
+ /// Gets or sets the underlying <see cref="UdpClient" />.
+ /// </summary>
+ /// <value>
+ /// The underlying <see cref="UdpClient" />.
+ /// </value>
+ /// <remarks>
+ /// <see cref="UdpAppender" /> creates a <see cref="UdpClient" /> to send logging events
+ /// over a network. Classes deriving from <see cref="UdpAppender" /> can use this
+ /// property to get or set this <see cref="UdpClient" />. Use the underlying <see cref="UdpClient" />
+ /// returned from <see cref="Client" /> if you require access beyond that which
+ /// <see cref="UdpAppender" /> provides.
+ /// </remarks>
+ protected UdpClient Client
+ {
+ get { return this.m_client; }
+ set { this.m_client = value; }
+ }
- /// <summary>
- /// Gets or sets the cached remote endpoint to which the logging events should be sent.
- /// </summary>
- /// <value>
- /// The cached remote endpoint to which the logging events will be sent.
- /// </value>
- /// <remarks>
- /// The <see cref="ActivateOptions" /> method will initialize the remote endpoint
- /// with the values of the <see cref="RemoteAddress" /> and <see cref="RemotePort"/>
- /// properties.
- /// </remarks>
- protected IPEndPoint RemoteEndPoint
- {
- get { return this.m_remoteEndPoint; }
- set { this.m_remoteEndPoint = value; }
- }
+ /// <summary>
+ /// Gets or sets the cached remote endpoint to which the logging events should be sent.
+ /// </summary>
+ /// <value>
+ /// The cached remote endpoint to which the logging events will be sent.
+ /// </value>
+ /// <remarks>
+ /// The <see cref="ActivateOptions" /> method will initialize the remote endpoint
+ /// with the values of the <see cref="RemoteAddress" /> and <see cref="RemotePort"/>
+ /// properties.
+ /// </remarks>
+ protected IPEndPoint RemoteEndPoint
+ {
+ get { return this.m_remoteEndPoint; }
+ set { this.m_remoteEndPoint = value; }
+ }
- #endregion Protected Instance Properties
+ #endregion Protected Instance Properties
- #region Implementation of IOptionHandler
+ #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>
- /// <para>
- /// The appender will be ignored if no <see cref="RemoteAddress" /> was specified or
- /// an invalid remote or local TCP port number was specified.
- /// </para>
- /// </remarks>
- /// <exception cref="ArgumentNullException">The required property <see cref="RemoteAddress" /> was not specified.</exception>
- /// <exception cref="ArgumentOutOfRangeException">The TCP port number assigned to <see cref="LocalPort" /> or <see cref="RemotePort" /> is less than <see cref="IPEndPoint.MinPort" /> or greater than <see cref="IPEndPoint.MaxPort" />.</exception>
- public override void ActivateOptions()
- {
- base.ActivateOptions();
+ /// <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>
+ /// <para>
+ /// The appender will be ignored if no <see cref="RemoteAddress" /> was specified or
+ /// an invalid remote or local TCP port number was specified.
+ /// </para>
+ /// </remarks>
+ /// <exception cref="ArgumentNullException">The required property <see cref="RemoteAddress" /> was not specified.</exception>
+ /// <exception cref="ArgumentOutOfRangeException">The TCP port number assigned to <see cref="LocalPort" /> or <see cref="RemotePort" /> is less than <see cref="IPEndPoint.MinPort" /> or greater than <see cref="IPEndPoint.MaxPort" />.</exception>
+ public override void ActivateOptions()
+ {
+ base.ActivateOptions();
- if (this.RemoteAddress == null)
- {
- throw new ArgumentNullException("The required property 'Address' was not specified.");
- }
- else if (this.RemotePort < IPEndPoint.MinPort || this.RemotePort > IPEndPoint.MaxPort)
- {
- throw log4net.Util.SystemInfo.CreateArgumentOutOfRangeException("this.RemotePort", (object)this.RemotePort,
- "The RemotePort is less than " +
- IPEndPoint.MinPort.ToString(NumberFormatInfo.InvariantInfo) +
- " or greater than " +
- IPEndPoint.MaxPort.ToString(NumberFormatInfo.InvariantInfo) + ".");
- }
- else if (this.LocalPort != 0 && (this.LocalPort < IPEndPoint.MinPort || this.LocalPort > IPEndPoint.MaxPort))
- {
- throw log4net.Util.SystemInfo.CreateArgumentOutOfRangeException("this.LocalPort", (object)this.LocalPort,
- "The LocalPort is less than " +
- IPEndPoint.MinPort.ToString(NumberFormatInfo.InvariantInfo) +
- " or greater than " +
- IPEndPoint.MaxPort.ToString(NumberFormatInfo.InvariantInfo) + ".");
- }
- else
- {
- this.RemoteEndPoint = new IPEndPoint(this.RemoteAddress, this.RemotePort);
- this.InitializeClientConnection();
- }
- }
+ if (this.RemoteAddress == null)
+ {
+ throw new ArgumentNullException("The required property 'Address' was not specified.");
+ }
+ else if (this.RemotePort < IPEndPoint.MinPort || this.RemotePort > IPEndPoint.MaxPort)
+ {
+ throw log4net.Util.SystemInfo.CreateArgumentOutOfRangeException("this.RemotePort", (object)this.RemotePort,
+ "The RemotePort is less than " +
+ IPEndPoint.MinPort.ToString(NumberFormatInfo.InvariantInfo) +
+ " or greater than " +
+ IPEndPoint.MaxPort.ToString(NumberFormatInfo.InvariantInfo) + ".");
+ }
+ else if (this.LocalPort != 0 && (this.LocalPort < IPEndPoint.MinPort || this.LocalPort > IPEndPoint.MaxPort))
+ {
+ throw log4net.Util.SystemInfo.CreateArgumentOutOfRangeException("this.LocalPort", (object)this.LocalPort,
+ "The LocalPort is less than " +
+ IPEndPoint.MinPort.ToString(NumberFormatInfo.InvariantInfo) +
+ " or greater than " +
+ IPEndPoint.MaxPort.ToString(NumberFormatInfo.InvariantInfo) + ".");
+ }
+ else
+ {
+ this.RemoteEndPoint = new IPEndPoint(this.RemoteAddress, this.RemotePort);
+ this.InitializeClientConnection();
+ }
+ }
- #endregion
+ #endregion
- #region Override implementation of AppenderSkeleton
+ #region Override implementation of AppenderSkeleton
- /// <summary>
- /// This method is called by the <see cref="M:AppenderSkeleton.DoAppend(LoggingEvent)"/> method.
- /// </summary>
- /// <param name="loggingEvent">The event to log.</param>
- /// <remarks>
- /// <para>
- /// Sends the event using an UDP datagram.
- /// </para>
- /// <para>
- /// Exceptions are passed to the <see cref="AppenderSkeleton.ErrorHandler"/>.
- /// </para>
- /// </remarks>
- protected override void Append(LoggingEvent loggingEvent)
- {
- try
- {
- Byte [] buffer = m_encoding.GetBytes(RenderLoggingEvent(loggingEvent).ToCharArray());
+ /// <summary>
+ /// This method is called by the <see cref="M:AppenderSkeleton.DoAppend(LoggingEvent)"/> method.
+ /// </summary>
+ /// <param name="loggingEvent">The event to log.</param>
+ /// <remarks>
+ /// <para>
+ /// Sends the event using an UDP datagram.
+ /// </para>
+ /// <para>
+ /// Exceptions are passed to the <see cref="AppenderSkeleton.ErrorHandler"/>.
+ /// </para>
+ /// </remarks>
+ protected override void Append(LoggingEvent loggingEvent)
+ {
+ try
+ {
+ Byte [] buffer = m_encoding.GetBytes(RenderLoggingEvent(loggingEvent).ToCharArray());
#if NETSTANDARD
- Client.SendAsync(buffer, buffer.Length, RemoteEndPoint).Wait();
+ Client.SendAsync(buffer, buffer.Length, RemoteEndPoint).Wait();
#else
- this.Client.Send(buffer, buffer.Length, this.RemoteEndPoint);
+ this.Client.Send(buffer, buffer.Length, this.RemoteEndPoint);
#endif
- }
- catch (Exception ex)
- {
- ErrorHandler.Error(
- "Unable to send logging event to remote host " +
- this.RemoteAddress.ToString() +
- " on port " +
- this.RemotePort + ".",
- ex,
- ErrorCode.WriteFailure);
- }
- }
+ }
+ catch (Exception ex)
+ {
+ ErrorHandler.Error(
+ "Unable to send logging event to remote host " +
+ this.RemoteAddress.ToString() +
+ " on port " +
+ this.RemotePort + ".",
+ ex,
+ ErrorCode.WriteFailure);
+ }
+ }
- /// <summary>
- /// This appender requires a <see cref="Layout"/> to be set.
- /// </summary>
- /// <value><c>true</c></value>
- /// <remarks>
- /// <para>
- /// This appender requires a <see cref="Layout"/> to be set.
- /// </para>
- /// </remarks>
- protected override bool RequiresLayout
- {
- get { return true; }
- }
+ /// <summary>
+ /// This appender requires a <see cref="Layout"/> to be set.
+ /// </summary>
+ /// <value><c>true</c></value>
+ /// <remarks>
+ /// <para>
+ /// This appender requires a <see cref="Layout"/> to be set.
+ /// </para>
+ /// </remarks>
+ protected override bool RequiresLayout
+ {
+ get { return true; }
+ }
- /// <summary>
- /// Closes the UDP connection and releases all resources associated with
- /// this <see cref="UdpAppender" /> instance.
- /// </summary>
- /// <remarks>
- /// <para>
- /// Disables the underlying <see cref="UdpClient" /> and releases all managed
- /// and unmanaged resources associated with the <see cref="UdpAppender" />.
- /// </para>
- /// </remarks>
- protected override void OnClose()
- {
- base.OnClose();
+ /// <summary>
+ /// Closes the UDP connection and releases all resources associated with
+ /// this <see cref="UdpAppender" /> instance.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Disables the underlying <see cref="UdpClient" /> and releases all managed
+ /// and unmanaged resources associated with the <see cref="UdpAppender" />.
+ /// </para>
+ /// </remarks>
+ protected override void OnClose()
+ {
+ base.OnClose();
- if (this.Client != null)
- {
- this.Client.Close();
- }
- }
+ if (this.Client != null)
+ {
+ this.Client.Close();
+ }
+ }
- #endregion Override implementation of AppenderSkeleton
+ #endregion Override implementation of AppenderSkeleton
- #region Protected Instance Methods
+ #region Protected Instance Methods
- /// <summary>
- /// Initializes the underlying <see cref="UdpClient" /> connection.
- /// </summary>
- /// <remarks>
- /// <para>
- /// The underlying <see cref="UdpClient"/> is initialized and binds to the
- /// port number from which you intend to communicate.
- /// </para>
- /// <para>
- /// Exceptions are passed to the <see cref="AppenderSkeleton.ErrorHandler"/>.
- /// </para>
- /// </remarks>
- protected virtual void InitializeClientConnection()
- {
- try
- {
- if (this.LocalPort == 0)
- {
+ /// <summary>
+ /// Initializes the underlying <see cref="UdpClient" /> connection.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// The underlying <see cref="UdpClient"/> is initialized and binds to the
+ /// port number from which you intend to communicate.
+ /// </para>
+ /// <para>
+ /// Exceptions are passed to the <see cref="AppenderSkeleton.ErrorHandler"/>.
+ /// </para>
+ /// </remarks>
+ protected virtual void InitializeClientConnection()
+ {
+ try
+ {
+ if (this.LocalPort == 0)
+ {
#if NETCF || NET_1_0 || SSCLI_1_0 || CLI_1_0
- this.Client = new UdpClient();
+ this.Client = new UdpClient();
#else
- this.Client = new UdpClient(RemoteAddress.AddressFamily);
+ this.Client = new UdpClient(RemoteAddress.AddressFamily);
#endif
- }
- else
- {
+ }
+ else
+ {
#if NETCF || NET_1_0 || SSCLI_1_0 || CLI_1_0
- this.Client = new UdpClient(this.LocalPort);
+ this.Client = new UdpClient(this.LocalPort);
#else
- this.Client = new UdpClient(this.LocalPort, RemoteAddress.AddressFamily);
+ this.Client = new UdpClient(this.LocalPort, RemoteAddress.AddressFamily);
#endif
- }
- }
- catch (Exception ex)
- {
- ErrorHandler.Error(
- "Could not initialize the UdpClient connection on port " +
- this.LocalPort.ToString(NumberFormatInfo.InvariantInfo) + ".",
- ex,
- ErrorCode.GenericFailure);
+ }
+ }
+ catch (Exception ex)
+ {
+ ErrorHandler.Error(
+ "Could not initialize the UdpClient connection on port " +
+ this.LocalPort.ToString(NumberFormatInfo.InvariantInfo) + ".",
+ ex,
+ ErrorCode.GenericFailure);
- this.Client = null;
- }
- }
+ this.Client = null;
+ }
+ }
- #endregion Protected Instance Methods
+ #endregion Protected Instance Methods
- #region Private Instance Fields
+ #region Private Instance Fields
- /// <summary>
- /// The IP address of the remote host or multicast group to which
- /// the logging event will be sent.
- /// </summary>
- private IPAddress m_remoteAddress;
-
- /// <summary>
- /// The TCP port number of the remote host or multicast group to
- /// which the logging event will be sent.
- /// </summary>
- private int m_remotePort;
+ /// <summary>
+ /// The IP address of the remote host or multicast group to which
+ /// the logging event will be sent.
+ /// </summary>
+ private IPAddress m_remoteAddress;
+
+ /// <summary>
+ /// The TCP port number of the remote host or multicast group to
+ /// which the logging event will be sent.
+ /// </summary>
+ private int m_remotePort;
- /// <summary>
- /// The cached remote endpoint to which the logging events will be sent.
- /// </summary>
- private IPEndPoint m_remoteEndPoint;
+ /// <summary>
+ /// The cached remote endpoint to which the logging events will be sent.
+ /// </summary>
+ private IPEndPoint m_remoteEndPoint;
- /// <summary>
- /// The TCP port number from which the <see cref="UdpClient" /> will communicate.
- /// </summary>
- private int m_localPort;
+ /// <summary>
+ /// The TCP port number from which the <see cref="UdpClient" /> will communicate.
+ /// </summary>
+ private int m_localPort;
- /// <summary>
- /// The <see cref="UdpClient" /> instance that will be used for sending the
- /// logging events.
- /// </summary>
- private UdpClient m_client;
+ /// <summary>
+ /// The <see cref="UdpClient" /> instance that will be used for sending the
+ /// logging events.
+ /// </summary>
+ private UdpClient m_client;
- /// <summary>
- /// The encoding to use for the packet.
- /// </summary>
+ /// <summary>
+ /// The encoding to use for the packet.
+ /// </summary>
#if NETSTANDARD
- private Encoding m_encoding = Encoding.Unicode;
+ private Encoding m_encoding = Encoding.Unicode;
#else
- private Encoding m_encoding = Encoding.Default;
+ private Encoding m_encoding = Encoding.Default;
#endif
- #endregion Private Instance Fields
- }
+ #endregion Private Instance Fields
+ }
}
diff --git a/src/log4net/AssemblyInfo.cs b/src/log4net/AssemblyInfo.cs
index 2cae3b9..19772bc 100644
--- a/src/log4net/AssemblyInfo.cs
+++ b/src/log4net/AssemblyInfo.cs
@@ -137,8 +137,8 @@
[assembly: AssemblyProduct("log4net")]
[assembly: AssemblyDefaultAlias("log4net")]
-[assembly: AssemblyCulture("")]
-
+[assembly: AssemblyCulture("")]
+
//
// In order to sign your assembly you must specify a key to use. Refer to the
// Microsoft .NET Framework documentation for more information on assembly signing.
diff --git a/src/log4net/Config/AliasDomainAttribute.cs b/src/log4net/Config/AliasDomainAttribute.cs
index 11906f6..dc1af1f 100644
--- a/src/log4net/Config/AliasDomainAttribute.cs
+++ b/src/log4net/Config/AliasDomainAttribute.cs
@@ -24,51 +24,51 @@
namespace log4net.Config
{
- /// <summary>
- /// Assembly level attribute that specifies a domain to alias to this assembly's repository.
- /// </summary>
- /// <remarks>
- /// <para>
- /// <b>AliasDomainAttribute is obsolete. Use AliasRepositoryAttribute instead of AliasDomainAttribute.</b>
- /// </para>
- /// <para>
- /// An assembly's logger repository is defined by its <see cref="DomainAttribute"/>,
- /// however this can be overridden by an assembly loaded before the target assembly.
- /// </para>
- /// <para>
- /// An assembly can alias another assembly's domain to its repository by
- /// specifying this attribute with the name of the target domain.
- /// </para>
- /// <para>
- /// This attribute can only be specified on the assembly and may be used
- /// as many times as necessary to alias all the required domains.
- /// </para>
- /// </remarks>
- /// <author>Nicko Cadell</author>
- /// <author>Gert Driesen</author>
- [AttributeUsage(AttributeTargets.Assembly,AllowMultiple=true)]
- [Serializable]
- [Obsolete("Use AliasRepositoryAttribute instead of AliasDomainAttribute")]
- public sealed class AliasDomainAttribute : AliasRepositoryAttribute
- {
- #region Public Instance Constructors
+ /// <summary>
+ /// Assembly level attribute that specifies a domain to alias to this assembly's repository.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// <b>AliasDomainAttribute is obsolete. Use AliasRepositoryAttribute instead of AliasDomainAttribute.</b>
+ /// </para>
+ /// <para>
+ /// An assembly's logger repository is defined by its <see cref="DomainAttribute"/>,
+ /// however this can be overridden by an assembly loaded before the target assembly.
+ /// </para>
+ /// <para>
+ /// An assembly can alias another assembly's domain to its repository by
+ /// specifying this attribute with the name of the target domain.
+ /// </para>
+ /// <para>
+ /// This attribute can only be specified on the assembly and may be used
+ /// as many times as necessary to alias all the required domains.
+ /// </para>
+ /// </remarks>
+ /// <author>Nicko Cadell</author>
+ /// <author>Gert Driesen</author>
+ [AttributeUsage(AttributeTargets.Assembly,AllowMultiple=true)]
+ [Serializable]
+ [Obsolete("Use AliasRepositoryAttribute instead of AliasDomainAttribute")]
+ public sealed class AliasDomainAttribute : AliasRepositoryAttribute
+ {
+ #region Public Instance Constructors
- /// <summary>
- /// Initializes a new instance of the <see cref="AliasDomainAttribute" /> class with
- /// the specified domain to alias to this assembly's repository.
- /// </summary>
- /// <param name="name">The domain to alias to this assemby's repository.</param>
- /// <remarks>
- /// <para>
- /// Obsolete. Use <see cref="AliasRepositoryAttribute"/> instead of <see cref="AliasDomainAttribute"/>.
- /// </para>
- /// </remarks>
- public AliasDomainAttribute(string name) : base(name)
- {
- }
+ /// <summary>
+ /// Initializes a new instance of the <see cref="AliasDomainAttribute" /> class with
+ /// the specified domain to alias to this assembly's repository.
+ /// </summary>
+ /// <param name="name">The domain to alias to this assemby's repository.</param>
+ /// <remarks>
+ /// <para>
+ /// Obsolete. Use <see cref="AliasRepositoryAttribute"/> instead of <see cref="AliasDomainAttribute"/>.
+ /// </para>
+ /// </remarks>
+ public AliasDomainAttribute(string name) : base(name)
+ {
+ }
- #endregion Public Instance Constructors
- }
+ #endregion Public Instance Constructors
+ }
}
#endif // !NETCF
\ No newline at end of file
diff --git a/src/log4net/Config/AliasRepositoryAttribute.cs b/src/log4net/Config/AliasRepositoryAttribute.cs
index da83b77..1b6021f 100644
--- a/src/log4net/Config/AliasRepositoryAttribute.cs
+++ b/src/log4net/Config/AliasRepositoryAttribute.cs
@@ -24,80 +24,80 @@
namespace log4net.Config
{
- /// <summary>
- /// Assembly level attribute that specifies a repository to alias to this assembly's repository.
- /// </summary>
- /// <remarks>
- /// <para>
- /// An assembly's logger repository is defined by its <see cref="RepositoryAttribute"/>,
- /// however this can be overridden by an assembly loaded before the target assembly.
- /// </para>
- /// <para>
- /// An assembly can alias another assembly's repository to its repository by
- /// specifying this attribute with the name of the target repository.
- /// </para>
- /// <para>
- /// This attribute can only be specified on the assembly and may be used
- /// as many times as necessary to alias all the required repositories.
- /// </para>
- /// </remarks>
- /// <author>Nicko Cadell</author>
- /// <author>Gert Driesen</author>
- [AttributeUsage(AttributeTargets.Assembly,AllowMultiple=true)]
- [Serializable]
- public /*sealed*/ class AliasRepositoryAttribute : Attribute
- {
- //
- // Class is not sealed because AliasDomainAttribute extends it while it is obsoleted
- //
+ /// <summary>
+ /// Assembly level attribute that specifies a repository to alias to this assembly's repository.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// An assembly's logger repository is defined by its <see cref="RepositoryAttribute"/>,
+ /// however this can be overridden by an assembly loaded before the target assembly.
+ /// </para>
+ /// <para>
+ /// An assembly can alias another assembly's repository to its repository by
+ /// specifying this attribute with the name of the target repository.
+ /// </para>
+ /// <para>
+ /// This attribute can only be specified on the assembly and may be used
+ /// as many times as necessary to alias all the required repositories.
+ /// </para>
+ /// </remarks>
+ /// <author>Nicko Cadell</author>
+ /// <author>Gert Driesen</author>
+ [AttributeUsage(AttributeTargets.Assembly,AllowMultiple=true)]
+ [Serializable]
+ public /*sealed*/ class AliasRepositoryAttribute : Attribute
+ {
+ //
+ // Class is not sealed because AliasDomainAttribute extends it while it is obsoleted
+ //
- #region Public Instance Constructors
+ #region Public Instance Constructors
- /// <summary>
- /// Initializes a new instance of the <see cref="AliasRepositoryAttribute" /> class with
- /// the specified repository to alias to this assembly's repository.
- /// </summary>
- /// <param name="name">The repository to alias to this assemby's repository.</param>
- /// <remarks>
- /// <para>
- /// Initializes a new instance of the <see cref="AliasRepositoryAttribute" /> class with
- /// the specified repository to alias to this assembly's repository.
- /// </para>
- /// </remarks>
- public AliasRepositoryAttribute(string name)
- {
- Name = name;
- }
+ /// <summary>
+ /// Initializes a new instance of the <see cref="AliasRepositoryAttribute" /> class with
+ /// the specified repository to alias to this assembly's repository.
+ /// </summary>
+ /// <param name="name">The repository to alias to this assemby's repository.</param>
+ /// <remarks>
+ /// <para>
+ /// Initializes a new instance of the <see cref="AliasRepositoryAttribute" /> class with
+ /// the specified repository to alias to this assembly's repository.
+ /// </para>
+ /// </remarks>
+ public AliasRepositoryAttribute(string name)
+ {
+ Name = name;
+ }
- #endregion Public Instance Constructors
+ #endregion Public Instance Constructors
- #region Public Instance Properties
+ #region Public Instance Properties
- /// <summary>
- /// Gets or sets the repository to alias to this assemby's repository.
- /// </summary>
- /// <value>
- /// The repository to alias to this assemby's repository.
- /// </value>
- /// <remarks>
- /// <para>
- /// The name of the repository to alias to this assemby's repository.
- /// </para>
- /// </remarks>
- public string Name
- {
- get { return m_name; }
- set { m_name = value ; }
- }
+ /// <summary>
+ /// Gets or sets the repository to alias to this assemby's repository.
+ /// </summary>
+ /// <value>
+ /// The repository to alias to this assemby's repository.
+ /// </value>
+ /// <remarks>
+ /// <para>
+ /// The name of the repository to alias to this assemby's repository.
+ /// </para>
+ /// </remarks>
+ public string Name
+ {
+ get { return m_name; }
+ set { m_name = value ; }
+ }
- #endregion Public Instance Properties
+ #endregion Public Instance Properties
- #region Private Instance Fields
+ #region Private Instance Fields
- private string m_name = null;
+ private string m_name = null;
- #endregion Private Instance Fields
- }
+ #endregion Private Instance Fields
+ }
}
#endif // !NETCF
\ No newline at end of file
diff --git a/src/log4net/Config/BasicConfigurator.cs b/src/log4net/Config/BasicConfigurator.cs
index 374cf72..8e5a6b2 100644
--- a/src/log4net/Config/BasicConfigurator.cs
+++ b/src/log4net/Config/BasicConfigurator.cs
@@ -31,74 +31,74 @@
namespace log4net.Config
{
- /// <summary>
- /// Use this class to quickly configure a <see cref="Hierarchy"/>.
- /// </summary>
- /// <remarks>
- /// <para>
- /// Allows very simple programmatic configuration of log4net.
- /// </para>
- /// <para>
- /// Only one appender can be configured using this configurator.
- /// The appender is set at the root of the hierarchy and all logging
- /// events will be delivered to that appender.
- /// </para>
- /// <para>
- /// Appenders can also implement the <see cref="log4net.Core.IOptionHandler"/> interface. Therefore
- /// they would require that the <see cref="M:log4net.Core.IOptionHandler.ActivateOptions()"/> method
- /// be called after the appenders properties have been configured.
- /// </para>
- /// </remarks>
- /// <author>Nicko Cadell</author>
- /// <author>Gert Driesen</author>
- public sealed class BasicConfigurator
+ /// <summary>
+ /// Use this class to quickly configure a <see cref="Hierarchy"/>.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Allows very simple programmatic configuration of log4net.
+ /// </para>
+ /// <para>
+ /// Only one appender can be configured using this configurator.
+ /// The appender is set at the root of the hierarchy and all logging
+ /// events will be delivered to that appender.
+ /// </para>
+ /// <para>
+ /// Appenders can also implement the <see cref="log4net.Core.IOptionHandler"/> interface. Therefore
+ /// they would require that the <see cref="M:log4net.Core.IOptionHandler.ActivateOptions()"/> method
+ /// be called after the appenders properties have been configured.
+ /// </para>
+ /// </remarks>
+ /// <author>Nicko Cadell</author>
+ /// <author>Gert Driesen</author>
+ public sealed class BasicConfigurator
{
- #region Private Static Fields
+ #region Private Static Fields
- /// <summary>
- /// The fully qualified type of the BasicConfigurator class.
- /// </summary>
- /// <remarks>
- /// Used by the internal logger to record the Type of the
- /// log message.
- /// </remarks>
- private static readonly Type declaringType = typeof(BasicConfigurator);
+ /// <summary>
+ /// The fully qualified type of the BasicConfigurator class.
+ /// </summary>
+ /// <remarks>
+ /// Used by the internal logger to record the Type of the
+ /// log message.
+ /// </remarks>
+ private static readonly Type declaringType = typeof(BasicConfigurator);
- #endregion Private Static Fields
+ #endregion Private Static Fields
#region Private Instance Constructors
/// <summary>
- /// Initializes a new instance of the <see cref="BasicConfigurator" /> class.
- /// </summary>
- /// <remarks>
- /// <para>
- /// Uses a private access modifier to prevent instantiation of this class.
- /// </para>
- /// </remarks>
- private BasicConfigurator()
- {
- }
+ /// Initializes a new instance of the <see cref="BasicConfigurator" /> class.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Uses a private access modifier to prevent instantiation of this class.
+ /// </para>
+ /// </remarks>
+ private BasicConfigurator()
+ {
+ }
- #endregion Private Instance Constructors
+ #endregion Private Instance Constructors
- #region Public Static Methods
+ #region Public Static Methods
#if !NETSTANDARD1_3
- /// <summary>
- /// Initializes the log4net system with a default configuration.
- /// </summary>
- /// <remarks>
- /// <para>
- /// Initializes the log4net logging system using a <see cref="ConsoleAppender"/>
- /// that will write to <c>Console.Out</c>. The log messages are
- /// formatted using the <see cref="PatternLayout"/> layout object
- /// with the <see cref="PatternLayout.DetailConversionPattern"/>
- /// layout style.
- /// </para>
- /// </remarks>
+ /// <summary>
+ /// Initializes the log4net system with a default configuration.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Initializes the log4net logging system using a <see cref="ConsoleAppender"/>
+ /// that will write to <c>Console.Out</c>. The log messages are
+ /// formatted using the <see cref="PatternLayout"/> layout object
+ /// with the <see cref="PatternLayout.DetailConversionPattern"/>
+ /// layout style.
+ /// </para>
+ /// </remarks>
public static ICollection Configure()
- {
+ {
return BasicConfigurator.Configure(LogManager.GetRepository(Assembly.GetCallingAssembly()));
}
@@ -127,36 +127,36 @@
return configurationMessages;
}
- /// <summary>
- /// Initializes the log4net system using the specified appender.
- /// </summary>
- /// <param name="appender">The appender to use to log all logging events.</param>
- /// <remarks>
- /// <para>
- /// Initializes the log4net system using the specified appender.
- /// </para>
- /// </remarks>
- public static ICollection Configure(IAppender appender)
- {
+ /// <summary>
+ /// Initializes the log4net system using the specified appender.
+ /// </summary>
+ /// <param name="appender">The appender to use to log all logging events.</param>
+ /// <remarks>
+ /// <para>
+ /// Initializes the log4net system using the specified appender.
+ /// </para>
+ /// </remarks>
+ public static ICollection Configure(IAppender appender)
+ {
return Configure(new IAppender[] { appender });
- }
+ }
#endif // !NETSTANDARD1_3
- /// <summary>
- /// Initializes the <see cref="ILoggerRepository"/> with a default configuration.
- /// </summary>
- /// <param name="repository">The repository to configure.</param>
- /// <remarks>
- /// <para>
- /// Initializes the specified repository using a <see cref="ConsoleAppender"/>
- /// that will write to <c>Console.Out</c>. The log messages are
- /// formatted using the <see cref="PatternLayout"/> layout object
- /// with the <see cref="PatternLayout.DetailConversionPattern"/>
- /// layout style.
- /// </para>
- /// </remarks>
+ /// <summary>
+ /// Initializes the <see cref="ILoggerRepository"/> with a default configuration.
+ /// </summary>
+ /// <param name="repository">The repository to configure.</param>
+ /// <remarks>
+ /// <para>
+ /// Initializes the specified repository using a <see cref="ConsoleAppender"/>
+ /// that will write to <c>Console.Out</c>. The log messages are
+ /// formatted using the <see cref="PatternLayout"/> layout object
+ /// with the <see cref="PatternLayout.DetailConversionPattern"/>
+ /// layout style.
+ /// </para>
+ /// </remarks>
public static ICollection Configure(ILoggerRepository repository)
- {
+ {
ArrayList configurationMessages = new ArrayList();
using (new LogLog.LogReceivedAdapter(configurationMessages))
@@ -177,7 +177,7 @@
repository.ConfigurationMessages = configurationMessages;
return configurationMessages;
- }
+ }
/// <summary>
/// Initializes the <see cref="ILoggerRepository"/> using the specified appender.
@@ -217,9 +217,9 @@
return configurationMessages;
}
-
- private static void InternalConfigure(ILoggerRepository repository, params IAppender[] appenders)
- {
+
+ private static void InternalConfigure(ILoggerRepository repository, params IAppender[] appenders)
+ {
IBasicRepositoryConfigurator configurableRepository = repository as IBasicRepositoryConfigurator;
if (configurableRepository != null)
{
@@ -229,8 +229,8 @@
{
LogLog.Warn(declaringType, "BasicConfigurator: Repository [" + repository + "] does not support the BasicConfigurator");
}
- }
+ }
- #endregion Public Static Methods
- }
+ #endregion Public Static Methods
+ }
}
diff --git a/src/log4net/Config/ConfiguratorAttribute.cs b/src/log4net/Config/ConfiguratorAttribute.cs
index e3da674..c884736 100644
--- a/src/log4net/Config/ConfiguratorAttribute.cs
+++ b/src/log4net/Config/ConfiguratorAttribute.cs
@@ -27,87 +27,87 @@
namespace log4net.Config
{
- /// <summary>
- /// Base class for all log4net configuration attributes.
- /// </summary>
- /// <remarks>
- /// This is an abstract class that must be extended by
- /// specific configurators. This attribute allows the
- /// configurator to be parameterized by an assembly level
- /// attribute.
- /// </remarks>
- /// <author>Nicko Cadell</author>
- /// <author>Gert Driesen</author>
- [AttributeUsage(AttributeTargets.Assembly)]
- public abstract class ConfiguratorAttribute : Attribute, IComparable
- {
- private int m_priority = 0;
+ /// <summary>
+ /// Base class for all log4net configuration attributes.
+ /// </summary>
+ /// <remarks>
+ /// This is an abstract class that must be extended by
+ /// specific configurators. This attribute allows the
+ /// configurator to be parameterized by an assembly level
+ /// attribute.
+ /// </remarks>
+ /// <author>Nicko Cadell</author>
+ /// <author>Gert Driesen</author>
+ [AttributeUsage(AttributeTargets.Assembly)]
+ public abstract class ConfiguratorAttribute : Attribute, IComparable
+ {
+ private int m_priority = 0;
- /// <summary>
- /// Constructor used by subclasses.
- /// </summary>
- /// <param name="priority">the ordering priority for this configurator</param>
- /// <remarks>
- /// <para>
- /// The <paramref name="priority"/> is used to order the configurator
- /// attributes before they are invoked. Higher priority configurators are executed
- /// before lower priority ones.
- /// </para>
- /// </remarks>
- protected ConfiguratorAttribute(int priority)
- {
- m_priority = priority;
- }
+ /// <summary>
+ /// Constructor used by subclasses.
+ /// </summary>
+ /// <param name="priority">the ordering priority for this configurator</param>
+ /// <remarks>
+ /// <para>
+ /// The <paramref name="priority"/> is used to order the configurator
+ /// attributes before they are invoked. Higher priority configurators are executed
+ /// before lower priority ones.
+ /// </para>
+ /// </remarks>
+ protected ConfiguratorAttribute(int priority)
+ {
+ m_priority = priority;
+ }
- /// <summary>
- /// Configures the <see cref="ILoggerRepository"/> for the specified assembly.
- /// </summary>
- /// <param name="sourceAssembly">The assembly that this attribute was defined on.</param>
- /// <param name="targetRepository">The repository to configure.</param>
- /// <remarks>
- /// <para>
- /// Abstract method implemented by a subclass. When this method is called
- /// the subclass should configure the <paramref name="targetRepository"/>.
- /// </para>
- /// </remarks>
- public abstract void Configure(Assembly sourceAssembly, ILoggerRepository targetRepository);
+ /// <summary>
+ /// Configures the <see cref="ILoggerRepository"/> for the specified assembly.
+ /// </summary>
+ /// <param name="sourceAssembly">The assembly that this attribute was defined on.</param>
+ /// <param name="targetRepository">The repository to configure.</param>
+ /// <remarks>
+ /// <para>
+ /// Abstract method implemented by a subclass. When this method is called
+ /// the subclass should configure the <paramref name="targetRepository"/>.
+ /// </para>
+ /// </remarks>
+ public abstract void Configure(Assembly sourceAssembly, ILoggerRepository targetRepository);
- /// <summary>
- /// Compare this instance to another ConfiguratorAttribute
- /// </summary>
- /// <param name="obj">the object to compare to</param>
- /// <returns>see <see cref="IComparable.CompareTo"/></returns>
- /// <remarks>
- /// <para>
- /// Compares the priorities of the two <see cref="ConfiguratorAttribute"/> instances.
- /// Sorts by priority in descending order. Objects with the same priority are
- /// randomly ordered.
- /// </para>
- /// </remarks>
- public int CompareTo(object obj)
- {
- // Reference equals
- if ((object)this == obj)
- {
- return 0;
- }
+ /// <summary>
+ /// Compare this instance to another ConfiguratorAttribute
+ /// </summary>
+ /// <param name="obj">the object to compare to</param>
+ /// <returns>see <see cref="IComparable.CompareTo"/></returns>
+ /// <remarks>
+ /// <para>
+ /// Compares the priorities of the two <see cref="ConfiguratorAttribute"/> instances.
+ /// Sorts by priority in descending order. Objects with the same priority are
+ /// randomly ordered.
+ /// </para>
+ /// </remarks>
+ public int CompareTo(object obj)
+ {
+ // Reference equals
+ if ((object)this == obj)
+ {
+ return 0;
+ }
- int result = -1;
+ int result = -1;
- ConfiguratorAttribute target = obj as ConfiguratorAttribute;
- if (target != null)
- {
- // Compare the priorities
- result = target.m_priority.CompareTo(m_priority);
- if (result == 0)
- {
- // Same priority, so have to provide some ordering
- result = -1;
- }
- }
- return result;
- }
- }
+ ConfiguratorAttribute target = obj as ConfiguratorAttribute;
+ if (target != null)
+ {
+ // Compare the priorities
+ result = target.m_priority.CompareTo(m_priority);
+ if (result == 0)
+ {
+ // Same priority, so have to provide some ordering
+ result = -1;
+ }
+ }
+ return result;
+ }
+ }
}
#endif //!NETCF
\ No newline at end of file
diff --git a/src/log4net/Config/DOMConfigurator.cs b/src/log4net/Config/DOMConfigurator.cs
index 2dd16d8..0486edf 100644
--- a/src/log4net/Config/DOMConfigurator.cs
+++ b/src/log4net/Config/DOMConfigurator.cs
@@ -31,329 +31,329 @@
namespace log4net.Config
{
- /// <summary>
- /// Use this class to initialize the log4net environment using an Xml tree.
- /// </summary>
- /// <remarks>
- /// <para>
- /// <b>DOMConfigurator is obsolete. Use XmlConfigurator instead of DOMConfigurator.</b>
- /// </para>
- /// <para>
- /// Configures a <see cref="ILoggerRepository"/> using an Xml tree.
- /// </para>
- /// </remarks>
- /// <author>Nicko Cadell</author>
- /// <author>Gert Driesen</author>
- [Obsolete("Use XmlConfigurator instead of DOMConfigurator")]
- public sealed class DOMConfigurator
- {
- #region Private Instance Constructors
+ /// <summary>
+ /// Use this class to initialize the log4net environment using an Xml tree.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// <b>DOMConfigurator is obsolete. Use XmlConfigurator instead of DOMConfigurator.</b>
+ /// </para>
+ /// <para>
+ /// Configures a <see cref="ILoggerRepository"/> using an Xml tree.
+ /// </para>
+ /// </remarks>
+ /// <author>Nicko Cadell</author>
+ /// <author>Gert Driesen</author>
+ [Obsolete("Use XmlConfigurator instead of DOMConfigurator")]
+ public sealed class DOMConfigurator
+ {
+ #region Private Instance Constructors
- /// <summary>
- /// Private constructor
- /// </summary>
- private DOMConfigurator()
- {
- }
+ /// <summary>
+ /// Private constructor
+ /// </summary>
+ private DOMConfigurator()
+ {
+ }
- #endregion Protected Instance Constructors
+ #endregion Protected Instance Constructors
- #region Configure static methods
+ #region Configure static methods
- /// <summary>
- /// Automatically configures the log4net system based on the
- /// application's configuration settings.
- /// </summary>
- /// <remarks>
- /// <para>
- /// <b>DOMConfigurator is obsolete. Use XmlConfigurator instead of DOMConfigurator.</b>
- /// </para>
- /// Each application has a configuration file. This has the
- /// same name as the application with '.config' appended.
- /// This file is XML and calling this function prompts the
- /// configurator to look in that file for a section called
- /// <c>log4net</c> that contains the configuration data.
- /// </remarks>
- [Obsolete("Use XmlConfigurator.Configure instead of DOMConfigurator.Configure")]
- public static void Configure()
- {
- XmlConfigurator.Configure(LogManager.GetRepository(Assembly.GetCallingAssembly()));
- }
+ /// <summary>
+ /// Automatically configures the log4net system based on the
+ /// application's configuration settings.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// <b>DOMConfigurator is obsolete. Use XmlConfigurator instead of DOMConfigurator.</b>
+ /// </para>
+ /// Each application has a configuration file. This has the
+ /// same name as the application with '.config' appended.
+ /// This file is XML and calling this function prompts the
+ /// configurator to look in that file for a section called
+ /// <c>log4net</c> that contains the configuration data.
+ /// </remarks>
+ [Obsolete("Use XmlConfigurator.Configure instead of DOMConfigurator.Configure")]
+ public static void Configure()
+ {
+ XmlConfigurator.Configure(LogManager.GetRepository(Assembly.GetCallingAssembly()));
+ }
- /// <summary>
- /// Automatically configures the <see cref="ILoggerRepository"/> using settings
- /// stored in the application's configuration file.
- /// </summary>
- /// <remarks>
- /// <para>
- /// <b>DOMConfigurator is obsolete. Use XmlConfigurator instead of DOMConfigurator.</b>
- /// </para>
- /// Each application has a configuration file. This has the
- /// same name as the application with '.config' appended.
- /// This file is XML and calling this function prompts the
- /// configurator to look in that file for a section called
- /// <c>log4net</c> that contains the configuration data.
- /// </remarks>
- /// <param name="repository">The repository to configure.</param>
- [Obsolete("Use XmlConfigurator.Configure instead of DOMConfigurator.Configure")]
- public static void Configure(ILoggerRepository repository)
- {
- XmlConfigurator.Configure(repository);
- }
+ /// <summary>
+ /// Automatically configures the <see cref="ILoggerRepository"/> using settings
+ /// stored in the application's configuration file.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// <b>DOMConfigurator is obsolete. Use XmlConfigurator instead of DOMConfigurator.</b>
+ /// </para>
+ /// Each application has a configuration file. This has the
+ /// same name as the application with '.config' appended.
+ /// This file is XML and calling this function prompts the
+ /// configurator to look in that file for a section called
+ /// <c>log4net</c> that contains the configuration data.
+ /// </remarks>
+ /// <param name="repository">The repository to configure.</param>
+ [Obsolete("Use XmlConfigurator.Configure instead of DOMConfigurator.Configure")]
+ public static void Configure(ILoggerRepository repository)
+ {
+ XmlConfigurator.Configure(repository);
+ }
- /// <summary>
- /// Configures log4net using a <c>log4net</c> element
- /// </summary>
- /// <remarks>
- /// <para>
- /// <b>DOMConfigurator is obsolete. Use XmlConfigurator instead of DOMConfigurator.</b>
- /// </para>
- /// Loads the log4net configuration from the XML element
- /// supplied as <paramref name="element"/>.
- /// </remarks>
- /// <param name="element">The element to parse.</param>
- [Obsolete("Use XmlConfigurator.Configure instead of DOMConfigurator.Configure")]
- public static void Configure(XmlElement element)
- {
- XmlConfigurator.Configure(LogManager.GetRepository(Assembly.GetCallingAssembly()), element);
- }
+ /// <summary>
+ /// Configures log4net using a <c>log4net</c> element
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// <b>DOMConfigurator is obsolete. Use XmlConfigurator instead of DOMConfigurator.</b>
+ /// </para>
+ /// Loads the log4net configuration from the XML element
+ /// supplied as <paramref name="element"/>.
+ /// </remarks>
+ /// <param name="element">The element to parse.</param>
+ [Obsolete("Use XmlConfigurator.Configure instead of DOMConfigurator.Configure")]
+ public static void Configure(XmlElement element)
+ {
+ XmlConfigurator.Configure(LogManager.GetRepository(Assembly.GetCallingAssembly()), element);
+ }
- /// <summary>
- /// Configures the <see cref="ILoggerRepository"/> using the specified XML
- /// element.
- /// </summary>
- /// <remarks>
- /// <para>
- /// <b>DOMConfigurator is obsolete. Use XmlConfigurator instead of DOMConfigurator.</b>
- /// </para>
- /// Loads the log4net configuration from the XML element
- /// supplied as <paramref name="element"/>.
- /// </remarks>
- /// <param name="repository">The repository to configure.</param>
- /// <param name="element">The element to parse.</param>
- [Obsolete("Use XmlConfigurator.Configure instead of DOMConfigurator.Configure")]
- public static void Configure(ILoggerRepository repository, XmlElement element)
- {
- XmlConfigurator.Configure(repository, element);
- }
+ /// <summary>
+ /// Configures the <see cref="ILoggerRepository"/> using the specified XML
+ /// element.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// <b>DOMConfigurator is obsolete. Use XmlConfigurator instead of DOMConfigurator.</b>
+ /// </para>
+ /// Loads the log4net configuration from the XML element
+ /// supplied as <paramref name="element"/>.
+ /// </remarks>
+ /// <param name="repository">The repository to configure.</param>
+ /// <param name="element">The element to parse.</param>
+ [Obsolete("Use XmlConfigurator.Configure instead of DOMConfigurator.Configure")]
+ public static void Configure(ILoggerRepository repository, XmlElement element)
+ {
+ XmlConfigurator.Configure(repository, element);
+ }
- /// <summary>
- /// Configures log4net using the specified configuration file.
- /// </summary>
- /// <param name="configFile">The XML file to load the configuration from.</param>
- /// <remarks>
- /// <para>
- /// <b>DOMConfigurator is obsolete. Use XmlConfigurator instead of DOMConfigurator.</b>
- /// </para>
- /// <para>
- /// The configuration file must be valid XML. It must contain
- /// at least one element called <c>log4net</c> that holds
- /// the log4net configuration data.
- /// </para>
- /// <para>
- /// The log4net configuration file can possible be specified in the application's
- /// configuration file (either <c>MyAppName.exe.config</c> for a
- /// normal application on <c>Web.config</c> for an ASP.NET application).
- /// </para>
- /// <example>
- /// The following example configures log4net using a configuration file, of which the
- /// location is stored in the application's configuration file :
- /// </example>
- /// <code lang="C#">
- /// using log4net.Config;
- /// using System.IO;
- /// using System.Configuration;
- ///
- /// ...
- ///
- /// DOMConfigurator.Configure(new FileInfo(ConfigurationSettings.AppSettings["log4net-config-file"]));
- /// </code>
- /// <para>
- /// In the <c>.config</c> file, the path to the log4net can be specified like this :
- /// </para>
- /// <code lang="XML" escaped="true">
- /// <configuration>
- /// <appSettings>
- /// <add key="log4net-config-file" value="log.config"/>
- /// </appSettings>
- /// </configuration>
- /// </code>
- /// </remarks>
- [Obsolete("Use XmlConfigurator.Configure instead of DOMConfigurator.Configure")]
- public static void Configure(FileInfo configFile)
- {
- XmlConfigurator.Configure(LogManager.GetRepository(Assembly.GetCallingAssembly()), configFile);
- }
+ /// <summary>
+ /// Configures log4net using the specified configuration file.
+ /// </summary>
+ /// <param name="configFile">The XML file to load the configuration from.</param>
+ /// <remarks>
+ /// <para>
+ /// <b>DOMConfigurator is obsolete. Use XmlConfigurator instead of DOMConfigurator.</b>
+ /// </para>
+ /// <para>
+ /// The configuration file must be valid XML. It must contain
+ /// at least one element called <c>log4net</c> that holds
+ /// the log4net configuration data.
+ /// </para>
+ /// <para>
+ /// The log4net configuration file can possible be specified in the application's
+ /// configuration file (either <c>MyAppName.exe.config</c> for a
+ /// normal application on <c>Web.config</c> for an ASP.NET application).
+ /// </para>
+ /// <example>
+ /// The following example configures log4net using a configuration file, of which the
+ /// location is stored in the application's configuration file :
+ /// </example>
+ /// <code lang="C#">
+ /// using log4net.Config;
+ /// using System.IO;
+ /// using System.Configuration;
+ ///
+ /// ...
+ ///
+ /// DOMConfigurator.Configure(new FileInfo(ConfigurationSettings.AppSettings["log4net-config-file"]));
+ /// </code>
+ /// <para>
+ /// In the <c>.config</c> file, the path to the log4net can be specified like this :
+ /// </para>
+ /// <code lang="XML" escaped="true">
+ /// <configuration>
+ /// <appSettings>
+ /// <add key="log4net-config-file" value="log.config"/>
+ /// </appSettings>
+ /// </configuration>
+ /// </code>
+ /// </remarks>
+ [Obsolete("Use XmlConfigurator.Configure instead of DOMConfigurator.Configure")]
+ public static void Configure(FileInfo configFile)
+ {
+ XmlConfigurator.Configure(LogManager.GetRepository(Assembly.GetCallingAssembly()), configFile);
+ }
- /// <summary>
- /// Configures log4net using the specified configuration file.
- /// </summary>
- /// <param name="configStream">A stream to load the XML configuration from.</param>
- /// <remarks>
- /// <para>
- /// <b>DOMConfigurator is obsolete. Use XmlConfigurator instead of DOMConfigurator.</b>
- /// </para>
- /// <para>
- /// The configuration data must be valid XML. It must contain
- /// at least one element called <c>log4net</c> that holds
- /// the log4net configuration data.
- /// </para>
- /// <para>
- /// Note that this method will NOT close the stream parameter.
- /// </para>
- /// </remarks>
- [Obsolete("Use XmlConfigurator.Configure instead of DOMConfigurator.Configure")]
- public static void Configure(Stream configStream)
- {
- XmlConfigurator.Configure(LogManager.GetRepository(Assembly.GetCallingAssembly()), configStream);
- }
+ /// <summary>
+ /// Configures log4net using the specified configuration file.
+ /// </summary>
+ /// <param name="configStream">A stream to load the XML configuration from.</param>
+ /// <remarks>
+ /// <para>
+ /// <b>DOMConfigurator is obsolete. Use XmlConfigurator instead of DOMConfigurator.</b>
+ /// </para>
+ /// <para>
+ /// The configuration data must be valid XML. It must contain
+ /// at least one element called <c>log4net</c> that holds
+ /// the log4net configuration data.
+ /// </para>
+ /// <para>
+ /// Note that this method will NOT close the stream parameter.
+ /// </para>
+ /// </remarks>
+ [Obsolete("Use XmlConfigurator.Configure instead of DOMConfigurator.Configure")]
+ public static void Configure(Stream configStream)
+ {
+ XmlConfigurator.Configure(LogManager.GetRepository(Assembly.GetCallingAssembly()), configStream);
+ }
- /// <summary>
- /// Configures the <see cref="ILoggerRepository"/> using the specified configuration
- /// file.
- /// </summary>
- /// <param name="repository">The repository to configure.</param>
- /// <param name="configFile">The XML file to load the configuration from.</param>
- /// <remarks>
- /// <para>
- /// <b>DOMConfigurator is obsolete. Use XmlConfigurator instead of DOMConfigurator.</b>
- /// </para>
- /// <para>
- /// The configuration file must be valid XML. It must contain
- /// at least one element called <c>log4net</c> that holds
- /// the configuration data.
- /// </para>
- /// <para>
- /// The log4net configuration file can possible be specified in the application's
- /// configuration file (either <c>MyAppName.exe.config</c> for a
- /// normal application on <c>Web.config</c> for an ASP.NET application).
- /// </para>
- /// <example>
- /// The following example configures log4net using a configuration file, of which the
- /// location is stored in the application's configuration file :
- /// </example>
- /// <code lang="C#">
- /// using log4net.Config;
- /// using System.IO;
- /// using System.Configuration;
- ///
- /// ...
- ///
- /// DOMConfigurator.Configure(new FileInfo(ConfigurationSettings.AppSettings["log4net-config-file"]));
- /// </code>
- /// <para>
- /// In the <c>.config</c> file, the path to the log4net can be specified like this :
- /// </para>
- /// <code lang="XML" escaped="true">
- /// <configuration>
- /// <appSettings>
- /// <add key="log4net-config-file" value="log.config"/>
- /// </appSettings>
- /// </configuration>
- /// </code>
- /// </remarks>
- [Obsolete("Use XmlConfigurator.Configure instead of DOMConfigurator.Configure")]
- public static void Configure(ILoggerRepository repository, FileInfo configFile)
- {
- XmlConfigurator.Configure(repository, configFile);
- }
+ /// <summary>
+ /// Configures the <see cref="ILoggerRepository"/> using the specified configuration
+ /// file.
+ /// </summary>
+ /// <param name="repository">The repository to configure.</param>
+ /// <param name="configFile">The XML file to load the configuration from.</param>
+ /// <remarks>
+ /// <para>
+ /// <b>DOMConfigurator is obsolete. Use XmlConfigurator instead of DOMConfigurator.</b>
+ /// </para>
+ /// <para>
+ /// The configuration file must be valid XML. It must contain
+ /// at least one element called <c>log4net</c> that holds
+ /// the configuration data.
+ /// </para>
+ /// <para>
+ /// The log4net configuration file can possible be specified in the application's
+ /// configuration file (either <c>MyAppName.exe.config</c> for a
+ /// normal application on <c>Web.config</c> for an ASP.NET application).
+ /// </para>
+ /// <example>
+ /// The following example configures log4net using a configuration file, of which the
+ /// location is stored in the application's configuration file :
+ /// </example>
+ /// <code lang="C#">
+ /// using log4net.Config;
+ /// using System.IO;
+ /// using System.Configuration;
+ ///
+ /// ...
+ ///
+ /// DOMConfigurator.Configure(new FileInfo(ConfigurationSettings.AppSettings["log4net-config-file"]));
+ /// </code>
+ /// <para>
+ /// In the <c>.config</c> file, the path to the log4net can be specified like this :
+ /// </para>
+ /// <code lang="XML" escaped="true">
+ /// <configuration>
+ /// <appSettings>
+ /// <add key="log4net-config-file" value="log.config"/>
+ /// </appSettings>
+ /// </configuration>
+ /// </code>
+ /// </remarks>
+ [Obsolete("Use XmlConfigurator.Configure instead of DOMConfigurator.Configure")]
+ public static void Configure(ILoggerRepository repository, FileInfo configFile)
+ {
+ XmlConfigurator.Configure(repository, configFile);
+ }
- /// <summary>
- /// Configures the <see cref="ILoggerRepository"/> using the specified configuration
- /// file.
- /// </summary>
- /// <param name="repository">The repository to configure.</param>
- /// <param name="configStream">The stream to load the XML configuration from.</param>
- /// <remarks>
- /// <para>
- /// <b>DOMConfigurator is obsolete. Use XmlConfigurator instead of DOMConfigurator.</b>
- /// </para>
- /// <para>
- /// The configuration data must be valid XML. It must contain
- /// at least one element called <c>log4net</c> that holds
- /// the configuration data.
- /// </para>
- /// <para>
- /// Note that this method will NOT close the stream parameter.
- /// </para>
- /// </remarks>
- [Obsolete("Use XmlConfigurator.Configure instead of DOMConfigurator.Configure")]
- public static void Configure(ILoggerRepository repository, Stream configStream)
- {
- XmlConfigurator.Configure(repository, configStream);
- }
+ /// <summary>
+ /// Configures the <see cref="ILoggerRepository"/> using the specified configuration
+ /// file.
+ /// </summary>
+ /// <param name="repository">The repository to configure.</param>
+ /// <param name="configStream">The stream to load the XML configuration from.</param>
+ /// <remarks>
+ /// <para>
+ /// <b>DOMConfigurator is obsolete. Use XmlConfigurator instead of DOMConfigurator.</b>
+ /// </para>
+ /// <para>
+ /// The configuration data must be valid XML. It must contain
+ /// at least one element called <c>log4net</c> that holds
+ /// the configuration data.
+ /// </para>
+ /// <para>
+ /// Note that this method will NOT close the stream parameter.
+ /// </para>
+ /// </remarks>
+ [Obsolete("Use XmlConfigurator.Configure instead of DOMConfigurator.Configure")]
+ public static void Configure(ILoggerRepository repository, Stream configStream)
+ {
+ XmlConfigurator.Configure(repository, configStream);
+ }
- #endregion Configure static methods
+ #endregion Configure static methods
- #region ConfigureAndWatch static methods
+ #region ConfigureAndWatch static methods
#if (!NETCF && !SSCLI)
- /// <summary>
- /// Configures log4net using the file specified, monitors the file for changes
- /// and reloads the configuration if a change is detected.
- /// </summary>
- /// <param name="configFile">The XML file to load the configuration from.</param>
- /// <remarks>
- /// <para>
- /// <b>DOMConfigurator is obsolete. Use XmlConfigurator instead of DOMConfigurator.</b>
- /// </para>
- /// <para>
- /// The configuration file must be valid XML. It must contain
- /// at least one element called <c>log4net</c> that holds
- /// the configuration data.
- /// </para>
- /// <para>
- /// The configuration file will be monitored using a <see cref="FileSystemWatcher"/>
- /// and depends on the behavior of that class.
- /// </para>
- /// <para>
- /// For more information on how to configure log4net using
- /// a separate configuration file, see <see cref="M:Configure(FileInfo)"/>.
- /// </para>
- /// </remarks>
- /// <seealso cref="M:Configure(FileInfo)"/>
- [Obsolete("Use XmlConfigurator.ConfigureAndWatch instead of DOMConfigurator.ConfigureAndWatch")]
- public static void ConfigureAndWatch(FileInfo configFile)
- {
- XmlConfigurator.ConfigureAndWatch(LogManager.GetRepository(Assembly.GetCallingAssembly()), configFile);
- }
+ /// <summary>
+ /// Configures log4net using the file specified, monitors the file for changes
+ /// and reloads the configuration if a change is detected.
+ /// </summary>
+ /// <param name="configFile">The XML file to load the configuration from.</param>
+ /// <remarks>
+ /// <para>
+ /// <b>DOMConfigurator is obsolete. Use XmlConfigurator instead of DOMConfigurator.</b>
+ /// </para>
+ /// <para>
+ /// The configuration file must be valid XML. It must contain
+ /// at least one element called <c>log4net</c> that holds
+ /// the configuration data.
+ /// </para>
+ /// <para>
+ /// The configuration file will be monitored using a <see cref="FileSystemWatcher"/>
+ /// and depends on the behavior of that class.
+ /// </para>
+ /// <para>
+ /// For more information on how to configure log4net using
+ /// a separate configuration file, see <see cref="M:Configure(FileInfo)"/>.
+ /// </para>
+ /// </remarks>
+ /// <seealso cref="M:Configure(FileInfo)"/>
+ [Obsolete("Use XmlConfigurator.ConfigureAndWatch instead of DOMConfigurator.ConfigureAndWatch")]
+ public static void ConfigureAndWatch(FileInfo configFile)
+ {
+ XmlConfigurator.ConfigureAndWatch(LogManager.GetRepository(Assembly.GetCallingAssembly()), configFile);
+ }
- /// <summary>
- /// Configures the <see cref="ILoggerRepository"/> using the file specified,
- /// monitors the file for changes and reloads the configuration if a change
- /// is detected.
- /// </summary>
- /// <param name="repository">The repository to configure.</param>
- /// <param name="configFile">The XML file to load the configuration from.</param>
- /// <remarks>
- /// <para>
- /// <b>DOMConfigurator is obsolete. Use XmlConfigurator instead of DOMConfigurator.</b>
- /// </para>
- /// <para>
- /// The configuration file must be valid XML. It must contain
- /// at least one element called <c>log4net</c> that holds
- /// the configuration data.
- /// </para>
- /// <para>
- /// The configuration file will be monitored using a <see cref="FileSystemWatcher"/>
- /// and depends on the behavior of that class.
- /// </para>
- /// <para>
- /// For more information on how to configure log4net using
- /// a separate configuration file, see <see cref="M:Configure(FileInfo)"/>.
- /// </para>
- /// </remarks>
- /// <seealso cref="M:Configure(FileInfo)"/>
- [Obsolete("Use XmlConfigurator.ConfigureAndWatch instead of DOMConfigurator.ConfigureAndWatch")]
- public static void ConfigureAndWatch(ILoggerRepository repository, FileInfo configFile)
- {
- XmlConfigurator.ConfigureAndWatch(repository, configFile);
- }
+ /// <summary>
+ /// Configures the <see cref="ILoggerRepository"/> using the file specified,
+ /// monitors the file for changes and reloads the configuration if a change
+ /// is detected.
+ /// </summary>
+ /// <param name="repository">The repository to configure.</param>
+ /// <param name="configFile">The XML file to load the configuration from.</param>
+ /// <remarks>
+ /// <para>
+ /// <b>DOMConfigurator is obsolete. Use XmlConfigurator instead of DOMConfigurator.</b>
+ /// </para>
+ /// <para>
+ /// The configuration file must be valid XML. It must contain
+ /// at least one element called <c>log4net</c> that holds
+ /// the configuration data.
+ /// </para>
+ /// <para>
+ /// The configuration file will be monitored using a <see cref="FileSystemWatcher"/>
+ /// and depends on the behavior of that class.
+ /// </para>
+ /// <para>
+ /// For more information on how to configure log4net using
+ /// a separate configuration file, see <see cref="M:Configure(FileInfo)"/>.
+ /// </para>
+ /// </remarks>
+ /// <seealso cref="M:Configure(FileInfo)"/>
+ [Obsolete("Use XmlConfigurator.ConfigureAndWatch instead of DOMConfigurator.ConfigureAndWatch")]
+ public static void ConfigureAndWatch(ILoggerRepository repository, FileInfo configFile)
+ {
+ XmlConfigurator.ConfigureAndWatch(repository, configFile);
+ }
#endif
- #endregion ConfigureAndWatch static methods
- }
+ #endregion ConfigureAndWatch static methods
+ }
}
#endif // NET_2_0
diff --git a/src/log4net/Config/DOMConfiguratorAttribute.cs b/src/log4net/Config/DOMConfiguratorAttribute.cs
index e996b0e..4a2c2b5 100644
--- a/src/log4net/Config/DOMConfiguratorAttribute.cs
+++ b/src/log4net/Config/DOMConfiguratorAttribute.cs
@@ -30,31 +30,31 @@
namespace log4net.Config
{
- /// <summary>
- /// Assembly level attribute to configure the <see cref="XmlConfigurator"/>.
- /// </summary>
- /// <remarks>
- /// <para>
- /// <b>AliasDomainAttribute is obsolete. Use AliasRepositoryAttribute instead of AliasDomainAttribute.</b>
- /// </para>
- /// <para>
- /// This attribute may only be used at the assembly scope and can only
- /// be used once per assembly.
- /// </para>
- /// <para>
- /// Use this attribute to configure the <see cref="XmlConfigurator"/>
- /// without calling one of the <see cref="M:XmlConfigurator.Configure()"/>
- /// methods.
- /// </para>
- /// </remarks>
- /// <author>Nicko Cadell</author>
- /// <author>Gert Driesen</author>
- [AttributeUsage(AttributeTargets.Assembly)]
- [Serializable]
- [Obsolete("Use XmlConfiguratorAttribute instead of DOMConfiguratorAttribute")]
- public sealed class DOMConfiguratorAttribute : XmlConfiguratorAttribute
- {
- }
+ /// <summary>
+ /// Assembly level attribute to configure the <see cref="XmlConfigurator"/>.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// <b>AliasDomainAttribute is obsolete. Use AliasRepositoryAttribute instead of AliasDomainAttribute.</b>
+ /// </para>
+ /// <para>
+ /// This attribute may only be used at the assembly scope and can only
+ /// be used once per assembly.
+ /// </para>
+ /// <para>
+ /// Use this attribute to configure the <see cref="XmlConfigurator"/>
+ /// without calling one of the <see cref="M:XmlConfigurator.Configure()"/>
+ /// methods.
+ /// </para>
+ /// </remarks>
+ /// <author>Nicko Cadell</author>
+ /// <author>Gert Driesen</author>
+ [AttributeUsage(AttributeTargets.Assembly)]
+ [Serializable]
+ [Obsolete("Use XmlConfiguratorAttribute instead of DOMConfiguratorAttribute")]
+ public sealed class DOMConfiguratorAttribute : XmlConfiguratorAttribute
+ {
+ }
}
#endif // !NETCF
\ No newline at end of file
diff --git a/src/log4net/Config/DomainAttribute.cs b/src/log4net/Config/DomainAttribute.cs
index 8e49ff7..1aeab43 100644
--- a/src/log4net/Config/DomainAttribute.cs
+++ b/src/log4net/Config/DomainAttribute.cs
@@ -24,64 +24,64 @@
namespace log4net.Config
{
- /// <summary>
- /// Assembly level attribute that specifies the logging domain for the assembly.
- /// </summary>
- /// <remarks>
- /// <para>
- /// <b>DomainAttribute is obsolete. Use RepositoryAttribute instead of DomainAttribute.</b>
- /// </para>
- /// <para>
- /// Assemblies are mapped to logging domains. Each domain has its own
- /// logging repository. This attribute specified on the assembly controls
- /// the configuration of the domain. The <see cref="RepositoryAttribute.Name"/> property specifies the name
- /// of the domain that this assembly is a part of. The <see cref="RepositoryAttribute.RepositoryType"/>
- /// specifies the type of the repository objects to create for the domain. If
- /// this attribute is not specified and a <see cref="RepositoryAttribute.Name"/> is not specified
- /// then the assembly will be part of the default shared logging domain.
- /// </para>
- /// <para>
- /// This attribute can only be specified on the assembly and may only be used
- /// once per assembly.
- /// </para>
- /// </remarks>
- /// <author>Nicko Cadell</author>
- /// <author>Gert Driesen</author>
- [AttributeUsage(AttributeTargets.Assembly)]
- [Serializable]
- [Obsolete("Use RepositoryAttribute instead of DomainAttribute")]
- public sealed class DomainAttribute : RepositoryAttribute
- {
- #region Public Instance Constructors
+ /// <summary>
+ /// Assembly level attribute that specifies the logging domain for the assembly.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// <b>DomainAttribute is obsolete. Use RepositoryAttribute instead of DomainAttribute.</b>
+ /// </para>
+ /// <para>
+ /// Assemblies are mapped to logging domains. Each domain has its own
+ /// logging repository. This attribute specified on the assembly controls
+ /// the configuration of the domain. The <see cref="RepositoryAttribute.Name"/> property specifies the name
+ /// of the domain that this assembly is a part of. The <see cref="RepositoryAttribute.RepositoryType"/>
+ /// specifies the type of the repository objects to create for the domain. If
+ /// this attribute is not specified and a <see cref="RepositoryAttribute.Name"/> is not specified
+ /// then the assembly will be part of the default shared logging domain.
+ /// </para>
+ /// <para>
+ /// This attribute can only be specified on the assembly and may only be used
+ /// once per assembly.
+ /// </para>
+ /// </remarks>
+ /// <author>Nicko Cadell</author>
+ /// <author>Gert Driesen</author>
+ [AttributeUsage(AttributeTargets.Assembly)]
+ [Serializable]
+ [Obsolete("Use RepositoryAttribute instead of DomainAttribute")]
+ public sealed class DomainAttribute : RepositoryAttribute
+ {
+ #region Public Instance Constructors
- /// <summary>
- /// Initializes a new instance of the <see cref="DomainAttribute" /> class.
- /// </summary>
- /// <remarks>
- /// <para>
- /// Obsolete. Use RepositoryAttribute instead of DomainAttribute.
- /// </para>
- /// </remarks>
- public DomainAttribute() : base()
- {
- }
+ /// <summary>
+ /// Initializes a new instance of the <see cref="DomainAttribute" /> class.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Obsolete. Use RepositoryAttribute instead of DomainAttribute.
+ /// </para>
+ /// </remarks>
+ public DomainAttribute() : base()
+ {
+ }
- /// <summary>
- /// Initialize a new instance of the <see cref="DomainAttribute" /> class
- /// with the name of the domain.
- /// </summary>
- /// <param name="name">The name of the domain.</param>
- /// <remarks>
- /// <para>
- /// Obsolete. Use RepositoryAttribute instead of DomainAttribute.
- /// </para>
- /// </remarks>
- public DomainAttribute(string name) : base(name)
- {
- }
+ /// <summary>
+ /// Initialize a new instance of the <see cref="DomainAttribute" /> class
+ /// with the name of the domain.
+ /// </summary>
+ /// <param name="name">The name of the domain.</param>
+ /// <remarks>
+ /// <para>
+ /// Obsolete. Use RepositoryAttribute instead of DomainAttribute.
+ /// </para>
+ /// </remarks>
+ public DomainAttribute(string name) : base(name)
+ {
+ }
- #endregion Public Instance Constructors
- }
+ #endregion Public Instance Constructors
+ }
}
#endif // !NETCF
\ No newline at end of file
diff --git a/src/log4net/Config/Log4NetConfigurationSectionHandler.cs b/src/log4net/Config/Log4NetConfigurationSectionHandler.cs
index d5d4723..be34c8c 100644
--- a/src/log4net/Config/Log4NetConfigurationSectionHandler.cs
+++ b/src/log4net/Config/Log4NetConfigurationSectionHandler.cs
@@ -26,68 +26,68 @@
namespace log4net.Config
{
- /// <summary>
- /// Class to register for the log4net section of the configuration file
- /// </summary>
- /// <remarks>
- /// The log4net section of the configuration file needs to have a section
- /// handler registered. This is the section handler used. It simply returns
- /// the XML element that is the root of the section.
- /// </remarks>
- /// <example>
- /// Example of registering the log4net section handler :
- /// <code lang="XML" escaped="true">
- /// <configuration>
- /// <configSections>
- /// <section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" />
- /// </configSections>
- /// <log4net>
- /// log4net configuration XML goes here
- /// </log4net>
- /// </configuration>
- /// </code>
- /// </example>
- /// <author>Nicko Cadell</author>
- /// <author>Gert Driesen</author>
- public class Log4NetConfigurationSectionHandler : IConfigurationSectionHandler
- {
- #region Public Instance Constructors
+ /// <summary>
+ /// Class to register for the log4net section of the configuration file
+ /// </summary>
+ /// <remarks>
+ /// The log4net section of the configuration file needs to have a section
+ /// handler registered. This is the section handler used. It simply returns
+ /// the XML element that is the root of the section.
+ /// </remarks>
+ /// <example>
+ /// Example of registering the log4net section handler :
+ /// <code lang="XML" escaped="true">
+ /// <configuration>
+ /// <configSections>
+ /// <section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" />
+ /// </configSections>
+ /// <log4net>
+ /// log4net configuration XML goes here
+ /// </log4net>
+ /// </configuration>
+ /// </code>
+ /// </example>
+ /// <author>Nicko Cadell</author>
+ /// <author>Gert Driesen</author>
+ public class Log4NetConfigurationSectionHandler : IConfigurationSectionHandler
+ {
+ #region Public Instance Constructors
- /// <summary>
- /// Initializes a new instance of the <see cref="Log4NetConfigurationSectionHandler"/> class.
- /// </summary>
- /// <remarks>
- /// <para>
- /// Default constructor.
- /// </para>
- /// </remarks>
- public Log4NetConfigurationSectionHandler()
- {
- }
+ /// <summary>
+ /// Initializes a new instance of the <see cref="Log4NetConfigurationSectionHandler"/> class.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Default constructor.
+ /// </para>
+ /// </remarks>
+ public Log4NetConfigurationSectionHandler()
+ {
+ }
- #endregion Public Instance Constructors
+ #endregion Public Instance Constructors
- #region Implementation of IConfigurationSectionHandler
+ #region Implementation of IConfigurationSectionHandler
- /// <summary>
- /// Parses the configuration section.
- /// </summary>
- /// <param name="parent">The configuration settings in a corresponding parent configuration section.</param>
- /// <param name="configContext">The configuration context when called from the ASP.NET configuration system. Otherwise, this parameter is reserved and is a null reference.</param>
- /// <param name="section">The <see cref="XmlNode" /> for the log4net section.</param>
- /// <returns>The <see cref="XmlNode" /> for the log4net section.</returns>
- /// <remarks>
- /// <para>
- /// Returns the <see cref="XmlNode"/> containing the configuration data,
- /// </para>
- /// </remarks>
- public object Create(object parent, object configContext, XmlNode section)
- {
- return section;
- }
+ /// <summary>
+ /// Parses the configuration section.
+ /// </summary>
+ /// <param name="parent">The configuration settings in a corresponding parent configuration section.</param>
+ /// <param name="configContext">The configuration context when called from the ASP.NET configuration system. Otherwise, this parameter is reserved and is a null reference.</param>
+ /// <param name="section">The <see cref="XmlNode" /> for the log4net section.</param>
+ /// <returns>The <see cref="XmlNode" /> for the log4net section.</returns>
+ /// <remarks>
+ /// <para>
+ /// Returns the <see cref="XmlNode"/> containing the configuration data,
+ /// </para>
+ /// </remarks>
+ public object Create(object parent, object configContext, XmlNode section)
+ {
+ return section;
+ }
- #endregion Implementation of IConfigurationSectionHandler
- }
+ #endregion Implementation of IConfigurationSectionHandler
+ }
}
#endif // !NETCF
diff --git a/src/log4net/Config/PluginAttribute.cs b/src/log4net/Config/PluginAttribute.cs
index b662972..229dad9 100644
--- a/src/log4net/Config/PluginAttribute.cs
+++ b/src/log4net/Config/PluginAttribute.cs
@@ -30,169 +30,169 @@
namespace log4net.Config
{
- /// <summary>
- /// Assembly level attribute that specifies a plugin to attach to
- /// the repository.
- /// </summary>
- /// <remarks>
- /// <para>
- /// Specifies the type of a plugin to create and attach to the
- /// assembly's repository. The plugin type must implement the
- /// <see cref="IPlugin"/> interface.
- /// </para>
- /// </remarks>
- /// <author>Nicko Cadell</author>
- /// <author>Gert Driesen</author>
- [AttributeUsage(AttributeTargets.Assembly,AllowMultiple=true)]
- [Serializable]
- public sealed class PluginAttribute : Attribute, IPluginFactory
- {
- #region Public Instance Constructors
+ /// <summary>
+ /// Assembly level attribute that specifies a plugin to attach to
+ /// the repository.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Specifies the type of a plugin to create and attach to the
+ /// assembly's repository. The plugin type must implement the
+ /// <see cref="IPlugin"/> interface.
+ /// </para>
+ /// </remarks>
+ /// <author>Nicko Cadell</author>
+ /// <author>Gert Driesen</author>
+ [AttributeUsage(AttributeTargets.Assembly,AllowMultiple=true)]
+ [Serializable]
+ public sealed class PluginAttribute : Attribute, IPluginFactory
+ {
+ #region Public Instance Constructors
#if !NETSTANDARD1_3 // Excluded because GetCallingAssembly() is not available in CoreFX (https://github.com/dotnet/corefx/issues/2221).
- /// <summary>
- /// Initializes a new instance of the <see cref="PluginAttribute" /> class
- /// with the specified type.
- /// </summary>
- /// <param name="typeName">The type name of plugin to create.</param>
- /// <remarks>
- /// <para>
- /// Create the attribute with the plugin type specified.
- /// </para>
- /// <para>
- /// Where possible use the constructor that takes a <see cref="System.Type"/>.
- /// </para>
- /// </remarks>
- public PluginAttribute(string typeName)
- {
- m_typeName = typeName;
- }
+ /// <summary>
+ /// Initializes a new instance of the <see cref="PluginAttribute" /> class
+ /// with the specified type.
+ /// </summary>
+ /// <param name="typeName">The type name of plugin to create.</param>
+ /// <remarks>
+ /// <para>
+ /// Create the attribute with the plugin type specified.
+ /// </para>
+ /// <para>
+ /// Where possible use the constructor that takes a <see cref="System.Type"/>.
+ /// </para>
+ /// </remarks>
+ public PluginAttribute(string typeName)
+ {
+ m_typeName = typeName;
+ }
#endif
- /// <summary>
- /// Initializes a new instance of the <see cref="PluginAttribute" /> class
- /// with the specified type.
- /// </summary>
- /// <param name="type">The type of plugin to create.</param>
- /// <remarks>
- /// <para>
- /// Create the attribute with the plugin type specified.
- /// </para>
- /// </remarks>
- public PluginAttribute(Type type)
- {
- m_type = type;
- }
+ /// <summary>
+ /// Initializes a new instance of the <see cref="PluginAttribute" /> class
+ /// with the specified type.
+ /// </summary>
+ /// <param name="type">The type of plugin to create.</param>
+ /// <remarks>
+ /// <para>
+ /// Create the attribute with the plugin type specified.
+ /// </para>
+ /// </remarks>
+ public PluginAttribute(Type type)
+ {
+ m_type = type;
+ }
- #endregion Public Instance Constructors
+ #endregion Public Instance Constructors
- #region Public Instance Properties
+ #region Public Instance Properties
- /// <summary>
- /// Gets or sets the type for the plugin.
- /// </summary>
- /// <value>
- /// The type for the plugin.
- /// </value>
- /// <remarks>
- /// <para>
- /// The type for the plugin.
- /// </para>
- /// </remarks>
- public Type Type
- {
- get { return m_type; }
- set { m_type = value ; }
- }
+ /// <summary>
+ /// Gets or sets the type for the plugin.
+ /// </summary>
+ /// <value>
+ /// The type for the plugin.
+ /// </value>
+ /// <remarks>
+ /// <para>
+ /// The type for the plugin.
+ /// </para>
+ /// </remarks>
+ public Type Type
+ {
+ get { return m_type; }
+ set { m_type = value ; }
+ }
- /// <summary>
- /// Gets or sets the type name for the plugin.
- /// </summary>
- /// <value>
- /// The type name for the plugin.
- /// </value>
- /// <remarks>
- /// <para>
- /// The type name for the plugin.
- /// </para>
- /// <para>
- /// Where possible use the <see cref="Type"/> property instead.
- /// </para>
- /// </remarks>
- public string TypeName
- {
- get { return m_typeName; }
- set { m_typeName = value ; }
- }
+ /// <summary>
+ /// Gets or sets the type name for the plugin.
+ /// </summary>
+ /// <value>
+ /// The type name for the plugin.
+ /// </value>
+ /// <remarks>
+ /// <para>
+ /// The type name for the plugin.
+ /// </para>
+ /// <para>
+ /// Where possible use the <see cref="Type"/> property instead.
+ /// </para>
+ /// </remarks>
+ public string TypeName
+ {
+ get { return m_typeName; }
+ set { m_typeName = value ; }
+ }
- #endregion Public Instance Properties
+ #endregion Public Instance Properties
- #region Implementation of IPluginFactory
+ #region Implementation of IPluginFactory
- /// <summary>
- /// Creates the plugin object defined by this attribute.
- /// </summary>
- /// <remarks>
- /// <para>
- /// Creates the instance of the <see cref="IPlugin"/> object as
- /// specified by this attribute.
- /// </para>
- /// </remarks>
- /// <returns>The plugin object.</returns>
- public IPlugin CreatePlugin()
- {
- Type pluginType = m_type;
+ /// <summary>
+ /// Creates the plugin object defined by this attribute.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Creates the instance of the <see cref="IPlugin"/> object as
+ /// specified by this attribute.
+ /// </para>
+ /// </remarks>
+ /// <returns>The plugin object.</returns>
+ public IPlugin CreatePlugin()
+ {
+ Type pluginType = m_type;
#if !NETSTANDARD1_3
- if (m_type == null)
- {
- // Get the plugin object type from the string type name
- pluginType = SystemInfo.GetTypeFromString(m_typeName, true, true);
- }
+ if (m_type == null)
+ {
+ // Get the plugin object type from the string type name
+ pluginType = SystemInfo.GetTypeFromString(m_typeName, true, true);
+ }
#endif
- // Check that the type is a plugin
- if (!(typeof(IPlugin).IsAssignableFrom(pluginType)))
- {
- throw new LogException("Plugin type [" + pluginType.FullName + "] does not implement the log4net.IPlugin interface");
- }
+ // Check that the type is a plugin
+ if (!(typeof(IPlugin).IsAssignableFrom(pluginType)))
+ {
+ throw new LogException("Plugin type [" + pluginType.FullName + "] does not implement the log4net.IPlugin interface");
+ }
- // Create an instance of the plugin using the default constructor
- IPlugin plugin = (IPlugin)Activator.CreateInstance(pluginType);
+ // Create an instance of the plugin using the default constructor
+ IPlugin plugin = (IPlugin)Activator.CreateInstance(pluginType);
- return plugin;
- }
+ return plugin;
+ }
- #endregion Implementation of IPluginFactory
+ #endregion Implementation of IPluginFactory
- #region Override implementation of Object
+ #region Override implementation of Object
- /// <summary>
- /// Returns a representation of the properties of this object.
- /// </summary>
- /// <remarks>
- /// <para>
- /// Overrides base class <see cref="M:Object.ToString()" /> method to
- /// return a representation of the properties of this object.
- /// </para>
- /// </remarks>
- /// <returns>A representation of the properties of this object</returns>
- public override string ToString()
- {
- if (m_type != null)
- {
- return "PluginAttribute[Type=" + m_type.FullName + "]";
- }
- return "PluginAttribute[Type=" + m_typeName + "]";
- }
+ /// <summary>
+ /// Returns a representation of the properties of this object.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Overrides base class <see cref="M:Object.ToString()" /> method to
+ /// return a representation of the properties of this object.
+ /// </para>
+ /// </remarks>
+ /// <returns>A representation of the properties of this object</returns>
+ public override string ToString()
+ {
+ if (m_type != null)
+ {
+ return "PluginAttribute[Type=" + m_type.FullName + "]";
+ }
+ return "PluginAttribute[Type=" + m_typeName + "]";
+ }
- #endregion Override implementation of Object
+ #endregion Override implementation of Object
- #region Private Instance Fields
+ #region Private Instance Fields
- private string m_typeName = null;
- private Type m_type = null;
+ private string m_typeName = null;
+ private Type m_type = null;
- #endregion Private Instance Fields
- }
+ #endregion Private Instance Fields
+ }
}
#endif // !NETCF
\ No newline at end of file
diff --git a/src/log4net/Config/RepositoryAttribute.cs b/src/log4net/Config/RepositoryAttribute.cs
index 56dd982..2bacd53 100644
--- a/src/log4net/Config/RepositoryAttribute.cs
+++ b/src/log4net/Config/RepositoryAttribute.cs
@@ -24,121 +24,121 @@
namespace log4net.Config
{
- /// <summary>
- /// Assembly level attribute that specifies the logging repository for the assembly.
- /// </summary>
- /// <remarks>
- /// <para>
- /// Assemblies are mapped to logging repository. This attribute specified
- /// on the assembly controls
- /// the configuration of the repository. The <see cref="Name"/> property specifies the name
- /// of the repository that this assembly is a part of. The <see cref="RepositoryType"/>
- /// specifies the type of the <see cref="log4net.Repository.ILoggerRepository"/> object
- /// to create for the assembly. If this attribute is not specified or a <see cref="Name"/>
- /// is not specified then the assembly will be part of the default shared logging repository.
- /// </para>
- /// <para>
- /// This attribute can only be specified on the assembly and may only be used
- /// once per assembly.
- /// </para>
- /// </remarks>
- /// <author>Nicko Cadell</author>
- /// <author>Gert Driesen</author>
- [AttributeUsage(AttributeTargets.Assembly)]
- [Serializable]
- public /*sealed*/ class RepositoryAttribute : Attribute
- {
- //
- // Class is not sealed because DomainAttribute extends it while it is obsoleted
- //
+ /// <summary>
+ /// Assembly level attribute that specifies the logging repository for the assembly.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Assemblies are mapped to logging repository. This attribute specified
+ /// on the assembly controls
+ /// the configuration of the repository. The <see cref="Name"/> property specifies the name
+ /// of the repository that this assembly is a part of. The <see cref="RepositoryType"/>
+ /// specifies the type of the <see cref="log4net.Repository.ILoggerRepository"/> object
+ /// to create for the assembly. If this attribute is not specified or a <see cref="Name"/>
+ /// is not specified then the assembly will be part of the default shared logging repository.
+ /// </para>
+ /// <para>
+ /// This attribute can only be specified on the assembly and may only be used
+ /// once per assembly.
+ /// </para>
+ /// </remarks>
+ /// <author>Nicko Cadell</author>
+ /// <author>Gert Driesen</author>
+ [AttributeUsage(AttributeTargets.Assembly)]
+ [Serializable]
+ public /*sealed*/ class RepositoryAttribute : Attribute
+ {
+ //
+ // Class is not sealed because DomainAttribute extends it while it is obsoleted
+ //
- #region Public Instance Constructors
+ #region Public Instance Constructors
- /// <summary>
- /// Initializes a new instance of the <see cref="RepositoryAttribute" /> class.
- /// </summary>
- /// <remarks>
- /// <para>
- /// Default constructor.
- /// </para>
- /// </remarks>
- public RepositoryAttribute()
- {
- }
+ /// <summary>
+ /// Initializes a new instance of the <see cref="RepositoryAttribute" /> class.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Default constructor.
+ /// </para>
+ /// </remarks>
+ public RepositoryAttribute()
+ {
+ }
- /// <summary>
- /// Initialize a new instance of the <see cref="RepositoryAttribute" /> class
- /// with the name of the repository.
- /// </summary>
- /// <param name="name">The name of the repository.</param>
- /// <remarks>
- /// <para>
- /// Initialize the attribute with the name for the assembly's repository.
- /// </para>
- /// </remarks>
- public RepositoryAttribute(string name)
- {
- m_name = name;
- }
+ /// <summary>
+ /// Initialize a new instance of the <see cref="RepositoryAttribute" /> class
+ /// with the name of the repository.
+ /// </summary>
+ /// <param name="name">The name of the repository.</param>
+ /// <remarks>
+ /// <para>
+ /// Initialize the attribute with the name for the assembly's repository.
+ /// </para>
+ /// </remarks>
+ public RepositoryAttribute(string name)
+ {
+ m_name = name;
+ }
- #endregion Public Instance Constructors
+ #endregion Public Instance Constructors
- #region Public Instance Properties
+ #region Public Instance Properties
- /// <summary>
- /// Gets or sets the name of the logging repository.
- /// </summary>
- /// <value>
- /// The string name to use as the name of the repository associated with this
- /// assembly.
- /// </value>
- /// <remarks>
- /// <para>
- /// This value does not have to be unique. Several assemblies can share the
- /// same repository. They will share the logging configuration of the repository.
- /// </para>
- /// </remarks>
- public string Name
- {
- get { return m_name; }
- set { m_name = value ; }
- }
+ /// <summary>
+ /// Gets or sets the name of the logging repository.
+ /// </summary>
+ /// <value>
+ /// The string name to use as the name of the repository associated with this
+ /// assembly.
+ /// </value>
+ /// <remarks>
+ /// <para>
+ /// This value does not have to be unique. Several assemblies can share the
+ /// same repository. They will share the logging configuration of the repository.
+ /// </para>
+ /// </remarks>
+ public string Name
+ {
+ get { return m_name; }
+ set { m_name = value ; }
+ }
- /// <summary>
- /// Gets or sets the type of repository to create for this assembly.
- /// </summary>
- /// <value>
- /// The type of repository to create for this assembly.
- /// </value>
- /// <remarks>
- /// <para>
- /// The type of the repository to create for the assembly.
- /// The type must implement the <see cref="log4net.Repository.ILoggerRepository"/>
- /// interface.
- /// </para>
- /// <para>
- /// This will be the type of repository created when
- /// the repository is created. If multiple assemblies reference the
- /// same repository then the repository is only created once using the
- /// <see cref="RepositoryType" /> of the first assembly to call into the
- /// repository.
- /// </para>
- /// </remarks>
- public Type RepositoryType
- {
- get { return m_repositoryType; }
- set { m_repositoryType = value ; }
- }
+ /// <summary>
+ /// Gets or sets the type of repository to create for this assembly.
+ /// </summary>
+ /// <value>
+ /// The type of repository to create for this assembly.
+ /// </value>
+ /// <remarks>
+ /// <para>
+ /// The type of the repository to create for the assembly.
+ /// The type must implement the <see cref="log4net.Repository.ILoggerRepository"/>
+ /// interface.
+ /// </para>
+ /// <para>
+ /// This will be the type of repository created when
+ /// the repository is created. If multiple assemblies reference the
+ /// same repository then the repository is only created once using the
+ /// <see cref="RepositoryType" /> of the first assembly to call into the
+ /// repository.
+ /// </para>
+ /// </remarks>
+ public Type RepositoryType
+ {
+ get { return m_repositoryType; }
+ set { m_repositoryType = value ; }
+ }
- #endregion Public Instance Properties
+ #endregion Public Instance Properties
- #region Private Instance Fields
+ #region Private Instance Fields
- private string m_name = null;
- private Type m_repositoryType = null;
+ private string m_name = null;
+ private Type m_repositoryType = null;
- #endregion Private Instance Fields
- }
+ #endregion Private Instance Fields
+ }
}
#endif // !NETCF
\ No newline at end of file
diff --git a/src/log4net/Config/SecurityContextProviderAttribute.cs b/src/log4net/Config/SecurityContextProviderAttribute.cs
index 7698c1b..c85c15f 100644
--- a/src/log4net/Config/SecurityContextProviderAttribute.cs
+++ b/src/log4net/Config/SecurityContextProviderAttribute.cs
@@ -29,123 +29,123 @@
namespace log4net.Config
{
- /// <summary>
- /// Assembly level attribute to configure the <see cref="SecurityContextProvider"/>.
- /// </summary>
- /// <remarks>
- /// <para>
- /// This attribute may only be used at the assembly scope and can only
- /// be used once per assembly.
- /// </para>
- /// <para>
- /// Use this attribute to configure the <see cref="XmlConfigurator"/>
- /// without calling one of the <see cref="M:XmlConfigurator.Configure()"/>
- /// methods.
- /// </para>
- /// </remarks>
- /// <author>Nicko Cadell</author>
- [AttributeUsage(AttributeTargets.Assembly)]
- [Serializable]
- public sealed class SecurityContextProviderAttribute : ConfiguratorAttribute
- {
- #region Constructor
+ /// <summary>
+ /// Assembly level attribute to configure the <see cref="SecurityContextProvider"/>.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// This attribute may only be used at the assembly scope and can only
+ /// be used once per assembly.
+ /// </para>
+ /// <para>
+ /// Use this attribute to configure the <see cref="XmlConfigurator"/>
+ /// without calling one of the <see cref="M:XmlConfigurator.Configure()"/>
+ /// methods.
+ /// </para>
+ /// </remarks>
+ /// <author>Nicko Cadell</author>
+ [AttributeUsage(AttributeTargets.Assembly)]
+ [Serializable]
+ public sealed class SecurityContextProviderAttribute : ConfiguratorAttribute
+ {
+ #region Constructor
- /// <summary>
- /// Construct provider attribute with type specified
- /// </summary>
- /// <param name="providerType">the type of the provider to use</param>
- /// <remarks>
- /// <para>
- /// The provider specified must subclass the <see cref="SecurityContextProvider"/>
- /// class.
- /// </para>
- /// </remarks>
- public SecurityContextProviderAttribute(Type providerType) : base(100) /* configurator priority 100 to execute before the XmlConfigurator */
- {
- m_providerType = providerType;
- }
+ /// <summary>
+ /// Construct provider attribute with type specified
+ /// </summary>
+ /// <param name="providerType">the type of the provider to use</param>
+ /// <remarks>
+ /// <para>
+ /// The provider specified must subclass the <see cref="SecurityContextProvider"/>
+ /// class.
+ /// </para>
+ /// </remarks>
+ public SecurityContextProviderAttribute(Type providerType) : base(100) /* configurator priority 100 to execute before the XmlConfigurator */
+ {
+ m_providerType = providerType;
+ }
- #endregion
+ #endregion
- #region Public Instance Properties
+ #region Public Instance Properties
- /// <summary>
- /// Gets or sets the type of the provider to use.
- /// </summary>
- /// <value>
- /// the type of the provider to use.
- /// </value>
- /// <remarks>
- /// <para>
- /// The provider specified must subclass the <see cref="SecurityContextProvider"/>
- /// class.
- /// </para>
- /// </remarks>
- public Type ProviderType
- {
- get { return m_providerType; }
- set { m_providerType = value; }
- }
+ /// <summary>
+ /// Gets or sets the type of the provider to use.
+ /// </summary>
+ /// <value>
+ /// the type of the provider to use.
+ /// </value>
+ /// <remarks>
+ /// <para>
+ /// The provider specified must subclass the <see cref="SecurityContextProvider"/>
+ /// class.
+ /// </para>
+ /// </remarks>
+ public Type ProviderType
+ {
+ get { return m_providerType; }
+ set { m_providerType = value; }
+ }
- #endregion Public Instance Properties
+ #endregion Public Instance Properties
- #region Override ConfiguratorAttribute
+ #region Override ConfiguratorAttribute
- /// <summary>
- /// Configures the SecurityContextProvider
- /// </summary>
- /// <param name="sourceAssembly">The assembly that this attribute was defined on.</param>
- /// <param name="targetRepository">The repository to configure.</param>
- /// <remarks>
- /// <para>
- /// Creates a provider instance from the <see cref="ProviderType"/> specified.
- /// Sets this as the default security context provider <see cref="SecurityContextProvider.DefaultProvider"/>.
- /// </para>
- /// </remarks>
- public override void Configure(Assembly sourceAssembly, ILoggerRepository targetRepository)
- {
- if (m_providerType == null)
- {
- LogLog.Error(declaringType, "Attribute specified on assembly ["+sourceAssembly.FullName+"] with null ProviderType.");
- }
- else
- {
- LogLog.Debug(declaringType, "Creating provider of type ["+ m_providerType.FullName +"]");
+ /// <summary>
+ /// Configures the SecurityContextProvider
+ /// </summary>
+ /// <param name="sourceAssembly">The assembly that this attribute was defined on.</param>
+ /// <param name="targetRepository">The repository to configure.</param>
+ /// <remarks>
+ /// <para>
+ /// Creates a provider instance from the <see cref="ProviderType"/> specified.
+ /// Sets this as the default security context provider <see cref="SecurityContextProvider.DefaultProvider"/>.
+ /// </para>
+ /// </remarks>
+ public override void Configure(Assembly sourceAssembly, ILoggerRepository targetRepository)
+ {
+ if (m_providerType == null)
+ {
+ LogLog.Error(declaringType, "Attribute specified on assembly ["+sourceAssembly.FullName+"] with null ProviderType.");
+ }
+ else
+ {
+ LogLog.Debug(declaringType, "Creating provider of type ["+ m_providerType.FullName +"]");
- SecurityContextProvider provider = Activator.CreateInstance(m_providerType) as SecurityContextProvider;
+ SecurityContextProvider provider = Activator.CreateInstance(m_providerType) as SecurityContextProvider;
- if (provider == null)
- {
- LogLog.Error(declaringType, "Failed to create SecurityContextProvider instance of type ["+m_providerType.Name+"].");
- }
- else
- {
- SecurityContextProvider.DefaultProvider = provider;
- }
- }
- }
+ if (provider == null)
+ {
+ LogLog.Error(declaringType, "Failed to create SecurityContextProvider instance of type ["+m_providerType.Name+"].");
+ }
+ else
+ {
+ SecurityContextProvider.DefaultProvider = provider;
+ }
+ }
+ }
- #endregion
+ #endregion
- #region Private Instance Fields
+ #region Private Instance Fields
- private Type m_providerType = null;
+ private Type m_providerType = null;
- #endregion Private Instance Fields
+ #endregion Private Instance Fields
- #region Private Static Fields
+ #region Private Static Fields
- /// <summary>
- /// The fully qualified type of the SecurityContextProviderAttribute class.
- /// </summary>
- /// <remarks>
- /// Used by the internal logger to record the Type of the
- /// log message.
- /// </remarks>
- private static readonly Type declaringType = typeof(SecurityContextProviderAttribute);
+ /// <summary>
+ /// The fully qualified type of the SecurityContextProviderAttribute class.
+ /// </summary>
+ /// <remarks>
+ /// Used by the internal logger to record the Type of the
+ /// log message.
+ /// </remarks>
+ private static readonly Type declaringType = typeof(SecurityContextProviderAttribute);
- #endregion Private Static Fields
- }
+ #endregion Private Static Fields
+ }
}
#endif // !NETCF
\ No newline at end of file
diff --git a/src/log4net/Config/XmlConfigurator.cs b/src/log4net/Config/XmlConfigurator.cs
index ce37d2d..e854e75 100644
--- a/src/log4net/Config/XmlConfigurator.cs
+++ b/src/log4net/Config/XmlConfigurator.cs
@@ -32,1102 +32,1102 @@
namespace log4net.Config
{
- /// <summary>
- /// Use this class to initialize the log4net environment using an Xml tree.
- /// </summary>
- /// <remarks>
- /// <para>
- /// Configures a <see cref="ILoggerRepository"/> using an Xml tree.
- /// </para>
- /// </remarks>
- /// <author>Nicko Cadell</author>
- /// <author>Gert Driesen</author>
- public sealed class XmlConfigurator
- {
- #region Private Instance Constructors
+ /// <summary>
+ /// Use this class to initialize the log4net environment using an Xml tree.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Configures a <see cref="ILoggerRepository"/> using an Xml tree.
+ /// </para>
+ /// </remarks>
+ /// <author>Nicko Cadell</author>
+ /// <author>Gert Driesen</author>
+ public sealed class XmlConfigurator
+ {
+ #region Private Instance Constructors
- /// <summary>
- /// Private constructor
- /// </summary>
- private XmlConfigurator()
- {
- }
+ /// <summary>
+ /// Private constructor
+ /// </summary>
+ private XmlConfigurator()
+ {
+ }
- #endregion Protected Instance Constructors
+ #endregion Protected Instance Constructors
- #region Configure static methods
+ #region Configure static methods
#if !NETCF
- /// <summary>
- /// Automatically configures the <see cref="ILoggerRepository"/> using settings
- /// stored in the application's configuration file.
- /// </summary>
- /// <remarks>
- /// <para>
- /// Each application has a configuration file. This has the
- /// same name as the application with '.config' appended.
- /// This file is XML and calling this function prompts the
- /// configurator to look in that file for a section called
- /// <c>log4net</c> that contains the configuration data.
- /// </para>
- /// <para>
- /// To use this method to configure log4net you must specify
- /// the <see cref="Log4NetConfigurationSectionHandler"/> section
- /// handler for the <c>log4net</c> configuration section. See the
- /// <see cref="Log4NetConfigurationSectionHandler"/> for an example.
- /// </para>
- /// </remarks>
- /// <param name="repository">The repository to configure.</param>
+ /// <summary>
+ /// Automatically configures the <see cref="ILoggerRepository"/> using settings
+ /// stored in the application's configuration file.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Each application has a configuration file. This has the
+ /// same name as the application with '.config' appended.
+ /// This file is XML and calling this function prompts the
+ /// configurator to look in that file for a section called
+ /// <c>log4net</c> that contains the configuration data.
+ /// </para>
+ /// <para>
+ /// To use this method to configure log4net you must specify
+ /// the <see cref="Log4NetConfigurationSectionHandler"/> section
+ /// handler for the <c>log4net</c> configuration section. See the
+ /// <see cref="Log4NetConfigurationSectionHandler"/> for an example.
+ /// </para>
+ /// </remarks>
+ /// <param name="repository">The repository to configure.</param>
#else
- /// <summary>
- /// Automatically configures the <see cref="ILoggerRepository"/> using settings
- /// stored in the application's configuration file.
- /// </summary>
- /// <remarks>
- /// <para>
- /// Each application has a configuration file. This has the
- /// same name as the application with '.config' appended.
- /// This file is XML and calling this function prompts the
- /// configurator to look in that file for a section called
- /// <c>log4net</c> that contains the configuration data.
- /// </para>
- /// </remarks>
- /// <param name="repository">The repository to configure.</param>
+ /// <summary>
+ /// Automatically configures the <see cref="ILoggerRepository"/> using settings
+ /// stored in the application's configuration file.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Each application has a configuration file. This has the
+ /// same name as the application with '.config' appended.
+ /// This file is XML and calling this function prompts the
+ /// configurator to look in that file for a section called
+ /// <c>log4net</c> that contains the configuration data.
+ /// </para>
+ /// </remarks>
+ /// <param name="repository">The repository to configure.</param>
#endif
- public static ICollection Configure(ILoggerRepository repository)
- {
- ArrayList configurationMessages = new ArrayList();
+ public static ICollection Configure(ILoggerRepository repository)
+ {
+ ArrayList configurationMessages = new ArrayList();
- using (new LogLog.LogReceivedAdapter(configurationMessages))
- {
- InternalConfigure(repository);
- }
+ using (new LogLog.LogReceivedAdapter(configurationMessages))
+ {
+ InternalConfigure(repository);
+ }
- repository.ConfigurationMessages = configurationMessages;
+ repository.ConfigurationMessages = configurationMessages;
- return configurationMessages;
- }
+ return configurationMessages;
+ }
- private static void InternalConfigure(ILoggerRepository repository)
- {
- LogLog.Debug(declaringType, "configuring repository [" + repository.Name + "] using .config file section");
+ private static void InternalConfigure(ILoggerRepository repository)
+ {
+ LogLog.Debug(declaringType, "configuring repository [" + repository.Name + "] using .config file section");
- try
- {
- LogLog.Debug(declaringType, "Application config file is [" + SystemInfo.ConfigurationFileLocation + "]");
- }
- catch
- {
- // ignore error
- LogLog.Debug(declaringType, "Application config file location unknown");
- }
+ try
+ {
+ LogLog.Debug(declaringType, "Application config file is [" + SystemInfo.ConfigurationFileLocation + "]");
+ }
+ catch
+ {
+ // ignore error
+ LogLog.Debug(declaringType, "Application config file location unknown");
+ }
#if NETCF || NETSTANDARD1_3
- // No config file reading stuff. Just go straight for the file
- Configure(repository, new FileInfo(SystemInfo.ConfigurationFileLocation));
+ // No config file reading stuff. Just go straight for the file
+ Configure(repository, new FileInfo(SystemInfo.ConfigurationFileLocation));
#else
- try
- {
- XmlElement configElement = System.Configuration.ConfigurationManager.GetSection("log4net") as XmlElement;
- if (configElement == null)
- {
- // Failed to load the xml config using configuration settings handler
- LogLog.Error(declaringType, "Failed to find configuration section 'log4net' in the application's .config file. Check your .config file for the <log4net> and <configSections> elements. The configuration section should look like: <section name=\"log4net\" type=\"log4net.Config.Log4NetConfigurationSectionHandler,log4net\" />");
- }
- else
- {
- // Configure using the xml loaded from the config file
- InternalConfigureFromXml(repository, configElement);
- }
- }
- catch(System.Configuration.ConfigurationException confEx)
- {
- if (confEx.BareMessage.IndexOf("Unrecognized element") >= 0)
- {
- // Looks like the XML file is not valid
- LogLog.Error(declaringType, "Failed to parse config file. Check your .config file is well formed XML.", confEx);
- }
- else
- {
- // This exception is typically due to the assembly name not being correctly specified in the section type.
- string configSectionStr = "<section name=\"log4net\" type=\"log4net.Config.Log4NetConfigurationSectionHandler," + Assembly.GetExecutingAssembly().FullName + "\" />";
- LogLog.Error(declaringType, "Failed to parse config file. Is the <configSections> specified as: " + configSectionStr, confEx);
- }
- }
+ try
+ {
+ XmlElement configElement = System.Configuration.ConfigurationManager.GetSection("log4net") as XmlElement;
+ if (configElement == null)
+ {
+ // Failed to load the xml config using configuration settings handler
+ LogLog.Error(declaringType, "Failed to find configuration section 'log4net' in the application's .config file. Check your .config file for the <log4net> and <configSections> elements. The configuration section should look like: <section name=\"log4net\" type=\"log4net.Config.Log4NetConfigurationSectionHandler,log4net\" />");
+ }
+ else
+ {
+ // Configure using the xml loaded from the config file
+ InternalConfigureFromXml(repository, configElement);
+ }
+ }
+ catch(System.Configuration.ConfigurationException confEx)
+ {
+ if (confEx.BareMessage.IndexOf("Unrecognized element") >= 0)
+ {
+ // Looks like the XML file is not valid
+ LogLog.Error(declaringType, "Failed to parse config file. Check your .config file is well formed XML.", confEx);
+ }
+ else
+ {
+ // This exception is typically due to the assembly name not being correctly specified in the section type.
+ string configSectionStr = "<section name=\"log4net\" type=\"log4net.Config.Log4NetConfigurationSectionHandler," + Assembly.GetExecutingAssembly().FullName + "\" />";
+ LogLog.Error(declaringType, "Failed to parse config file. Is the <configSections> specified as: " + configSectionStr, confEx);
+ }
+ }
#endif
- }
+ }
#if !NETSTANDARD1_3 // Excluded because GetCallingAssembly() is not available in CoreFX (https://github.com/dotnet/corefx/issues/2221).
#if !NETCF
- /// <summary>
- /// Automatically configures the log4net system based on the
- /// application's configuration settings.
- /// </summary>
- /// <remarks>
- /// <para>
- /// Each application has a configuration file. This has the
- /// same name as the application with '.config' appended.
- /// This file is XML and calling this function prompts the
- /// configurator to look in that file for a section called
- /// <c>log4net</c> that contains the configuration data.
- /// </para>
- /// <para>
- /// To use this method to configure log4net you must specify
- /// the <see cref="Log4NetConfigurationSectionHandler"/> section
- /// handler for the <c>log4net</c> configuration section. See the
- /// <see cref="Log4NetConfigurationSectionHandler"/> for an example.
- /// </para>
- /// </remarks>
- /// <seealso cref="Log4NetConfigurationSectionHandler"/>
+ /// <summary>
+ /// Automatically configures the log4net system based on the
+ /// application's configuration settings.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Each application has a configuration file. This has the
+ /// same name as the application with '.config' appended.
+ /// This file is XML and calling this function prompts the
+ /// configurator to look in that file for a section called
+ /// <c>log4net</c> that contains the configuration data.
+ /// </para>
+ /// <para>
+ /// To use this method to configure log4net you must specify
+ /// the <see cref="Log4NetConfigurationSectionHandler"/> section
+ /// handler for the <c>log4net</c> configuration section. See the
+ /// <see cref="Log4NetConfigurationSectionHandler"/> for an example.
+ /// </para>
+ /// </remarks>
+ /// <seealso cref="Log4NetConfigurationSectionHandler"/>
#else
- /// <summary>
- /// Automatically configures the log4net system based on the
- /// application's configuration settings.
- /// </summary>
- /// <remarks>
- /// <para>
- /// Each application has a configuration file. This has the
- /// same name as the application with '.config' appended.
- /// This file is XML and calling this function prompts the
- /// configurator to look in that file for a section called
- /// <c>log4net</c> that contains the configuration data.
- /// </para>
- /// </remarks>
+ /// <summary>
+ /// Automatically configures the log4net system based on the
+ /// application's configuration settings.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Each application has a configuration file. This has the
+ /// same name as the application with '.config' appended.
+ /// This file is XML and calling this function prompts the
+ /// configurator to look in that file for a section called
+ /// <c>log4net</c> that contains the configuration data.
+ /// </para>
+ /// </remarks>
#endif
- public static ICollection Configure()
- {
- return Configure(LogManager.GetRepository(Assembly.GetCallingAssembly()));
- }
+ public static ICollection Configure()
+ {
+ return Configure(LogManager.GetRepository(Assembly.GetCallingAssembly()));
+ }
- /// <summary>
- /// Configures log4net using a <c>log4net</c> element
- /// </summary>
- /// <remarks>
- /// <para>
- /// Loads the log4net configuration from the XML element
- /// supplied as <paramref name="element"/>.
- /// </para>
- /// </remarks>
- /// <param name="element">The element to parse.</param>
- public static ICollection Configure(XmlElement element)
- {
- ArrayList configurationMessages = new ArrayList();
+ /// <summary>
+ /// Configures log4net using a <c>log4net</c> element
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Loads the log4net configuration from the XML element
+ /// supplied as <paramref name="element"/>.
+ /// </para>
+ /// </remarks>
+ /// <param name="element">The element to parse.</param>
+ public static ICollection Configure(XmlElement element)
+ {
+ ArrayList configurationMessages = new ArrayList();
- ILoggerRepository repository = LogManager.GetRepository(Assembly.GetCallingAssembly());
+ ILoggerRepository repository = LogManager.GetRepository(Assembly.GetCallingAssembly());
- using (new LogLog.LogReceivedAdapter(configurationMessages))
- {
- InternalConfigureFromXml(repository, element);
- }
+ using (new LogLog.LogReceivedAdapter(configurationMessages))
+ {
+ InternalConfigureFromXml(repository, element);
+ }
- repository.ConfigurationMessages = configurationMessages;
+ repository.ConfigurationMessages = configurationMessages;
- return configurationMessages;
- }
+ return configurationMessages;
+ }
#if !NETCF
- /// <summary>
- /// Configures log4net using the specified configuration file.
- /// </summary>
- /// <param name="configFile">The XML file to load the configuration from.</param>
- /// <remarks>
- /// <para>
- /// The configuration file must be valid XML. It must contain
- /// at least one element called <c>log4net</c> that holds
- /// the log4net configuration data.
- /// </para>
- /// <para>
- /// The log4net configuration file can possible be specified in the application's
- /// configuration file (either <c>MyAppName.exe.config</c> for a
- /// normal application on <c>Web.config</c> for an ASP.NET application).
- /// </para>
- /// <para>
- /// The first element matching <c><configuration></c> will be read as the
- /// configuration. If this file is also a .NET .config file then you must specify
- /// a configuration section for the <c>log4net</c> element otherwise .NET will
- /// complain. Set the type for the section handler to <see cref="System.Configuration.IgnoreSectionHandler"/>, for example:
- /// <code lang="XML" escaped="true">
- /// <configSections>
- /// <section name="log4net" type="System.Configuration.IgnoreSectionHandler" />
- /// </configSections>
- /// </code>
- /// </para>
- /// <example>
- /// The following example configures log4net using a configuration file, of which the
- /// location is stored in the application's configuration file :
- /// </example>
- /// <code lang="C#">
- /// using log4net.Config;
- /// using System.IO;
- /// using System.Configuration;
- ///
- /// ...
- ///
- /// XmlConfigurator.Configure(new FileInfo(ConfigurationSettings.AppSettings["log4net-config-file"]));
- /// </code>
- /// <para>
- /// In the <c>.config</c> file, the path to the log4net can be specified like this :
- /// </para>
- /// <code lang="XML" escaped="true">
- /// <configuration>
- /// <appSettings>
- /// <add key="log4net-config-file" value="log.config"/>
- /// </appSettings>
- /// </configuration>
- /// </code>
- /// </remarks>
+ /// <summary>
+ /// Configures log4net using the specified configuration file.
+ /// </summary>
+ /// <param name="configFile">The XML file to load the configuration from.</param>
+ /// <remarks>
+ /// <para>
+ /// The configuration file must be valid XML. It must contain
+ /// at least one element called <c>log4net</c> that holds
+ /// the log4net configuration data.
+ /// </para>
+ /// <para>
+ /// The log4net configuration file can possible be specified in the application's
+ /// configuration file (either <c>MyAppName.exe.config</c> for a
+ /// normal application on <c>Web.config</c> for an ASP.NET application).
+ /// </para>
+ /// <para>
+ /// The first element matching <c><configuration></c> will be read as the
+ /// configuration. If this file is also a .NET .config file then you must specify
+ /// a configuration section for the <c>log4net</c> element otherwise .NET will
+ /// complain. Set the type for the section handler to <see cref="System.Configuration.IgnoreSectionHandler"/>, for example:
+ /// <code lang="XML" escaped="true">
+ /// <configSections>
+ /// <section name="log4net" type="System.Configuration.IgnoreSectionHandler" />
+ /// </configSections>
+ /// </code>
+ /// </para>
+ /// <example>
+ /// The following example configures log4net using a configuration file, of which the
+ /// location is stored in the application's configuration file :
+ /// </example>
+ /// <code lang="C#">
+ /// using log4net.Config;
+ /// using System.IO;
+ /// using System.Configuration;
+ ///
+ /// ...
+ ///
+ /// XmlConfigurator.Configure(new FileInfo(ConfigurationSettings.AppSettings["log4net-config-file"]));
+ /// </code>
+ /// <para>
+ /// In the <c>.config</c> file, the path to the log4net can be specified like this :
+ /// </para>
+ /// <code lang="XML" escaped="true">
+ /// <configuration>
+ /// <appSettings>
+ /// <add key="log4net-config-file" value="log.config"/>
+ /// </appSettings>
+ /// </configuration>
+ /// </code>
+ /// </remarks>
#else
- /// <summary>
- /// Configures log4net using the specified configuration file.
- /// </summary>
- /// <param name="configFile">The XML file to load the configuration from.</param>
- /// <remarks>
- /// <para>
- /// The configuration file must be valid XML. It must contain
- /// at least one element called <c>log4net</c> that holds
- /// the log4net configuration data.
- /// </para>
- /// <example>
- /// The following example configures log4net using a configuration file, of which the
- /// location is stored in the application's configuration file :
- /// </example>
- /// <code lang="C#">
- /// using log4net.Config;
- /// using System.IO;
- /// using System.Configuration;
- ///
- /// ...
- ///
- /// XmlConfigurator.Configure(new FileInfo(ConfigurationSettings.AppSettings["log4net-config-file"]));
- /// </code>
- /// <para>
- /// In the <c>.config</c> file, the path to the log4net can be specified like this :
- /// </para>
- /// <code lang="XML" escaped="true">
- /// <configuration>
- /// <appSettings>
- /// <add key="log4net-config-file" value="log.config"/>
- /// </appSettings>
- /// </configuration>
- /// </code>
- /// </remarks>
+ /// <summary>
+ /// Configures log4net using the specified configuration file.
+ /// </summary>
+ /// <param name="configFile">The XML file to load the configuration from.</param>
+ /// <remarks>
+ /// <para>
+ /// The configuration file must be valid XML. It must contain
+ /// at least one element called <c>log4net</c> that holds
+ /// the log4net configuration data.
+ /// </para>
+ /// <example>
+ /// The following example configures log4net using a configuration file, of which the
+ /// location is stored in the application's configuration file :
+ /// </example>
+ /// <code lang="C#">
+ /// using log4net.Config;
+ /// using System.IO;
+ /// using System.Configuration;
+ ///
+ /// ...
+ ///
+ /// XmlConfigurator.Configure(new FileInfo(ConfigurationSettings.AppSettings["log4net-config-file"]));
+ /// </code>
+ /// <para>
+ /// In the <c>.config</c> file, the path to the log4net can be specified like this :
+ /// </para>
+ /// <code lang="XML" escaped="true">
+ /// <configuration>
+ /// <appSettings>
+ /// <add key="log4net-config-file" value="log.config"/>
+ /// </appSettings>
+ /// </configuration>
+ /// </code>
+ /// </remarks>
#endif
- public static ICollection Configure(FileInfo configFile)
- {
- ArrayList configurationMessages = new ArrayList();
+ public static ICollection Configure(FileInfo configFile)
+ {
+ ArrayList configurationMessages = new ArrayList();
- using (new LogLog.LogReceivedAdapter(configurationMessages))
- {
- InternalConfigure(LogManager.GetRepository(Assembly.GetCallingAssembly()), configFile);
- }
+ using (new LogLog.LogReceivedAdapter(configurationMessages))
+ {
+ InternalConfigure(LogManager.GetRepository(Assembly.GetCallingAssembly()), configFile);
+ }
- return configurationMessages;
- }
+ return configurationMessages;
+ }
- /// <summary>
- /// Configures log4net using the specified configuration URI.
- /// </summary>
- /// <param name="configUri">A URI to load the XML configuration from.</param>
- /// <remarks>
- /// <para>
- /// The configuration data must be valid XML. It must contain
- /// at least one element called <c>log4net</c> that holds
- /// the log4net configuration data.
- /// </para>
- /// <para>
- /// The <see cref="System.Net.WebRequest"/> must support the URI scheme specified.
- /// </para>
- /// </remarks>
- public static ICollection Configure(Uri configUri)
- {
- ArrayList configurationMessages = new ArrayList();
+ /// <summary>
+ /// Configures log4net using the specified configuration URI.
+ /// </summary>
+ /// <param name="configUri">A URI to load the XML configuration from.</param>
+ /// <remarks>
+ /// <para>
+ /// The configuration data must be valid XML. It must contain
+ /// at least one element called <c>log4net</c> that holds
+ /// the log4net configuration data.
+ /// </para>
+ /// <para>
+ /// The <see cref="System.Net.WebRequest"/> must support the URI scheme specified.
+ /// </para>
+ /// </remarks>
+ public static ICollection Configure(Uri configUri)
+ {
+ ArrayList configurationMessages = new ArrayList();
- ILoggerRepository repository = LogManager.GetRepository(Assembly.GetCallingAssembly());
- using (new LogLog.LogReceivedAdapter(configurationMessages))
- {
- InternalConfigure(repository, configUri);
- }
+ ILoggerRepository repository = LogManager.GetRepository(Assembly.GetCallingAssembly());
+ using (new LogLog.LogReceivedAdapter(configurationMessages))
+ {
+ InternalConfigure(repository, configUri);
+ }
- repository.ConfigurationMessages = configurationMessages;
+ repository.ConfigurationMessages = configurationMessages;
- return configurationMessages;
- }
+ return configurationMessages;
+ }
- /// <summary>
- /// Configures log4net using the specified configuration data stream.
- /// </summary>
- /// <param name="configStream">A stream to load the XML configuration from.</param>
- /// <remarks>
- /// <para>
- /// The configuration data must be valid XML. It must contain
- /// at least one element called <c>log4net</c> that holds
- /// the log4net configuration data.
- /// </para>
- /// <para>
- /// Note that this method will NOT close the stream parameter.
- /// </para>
- /// </remarks>
- public static ICollection Configure(Stream configStream)
- {
- ArrayList configurationMessages = new ArrayList();
+ /// <summary>
+ /// Configures log4net using the specified configuration data stream.
+ /// </summary>
+ /// <param name="configStream">A stream to load the XML configuration from.</param>
+ /// <remarks>
+ /// <para>
+ /// The configuration data must be valid XML. It must contain
+ /// at least one element called <c>log4net</c> that holds
+ /// the log4net configuration data.
+ /// </para>
+ /// <para>
+ /// Note that this method will NOT close the stream parameter.
+ /// </para>
+ /// </remarks>
+ public static ICollection Configure(Stream configStream)
+ {
+ ArrayList configurationMessages = new ArrayList();
- ILoggerRepository repository = LogManager.GetRepository(Assembly.GetCallingAssembly());
- using (new LogLog.LogReceivedAdapter(configurationMessages))
- {
- InternalConfigure(repository, configStream);
- }
+ ILoggerRepository repository = LogManager.GetRepository(Assembly.GetCallingAssembly());
+ using (new LogLog.LogReceivedAdapter(configurationMessages))
+ {
+ InternalConfigure(repository, configStream);
+ }
- repository.ConfigurationMessages = configurationMessages;
+ repository.ConfigurationMessages = configurationMessages;
- return configurationMessages;
- }
+ return configurationMessages;
+ }
#endif // !NETSTANDARD1_3
- /// <summary>
- /// Configures the <see cref="ILoggerRepository"/> using the specified XML
- /// element.
- /// </summary>
- /// <remarks>
- /// Loads the log4net configuration from the XML element
- /// supplied as <paramref name="element"/>.
- /// </remarks>
- /// <param name="repository">The repository to configure.</param>
- /// <param name="element">The element to parse.</param>
- public static ICollection Configure(ILoggerRepository repository, XmlElement element)
- {
- ArrayList configurationMessages = new ArrayList();
+ /// <summary>
+ /// Configures the <see cref="ILoggerRepository"/> using the specified XML
+ /// element.
+ /// </summary>
+ /// <remarks>
+ /// Loads the log4net configuration from the XML element
+ /// supplied as <paramref name="element"/>.
+ /// </remarks>
+ /// <param name="repository">The repository to configure.</param>
+ /// <param name="element">The element to parse.</param>
+ public static ICollection Configure(ILoggerRepository repository, XmlElement element)
+ {
+ ArrayList configurationMessages = new ArrayList();
- using (new LogLog.LogReceivedAdapter(configurationMessages))
- {
- LogLog.Debug(declaringType, "configuring repository [" + repository.Name + "] using XML element");
+ using (new LogLog.LogReceivedAdapter(configurationMessages))
+ {
+ LogLog.Debug(declaringType, "configuring repository [" + repository.Name + "] using XML element");
- InternalConfigureFromXml(repository, element);
- }
+ InternalConfigureFromXml(repository, element);
+ }
- repository.ConfigurationMessages = configurationMessages;
+ repository.ConfigurationMessages = configurationMessages;
- return configurationMessages;
- }
+ return configurationMessages;
+ }
#if !NETCF
- /// <summary>
- /// Configures the <see cref="ILoggerRepository"/> using the specified configuration
- /// file.
- /// </summary>
- /// <param name="repository">The repository to configure.</param>
- /// <param name="configFile">The XML file to load the configuration from.</param>
- /// <remarks>
- /// <para>
- /// The configuration file must be valid XML. It must contain
- /// at least one element called <c>log4net</c> that holds
- /// the configuration data.
- /// </para>
- /// <para>
- /// The log4net configuration file can possible be specified in the application's
- /// configuration file (either <c>MyAppName.exe.config</c> for a
- /// normal application on <c>Web.config</c> for an ASP.NET application).
- /// </para>
- /// <para>
- /// The first element matching <c><configuration></c> will be read as the
- /// configuration. If this file is also a .NET .config file then you must specify
- /// a configuration section for the <c>log4net</c> element otherwise .NET will
- /// complain. Set the type for the section handler to <see cref="System.Configuration.IgnoreSectionHandler"/>, for example:
- /// <code lang="XML" escaped="true">
- /// <configSections>
- /// <section name="log4net" type="System.Configuration.IgnoreSectionHandler" />
- /// </configSections>
- /// </code>
- /// </para>
- /// <example>
- /// The following example configures log4net using a configuration file, of which the
- /// location is stored in the application's configuration file :
- /// </example>
- /// <code lang="C#">
- /// using log4net.Config;
- /// using System.IO;
- /// using System.Configuration;
- ///
- /// ...
- ///
- /// XmlConfigurator.Configure(new FileInfo(ConfigurationSettings.AppSettings["log4net-config-file"]));
- /// </code>
- /// <para>
- /// In the <c>.config</c> file, the path to the log4net can be specified like this :
- /// </para>
- /// <code lang="XML" escaped="true">
- /// <configuration>
- /// <appSettings>
- /// <add key="log4net-config-file" value="log.config"/>
- /// </appSettings>
- /// </configuration>
- /// </code>
- /// </remarks>
+ /// <summary>
+ /// Configures the <see cref="ILoggerRepository"/> using the specified configuration
+ /// file.
+ /// </summary>
+ /// <param name="repository">The repository to configure.</param>
+ /// <param name="configFile">The XML file to load the configuration from.</param>
+ /// <remarks>
+ /// <para>
+ /// The configuration file must be valid XML. It must contain
+ /// at least one element called <c>log4net</c> that holds
+ /// the configuration data.
+ /// </para>
+ /// <para>
+ /// The log4net configuration file can possible be specified in the application's
+ /// configuration file (either <c>MyAppName.exe.config</c> for a
+ /// normal application on <c>Web.config</c> for an ASP.NET application).
+ /// </para>
+ /// <para>
+ /// The first element matching <c><configuration></c> will be read as the
+ /// configuration. If this file is also a .NET .config file then you must specify
+ /// a configuration section for the <c>log4net</c> element otherwise .NET will
+ /// complain. Set the type for the section handler to <see cref="System.Configuration.IgnoreSectionHandler"/>, for example:
+ /// <code lang="XML" escaped="true">
+ /// <configSections>
+ /// <section name="log4net" type="System.Configuration.IgnoreSectionHandler" />
+ /// </configSections>
+ /// </code>
+ /// </para>
+ /// <example>
+ /// The following example configures log4net using a configuration file, of which the
+ /// location is stored in the application's configuration file :
+ /// </example>
+ /// <code lang="C#">
+ /// using log4net.Config;
+ /// using System.IO;
+ /// using System.Configuration;
+ ///
+ /// ...
+ ///
+ /// XmlConfigurator.Configure(new FileInfo(ConfigurationSettings.AppSettings["log4net-config-file"]));
+ /// </code>
+ /// <para>
+ /// In the <c>.config</c> file, the path to the log4net can be specified like this :
+ /// </para>
+ /// <code lang="XML" escaped="true">
+ /// <configuration>
+ /// <appSettings>
+ /// <add key="log4net-config-file" value="log.config"/>
+ /// </appSettings>
+ /// </configuration>
+ /// </code>
+ /// </remarks>
#else
- /// <summary>
- /// Configures the <see cref="ILoggerRepository"/> using the specified configuration
- /// file.
- /// </summary>
- /// <param name="repository">The repository to configure.</param>
- /// <param name="configFile">The XML file to load the configuration from.</param>
- /// <remarks>
- /// <para>
- /// The configuration file must be valid XML. It must contain
- /// at least one element called <c>log4net</c> that holds
- /// the configuration data.
- /// </para>
- /// <example>
- /// The following example configures log4net using a configuration file, of which the
- /// location is stored in the application's configuration file :
- /// </example>
- /// <code lang="C#">
- /// using log4net.Config;
- /// using System.IO;
- /// using System.Configuration;
- ///
- /// ...
- ///
- /// XmlConfigurator.Configure(new FileInfo(ConfigurationSettings.AppSettings["log4net-config-file"]));
- /// </code>
- /// <para>
- /// In the <c>.config</c> file, the path to the log4net can be specified like this :
- /// </para>
- /// <code lang="XML" escaped="true">
- /// <configuration>
- /// <appSettings>
- /// <add key="log4net-config-file" value="log.config"/>
- /// </appSettings>
- /// </configuration>
- /// </code>
- /// </remarks>
+ /// <summary>
+ /// Configures the <see cref="ILoggerRepository"/> using the specified configuration
+ /// file.
+ /// </summary>
+ /// <param name="repository">The repository to configure.</param>
+ /// <param name="configFile">The XML file to load the configuration from.</param>
+ /// <remarks>
+ /// <para>
+ /// The configuration file must be valid XML. It must contain
+ /// at least one element called <c>log4net</c> that holds
+ /// the configuration data.
+ /// </para>
+ /// <example>
+ /// The following example configures log4net using a configuration file, of which the
+ /// location is stored in the application's configuration file :
+ /// </example>
+ /// <code lang="C#">
+ /// using log4net.Config;
+ /// using System.IO;
+ /// using System.Configuration;
+ ///
+ /// ...
+ ///
+ /// XmlConfigurator.Configure(new FileInfo(ConfigurationSettings.AppSettings["log4net-config-file"]));
+ /// </code>
+ /// <para>
+ /// In the <c>.config</c> file, the path to the log4net can be specified like this :
+ /// </para>
+ /// <code lang="XML" escaped="true">
+ /// <configuration>
+ /// <appSettings>
+ /// <add key="log4net-config-file" value="log.config"/>
+ /// </appSettings>
+ /// </configuration>
+ /// </code>
+ /// </remarks>
#endif
- public static ICollection Configure(ILoggerRepository repository, FileInfo configFile)
- {
- ArrayList configurationMessages = new ArrayList();
+ public static ICollection Configure(ILoggerRepository repository, FileInfo configFile)
+ {
+ ArrayList configurationMessages = new ArrayList();
- using (new LogLog.LogReceivedAdapter(configurationMessages))
- {
- InternalConfigure(repository, configFile);
- }
+ using (new LogLog.LogReceivedAdapter(configurationMessages))
+ {
+ InternalConfigure(repository, configFile);
+ }
- repository.ConfigurationMessages = configurationMessages;
+ repository.ConfigurationMessages = configurationMessages;
- return configurationMessages;
- }
+ return configurationMessages;
+ }
- private static void InternalConfigure(ILoggerRepository repository, FileInfo configFile)
- {
- LogLog.Debug(declaringType, "configuring repository [" + repository.Name + "] using file [" + configFile + "]");
+ private static void InternalConfigure(ILoggerRepository repository, FileInfo configFile)
+ {
+ LogLog.Debug(declaringType, "configuring repository [" + repository.Name + "] using file [" + configFile + "]");
- if (configFile == null)
- {
- LogLog.Error(declaringType, "Configure called with null 'configFile' parameter");
- }
- else
- {
- // Have to use File.Exists() rather than configFile.Exists()
- // because configFile.Exists() caches the value, not what we want.
- if (File.Exists(configFile.FullName))
- {
- // Open the file for reading
- FileStream fs = null;
+ if (configFile == null)
+ {
+ LogLog.Error(declaringType, "Configure called with null 'configFile' parameter");
+ }
+ else
+ {
+ // Have to use File.Exists() rather than configFile.Exists()
+ // because configFile.Exists() caches the value, not what we want.
+ if (File.Exists(configFile.FullName))
+ {
+ // Open the file for reading
+ FileStream fs = null;
- // Try hard to open the file
- for(int retry = 5; --retry >= 0; )
- {
- try
- {
- fs = configFile.Open(FileMode.Open, FileAccess.Read, FileShare.Read);
- break;
- }
- catch(IOException ex)
- {
- if (retry == 0)
- {
- LogLog.Error(declaringType, "Failed to open XML config file [" + configFile.Name + "]", ex);
+ // Try hard to open the file
+ for(int retry = 5; --retry >= 0; )
+ {
+ try
+ {
+ fs = configFile.Open(FileMode.Open, FileAccess.Read, FileShare.Read);
+ break;
+ }
+ catch(IOException ex)
+ {
+ if (retry == 0)
+ {
+ LogLog.Error(declaringType, "Failed to open XML config file [" + configFile.Name + "]", ex);
- // The stream cannot be valid
- fs = null;
- }
- System.Threading.Thread.Sleep(250);
- }
- }
+ // The stream cannot be valid
+ fs = null;
+ }
+ System.Threading.Thread.Sleep(250);
+ }
+ }
- if (fs != null)
- {
- try
- {
- // Load the configuration from the stream
- InternalConfigure(repository, fs);
- }
- finally
- {
- // Force the file closed whatever happens
- fs.Dispose();
- }
- }
- }
- else
- {
- LogLog.Debug(declaringType, "config file [" + configFile.FullName + "] not found. Configuration unchanged.");
- }
- }
- }
+ if (fs != null)
+ {
+ try
+ {
+ // Load the configuration from the stream
+ InternalConfigure(repository, fs);
+ }
+ finally
+ {
+ // Force the file closed whatever happens
+ fs.Dispose();
+ }
+ }
+ }
+ else
+ {
+ LogLog.Debug(declaringType, "config file [" + configFile.FullName + "] not found. Configuration unchanged.");
+ }
+ }
+ }
- /// <summary>
- /// Configures the <see cref="ILoggerRepository"/> using the specified configuration
- /// URI.
- /// </summary>
- /// <param name="repository">The repository to configure.</param>
- /// <param name="configUri">A URI to load the XML configuration from.</param>
- /// <remarks>
- /// <para>
- /// The configuration data must be valid XML. It must contain
- /// at least one element called <c>log4net</c> that holds
- /// the configuration data.
- /// </para>
- /// <para>
- /// The <see cref="System.Net.WebRequest"/> must support the URI scheme specified.
- /// </para>
- /// </remarks>
- public static ICollection Configure(ILoggerRepository repository, Uri configUri)
- {
- ArrayList configurationMessages = new ArrayList();
+ /// <summary>
+ /// Configures the <see cref="ILoggerRepository"/> using the specified configuration
+ /// URI.
+ /// </summary>
+ /// <param name="repository">The repository to configure.</param>
+ /// <param name="configUri">A URI to load the XML configuration from.</param>
+ /// <remarks>
+ /// <para>
+ /// The configuration data must be valid XML. It must contain
+ /// at least one element called <c>log4net</c> that holds
+ /// the configuration data.
+ /// </para>
+ /// <para>
+ /// The <see cref="System.Net.WebRequest"/> must support the URI scheme specified.
+ /// </para>
+ /// </remarks>
+ public static ICollection Configure(ILoggerRepository repository, Uri configUri)
+ {
+ ArrayList configurationMessages = new ArrayList();
- using (new LogLog.LogReceivedAdapter(configurationMessages))
- {
- InternalConfigure(repository, configUri);
- }
+ using (new LogLog.LogReceivedAdapter(configurationMessages))
+ {
+ InternalConfigure(repository, configUri);
+ }
- repository.ConfigurationMessages = configurationMessages;
+ repository.ConfigurationMessages = configurationMessages;
- return configurationMessages;
- }
+ return configurationMessages;
+ }
- private static void InternalConfigure(ILoggerRepository repository, Uri configUri)
- {
- LogLog.Debug(declaringType, "configuring repository [" + repository.Name + "] using URI ["+configUri+"]");
+ private static void InternalConfigure(ILoggerRepository repository, Uri configUri)
+ {
+ LogLog.Debug(declaringType, "configuring repository [" + repository.Name + "] using URI ["+configUri+"]");
- if (configUri == null)
- {
- LogLog.Error(declaringType, "Configure called with null 'configUri' parameter");
- }
- else
- {
- if (configUri.IsFile)
- {
- // If URI is local file then call Configure with FileInfo
- InternalConfigure(repository, new FileInfo(configUri.LocalPath));
- }
- else
- {
- // NETCF dose not support WebClient
- WebRequest configRequest = null;
+ if (configUri == null)
+ {
+ LogLog.Error(declaringType, "Configure called with null 'configUri' parameter");
+ }
+ else
+ {
+ if (configUri.IsFile)
+ {
+ // If URI is local file then call Configure with FileInfo
+ InternalConfigure(repository, new FileInfo(configUri.LocalPath));
+ }
+ else
+ {
+ // NETCF dose not support WebClient
+ WebRequest configRequest = null;
- try
- {
- configRequest = WebRequest.Create(configUri);
- }
- catch(Exception ex)
- {
- LogLog.Error(declaringType, "Failed to create WebRequest for URI ["+configUri+"]", ex);
- }
+ try
+ {
+ configRequest = WebRequest.Create(configUri);
+ }
+ catch(Exception ex)
+ {
+ LogLog.Error(declaringType, "Failed to create WebRequest for URI ["+configUri+"]", ex);
+ }
- if (configRequest != null)
- {
+ if (configRequest != null)
+ {
#if !NETCF_1_0
- // authentication may be required, set client to use default credentials
- try
- {
- configRequest.Credentials = CredentialCache.DefaultCredentials;
- }
- catch
- {
- // ignore security exception
- }
+ // authentication may be required, set client to use default credentials
+ try
+ {
+ configRequest.Credentials = CredentialCache.DefaultCredentials;
+ }
+ catch
+ {
+ // ignore security exception
+ }
#endif
- try
- {
+ try
+ {
#if NETSTANDARD
- using WebResponse response = configRequest.GetResponseAsync().GetAwaiter().GetResult();
+ using WebResponse response = configRequest.GetResponseAsync().GetAwaiter().GetResult();
#else
- using WebResponse response = configRequest.GetResponse();
+ using WebResponse response = configRequest.GetResponse();
#endif
- if (response != null)
- {
- using var configStream = response.GetResponseStream();
- InternalConfigure(repository, configStream);
- }
- }
- catch(Exception ex)
- {
- LogLog.Error(declaringType, "Failed to request config from URI ["+configUri+"]", ex);
- }
- }
- }
- }
- }
+ if (response != null)
+ {
+ using var configStream = response.GetResponseStream();
+ InternalConfigure(repository, configStream);
+ }
+ }
+ catch(Exception ex)
+ {
+ LogLog.Error(declaringType, "Failed to request config from URI ["+configUri+"]", ex);
+ }
+ }
+ }
+ }
+ }
- /// <summary>
- /// Configures the <see cref="ILoggerRepository"/> using the specified configuration
- /// file.
- /// </summary>
- /// <param name="repository">The repository to configure.</param>
- /// <param name="configStream">The stream to load the XML configuration from.</param>
- /// <remarks>
- /// <para>
- /// The configuration data must be valid XML. It must contain
- /// at least one element called <c>log4net</c> that holds
- /// the configuration data.
- /// </para>
- /// <para>
- /// Note that this method will NOT close the stream parameter.
- /// </para>
- /// </remarks>
- public static ICollection Configure(ILoggerRepository repository, Stream configStream)
- {
- ArrayList configurationMessages = new ArrayList();
+ /// <summary>
+ /// Configures the <see cref="ILoggerRepository"/> using the specified configuration
+ /// file.
+ /// </summary>
+ /// <param name="repository">The repository to configure.</param>
+ /// <param name="configStream">The stream to load the XML configuration from.</param>
+ /// <remarks>
+ /// <para>
+ /// The configuration data must be valid XML. It must contain
+ /// at least one element called <c>log4net</c> that holds
+ /// the configuration data.
+ /// </para>
+ /// <para>
+ /// Note that this method will NOT close the stream parameter.
+ /// </para>
+ /// </remarks>
+ public static ICollection Configure(ILoggerRepository repository, Stream configStream)
+ {
+ ArrayList configurationMessages = new ArrayList();
- using (new LogLog.LogReceivedAdapter(configurationMessages))
- {
- InternalConfigure(repository, configStream);
- }
+ using (new LogLog.LogReceivedAdapter(configurationMessages))
+ {
+ InternalConfigure(repository, configStream);
+ }
- repository.ConfigurationMessages = configurationMessages;
+ repository.ConfigurationMessages = configurationMessages;
- return configurationMessages;
- }
+ return configurationMessages;
+ }
- private static void InternalConfigure(ILoggerRepository repository, Stream configStream)
- {
- LogLog.Debug(declaringType, "configuring repository [" + repository.Name + "] using stream");
+ private static void InternalConfigure(ILoggerRepository repository, Stream configStream)
+ {
+ LogLog.Debug(declaringType, "configuring repository [" + repository.Name + "] using stream");
- if (configStream == null)
- {
- LogLog.Error(declaringType, "Configure called with null 'configStream' parameter");
- }
- else
- {
- // Load the config file into a document
+ if (configStream == null)
+ {
+ LogLog.Error(declaringType, "Configure called with null 'configStream' parameter");
+ }
+ else
+ {
+ // Load the config file into a document
#if NETSTANDARD1_3
- XmlDocument doc = new XmlDocument();
+ XmlDocument doc = new XmlDocument();
#else
- XmlDocument doc = new XmlDocument { XmlResolver = null };
+ XmlDocument doc = new XmlDocument { XmlResolver = null };
#endif
- try
- {
+ try
+ {
#if (NETCF)
- // Create a text reader for the file stream
- XmlTextReader xmlReader = new XmlTextReader(configStream);
+ // Create a text reader for the file stream
+ XmlTextReader xmlReader = new XmlTextReader(configStream);
#elif NET_2_0 || NETSTANDARD
- // Allow the DTD to specify entity includes
- XmlReaderSettings settings = new XmlReaderSettings();
- // .NET 4.0 warning CS0618: 'System.Xml.XmlReaderSettings.ProhibitDtd'
- // is obsolete: 'Use XmlReaderSettings.DtdProcessing property instead.'
+ // Allow the DTD to specify entity includes
+ XmlReaderSettings settings = new XmlReaderSettings();
+ // .NET 4.0 warning CS0618: 'System.Xml.XmlReaderSettings.ProhibitDtd'
+ // is obsolete: 'Use XmlReaderSettings.DtdProcessing property instead.'
#if NETSTANDARD1_3 // TODO DtdProcessing.Parse not yet available (https://github.com/dotnet/corefx/issues/4376)
- settings.DtdProcessing = DtdProcessing.Ignore;
+ settings.DtdProcessing = DtdProcessing.Ignore;
#elif !NET_4_0 && !MONO_4_0 && !NETSTANDARD2_0
- settings.ProhibitDtd = true;
+ settings.ProhibitDtd = true;
#else
- settings.DtdProcessing = DtdProcessing.Ignore;
+ settings.DtdProcessing = DtdProcessing.Ignore;
#endif
- // Create a reader over the input stream
- using XmlReader xmlReader = XmlReader.Create(configStream, settings);
+ // Create a reader over the input stream
+ using XmlReader xmlReader = XmlReader.Create(configStream, settings);
#else
- // Create a validating reader around a text reader for the file stream
- using XmlValidatingReader xmlReader = new XmlValidatingReader(new XmlTextReader(configStream));
+ // Create a validating reader around a text reader for the file stream
+ using XmlValidatingReader xmlReader = new XmlValidatingReader(new XmlTextReader(configStream));
- // Specify that the reader should not perform validation, but that it should
- // expand entity refs.
- xmlReader.ValidationType = ValidationType.None;
- xmlReader.EntityHandling = EntityHandling.ExpandEntities;
+ // Specify that the reader should not perform validation, but that it should
+ // expand entity refs.
+ xmlReader.ValidationType = ValidationType.None;
+ xmlReader.EntityHandling = EntityHandling.ExpandEntities;
#endif
- // load the data into the document
- doc.Load(xmlReader);
- }
- catch(Exception ex)
- {
- LogLog.Error(declaringType, "Error while loading XML configuration", ex);
+ // load the data into the document
+ doc.Load(xmlReader);
+ }
+ catch(Exception ex)
+ {
+ LogLog.Error(declaringType, "Error while loading XML configuration", ex);
- // The document is invalid
- doc = null;
- }
+ // The document is invalid
+ doc = null;
+ }
- if (doc != null)
- {
- LogLog.Debug(declaringType, "loading XML configuration");
+ if (doc != null)
+ {
+ LogLog.Debug(declaringType, "loading XML configuration");
- // Configure using the 'log4net' element
- XmlNodeList configNodeList = doc.GetElementsByTagName("log4net");
- if (configNodeList.Count == 0)
- {
- LogLog.Debug(declaringType, "XML configuration does not contain a <log4net> element. Configuration Aborted.");
- }
- else if (configNodeList.Count > 1)
- {
- LogLog.Error(declaringType, "XML configuration contains [" + configNodeList.Count + "] <log4net> elements. Only one is allowed. Configuration Aborted.");
- }
- else
- {
- InternalConfigureFromXml(repository, configNodeList[0] as XmlElement);
- }
- }
- }
- }
+ // Configure using the 'log4net' element
+ XmlNodeList configNodeList = doc.GetElementsByTagName("log4net");
+ if (configNodeList.Count == 0)
+ {
+ LogLog.Debug(declaringType, "XML configuration does not contain a <log4net> element. Configuration Aborted.");
+ }
+ else if (configNodeList.Count > 1)
+ {
+ LogLog.Error(declaringType, "XML configuration contains [" + configNodeList.Count + "] <log4net> elements. Only one is allowed. Configuration Aborted.");
+ }
+ else
+ {
+ InternalConfigureFromXml(repository, configNodeList[0] as XmlElement);
+ }
+ }
+ }
+ }
- #endregion Configure static methods
+ #endregion Configure static methods
- #region ConfigureAndWatch static methods
+ #region ConfigureAndWatch static methods
#if (!NETCF && !SSCLI)
#if !NETSTANDARD1_3 // Excluded because GetCallingAssembly() is not available in CoreFX (https://github.com/dotnet/corefx/issues/2221).
- /// <summary>
- /// Configures log4net using the file specified, monitors the file for changes
- /// and reloads the configuration if a change is detected.
- /// </summary>
- /// <param name="configFile">The XML file to load the configuration from.</param>
- /// <remarks>
- /// <para>
- /// The configuration file must be valid XML. It must contain
- /// at least one element called <c>log4net</c> that holds
- /// the configuration data.
- /// </para>
- /// <para>
- /// The configuration file will be monitored using a <see cref="FileSystemWatcher"/>
- /// and depends on the behavior of that class.
- /// </para>
- /// <para>
- /// For more information on how to configure log4net using
- /// a separate configuration file, see <see cref="M:Configure(FileInfo)"/>.
- /// </para>
- /// </remarks>
- /// <seealso cref="M:Configure(FileInfo)"/>
- public static ICollection ConfigureAndWatch(FileInfo configFile)
- {
- ArrayList configurationMessages = new ArrayList();
+ /// <summary>
+ /// Configures log4net using the file specified, monitors the file for changes
+ /// and reloads the configuration if a change is detected.
+ /// </summary>
+ /// <param name="configFile">The XML file to load the configuration from.</param>
+ /// <remarks>
+ /// <para>
+ /// The configuration file must be valid XML. It must contain
+ /// at least one element called <c>log4net</c> that holds
+ /// the configuration data.
+ /// </para>
+ /// <para>
+ /// The configuration file will be monitored using a <see cref="FileSystemWatcher"/>
+ /// and depends on the behavior of that class.
+ /// </para>
+ /// <para>
+ /// For more information on how to configure log4net using
+ /// a separate configuration file, see <see cref="M:Configure(FileInfo)"/>.
+ /// </para>
+ /// </remarks>
+ /// <seealso cref="M:Configure(FileInfo)"/>
+ public static ICollection ConfigureAndWatch(FileInfo configFile)
+ {
+ ArrayList configurationMessages = new ArrayList();
- ILoggerRepository repository = LogManager.GetRepository(Assembly.GetCallingAssembly());
+ ILoggerRepository repository = LogManager.GetRepository(Assembly.GetCallingAssembly());
- using (new LogLog.LogReceivedAdapter(configurationMessages))
- {
- InternalConfigureAndWatch(repository, configFile);
- }
+ using (new LogLog.LogReceivedAdapter(configurationMessages))
+ {
+ InternalConfigureAndWatch(repository, configFile);
+ }
- repository.ConfigurationMessages = configurationMessages;
+ repository.ConfigurationMessages = configurationMessages;
- return configurationMessages;
- }
+ return configurationMessages;
+ }
#endif // !NETSTANDARD1_3
- /// <summary>
- /// Configures the <see cref="ILoggerRepository"/> using the file specified,
- /// monitors the file for changes and reloads the configuration if a change
- /// is detected.
- /// </summary>
- /// <param name="repository">The repository to configure.</param>
- /// <param name="configFile">The XML file to load the configuration from.</param>
- /// <remarks>
- /// <para>
- /// The configuration file must be valid XML. It must contain
- /// at least one element called <c>log4net</c> that holds
- /// the configuration data.
- /// </para>
- /// <para>
- /// The configuration file will be monitored using a <see cref="FileSystemWatcher"/>
- /// and depends on the behavior of that class.
- /// </para>
- /// <para>
- /// For more information on how to configure log4net using
- /// a separate configuration file, see <see cref="M:Configure(FileInfo)"/>.
- /// </para>
- /// </remarks>
- /// <seealso cref="M:Configure(FileInfo)"/>
- public static ICollection ConfigureAndWatch(ILoggerRepository repository, FileInfo configFile)
- {
- ArrayList configurationMessages = new ArrayList();
+ /// <summary>
+ /// Configures the <see cref="ILoggerRepository"/> using the file specified,
+ /// monitors the file for changes and reloads the configuration if a change
+ /// is detected.
+ /// </summary>
+ /// <param name="repository">The repository to configure.</param>
+ /// <param name="configFile">The XML file to load the configuration from.</param>
+ /// <remarks>
+ /// <para>
+ /// The configuration file must be valid XML. It must contain
+ /// at least one element called <c>log4net</c> that holds
+ /// the configuration data.
+ /// </para>
+ /// <para>
+ /// The configuration file will be monitored using a <see cref="FileSystemWatcher"/>
+ /// and depends on the behavior of that class.
+ /// </para>
+ /// <para>
+ /// For more information on how to configure log4net using
+ /// a separate configuration file, see <see cref="M:Configure(FileInfo)"/>.
+ /// </para>
+ /// </remarks>
+ /// <seealso cref="M:Configure(FileInfo)"/>
+ public static ICollection ConfigureAndWatch(ILoggerRepository repository, FileInfo configFile)
+ {
+ ArrayList configurationMessages = new ArrayList();
- using (new LogLog.LogReceivedAdapter(configurationMessages))
- {
- InternalConfigureAndWatch(repository, configFile);
- }
+ using (new LogLog.LogReceivedAdapter(configurationMessages))
+ {
+ InternalConfigureAndWatch(repository, configFile);
+ }
- repository.ConfigurationMessages = configurationMessages;
+ repository.ConfigurationMessages = configurationMessages;
- return configurationMessages;
- }
+ return configurationMessages;
+ }
- private static void InternalConfigureAndWatch(ILoggerRepository repository, FileInfo configFile)
- {
- LogLog.Debug(declaringType, "configuring repository [" + repository.Name + "] using file [" + configFile + "] watching for file updates");
+ private static void InternalConfigureAndWatch(ILoggerRepository repository, FileInfo configFile)
+ {
+ LogLog.Debug(declaringType, "configuring repository [" + repository.Name + "] using file [" + configFile + "] watching for file updates");
- if (configFile == null)
- {
- LogLog.Error(declaringType, "ConfigureAndWatch called with null 'configFile' parameter");
- }
- else
- {
- // Configure log4net now
- InternalConfigure(repository, configFile);
+ if (configFile == null)
+ {
+ LogLog.Error(declaringType, "ConfigureAndWatch called with null 'configFile' parameter");
+ }
+ else
+ {
+ // Configure log4net now
+ InternalConfigure(repository, configFile);
- try
- {
- lock (m_repositoryName2ConfigAndWatchHandler)
- {
- // support multiple repositories each having their own watcher
- ConfigureAndWatchHandler handler =
- (ConfigureAndWatchHandler)m_repositoryName2ConfigAndWatchHandler[configFile.FullName];
+ try
+ {
+ lock (m_repositoryName2ConfigAndWatchHandler)
+ {
+ // support multiple repositories each having their own watcher
+ ConfigureAndWatchHandler handler =
+ (ConfigureAndWatchHandler)m_repositoryName2ConfigAndWatchHandler[configFile.FullName];
- if (handler != null)
- {
- m_repositoryName2ConfigAndWatchHandler.Remove(configFile.FullName);
- handler.Dispose();
- }
+ if (handler != null)
+ {
+ m_repositoryName2ConfigAndWatchHandler.Remove(configFile.FullName);
+ handler.Dispose();
+ }
- // Create and start a watch handler that will reload the
- // configuration whenever the config file is modified.
- handler = new ConfigureAndWatchHandler(repository, configFile);
- m_repositoryName2ConfigAndWatchHandler[configFile.FullName] = handler;
- }
- }
- catch(Exception ex)
- {
- LogLog.Error(declaringType, "Failed to initialize configuration file watcher for file ["+configFile.FullName+"]", ex);
- }
- }
- }
+ // Create and start a watch handler that will reload the
+ // configuration whenever the config file is modified.
+ handler = new ConfigureAndWatchHandler(repository, configFile);
+ m_repositoryName2ConfigAndWatchHandler[configFile.FullName] = handler;
+ }
+ }
+ catch(Exception ex)
+ {
+ LogLog.Error(declaringType, "Failed to initialize configuration file watcher for file ["+configFile.FullName+"]", ex);
+ }
+ }
+ }
#endif
- #endregion ConfigureAndWatch static methods
+ #endregion ConfigureAndWatch static methods
- #region ConfigureAndWatchHandler
+ #region ConfigureAndWatchHandler
#if (!NETCF && !SSCLI)
- /// <summary>
- /// Class used to watch config files.
- /// </summary>
- /// <remarks>
- /// <para>
- /// Uses the <see cref="FileSystemWatcher"/> to monitor
- /// changes to a specified file. Because multiple change notifications
- /// may be raised when the file is modified, a timer is used to
- /// compress the notifications into a single event. The timer
- /// waits for <see cref="TimeoutMillis"/> time before delivering
- /// the event notification. If any further <see cref="FileSystemWatcher"/>
- /// change notifications arrive while the timer is waiting it
- /// is reset and waits again for <see cref="TimeoutMillis"/> to
- /// elapse.
- /// </para>
- /// </remarks>
- private sealed class ConfigureAndWatchHandler : IDisposable
- {
- /// <summary>
- /// Holds the FileInfo used to configure the XmlConfigurator
- /// </summary>
- private FileInfo m_configFile;
+ /// <summary>
+ /// Class used to watch config files.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Uses the <see cref="FileSystemWatcher"/> to monitor
+ /// changes to a specified file. Because multiple change notifications
+ /// may be raised when the file is modified, a timer is used to
+ /// compress the notifications into a single event. The timer
+ /// waits for <see cref="TimeoutMillis"/> time before delivering
+ /// the event notification. If any further <see cref="FileSystemWatcher"/>
+ /// change notifications arrive while the timer is waiting it
+ /// is reset and waits again for <see cref="TimeoutMillis"/> to
+ /// elapse.
+ /// </para>
+ /// </remarks>
+ private sealed class ConfigureAndWatchHandler : IDisposable
+ {
+ /// <summary>
+ /// Holds the FileInfo used to configure the XmlConfigurator
+ /// </summary>
+ private FileInfo m_configFile;
- /// <summary>
- /// Holds the repository being configured.
- /// </summary>
- private ILoggerRepository m_repository;
+ /// <summary>
+ /// Holds the repository being configured.
+ /// </summary>
+ private ILoggerRepository m_repository;
- /// <summary>
- /// The timer used to compress the notification events.
- /// </summary>
- private Timer m_timer;
+ /// <summary>
+ /// The timer used to compress the notification events.
+ /// </summary>
+ private Timer m_timer;
- /// <summary>
- /// The default amount of time to wait after receiving notification
- /// before reloading the config file.
- /// </summary>
- private const int TimeoutMillis = 500;
+ /// <summary>
+ /// The default amount of time to wait after receiving notification
+ /// before reloading the config file.
+ /// </summary>
+ private const int TimeoutMillis = 500;
- /// <summary>
- /// Watches file for changes. This object should be disposed when no longer
- /// needed to free system handles on the watched resources.
- /// </summary>
- private FileSystemWatcher m_watcher;
+ /// <summary>
+ /// Watches file for changes. This object should be disposed when no longer
+ /// needed to free system handles on the watched resources.
+ /// </summary>
+ private FileSystemWatcher m_watcher;
- /// <summary>
- /// Initializes a new instance of the <see cref="ConfigureAndWatchHandler" /> class to
- /// watch a specified config file used to configure a repository.
- /// </summary>
- /// <param name="repository">The repository to configure.</param>
- /// <param name="configFile">The configuration file to watch.</param>
- /// <remarks>
- /// <para>
- /// Initializes a new instance of the <see cref="ConfigureAndWatchHandler" /> class.
- /// </para>
- /// </remarks>
+ /// <summary>
+ /// Initializes a new instance of the <see cref="ConfigureAndWatchHandler" /> class to
+ /// watch a specified config file used to configure a repository.
+ /// </summary>
+ /// <param name="repository">The repository to configure.</param>
+ /// <param name="configFile">The configuration file to watch.</param>
+ /// <remarks>
+ /// <para>
+ /// Initializes a new instance of the <see cref="ConfigureAndWatchHandler" /> class.
+ /// </para>
+ /// </remarks>
#if NET_4_0 || MONO_4_0 || NETSTANDARD
- [System.Security.SecuritySafeCritical]
+ [System.Security.SecuritySafeCritical]
#endif
- public ConfigureAndWatchHandler(ILoggerRepository repository, FileInfo configFile)
- {
- m_repository = repository;
- m_configFile = configFile;
+ public ConfigureAndWatchHandler(ILoggerRepository repository, FileInfo configFile)
+ {
+ m_repository = repository;
+ m_configFile = configFile;
- // Create a new FileSystemWatcher and set its properties.
- m_watcher = new FileSystemWatcher();
+ // Create a new FileSystemWatcher and set its properties.
+ m_watcher = new FileSystemWatcher();
- m_watcher.Path = m_configFile.DirectoryName;
- m_watcher.Filter = m_configFile.Name;
+ m_watcher.Path = m_configFile.DirectoryName;
+ m_watcher.Filter = m_configFile.Name;
- // Set the notification filters
- m_watcher.NotifyFilter = NotifyFilters.CreationTime | NotifyFilters.LastWrite | NotifyFilters.FileName;
+ // Set the notification filters
+ m_watcher.NotifyFilter = NotifyFilters.CreationTime | NotifyFilters.LastWrite | NotifyFilters.FileName;
- // Add event handlers. OnChanged will do for all event handlers that fire a FileSystemEventArgs
- m_watcher.Changed += new FileSystemEventHandler(ConfigureAndWatchHandler_OnChanged);
- m_watcher.Created += new FileSystemEventHandler(ConfigureAndWatchHandler_OnChanged);
- m_watcher.Deleted += new FileSystemEventHandler(ConfigureAndWatchHandler_OnChanged);
- m_watcher.Renamed += new RenamedEventHandler(ConfigureAndWatchHandler_OnRenamed);
+ // Add event handlers. OnChanged will do for all event handlers that fire a FileSystemEventArgs
+ m_watcher.Changed += new FileSystemEventHandler(ConfigureAndWatchHandler_OnChanged);
+ m_watcher.Created += new FileSystemEventHandler(ConfigureAndWatchHandler_OnChanged);
+ m_watcher.Deleted += new FileSystemEventHandler(ConfigureAndWatchHandler_OnChanged);
+ m_watcher.Renamed += new RenamedEventHandler(ConfigureAndWatchHandler_OnRenamed);
- // Begin watching.
- m_watcher.EnableRaisingEvents = true;
+ // Begin watching.
+ m_watcher.EnableRaisingEvents = true;
- // Create the timer that will be used to deliver events. Set as disabled
- m_timer = new Timer(new TimerCallback(OnWatchedFileChange), null, Timeout.Infinite, Timeout.Infinite);
- }
+ // Create the timer that will be used to deliver events. Set as disabled
+ m_timer = new Timer(new TimerCallback(OnWatchedFileChange), null, Timeout.Infinite, Timeout.Infinite);
+ }
- /// <summary>
- /// Event handler used by <see cref="ConfigureAndWatchHandler"/>.
- /// </summary>
- /// <param name="source">The <see cref="FileSystemWatcher"/> firing the event.</param>
- /// <param name="e">The argument indicates the file that caused the event to be fired.</param>
- /// <remarks>
- /// <para>
- /// This handler reloads the configuration from the file when the event is fired.
- /// </para>
- /// </remarks>
- private void ConfigureAndWatchHandler_OnChanged(object source, FileSystemEventArgs e)
- {
- LogLog.Debug(declaringType, "ConfigureAndWatchHandler: "+e.ChangeType+" [" + m_configFile.FullName + "]");
+ /// <summary>
+ /// Event handler used by <see cref="ConfigureAndWatchHandler"/>.
+ /// </summary>
+ /// <param name="source">The <see cref="FileSystemWatcher"/> firing the event.</param>
+ /// <param name="e">The argument indicates the file that caused the event to be fired.</param>
+ /// <remarks>
+ /// <para>
+ /// This handler reloads the configuration from the file when the event is fired.
+ /// </para>
+ /// </remarks>
+ private void ConfigureAndWatchHandler_OnChanged(object source, FileSystemEventArgs e)
+ {
+ LogLog.Debug(declaringType, "ConfigureAndWatchHandler: "+e.ChangeType+" [" + m_configFile.FullName + "]");
- // Deliver the event in TimeoutMillis time
- // timer will fire only once
- m_timer.Change(TimeoutMillis, Timeout.Infinite);
- }
+ // Deliver the event in TimeoutMillis time
+ // timer will fire only once
+ m_timer.Change(TimeoutMillis, Timeout.Infinite);
+ }
- /// <summary>
- /// Event handler used by <see cref="ConfigureAndWatchHandler"/>.
- /// </summary>
- /// <param name="source">The <see cref="FileSystemWatcher"/> firing the event.</param>
- /// <param name="e">The argument indicates the file that caused the event to be fired.</param>
- /// <remarks>
- /// <para>
- /// This handler reloads the configuration from the file when the event is fired.
- /// </para>
- /// </remarks>
- private void ConfigureAndWatchHandler_OnRenamed(object source, RenamedEventArgs e)
- {
- LogLog.Debug(declaringType, "ConfigureAndWatchHandler: " + e.ChangeType + " [" + m_configFile.FullName + "]");
+ /// <summary>
+ /// Event handler used by <see cref="ConfigureAndWatchHandler"/>.
+ /// </summary>
+ /// <param name="source">The <see cref="FileSystemWatcher"/> firing the event.</param>
+ /// <param name="e">The argument indicates the file that caused the event to be fired.</param>
+ /// <remarks>
+ /// <para>
+ /// This handler reloads the configuration from the file when the event is fired.
+ /// </para>
+ /// </remarks>
+ private void ConfigureAndWatchHandler_OnRenamed(object source, RenamedEventArgs e)
+ {
+ LogLog.Debug(declaringType, "ConfigureAndWatchHandler: " + e.ChangeType + " [" + m_configFile.FullName + "]");
- // Deliver the event in TimeoutMillis time
- // timer will fire only once
- m_timer.Change(TimeoutMillis, Timeout.Infinite);
- }
+ // Deliver the event in TimeoutMillis time
+ // timer will fire only once
+ m_timer.Change(TimeoutMillis, Timeout.Infinite);
+ }
- /// <summary>
- /// Called by the timer when the configuration has been updated.
- /// </summary>
- /// <param name="state">null</param>
- private void OnWatchedFileChange(object state)
- {
- XmlConfigurator.InternalConfigure(m_repository, m_configFile);
- }
+ /// <summary>
+ /// Called by the timer when the configuration has been updated.
+ /// </summary>
+ /// <param name="state">null</param>
+ private void OnWatchedFileChange(object state)
+ {
+ XmlConfigurator.InternalConfigure(m_repository, m_configFile);
+ }
- /// <summary>
- /// Release the handles held by the watcher and timer.
- /// </summary>
+ /// <summary>
+ /// Release the handles held by the watcher and timer.
+ /// </summary>
#if NET_4_0 || MONO_4_0 || NETSTANDARD
- [System.Security.SecuritySafeCritical]
+ [System.Security.SecuritySafeCritical]
#endif
- public void Dispose()
- {
- m_watcher.EnableRaisingEvents = false;
- m_watcher.Dispose();
- m_timer.Dispose();
- }
- }
+ public void Dispose()
+ {
+ m_watcher.EnableRaisingEvents = false;
+ m_watcher.Dispose();
+ m_timer.Dispose();
+ }
+ }
#endif
- #endregion ConfigureAndWatchHandler
+ #endregion ConfigureAndWatchHandler
- #region Private Static Methods
+ #region Private Static Methods
- /// <summary>
- /// Configures the specified repository using a <c>log4net</c> element.
- /// </summary>
- /// <param name="repository">The hierarchy to configure.</param>
- /// <param name="element">The element to parse.</param>
- /// <remarks>
- /// <para>
- /// Loads the log4net configuration from the XML element
- /// supplied as <paramref name="element"/>.
- /// </para>
- /// <para>
- /// This method is ultimately called by one of the Configure methods
- /// to load the configuration from an <see cref="XmlElement"/>.
- /// </para>
- /// </remarks>
- private static void InternalConfigureFromXml(ILoggerRepository repository, XmlElement element)
- {
- if (element == null)
- {
- LogLog.Error(declaringType, "ConfigureFromXml called with null 'element' parameter");
- }
- else if (repository == null)
- {
- LogLog.Error(declaringType, "ConfigureFromXml called with null 'repository' parameter");
- }
- else
- {
- LogLog.Debug(declaringType, "Configuring Repository [" + repository.Name + "]");
+ /// <summary>
+ /// Configures the specified repository using a <c>log4net</c> element.
+ /// </summary>
+ /// <param name="repository">The hierarchy to configure.</param>
+ /// <param name="element">The element to parse.</param>
+ /// <remarks>
+ /// <para>
+ /// Loads the log4net configuration from the XML element
+ /// supplied as <paramref name="element"/>.
+ /// </para>
+ /// <para>
+ /// This method is ultimately called by one of the Configure methods
+ /// to load the configuration from an <see cref="XmlElement"/>.
+ /// </para>
+ /// </remarks>
+ private static void InternalConfigureFromXml(ILoggerRepository repository, XmlElement element)
+ {
+ if (element == null)
+ {
+ LogLog.Error(declaringType, "ConfigureFromXml called with null 'element' parameter");
+ }
+ else if (repository == null)
+ {
+ LogLog.Error(declaringType, "ConfigureFromXml called with null 'repository' parameter");
+ }
+ else
+ {
+ LogLog.Debug(declaringType, "Configuring Repository [" + repository.Name + "]");
- IXmlRepositoryConfigurator configurableRepository = repository as IXmlRepositoryConfigurator;
- if (configurableRepository == null)
- {
- LogLog.Warn(declaringType, "Repository [" + repository + "] does not support the XmlConfigurator");
- }
- else
- {
- // Copy the xml data into the root of a new document
- // this isolates the xml config data from the rest of
- // the document
+ IXmlRepositoryConfigurator configurableRepository = repository as IXmlRepositoryConfigurator;
+ if (configurableRepository == null)
+ {
+ LogLog.Warn(declaringType, "Repository [" + repository + "] does not support the XmlConfigurator");
+ }
+ else
+ {
+ // Copy the xml data into the root of a new document
+ // this isolates the xml config data from the rest of
+ // the document
#if NETSTANDARD1_3
- XmlDocument newDoc = new XmlDocument();
+ XmlDocument newDoc = new XmlDocument();
#else
- XmlDocument newDoc = new XmlDocument { XmlResolver = null };
+ XmlDocument newDoc = new XmlDocument { XmlResolver = null };
#endif
- XmlElement newElement = (XmlElement)newDoc.AppendChild(newDoc.ImportNode(element, true));
+ XmlElement newElement = (XmlElement)newDoc.AppendChild(newDoc.ImportNode(element, true));
- // Pass the configurator the config element
- configurableRepository.Configure(newElement);
- }
- }
- }
+ // Pass the configurator the config element
+ configurableRepository.Configure(newElement);
+ }
+ }
+ }
- #endregion Private Static Methods
+ #endregion Private Static Methods
- #region Private Static Fields
+ #region Private Static Fields
- /// <summary>
- /// Maps repository names to ConfigAndWatchHandler instances to allow a particular
- /// ConfigAndWatchHandler to dispose of its FileSystemWatcher when a repository is
- /// reconfigured.
- /// </summary>
- private static readonly Hashtable m_repositoryName2ConfigAndWatchHandler = new Hashtable();
+ /// <summary>
+ /// Maps repository names to ConfigAndWatchHandler instances to allow a particular
+ /// ConfigAndWatchHandler to dispose of its FileSystemWatcher when a repository is
+ /// reconfigured.
+ /// </summary>
+ private static readonly Hashtable m_repositoryName2ConfigAndWatchHandler = new Hashtable();
- /// <summary>
- /// The fully qualified type of the XmlConfigurator class.
- /// </summary>
- /// <remarks>
- /// Used by the internal logger to record the Type of the
- /// log message.
- /// </remarks>
- private static readonly Type declaringType = typeof(XmlConfigurator);
+ /// <summary>
+ /// The fully qualified type of the XmlConfigurator class.
+ /// </summary>
+ /// <remarks>
+ /// Used by the internal logger to record the Type of the
+ /// log message.
+ /// </remarks>
+ private static readonly Type declaringType = typeof(XmlConfigurator);
- #endregion Private Static Fields
- }
+ #endregion Private Static Fields
+ }
}
diff --git a/src/log4net/Config/XmlConfiguratorAttribute.cs b/src/log4net/Config/XmlConfiguratorAttribute.cs
index b5cc702..4fa93fa 100644
--- a/src/log4net/Config/XmlConfiguratorAttribute.cs
+++ b/src/log4net/Config/XmlConfiguratorAttribute.cs
@@ -31,173 +31,173 @@
namespace log4net.Config
{
- /// <summary>
- /// Assembly level attribute to configure the <see cref="XmlConfigurator"/>.
- /// </summary>
- /// <remarks>
- /// <para>
- /// This attribute may only be used at the assembly scope and can only
- /// be used once per assembly.
- /// </para>
- /// <para>
- /// Use this attribute to configure the <see cref="XmlConfigurator"/>
- /// without calling one of the <see cref="M:XmlConfigurator.Configure()"/>
- /// methods.
- /// </para>
- /// <para>
- /// If neither of the <see cref="ConfigFile"/> or <see cref="ConfigFileExtension"/>
- /// properties are set the configuration is loaded from the application's .config file.
- /// If set the <see cref="ConfigFile"/> property takes priority over the
- /// <see cref="ConfigFileExtension"/> property. The <see cref="ConfigFile"/> property
- /// specifies a path to a file to load the config from. The path is relative to the
- /// application's base directory; <see cref="AppDomain.BaseDirectory"/>.
- /// The <see cref="ConfigFileExtension"/> property is used as a postfix to the assembly file name.
- /// The config file must be located in the application's base directory; <see cref="AppDomain.BaseDirectory"/>.
- /// For example in a console application setting the <see cref="ConfigFileExtension"/> to
- /// <c>config</c> has the same effect as not specifying the <see cref="ConfigFile"/> or
- /// <see cref="ConfigFileExtension"/> properties.
- /// </para>
- /// <para>
- /// The <see cref="Watch"/> property can be set to cause the <see cref="XmlConfigurator"/>
- /// to watch the configuration file for changes.
- /// </para>
- /// <note>
- /// <para>
- /// Log4net will only look for assembly level configuration attributes once.
- /// When using the log4net assembly level attributes to control the configuration
- /// of log4net you must ensure that the first call to any of the
- /// <see cref="log4net.Core.LoggerManager"/> methods is made from the assembly with the configuration
- /// attributes.
- /// </para>
- /// <para>
- /// If you cannot guarantee the order in which log4net calls will be made from
- /// different assemblies you must use programmatic configuration instead, i.e.
- /// call the <see cref="M:XmlConfigurator.Configure()"/> method directly.
- /// </para>
- /// </note>
- /// </remarks>
- /// <author>Nicko Cadell</author>
- /// <author>Gert Driesen</author>
- [AttributeUsage(AttributeTargets.Assembly)]
- [Serializable]
- public /*sealed*/ class XmlConfiguratorAttribute : ConfiguratorAttribute
- {
- //
- // Class is not sealed because DOMConfiguratorAttribute extends it while it is obsoleted
- //
+ /// <summary>
+ /// Assembly level attribute to configure the <see cref="XmlConfigurator"/>.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// This attribute may only be used at the assembly scope and can only
+ /// be used once per assembly.
+ /// </para>
+ /// <para>
+ /// Use this attribute to configure the <see cref="XmlConfigurator"/>
+ /// without calling one of the <see cref="M:XmlConfigurator.Configure()"/>
+ /// methods.
+ /// </para>
+ /// <para>
+ /// If neither of the <see cref="ConfigFile"/> or <see cref="ConfigFileExtension"/>
+ /// properties are set the configuration is loaded from the application's .config file.
+ /// If set the <see cref="ConfigFile"/> property takes priority over the
+ /// <see cref="ConfigFileExtension"/> property. The <see cref="ConfigFile"/> property
+ /// specifies a path to a file to load the config from. The path is relative to the
+ /// application's base directory; <see cref="AppDomain.BaseDirectory"/>.
+ /// The <see cref="ConfigFileExtension"/> property is used as a postfix to the assembly file name.
+ /// The config file must be located in the application's base directory; <see cref="AppDomain.BaseDirectory"/>.
+ /// For example in a console application setting the <see cref="ConfigFileExtension"/> to
+ /// <c>config</c> has the same effect as not specifying the <see cref="ConfigFile"/> or
+ /// <see cref="ConfigFileExtension"/> properties.
+ /// </para>
+ /// <para>
+ /// The <see cref="Watch"/> property can be set to cause the <see cref="XmlConfigurator"/>
+ /// to watch the configuration file for changes.
+ /// </para>
+ /// <note>
+ /// <para>
+ /// Log4net will only look for assembly level configuration attributes once.
+ /// When using the log4net assembly level attributes to control the configuration
+ /// of log4net you must ensure that the first call to any of the
+ /// <see cref="log4net.Core.LoggerManager"/> methods is made from the assembly with the configuration
+ /// attributes.
+ /// </para>
+ /// <para>
+ /// If you cannot guarantee the order in which log4net calls will be made from
+ /// different assemblies you must use programmatic configuration instead, i.e.
+ /// call the <see cref="M:XmlConfigurator.Configure()"/> method directly.
+ /// </para>
+ /// </note>
+ /// </remarks>
+ /// <author>Nicko Cadell</author>
+ /// <author>Gert Driesen</author>
+ [AttributeUsage(AttributeTargets.Assembly)]
+ [Serializable]
+ public /*sealed*/ class XmlConfiguratorAttribute : ConfiguratorAttribute
+ {
+ //
+ // Class is not sealed because DOMConfiguratorAttribute extends it while it is obsoleted
+ //
- /// <summary>
- /// Default constructor
- /// </summary>
- /// <remarks>
- /// <para>
- /// Default constructor
- /// </para>
- /// </remarks>
- public XmlConfiguratorAttribute() : base(0) /* configurator priority 0 */
- {
- }
+ /// <summary>
+ /// Default constructor
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Default constructor
+ /// </para>
+ /// </remarks>
+ public XmlConfiguratorAttribute() : base(0) /* configurator priority 0 */
+ {
+ }
- #region Public Instance Properties
+ #region Public Instance Properties
- /// <summary>
- /// Gets or sets the filename of the configuration file.
- /// </summary>
- /// <value>
- /// The filename of the configuration file.
- /// </value>
- /// <remarks>
- /// <para>
- /// If specified, this is the name of the configuration file to use with
- /// the <see cref="XmlConfigurator"/>. This file path is relative to the
- /// <b>application base</b> directory (<see cref="AppDomain.BaseDirectory"/>).
- /// </para>
- /// <para>
- /// The <see cref="ConfigFile"/> takes priority over the <see cref="ConfigFileExtension"/>.
- /// </para>
- /// </remarks>
- public string ConfigFile
- {
- get { return m_configFile; }
- set { m_configFile = value; }
- }
+ /// <summary>
+ /// Gets or sets the filename of the configuration file.
+ /// </summary>
+ /// <value>
+ /// The filename of the configuration file.
+ /// </value>
+ /// <remarks>
+ /// <para>
+ /// If specified, this is the name of the configuration file to use with
+ /// the <see cref="XmlConfigurator"/>. This file path is relative to the
+ /// <b>application base</b> directory (<see cref="AppDomain.BaseDirectory"/>).
+ /// </para>
+ /// <para>
+ /// The <see cref="ConfigFile"/> takes priority over the <see cref="ConfigFileExtension"/>.
+ /// </para>
+ /// </remarks>
+ public string ConfigFile
+ {
+ get { return m_configFile; }
+ set { m_configFile = value; }
+ }
- /// <summary>
- /// Gets or sets the extension of the configuration file.
- /// </summary>
- /// <value>
- /// The extension of the configuration file.
- /// </value>
- /// <remarks>
- /// <para>
- /// If specified this is the extension for the configuration file.
- /// The path to the config file is built by using the <b>application
- /// base</b> directory (<see cref="AppDomain.BaseDirectory"/>),
- /// the <b>assembly file name</b> and the config file extension.
- /// </para>
- /// <para>
- /// If the <see cref="ConfigFileExtension"/> is set to <c>MyExt</c> then
- /// possible config file names would be: <c>MyConsoleApp.exe.MyExt</c> or
- /// <c>MyClassLibrary.dll.MyExt</c>.
- /// </para>
- /// <para>
- /// The <see cref="ConfigFile"/> takes priority over the <see cref="ConfigFileExtension"/>.
- /// </para>
- /// </remarks>
- public string ConfigFileExtension
- {
- get { return m_configFileExtension; }
- set { m_configFileExtension = value; }
- }
+ /// <summary>
+ /// Gets or sets the extension of the configuration file.
+ /// </summary>
+ /// <value>
+ /// The extension of the configuration file.
+ /// </value>
+ /// <remarks>
+ /// <para>
+ /// If specified this is the extension for the configuration file.
+ /// The path to the config file is built by using the <b>application
+ /// base</b> directory (<see cref="AppDomain.BaseDirectory"/>),
+ /// the <b>assembly file name</b> and the config file extension.
+ /// </para>
+ /// <para>
+ /// If the <see cref="ConfigFileExtension"/> is set to <c>MyExt</c> then
+ /// possible config file names would be: <c>MyConsoleApp.exe.MyExt</c> or
+ /// <c>MyClassLibrary.dll.MyExt</c>.
+ /// </para>
+ /// <para>
+ /// The <see cref="ConfigFile"/> takes priority over the <see cref="ConfigFileExtension"/>.
+ /// </para>
+ /// </remarks>
+ public string ConfigFileExtension
+ {
+ get { return m_configFileExtension; }
+ set { m_configFileExtension = value; }
+ }
- /// <summary>
- /// Gets or sets a value indicating whether to watch the configuration file.
- /// </summary>
- /// <value>
- /// <c>true</c> if the configuration should be watched, <c>false</c> otherwise.
- /// </value>
- /// <remarks>
- /// <para>
- /// If this flag is specified and set to <c>true</c> then the framework
- /// will watch the configuration file and will reload the config each time
- /// the file is modified.
- /// </para>
- /// <para>
- /// The config file can only be watched if it is loaded from local disk.
- /// In a No-Touch (Smart Client) deployment where the application is downloaded
- /// from a web server the config file may not reside on the local disk
- /// and therefore it may not be able to watch it.
- /// </para>
- /// <note>
- /// Watching configuration is not supported on the SSCLI.
- /// </note>
- /// </remarks>
- public bool Watch
- {
- get { return m_configureAndWatch; }
- set { m_configureAndWatch = value; }
- }
+ /// <summary>
+ /// Gets or sets a value indicating whether to watch the configuration file.
+ /// </summary>
+ /// <value>
+ /// <c>true</c> if the configuration should be watched, <c>false</c> otherwise.
+ /// </value>
+ /// <remarks>
+ /// <para>
+ /// If this flag is specified and set to <c>true</c> then the framework
+ /// will watch the configuration file and will reload the config each time
+ /// the file is modified.
+ /// </para>
+ /// <para>
+ /// The config file can only be watched if it is loaded from local disk.
+ /// In a No-Touch (Smart Client) deployment where the application is downloaded
+ /// from a web server the config file may not reside on the local disk
+ /// and therefore it may not be able to watch it.
+ /// </para>
+ /// <note>
+ /// Watching configuration is not supported on the SSCLI.
+ /// </note>
+ /// </remarks>
+ public bool Watch
+ {
+ get { return m_configureAndWatch; }
+ set { m_configureAndWatch = value; }
+ }
- #endregion Public Instance Properties
+ #endregion Public Instance Properties
- #region Override ConfiguratorAttribute
+ #region Override ConfiguratorAttribute
- /// <summary>
- /// Configures the <see cref="ILoggerRepository"/> for the specified assembly.
- /// </summary>
- /// <param name="sourceAssembly">The assembly that this attribute was defined on.</param>
- /// <param name="targetRepository">The repository to configure.</param>
- /// <remarks>
- /// <para>
- /// Configure the repository using the <see cref="XmlConfigurator"/>.
- /// The <paramref name="targetRepository"/> specified must extend the <see cref="Hierarchy"/>
- /// class otherwise the <see cref="XmlConfigurator"/> will not be able to
- /// configure it.
- /// </para>
- /// </remarks>
+ /// <summary>
+ /// Configures the <see cref="ILoggerRepository"/> for the specified assembly.
+ /// </summary>
+ /// <param name="sourceAssembly">The assembly that this attribute was defined on.</param>
+ /// <param name="targetRepository">The repository to configure.</param>
+ /// <remarks>
+ /// <para>
+ /// Configure the repository using the <see cref="XmlConfigurator"/>.
+ /// The <paramref name="targetRepository"/> specified must extend the <see cref="Hierarchy"/>
+ /// class otherwise the <see cref="XmlConfigurator"/> will not be able to
+ /// configure it.
+ /// </para>
+ /// </remarks>
/// <exception cref="ArgumentOutOfRangeException">The <paramref name="targetRepository" /> does not extend <see cref="Hierarchy"/>.</exception>
- public override void Configure(Assembly sourceAssembly, ILoggerRepository targetRepository)
- {
+ public override void Configure(Assembly sourceAssembly, ILoggerRepository targetRepository)
+ {
IList configurationMessages = new ArrayList();
using (new LogLog.LogReceivedAdapter(configurationMessages))
@@ -224,246 +224,246 @@
}
targetRepository.ConfigurationMessages = configurationMessages;
- }
+ }
- #endregion
+ #endregion
- /// <summary>
- /// Attempt to load configuration from the local file system
- /// </summary>
- /// <param name="sourceAssembly">The assembly that this attribute was defined on.</param>
- /// <param name="targetRepository">The repository to configure.</param>
- private void ConfigureFromFile(Assembly sourceAssembly, ILoggerRepository targetRepository)
- {
- // Work out the full path to the config file
- string fullPath2ConfigFile = null;
-
- // Select the config file
- if (m_configFile == null || m_configFile.Length == 0)
- {
- if (m_configFileExtension == null || m_configFileExtension.Length == 0)
- {
- // Use the default .config file for the AppDomain
- try
- {
- fullPath2ConfigFile = SystemInfo.ConfigurationFileLocation;
- }
- catch(Exception ex)
- {
- LogLog.Error(declaringType, "XmlConfiguratorAttribute: Exception getting ConfigurationFileLocation. Must be able to resolve ConfigurationFileLocation when ConfigFile and ConfigFileExtension properties are not set.", ex);
- }
- }
- else
- {
- // Force the extension to start with a '.'
- if (m_configFileExtension[0] != '.')
- {
- m_configFileExtension = "." + m_configFileExtension;
- }
+ /// <summary>
+ /// Attempt to load configuration from the local file system
+ /// </summary>
+ /// <param name="sourceAssembly">The assembly that this attribute was defined on.</param>
+ /// <param name="targetRepository">The repository to configure.</param>
+ private void ConfigureFromFile(Assembly sourceAssembly, ILoggerRepository targetRepository)
+ {
+ // Work out the full path to the config file
+ string fullPath2ConfigFile = null;
+
+ // Select the config file
+ if (m_configFile == null || m_configFile.Length == 0)
+ {
+ if (m_configFileExtension == null || m_configFileExtension.Length == 0)
+ {
+ // Use the default .config file for the AppDomain
+ try
+ {
+ fullPath2ConfigFile = SystemInfo.ConfigurationFileLocation;
+ }
+ catch(Exception ex)
+ {
+ LogLog.Error(declaringType, "XmlConfiguratorAttribute: Exception getting ConfigurationFileLocation. Must be able to resolve ConfigurationFileLocation when ConfigFile and ConfigFileExtension properties are not set.", ex);
+ }
+ }
+ else
+ {
+ // Force the extension to start with a '.'
+ if (m_configFileExtension[0] != '.')
+ {
+ m_configFileExtension = "." + m_configFileExtension;
+ }
- string applicationBaseDirectory = null;
- try
- {
- applicationBaseDirectory = SystemInfo.ApplicationBaseDirectory;
- }
- catch(Exception ex)
- {
- LogLog.Error(declaringType, "Exception getting ApplicationBaseDirectory. Must be able to resolve ApplicationBaseDirectory and AssemblyFileName when ConfigFileExtension property is set.", ex);
- }
+ string applicationBaseDirectory = null;
+ try
+ {
+ applicationBaseDirectory = SystemInfo.ApplicationBaseDirectory;
+ }
+ catch(Exception ex)
+ {
+ LogLog.Error(declaringType, "Exception getting ApplicationBaseDirectory. Must be able to resolve ApplicationBaseDirectory and AssemblyFileName when ConfigFileExtension property is set.", ex);
+ }
- if (applicationBaseDirectory != null)
- {
- fullPath2ConfigFile = Path.Combine(applicationBaseDirectory, SystemInfo.AssemblyFileName(sourceAssembly) + m_configFileExtension);
- }
- }
- }
- else
- {
- string applicationBaseDirectory = null;
- try
- {
- applicationBaseDirectory = SystemInfo.ApplicationBaseDirectory;
- }
- catch(Exception ex)
- {
- LogLog.Warn(declaringType, "Exception getting ApplicationBaseDirectory. ConfigFile property path ["+m_configFile+"] will be treated as an absolute path.", ex);
- }
+ if (applicationBaseDirectory != null)
+ {
+ fullPath2ConfigFile = Path.Combine(applicationBaseDirectory, SystemInfo.AssemblyFileName(sourceAssembly) + m_configFileExtension);
+ }
+ }
+ }
+ else
+ {
+ string applicationBaseDirectory = null;
+ try
+ {
+ applicationBaseDirectory = SystemInfo.ApplicationBaseDirectory;
+ }
+ catch(Exception ex)
+ {
+ LogLog.Warn(declaringType, "Exception getting ApplicationBaseDirectory. ConfigFile property path ["+m_configFile+"] will be treated as an absolute path.", ex);
+ }
- if (applicationBaseDirectory != null)
- {
- // Just the base dir + the config file
- fullPath2ConfigFile = Path.Combine(applicationBaseDirectory, m_configFile);
- }
- else
- {
- fullPath2ConfigFile = m_configFile;
- }
- }
+ if (applicationBaseDirectory != null)
+ {
+ // Just the base dir + the config file
+ fullPath2ConfigFile = Path.Combine(applicationBaseDirectory, m_configFile);
+ }
+ else
+ {
+ fullPath2ConfigFile = m_configFile;
+ }
+ }
- if (fullPath2ConfigFile != null)
- {
- ConfigureFromFile(targetRepository, new FileInfo(fullPath2ConfigFile));
- }
- }
+ if (fullPath2ConfigFile != null)
+ {
+ ConfigureFromFile(targetRepository, new FileInfo(fullPath2ConfigFile));
+ }
+ }
- /// <summary>
- /// Configure the specified repository using a <see cref="FileInfo"/>
- /// </summary>
- /// <param name="targetRepository">The repository to configure.</param>
- /// <param name="configFile">the FileInfo pointing to the config file</param>
- private void ConfigureFromFile(ILoggerRepository targetRepository, FileInfo configFile)
- {
+ /// <summary>
+ /// Configure the specified repository using a <see cref="FileInfo"/>
+ /// </summary>
+ /// <param name="targetRepository">The repository to configure.</param>
+ /// <param name="configFile">the FileInfo pointing to the config file</param>
+ private void ConfigureFromFile(ILoggerRepository targetRepository, FileInfo configFile)
+ {
#if (SSCLI)
- if (m_configureAndWatch)
- {
- LogLog.Warn(declaringType, "XmlConfiguratorAttribute: Unable to watch config file not supported on SSCLI");
- }
- XmlConfigurator.Configure(targetRepository, configFile);
+ if (m_configureAndWatch)
+ {
+ LogLog.Warn(declaringType, "XmlConfiguratorAttribute: Unable to watch config file not supported on SSCLI");
+ }
+ XmlConfigurator.Configure(targetRepository, configFile);
#else
- // Do we configure just once or do we configure and then watch?
- if (m_configureAndWatch)
- {
- XmlConfigurator.ConfigureAndWatch(targetRepository, configFile);
- }
- else
- {
- XmlConfigurator.Configure(targetRepository, configFile);
- }
+ // Do we configure just once or do we configure and then watch?
+ if (m_configureAndWatch)
+ {
+ XmlConfigurator.ConfigureAndWatch(targetRepository, configFile);
+ }
+ else
+ {
+ XmlConfigurator.Configure(targetRepository, configFile);
+ }
#endif
- }
+ }
- /// <summary>
- /// Attempt to load configuration from a URI
- /// </summary>
- /// <param name="sourceAssembly">The assembly that this attribute was defined on.</param>
- /// <param name="targetRepository">The repository to configure.</param>
- private void ConfigureFromUri(Assembly sourceAssembly, ILoggerRepository targetRepository)
- {
- // Work out the full path to the config file
- Uri fullPath2ConfigFile = null;
-
- // Select the config file
- if (m_configFile == null || m_configFile.Length == 0)
- {
- if (m_configFileExtension == null || m_configFileExtension.Length == 0)
- {
- string systemConfigFilePath = null;
- try
- {
- systemConfigFilePath = SystemInfo.ConfigurationFileLocation;
- }
- catch(Exception ex)
- {
- LogLog.Error(declaringType, "XmlConfiguratorAttribute: Exception getting ConfigurationFileLocation. Must be able to resolve ConfigurationFileLocation when ConfigFile and ConfigFileExtension properties are not set.", ex);
- }
+ /// <summary>
+ /// Attempt to load configuration from a URI
+ /// </summary>
+ /// <param name="sourceAssembly">The assembly that this attribute was defined on.</param>
+ /// <param name="targetRepository">The repository to configure.</param>
+ private void ConfigureFromUri(Assembly sourceAssembly, ILoggerRepository targetRepository)
+ {
+ // Work out the full path to the config file
+ Uri fullPath2ConfigFile = null;
+
+ // Select the config file
+ if (m_configFile == null || m_configFile.Length == 0)
+ {
+ if (m_configFileExtension == null || m_configFileExtension.Length == 0)
+ {
+ string systemConfigFilePath = null;
+ try
+ {
+ systemConfigFilePath = SystemInfo.ConfigurationFileLocation;
+ }
+ catch(Exception ex)
+ {
+ LogLog.Error(declaringType, "XmlConfiguratorAttribute: Exception getting ConfigurationFileLocation. Must be able to resolve ConfigurationFileLocation when ConfigFile and ConfigFileExtension properties are not set.", ex);
+ }
- if (systemConfigFilePath != null)
- {
- Uri systemConfigFileUri = new Uri(systemConfigFilePath);
+ if (systemConfigFilePath != null)
+ {
+ Uri systemConfigFileUri = new Uri(systemConfigFilePath);
- // Use the default .config file for the AppDomain
- fullPath2ConfigFile = systemConfigFileUri;
- }
- }
- else
- {
- // Force the extension to start with a '.'
- if (m_configFileExtension[0] != '.')
- {
- m_configFileExtension = "." + m_configFileExtension;
- }
+ // Use the default .config file for the AppDomain
+ fullPath2ConfigFile = systemConfigFileUri;
+ }
+ }
+ else
+ {
+ // Force the extension to start with a '.'
+ if (m_configFileExtension[0] != '.')
+ {
+ m_configFileExtension = "." + m_configFileExtension;
+ }
- string systemConfigFilePath = null;
- try
- {
- systemConfigFilePath = SystemInfo.ConfigurationFileLocation;
- }
- catch(Exception ex)
- {
- LogLog.Error(declaringType, "XmlConfiguratorAttribute: Exception getting ConfigurationFileLocation. Must be able to resolve ConfigurationFileLocation when the ConfigFile property are not set.", ex);
- }
+ string systemConfigFilePath = null;
+ try
+ {
+ systemConfigFilePath = SystemInfo.ConfigurationFileLocation;
+ }
+ catch(Exception ex)
+ {
+ LogLog.Error(declaringType, "XmlConfiguratorAttribute: Exception getting ConfigurationFileLocation. Must be able to resolve ConfigurationFileLocation when the ConfigFile property are not set.", ex);
+ }
- if (systemConfigFilePath != null)
- {
- UriBuilder builder = new UriBuilder(new Uri(systemConfigFilePath));
+ if (systemConfigFilePath != null)
+ {
+ UriBuilder builder = new UriBuilder(new Uri(systemConfigFilePath));
- // Remove the current extension from the systemConfigFileUri path
- string path = builder.Path;
- int startOfExtension = path.LastIndexOf(".");
- if (startOfExtension >= 0)
- {
- path = path.Substring(0, startOfExtension);
- }
- path += m_configFileExtension;
+ // Remove the current extension from the systemConfigFileUri path
+ string path = builder.Path;
+ int startOfExtension = path.LastIndexOf(".");
+ if (startOfExtension >= 0)
+ {
+ path = path.Substring(0, startOfExtension);
+ }
+ path += m_configFileExtension;
- builder.Path = path;
- fullPath2ConfigFile = builder.Uri;
- }
- }
- }
- else
- {
- string applicationBaseDirectory = null;
- try
- {
- applicationBaseDirectory = SystemInfo.ApplicationBaseDirectory;
- }
- catch(Exception ex)
- {
- LogLog.Warn(declaringType, "Exception getting ApplicationBaseDirectory. ConfigFile property path ["+m_configFile+"] will be treated as an absolute URI.", ex);
- }
+ builder.Path = path;
+ fullPath2ConfigFile = builder.Uri;
+ }
+ }
+ }
+ else
+ {
+ string applicationBaseDirectory = null;
+ try
+ {
+ applicationBaseDirectory = SystemInfo.ApplicationBaseDirectory;
+ }
+ catch(Exception ex)
+ {
+ LogLog.Warn(declaringType, "Exception getting ApplicationBaseDirectory. ConfigFile property path ["+m_configFile+"] will be treated as an absolute URI.", ex);
+ }
- if (applicationBaseDirectory != null)
- {
- // Just the base dir + the config file
- fullPath2ConfigFile = new Uri(new Uri(applicationBaseDirectory), m_configFile);
- }
- else
- {
- fullPath2ConfigFile = new Uri(m_configFile);
- }
- }
+ if (applicationBaseDirectory != null)
+ {
+ // Just the base dir + the config file
+ fullPath2ConfigFile = new Uri(new Uri(applicationBaseDirectory), m_configFile);
+ }
+ else
+ {
+ fullPath2ConfigFile = new Uri(m_configFile);
+ }
+ }
- if (fullPath2ConfigFile != null)
- {
- if (fullPath2ConfigFile.IsFile)
- {
- // The m_configFile could be an absolute local path, therefore we have to be
- // prepared to switch back to using FileInfos here
- ConfigureFromFile(targetRepository, new FileInfo(fullPath2ConfigFile.LocalPath));
- }
- else
- {
- if (m_configureAndWatch)
- {
- LogLog.Warn(declaringType, "XmlConfiguratorAttribute: Unable to watch config file loaded from a URI");
- }
- XmlConfigurator.Configure(targetRepository, fullPath2ConfigFile);
- }
- }
- }
+ if (fullPath2ConfigFile != null)
+ {
+ if (fullPath2ConfigFile.IsFile)
+ {
+ // The m_configFile could be an absolute local path, therefore we have to be
+ // prepared to switch back to using FileInfos here
+ ConfigureFromFile(targetRepository, new FileInfo(fullPath2ConfigFile.LocalPath));
+ }
+ else
+ {
+ if (m_configureAndWatch)
+ {
+ LogLog.Warn(declaringType, "XmlConfiguratorAttribute: Unable to watch config file loaded from a URI");
+ }
+ XmlConfigurator.Configure(targetRepository, fullPath2ConfigFile);
+ }
+ }
+ }
- #region Private Instance Fields
+ #region Private Instance Fields
- private string m_configFile = null;
- private string m_configFileExtension = null;
- private bool m_configureAndWatch = false;
+ private string m_configFile = null;
+ private string m_configFileExtension = null;
+ private bool m_configureAndWatch = false;
- #endregion Private Instance Fields
+ #endregion Private Instance Fields
- #region Private Static Fields
+ #region Private Static Fields
- /// <summary>
- /// The fully qualified type of the XmlConfiguratorAttribute class.
- /// </summary>
- /// <remarks>
- /// Used by the internal logger to record the Type of the
- /// log message.
- /// </remarks>
- private static readonly Type declaringType = typeof(XmlConfiguratorAttribute);
+ /// <summary>
+ /// The fully qualified type of the XmlConfiguratorAttribute class.
+ /// </summary>
+ /// <remarks>
+ /// Used by the internal logger to record the Type of the
+ /// log message.
+ /// </remarks>
+ private static readonly Type declaringType = typeof(XmlConfiguratorAttribute);
- #endregion Private Static Fields
- }
+ #endregion Private Static Fields
+ }
}
#endif // !NETCF
diff --git a/src/log4net/Core/CompactRepositorySelector.cs b/src/log4net/Core/CompactRepositorySelector.cs
index b1b2805..f97f107 100644
--- a/src/log4net/Core/CompactRepositorySelector.cs
+++ b/src/log4net/Core/CompactRepositorySelector.cs
@@ -28,330 +28,330 @@
namespace log4net.Core
{
- /// <summary>
- /// The implementation of the <see cref="IRepositorySelector"/> interface suitable
- /// for use with the compact framework
- /// </summary>
- /// <remarks>
- /// <para>
- /// This <see cref="IRepositorySelector"/> implementation is a simple
- /// mapping between repository name and <see cref="ILoggerRepository"/>
- /// object.
- /// </para>
- /// <para>
- /// The .NET Compact Framework 1.0 does not support retrieving assembly
- /// level attributes therefore unlike the <c>DefaultRepositorySelector</c>
- /// this selector does not examine the calling assembly for attributes.
- /// </para>
- /// </remarks>
- /// <author>Nicko Cadell</author>
- public class CompactRepositorySelector : IRepositorySelector
- {
- #region Member Variables
+ /// <summary>
+ /// The implementation of the <see cref="IRepositorySelector"/> interface suitable
+ /// for use with the compact framework
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// This <see cref="IRepositorySelector"/> implementation is a simple
+ /// mapping between repository name and <see cref="ILoggerRepository"/>
+ /// object.
+ /// </para>
+ /// <para>
+ /// The .NET Compact Framework 1.0 does not support retrieving assembly
+ /// level attributes therefore unlike the <c>DefaultRepositorySelector</c>
+ /// this selector does not examine the calling assembly for attributes.
+ /// </para>
+ /// </remarks>
+ /// <author>Nicko Cadell</author>
+ public class CompactRepositorySelector : IRepositorySelector
+ {
+ #region Member Variables
- private const string DefaultRepositoryName = "log4net-default-repository";
+ private const string DefaultRepositoryName = "log4net-default-repository";
- private readonly Hashtable m_name2repositoryMap = new Hashtable();
- private readonly Type m_defaultRepositoryType;
+ private readonly Hashtable m_name2repositoryMap = new Hashtable();
+ private readonly Type m_defaultRepositoryType;
- private event LoggerRepositoryCreationEventHandler m_loggerRepositoryCreatedEvent;
+ private event LoggerRepositoryCreationEventHandler m_loggerRepositoryCreatedEvent;
- #endregion
+ #endregion
- #region Constructors
+ #region Constructors
- /// <summary>
- /// Create a new repository selector
- /// </summary>
- /// <param name="defaultRepositoryType">the type of the repositories to create, must implement <see cref="ILoggerRepository"/></param>
- /// <remarks>
- /// <para>
- /// Create an new compact repository selector.
- /// The default type for repositories must be specified,
- /// an appropriate value would be <see cref="log4net.Repository.Hierarchy.Hierarchy"/>.
- /// </para>
- /// </remarks>
- /// <exception cref="ArgumentNullException">throw if <paramref name="defaultRepositoryType"/> is null</exception>
- /// <exception cref="ArgumentOutOfRangeException">throw if <paramref name="defaultRepositoryType"/> does not implement <see cref="ILoggerRepository"/></exception>
- public CompactRepositorySelector(Type defaultRepositoryType)
- {
- if (defaultRepositoryType == null)
- {
- throw new ArgumentNullException("defaultRepositoryType");
- }
+ /// <summary>
+ /// Create a new repository selector
+ /// </summary>
+ /// <param name="defaultRepositoryType">the type of the repositories to create, must implement <see cref="ILoggerRepository"/></param>
+ /// <remarks>
+ /// <para>
+ /// Create an new compact repository selector.
+ /// The default type for repositories must be specified,
+ /// an appropriate value would be <see cref="log4net.Repository.Hierarchy.Hierarchy"/>.
+ /// </para>
+ /// </remarks>
+ /// <exception cref="ArgumentNullException">throw if <paramref name="defaultRepositoryType"/> is null</exception>
+ /// <exception cref="ArgumentOutOfRangeException">throw if <paramref name="defaultRepositoryType"/> does not implement <see cref="ILoggerRepository"/></exception>
+ public CompactRepositorySelector(Type defaultRepositoryType)
+ {
+ if (defaultRepositoryType == null)
+ {
+ throw new ArgumentNullException("defaultRepositoryType");
+ }
- // Check that the type is a repository
- if (! (typeof(ILoggerRepository).IsAssignableFrom(defaultRepositoryType)) )
- {
- throw log4net.Util.SystemInfo.CreateArgumentOutOfRangeException("defaultRepositoryType", (object)defaultRepositoryType, "Parameter: defaultRepositoryType, Value: ["+defaultRepositoryType+"] out of range. Argument must implement the ILoggerRepository interface");
- }
+ // Check that the type is a repository
+ if (! (typeof(ILoggerRepository).IsAssignableFrom(defaultRepositoryType)) )
+ {
+ throw log4net.Util.SystemInfo.CreateArgumentOutOfRangeException("defaultRepositoryType", (object)defaultRepositoryType, "Parameter: defaultRepositoryType, Value: ["+defaultRepositoryType+"] out of range. Argument must implement the ILoggerRepository interface");
+ }
- m_defaultRepositoryType = defaultRepositoryType;
+ m_defaultRepositoryType = defaultRepositoryType;
- LogLog.Debug(declaringType, "defaultRepositoryType ["+m_defaultRepositoryType+"]");
- }
+ LogLog.Debug(declaringType, "defaultRepositoryType ["+m_defaultRepositoryType+"]");
+ }
- #endregion
+ #endregion
- #region Implementation of IRepositorySelector
+ #region Implementation of IRepositorySelector
- /// <summary>
- /// Get the <see cref="ILoggerRepository"/> for the specified assembly
- /// </summary>
- /// <param name="assembly">not used</param>
- /// <returns>The default <see cref="ILoggerRepository"/></returns>
- /// <remarks>
- /// <para>
- /// The <paramref name="assembly"/> argument is not used. This selector does not create a
- /// separate repository for each assembly.
- /// </para>
- /// <para>
- /// As a named repository is not specified the default repository is
- /// returned. The default repository is named <c>log4net-default-repository</c>.
- /// </para>
- /// </remarks>
- public ILoggerRepository GetRepository(Assembly assembly)
- {
- return CreateRepository(assembly, m_defaultRepositoryType);
- }
+ /// <summary>
+ /// Get the <see cref="ILoggerRepository"/> for the specified assembly
+ /// </summary>
+ /// <param name="assembly">not used</param>
+ /// <returns>The default <see cref="ILoggerRepository"/></returns>
+ /// <remarks>
+ /// <para>
+ /// The <paramref name="assembly"/> argument is not used. This selector does not create a
+ /// separate repository for each assembly.
+ /// </para>
+ /// <para>
+ /// As a named repository is not specified the default repository is
+ /// returned. The default repository is named <c>log4net-default-repository</c>.
+ /// </para>
+ /// </remarks>
+ public ILoggerRepository GetRepository(Assembly assembly)
+ {
+ return CreateRepository(assembly, m_defaultRepositoryType);
+ }
- /// <summary>
- /// Get the named <see cref="ILoggerRepository"/>
- /// </summary>
- /// <param name="repositoryName">the name of the repository to lookup</param>
- /// <returns>The named <see cref="ILoggerRepository"/></returns>
- /// <remarks>
- /// <para>
- /// Get the named <see cref="ILoggerRepository"/>. The default
- /// repository is <c>log4net-default-repository</c>. Other repositories
- /// must be created using the <see cref="M:CreateRepository(string, Type)"/>.
- /// If the named repository does not exist an exception is thrown.
- /// </para>
- /// </remarks>
- /// <exception cref="ArgumentNullException">throw if <paramref name="repositoryName"/> is null</exception>
- /// <exception cref="LogException">throw if the <paramref name="repositoryName"/> does not exist</exception>
- public ILoggerRepository GetRepository(string repositoryName)
- {
- if (repositoryName == null)
- {
- throw new ArgumentNullException("repositoryName");
- }
+ /// <summary>
+ /// Get the named <see cref="ILoggerRepository"/>
+ /// </summary>
+ /// <param name="repositoryName">the name of the repository to lookup</param>
+ /// <returns>The named <see cref="ILoggerRepository"/></returns>
+ /// <remarks>
+ /// <para>
+ /// Get the named <see cref="ILoggerRepository"/>. The default
+ /// repository is <c>log4net-default-repository</c>. Other repositories
+ /// must be created using the <see cref="M:CreateRepository(string, Type)"/>.
+ /// If the named repository does not exist an exception is thrown.
+ /// </para>
+ /// </remarks>
+ /// <exception cref="ArgumentNullException">throw if <paramref name="repositoryName"/> is null</exception>
+ /// <exception cref="LogException">throw if the <paramref name="repositoryName"/> does not exist</exception>
+ public ILoggerRepository GetRepository(string repositoryName)
+ {
+ if (repositoryName == null)
+ {
+ throw new ArgumentNullException("repositoryName");
+ }
- lock(this)
- {
- // Lookup in map
- ILoggerRepository rep = m_name2repositoryMap[repositoryName] as ILoggerRepository;
- if (rep == null)
- {
- throw new LogException("Repository ["+repositoryName+"] is NOT defined.");
- }
- return rep;
- }
- }
+ lock(this)
+ {
+ // Lookup in map
+ ILoggerRepository rep = m_name2repositoryMap[repositoryName] as ILoggerRepository;
+ if (rep == null)
+ {
+ throw new LogException("Repository ["+repositoryName+"] is NOT defined.");
+ }
+ return rep;
+ }
+ }
- /// <summary>
- /// Create a new repository for the assembly specified
- /// </summary>
- /// <param name="assembly">not used</param>
- /// <param name="repositoryType">the type of repository to create, must implement <see cref="ILoggerRepository"/></param>
- /// <returns>the repository created</returns>
- /// <remarks>
- /// <para>
- /// The <paramref name="assembly"/> argument is not used. This selector does not create a
- /// separate repository for each assembly.
- /// </para>
- /// <para>
- /// If the <paramref name="repositoryType"/> is <c>null</c> then the
- /// default repository type specified to the constructor is used.
- /// </para>
- /// <para>
- /// As a named repository is not specified the default repository is
- /// returned. The default repository is named <c>log4net-default-repository</c>.
- /// </para>
- /// </remarks>
- public ILoggerRepository CreateRepository(Assembly assembly, Type repositoryType)
- {
- // If the type is not set then use the default type
- if (repositoryType == null)
- {
- repositoryType = m_defaultRepositoryType;
- }
+ /// <summary>
+ /// Create a new repository for the assembly specified
+ /// </summary>
+ /// <param name="assembly">not used</param>
+ /// <param name="repositoryType">the type of repository to create, must implement <see cref="ILoggerRepository"/></param>
+ /// <returns>the repository created</returns>
+ /// <remarks>
+ /// <para>
+ /// The <paramref name="assembly"/> argument is not used. This selector does not create a
+ /// separate repository for each assembly.
+ /// </para>
+ /// <para>
+ /// If the <paramref name="repositoryType"/> is <c>null</c> then the
+ /// default repository type specified to the constructor is used.
+ /// </para>
+ /// <para>
+ /// As a named repository is not specified the default repository is
+ /// returned. The default repository is named <c>log4net-default-repository</c>.
+ /// </para>
+ /// </remarks>
+ public ILoggerRepository CreateRepository(Assembly assembly, Type repositoryType)
+ {
+ // If the type is not set then use the default type
+ if (repositoryType == null)
+ {
+ repositoryType = m_defaultRepositoryType;
+ }
- lock(this)
- {
- // This method should not throw if the default repository already exists.
+ lock(this)
+ {
+ // This method should not throw if the default repository already exists.
- // First check that the repository does not exist
- ILoggerRepository rep = m_name2repositoryMap[DefaultRepositoryName] as ILoggerRepository;
- if (rep == null)
- {
- // Must create the repository
- rep = CreateRepository(DefaultRepositoryName, repositoryType);
- }
+ // First check that the repository does not exist
+ ILoggerRepository rep = m_name2repositoryMap[DefaultRepositoryName] as ILoggerRepository;
+ if (rep == null)
+ {
+ // Must create the repository
+ rep = CreateRepository(DefaultRepositoryName, repositoryType);
+ }
- return rep;
- }
- }
+ return rep;
+ }
+ }
- /// <summary>
- /// Create a new repository for the repository specified
- /// </summary>
- /// <param name="repositoryName">the repository to associate with the <see cref="ILoggerRepository"/></param>
- /// <param name="repositoryType">the type of repository to create, must implement <see cref="ILoggerRepository"/>.
- /// If this param is null then the default repository type is used.</param>
- /// <returns>the repository created</returns>
- /// <remarks>
- /// <para>
- /// The <see cref="ILoggerRepository"/> created will be associated with the repository
- /// specified such that a call to <see cref="M:GetRepository(string)"/> with the
- /// same repository specified will return the same repository instance.
- /// </para>
- /// <para>
- /// If the named repository already exists an exception will be thrown.
- /// </para>
- /// <para>
- /// If <paramref name="repositoryType"/> is <c>null</c> then the default
- /// repository type specified to the constructor is used.
- /// </para>
- /// </remarks>
- /// <exception cref="ArgumentNullException">throw if <paramref name="repositoryName"/> is null</exception>
- /// <exception cref="LogException">throw if the <paramref name="repositoryName"/> already exists</exception>
- public ILoggerRepository CreateRepository(string repositoryName, Type repositoryType)
- {
- if (repositoryName == null)
- {
- throw new ArgumentNullException("repositoryName");
- }
+ /// <summary>
+ /// Create a new repository for the repository specified
+ /// </summary>
+ /// <param name="repositoryName">the repository to associate with the <see cref="ILoggerRepository"/></param>
+ /// <param name="repositoryType">the type of repository to create, must implement <see cref="ILoggerRepository"/>.
+ /// If this param is null then the default repository type is used.</param>
+ /// <returns>the repository created</returns>
+ /// <remarks>
+ /// <para>
+ /// The <see cref="ILoggerRepository"/> created will be associated with the repository
+ /// specified such that a call to <see cref="M:GetRepository(string)"/> with the
+ /// same repository specified will return the same repository instance.
+ /// </para>
+ /// <para>
+ /// If the named repository already exists an exception will be thrown.
+ /// </para>
+ /// <para>
+ /// If <paramref name="repositoryType"/> is <c>null</c> then the default
+ /// repository type specified to the constructor is used.
+ /// </para>
+ /// </remarks>
+ /// <exception cref="ArgumentNullException">throw if <paramref name="repositoryName"/> is null</exception>
+ /// <exception cref="LogException">throw if the <paramref name="repositoryName"/> already exists</exception>
+ public ILoggerRepository CreateRepository(string repositoryName, Type repositoryType)
+ {
+ if (repositoryName == null)
+ {
+ throw new ArgumentNullException("repositoryName");
+ }
- // If the type is not set then use the default type
- if (repositoryType == null)
- {
- repositoryType = m_defaultRepositoryType;
- }
+ // If the type is not set then use the default type
+ if (repositoryType == null)
+ {
+ repositoryType = m_defaultRepositoryType;
+ }
- lock(this)
- {
- ILoggerRepository rep = null;
+ lock(this)
+ {
+ ILoggerRepository rep = null;
- // First check that the repository does not exist
- rep = m_name2repositoryMap[repositoryName] as ILoggerRepository;
- if (rep != null)
- {
- throw new LogException("Repository ["+repositoryName+"] is already defined. Repositories cannot be redefined.");
- }
- else
- {
- LogLog.Debug(declaringType, "Creating repository ["+repositoryName+"] using type ["+repositoryType+"]");
+ // First check that the repository does not exist
+ rep = m_name2repositoryMap[repositoryName] as ILoggerRepository;
+ if (rep != null)
+ {
+ throw new LogException("Repository ["+repositoryName+"] is already defined. Repositories cannot be redefined.");
+ }
+ else
+ {
+ LogLog.Debug(declaringType, "Creating repository ["+repositoryName+"] using type ["+repositoryType+"]");
- // Call the no arg constructor for the repositoryType
- rep = (ILoggerRepository)Activator.CreateInstance(repositoryType);
+ // Call the no arg constructor for the repositoryType
+ rep = (ILoggerRepository)Activator.CreateInstance(repositoryType);
- // Set the name of the repository
- rep.Name = repositoryName;
+ // Set the name of the repository
+ rep.Name = repositoryName;
- // Store in map
- m_name2repositoryMap[repositoryName] = rep;
+ // Store in map
+ m_name2repositoryMap[repositoryName] = rep;
- // Notify listeners that the repository has been created
- OnLoggerRepositoryCreatedEvent(rep);
- }
+ // Notify listeners that the repository has been created
+ OnLoggerRepositoryCreatedEvent(rep);
+ }
- return rep;
- }
- }
+ return rep;
+ }
+ }
- /// <summary>
- /// Test if a named repository exists
- /// </summary>
- /// <param name="repositoryName">the named repository to check</param>
- /// <returns><c>true</c> if the repository exists</returns>
- /// <remarks>
- /// <para>
- /// Test if a named repository exists. Use <see cref="M:CreateRepository(string, Type)"/>
- /// to create a new repository and <see cref="M:GetRepository(string)"/> to retrieve
- /// a repository.
- /// </para>
- /// </remarks>
- public bool ExistsRepository(string repositoryName)
- {
- lock(this)
- {
- return m_name2repositoryMap.ContainsKey(repositoryName);
- }
- }
+ /// <summary>
+ /// Test if a named repository exists
+ /// </summary>
+ /// <param name="repositoryName">the named repository to check</param>
+ /// <returns><c>true</c> if the repository exists</returns>
+ /// <remarks>
+ /// <para>
+ /// Test if a named repository exists. Use <see cref="M:CreateRepository(string, Type)"/>
+ /// to create a new repository and <see cref="M:GetRepository(string)"/> to retrieve
+ /// a repository.
+ /// </para>
+ /// </remarks>
+ public bool ExistsRepository(string repositoryName)
+ {
+ lock(this)
+ {
+ return m_name2repositoryMap.ContainsKey(repositoryName);
+ }
+ }
- /// <summary>
- /// Gets a list of <see cref="ILoggerRepository"/> objects
- /// </summary>
- /// <returns>an array of all known <see cref="ILoggerRepository"/> objects</returns>
- /// <remarks>
- /// <para>
- /// Gets an array of all of the repositories created by this selector.
- /// </para>
- /// </remarks>
- public ILoggerRepository[] GetAllRepositories()
- {
- lock(this)
- {
- ICollection reps = m_name2repositoryMap.Values;
- ILoggerRepository[] all = new ILoggerRepository[reps.Count];
- reps.CopyTo(all, 0);
- return all;
- }
- }
+ /// <summary>
+ /// Gets a list of <see cref="ILoggerRepository"/> objects
+ /// </summary>
+ /// <returns>an array of all known <see cref="ILoggerRepository"/> objects</returns>
+ /// <remarks>
+ /// <para>
+ /// Gets an array of all of the repositories created by this selector.
+ /// </para>
+ /// </remarks>
+ public ILoggerRepository[] GetAllRepositories()
+ {
+ lock(this)
+ {
+ ICollection reps = m_name2repositoryMap.Values;
+ ILoggerRepository[] all = new ILoggerRepository[reps.Count];
+ reps.CopyTo(all, 0);
+ return all;
+ }
+ }
- #endregion
+ #endregion
- #region Private Static Fields
+ #region Private Static Fields
- /// <summary>
- /// The fully qualified type of the CompactRepositorySelector class.
- /// </summary>
- /// <remarks>
- /// Used by the internal logger to record the Type of the
- /// log message.
- /// </remarks>
- private static readonly Type declaringType = typeof(CompactRepositorySelector);
+ /// <summary>
+ /// The fully qualified type of the CompactRepositorySelector class.
+ /// </summary>
+ /// <remarks>
+ /// Used by the internal logger to record the Type of the
+ /// log message.
+ /// </remarks>
+ private static readonly Type declaringType = typeof(CompactRepositorySelector);
- #endregion Private Static Fields
+ #endregion Private Static Fields
- /// <summary>
- /// Event to notify that a logger repository has been created.
- /// </summary>
- /// <value>
- /// Event to notify that a logger repository has been created.
- /// </value>
- /// <remarks>
- /// <para>
- /// Event raised when a new repository is created.
- /// The event source will be this selector. The event args will
- /// be a <see cref="LoggerRepositoryCreationEventArgs"/> which
- /// holds the newly created <see cref="ILoggerRepository"/>.
- /// </para>
- /// </remarks>
- public event LoggerRepositoryCreationEventHandler LoggerRepositoryCreatedEvent
- {
- add { m_loggerRepositoryCreatedEvent += value; }
- remove { m_loggerRepositoryCreatedEvent -= value; }
- }
+ /// <summary>
+ /// Event to notify that a logger repository has been created.
+ /// </summary>
+ /// <value>
+ /// Event to notify that a logger repository has been created.
+ /// </value>
+ /// <remarks>
+ /// <para>
+ /// Event raised when a new repository is created.
+ /// The event source will be this selector. The event args will
+ /// be a <see cref="LoggerRepositoryCreationEventArgs"/> which
+ /// holds the newly created <see cref="ILoggerRepository"/>.
+ /// </para>
+ /// </remarks>
+ public event LoggerRepositoryCreationEventHandler LoggerRepositoryCreatedEvent
+ {
+ add { m_loggerRepositoryCreatedEvent += value; }
+ remove { m_loggerRepositoryCreatedEvent -= value; }
+ }
- /// <summary>
- /// Notify the registered listeners that the repository has been created
- /// </summary>
- /// <param name="repository">The repository that has been created</param>
- /// <remarks>
- /// <para>
- /// Raises the <event cref="LoggerRepositoryCreatedEvent">LoggerRepositoryCreatedEvent</event>
- /// event.
- /// </para>
- /// </remarks>
- protected virtual void OnLoggerRepositoryCreatedEvent(ILoggerRepository repository)
- {
- LoggerRepositoryCreationEventHandler handler = m_loggerRepositoryCreatedEvent;
- if (handler != null)
- {
- handler(this, new LoggerRepositoryCreationEventArgs(repository));
- }
- }
- }
+ /// <summary>
+ /// Notify the registered listeners that the repository has been created
+ /// </summary>
+ /// <param name="repository">The repository that has been created</param>
+ /// <remarks>
+ /// <para>
+ /// Raises the <event cref="LoggerRepositoryCreatedEvent">LoggerRepositoryCreatedEvent</event>
+ /// event.
+ /// </para>
+ /// </remarks>
+ protected virtual void OnLoggerRepositoryCreatedEvent(ILoggerRepository repository)
+ {
+ LoggerRepositoryCreationEventHandler handler = m_loggerRepositoryCreatedEvent;
+ if (handler != null)
+ {
+ handler(this, new LoggerRepositoryCreationEventArgs(repository));
+ }
+ }
+ }
}
diff --git a/src/log4net/Core/DefaultRepositorySelector.cs b/src/log4net/Core/DefaultRepositorySelector.cs
index 2cc84d2..3240813 100644
--- a/src/log4net/Core/DefaultRepositorySelector.cs
+++ b/src/log4net/Core/DefaultRepositorySelector.cs
@@ -37,677 +37,677 @@
namespace log4net.Core
{
- /// <summary>
- /// The default implementation of the <see cref="IRepositorySelector"/> interface.
- /// </summary>
- /// <remarks>
- /// <para>
- /// Uses attributes defined on the calling assembly to determine how to
- /// configure the hierarchy for the repository.
- /// </para>
- /// </remarks>
- /// <author>Nicko Cadell</author>
- /// <author>Gert Driesen</author>
- public class DefaultRepositorySelector : IRepositorySelector
- {
- #region Public Events
+ /// <summary>
+ /// The default implementation of the <see cref="IRepositorySelector"/> interface.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Uses attributes defined on the calling assembly to determine how to
+ /// configure the hierarchy for the repository.
+ /// </para>
+ /// </remarks>
+ /// <author>Nicko Cadell</author>
+ /// <author>Gert Driesen</author>
+ public class DefaultRepositorySelector : IRepositorySelector
+ {
+ #region Public Events
- /// <summary>
- /// Event to notify that a logger repository has been created.
- /// </summary>
- /// <value>
- /// Event to notify that a logger repository has been created.
- /// </value>
- /// <remarks>
- /// <para>
- /// Event raised when a new repository is created.
- /// The event source will be this selector. The event args will
- /// be a <see cref="LoggerRepositoryCreationEventArgs"/> which
- /// holds the newly created <see cref="ILoggerRepository"/>.
- /// </para>
- /// </remarks>
- public event LoggerRepositoryCreationEventHandler LoggerRepositoryCreatedEvent
- {
- add { m_loggerRepositoryCreatedEvent += value; }
- remove { m_loggerRepositoryCreatedEvent -= value; }
- }
+ /// <summary>
+ /// Event to notify that a logger repository has been created.
+ /// </summary>
+ /// <value>
+ /// Event to notify that a logger repository has been created.
+ /// </value>
+ /// <remarks>
+ /// <para>
+ /// Event raised when a new repository is created.
+ /// The event source will be this selector. The event args will
+ /// be a <see cref="LoggerRepositoryCreationEventArgs"/> which
+ /// holds the newly created <see cref="ILoggerRepository"/>.
+ /// </para>
+ /// </remarks>
+ public event LoggerRepositoryCreationEventHandler LoggerRepositoryCreatedEvent
+ {
+ add { m_loggerRepositoryCreatedEvent += value; }
+ remove { m_loggerRepositoryCreatedEvent -= value; }
+ }
- #endregion Public Events
+ #endregion Public Events
- #region Public Instance Constructors
+ #region Public Instance Constructors
- /// <summary>
- /// Creates a new repository selector.
- /// </summary>
- /// <param name="defaultRepositoryType">The type of the repositories to create, must implement <see cref="ILoggerRepository"/></param>
- /// <remarks>
- /// <para>
- /// Create an new repository selector.
- /// The default type for repositories must be specified,
- /// an appropriate value would be <see cref="log4net.Repository.Hierarchy.Hierarchy"/>.
- /// </para>
- /// </remarks>
- /// <exception cref="ArgumentNullException"><paramref name="defaultRepositoryType"/> is <see langword="null" />.</exception>
- /// <exception cref="ArgumentOutOfRangeException"><paramref name="defaultRepositoryType"/> does not implement <see cref="ILoggerRepository"/>.</exception>
- public DefaultRepositorySelector(Type defaultRepositoryType)
- {
- if (defaultRepositoryType == null)
- {
- throw new ArgumentNullException("defaultRepositoryType");
- }
+ /// <summary>
+ /// Creates a new repository selector.
+ /// </summary>
+ /// <param name="defaultRepositoryType">The type of the repositories to create, must implement <see cref="ILoggerRepository"/></param>
+ /// <remarks>
+ /// <para>
+ /// Create an new repository selector.
+ /// The default type for repositories must be specified,
+ /// an appropriate value would be <see cref="log4net.Repository.Hierarchy.Hierarchy"/>.
+ /// </para>
+ /// </remarks>
+ /// <exception cref="ArgumentNullException"><paramref name="defaultRepositoryType"/> is <see langword="null" />.</exception>
+ /// <exception cref="ArgumentOutOfRangeException"><paramref name="defaultRepositoryType"/> does not implement <see cref="ILoggerRepository"/>.</exception>
+ public DefaultRepositorySelector(Type defaultRepositoryType)
+ {
+ if (defaultRepositoryType == null)
+ {
+ throw new ArgumentNullException("defaultRepositoryType");
+ }
- // Check that the type is a repository
- if (! (typeof(ILoggerRepository).IsAssignableFrom(defaultRepositoryType)) )
- {
- throw log4net.Util.SystemInfo.CreateArgumentOutOfRangeException("defaultRepositoryType", defaultRepositoryType, "Parameter: defaultRepositoryType, Value: [" + defaultRepositoryType + "] out of range. Argument must implement the ILoggerRepository interface");
- }
+ // Check that the type is a repository
+ if (! (typeof(ILoggerRepository).IsAssignableFrom(defaultRepositoryType)) )
+ {
+ throw log4net.Util.SystemInfo.CreateArgumentOutOfRangeException("defaultRepositoryType", defaultRepositoryType, "Parameter: defaultRepositoryType, Value: [" + defaultRepositoryType + "] out of range. Argument must implement the ILoggerRepository interface");
+ }
- m_defaultRepositoryType = defaultRepositoryType;
+ m_defaultRepositoryType = defaultRepositoryType;
- LogLog.Debug(declaringType, "defaultRepositoryType [" + m_defaultRepositoryType + "]");
- }
+ LogLog.Debug(declaringType, "defaultRepositoryType [" + m_defaultRepositoryType + "]");
+ }
- #endregion Public Instance Constructors
+ #endregion Public Instance Constructors
- #region Implementation of IRepositorySelector
+ #region Implementation of IRepositorySelector
- /// <summary>
- /// Gets the <see cref="ILoggerRepository"/> for the specified assembly.
- /// </summary>
- /// <param name="repositoryAssembly">The assembly use to lookup the <see cref="ILoggerRepository"/>.</param>
- /// <remarks>
- /// <para>
- /// The type of the <see cref="ILoggerRepository"/> created and the repository
- /// to create can be overridden by specifying the <see cref="log4net.Config.RepositoryAttribute"/>
- /// attribute on the <paramref name="repositoryAssembly"/>.
- /// </para>
- /// <para>
- /// The default values are to use the <see cref="log4net.Repository.Hierarchy.Hierarchy"/>
- /// implementation of the <see cref="ILoggerRepository"/> interface and to use the
- /// <see cref="AssemblyName.Name"/> as the name of the repository.
- /// </para>
- /// <para>
- /// The <see cref="ILoggerRepository"/> created will be automatically configured using
- /// any <see cref="log4net.Config.ConfiguratorAttribute"/> attributes defined on
- /// the <paramref name="repositoryAssembly"/>.
- /// </para>
- /// </remarks>
- /// <returns>The <see cref="ILoggerRepository"/> for the assembly</returns>
- /// <exception cref="ArgumentNullException"><paramref name="repositoryAssembly"/> is <see langword="null" />.</exception>
- public ILoggerRepository GetRepository(Assembly repositoryAssembly)
- {
- if (repositoryAssembly == null)
- {
- throw new ArgumentNullException("repositoryAssembly");
- }
- return CreateRepository(repositoryAssembly, m_defaultRepositoryType);
- }
+ /// <summary>
+ /// Gets the <see cref="ILoggerRepository"/> for the specified assembly.
+ /// </summary>
+ /// <param name="repositoryAssembly">The assembly use to lookup the <see cref="ILoggerRepository"/>.</param>
+ /// <remarks>
+ /// <para>
+ /// The type of the <see cref="ILoggerRepository"/> created and the repository
+ /// to create can be overridden by specifying the <see cref="log4net.Config.RepositoryAttribute"/>
+ /// attribute on the <paramref name="repositoryAssembly"/>.
+ /// </para>
+ /// <para>
+ /// The default values are to use the <see cref="log4net.Repository.Hierarchy.Hierarchy"/>
+ /// implementation of the <see cref="ILoggerRepository"/> interface and to use the
+ /// <see cref="AssemblyName.Name"/> as the name of the repository.
+ /// </para>
+ /// <para>
+ /// The <see cref="ILoggerRepository"/> created will be automatically configured using
+ /// any <see cref="log4net.Config.ConfiguratorAttribute"/> attributes defined on
+ /// the <paramref name="repositoryAssembly"/>.
+ /// </para>
+ /// </remarks>
+ /// <returns>The <see cref="ILoggerRepository"/> for the assembly</returns>
+ /// <exception cref="ArgumentNullException"><paramref name="repositoryAssembly"/> is <see langword="null" />.</exception>
+ public ILoggerRepository GetRepository(Assembly repositoryAssembly)
+ {
+ if (repositoryAssembly == null)
+ {
+ throw new ArgumentNullException("repositoryAssembly");
+ }
+ return CreateRepository(repositoryAssembly, m_defaultRepositoryType);
+ }
- /// <summary>
- /// Gets the <see cref="ILoggerRepository"/> for the specified repository.
- /// </summary>
- /// <param name="repositoryName">The repository to use to lookup the <see cref="ILoggerRepository"/>.</param>
- /// <returns>The <see cref="ILoggerRepository"/> for the specified repository.</returns>
- /// <remarks>
- /// <para>
- /// Returns the named repository. If <paramref name="repositoryName"/> is <c>null</c>
- /// a <see cref="ArgumentNullException"/> is thrown. If the repository
- /// does not exist a <see cref="LogException"/> is thrown.
- /// </para>
- /// <para>
- /// Use <see cref="M:CreateRepository(string, Type)"/> to create a repository.
- /// </para>
- /// </remarks>
- /// <exception cref="ArgumentNullException"><paramref name="repositoryName"/> is <see langword="null" />.</exception>
- /// <exception cref="LogException"><paramref name="repositoryName"/> does not exist.</exception>
- public ILoggerRepository GetRepository(string repositoryName)
- {
- if (repositoryName == null)
- {
- throw new ArgumentNullException("repositoryName");
- }
+ /// <summary>
+ /// Gets the <see cref="ILoggerRepository"/> for the specified repository.
+ /// </summary>
+ /// <param name="repositoryName">The repository to use to lookup the <see cref="ILoggerRepository"/>.</param>
+ /// <returns>The <see cref="ILoggerRepository"/> for the specified repository.</returns>
+ /// <remarks>
+ /// <para>
+ /// Returns the named repository. If <paramref name="repositoryName"/> is <c>null</c>
+ /// a <see cref="ArgumentNullException"/> is thrown. If the repository
+ /// does not exist a <see cref="LogException"/> is thrown.
+ /// </para>
+ /// <para>
+ /// Use <see cref="M:CreateRepository(string, Type)"/> to create a repository.
+ /// </para>
+ /// </remarks>
+ /// <exception cref="ArgumentNullException"><paramref name="repositoryName"/> is <see langword="null" />.</exception>
+ /// <exception cref="LogException"><paramref name="repositoryName"/> does not exist.</exception>
+ public ILoggerRepository GetRepository(string repositoryName)
+ {
+ if (repositoryName == null)
+ {
+ throw new ArgumentNullException("repositoryName");
+ }
- lock(this)
- {
- // Lookup in map
- ILoggerRepository rep = m_name2repositoryMap[repositoryName] as ILoggerRepository;
- if (rep == null)
- {
- throw new LogException("Repository [" + repositoryName + "] is NOT defined.");
- }
- return rep;
- }
- }
+ lock(this)
+ {
+ // Lookup in map
+ ILoggerRepository rep = m_name2repositoryMap[repositoryName] as ILoggerRepository;
+ if (rep == null)
+ {
+ throw new LogException("Repository [" + repositoryName + "] is NOT defined.");
+ }
+ return rep;
+ }
+ }
- /// <summary>
- /// Create a new repository for the assembly specified
- /// </summary>
- /// <param name="repositoryAssembly">the assembly to use to create the repository to associate with the <see cref="ILoggerRepository"/>.</param>
- /// <param name="repositoryType">The type of repository to create, must implement <see cref="ILoggerRepository"/>.</param>
- /// <returns>The repository created.</returns>
- /// <remarks>
- /// <para>
- /// The <see cref="ILoggerRepository"/> created will be associated with the repository
- /// specified such that a call to <see cref="M:GetRepository(Assembly)"/> with the
- /// same assembly specified will return the same repository instance.
- /// </para>
- /// <para>
- /// The type of the <see cref="ILoggerRepository"/> created and
- /// the repository to create can be overridden by specifying the
- /// <see cref="log4net.Config.RepositoryAttribute"/> attribute on the
- /// <paramref name="repositoryAssembly"/>. The default values are to use the
- /// <paramref name="repositoryType"/> implementation of the
- /// <see cref="ILoggerRepository"/> interface and to use the
- /// <see cref="AssemblyName.Name"/> as the name of the repository.
- /// </para>
- /// <para>
- /// The <see cref="ILoggerRepository"/> created will be automatically
- /// configured using any <see cref="log4net.Config.ConfiguratorAttribute"/>
- /// attributes defined on the <paramref name="repositoryAssembly"/>.
- /// </para>
- /// <para>
- /// If a repository for the <paramref name="repositoryAssembly"/> already exists
- /// that repository will be returned. An error will not be raised and that
- /// repository may be of a different type to that specified in <paramref name="repositoryType"/>.
- /// Also the <see cref="log4net.Config.RepositoryAttribute"/> attribute on the
- /// assembly may be used to override the repository type specified in
- /// <paramref name="repositoryType"/>.
- /// </para>
- /// </remarks>
- /// <exception cref="ArgumentNullException"><paramref name="repositoryAssembly"/> is <see langword="null" />.</exception>
- public ILoggerRepository CreateRepository(Assembly repositoryAssembly, Type repositoryType)
- {
- return CreateRepository(repositoryAssembly, repositoryType, DefaultRepositoryName, true);
- }
+ /// <summary>
+ /// Create a new repository for the assembly specified
+ /// </summary>
+ /// <param name="repositoryAssembly">the assembly to use to create the repository to associate with the <see cref="ILoggerRepository"/>.</param>
+ /// <param name="repositoryType">The type of repository to create, must implement <see cref="ILoggerRepository"/>.</param>
+ /// <returns>The repository created.</returns>
+ /// <remarks>
+ /// <para>
+ /// The <see cref="ILoggerRepository"/> created will be associated with the repository
+ /// specified such that a call to <see cref="M:GetRepository(Assembly)"/> with the
+ /// same assembly specified will return the same repository instance.
+ /// </para>
+ /// <para>
+ /// The type of the <see cref="ILoggerRepository"/> created and
+ /// the repository to create can be overridden by specifying the
+ /// <see cref="log4net.Config.RepositoryAttribute"/> attribute on the
+ /// <paramref name="repositoryAssembly"/>. The default values are to use the
+ /// <paramref name="repositoryType"/> implementation of the
+ /// <see cref="ILoggerRepository"/> interface and to use the
+ /// <see cref="AssemblyName.Name"/> as the name of the repository.
+ /// </para>
+ /// <para>
+ /// The <see cref="ILoggerRepository"/> created will be automatically
+ /// configured using any <see cref="log4net.Config.ConfiguratorAttribute"/>
+ /// attributes defined on the <paramref name="repositoryAssembly"/>.
+ /// </para>
+ /// <para>
+ /// If a repository for the <paramref name="repositoryAssembly"/> already exists
+ /// that repository will be returned. An error will not be raised and that
+ /// repository may be of a different type to that specified in <paramref name="repositoryType"/>.
+ /// Also the <see cref="log4net.Config.RepositoryAttribute"/> attribute on the
+ /// assembly may be used to override the repository type specified in
+ /// <paramref name="repositoryType"/>.
+ /// </para>
+ /// </remarks>
+ /// <exception cref="ArgumentNullException"><paramref name="repositoryAssembly"/> is <see langword="null" />.</exception>
+ public ILoggerRepository CreateRepository(Assembly repositoryAssembly, Type repositoryType)
+ {
+ return CreateRepository(repositoryAssembly, repositoryType, DefaultRepositoryName, true);
+ }
- /// <summary>
- /// Creates a new repository for the assembly specified.
- /// </summary>
- /// <param name="repositoryAssembly">the assembly to use to create the repository to associate with the <see cref="ILoggerRepository"/>.</param>
- /// <param name="repositoryType">The type of repository to create, must implement <see cref="ILoggerRepository"/>.</param>
- /// <param name="repositoryName">The name to assign to the created repository</param>
- /// <param name="readAssemblyAttributes">Set to <c>true</c> to read and apply the assembly attributes</param>
- /// <returns>The repository created.</returns>
- /// <remarks>
- /// <para>
- /// The <see cref="ILoggerRepository"/> created will be associated with the repository
- /// specified such that a call to <see cref="M:GetRepository(Assembly)"/> with the
- /// same assembly specified will return the same repository instance.
- /// </para>
- /// <para>
- /// The type of the <see cref="ILoggerRepository"/> created and
- /// the repository to create can be overridden by specifying the
- /// <see cref="log4net.Config.RepositoryAttribute"/> attribute on the
- /// <paramref name="repositoryAssembly"/>. The default values are to use the
- /// <paramref name="repositoryType"/> implementation of the
- /// <see cref="ILoggerRepository"/> interface and to use the
- /// <see cref="AssemblyName.Name"/> as the name of the repository.
- /// </para>
- /// <para>
- /// The <see cref="ILoggerRepository"/> created will be automatically
- /// configured using any <see cref="log4net.Config.ConfiguratorAttribute"/>
- /// attributes defined on the <paramref name="repositoryAssembly"/>.
- /// </para>
- /// <para>
- /// If a repository for the <paramref name="repositoryAssembly"/> already exists
- /// that repository will be returned. An error will not be raised and that
- /// repository may be of a different type to that specified in <paramref name="repositoryType"/>.
- /// Also the <see cref="log4net.Config.RepositoryAttribute"/> attribute on the
- /// assembly may be used to override the repository type specified in
- /// <paramref name="repositoryType"/>.
- /// </para>
- /// </remarks>
- /// <exception cref="ArgumentNullException"><paramref name="repositoryAssembly"/> is <see langword="null" />.</exception>
- public ILoggerRepository CreateRepository(Assembly repositoryAssembly, Type repositoryType, string repositoryName, bool readAssemblyAttributes)
- {
- if (repositoryAssembly == null)
- {
- throw new ArgumentNullException("repositoryAssembly");
- }
+ /// <summary>
+ /// Creates a new repository for the assembly specified.
+ /// </summary>
+ /// <param name="repositoryAssembly">the assembly to use to create the repository to associate with the <see cref="ILoggerRepository"/>.</param>
+ /// <param name="repositoryType">The type of repository to create, must implement <see cref="ILoggerRepository"/>.</param>
+ /// <param name="repositoryName">The name to assign to the created repository</param>
+ /// <param name="readAssemblyAttributes">Set to <c>true</c> to read and apply the assembly attributes</param>
+ /// <returns>The repository created.</returns>
+ /// <remarks>
+ /// <para>
+ /// The <see cref="ILoggerRepository"/> created will be associated with the repository
+ /// specified such that a call to <see cref="M:GetRepository(Assembly)"/> with the
+ /// same assembly specified will return the same repository instance.
+ /// </para>
+ /// <para>
+ /// The type of the <see cref="ILoggerRepository"/> created and
+ /// the repository to create can be overridden by specifying the
+ /// <see cref="log4net.Config.RepositoryAttribute"/> attribute on the
+ /// <paramref name="repositoryAssembly"/>. The default values are to use the
+ /// <paramref name="repositoryType"/> implementation of the
+ /// <see cref="ILoggerRepository"/> interface and to use the
+ /// <see cref="AssemblyName.Name"/> as the name of the repository.
+ /// </para>
+ /// <para>
+ /// The <see cref="ILoggerRepository"/> created will be automatically
+ /// configured using any <see cref="log4net.Config.ConfiguratorAttribute"/>
+ /// attributes defined on the <paramref name="repositoryAssembly"/>.
+ /// </para>
+ /// <para>
+ /// If a repository for the <paramref name="repositoryAssembly"/> already exists
+ /// that repository will be returned. An error will not be raised and that
+ /// repository may be of a different type to that specified in <paramref name="repositoryType"/>.
+ /// Also the <see cref="log4net.Config.RepositoryAttribute"/> attribute on the
+ /// assembly may be used to override the repository type specified in
+ /// <paramref name="repositoryType"/>.
+ /// </para>
+ /// </remarks>
+ /// <exception cref="ArgumentNullException"><paramref name="repositoryAssembly"/> is <see langword="null" />.</exception>
+ public ILoggerRepository CreateRepository(Assembly repositoryAssembly, Type repositoryType, string repositoryName, bool readAssemblyAttributes)
+ {
+ if (repositoryAssembly == null)
+ {
+ throw new ArgumentNullException("repositoryAssembly");
+ }
- // If the type is not set then use the default type
- if (repositoryType == null)
- {
- repositoryType = m_defaultRepositoryType;
- }
+ // If the type is not set then use the default type
+ if (repositoryType == null)
+ {
+ repositoryType = m_defaultRepositoryType;
+ }
- lock(this)
- {
- // Lookup in map
- ILoggerRepository rep = m_assembly2repositoryMap[repositoryAssembly] as ILoggerRepository;
- if (rep == null)
- {
- // Not found, therefore create
- LogLog.Debug(declaringType, "Creating repository for assembly [" + repositoryAssembly + "]");
+ lock(this)
+ {
+ // Lookup in map
+ ILoggerRepository rep = m_assembly2repositoryMap[repositoryAssembly] as ILoggerRepository;
+ if (rep == null)
+ {
+ // Not found, therefore create
+ LogLog.Debug(declaringType, "Creating repository for assembly [" + repositoryAssembly + "]");
- // Must specify defaults
- string actualRepositoryName = repositoryName;
- Type actualRepositoryType = repositoryType;
+ // Must specify defaults
+ string actualRepositoryName = repositoryName;
+ Type actualRepositoryType = repositoryType;
- if (readAssemblyAttributes)
- {
- // Get the repository and type from the assembly attributes
- GetInfoForAssembly(repositoryAssembly, ref actualRepositoryName, ref actualRepositoryType);
- }
+ if (readAssemblyAttributes)
+ {
+ // Get the repository and type from the assembly attributes
+ GetInfoForAssembly(repositoryAssembly, ref actualRepositoryName, ref actualRepositoryType);
+ }
- LogLog.Debug(declaringType, "Assembly [" + repositoryAssembly + "] using repository [" + actualRepositoryName + "] and repository type [" + actualRepositoryType + "]");
+ LogLog.Debug(declaringType, "Assembly [" + repositoryAssembly + "] using repository [" + actualRepositoryName + "] and repository type [" + actualRepositoryType + "]");
- // Lookup the repository in the map (as this may already be defined)
- rep = m_name2repositoryMap[actualRepositoryName] as ILoggerRepository;
- if (rep == null)
- {
- // Create the repository
- rep = CreateRepository(actualRepositoryName, actualRepositoryType);
+ // Lookup the repository in the map (as this may already be defined)
+ rep = m_name2repositoryMap[actualRepositoryName] as ILoggerRepository;
+ if (rep == null)
+ {
+ // Create the repository
+ rep = CreateRepository(actualRepositoryName, actualRepositoryType);
- if (readAssemblyAttributes)
- {
- try
- {
- // Look for aliasing attributes
- LoadAliases(repositoryAssembly, rep);
+ if (readAssemblyAttributes)
+ {
+ try
+ {
+ // Look for aliasing attributes
+ LoadAliases(repositoryAssembly, rep);
- // Look for plugins defined on the assembly
- LoadPlugins(repositoryAssembly, rep);
+ // Look for plugins defined on the assembly
+ LoadPlugins(repositoryAssembly, rep);
- // Configure the repository using the assembly attributes
- ConfigureRepository(repositoryAssembly, rep);
- }
- catch (Exception ex)
- {
- LogLog.Error(declaringType, "Failed to configure repository [" + actualRepositoryName + "] from assembly attributes.", ex);
- }
- }
- }
- else
- {
- LogLog.Debug(declaringType, "repository [" + actualRepositoryName + "] already exists, using repository type [" + rep.GetType().FullName + "]");
+ // Configure the repository using the assembly attributes
+ ConfigureRepository(repositoryAssembly, rep);
+ }
+ catch (Exception ex)
+ {
+ LogLog.Error(declaringType, "Failed to configure repository [" + actualRepositoryName + "] from assembly attributes.", ex);
+ }
+ }
+ }
+ else
+ {
+ LogLog.Debug(declaringType, "repository [" + actualRepositoryName + "] already exists, using repository type [" + rep.GetType().FullName + "]");
- if (readAssemblyAttributes)
- {
- try
- {
- // Look for plugins defined on the assembly
- LoadPlugins(repositoryAssembly, rep);
- }
- catch (Exception ex)
- {
- LogLog.Error(declaringType, "Failed to configure repository [" + actualRepositoryName + "] from assembly attributes.", ex);
- }
- }
- }
- m_assembly2repositoryMap[repositoryAssembly] = rep;
- }
- return rep;
- }
- }
+ if (readAssemblyAttributes)
+ {
+ try
+ {
+ // Look for plugins defined on the assembly
+ LoadPlugins(repositoryAssembly, rep);
+ }
+ catch (Exception ex)
+ {
+ LogLog.Error(declaringType, "Failed to configure repository [" + actualRepositoryName + "] from assembly attributes.", ex);
+ }
+ }
+ }
+ m_assembly2repositoryMap[repositoryAssembly] = rep;
+ }
+ return rep;
+ }
+ }
- /// <summary>
- /// Creates a new repository for the specified repository.
- /// </summary>
- /// <param name="repositoryName">The repository to associate with the <see cref="ILoggerRepository"/>.</param>
- /// <param name="repositoryType">The type of repository to create, must implement <see cref="ILoggerRepository"/>.
- /// If this param is <see langword="null" /> then the default repository type is used.</param>
- /// <returns>The new repository.</returns>
- /// <remarks>
- /// <para>
- /// The <see cref="ILoggerRepository"/> created will be associated with the repository
- /// specified such that a call to <see cref="M:GetRepository(string)"/> with the
- /// same repository specified will return the same repository instance.
- /// </para>
- /// </remarks>
- /// <exception cref="ArgumentNullException"><paramref name="repositoryName"/> is <see langword="null" />.</exception>
- /// <exception cref="LogException"><paramref name="repositoryName"/> already exists.</exception>
- public ILoggerRepository CreateRepository(string repositoryName, Type repositoryType)
- {
- if (repositoryName == null)
- {
- throw new ArgumentNullException("repositoryName");
- }
+ /// <summary>
+ /// Creates a new repository for the specified repository.
+ /// </summary>
+ /// <param name="repositoryName">The repository to associate with the <see cref="ILoggerRepository"/>.</param>
+ /// <param name="repositoryType">The type of repository to create, must implement <see cref="ILoggerRepository"/>.
+ /// If this param is <see langword="null" /> then the default repository type is used.</param>
+ /// <returns>The new repository.</returns>
+ /// <remarks>
+ /// <para>
+ /// The <see cref="ILoggerRepository"/> created will be associated with the repository
+ /// specified such that a call to <see cref="M:GetRepository(string)"/> with the
+ /// same repository specified will return the same repository instance.
+ /// </para>
+ /// </remarks>
+ /// <exception cref="ArgumentNullException"><paramref name="repositoryName"/> is <see langword="null" />.</exception>
+ /// <exception cref="LogException"><paramref name="repositoryName"/> already exists.</exception>
+ public ILoggerRepository CreateRepository(string repositoryName, Type repositoryType)
+ {
+ if (repositoryName == null)
+ {
+ throw new ArgumentNullException("repositoryName");
+ }
- // If the type is not set then use the default type
- if (repositoryType == null)
- {
- repositoryType = m_defaultRepositoryType;
- }
+ // If the type is not set then use the default type
+ if (repositoryType == null)
+ {
+ repositoryType = m_defaultRepositoryType;
+ }
- lock(this)
- {
- ILoggerRepository rep = null;
+ lock(this)
+ {
+ ILoggerRepository rep = null;
- // First check that the repository does not exist
- rep = m_name2repositoryMap[repositoryName] as ILoggerRepository;
- if (rep != null)
- {
- throw new LogException("Repository [" + repositoryName + "] is already defined. Repositories cannot be redefined.");
- }
- else
- {
- // Lookup an alias before trying to create the new repository
- ILoggerRepository aliasedRepository = m_alias2repositoryMap[repositoryName] as ILoggerRepository;
- if (aliasedRepository != null)
- {
- // Found an alias
+ // First check that the repository does not exist
+ rep = m_name2repositoryMap[repositoryName] as ILoggerRepository;
+ if (rep != null)
+ {
+ throw new LogException("Repository [" + repositoryName + "] is already defined. Repositories cannot be redefined.");
+ }
+ else
+ {
+ // Lookup an alias before trying to create the new repository
+ ILoggerRepository aliasedRepository = m_alias2repositoryMap[repositoryName] as ILoggerRepository;
+ if (aliasedRepository != null)
+ {
+ // Found an alias
- // Check repository type
- if (aliasedRepository.GetType() == repositoryType)
- {
- // Repository type is compatible
- LogLog.Debug(declaringType, "Aliasing repository [" + repositoryName + "] to existing repository [" + aliasedRepository.Name + "]");
- rep = aliasedRepository;
+ // Check repository type
+ if (aliasedRepository.GetType() == repositoryType)
+ {
+ // Repository type is compatible
+ LogLog.Debug(declaringType, "Aliasing repository [" + repositoryName + "] to existing repository [" + aliasedRepository.Name + "]");
+ rep = aliasedRepository;
- // Store in map
- m_name2repositoryMap[repositoryName] = rep;
- }
- else
- {
- // Invalid repository type for alias
- LogLog.Error(declaringType, "Failed to alias repository [" + repositoryName + "] to existing repository ["+aliasedRepository.Name+"]. Requested repository type ["+repositoryType.FullName+"] is not compatible with existing type [" + aliasedRepository.GetType().FullName + "]");
+ // Store in map
+ m_name2repositoryMap[repositoryName] = rep;
+ }
+ else
+ {
+ // Invalid repository type for alias
+ LogLog.Error(declaringType, "Failed to alias repository [" + repositoryName + "] to existing repository ["+aliasedRepository.Name+"]. Requested repository type ["+repositoryType.FullName+"] is not compatible with existing type [" + aliasedRepository.GetType().FullName + "]");
- // We now drop through to create the repository without aliasing
- }
- }
+ // We now drop through to create the repository without aliasing
+ }
+ }
- // If we could not find an alias
- if (rep == null)
- {
- LogLog.Debug(declaringType, "Creating repository [" + repositoryName + "] using type [" + repositoryType + "]");
+ // If we could not find an alias
+ if (rep == null)
+ {
+ LogLog.Debug(declaringType, "Creating repository [" + repositoryName + "] using type [" + repositoryType + "]");
- // Call the no arg constructor for the repositoryType
- rep = (ILoggerRepository)Activator.CreateInstance(repositoryType);
+ // Call the no arg constructor for the repositoryType
+ rep = (ILoggerRepository)Activator.CreateInstance(repositoryType);
- // Set the name of the repository
- rep.Name = repositoryName;
+ // Set the name of the repository
+ rep.Name = repositoryName;
- // Store in map
- m_name2repositoryMap[repositoryName] = rep;
+ // Store in map
+ m_name2repositoryMap[repositoryName] = rep;
- // Notify listeners that the repository has been created
- OnLoggerRepositoryCreatedEvent(rep);
- }
- }
+ // Notify listeners that the repository has been created
+ OnLoggerRepositoryCreatedEvent(rep);
+ }
+ }
- return rep;
- }
- }
+ return rep;
+ }
+ }
- /// <summary>
- /// Test if a named repository exists
- /// </summary>
- /// <param name="repositoryName">the named repository to check</param>
- /// <returns><c>true</c> if the repository exists</returns>
- /// <remarks>
- /// <para>
- /// Test if a named repository exists. Use <see cref="M:CreateRepository(string, Type)"/>
- /// to create a new repository and <see cref="M:GetRepository(string)"/> to retrieve
- /// a repository.
- /// </para>
- /// </remarks>
- public bool ExistsRepository(string repositoryName)
- {
- lock(this)
- {
- return m_name2repositoryMap.ContainsKey(repositoryName);
- }
- }
+ /// <summary>
+ /// Test if a named repository exists
+ /// </summary>
+ /// <param name="repositoryName">the named repository to check</param>
+ /// <returns><c>true</c> if the repository exists</returns>
+ /// <remarks>
+ /// <para>
+ /// Test if a named repository exists. Use <see cref="M:CreateRepository(string, Type)"/>
+ /// to create a new repository and <see cref="M:GetRepository(string)"/> to retrieve
+ /// a repository.
+ /// </para>
+ /// </remarks>
+ public bool ExistsRepository(string repositoryName)
+ {
+ lock(this)
+ {
+ return m_name2repositoryMap.ContainsKey(repositoryName);
+ }
+ }
- /// <summary>
- /// Gets a list of <see cref="ILoggerRepository"/> objects
- /// </summary>
- /// <returns>an array of all known <see cref="ILoggerRepository"/> objects</returns>
- /// <remarks>
- /// <para>
- /// Gets an array of all of the repositories created by this selector.
- /// </para>
- /// </remarks>
- public ILoggerRepository[] GetAllRepositories()
- {
- lock(this)
- {
- ICollection reps = m_name2repositoryMap.Values;
- ILoggerRepository[] all = new ILoggerRepository[reps.Count];
- reps.CopyTo(all, 0);
- return all;
- }
- }
+ /// <summary>
+ /// Gets a list of <see cref="ILoggerRepository"/> objects
+ /// </summary>
+ /// <returns>an array of all known <see cref="ILoggerRepository"/> objects</returns>
+ /// <remarks>
+ /// <para>
+ /// Gets an array of all of the repositories created by this selector.
+ /// </para>
+ /// </remarks>
+ public ILoggerRepository[] GetAllRepositories()
+ {
+ lock(this)
+ {
+ ICollection reps = m_name2repositoryMap.Values;
+ ILoggerRepository[] all = new ILoggerRepository[reps.Count];
+ reps.CopyTo(all, 0);
+ return all;
+ }
+ }
- #endregion Implementation of IRepositorySelector
+ #endregion Implementation of IRepositorySelector
- #region Public Instance Methods
+ #region Public Instance Methods
- /// <summary>
- /// Aliases a repository to an existing repository.
- /// </summary>
- /// <param name="repositoryAlias">The repository to alias.</param>
- /// <param name="repositoryTarget">The repository that the repository is aliased to.</param>
- /// <remarks>
- /// <para>
- /// The repository specified will be aliased to the repository when created.
- /// The repository must not already exist.
- /// </para>
- /// <para>
- /// When the repository is created it must utilize the same repository type as
- /// the repository it is aliased to, otherwise the aliasing will fail.
- /// </para>
- /// </remarks>
- /// <exception cref="ArgumentNullException">
- /// <para><paramref name="repositoryAlias" /> is <see langword="null" />.</para>
- /// <para>-or-</para>
- /// <para><paramref name="repositoryTarget" /> is <see langword="null" />.</para>
- /// </exception>
- public void AliasRepository(string repositoryAlias, ILoggerRepository repositoryTarget)
- {
- if (repositoryAlias == null)
- {
- throw new ArgumentNullException("repositoryAlias");
- }
- if (repositoryTarget == null)
- {
- throw new ArgumentNullException("repositoryTarget");
- }
+ /// <summary>
+ /// Aliases a repository to an existing repository.
+ /// </summary>
+ /// <param name="repositoryAlias">The repository to alias.</param>
+ /// <param name="repositoryTarget">The repository that the repository is aliased to.</param>
+ /// <remarks>
+ /// <para>
+ /// The repository specified will be aliased to the repository when created.
+ /// The repository must not already exist.
+ /// </para>
+ /// <para>
+ /// When the repository is created it must utilize the same repository type as
+ /// the repository it is aliased to, otherwise the aliasing will fail.
+ /// </para>
+ /// </remarks>
+ /// <exception cref="ArgumentNullException">
+ /// <para><paramref name="repositoryAlias" /> is <see langword="null" />.</para>
+ /// <para>-or-</para>
+ /// <para><paramref name="repositoryTarget" /> is <see langword="null" />.</para>
+ /// </exception>
+ public void AliasRepository(string repositoryAlias, ILoggerRepository repositoryTarget)
+ {
+ if (repositoryAlias == null)
+ {
+ throw new ArgumentNullException("repositoryAlias");
+ }
+ if (repositoryTarget == null)
+ {
+ throw new ArgumentNullException("repositoryTarget");
+ }
- lock(this)
- {
- // Check if the alias is already set
- if (m_alias2repositoryMap.Contains(repositoryAlias))
- {
- // Check if this is a duplicate of the current alias
- if (repositoryTarget != ((ILoggerRepository)m_alias2repositoryMap[repositoryAlias]))
- {
- // Cannot redefine existing alias
- throw new InvalidOperationException("Repository [" + repositoryAlias + "] is already aliased to repository [" + ((ILoggerRepository)m_alias2repositoryMap[repositoryAlias]).Name + "]. Aliases cannot be redefined.");
- }
- }
- // Check if the alias is already mapped to a repository
- else if (m_name2repositoryMap.Contains(repositoryAlias))
- {
- // Check if this is a duplicate of the current mapping
- if ( repositoryTarget != ((ILoggerRepository)m_name2repositoryMap[repositoryAlias]) )
- {
- // Cannot define alias for already mapped repository
- throw new InvalidOperationException("Repository [" + repositoryAlias + "] already exists and cannot be aliased to repository [" + repositoryTarget.Name + "].");
- }
- }
- else
- {
- // Set the alias
- m_alias2repositoryMap[repositoryAlias] = repositoryTarget;
- }
- }
- }
+ lock(this)
+ {
+ // Check if the alias is already set
+ if (m_alias2repositoryMap.Contains(repositoryAlias))
+ {
+ // Check if this is a duplicate of the current alias
+ if (repositoryTarget != ((ILoggerRepository)m_alias2repositoryMap[repositoryAlias]))
+ {
+ // Cannot redefine existing alias
+ throw new InvalidOperationException("Repository [" + repositoryAlias + "] is already aliased to repository [" + ((ILoggerRepository)m_alias2repositoryMap[repositoryAlias]).Name + "]. Aliases cannot be redefined.");
+ }
+ }
+ // Check if the alias is already mapped to a repository
+ else if (m_name2repositoryMap.Contains(repositoryAlias))
+ {
+ // Check if this is a duplicate of the current mapping
+ if ( repositoryTarget != ((ILoggerRepository)m_name2repositoryMap[repositoryAlias]) )
+ {
+ // Cannot define alias for already mapped repository
+ throw new InvalidOperationException("Repository [" + repositoryAlias + "] already exists and cannot be aliased to repository [" + repositoryTarget.Name + "].");
+ }
+ }
+ else
+ {
+ // Set the alias
+ m_alias2repositoryMap[repositoryAlias] = repositoryTarget;
+ }
+ }
+ }
- #endregion Public Instance Methods
+ #endregion Public Instance Methods
- #region Protected Instance Methods
+ #region Protected Instance Methods
- /// <summary>
- /// Notifies the registered listeners that the repository has been created.
- /// </summary>
- /// <param name="repository">The repository that has been created.</param>
- /// <remarks>
- /// <para>
- /// Raises the <see cref="LoggerRepositoryCreatedEvent"/> event.
- /// </para>
- /// </remarks>
- protected virtual void OnLoggerRepositoryCreatedEvent(ILoggerRepository repository)
- {
- LoggerRepositoryCreationEventHandler handler = m_loggerRepositoryCreatedEvent;
- if (handler != null)
- {
- handler(this, new LoggerRepositoryCreationEventArgs(repository));
- }
- }
+ /// <summary>
+ /// Notifies the registered listeners that the repository has been created.
+ /// </summary>
+ /// <param name="repository">The repository that has been created.</param>
+ /// <remarks>
+ /// <para>
+ /// Raises the <see cref="LoggerRepositoryCreatedEvent"/> event.
+ /// </para>
+ /// </remarks>
+ protected virtual void OnLoggerRepositoryCreatedEvent(ILoggerRepository repository)
+ {
+ LoggerRepositoryCreationEventHandler handler = m_loggerRepositoryCreatedEvent;
+ if (handler != null)
+ {
+ handler(this, new LoggerRepositoryCreationEventArgs(repository));
+ }
+ }
- #endregion Protected Instance Methods
+ #endregion Protected Instance Methods
- #region Private Instance Methods
+ #region Private Instance Methods
- /// <summary>
- /// Gets the repository name and repository type for the specified assembly.
- /// </summary>
- /// <param name="assembly">The assembly that has a <see cref="log4net.Config.RepositoryAttribute"/>.</param>
- /// <param name="repositoryName">in/out param to hold the repository name to use for the assembly, caller should set this to the default value before calling.</param>
- /// <param name="repositoryType">in/out param to hold the type of the repository to create for the assembly, caller should set this to the default value before calling.</param>
- /// <exception cref="ArgumentNullException"><paramref name="assembly" /> is <see langword="null" />.</exception>
- private void GetInfoForAssembly(Assembly assembly, ref string repositoryName, ref Type repositoryType)
- {
- if (assembly == null)
- {
- throw new ArgumentNullException("assembly");
- }
+ /// <summary>
+ /// Gets the repository name and repository type for the specified assembly.
+ /// </summary>
+ /// <param name="assembly">The assembly that has a <see cref="log4net.Config.RepositoryAttribute"/>.</param>
+ /// <param name="repositoryName">in/out param to hold the repository name to use for the assembly, caller should set this to the default value before calling.</param>
+ /// <param name="repositoryType">in/out param to hold the type of the repository to create for the assembly, caller should set this to the default value before calling.</param>
+ /// <exception cref="ArgumentNullException"><paramref name="assembly" /> is <see langword="null" />.</exception>
+ private void GetInfoForAssembly(Assembly assembly, ref string repositoryName, ref Type repositoryType)
+ {
+ if (assembly == null)
+ {
+ throw new ArgumentNullException("assembly");
+ }
- try
- {
- LogLog.Debug(declaringType, "Assembly [" + assembly.FullName + "] Loaded From [" + SystemInfo.AssemblyLocationInfo(assembly) + "]");
- }
- catch
- {
- // Ignore exception from debug call
- }
+ try
+ {
+ LogLog.Debug(declaringType, "Assembly [" + assembly.FullName + "] Loaded From [" + SystemInfo.AssemblyLocationInfo(assembly) + "]");
+ }
+ catch
+ {
+ // Ignore exception from debug call
+ }
- try
- {
- // Look for the RepositoryAttribute on the assembly
+ try
+ {
+ // Look for the RepositoryAttribute on the assembly
#if NETSTANDARD
- object[] repositoryAttributes = assembly.GetCustomAttributes(typeof(log4net.Config.RepositoryAttribute)).ToArray();
+ object[] repositoryAttributes = assembly.GetCustomAttributes(typeof(log4net.Config.RepositoryAttribute)).ToArray();
#else
- object[] repositoryAttributes = Attribute.GetCustomAttributes(assembly, typeof(log4net.Config.RepositoryAttribute), false);
+ object[] repositoryAttributes = Attribute.GetCustomAttributes(assembly, typeof(log4net.Config.RepositoryAttribute), false);
#endif
- if (repositoryAttributes == null || repositoryAttributes.Length == 0)
- {
- // This is not a problem, but its nice to know what is going on.
- LogLog.Debug(declaringType, "Assembly [" + assembly + "] does not have a RepositoryAttribute specified.");
- }
- else
- {
- if (repositoryAttributes.Length > 1)
- {
- LogLog.Error(declaringType, "Assembly [" + assembly + "] has multiple log4net.Config.RepositoryAttribute assembly attributes. Only using first occurrence.");
- }
+ if (repositoryAttributes == null || repositoryAttributes.Length == 0)
+ {
+ // This is not a problem, but its nice to know what is going on.
+ LogLog.Debug(declaringType, "Assembly [" + assembly + "] does not have a RepositoryAttribute specified.");
+ }
+ else
+ {
+ if (repositoryAttributes.Length > 1)
+ {
+ LogLog.Error(declaringType, "Assembly [" + assembly + "] has multiple log4net.Config.RepositoryAttribute assembly attributes. Only using first occurrence.");
+ }
- log4net.Config.RepositoryAttribute domAttr = repositoryAttributes[0] as log4net.Config.RepositoryAttribute;
+ log4net.Config.RepositoryAttribute domAttr = repositoryAttributes[0] as log4net.Config.RepositoryAttribute;
- if (domAttr == null)
- {
- LogLog.Error(declaringType, "Assembly [" + assembly + "] has a RepositoryAttribute but it does not!.");
- }
- else
- {
- // If the Name property is set then override the default
- if (domAttr.Name != null)
- {
- repositoryName = domAttr.Name;
- }
+ if (domAttr == null)
+ {
+ LogLog.Error(declaringType, "Assembly [" + assembly + "] has a RepositoryAttribute but it does not!.");
+ }
+ else
+ {
+ // If the Name property is set then override the default
+ if (domAttr.Name != null)
+ {
+ repositoryName = domAttr.Name;
+ }
- // If the RepositoryType property is set then override the default
- if (domAttr.RepositoryType != null)
- {
- // Check that the type is a repository
- if (typeof(ILoggerRepository).IsAssignableFrom(domAttr.RepositoryType))
- {
- repositoryType = domAttr.RepositoryType;
- }
- else
- {
- LogLog.Error(declaringType, "DefaultRepositorySelector: Repository Type [" + domAttr.RepositoryType + "] must implement the ILoggerRepository interface.");
- }
- }
- }
- }
- }
- catch (Exception ex)
- {
- LogLog.Error(declaringType, "Unhandled exception in GetInfoForAssembly", ex);
- }
- }
+ // If the RepositoryType property is set then override the default
+ if (domAttr.RepositoryType != null)
+ {
+ // Check that the type is a repository
+ if (typeof(ILoggerRepository).IsAssignableFrom(domAttr.RepositoryType))
+ {
+ repositoryType = domAttr.RepositoryType;
+ }
+ else
+ {
+ LogLog.Error(declaringType, "DefaultRepositorySelector: Repository Type [" + domAttr.RepositoryType + "] must implement the ILoggerRepository interface.");
+ }
+ }
+ }
+ }
+ }
+ catch (Exception ex)
+ {
+ LogLog.Error(declaringType, "Unhandled exception in GetInfoForAssembly", ex);
+ }
+ }
- /// <summary>
- /// Configures the repository using information from the assembly.
- /// </summary>
- /// <param name="assembly">The assembly containing <see cref="log4net.Config.ConfiguratorAttribute"/>
- /// attributes which define the configuration for the repository.</param>
- /// <param name="repository">The repository to configure.</param>
- /// <exception cref="ArgumentNullException">
- /// <para><paramref name="assembly" /> is <see langword="null" />.</para>
- /// <para>-or-</para>
- /// <para><paramref name="repository" /> is <see langword="null" />.</para>
- /// </exception>
- private void ConfigureRepository(Assembly assembly, ILoggerRepository repository)
- {
- if (assembly == null)
- {
- throw new ArgumentNullException("assembly");
- }
- if (repository == null)
- {
- throw new ArgumentNullException("repository");
- }
+ /// <summary>
+ /// Configures the repository using information from the assembly.
+ /// </summary>
+ /// <param name="assembly">The assembly containing <see cref="log4net.Config.ConfiguratorAttribute"/>
+ /// attributes which define the configuration for the repository.</param>
+ /// <param name="repository">The repository to configure.</param>
+ /// <exception cref="ArgumentNullException">
+ /// <para><paramref name="assembly" /> is <see langword="null" />.</para>
+ /// <para>-or-</para>
+ /// <para><paramref name="repository" /> is <see langword="null" />.</para>
+ /// </exception>
+ private void ConfigureRepository(Assembly assembly, ILoggerRepository repository)
+ {
+ if (assembly == null)
+ {
+ throw new ArgumentNullException("assembly");
+ }
+ if (repository == null)
+ {
+ throw new ArgumentNullException("repository");
+ }
- // Look for the Configurator attributes (e.g. XmlConfiguratorAttribute) on the assembly
+ // Look for the Configurator attributes (e.g. XmlConfiguratorAttribute) on the assembly
#if NETSTANDARD
- object[] configAttributes = assembly.GetCustomAttributes(typeof(log4net.Config.ConfiguratorAttribute)).ToArray();
+ object[] configAttributes = assembly.GetCustomAttributes(typeof(log4net.Config.ConfiguratorAttribute)).ToArray();
#else
- object[] configAttributes = Attribute.GetCustomAttributes(assembly, typeof(log4net.Config.ConfiguratorAttribute), false);
+ object[] configAttributes = Attribute.GetCustomAttributes(assembly, typeof(log4net.Config.ConfiguratorAttribute), false);
#endif
- if (configAttributes != null && configAttributes.Length > 0)
- {
- // Sort the ConfiguratorAttributes in priority order
- Array.Sort(configAttributes);
+ if (configAttributes != null && configAttributes.Length > 0)
+ {
+ // Sort the ConfiguratorAttributes in priority order
+ Array.Sort(configAttributes);
- // Delegate to the attribute the job of configuring the repository
- foreach(log4net.Config.ConfiguratorAttribute configAttr in configAttributes)
- {
- if (configAttr != null)
- {
- try
- {
- configAttr.Configure(assembly, repository);
- }
- catch (Exception ex)
- {
- LogLog.Error(declaringType, "Exception calling ["+configAttr.GetType().FullName+"] .Configure method.", ex);
- }
- }
- }
- }
+ // Delegate to the attribute the job of configuring the repository
+ foreach(log4net.Config.ConfiguratorAttribute configAttr in configAttributes)
+ {
+ if (configAttr != null)
+ {
+ try
+ {
+ configAttr.Configure(assembly, repository);
+ }
+ catch (Exception ex)
+ {
+ LogLog.Error(declaringType, "Exception calling ["+configAttr.GetType().FullName+"] .Configure method.", ex);
+ }
+ }
+ }
+ }
- if (repository.Name == DefaultRepositoryName)
- {
- // Try to configure the default repository using an AppSettings specified config file
- // Do this even if the repository has been configured (or claims to be), this allows overriding
- // of the default config files etc, if that is required.
+ if (repository.Name == DefaultRepositoryName)
+ {
+ // Try to configure the default repository using an AppSettings specified config file
+ // Do this even if the repository has been configured (or claims to be), this allows overriding
+ // of the default config files etc, if that is required.
- string repositoryConfigFile = SystemInfo.GetAppSetting("log4net.Config");
- if (repositoryConfigFile != null && repositoryConfigFile.Length > 0)
- {
- string applicationBaseDirectory = null;
- try
- {
- applicationBaseDirectory = SystemInfo.ApplicationBaseDirectory;
- }
- catch(Exception ex)
- {
- LogLog.Warn(declaringType, "Exception getting ApplicationBaseDirectory. appSettings log4net.Config path ["+repositoryConfigFile+"] will be treated as an absolute URI", ex);
- }
+ string repositoryConfigFile = SystemInfo.GetAppSetting("log4net.Config");
+ if (repositoryConfigFile != null && repositoryConfigFile.Length > 0)
+ {
+ string applicationBaseDirectory = null;
+ try
+ {
+ applicationBaseDirectory = SystemInfo.ApplicationBaseDirectory;
+ }
+ catch(Exception ex)
+ {
+ LogLog.Warn(declaringType, "Exception getting ApplicationBaseDirectory. appSettings log4net.Config path ["+repositoryConfigFile+"] will be treated as an absolute URI", ex);
+ }
string repositoryConfigFilePath = repositoryConfigFile;
if (applicationBaseDirectory != null)
@@ -716,9 +716,9 @@
}
// Determine whether to watch the file or not based on an app setting value:
- bool watchRepositoryConfigFile = false;
+ bool watchRepositoryConfigFile = false;
#if NET_2_0 || MONO_2_0 || MONO_3_5 || MONO_4_0 || NETSTANDARD
- Boolean.TryParse(SystemInfo.GetAppSetting("log4net.Config.Watch"), out watchRepositoryConfigFile);
+ Boolean.TryParse(SystemInfo.GetAppSetting("log4net.Config.Watch"), out watchRepositoryConfigFile);
#else
{
string watch = SystemInfo.GetAppSetting("log4net.Config.Watch");
@@ -736,153 +736,153 @@
}
#endif
- if (watchRepositoryConfigFile)
- {
- // As we are going to watch the config file it is required to resolve it as a
- // physical file system path pass that in a FileInfo object to the Configurator
- FileInfo repositoryConfigFileInfo = null;
- try
- {
- repositoryConfigFileInfo = new FileInfo(repositoryConfigFilePath);
- }
- catch (Exception ex)
- {
+ if (watchRepositoryConfigFile)
+ {
+ // As we are going to watch the config file it is required to resolve it as a
+ // physical file system path pass that in a FileInfo object to the Configurator
+ FileInfo repositoryConfigFileInfo = null;
+ try
+ {
+ repositoryConfigFileInfo = new FileInfo(repositoryConfigFilePath);
+ }
+ catch (Exception ex)
+ {
LogLog.Error(declaringType, "DefaultRepositorySelector: Exception while parsing log4net.Config file physical path [" + repositoryConfigFilePath + "]", ex);
- }
- try
- {
+ }
+ try
+ {
LogLog.Debug(declaringType, "Loading and watching configuration for default repository from AppSettings specified Config path [" + repositoryConfigFilePath + "]");
XmlConfigurator.ConfigureAndWatch(repository, repositoryConfigFileInfo);
- }
- catch (Exception ex)
- {
+ }
+ catch (Exception ex)
+ {
LogLog.Error(declaringType, "DefaultRepositorySelector: Exception calling XmlConfigurator.ConfigureAndWatch method with ConfigFilePath [" + repositoryConfigFilePath + "]", ex);
- }
- }
- else
- {
+ }
+ }
+ else
+ {
// As we are not going to watch the config file it is easiest to just resolve it as a
- // URI and pass that to the Configurator
- Uri repositoryConfigUri = null;
- try
- {
- repositoryConfigUri = new Uri(repositoryConfigFilePath);
- }
- catch(Exception ex)
- {
- LogLog.Error(declaringType, "Exception while parsing log4net.Config file path ["+repositoryConfigFile+"]", ex);
- }
+ // URI and pass that to the Configurator
+ Uri repositoryConfigUri = null;
+ try
+ {
+ repositoryConfigUri = new Uri(repositoryConfigFilePath);
+ }
+ catch(Exception ex)
+ {
+ LogLog.Error(declaringType, "Exception while parsing log4net.Config file path ["+repositoryConfigFile+"]", ex);
+ }
- if (repositoryConfigUri != null)
- {
- LogLog.Debug(declaringType, "Loading configuration for default repository from AppSettings specified Config URI ["+repositoryConfigUri.ToString()+"]");
+ if (repositoryConfigUri != null)
+ {
+ LogLog.Debug(declaringType, "Loading configuration for default repository from AppSettings specified Config URI ["+repositoryConfigUri.ToString()+"]");
- try
- {
- // TODO: Support other types of configurator
- XmlConfigurator.Configure(repository, repositoryConfigUri);
- }
- catch (Exception ex)
- {
- LogLog.Error(declaringType, "Exception calling XmlConfigurator.Configure method with ConfigUri ["+repositoryConfigUri+"]", ex);
- }
- }
+ try
+ {
+ // TODO: Support other types of configurator
+ XmlConfigurator.Configure(repository, repositoryConfigUri);
+ }
+ catch (Exception ex)
+ {
+ LogLog.Error(declaringType, "Exception calling XmlConfigurator.Configure method with ConfigUri ["+repositoryConfigUri+"]", ex);
+ }
+ }
}
- }
- }
- }
+ }
+ }
+ }
- /// <summary>
- /// Loads the attribute defined plugins on the assembly.
- /// </summary>
- /// <param name="assembly">The assembly that contains the attributes.</param>
- /// <param name="repository">The repository to add the plugins to.</param>
- /// <exception cref="ArgumentNullException">
- /// <para><paramref name="assembly" /> is <see langword="null" />.</para>
- /// <para>-or-</para>
- /// <para><paramref name="repository" /> is <see langword="null" />.</para>
- /// </exception>
- private void LoadPlugins(Assembly assembly, ILoggerRepository repository)
- {
- if (assembly == null)
- {
- throw new ArgumentNullException("assembly");
- }
- if (repository == null)
- {
- throw new ArgumentNullException("repository");
- }
+ /// <summary>
+ /// Loads the attribute defined plugins on the assembly.
+ /// </summary>
+ /// <param name="assembly">The assembly that contains the attributes.</param>
+ /// <param name="repository">The repository to add the plugins to.</param>
+ /// <exception cref="ArgumentNullException">
+ /// <para><paramref name="assembly" /> is <see langword="null" />.</para>
+ /// <para>-or-</para>
+ /// <para><paramref name="repository" /> is <see langword="null" />.</para>
+ /// </exception>
+ private void LoadPlugins(Assembly assembly, ILoggerRepository repository)
+ {
+ if (assembly == null)
+ {
+ throw new ArgumentNullException("assembly");
+ }
+ if (repository == null)
+ {
+ throw new ArgumentNullException("repository");
+ }
- // Look for the PluginAttribute on the assembly
+ // Look for the PluginAttribute on the assembly
#if NETSTANDARD
- object[] configAttributes = assembly.GetCustomAttributes(typeof(log4net.Config.PluginAttribute)).ToArray();
+ object[] configAttributes = assembly.GetCustomAttributes(typeof(log4net.Config.PluginAttribute)).ToArray();
#else
- object[] configAttributes = Attribute.GetCustomAttributes(assembly, typeof(log4net.Config.PluginAttribute), false);
+ object[] configAttributes = Attribute.GetCustomAttributes(assembly, typeof(log4net.Config.PluginAttribute), false);
#endif
- if (configAttributes != null && configAttributes.Length > 0)
- {
- foreach(log4net.Plugin.IPluginFactory configAttr in configAttributes)
- {
- try
- {
- // Create the plugin and add it to the repository
- repository.PluginMap.Add(configAttr.CreatePlugin());
- }
- catch(Exception ex)
- {
- LogLog.Error(declaringType, "Failed to create plugin. Attribute [" + configAttr.ToString() + "]", ex);
- }
- }
- }
- }
+ if (configAttributes != null && configAttributes.Length > 0)
+ {
+ foreach(log4net.Plugin.IPluginFactory configAttr in configAttributes)
+ {
+ try
+ {
+ // Create the plugin and add it to the repository
+ repository.PluginMap.Add(configAttr.CreatePlugin());
+ }
+ catch(Exception ex)
+ {
+ LogLog.Error(declaringType, "Failed to create plugin. Attribute [" + configAttr.ToString() + "]", ex);
+ }
+ }
+ }
+ }
- /// <summary>
- /// Loads the attribute defined aliases on the assembly.
- /// </summary>
- /// <param name="assembly">The assembly that contains the attributes.</param>
- /// <param name="repository">The repository to alias to.</param>
- /// <exception cref="ArgumentNullException">
- /// <para><paramref name="assembly" /> is <see langword="null" />.</para>
- /// <para>-or-</para>
- /// <para><paramref name="repository" /> is <see langword="null" />.</para>
- /// </exception>
- private void LoadAliases(Assembly assembly, ILoggerRepository repository)
- {
- if (assembly == null)
- {
- throw new ArgumentNullException("assembly");
- }
- if (repository == null)
- {
- throw new ArgumentNullException("repository");
- }
+ /// <summary>
+ /// Loads the attribute defined aliases on the assembly.
+ /// </summary>
+ /// <param name="assembly">The assembly that contains the attributes.</param>
+ /// <param name="repository">The repository to alias to.</param>
+ /// <exception cref="ArgumentNullException">
+ /// <para><paramref name="assembly" /> is <see langword="null" />.</para>
+ /// <para>-or-</para>
+ /// <para><paramref name="repository" /> is <see langword="null" />.</para>
+ /// </exception>
+ private void LoadAliases(Assembly assembly, ILoggerRepository repository)
+ {
+ if (assembly == null)
+ {
+ throw new ArgumentNullException("assembly");
+ }
+ if (repository == null)
+ {
+ throw new ArgumentNullException("repository");
+ }
- // Look for the AliasRepositoryAttribute on the assembly
+ // Look for the AliasRepositoryAttribute on the assembly
#if NETSTANDARD
- object[] configAttributes = assembly.GetCustomAttributes(typeof(log4net.Config.AliasRepositoryAttribute)).ToArray();
+ object[] configAttributes = assembly.GetCustomAttributes(typeof(log4net.Config.AliasRepositoryAttribute)).ToArray();
#else
- object[] configAttributes = Attribute.GetCustomAttributes(assembly, typeof(log4net.Config.AliasRepositoryAttribute), false);
+ object[] configAttributes = Attribute.GetCustomAttributes(assembly, typeof(log4net.Config.AliasRepositoryAttribute), false);
#endif
- if (configAttributes != null && configAttributes.Length > 0)
- {
- foreach(log4net.Config.AliasRepositoryAttribute configAttr in configAttributes)
- {
- try
- {
- AliasRepository(configAttr.Name, repository);
- }
- catch(Exception ex)
- {
- LogLog.Error(declaringType, "Failed to alias repository [" + configAttr.Name + "]", ex);
- }
- }
- }
- }
+ if (configAttributes != null && configAttributes.Length > 0)
+ {
+ foreach(log4net.Config.AliasRepositoryAttribute configAttr in configAttributes)
+ {
+ try
+ {
+ AliasRepository(configAttr.Name, repository);
+ }
+ catch(Exception ex)
+ {
+ LogLog.Error(declaringType, "Failed to alias repository [" + configAttr.Name + "]", ex);
+ }
+ }
+ }
+ }
- #endregion Private Instance Methods
+ #endregion Private Instance Methods
- #region Private Static Fields
+ #region Private Static Fields
/// <summary>
/// The fully qualified type of the DefaultRepositorySelector class.
@@ -893,21 +893,21 @@
/// </remarks>
private static readonly Type declaringType = typeof(DefaultRepositorySelector);
- private const string DefaultRepositoryName = "log4net-default-repository";
+ private const string DefaultRepositoryName = "log4net-default-repository";
- #endregion Private Static Fields
+ #endregion Private Static Fields
- #region Private Instance Fields
+ #region Private Instance Fields
- private readonly Hashtable m_name2repositoryMap = new Hashtable();
- private readonly Hashtable m_assembly2repositoryMap = new Hashtable();
- private readonly Hashtable m_alias2repositoryMap = new Hashtable();
- private readonly Type m_defaultRepositoryType;
+ private readonly Hashtable m_name2repositoryMap = new Hashtable();
+ private readonly Hashtable m_assembly2repositoryMap = new Hashtable();
+ private readonly Hashtable m_alias2repositoryMap = new Hashtable();
+ private readonly Type m_defaultRepositoryType;
- private event LoggerRepositoryCreationEventHandler m_loggerRepositoryCreatedEvent;
+ private event LoggerRepositoryCreationEventHandler m_loggerRepositoryCreatedEvent;
- #endregion Private Instance Fields
- }
+ #endregion Private Instance Fields
+ }
}
#endif // !NETCF
diff --git a/src/log4net/Core/ErrorCode.cs b/src/log4net/Core/ErrorCode.cs
index 9107a24..3df2581 100644
--- a/src/log4net/Core/ErrorCode.cs
+++ b/src/log4net/Core/ErrorCode.cs
@@ -21,50 +21,50 @@
namespace log4net.Core
{
- /// <summary>
- /// Defined error codes that can be passed to the <see cref="M:IErrorHandler.Error(string, Exception, ErrorCode)"/> method.
- /// </summary>
- /// <remarks>
- /// <para>
- /// Values passed to the <see cref="M:IErrorHandler.Error(string, Exception, ErrorCode)"/> method.
- /// </para>
- /// </remarks>
- /// <author>Nicko Cadell</author>
- public enum ErrorCode : int
- {
- /// <summary>
- /// A general error
- /// </summary>
- GenericFailure = 0,
+ /// <summary>
+ /// Defined error codes that can be passed to the <see cref="M:IErrorHandler.Error(string, Exception, ErrorCode)"/> method.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Values passed to the <see cref="M:IErrorHandler.Error(string, Exception, ErrorCode)"/> method.
+ /// </para>
+ /// </remarks>
+ /// <author>Nicko Cadell</author>
+ public enum ErrorCode : int
+ {
+ /// <summary>
+ /// A general error
+ /// </summary>
+ GenericFailure = 0,
- /// <summary>
- /// Error while writing output
- /// </summary>
- WriteFailure,
+ /// <summary>
+ /// Error while writing output
+ /// </summary>
+ WriteFailure,
- /// <summary>
- /// Failed to flush file
- /// </summary>
- FlushFailure,
+ /// <summary>
+ /// Failed to flush file
+ /// </summary>
+ FlushFailure,
- /// <summary>
- /// Failed to close file
- /// </summary>
- CloseFailure,
+ /// <summary>
+ /// Failed to close file
+ /// </summary>
+ CloseFailure,
- /// <summary>
- /// Unable to open output file
- /// </summary>
- FileOpenFailure,
+ /// <summary>
+ /// Unable to open output file
+ /// </summary>
+ FileOpenFailure,
- /// <summary>
- /// No layout specified
- /// </summary>
- MissingLayout,
+ /// <summary>
+ /// No layout specified
+ /// </summary>
+ MissingLayout,
- /// <summary>
- /// Failed to parse address
- /// </summary>
- AddressParseFailure
- }
+ /// <summary>
+ /// Failed to parse address
+ /// </summary>
+ AddressParseFailure
+ }
}
diff --git a/src/log4net/Core/ExceptionEvaluator.cs b/src/log4net/Core/ExceptionEvaluator.cs
index 60bac57..adaeb49 100644
--- a/src/log4net/Core/ExceptionEvaluator.cs
+++ b/src/log4net/Core/ExceptionEvaluator.cs
@@ -21,110 +21,110 @@
namespace log4net.Core
{
- /// <summary>
- /// An evaluator that triggers on an Exception type
- /// </summary>
- /// <remarks>
- /// <para>
- /// This evaluator will trigger if the type of the Exception
- /// passed to <see cref="M:IsTriggeringEvent(LoggingEvent)"/>
- /// is equal to a Type in <see cref="ExceptionType"/>. ///
- /// </para>
- /// </remarks>
- /// <author>Drew Schaeffer</author>
- public class ExceptionEvaluator : ITriggeringEventEvaluator
- {
- /// <summary>
- /// The type that causes the trigger to fire.
- /// </summary>
- private Type m_type;
+ /// <summary>
+ /// An evaluator that triggers on an Exception type
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// This evaluator will trigger if the type of the Exception
+ /// passed to <see cref="M:IsTriggeringEvent(LoggingEvent)"/>
+ /// is equal to a Type in <see cref="ExceptionType"/>. ///
+ /// </para>
+ /// </remarks>
+ /// <author>Drew Schaeffer</author>
+ public class ExceptionEvaluator : ITriggeringEventEvaluator
+ {
+ /// <summary>
+ /// The type that causes the trigger to fire.
+ /// </summary>
+ private Type m_type;
- /// <summary>
- /// Causes subclasses of <see cref="ExceptionType"/> to cause the trigger to fire.
- /// </summary>
- private bool m_triggerOnSubclass;
+ /// <summary>
+ /// Causes subclasses of <see cref="ExceptionType"/> to cause the trigger to fire.
+ /// </summary>
+ private bool m_triggerOnSubclass;
- /// <summary>
- /// Default ctor to allow dynamic creation through a configurator.
- /// </summary>
- public ExceptionEvaluator()
- {
- // empty
- }
+ /// <summary>
+ /// Default ctor to allow dynamic creation through a configurator.
+ /// </summary>
+ public ExceptionEvaluator()
+ {
+ // empty
+ }
- /// <summary>
- /// Constructs an evaluator and initializes to trigger on <paramref name="exType"/>
- /// </summary>
- /// <param name="exType">the type that triggers this evaluator.</param>
- /// <param name="triggerOnSubClass">If true, this evaluator will trigger on subclasses of <see cref="ExceptionType"/>.</param>
- public ExceptionEvaluator(Type exType, bool triggerOnSubClass)
- {
- if (exType == null)
- {
- throw new ArgumentNullException("exType");
- }
+ /// <summary>
+ /// Constructs an evaluator and initializes to trigger on <paramref name="exType"/>
+ /// </summary>
+ /// <param name="exType">the type that triggers this evaluator.</param>
+ /// <param name="triggerOnSubClass">If true, this evaluator will trigger on subclasses of <see cref="ExceptionType"/>.</param>
+ public ExceptionEvaluator(Type exType, bool triggerOnSubClass)
+ {
+ if (exType == null)
+ {
+ throw new ArgumentNullException("exType");
+ }
- m_type = exType;
- m_triggerOnSubclass = triggerOnSubClass;
- }
+ m_type = exType;
+ m_triggerOnSubclass = triggerOnSubClass;
+ }
- /// <summary>
- /// The type that triggers this evaluator.
- /// </summary>
- public Type ExceptionType
- {
- get { return m_type; }
- set { m_type = value; }
- }
+ /// <summary>
+ /// The type that triggers this evaluator.
+ /// </summary>
+ public Type ExceptionType
+ {
+ get { return m_type; }
+ set { m_type = value; }
+ }
- /// <summary>
- /// If true, this evaluator will trigger on subclasses of <see cref="ExceptionType"/>.
- /// </summary>
- public bool TriggerOnSubclass
- {
- get { return m_triggerOnSubclass; }
- set { m_triggerOnSubclass = value; }
- }
+ /// <summary>
+ /// If true, this evaluator will trigger on subclasses of <see cref="ExceptionType"/>.
+ /// </summary>
+ public bool TriggerOnSubclass
+ {
+ get { return m_triggerOnSubclass; }
+ set { m_triggerOnSubclass = value; }
+ }
- #region ITriggeringEventEvaluator Members
+ #region ITriggeringEventEvaluator Members
- /// <summary>
- /// Is this <paramref name="loggingEvent"/> the triggering event?
- /// </summary>
- /// <param name="loggingEvent">The event to check</param>
- /// <returns>This method returns <c>true</c>, if the logging event Exception
- /// Type is <see cref="ExceptionType"/>.
- /// Otherwise it returns <c>false</c></returns>
- /// <remarks>
- /// <para>
- /// This evaluator will trigger if the Exception Type of the event
- /// passed to <see cref="M:IsTriggeringEvent(LoggingEvent)"/>
- /// is <see cref="ExceptionType"/>.
- /// </para>
- /// </remarks>
- public bool IsTriggeringEvent(LoggingEvent loggingEvent)
- {
- if (loggingEvent == null)
- {
- throw new ArgumentNullException("loggingEvent");
- }
+ /// <summary>
+ /// Is this <paramref name="loggingEvent"/> the triggering event?
+ /// </summary>
+ /// <param name="loggingEvent">The event to check</param>
+ /// <returns>This method returns <c>true</c>, if the logging event Exception
+ /// Type is <see cref="ExceptionType"/>.
+ /// Otherwise it returns <c>false</c></returns>
+ /// <remarks>
+ /// <para>
+ /// This evaluator will trigger if the Exception Type of the event
+ /// passed to <see cref="M:IsTriggeringEvent(LoggingEvent)"/>
+ /// is <see cref="ExceptionType"/>.
+ /// </para>
+ /// </remarks>
+ public bool IsTriggeringEvent(LoggingEvent loggingEvent)
+ {
+ if (loggingEvent == null)
+ {
+ throw new ArgumentNullException("loggingEvent");
+ }
- if (m_triggerOnSubclass && loggingEvent.ExceptionObject != null)
- {
- // check if loggingEvent.ExceptionObject is of type ExceptionType or subclass of ExceptionType
- Type exceptionObjectType = loggingEvent.ExceptionObject.GetType();
- return exceptionObjectType == m_type || m_type.IsAssignableFrom(exceptionObjectType);
- }
- else if (!m_triggerOnSubclass && loggingEvent.ExceptionObject != null)
- { // check if loggingEvent.ExceptionObject is of type ExceptionType
- return loggingEvent.ExceptionObject.GetType() == m_type;
- }
- else
- { // loggingEvent.ExceptionObject is null
- return false;
- }
- }
+ if (m_triggerOnSubclass && loggingEvent.ExceptionObject != null)
+ {
+ // check if loggingEvent.ExceptionObject is of type ExceptionType or subclass of ExceptionType
+ Type exceptionObjectType = loggingEvent.ExceptionObject.GetType();
+ return exceptionObjectType == m_type || m_type.IsAssignableFrom(exceptionObjectType);
+ }
+ else if (!m_triggerOnSubclass && loggingEvent.ExceptionObject != null)
+ { // check if loggingEvent.ExceptionObject is of type ExceptionType
+ return loggingEvent.ExceptionObject.GetType() == m_type;
+ }
+ else
+ { // loggingEvent.ExceptionObject is null
+ return false;
+ }
+ }
- #endregion
- }
+ #endregion
+ }
}
diff --git a/src/log4net/Core/IAppenderAttachable.cs b/src/log4net/Core/IAppenderAttachable.cs
index 9c350c1..43b50c1 100644
--- a/src/log4net/Core/IAppenderAttachable.cs
+++ b/src/log4net/Core/IAppenderAttachable.cs
@@ -23,99 +23,99 @@
namespace log4net.Core
{
- /// <summary>
- /// Interface for attaching appenders to objects.
- /// </summary>
- /// <remarks>
- /// <para>
- /// Interface for attaching, removing and retrieving appenders.
- /// </para>
- /// </remarks>
- /// <author>Nicko Cadell</author>
- /// <author>Gert Driesen</author>
- public interface IAppenderAttachable
- {
- /// <summary>
- /// Attaches an appender.
- /// </summary>
- /// <param name="appender">The appender to add.</param>
- /// <remarks>
- /// <para>
- /// Add the specified appender. The implementation may
- /// choose to allow or deny duplicate appenders.
- /// </para>
- /// </remarks>
- void AddAppender(IAppender appender);
+ /// <summary>
+ /// Interface for attaching appenders to objects.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Interface for attaching, removing and retrieving appenders.
+ /// </para>
+ /// </remarks>
+ /// <author>Nicko Cadell</author>
+ /// <author>Gert Driesen</author>
+ public interface IAppenderAttachable
+ {
+ /// <summary>
+ /// Attaches an appender.
+ /// </summary>
+ /// <param name="appender">The appender to add.</param>
+ /// <remarks>
+ /// <para>
+ /// Add the specified appender. The implementation may
+ /// choose to allow or deny duplicate appenders.
+ /// </para>
+ /// </remarks>
+ void AddAppender(IAppender appender);
- /// <summary>
- /// Gets all attached appenders.
- /// </summary>
- /// <value>
- /// A collection of attached appenders.
- /// </value>
- /// <remarks>
- /// <para>
- /// Gets a collection of attached appenders.
- /// If there are no attached appenders the
- /// implementation should return an empty
- /// collection rather than <c>null</c>.
- /// </para>
- /// </remarks>
- AppenderCollection Appenders {get;}
+ /// <summary>
+ /// Gets all attached appenders.
+ /// </summary>
+ /// <value>
+ /// A collection of attached appenders.
+ /// </value>
+ /// <remarks>
+ /// <para>
+ /// Gets a collection of attached appenders.
+ /// If there are no attached appenders the
+ /// implementation should return an empty
+ /// collection rather than <c>null</c>.
+ /// </para>
+ /// </remarks>
+ AppenderCollection Appenders {get;}
- /// <summary>
- /// Gets an attached appender with the specified name.
- /// </summary>
- /// <param name="name">The name of the appender to get.</param>
- /// <returns>
- /// The appender with the name specified, or <c>null</c> if no appender with the
- /// specified name is found.
- /// </returns>
- /// <remarks>
- /// <para>
- /// Returns an attached appender with the <paramref name="name"/> specified.
- /// If no appender with the specified name is found <c>null</c> will be
- /// returned.
- /// </para>
- /// </remarks>
- IAppender GetAppender(string name);
+ /// <summary>
+ /// Gets an attached appender with the specified name.
+ /// </summary>
+ /// <param name="name">The name of the appender to get.</param>
+ /// <returns>
+ /// The appender with the name specified, or <c>null</c> if no appender with the
+ /// specified name is found.
+ /// </returns>
+ /// <remarks>
+ /// <para>
+ /// Returns an attached appender with the <paramref name="name"/> specified.
+ /// If no appender with the specified name is found <c>null</c> will be
+ /// returned.
+ /// </para>
+ /// </remarks>
+ IAppender GetAppender(string name);
- /// <summary>
- /// Removes all attached appenders.
- /// </summary>
- /// <remarks>
- /// <para>
- /// Removes and closes all attached appenders
- /// </para>
- /// </remarks>
- void RemoveAllAppenders();
+ /// <summary>
+ /// Removes all attached appenders.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Removes and closes all attached appenders
+ /// </para>
+ /// </remarks>
+ void RemoveAllAppenders();
- /// <summary>
- /// Removes the specified appender from the list of attached appenders.
- /// </summary>
- /// <param name="appender">The appender to remove.</param>
- /// <returns>The appender removed from the list</returns>
- /// <remarks>
- /// <para>
- /// The appender removed is not closed.
- /// If you are discarding the appender you must call
- /// <see cref="IAppender.Close"/> on the appender removed.
- /// </para>
- /// </remarks>
- IAppender RemoveAppender(IAppender appender);
+ /// <summary>
+ /// Removes the specified appender from the list of attached appenders.
+ /// </summary>
+ /// <param name="appender">The appender to remove.</param>
+ /// <returns>The appender removed from the list</returns>
+ /// <remarks>
+ /// <para>
+ /// The appender removed is not closed.
+ /// If you are discarding the appender you must call
+ /// <see cref="IAppender.Close"/> on the appender removed.
+ /// </para>
+ /// </remarks>
+ IAppender RemoveAppender(IAppender appender);
- /// <summary>
- /// Removes the appender with the specified name from the list of appenders.
- /// </summary>
- /// <param name="name">The name of the appender to remove.</param>
- /// <returns>The appender removed from the list</returns>
- /// <remarks>
- /// <para>
- /// The appender removed is not closed.
- /// If you are discarding the appender you must call
- /// <see cref="IAppender.Close"/> on the appender removed.
- /// </para>
- /// </remarks>
- IAppender RemoveAppender(string name);
- }
+ /// <summary>
+ /// Removes the appender with the specified name from the list of appenders.
+ /// </summary>
+ /// <param name="name">The name of the appender to remove.</param>
+ /// <returns>The appender removed from the list</returns>
+ /// <remarks>
+ /// <para>
+ /// The appender removed is not closed.
+ /// If you are discarding the appender you must call
+ /// <see cref="IAppender.Close"/> on the appender removed.
+ /// </para>
+ /// </remarks>
+ IAppender RemoveAppender(string name);
+ }
}
diff --git a/src/log4net/Core/IErrorHandler.cs b/src/log4net/Core/IErrorHandler.cs
index 763e518..06197de 100644
--- a/src/log4net/Core/IErrorHandler.cs
+++ b/src/log4net/Core/IErrorHandler.cs
@@ -21,55 +21,55 @@
namespace log4net.Core
{
- /// <summary>
- /// Appenders may delegate their error handling to an <see cref="IErrorHandler" />.
- /// </summary>
- /// <remarks>
- /// <para>
- /// Error handling is a particularly tedious to get right because by
- /// definition errors are hard to predict and to reproduce.
- /// </para>
- /// </remarks>
- /// <author>Nicko Cadell</author>
- /// <author>Gert Driesen</author>
- public interface IErrorHandler
- {
- /// <summary>
- /// Handles the error and information about the error condition is passed as
- /// a parameter.
- /// </summary>
- /// <param name="message">The message associated with the error.</param>
- /// <param name="e">The <see cref="Exception" /> that was thrown when the error occurred.</param>
- /// <param name="errorCode">The error code associated with the error.</param>
- /// <remarks>
- /// <para>
- /// Handles the error and information about the error condition is passed as
- /// a parameter.
- /// </para>
- /// </remarks>
- void Error(string message, Exception e, ErrorCode errorCode);
+ /// <summary>
+ /// Appenders may delegate their error handling to an <see cref="IErrorHandler" />.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Error handling is a particularly tedious to get right because by
+ /// definition errors are hard to predict and to reproduce.
+ /// </para>
+ /// </remarks>
+ /// <author>Nicko Cadell</author>
+ /// <author>Gert Driesen</author>
+ public interface IErrorHandler
+ {
+ /// <summary>
+ /// Handles the error and information about the error condition is passed as
+ /// a parameter.
+ /// </summary>
+ /// <param name="message">The message associated with the error.</param>
+ /// <param name="e">The <see cref="Exception" /> that was thrown when the error occurred.</param>
+ /// <param name="errorCode">The error code associated with the error.</param>
+ /// <remarks>
+ /// <para>
+ /// Handles the error and information about the error condition is passed as
+ /// a parameter.
+ /// </para>
+ /// </remarks>
+ void Error(string message, Exception e, ErrorCode errorCode);
- /// <summary>
- /// Prints the error message passed as a parameter.
- /// </summary>
- /// <param name="message">The message associated with the error.</param>
- /// <param name="e">The <see cref="Exception" /> that was thrown when the error occurred.</param>
- /// <remarks>
- /// <para>
- /// See <see cref="M:Error(string,Exception,ErrorCode)"/>.
- /// </para>
- /// </remarks>
- void Error(string message, Exception e);
+ /// <summary>
+ /// Prints the error message passed as a parameter.
+ /// </summary>
+ /// <param name="message">The message associated with the error.</param>
+ /// <param name="e">The <see cref="Exception" /> that was thrown when the error occurred.</param>
+ /// <remarks>
+ /// <para>
+ /// See <see cref="M:Error(string,Exception,ErrorCode)"/>.
+ /// </para>
+ /// </remarks>
+ void Error(string message, Exception e);
- /// <summary>
- /// Prints the error message passed as a parameter.
- /// </summary>
- /// <param name="message">The message associated with the error.</param>
- /// <remarks>
- /// <para>
- /// See <see cref="M:Error(string,Exception,ErrorCode)"/>.
- /// </para>
- /// </remarks>
- void Error(string message);
- }
+ /// <summary>
+ /// Prints the error message passed as a parameter.
+ /// </summary>
+ /// <param name="message">The message associated with the error.</param>
+ /// <remarks>
+ /// <para>
+ /// See <see cref="M:Error(string,Exception,ErrorCode)"/>.
+ /// </para>
+ /// </remarks>
+ void Error(string message);
+ }
}
diff --git a/src/log4net/Core/IFixingRequired.cs b/src/log4net/Core/IFixingRequired.cs
index 9f05b14..58e84cf 100644
--- a/src/log4net/Core/IFixingRequired.cs
+++ b/src/log4net/Core/IFixingRequired.cs
@@ -21,38 +21,38 @@
namespace log4net.Core
{
- /// <summary>
- /// Interface for objects that require fixing.
- /// </summary>
- /// <remarks>
- /// <para>
- /// Interface that indicates that the object requires fixing before it
- /// can be taken outside the context of the appender's
- /// <see cref="log4net.Appender.IAppender.DoAppend"/> method.
- /// </para>
- /// <para>
- /// When objects that implement this interface are stored
- /// in the context properties maps <see cref="log4net.GlobalContext"/>
- /// <see cref="log4net.GlobalContext.Properties"/> and <see cref="log4net.ThreadContext"/>
- /// <see cref="log4net.ThreadContext.Properties"/> are fixed
- /// (see <see cref="LoggingEvent.Fix"/>) the <see cref="GetFixedObject"/>
- /// method will be called.
- /// </para>
- /// </remarks>
- /// <author>Nicko Cadell</author>
- public interface IFixingRequired
- {
- /// <summary>
- /// Get a portable version of this object
- /// </summary>
- /// <returns>the portable instance of this object</returns>
- /// <remarks>
- /// <para>
- /// Get a portable instance object that represents the current
- /// state of this object. The portable object can be stored
- /// and logged from any thread with identical results.
- /// </para>
- /// </remarks>
- object GetFixedObject();
- }
+ /// <summary>
+ /// Interface for objects that require fixing.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Interface that indicates that the object requires fixing before it
+ /// can be taken outside the context of the appender's
+ /// <see cref="log4net.Appender.IAppender.DoAppend"/> method.
+ /// </para>
+ /// <para>
+ /// When objects that implement this interface are stored
+ /// in the context properties maps <see cref="log4net.GlobalContext"/>
+ /// <see cref="log4net.GlobalContext.Properties"/> and <see cref="log4net.ThreadContext"/>
+ /// <see cref="log4net.ThreadContext.Properties"/> are fixed
+ /// (see <see cref="LoggingEvent.Fix"/>) the <see cref="GetFixedObject"/>
+ /// method will be called.
+ /// </para>
+ /// </remarks>
+ /// <author>Nicko Cadell</author>
+ public interface IFixingRequired
+ {
+ /// <summary>
+ /// Get a portable version of this object
+ /// </summary>
+ /// <returns>the portable instance of this object</returns>
+ /// <remarks>
+ /// <para>
+ /// Get a portable instance object that represents the current
+ /// state of this object. The portable object can be stored
+ /// and logged from any thread with identical results.
+ /// </para>
+ /// </remarks>
+ object GetFixedObject();
+ }
}
diff --git a/src/log4net/Core/ILogger.cs b/src/log4net/Core/ILogger.cs
index bbb152c..b7e4514 100644
--- a/src/log4net/Core/ILogger.cs
+++ b/src/log4net/Core/ILogger.cs
@@ -24,92 +24,92 @@
namespace log4net.Core
{
- /// <summary>
- /// Interface that all loggers implement
- /// </summary>
- /// <remarks>
- /// <para>
- /// This interface supports logging events and testing if a level
- /// is enabled for logging.
- /// </para>
- /// <para>
- /// These methods will not throw exceptions. Note to implementor, ensure
- /// that the implementation of these methods cannot allow an exception
- /// to be thrown to the caller.
- /// </para>
- /// </remarks>
- /// <author>Nicko Cadell</author>
- /// <author>Gert Driesen</author>
- public interface ILogger
- {
- /// <summary>
- /// Gets the name of the logger.
- /// </summary>
- /// <value>
- /// The name of the logger.
- /// </value>
- /// <remarks>
- /// <para>
- /// The name of this logger
- /// </para>
- /// </remarks>
- string Name { get; }
+ /// <summary>
+ /// Interface that all loggers implement
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// This interface supports logging events and testing if a level
+ /// is enabled for logging.
+ /// </para>
+ /// <para>
+ /// These methods will not throw exceptions. Note to implementor, ensure
+ /// that the implementation of these methods cannot allow an exception
+ /// to be thrown to the caller.
+ /// </para>
+ /// </remarks>
+ /// <author>Nicko Cadell</author>
+ /// <author>Gert Driesen</author>
+ public interface ILogger
+ {
+ /// <summary>
+ /// Gets the name of the logger.
+ /// </summary>
+ /// <value>
+ /// The name of the logger.
+ /// </value>
+ /// <remarks>
+ /// <para>
+ /// The name of this logger
+ /// </para>
+ /// </remarks>
+ string Name { get; }
- /// <summary>
- /// This generic form is intended to be used by wrappers.
- /// </summary>
- /// <param name="callerStackBoundaryDeclaringType">The declaring type of the method that is
- /// the stack boundary into the logging system for this call.</param>
- /// <param name="level">The level of the message to be logged.</param>
- /// <param name="message">The message object to log.</param>
- /// <param name="exception">the exception to log, including its stack trace. Pass <c>null</c> to not log an exception.</param>
- /// <remarks>
- /// <para>
- /// Generates a logging event for the specified <paramref name="level"/> using
- /// the <paramref name="message"/> and <paramref name="exception"/>.
- /// </para>
- /// </remarks>
- void Log(Type callerStackBoundaryDeclaringType, Level level, object message, Exception exception);
+ /// <summary>
+ /// This generic form is intended to be used by wrappers.
+ /// </summary>
+ /// <param name="callerStackBoundaryDeclaringType">The declaring type of the method that is
+ /// the stack boundary into the logging system for this call.</param>
+ /// <param name="level">The level of the message to be logged.</param>
+ /// <param name="message">The message object to log.</param>
+ /// <param name="exception">the exception to log, including its stack trace. Pass <c>null</c> to not log an exception.</param>
+ /// <remarks>
+ /// <para>
+ /// Generates a logging event for the specified <paramref name="level"/> using
+ /// the <paramref name="message"/> and <paramref name="exception"/>.
+ /// </para>
+ /// </remarks>
+ void Log(Type callerStackBoundaryDeclaringType, Level level, object message, Exception exception);
- /// <summary>
- /// This is the most generic printing method that is intended to be used
- /// by wrappers.
- /// </summary>
- /// <param name="logEvent">The event being logged.</param>
- /// <remarks>
- /// <para>
- /// Logs the specified logging event through this logger.
- /// </para>
- /// </remarks>
- void Log(LoggingEvent logEvent);
+ /// <summary>
+ /// This is the most generic printing method that is intended to be used
+ /// by wrappers.
+ /// </summary>
+ /// <param name="logEvent">The event being logged.</param>
+ /// <remarks>
+ /// <para>
+ /// Logs the specified logging event through this logger.
+ /// </para>
+ /// </remarks>
+ void Log(LoggingEvent logEvent);
- /// <summary>
- /// Checks if this logger is enabled for a given <see cref="Level"/> passed as parameter.
- /// </summary>
- /// <param name="level">The level to check.</param>
- /// <returns>
- /// <c>true</c> if this logger is enabled for <c>level</c>, otherwise <c>false</c>.
- /// </returns>
- /// <remarks>
- /// <para>
- /// Test if this logger is going to log events of the specified <paramref name="level"/>.
- /// </para>
- /// </remarks>
- bool IsEnabledFor(Level level);
+ /// <summary>
+ /// Checks if this logger is enabled for a given <see cref="Level"/> passed as parameter.
+ /// </summary>
+ /// <param name="level">The level to check.</param>
+ /// <returns>
+ /// <c>true</c> if this logger is enabled for <c>level</c>, otherwise <c>false</c>.
+ /// </returns>
+ /// <remarks>
+ /// <para>
+ /// Test if this logger is going to log events of the specified <paramref name="level"/>.
+ /// </para>
+ /// </remarks>
+ bool IsEnabledFor(Level level);
- /// <summary>
- /// Gets the <see cref="ILoggerRepository"/> where this
- /// <c>Logger</c> instance is attached to.
- /// </summary>
- /// <value>
- /// The <see cref="ILoggerRepository" /> that this logger belongs to.
- /// </value>
- /// <remarks>
- /// <para>
- /// Gets the <see cref="ILoggerRepository"/> where this
- /// <c>Logger</c> instance is attached to.
- /// </para>
- /// </remarks>
- ILoggerRepository Repository { get; }
- }
+ /// <summary>
+ /// Gets the <see cref="ILoggerRepository"/> where this
+ /// <c>Logger</c> instance is attached to.
+ /// </summary>
+ /// <value>
+ /// The <see cref="ILoggerRepository" /> that this logger belongs to.
+ /// </value>
+ /// <remarks>
+ /// <para>
+ /// Gets the <see cref="ILoggerRepository"/> where this
+ /// <c>Logger</c> instance is attached to.
+ /// </para>
+ /// </remarks>
+ ILoggerRepository Repository { get; }
+ }
}
diff --git a/src/log4net/Core/ILoggerWrapper.cs b/src/log4net/Core/ILoggerWrapper.cs
index 735e368..fefbd20 100644
--- a/src/log4net/Core/ILoggerWrapper.cs
+++ b/src/log4net/Core/ILoggerWrapper.cs
@@ -25,35 +25,35 @@
namespace log4net.Core
{
- /// <summary>
- /// Base interface for all wrappers
- /// </summary>
- /// <remarks>
- /// <para>
- /// Base interface for all wrappers.
- /// </para>
- /// <para>
- /// All wrappers must implement this interface.
- /// </para>
- /// </remarks>
- /// <author>Nicko Cadell</author>
- public interface ILoggerWrapper
- {
- /// <summary>
- /// Get the implementation behind this wrapper object.
- /// </summary>
- /// <value>
- /// The <see cref="ILogger"/> object that in implementing this object.
- /// </value>
- /// <remarks>
- /// <para>
- /// The <see cref="ILogger"/> object that in implementing this
- /// object. The <c>Logger</c> object may not
- /// be the same object as this object because of logger decorators.
- /// This gets the actual underlying objects that is used to process
- /// the log events.
- /// </para>
- /// </remarks>
- ILogger Logger { get; }
- }
+ /// <summary>
+ /// Base interface for all wrappers
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Base interface for all wrappers.
+ /// </para>
+ /// <para>
+ /// All wrappers must implement this interface.
+ /// </para>
+ /// </remarks>
+ /// <author>Nicko Cadell</author>
+ public interface ILoggerWrapper
+ {
+ /// <summary>
+ /// Get the implementation behind this wrapper object.
+ /// </summary>
+ /// <value>
+ /// The <see cref="ILogger"/> object that in implementing this object.
+ /// </value>
+ /// <remarks>
+ /// <para>
+ /// The <see cref="ILogger"/> object that in implementing this
+ /// object. The <c>Logger</c> object may not
+ /// be the same object as this object because of logger decorators.
+ /// This gets the actual underlying objects that is used to process
+ /// the log events.
+ /// </para>
+ /// </remarks>
+ ILogger Logger { get; }
+ }
}
diff --git a/src/log4net/Core/IOptionHandler.cs b/src/log4net/Core/IOptionHandler.cs
index cdc4682..6d73ee1 100644
--- a/src/log4net/Core/IOptionHandler.cs
+++ b/src/log4net/Core/IOptionHandler.cs
@@ -21,38 +21,38 @@
namespace log4net.Core
{
- /// <summary>
- /// Interface used to delay activate a configured object.
- /// </summary>
- /// <remarks>
- /// <para>
- /// This allows an object to defer activation of its options until all
- /// options have been set. This is required for components which have
- /// related options that remain ambiguous until all are set.
- /// </para>
- /// <para>
- /// If a component implements this interface then the <see cref="ActivateOptions"/> method
- /// must be called by the container after its all the configured properties have been set
- /// and before the component can be used.
- /// </para>
- /// </remarks>
- /// <author>Nicko Cadell</author>
- public interface IOptionHandler
- {
- /// <summary>
- /// Activate the options that were previously set with calls to properties.
- /// </summary>
- /// <remarks>
- /// <para>
- /// This allows an object to defer activation of its options until all
- /// options have been set. This is required for components which have
- /// related options that remain ambiguous until all are set.
- /// </para>
- /// <para>
- /// If a component implements this interface then this method must be called
- /// after its properties have been set before the component can be used.
- /// </para>
- /// </remarks>
- void ActivateOptions();
- }
+ /// <summary>
+ /// Interface used to delay activate a configured object.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// This allows an object to defer activation of its options until all
+ /// options have been set. This is required for components which have
+ /// related options that remain ambiguous until all are set.
+ /// </para>
+ /// <para>
+ /// If a component implements this interface then the <see cref="ActivateOptions"/> method
+ /// must be called by the container after its all the configured properties have been set
+ /// and before the component can be used.
+ /// </para>
+ /// </remarks>
+ /// <author>Nicko Cadell</author>
+ public interface IOptionHandler
+ {
+ /// <summary>
+ /// Activate the options that were previously set with calls to properties.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// This allows an object to defer activation of its options until all
+ /// options have been set. This is required for components which have
+ /// related options that remain ambiguous until all are set.
+ /// </para>
+ /// <para>
+ /// If a component implements this interface then this method must be called
+ /// after its properties have been set before the component can be used.
+ /// </para>
+ /// </remarks>
+ void ActivateOptions();
+ }
}
diff --git a/src/log4net/Core/IRepositorySelector.cs b/src/log4net/Core/IRepositorySelector.cs
index 55e393a..4e34839 100644
--- a/src/log4net/Core/IRepositorySelector.cs
+++ b/src/log4net/Core/IRepositorySelector.cs
@@ -24,190 +24,190 @@
namespace log4net.Core
{
- #region LoggerRepositoryCreationEvent
+ #region LoggerRepositoryCreationEvent
- /// <summary>
- /// Delegate used to handle logger repository creation event notifications
- /// </summary>
- /// <param name="sender">The <see cref="IRepositorySelector"/> which created the repository.</param>
- /// <param name="e">The <see cref="LoggerRepositoryCreationEventArgs"/> event args
- /// that holds the <see cref="ILoggerRepository"/> instance that has been created.</param>
- /// <remarks>
- /// <para>
- /// Delegate used to handle logger repository creation event notifications.
- /// </para>
- /// </remarks>
- public delegate void LoggerRepositoryCreationEventHandler(object sender, LoggerRepositoryCreationEventArgs e);
+ /// <summary>
+ /// Delegate used to handle logger repository creation event notifications
+ /// </summary>
+ /// <param name="sender">The <see cref="IRepositorySelector"/> which created the repository.</param>
+ /// <param name="e">The <see cref="LoggerRepositoryCreationEventArgs"/> event args
+ /// that holds the <see cref="ILoggerRepository"/> instance that has been created.</param>
+ /// <remarks>
+ /// <para>
+ /// Delegate used to handle logger repository creation event notifications.
+ /// </para>
+ /// </remarks>
+ public delegate void LoggerRepositoryCreationEventHandler(object sender, LoggerRepositoryCreationEventArgs e);
- /// <summary>
- /// Provides data for the <see cref="IRepositorySelector.LoggerRepositoryCreatedEvent"/> event.
- /// </summary>
- /// <remarks>
- /// <para>
- /// A <see cref="IRepositorySelector.LoggerRepositoryCreatedEvent"/>
- /// event is raised every time a <see cref="ILoggerRepository"/> is created.
- /// </para>
- /// </remarks>
- public class LoggerRepositoryCreationEventArgs : EventArgs
- {
- /// <summary>
- /// The <see cref="ILoggerRepository"/> created
- /// </summary>
- private ILoggerRepository m_repository;
+ /// <summary>
+ /// Provides data for the <see cref="IRepositorySelector.LoggerRepositoryCreatedEvent"/> event.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// A <see cref="IRepositorySelector.LoggerRepositoryCreatedEvent"/>
+ /// event is raised every time a <see cref="ILoggerRepository"/> is created.
+ /// </para>
+ /// </remarks>
+ public class LoggerRepositoryCreationEventArgs : EventArgs
+ {
+ /// <summary>
+ /// The <see cref="ILoggerRepository"/> created
+ /// </summary>
+ private ILoggerRepository m_repository;
- /// <summary>
- /// Construct instance using <see cref="ILoggerRepository"/> specified
- /// </summary>
- /// <param name="repository">the <see cref="ILoggerRepository"/> that has been created</param>
- /// <remarks>
- /// <para>
- /// Construct instance using <see cref="ILoggerRepository"/> specified
- /// </para>
- /// </remarks>
- public LoggerRepositoryCreationEventArgs(ILoggerRepository repository)
- {
- m_repository = repository;
- }
+ /// <summary>
+ /// Construct instance using <see cref="ILoggerRepository"/> specified
+ /// </summary>
+ /// <param name="repository">the <see cref="ILoggerRepository"/> that has been created</param>
+ /// <remarks>
+ /// <para>
+ /// Construct instance using <see cref="ILoggerRepository"/> specified
+ /// </para>
+ /// </remarks>
+ public LoggerRepositoryCreationEventArgs(ILoggerRepository repository)
+ {
+ m_repository = repository;
+ }
- /// <summary>
- /// The <see cref="ILoggerRepository"/> that has been created
- /// </summary>
- /// <value>
- /// The <see cref="ILoggerRepository"/> that has been created
- /// </value>
- /// <remarks>
- /// <para>
- /// The <see cref="ILoggerRepository"/> that has been created
- /// </para>
- /// </remarks>
- public ILoggerRepository LoggerRepository
- {
- get { return m_repository; }
- }
- }
+ /// <summary>
+ /// The <see cref="ILoggerRepository"/> that has been created
+ /// </summary>
+ /// <value>
+ /// The <see cref="ILoggerRepository"/> that has been created
+ /// </value>
+ /// <remarks>
+ /// <para>
+ /// The <see cref="ILoggerRepository"/> that has been created
+ /// </para>
+ /// </remarks>
+ public ILoggerRepository LoggerRepository
+ {
+ get { return m_repository; }
+ }
+ }
- #endregion
+ #endregion
- /// <summary>
- /// Interface used by the <see cref="LogManager"/> to select the <see cref="ILoggerRepository"/>.
- /// </summary>
- /// <remarks>
- /// <para>
- /// The <see cref="LogManager"/> uses a <see cref="IRepositorySelector"/>
- /// to specify the policy for selecting the correct <see cref="ILoggerRepository"/>
- /// to return to the caller.
- /// </para>
- /// </remarks>
- /// <author>Nicko Cadell</author>
- /// <author>Gert Driesen</author>
- public interface IRepositorySelector
- {
- /// <summary>
- /// Gets the <see cref="ILoggerRepository"/> for the specified assembly.
- /// </summary>
- /// <param name="assembly">The assembly to use to lookup to the <see cref="ILoggerRepository"/></param>
- /// <returns>The <see cref="ILoggerRepository"/> for the assembly.</returns>
- /// <remarks>
- /// <para>
- /// Gets the <see cref="ILoggerRepository"/> for the specified assembly.
- /// </para>
- /// <para>
- /// How the association between <see cref="Assembly"/> and <see cref="ILoggerRepository"/>
- /// is made is not defined. The implementation may choose any method for
- /// this association. The results of this method must be repeatable, i.e.
- /// when called again with the same arguments the result must be the
- /// save value.
- /// </para>
- /// </remarks>
- ILoggerRepository GetRepository(Assembly assembly);
+ /// <summary>
+ /// Interface used by the <see cref="LogManager"/> to select the <see cref="ILoggerRepository"/>.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// The <see cref="LogManager"/> uses a <see cref="IRepositorySelector"/>
+ /// to specify the policy for selecting the correct <see cref="ILoggerRepository"/>
+ /// to return to the caller.
+ /// </para>
+ /// </remarks>
+ /// <author>Nicko Cadell</author>
+ /// <author>Gert Driesen</author>
+ public interface IRepositorySelector
+ {
+ /// <summary>
+ /// Gets the <see cref="ILoggerRepository"/> for the specified assembly.
+ /// </summary>
+ /// <param name="assembly">The assembly to use to lookup to the <see cref="ILoggerRepository"/></param>
+ /// <returns>The <see cref="ILoggerRepository"/> for the assembly.</returns>
+ /// <remarks>
+ /// <para>
+ /// Gets the <see cref="ILoggerRepository"/> for the specified assembly.
+ /// </para>
+ /// <para>
+ /// How the association between <see cref="Assembly"/> and <see cref="ILoggerRepository"/>
+ /// is made is not defined. The implementation may choose any method for
+ /// this association. The results of this method must be repeatable, i.e.
+ /// when called again with the same arguments the result must be the
+ /// save value.
+ /// </para>
+ /// </remarks>
+ ILoggerRepository GetRepository(Assembly assembly);
- /// <summary>
- /// Gets the named <see cref="ILoggerRepository"/>.
- /// </summary>
- /// <param name="repositoryName">The name to use to lookup to the <see cref="ILoggerRepository"/>.</param>
- /// <returns>The named <see cref="ILoggerRepository"/></returns>
- /// <remarks>
- /// Lookup a named <see cref="ILoggerRepository"/>. This is the repository created by
- /// calling <see cref="M:CreateRepository(string,Type)"/>.
- /// </remarks>
- ILoggerRepository GetRepository(string repositoryName);
+ /// <summary>
+ /// Gets the named <see cref="ILoggerRepository"/>.
+ /// </summary>
+ /// <param name="repositoryName">The name to use to lookup to the <see cref="ILoggerRepository"/>.</param>
+ /// <returns>The named <see cref="ILoggerRepository"/></returns>
+ /// <remarks>
+ /// Lookup a named <see cref="ILoggerRepository"/>. This is the repository created by
+ /// calling <see cref="M:CreateRepository(string,Type)"/>.
+ /// </remarks>
+ ILoggerRepository GetRepository(string repositoryName);
- /// <summary>
- /// Creates a new repository for the assembly specified.
- /// </summary>
- /// <param name="assembly">The assembly to use to create the domain to associate with the <see cref="ILoggerRepository"/>.</param>
- /// <param name="repositoryType">The type of repository to create, must implement <see cref="ILoggerRepository"/>.</param>
- /// <returns>The repository created.</returns>
- /// <remarks>
- /// <para>
- /// The <see cref="ILoggerRepository"/> created will be associated with the domain
- /// specified such that a call to <see cref="M:GetRepository(Assembly)"/> with the
- /// same assembly specified will return the same repository instance.
- /// </para>
- /// <para>
- /// How the association between <see cref="Assembly"/> and <see cref="ILoggerRepository"/>
- /// is made is not defined. The implementation may choose any method for
- /// this association.
- /// </para>
- /// </remarks>
- ILoggerRepository CreateRepository(Assembly assembly, Type repositoryType);
+ /// <summary>
+ /// Creates a new repository for the assembly specified.
+ /// </summary>
+ /// <param name="assembly">The assembly to use to create the domain to associate with the <see cref="ILoggerRepository"/>.</param>
+ /// <param name="repositoryType">The type of repository to create, must implement <see cref="ILoggerRepository"/>.</param>
+ /// <returns>The repository created.</returns>
+ /// <remarks>
+ /// <para>
+ /// The <see cref="ILoggerRepository"/> created will be associated with the domain
+ /// specified such that a call to <see cref="M:GetRepository(Assembly)"/> with the
+ /// same assembly specified will return the same repository instance.
+ /// </para>
+ /// <para>
+ /// How the association between <see cref="Assembly"/> and <see cref="ILoggerRepository"/>
+ /// is made is not defined. The implementation may choose any method for
+ /// this association.
+ /// </para>
+ /// </remarks>
+ ILoggerRepository CreateRepository(Assembly assembly, Type repositoryType);
- /// <summary>
- /// Creates a new repository with the name specified.
- /// </summary>
- /// <param name="repositoryName">The name to associate with the <see cref="ILoggerRepository"/>.</param>
- /// <param name="repositoryType">The type of repository to create, must implement <see cref="ILoggerRepository"/>.</param>
- /// <returns>The repository created.</returns>
- /// <remarks>
- /// <para>
- /// The <see cref="ILoggerRepository"/> created will be associated with the name
- /// specified such that a call to <see cref="M:GetRepository(string)"/> with the
- /// same name will return the same repository instance.
- /// </para>
- /// </remarks>
- ILoggerRepository CreateRepository(string repositoryName, Type repositoryType);
+ /// <summary>
+ /// Creates a new repository with the name specified.
+ /// </summary>
+ /// <param name="repositoryName">The name to associate with the <see cref="ILoggerRepository"/>.</param>
+ /// <param name="repositoryType">The type of repository to create, must implement <see cref="ILoggerRepository"/>.</param>
+ /// <returns>The repository created.</returns>
+ /// <remarks>
+ /// <para>
+ /// The <see cref="ILoggerRepository"/> created will be associated with the name
+ /// specified such that a call to <see cref="M:GetRepository(string)"/> with the
+ /// same name will return the same repository instance.
+ /// </para>
+ /// </remarks>
+ ILoggerRepository CreateRepository(string repositoryName, Type repositoryType);
- /// <summary>
- /// Test if a named repository exists
- /// </summary>
- /// <param name="repositoryName">the named repository to check</param>
- /// <returns><c>true</c> if the repository exists</returns>
- /// <remarks>
- /// <para>
- /// Test if a named repository exists. Use <see cref="M:CreateRepository(Assembly, Type)"/>
- /// to create a new repository and <see cref="M:GetRepository(Assembly)"/> to retrieve
- /// a repository.
- /// </para>
- /// </remarks>
- bool ExistsRepository(string repositoryName);
+ /// <summary>
+ /// Test if a named repository exists
+ /// </summary>
+ /// <param name="repositoryName">the named repository to check</param>
+ /// <returns><c>true</c> if the repository exists</returns>
+ /// <remarks>
+ /// <para>
+ /// Test if a named repository exists. Use <see cref="M:CreateRepository(Assembly, Type)"/>
+ /// to create a new repository and <see cref="M:GetRepository(Assembly)"/> to retrieve
+ /// a repository.
+ /// </para>
+ /// </remarks>
+ bool ExistsRepository(string repositoryName);
- /// <summary>
- /// Gets an array of all currently defined repositories.
- /// </summary>
- /// <returns>
- /// An array of the <see cref="ILoggerRepository"/> instances created by
- /// this <see cref="IRepositorySelector"/>.</returns>
- /// <remarks>
- /// <para>
- /// Gets an array of all of the repositories created by this selector.
- /// </para>
- /// </remarks>
- ILoggerRepository[] GetAllRepositories();
+ /// <summary>
+ /// Gets an array of all currently defined repositories.
+ /// </summary>
+ /// <returns>
+ /// An array of the <see cref="ILoggerRepository"/> instances created by
+ /// this <see cref="IRepositorySelector"/>.</returns>
+ /// <remarks>
+ /// <para>
+ /// Gets an array of all of the repositories created by this selector.
+ /// </para>
+ /// </remarks>
+ ILoggerRepository[] GetAllRepositories();
- /// <summary>
- /// Event to notify that a logger repository has been created.
- /// </summary>
- /// <value>
- /// Event to notify that a logger repository has been created.
- /// </value>
- /// <remarks>
- /// <para>
- /// Event raised when a new repository is created.
- /// The event source will be this selector. The event args will
- /// be a <see cref="LoggerRepositoryCreationEventArgs"/> which
- /// holds the newly created <see cref="ILoggerRepository"/>.
- /// </para>
- /// </remarks>
- event LoggerRepositoryCreationEventHandler LoggerRepositoryCreatedEvent;
- }
+ /// <summary>
+ /// Event to notify that a logger repository has been created.
+ /// </summary>
+ /// <value>
+ /// Event to notify that a logger repository has been created.
+ /// </value>
+ /// <remarks>
+ /// <para>
+ /// Event raised when a new repository is created.
+ /// The event source will be this selector. The event args will
+ /// be a <see cref="LoggerRepositoryCreationEventArgs"/> which
+ /// holds the newly created <see cref="ILoggerRepository"/>.
+ /// </para>
+ /// </remarks>
+ event LoggerRepositoryCreationEventHandler LoggerRepositoryCreatedEvent;
+ }
}
diff --git a/src/log4net/Core/ITriggeringEventEvaluator.cs b/src/log4net/Core/ITriggeringEventEvaluator.cs
index baa7536..2063c34 100644
--- a/src/log4net/Core/ITriggeringEventEvaluator.cs
+++ b/src/log4net/Core/ITriggeringEventEvaluator.cs
@@ -21,31 +21,31 @@
namespace log4net.Core
{
- /// <summary>
- /// Test if an <see cref="LoggingEvent"/> triggers an action
- /// </summary>
- /// <remarks>
- /// <para>
- /// Implementations of this interface allow certain appenders to decide
- /// when to perform an appender specific action.
- /// </para>
- /// <para>
- /// The action or behavior triggered is defined by the implementation.
- /// </para>
- /// </remarks>
- /// <author>Nicko Cadell</author>
- public interface ITriggeringEventEvaluator
- {
- /// <summary>
- /// Test if this event triggers the action
- /// </summary>
- /// <param name="loggingEvent">The event to check</param>
- /// <returns><c>true</c> if this event triggers the action, otherwise <c>false</c></returns>
- /// <remarks>
- /// <para>
- /// Return <c>true</c> if this event triggers the action
- /// </para>
- /// </remarks>
- bool IsTriggeringEvent(LoggingEvent loggingEvent);
- }
+ /// <summary>
+ /// Test if an <see cref="LoggingEvent"/> triggers an action
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Implementations of this interface allow certain appenders to decide
+ /// when to perform an appender specific action.
+ /// </para>
+ /// <para>
+ /// The action or behavior triggered is defined by the implementation.
+ /// </para>
+ /// </remarks>
+ /// <author>Nicko Cadell</author>
+ public interface ITriggeringEventEvaluator
+ {
+ /// <summary>
+ /// Test if this event triggers the action
+ /// </summary>
+ /// <param name="loggingEvent">The event to check</param>
+ /// <returns><c>true</c> if this event triggers the action, otherwise <c>false</c></returns>
+ /// <remarks>
+ /// <para>
+ /// Return <c>true</c> if this event triggers the action
+ /// </para>
+ /// </remarks>
+ bool IsTriggeringEvent(LoggingEvent loggingEvent);
+ }
}
diff --git a/src/log4net/Core/Level.cs b/src/log4net/Core/Level.cs
index 767d03e..ced11f8 100644
--- a/src/log4net/Core/Level.cs
+++ b/src/log4net/Core/Level.cs
@@ -22,485 +22,485 @@
namespace log4net.Core
{
- /// <summary>
- /// Defines the default set of levels recognized by the system.
- /// </summary>
- /// <remarks>
- /// <para>
- /// Each <see cref="LoggingEvent"/> has an associated <see cref="Level"/>.
- /// </para>
- /// <para>
- /// Levels have a numeric <see cref="Level.Value"/> that defines the relative
- /// ordering between levels. Two Levels with the same <see cref="Level.Value"/>
- /// are deemed to be equivalent.
- /// </para>
- /// <para>
- /// The levels that are recognized by log4net are set for each <see cref="log4net.Repository.ILoggerRepository"/>
- /// and each repository can have different levels defined. The levels are stored
- /// in the <see cref="log4net.Repository.ILoggerRepository.LevelMap"/> on the repository. Levels are
- /// looked up by name from the <see cref="log4net.Repository.ILoggerRepository.LevelMap"/>.
- /// </para>
- /// <para>
- /// When logging at level INFO the actual level used is not <see cref="Level.Info"/> but
- /// the value of <c>LoggerRepository.LevelMap["INFO"]</c>. The default value for this is
- /// <see cref="Level.Info"/>, but this can be changed by reconfiguring the level map.
- /// </para>
- /// <para>
- /// Each level has a <see cref="DisplayName"/> in addition to its <see cref="Name"/>. The
- /// <see cref="DisplayName"/> is the string that is written into the output log. By default
- /// the display name is the same as the level name, but this can be used to alias levels
- /// or to localize the log output.
- /// </para>
- /// <para>
- /// Some of the predefined levels recognized by the system are:
- /// </para>
- /// <list type="bullet">
- /// <item>
- /// <description><see cref="Off"/>.</description>
- /// </item>
- /// <item>
- /// <description><see cref="Fatal"/>.</description>
- /// </item>
- /// <item>
- /// <description><see cref="Error"/>.</description>
- /// </item>
- /// <item>
- /// <description><see cref="Warn"/>.</description>
- /// </item>
- /// <item>
- /// <description><see cref="Info"/>.</description>
- /// </item>
- /// <item>
- /// <description><see cref="Debug"/>.</description>
- /// </item>
- /// <item>
- /// <description><see cref="All"/>.</description>
- /// </item>
- /// </list>
- /// </remarks>
- /// <author>Nicko Cadell</author>
- /// <author>Gert Driesen</author>
+ /// <summary>
+ /// Defines the default set of levels recognized by the system.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Each <see cref="LoggingEvent"/> has an associated <see cref="Level"/>.
+ /// </para>
+ /// <para>
+ /// Levels have a numeric <see cref="Level.Value"/> that defines the relative
+ /// ordering between levels. Two Levels with the same <see cref="Level.Value"/>
+ /// are deemed to be equivalent.
+ /// </para>
+ /// <para>
+ /// The levels that are recognized by log4net are set for each <see cref="log4net.Repository.ILoggerRepository"/>
+ /// and each repository can have different levels defined. The levels are stored
+ /// in the <see cref="log4net.Repository.ILoggerRepository.LevelMap"/> on the repository. Levels are
+ /// looked up by name from the <see cref="log4net.Repository.ILoggerRepository.LevelMap"/>.
+ /// </para>
+ /// <para>
+ /// When logging at level INFO the actual level used is not <see cref="Level.Info"/> but
+ /// the value of <c>LoggerRepository.LevelMap["INFO"]</c>. The default value for this is
+ /// <see cref="Level.Info"/>, but this can be changed by reconfiguring the level map.
+ /// </para>
+ /// <para>
+ /// Each level has a <see cref="DisplayName"/> in addition to its <see cref="Name"/>. The
+ /// <see cref="DisplayName"/> is the string that is written into the output log. By default
+ /// the display name is the same as the level name, but this can be used to alias levels
+ /// or to localize the log output.
+ /// </para>
+ /// <para>
+ /// Some of the predefined levels recognized by the system are:
+ /// </para>
+ /// <list type="bullet">
+ /// <item>
+ /// <description><see cref="Off"/>.</description>
+ /// </item>
+ /// <item>
+ /// <description><see cref="Fatal"/>.</description>
+ /// </item>
+ /// <item>
+ /// <description><see cref="Error"/>.</description>
+ /// </item>
+ /// <item>
+ /// <description><see cref="Warn"/>.</description>
+ /// </item>
+ /// <item>
+ /// <description><see cref="Info"/>.</description>
+ /// </item>
+ /// <item>
+ /// <description><see cref="Debug"/>.</description>
+ /// </item>
+ /// <item>
+ /// <description><see cref="All"/>.</description>
+ /// </item>
+ /// </list>
+ /// </remarks>
+ /// <author>Nicko Cadell</author>
+ /// <author>Gert Driesen</author>
#if !NETCF
- [Serializable]
+ [Serializable]
#endif
- public sealed class Level : IComparable
- {
- #region Public Instance Constructors
+ public sealed class Level : IComparable
+ {
+ #region Public Instance Constructors
- /// <summary>
- /// Constructor
- /// </summary>
- /// <param name="level">Integer value for this level, higher values represent more severe levels.</param>
- /// <param name="levelName">The string name of this level.</param>
- /// <param name="displayName">The display name for this level. This may be localized or otherwise different from the name</param>
- /// <remarks>
- /// <para>
- /// Initializes a new instance of the <see cref="Level" /> class with
- /// the specified level name and value.
- /// </para>
- /// </remarks>
- public Level(int level, string levelName, string displayName)
- {
- if (levelName == null)
- {
- throw new ArgumentNullException("levelName");
- }
- if (displayName == null)
- {
- throw new ArgumentNullException("displayName");
- }
+ /// <summary>
+ /// Constructor
+ /// </summary>
+ /// <param name="level">Integer value for this level, higher values represent more severe levels.</param>
+ /// <param name="levelName">The string name of this level.</param>
+ /// <param name="displayName">The display name for this level. This may be localized or otherwise different from the name</param>
+ /// <remarks>
+ /// <para>
+ /// Initializes a new instance of the <see cref="Level" /> class with
+ /// the specified level name and value.
+ /// </para>
+ /// </remarks>
+ public Level(int level, string levelName, string displayName)
+ {
+ if (levelName == null)
+ {
+ throw new ArgumentNullException("levelName");
+ }
+ if (displayName == null)
+ {
+ throw new ArgumentNullException("displayName");
+ }
- m_levelValue = level;
+ m_levelValue = level;
#if NETSTANDARD1_3
- m_levelName = levelName;
+ m_levelName = levelName;
#else
- m_levelName = string.Intern(levelName);
+ m_levelName = string.Intern(levelName);
#endif
- m_levelDisplayName = displayName;
- }
+ m_levelDisplayName = displayName;
+ }
- /// <summary>
- /// Constructor
- /// </summary>
- /// <param name="level">Integer value for this level, higher values represent more severe levels.</param>
- /// <param name="levelName">The string name of this level.</param>
- /// <remarks>
- /// <para>
- /// Initializes a new instance of the <see cref="Level" /> class with
- /// the specified level name and value.
- /// </para>
- /// </remarks>
- public Level(int level, string levelName) : this(level, levelName, levelName)
- {
- }
+ /// <summary>
+ /// Constructor
+ /// </summary>
+ /// <param name="level">Integer value for this level, higher values represent more severe levels.</param>
+ /// <param name="levelName">The string name of this level.</param>
+ /// <remarks>
+ /// <para>
+ /// Initializes a new instance of the <see cref="Level" /> class with
+ /// the specified level name and value.
+ /// </para>
+ /// </remarks>
+ public Level(int level, string levelName) : this(level, levelName, levelName)
+ {
+ }
- #endregion Public Instance Constructors
+ #endregion Public Instance Constructors
- #region Public Instance Properties
+ #region Public Instance Properties
- /// <summary>
- /// Gets the name of this level.
- /// </summary>
- /// <value>
- /// The name of this level.
- /// </value>
- /// <remarks>
- /// <para>
- /// Gets the name of this level.
- /// </para>
- /// </remarks>
- public string Name
- {
- get { return m_levelName; }
- }
+ /// <summary>
+ /// Gets the name of this level.
+ /// </summary>
+ /// <value>
+ /// The name of this level.
+ /// </value>
+ /// <remarks>
+ /// <para>
+ /// Gets the name of this level.
+ /// </para>
+ /// </remarks>
+ public string Name
+ {
+ get { return m_levelName; }
+ }
- /// <summary>
- /// Gets the value of this level.
- /// </summary>
- /// <value>
- /// The value of this level.
- /// </value>
- /// <remarks>
- /// <para>
- /// Gets the value of this level.
- /// </para>
- /// </remarks>
- public int Value
- {
- get { return m_levelValue; }
- }
+ /// <summary>
+ /// Gets the value of this level.
+ /// </summary>
+ /// <value>
+ /// The value of this level.
+ /// </value>
+ /// <remarks>
+ /// <para>
+ /// Gets the value of this level.
+ /// </para>
+ /// </remarks>
+ public int Value
+ {
+ get { return m_levelValue; }
+ }
- /// <summary>
- /// Gets the display name of this level.
- /// </summary>
- /// <value>
- /// The display name of this level.
- /// </value>
- /// <remarks>
- /// <para>
- /// Gets the display name of this level.
- /// </para>
- /// </remarks>
- public string DisplayName
- {
- get { return m_levelDisplayName; }
- }
+ /// <summary>
+ /// Gets the display name of this level.
+ /// </summary>
+ /// <value>
+ /// The display name of this level.
+ /// </value>
+ /// <remarks>
+ /// <para>
+ /// Gets the display name of this level.
+ /// </para>
+ /// </remarks>
+ public string DisplayName
+ {
+ get { return m_levelDisplayName; }
+ }
- #endregion Public Instance Properties
+ #endregion Public Instance Properties
- #region Override implementation of Object
+ #region Override implementation of Object
- /// <summary>
- /// Returns the <see cref="string" /> representation of the current
- /// <see cref="Level" />.
- /// </summary>
- /// <returns>
- /// A <see cref="string" /> representation of the current <see cref="Level" />.
- /// </returns>
- /// <remarks>
- /// <para>
- /// Returns the level <see cref="Name"/>.
- /// </para>
- /// </remarks>
- public override string ToString()
- {
- return m_levelName;
- }
+ /// <summary>
+ /// Returns the <see cref="string" /> representation of the current
+ /// <see cref="Level" />.
+ /// </summary>
+ /// <returns>
+ /// A <see cref="string" /> representation of the current <see cref="Level" />.
+ /// </returns>
+ /// <remarks>
+ /// <para>
+ /// Returns the level <see cref="Name"/>.
+ /// </para>
+ /// </remarks>
+ public override string ToString()
+ {
+ return m_levelName;
+ }
- /// <summary>
- /// Compares levels.
- /// </summary>
- /// <param name="o">The object to compare against.</param>
- /// <returns><c>true</c> if the objects are equal.</returns>
- /// <remarks>
- /// <para>
- /// Compares the levels of <see cref="Level" /> instances, and
- /// defers to base class if the target object is not a <see cref="Level" />
- /// instance.
- /// </para>
- /// </remarks>
- public override bool Equals(object o)
- {
- Level otherLevel = o as Level;
- if (otherLevel != null)
- {
- return m_levelValue == otherLevel.m_levelValue;
- }
- else
- {
- return base.Equals(o);
- }
- }
+ /// <summary>
+ /// Compares levels.
+ /// </summary>
+ /// <param name="o">The object to compare against.</param>
+ /// <returns><c>true</c> if the objects are equal.</returns>
+ /// <remarks>
+ /// <para>
+ /// Compares the levels of <see cref="Level" /> instances, and
+ /// defers to base class if the target object is not a <see cref="Level" />
+ /// instance.
+ /// </para>
+ /// </remarks>
+ public override bool Equals(object o)
+ {
+ Level otherLevel = o as Level;
+ if (otherLevel != null)
+ {
+ return m_levelValue == otherLevel.m_levelValue;
+ }
+ else
+ {
+ return base.Equals(o);
+ }
+ }
- /// <summary>
- /// Returns a hash code
- /// </summary>
- /// <returns>A hash code for the current <see cref="Level" />.</returns>
- /// <remarks>
- /// <para>
- /// Returns a hash code suitable for use in hashing algorithms and data
- /// structures like a hash table.
- /// </para>
- /// <para>
- /// Returns the hash code of the level <see cref="Value"/>.
- /// </para>
- /// </remarks>
- public override int GetHashCode()
- {
- return m_levelValue;
- }
+ /// <summary>
+ /// Returns a hash code
+ /// </summary>
+ /// <returns>A hash code for the current <see cref="Level" />.</returns>
+ /// <remarks>
+ /// <para>
+ /// Returns a hash code suitable for use in hashing algorithms and data
+ /// structures like a hash table.
+ /// </para>
+ /// <para>
+ /// Returns the hash code of the level <see cref="Value"/>.
+ /// </para>
+ /// </remarks>
+ public override int GetHashCode()
+ {
+ return m_levelValue;
+ }
- #endregion Override implementation of Object
+ #endregion Override implementation of Object
- #region Implementation of IComparable
+ #region Implementation of IComparable
- /// <summary>
- /// Compares this instance to a specified object and returns an
- /// indication of their relative values.
- /// </summary>
- /// <param name="r">A <see cref="Level"/> instance or <see langword="null" /> to compare with this instance.</param>
- /// <returns>
- /// A 32-bit signed integer that indicates the relative order of the
- /// values compared. The return value has these meanings:
- /// <list type="table">
- /// <listheader>
- /// <term>Value</term>
- /// <description>Meaning</description>
- /// </listheader>
- /// <item>
- /// <term>Less than zero</term>
- /// <description>This instance is less than <paramref name="r" />.</description>
- /// </item>
- /// <item>
- /// <term>Zero</term>
- /// <description>This instance is equal to <paramref name="r" />.</description>
- /// </item>
- /// <item>
- /// <term>Greater than zero</term>
- /// <description>
- /// <para>This instance is greater than <paramref name="r" />.</para>
- /// <para>-or-</para>
- /// <para><paramref name="r" /> is <see langword="null" />.</para>
- /// </description>
- /// </item>
- /// </list>
- /// </returns>
- /// <remarks>
- /// <para>
- /// <paramref name="r" /> must be an instance of <see cref="Level" />
- /// or <see langword="null" />; otherwise, an exception is thrown.
- /// </para>
- /// </remarks>
- /// <exception cref="ArgumentException"><paramref name="r" /> is not a <see cref="Level" />.</exception>
- public int CompareTo(object r)
- {
- Level target = r as Level;
- if (target != null)
- {
- return Compare(this, target);
- }
- throw new ArgumentException("Parameter: r, Value: [" + r + "] is not an instance of Level");
- }
+ /// <summary>
+ /// Compares this instance to a specified object and returns an
+ /// indication of their relative values.
+ /// </summary>
+ /// <param name="r">A <see cref="Level"/> instance or <see langword="null" /> to compare with this instance.</param>
+ /// <returns>
+ /// A 32-bit signed integer that indicates the relative order of the
+ /// values compared. The return value has these meanings:
+ /// <list type="table">
+ /// <listheader>
+ /// <term>Value</term>
+ /// <description>Meaning</description>
+ /// </listheader>
+ /// <item>
+ /// <term>Less than zero</term>
+ /// <description>This instance is less than <paramref name="r" />.</description>
+ /// </item>
+ /// <item>
+ /// <term>Zero</term>
+ /// <description>This instance is equal to <paramref name="r" />.</description>
+ /// </item>
+ /// <item>
+ /// <term>Greater than zero</term>
+ /// <description>
+ /// <para>This instance is greater than <paramref name="r" />.</para>
+ /// <para>-or-</para>
+ /// <para><paramref name="r" /> is <see langword="null" />.</para>
+ /// </description>
+ /// </item>
+ /// </list>
+ /// </returns>
+ /// <remarks>
+ /// <para>
+ /// <paramref name="r" /> must be an instance of <see cref="Level" />
+ /// or <see langword="null" />; otherwise, an exception is thrown.
+ /// </para>
+ /// </remarks>
+ /// <exception cref="ArgumentException"><paramref name="r" /> is not a <see cref="Level" />.</exception>
+ public int CompareTo(object r)
+ {
+ Level target = r as Level;
+ if (target != null)
+ {
+ return Compare(this, target);
+ }
+ throw new ArgumentException("Parameter: r, Value: [" + r + "] is not an instance of Level");
+ }
- #endregion Implementation of IComparable
+ #endregion Implementation of IComparable
- #region Operators
+ #region Operators
- /// <summary>
- /// Returns a value indicating whether a specified <see cref="Level" />
- /// is greater than another specified <see cref="Level" />.
- /// </summary>
- /// <param name="l">A <see cref="Level" /></param>
- /// <param name="r">A <see cref="Level" /></param>
- /// <returns>
- /// <c>true</c> if <paramref name="l" /> is greater than
- /// <paramref name="r" />; otherwise, <c>false</c>.
- /// </returns>
- /// <remarks>
- /// <para>
- /// Compares two levels.
- /// </para>
- /// </remarks>
- public static bool operator > (Level l, Level r)
- {
- return l.m_levelValue > r.m_levelValue;
- }
+ /// <summary>
+ /// Returns a value indicating whether a specified <see cref="Level" />
+ /// is greater than another specified <see cref="Level" />.
+ /// </summary>
+ /// <param name="l">A <see cref="Level" /></param>
+ /// <param name="r">A <see cref="Level" /></param>
+ /// <returns>
+ /// <c>true</c> if <paramref name="l" /> is greater than
+ /// <paramref name="r" />; otherwise, <c>false</c>.
+ /// </returns>
+ /// <remarks>
+ /// <para>
+ /// Compares two levels.
+ /// </para>
+ /// </remarks>
+ public static bool operator > (Level l, Level r)
+ {
+ return l.m_levelValue > r.m_levelValue;
+ }
- /// <summary>
- /// Returns a value indicating whether a specified <see cref="Level" />
- /// is less than another specified <see cref="Level" />.
- /// </summary>
- /// <param name="l">A <see cref="Level" /></param>
- /// <param name="r">A <see cref="Level" /></param>
- /// <returns>
- /// <c>true</c> if <paramref name="l" /> is less than
- /// <paramref name="r" />; otherwise, <c>false</c>.
- /// </returns>
- /// <remarks>
- /// <para>
- /// Compares two levels.
- /// </para>
- /// </remarks>
- public static bool operator < (Level l, Level r)
- {
- return l.m_levelValue < r.m_levelValue;
- }
+ /// <summary>
+ /// Returns a value indicating whether a specified <see cref="Level" />
+ /// is less than another specified <see cref="Level" />.
+ /// </summary>
+ /// <param name="l">A <see cref="Level" /></param>
+ /// <param name="r">A <see cref="Level" /></param>
+ /// <returns>
+ /// <c>true</c> if <paramref name="l" /> is less than
+ /// <paramref name="r" />; otherwise, <c>false</c>.
+ /// </returns>
+ /// <remarks>
+ /// <para>
+ /// Compares two levels.
+ /// </para>
+ /// </remarks>
+ public static bool operator < (Level l, Level r)
+ {
+ return l.m_levelValue < r.m_levelValue;
+ }
- /// <summary>
- /// Returns a value indicating whether a specified <see cref="Level" />
- /// is greater than or equal to another specified <see cref="Level" />.
- /// </summary>
- /// <param name="l">A <see cref="Level" /></param>
- /// <param name="r">A <see cref="Level" /></param>
- /// <returns>
- /// <c>true</c> if <paramref name="l" /> is greater than or equal to
- /// <paramref name="r" />; otherwise, <c>false</c>.
- /// </returns>
- /// <remarks>
- /// <para>
- /// Compares two levels.
- /// </para>
- /// </remarks>
- public static bool operator >= (Level l, Level r)
- {
- return l.m_levelValue >= r.m_levelValue;
- }
+ /// <summary>
+ /// Returns a value indicating whether a specified <see cref="Level" />
+ /// is greater than or equal to another specified <see cref="Level" />.
+ /// </summary>
+ /// <param name="l">A <see cref="Level" /></param>
+ /// <param name="r">A <see cref="Level" /></param>
+ /// <returns>
+ /// <c>true</c> if <paramref name="l" /> is greater than or equal to
+ /// <paramref name="r" />; otherwise, <c>false</c>.
+ /// </returns>
+ /// <remarks>
+ /// <para>
+ /// Compares two levels.
+ /// </para>
+ /// </remarks>
+ public static bool operator >= (Level l, Level r)
+ {
+ return l.m_levelValue >= r.m_levelValue;
+ }
- /// <summary>
- /// Returns a value indicating whether a specified <see cref="Level" />
- /// is less than or equal to another specified <see cref="Level" />.
- /// </summary>
- /// <param name="l">A <see cref="Level" /></param>
- /// <param name="r">A <see cref="Level" /></param>
- /// <returns>
- /// <c>true</c> if <paramref name="l" /> is less than or equal to
- /// <paramref name="r" />; otherwise, <c>false</c>.
- /// </returns>
- /// <remarks>
- /// <para>
- /// Compares two levels.
- /// </para>
- /// </remarks>
- public static bool operator <= (Level l, Level r)
- {
- return l.m_levelValue <= r.m_levelValue;
- }
+ /// <summary>
+ /// Returns a value indicating whether a specified <see cref="Level" />
+ /// is less than or equal to another specified <see cref="Level" />.
+ /// </summary>
+ /// <param name="l">A <see cref="Level" /></param>
+ /// <param name="r">A <see cref="Level" /></param>
+ /// <returns>
+ /// <c>true</c> if <paramref name="l" /> is less than or equal to
+ /// <paramref name="r" />; otherwise, <c>false</c>.
+ /// </returns>
+ /// <remarks>
+ /// <para>
+ /// Compares two levels.
+ /// </para>
+ /// </remarks>
+ public static bool operator <= (Level l, Level r)
+ {
+ return l.m_levelValue <= r.m_levelValue;
+ }
- /// <summary>
- /// Returns a value indicating whether two specified <see cref="Level" />
- /// objects have the same value.
- /// </summary>
- /// <param name="l">A <see cref="Level" /> or <see langword="null" />.</param>
- /// <param name="r">A <see cref="Level" /> or <see langword="null" />.</param>
- /// <returns>
- /// <c>true</c> if the value of <paramref name="l" /> is the same as the
- /// value of <paramref name="r" />; otherwise, <c>false</c>.
- /// </returns>
- /// <remarks>
- /// <para>
- /// Compares two levels.
- /// </para>
- /// </remarks>
- public static bool operator == (Level l, Level r)
- {
- if (((object)l) != null && ((object)r) != null)
- {
- return l.m_levelValue == r.m_levelValue;
- }
- else
- {
- return ((object) l) == ((object) r);
- }
- }
+ /// <summary>
+ /// Returns a value indicating whether two specified <see cref="Level" />
+ /// objects have the same value.
+ /// </summary>
+ /// <param name="l">A <see cref="Level" /> or <see langword="null" />.</param>
+ /// <param name="r">A <see cref="Level" /> or <see langword="null" />.</param>
+ /// <returns>
+ /// <c>true</c> if the value of <paramref name="l" /> is the same as the
+ /// value of <paramref name="r" />; otherwise, <c>false</c>.
+ /// </returns>
+ /// <remarks>
+ /// <para>
+ /// Compares two levels.
+ /// </para>
+ /// </remarks>
+ public static bool operator == (Level l, Level r)
+ {
+ if (((object)l) != null && ((object)r) != null)
+ {
+ return l.m_levelValue == r.m_levelValue;
+ }
+ else
+ {
+ return ((object) l) == ((object) r);
+ }
+ }
- /// <summary>
- /// Returns a value indicating whether two specified <see cref="Level" />
- /// objects have different values.
- /// </summary>
- /// <param name="l">A <see cref="Level" /> or <see langword="null" />.</param>
- /// <param name="r">A <see cref="Level" /> or <see langword="null" />.</param>
- /// <returns>
- /// <c>true</c> if the value of <paramref name="l" /> is different from
- /// the value of <paramref name="r" />; otherwise, <c>false</c>.
- /// </returns>
- /// <remarks>
- /// <para>
- /// Compares two levels.
- /// </para>
- /// </remarks>
- public static bool operator != (Level l, Level r)
- {
- return !(l==r);
- }
+ /// <summary>
+ /// Returns a value indicating whether two specified <see cref="Level" />
+ /// objects have different values.
+ /// </summary>
+ /// <param name="l">A <see cref="Level" /> or <see langword="null" />.</param>
+ /// <param name="r">A <see cref="Level" /> or <see langword="null" />.</param>
+ /// <returns>
+ /// <c>true</c> if the value of <paramref name="l" /> is different from
+ /// the value of <paramref name="r" />; otherwise, <c>false</c>.
+ /// </returns>
+ /// <remarks>
+ /// <para>
+ /// Compares two levels.
+ /// </para>
+ /// </remarks>
+ public static bool operator != (Level l, Level r)
+ {
+ return !(l==r);
+ }
- #endregion Operators
+ #endregion Operators
- #region Public Static Methods
+ #region Public Static Methods
- /// <summary>
- /// Compares two specified <see cref="Level"/> instances.
- /// </summary>
- /// <param name="l">The first <see cref="Level"/> to compare.</param>
- /// <param name="r">The second <see cref="Level"/> to compare.</param>
- /// <returns>
- /// A 32-bit signed integer that indicates the relative order of the
- /// two values compared. The return value has these meanings:
- /// <list type="table">
- /// <listheader>
- /// <term>Value</term>
- /// <description>Meaning</description>
- /// </listheader>
- /// <item>
- /// <term>Less than zero</term>
- /// <description><paramref name="l" /> is less than <paramref name="r" />.</description>
- /// </item>
- /// <item>
- /// <term>Zero</term>
- /// <description><paramref name="l" /> is equal to <paramref name="r" />.</description>
- /// </item>
- /// <item>
- /// <term>Greater than zero</term>
- /// <description><paramref name="l" /> is greater than <paramref name="r" />.</description>
- /// </item>
- /// </list>
- /// </returns>
- /// <remarks>
- /// <para>
- /// Compares two levels.
- /// </para>
- /// </remarks>
- public static int Compare(Level l, Level r)
- {
- // Reference equals
- if ((object)l == (object)r)
- {
- return 0;
- }
+ /// <summary>
+ /// Compares two specified <see cref="Level"/> instances.
+ /// </summary>
+ /// <param name="l">The first <see cref="Level"/> to compare.</param>
+ /// <param name="r">The second <see cref="Level"/> to compare.</param>
+ /// <returns>
+ /// A 32-bit signed integer that indicates the relative order of the
+ /// two values compared. The return value has these meanings:
+ /// <list type="table">
+ /// <listheader>
+ /// <term>Value</term>
+ /// <description>Meaning</description>
+ /// </listheader>
+ /// <item>
+ /// <term>Less than zero</term>
+ /// <description><paramref name="l" /> is less than <paramref name="r" />.</description>
+ /// </item>
+ /// <item>
+ /// <term>Zero</term>
+ /// <description><paramref name="l" /> is equal to <paramref name="r" />.</description>
+ /// </item>
+ /// <item>
+ /// <term>Greater than zero</term>
+ /// <description><paramref name="l" /> is greater than <paramref name="r" />.</description>
+ /// </item>
+ /// </list>
+ /// </returns>
+ /// <remarks>
+ /// <para>
+ /// Compares two levels.
+ /// </para>
+ /// </remarks>
+ public static int Compare(Level l, Level r)
+ {
+ // Reference equals
+ if ((object)l == (object)r)
+ {
+ return 0;
+ }
- if (l == null && r == null)
- {
- return 0;
- }
- if (l == null)
- {
- return -1;
- }
- if (r == null)
- {
- return 1;
- }
+ if (l == null && r == null)
+ {
+ return 0;
+ }
+ if (l == null)
+ {
+ return -1;
+ }
+ if (r == null)
+ {
+ return 1;
+ }
- return l.m_levelValue.CompareTo(r.m_levelValue);
- }
+ return l.m_levelValue.CompareTo(r.m_levelValue);
+ }
- #endregion Public Static Methods
+ #endregion Public Static Methods
- #region Public Static Fields
+ #region Public Static Fields
- /// <summary>
- /// The <see cref="Off" /> level designates a higher level than all the rest.
- /// </summary>
- public static readonly Level Off = new Level(int.MaxValue, "OFF");
+ /// <summary>
+ /// The <see cref="Off" /> level designates a higher level than all the rest.
+ /// </summary>
+ public static readonly Level Off = new Level(int.MaxValue, "OFF");
/// <summary>
/// The <see cref="Emergency" /> level designates very severe error events.
@@ -508,108 +508,108 @@
/// </summary>
public static readonly Level Log4Net_Debug = new Level(120000, "log4net:DEBUG");
- /// <summary>
- /// The <see cref="Emergency" /> level designates very severe error events.
- /// System unusable, emergencies.
- /// </summary>
- public static readonly Level Emergency = new Level(120000, "EMERGENCY");
+ /// <summary>
+ /// The <see cref="Emergency" /> level designates very severe error events.
+ /// System unusable, emergencies.
+ /// </summary>
+ public static readonly Level Emergency = new Level(120000, "EMERGENCY");
- /// <summary>
- /// The <see cref="Fatal" /> level designates very severe error events
- /// that will presumably lead the application to abort.
- /// </summary>
- public static readonly Level Fatal = new Level(110000, "FATAL");
+ /// <summary>
+ /// The <see cref="Fatal" /> level designates very severe error events
+ /// that will presumably lead the application to abort.
+ /// </summary>
+ public static readonly Level Fatal = new Level(110000, "FATAL");
- /// <summary>
- /// The <see cref="Alert" /> level designates very severe error events.
- /// Take immediate action, alerts.
- /// </summary>
- public static readonly Level Alert = new Level(100000, "ALERT");
+ /// <summary>
+ /// The <see cref="Alert" /> level designates very severe error events.
+ /// Take immediate action, alerts.
+ /// </summary>
+ public static readonly Level Alert = new Level(100000, "ALERT");
- /// <summary>
- /// The <see cref="Critical" /> level designates very severe error events.
- /// Critical condition, critical.
- /// </summary>
- public static readonly Level Critical = new Level(90000, "CRITICAL");
+ /// <summary>
+ /// The <see cref="Critical" /> level designates very severe error events.
+ /// Critical condition, critical.
+ /// </summary>
+ public static readonly Level Critical = new Level(90000, "CRITICAL");
- /// <summary>
- /// The <see cref="Severe" /> level designates very severe error events.
- /// </summary>
- public static readonly Level Severe = new Level(80000, "SEVERE");
+ /// <summary>
+ /// The <see cref="Severe" /> level designates very severe error events.
+ /// </summary>
+ public static readonly Level Severe = new Level(80000, "SEVERE");
- /// <summary>
- /// The <see cref="Error" /> level designates error events that might
- /// still allow the application to continue running.
- /// </summary>
- public static readonly Level Error = new Level(70000, "ERROR");
+ /// <summary>
+ /// The <see cref="Error" /> level designates error events that might
+ /// still allow the application to continue running.
+ /// </summary>
+ public static readonly Level Error = new Level(70000, "ERROR");
- /// <summary>
- /// The <see cref="Warn" /> level designates potentially harmful
- /// situations.
- /// </summary>
- public static readonly Level Warn = new Level(60000, "WARN");
+ /// <summary>
+ /// The <see cref="Warn" /> level designates potentially harmful
+ /// situations.
+ /// </summary>
+ public static readonly Level Warn = new Level(60000, "WARN");
- /// <summary>
- /// The <see cref="Notice" /> level designates informational messages
- /// that highlight the progress of the application at the highest level.
- /// </summary>
- public static readonly Level Notice = new Level(50000, "NOTICE");
+ /// <summary>
+ /// The <see cref="Notice" /> level designates informational messages
+ /// that highlight the progress of the application at the highest level.
+ /// </summary>
+ public static readonly Level Notice = new Level(50000, "NOTICE");
- /// <summary>
- /// The <see cref="Info" /> level designates informational messages that
- /// highlight the progress of the application at coarse-grained level.
- /// </summary>
- public static readonly Level Info = new Level(40000, "INFO");
+ /// <summary>
+ /// The <see cref="Info" /> level designates informational messages that
+ /// highlight the progress of the application at coarse-grained level.
+ /// </summary>
+ public static readonly Level Info = new Level(40000, "INFO");
- /// <summary>
- /// The <see cref="Debug" /> level designates fine-grained informational
- /// events that are most useful to debug an application.
- /// </summary>
- public static readonly Level Debug = new Level(30000, "DEBUG");
+ /// <summary>
+ /// The <see cref="Debug" /> level designates fine-grained informational
+ /// events that are most useful to debug an application.
+ /// </summary>
+ public static readonly Level Debug = new Level(30000, "DEBUG");
- /// <summary>
- /// The <see cref="Fine" /> level designates fine-grained informational
- /// events that are most useful to debug an application.
- /// </summary>
- public static readonly Level Fine = new Level(30000, "FINE");
+ /// <summary>
+ /// The <see cref="Fine" /> level designates fine-grained informational
+ /// events that are most useful to debug an application.
+ /// </summary>
+ public static readonly Level Fine = new Level(30000, "FINE");
- /// <summary>
- /// The <see cref="Trace" /> level designates fine-grained informational
- /// events that are most useful to debug an application.
- /// </summary>
- public static readonly Level Trace = new Level(20000, "TRACE");
+ /// <summary>
+ /// The <see cref="Trace" /> level designates fine-grained informational
+ /// events that are most useful to debug an application.
+ /// </summary>
+ public static readonly Level Trace = new Level(20000, "TRACE");
- /// <summary>
- /// The <see cref="Finer" /> level designates fine-grained informational
- /// events that are most useful to debug an application.
- /// </summary>
- public static readonly Level Finer = new Level(20000, "FINER");
+ /// <summary>
+ /// The <see cref="Finer" /> level designates fine-grained informational
+ /// events that are most useful to debug an application.
+ /// </summary>
+ public static readonly Level Finer = new Level(20000, "FINER");
- /// <summary>
- /// The <see cref="Verbose" /> level designates fine-grained informational
- /// events that are most useful to debug an application.
- /// </summary>
- public static readonly Level Verbose = new Level(10000, "VERBOSE");
+ /// <summary>
+ /// The <see cref="Verbose" /> level designates fine-grained informational
+ /// events that are most useful to debug an application.
+ /// </summary>
+ public static readonly Level Verbose = new Level(10000, "VERBOSE");
- /// <summary>
- /// The <see cref="Finest" /> level designates fine-grained informational
- /// events that are most useful to debug an application.
- /// </summary>
- public static readonly Level Finest = new Level(10000, "FINEST");
+ /// <summary>
+ /// The <see cref="Finest" /> level designates fine-grained informational
+ /// events that are most useful to debug an application.
+ /// </summary>
+ public static readonly Level Finest = new Level(10000, "FINEST");
- /// <summary>
- /// The <see cref="All" /> level designates the lowest level possible.
- /// </summary>
- public static readonly Level All = new Level(int.MinValue, "ALL");
+ /// <summary>
+ /// The <see cref="All" /> level designates the lowest level possible.
+ /// </summary>
+ public static readonly Level All = new Level(int.MinValue, "ALL");
- #endregion Public Static Fields
+ #endregion Public Static Fields
- #region Private Instance Fields
+ #region Private Instance Fields
- private readonly int m_levelValue;
- private readonly string m_levelName;
- private readonly string m_levelDisplayName;
+ private readonly int m_levelValue;
+ private readonly string m_levelName;
+ private readonly string m_levelDisplayName;
- #endregion Private Instance Fields
- }
+ #endregion Private Instance Fields
+ }
}
diff --git a/src/log4net/Core/LevelCollection.cs b/src/log4net/Core/LevelCollection.cs
index d51bd0d..649eeca 100644
--- a/src/log4net/Core/LevelCollection.cs
+++ b/src/log4net/Core/LevelCollection.cs
@@ -22,839 +22,839 @@
namespace log4net.Core
{
- /// <summary>
- /// A strongly-typed collection of <see cref="Level"/> objects.
- /// </summary>
- /// <author>Nicko Cadell</author>
- public class LevelCollection : ICollection, IList, IEnumerable
+ /// <summary>
+ /// A strongly-typed collection of <see cref="Level"/> objects.
+ /// </summary>
+ /// <author>Nicko Cadell</author>
+ public class LevelCollection : ICollection, IList, IEnumerable
#if !NETSTANDARD1_3
- , ICloneable
+ , ICloneable
#endif
- {
- #region Interfaces
+ {
+ #region Interfaces
- /// <summary>
- /// Supports type-safe iteration over a <see cref="LevelCollection"/>.
- /// </summary>
- public interface ILevelCollectionEnumerator
- {
- /// <summary>
- /// Gets the current element in the collection.
- /// </summary>
- Level Current { get; }
+ /// <summary>
+ /// Supports type-safe iteration over a <see cref="LevelCollection"/>.
+ /// </summary>
+ public interface ILevelCollectionEnumerator
+ {
+ /// <summary>
+ /// Gets the current element in the collection.
+ /// </summary>
+ Level Current { get; }
- /// <summary>
- /// Advances the enumerator to the next element in the collection.
- /// </summary>
- /// <returns>
- /// <c>true</c> if the enumerator was successfully advanced to the next element;
- /// <c>false</c> if the enumerator has passed the end of the collection.
- /// </returns>
- /// <exception cref="InvalidOperationException">
- /// The collection was modified after the enumerator was created.
- /// </exception>
- bool MoveNext();
+ /// <summary>
+ /// Advances the enumerator to the next element in the collection.
+ /// </summary>
+ /// <returns>
+ /// <c>true</c> if the enumerator was successfully advanced to the next element;
+ /// <c>false</c> if the enumerator has passed the end of the collection.
+ /// </returns>
+ /// <exception cref="InvalidOperationException">
+ /// The collection was modified after the enumerator was created.
+ /// </exception>
+ bool MoveNext();
- /// <summary>
- /// Sets the enumerator to its initial position, before the first element in the collection.
- /// </summary>
- void Reset();
- }
+ /// <summary>
+ /// Sets the enumerator to its initial position, before the first element in the collection.
+ /// </summary>
+ void Reset();
+ }
- #endregion
+ #endregion
- private const int DEFAULT_CAPACITY = 16;
+ private const int DEFAULT_CAPACITY = 16;
- #region Implementation (data)
+ #region Implementation (data)
- private Level[] m_array;
- private int m_count = 0;
- private int m_version = 0;
+ private Level[] m_array;
+ private int m_count = 0;
+ private int m_version = 0;
- #endregion
-
- #region Static Wrappers
+ #endregion
+
+ #region Static Wrappers
- /// <summary>
- /// Creates a read-only wrapper for a <c>LevelCollection</c> instance.
- /// </summary>
- /// <param name="list">list to create a readonly wrapper arround</param>
- /// <returns>
- /// A <c>LevelCollection</c> wrapper that is read-only.
- /// </returns>
- public static LevelCollection ReadOnly(LevelCollection list)
- {
- if(list==null) throw new ArgumentNullException("list");
+ /// <summary>
+ /// Creates a read-only wrapper for a <c>LevelCollection</c> instance.
+ /// </summary>
+ /// <param name="list">list to create a readonly wrapper arround</param>
+ /// <returns>
+ /// A <c>LevelCollection</c> wrapper that is read-only.
+ /// </returns>
+ public static LevelCollection ReadOnly(LevelCollection list)
+ {
+ if(list==null) throw new ArgumentNullException("list");
- return new ReadOnlyLevelCollection(list);
- }
+ return new ReadOnlyLevelCollection(list);
+ }
- #endregion
+ #endregion
- #region Constructors
+ #region Constructors
- /// <summary>
- /// Initializes a new instance of the <c>LevelCollection</c> class
- /// that is empty and has the default initial capacity.
- /// </summary>
- public LevelCollection()
- {
- m_array = new Level[DEFAULT_CAPACITY];
- }
-
- /// <summary>
- /// Initializes a new instance of the <c>LevelCollection</c> class
- /// that has the specified initial capacity.
- /// </summary>
- /// <param name="capacity">
- /// The number of elements that the new <c>LevelCollection</c> is initially capable of storing.
- /// </param>
- public LevelCollection(int capacity)
- {
- m_array = new Level[capacity];
- }
+ /// <summary>
+ /// Initializes a new instance of the <c>LevelCollection</c> class
+ /// that is empty and has the default initial capacity.
+ /// </summary>
+ public LevelCollection()
+ {
+ m_array = new Level[DEFAULT_CAPACITY];
+ }
+
+ /// <summary>
+ /// Initializes a new instance of the <c>LevelCollection</c> class
+ /// that has the specified initial capacity.
+ /// </summary>
+ /// <param name="capacity">
+ /// The number of elements that the new <c>LevelCollection</c> is initially capable of storing.
+ /// </param>
+ public LevelCollection(int capacity)
+ {
+ m_array = new Level[capacity];
+ }
- /// <summary>
- /// Initializes a new instance of the <c>LevelCollection</c> class
- /// that contains elements copied from the specified <c>LevelCollection</c>.
- /// </summary>
- /// <param name="c">The <c>LevelCollection</c> whose elements are copied to the new collection.</param>
- public LevelCollection(LevelCollection c)
- {
- m_array = new Level[c.Count];
- AddRange(c);
- }
+ /// <summary>
+ /// Initializes a new instance of the <c>LevelCollection</c> class
+ /// that contains elements copied from the specified <c>LevelCollection</c>.
+ /// </summary>
+ /// <param name="c">The <c>LevelCollection</c> whose elements are copied to the new collection.</param>
+ public LevelCollection(LevelCollection c)
+ {
+ m_array = new Level[c.Count];
+ AddRange(c);
+ }
- /// <summary>
- /// Initializes a new instance of the <c>LevelCollection</c> class
- /// that contains elements copied from the specified <see cref="Level"/> array.
- /// </summary>
- /// <param name="a">The <see cref="Level"/> array whose elements are copied to the new list.</param>
- public LevelCollection(Level[] a)
- {
- m_array = new Level[a.Length];
- AddRange(a);
- }
+ /// <summary>
+ /// Initializes a new instance of the <c>LevelCollection</c> class
+ /// that contains elements copied from the specified <see cref="Level"/> array.
+ /// </summary>
+ /// <param name="a">The <see cref="Level"/> array whose elements are copied to the new list.</param>
+ public LevelCollection(Level[] a)
+ {
+ m_array = new Level[a.Length];
+ AddRange(a);
+ }
- /// <summary>
- /// Initializes a new instance of the <c>LevelCollection</c> class
- /// that contains elements copied from the specified <see cref="Level"/> collection.
- /// </summary>
- /// <param name="col">The <see cref="Level"/> collection whose elements are copied to the new list.</param>
- public LevelCollection(ICollection col)
- {
- m_array = new Level[col.Count];
- AddRange(col);
- }
-
- /// <summary>
- /// Type visible only to our subclasses
- /// Used to access protected constructor
- /// </summary>
- protected internal enum Tag
- {
- /// <summary>
- /// A value
- /// </summary>
- Default
- }
+ /// <summary>
+ /// Initializes a new instance of the <c>LevelCollection</c> class
+ /// that contains elements copied from the specified <see cref="Level"/> collection.
+ /// </summary>
+ /// <param name="col">The <see cref="Level"/> collection whose elements are copied to the new list.</param>
+ public LevelCollection(ICollection col)
+ {
+ m_array = new Level[col.Count];
+ AddRange(col);
+ }
+
+ /// <summary>
+ /// Type visible only to our subclasses
+ /// Used to access protected constructor
+ /// </summary>
+ protected internal enum Tag
+ {
+ /// <summary>
+ /// A value
+ /// </summary>
+ Default
+ }
- /// <summary>
- /// Allow subclasses to avoid our default constructors
- /// </summary>
- /// <param name="tag"></param>
- protected internal LevelCollection(Tag tag)
- {
- m_array = null;
- }
- #endregion
-
- #region Operations (type-safe ICollection)
+ /// <summary>
+ /// Allow subclasses to avoid our default constructors
+ /// </summary>
+ /// <param name="tag"></param>
+ protected internal LevelCollection(Tag tag)
+ {
+ m_array = null;
+ }
+ #endregion
+
+ #region Operations (type-safe ICollection)
- /// <summary>
- /// Gets the number of elements actually contained in the <c>LevelCollection</c>.
- /// </summary>
- public virtual int Count
- {
- get { return m_count; }
- }
+ /// <summary>
+ /// Gets the number of elements actually contained in the <c>LevelCollection</c>.
+ /// </summary>
+ public virtual int Count
+ {
+ get { return m_count; }
+ }
- /// <summary>
- /// Copies the entire <c>LevelCollection</c> to a one-dimensional
- /// <see cref="Level"/> array.
- /// </summary>
- /// <param name="array">The one-dimensional <see cref="Level"/> array to copy to.</param>
- public virtual void CopyTo(Level[] array)
- {
- this.CopyTo(array, 0);
- }
+ /// <summary>
+ /// Copies the entire <c>LevelCollection</c> to a one-dimensional
+ /// <see cref="Level"/> array.
+ /// </summary>
+ /// <param name="array">The one-dimensional <see cref="Level"/> array to copy to.</param>
+ public virtual void CopyTo(Level[] array)
+ {
+ this.CopyTo(array, 0);
+ }
- /// <summary>
- /// Copies the entire <c>LevelCollection</c> to a one-dimensional
- /// <see cref="Level"/> array, starting at the specified index of the target array.
- /// </summary>
- /// <param name="array">The one-dimensional <see cref="Level"/> array to copy to.</param>
- /// <param name="start">The zero-based index in <paramref name="array"/> at which copying begins.</param>
- public virtual void CopyTo(Level[] array, int start)
- {
- if (m_count > array.GetUpperBound(0) + 1 - start)
- {
- throw new System.ArgumentException("Destination array was not long enough.");
- }
-
- Array.Copy(m_array, 0, array, start, m_count);
- }
+ /// <summary>
+ /// Copies the entire <c>LevelCollection</c> to a one-dimensional
+ /// <see cref="Level"/> array, starting at the specified index of the target array.
+ /// </summary>
+ /// <param name="array">The one-dimensional <see cref="Level"/> array to copy to.</param>
+ /// <param name="start">The zero-based index in <paramref name="array"/> at which copying begins.</param>
+ public virtual void CopyTo(Level[] array, int start)
+ {
+ if (m_count > array.GetUpperBound(0) + 1 - start)
+ {
+ throw new System.ArgumentException("Destination array was not long enough.");
+ }
+
+ Array.Copy(m_array, 0, array, start, m_count);
+ }
- /// <summary>
- /// Gets a value indicating whether access to the collection is synchronized (thread-safe).
- /// </summary>
- /// <returns>false, because the backing type is an array, which is never thread-safe.</returns>
- public virtual bool IsSynchronized
- {
- get { return false; }
- }
+ /// <summary>
+ /// Gets a value indicating whether access to the collection is synchronized (thread-safe).
+ /// </summary>
+ /// <returns>false, because the backing type is an array, which is never thread-safe.</returns>
+ public virtual bool IsSynchronized
+ {
+ get { return false; }
+ }
- /// <summary>
- /// Gets an object that can be used to synchronize access to the collection.
- /// </summary>
- public virtual object SyncRoot
- {
- get { return m_array; }
- }
+ /// <summary>
+ /// Gets an object that can be used to synchronize access to the collection.
+ /// </summary>
+ public virtual object SyncRoot
+ {
+ get { return m_array; }
+ }
- #endregion
-
- #region Operations (type-safe IList)
+ #endregion
+
+ #region Operations (type-safe IList)
- /// <summary>
- /// Gets or sets the <see cref="Level"/> at the specified index.
- /// </summary>
- /// <param name="index">The zero-based index of the element to get or set.</param>
- /// <exception cref="ArgumentOutOfRangeException">
- /// <para><paramref name="index"/> is less than zero</para>
- /// <para>-or-</para>
- /// <para><paramref name="index"/> is equal to or greater than <see cref="LevelCollection.Count"/>.</para>
- /// </exception>
- public virtual Level this[int index]
- {
- get
- {
- ValidateIndex(index); // throws
- return m_array[index];
- }
- set
- {
- ValidateIndex(index); // throws
- ++m_version;
- m_array[index] = value;
- }
- }
+ /// <summary>
+ /// Gets or sets the <see cref="Level"/> at the specified index.
+ /// </summary>
+ /// <param name="index">The zero-based index of the element to get or set.</param>
+ /// <exception cref="ArgumentOutOfRangeException">
+ /// <para><paramref name="index"/> is less than zero</para>
+ /// <para>-or-</para>
+ /// <para><paramref name="index"/> is equal to or greater than <see cref="LevelCollection.Count"/>.</para>
+ /// </exception>
+ public virtual Level this[int index]
+ {
+ get
+ {
+ ValidateIndex(index); // throws
+ return m_array[index];
+ }
+ set
+ {
+ ValidateIndex(index); // throws
+ ++m_version;
+ m_array[index] = value;
+ }
+ }
- /// <summary>
- /// Adds a <see cref="Level"/> to the end of the <c>LevelCollection</c>.
- /// </summary>
- /// <param name="item">The <see cref="Level"/> to be added to the end of the <c>LevelCollection</c>.</param>
- /// <returns>The index at which the value has been added.</returns>
- public virtual int Add(Level item)
- {
- if (m_count == m_array.Length)
- {
- EnsureCapacity(m_count + 1);
- }
+ /// <summary>
+ /// Adds a <see cref="Level"/> to the end of the <c>LevelCollection</c>.
+ /// </summary>
+ /// <param name="item">The <see cref="Level"/> to be added to the end of the <c>LevelCollection</c>.</param>
+ /// <returns>The index at which the value has been added.</returns>
+ public virtual int Add(Level item)
+ {
+ if (m_count == m_array.Length)
+ {
+ EnsureCapacity(m_count + 1);
+ }
- m_array[m_count] = item;
- m_version++;
+ m_array[m_count] = item;
+ m_version++;
- return m_count++;
- }
-
- /// <summary>
- /// Removes all elements from the <c>LevelCollection</c>.
- /// </summary>
- public virtual void Clear()
- {
- ++m_version;
- m_array = new Level[DEFAULT_CAPACITY];
- m_count = 0;
- }
-
- /// <summary>
- /// Creates a shallow copy of the <see cref="LevelCollection"/>.
- /// </summary>
- /// <returns>A new <see cref="LevelCollection"/> with a shallow copy of the collection data.</returns>
- public virtual object Clone()
- {
- LevelCollection newCol = new LevelCollection(m_count);
- Array.Copy(m_array, 0, newCol.m_array, 0, m_count);
- newCol.m_count = m_count;
- newCol.m_version = m_version;
+ return m_count++;
+ }
+
+ /// <summary>
+ /// Removes all elements from the <c>LevelCollection</c>.
+ /// </summary>
+ public virtual void Clear()
+ {
+ ++m_version;
+ m_array = new Level[DEFAULT_CAPACITY];
+ m_count = 0;
+ }
+
+ /// <summary>
+ /// Creates a shallow copy of the <see cref="LevelCollection"/>.
+ /// </summary>
+ /// <returns>A new <see cref="LevelCollection"/> with a shallow copy of the collection data.</returns>
+ public virtual object Clone()
+ {
+ LevelCollection newCol = new LevelCollection(m_count);
+ Array.Copy(m_array, 0, newCol.m_array, 0, m_count);
+ newCol.m_count = m_count;
+ newCol.m_version = m_version;
- return newCol;
- }
+ return newCol;
+ }
- /// <summary>
- /// Determines whether a given <see cref="Level"/> is in the <c>LevelCollection</c>.
- /// </summary>
- /// <param name="item">The <see cref="Level"/> to check for.</param>
- /// <returns><c>true</c> if <paramref name="item"/> is found in the <c>LevelCollection</c>; otherwise, <c>false</c>.</returns>
- public virtual bool Contains(Level item)
- {
- for (int i=0; i != m_count; ++i)
- {
- if (m_array[i].Equals(item))
- {
- return true;
- }
- }
- return false;
- }
+ /// <summary>
+ /// Determines whether a given <see cref="Level"/> is in the <c>LevelCollection</c>.
+ /// </summary>
+ /// <param name="item">The <see cref="Level"/> to check for.</param>
+ /// <returns><c>true</c> if <paramref name="item"/> is found in the <c>LevelCollection</c>; otherwise, <c>false</c>.</returns>
+ public virtual bool Contains(Level item)
+ {
+ for (int i=0; i != m_count; ++i)
+ {
+ if (m_array[i].Equals(item))
+ {
+ return true;
+ }
+ }
+ return false;
+ }
- /// <summary>
- /// Returns the zero-based index of the first occurrence of a <see cref="Level"/>
- /// in the <c>LevelCollection</c>.
- /// </summary>
- /// <param name="item">The <see cref="Level"/> to locate in the <c>LevelCollection</c>.</param>
- /// <returns>
- /// The zero-based index of the first occurrence of <paramref name="item"/>
- /// in the entire <c>LevelCollection</c>, if found; otherwise, -1.
- /// </returns>
- public virtual int IndexOf(Level item)
- {
- for (int i=0; i != m_count; ++i)
- {
- if (m_array[i].Equals(item))
- {
- return i;
- }
- }
- return -1;
- }
+ /// <summary>
+ /// Returns the zero-based index of the first occurrence of a <see cref="Level"/>
+ /// in the <c>LevelCollection</c>.
+ /// </summary>
+ /// <param name="item">The <see cref="Level"/> to locate in the <c>LevelCollection</c>.</param>
+ /// <returns>
+ /// The zero-based index of the first occurrence of <paramref name="item"/>
+ /// in the entire <c>LevelCollection</c>, if found; otherwise, -1.
+ /// </returns>
+ public virtual int IndexOf(Level item)
+ {
+ for (int i=0; i != m_count; ++i)
+ {
+ if (m_array[i].Equals(item))
+ {
+ return i;
+ }
+ }
+ return -1;
+ }
- /// <summary>
- /// Inserts an element into the <c>LevelCollection</c> at the specified index.
- /// </summary>
- /// <param name="index">The zero-based index at which <paramref name="item"/> should be inserted.</param>
- /// <param name="item">The <see cref="Level"/> to insert.</param>
- /// <exception cref="ArgumentOutOfRangeException">
- /// <para><paramref name="index"/> is less than zero</para>
- /// <para>-or-</para>
- /// <para><paramref name="index"/> is equal to or greater than <see cref="LevelCollection.Count"/>.</para>
- /// </exception>
- public virtual void Insert(int index, Level item)
- {
- ValidateIndex(index, true); // throws
-
- if (m_count == m_array.Length)
- {
- EnsureCapacity(m_count + 1);
- }
+ /// <summary>
+ /// Inserts an element into the <c>LevelCollection</c> at the specified index.
+ /// </summary>
+ /// <param name="index">The zero-based index at which <paramref name="item"/> should be inserted.</param>
+ /// <param name="item">The <see cref="Level"/> to insert.</param>
+ /// <exception cref="ArgumentOutOfRangeException">
+ /// <para><paramref name="index"/> is less than zero</para>
+ /// <para>-or-</para>
+ /// <para><paramref name="index"/> is equal to or greater than <see cref="LevelCollection.Count"/>.</para>
+ /// </exception>
+ public virtual void Insert(int index, Level item)
+ {
+ ValidateIndex(index, true); // throws
+
+ if (m_count == m_array.Length)
+ {
+ EnsureCapacity(m_count + 1);
+ }
- if (index < m_count)
- {
- Array.Copy(m_array, index, m_array, index + 1, m_count - index);
- }
+ if (index < m_count)
+ {
+ Array.Copy(m_array, index, m_array, index + 1, m_count - index);
+ }
- m_array[index] = item;
- m_count++;
- m_version++;
- }
+ m_array[index] = item;
+ m_count++;
+ m_version++;
+ }
- /// <summary>
- /// Removes the first occurrence of a specific <see cref="Level"/> from the <c>LevelCollection</c>.
- /// </summary>
- /// <param name="item">The <see cref="Level"/> to remove from the <c>LevelCollection</c>.</param>
- /// <exception cref="ArgumentException">
- /// The specified <see cref="Level"/> was not found in the <c>LevelCollection</c>.
- /// </exception>
- public virtual void Remove(Level item)
- {
- int i = IndexOf(item);
- if (i < 0)
- {
- throw new System.ArgumentException("Cannot remove the specified item because it was not found in the specified Collection.");
- }
-
- ++m_version;
- RemoveAt(i);
- }
+ /// <summary>
+ /// Removes the first occurrence of a specific <see cref="Level"/> from the <c>LevelCollection</c>.
+ /// </summary>
+ /// <param name="item">The <see cref="Level"/> to remove from the <c>LevelCollection</c>.</param>
+ /// <exception cref="ArgumentException">
+ /// The specified <see cref="Level"/> was not found in the <c>LevelCollection</c>.
+ /// </exception>
+ public virtual void Remove(Level item)
+ {
+ int i = IndexOf(item);
+ if (i < 0)
+ {
+ throw new System.ArgumentException("Cannot remove the specified item because it was not found in the specified Collection.");
+ }
+
+ ++m_version;
+ RemoveAt(i);
+ }
- /// <summary>
- /// Removes the element at the specified index of the <c>LevelCollection</c>.
- /// </summary>
- /// <param name="index">The zero-based index of the element to remove.</param>
- /// <exception cref="ArgumentOutOfRangeException">
- /// <para><paramref name="index"/> is less than zero</para>
- /// <para>-or-</para>
- /// <para><paramref name="index"/> is equal to or greater than <see cref="LevelCollection.Count"/>.</para>
- /// </exception>
- public virtual void RemoveAt(int index)
- {
- ValidateIndex(index); // throws
-
- m_count--;
+ /// <summary>
+ /// Removes the element at the specified index of the <c>LevelCollection</c>.
+ /// </summary>
+ /// <param name="index">The zero-based index of the element to remove.</param>
+ /// <exception cref="ArgumentOutOfRangeException">
+ /// <para><paramref name="index"/> is less than zero</para>
+ /// <para>-or-</para>
+ /// <para><paramref name="index"/> is equal to or greater than <see cref="LevelCollection.Count"/>.</para>
+ /// </exception>
+ public virtual void RemoveAt(int index)
+ {
+ ValidateIndex(index); // throws
+
+ m_count--;
- if (index < m_count)
- {
- Array.Copy(m_array, index + 1, m_array, index, m_count - index);
- }
-
- // We can't set the deleted entry equal to null, because it might be a value type.
- // Instead, we'll create an empty single-element array of the right type and copy it
- // over the entry we want to erase.
- Level[] temp = new Level[1];
- Array.Copy(temp, 0, m_array, m_count, 1);
- m_version++;
- }
+ if (index < m_count)
+ {
+ Array.Copy(m_array, index + 1, m_array, index, m_count - index);
+ }
+
+ // We can't set the deleted entry equal to null, because it might be a value type.
+ // Instead, we'll create an empty single-element array of the right type and copy it
+ // over the entry we want to erase.
+ Level[] temp = new Level[1];
+ Array.Copy(temp, 0, m_array, m_count, 1);
+ m_version++;
+ }
- /// <summary>
- /// Gets a value indicating whether the collection has a fixed size.
- /// </summary>
- /// <value>true if the collection has a fixed size; otherwise, false. The default is false</value>
- public virtual bool IsFixedSize
- {
- get { return false; }
- }
+ /// <summary>
+ /// Gets a value indicating whether the collection has a fixed size.
+ /// </summary>
+ /// <value>true if the collection has a fixed size; otherwise, false. The default is false</value>
+ public virtual bool IsFixedSize
+ {
+ get { return false; }
+ }
- /// <summary>
- /// Gets a value indicating whether the IList is read-only.
- /// </summary>
- /// <value>true if the collection is read-only; otherwise, false. The default is false</value>
- public virtual bool IsReadOnly
- {
- get { return false; }
- }
+ /// <summary>
+ /// Gets a value indicating whether the IList is read-only.
+ /// </summary>
+ /// <value>true if the collection is read-only; otherwise, false. The default is false</value>
+ public virtual bool IsReadOnly
+ {
+ get { return false; }
+ }
- #endregion
+ #endregion
- #region Operations (type-safe IEnumerable)
-
- /// <summary>
- /// Returns an enumerator that can iterate through the <c>LevelCollection</c>.
- /// </summary>
- /// <returns>An <see cref="Enumerator"/> for the entire <c>LevelCollection</c>.</returns>
- public virtual ILevelCollectionEnumerator GetEnumerator()
- {
- return new Enumerator(this);
- }
+ #region Operations (type-safe IEnumerable)
+
+ /// <summary>
+ /// Returns an enumerator that can iterate through the <c>LevelCollection</c>.
+ /// </summary>
+ /// <returns>An <see cref="Enumerator"/> for the entire <c>LevelCollection</c>.</returns>
+ public virtual ILevelCollectionEnumerator GetEnumerator()
+ {
+ return new Enumerator(this);
+ }
- #endregion
+ #endregion
- #region Public helpers (just to mimic some nice features of ArrayList)
-
- /// <summary>
- /// Gets or sets the number of elements the <c>LevelCollection</c> can contain.
- /// </summary>
- public virtual int Capacity
- {
- get
- {
- return m_array.Length;
- }
- set
- {
- if (value < m_count)
- {
- value = m_count;
- }
+ #region Public helpers (just to mimic some nice features of ArrayList)
+
+ /// <summary>
+ /// Gets or sets the number of elements the <c>LevelCollection</c> can contain.
+ /// </summary>
+ public virtual int Capacity
+ {
+ get
+ {
+ return m_array.Length;
+ }
+ set
+ {
+ if (value < m_count)
+ {
+ value = m_count;
+ }
- if (value != m_array.Length)
- {
- if (value > 0)
- {
- Level[] temp = new Level[value];
- Array.Copy(m_array, 0, temp, 0, m_count);
- m_array = temp;
- }
- else
- {
- m_array = new Level[DEFAULT_CAPACITY];
- }
- }
- }
- }
+ if (value != m_array.Length)
+ {
+ if (value > 0)
+ {
+ Level[] temp = new Level[value];
+ Array.Copy(m_array, 0, temp, 0, m_count);
+ m_array = temp;
+ }
+ else
+ {
+ m_array = new Level[DEFAULT_CAPACITY];
+ }
+ }
+ }
+ }
- /// <summary>
- /// Adds the elements of another <c>LevelCollection</c> to the current <c>LevelCollection</c>.
- /// </summary>
- /// <param name="x">The <c>LevelCollection</c> whose elements should be added to the end of the current <c>LevelCollection</c>.</param>
- /// <returns>The new <see cref="LevelCollection.Count"/> of the <c>LevelCollection</c>.</returns>
- public virtual int AddRange(LevelCollection x)
- {
- if (m_count + x.Count >= m_array.Length)
- {
- EnsureCapacity(m_count + x.Count);
- }
-
- Array.Copy(x.m_array, 0, m_array, m_count, x.Count);
- m_count += x.Count;
- m_version++;
+ /// <summary>
+ /// Adds the elements of another <c>LevelCollection</c> to the current <c>LevelCollection</c>.
+ /// </summary>
+ /// <param name="x">The <c>LevelCollection</c> whose elements should be added to the end of the current <c>LevelCollection</c>.</param>
+ /// <returns>The new <see cref="LevelCollection.Count"/> of the <c>LevelCollection</c>.</returns>
+ public virtual int AddRange(LevelCollection x)
+ {
+ if (m_count + x.Count >= m_array.Length)
+ {
+ EnsureCapacity(m_count + x.Count);
+ }
+
+ Array.Copy(x.m_array, 0, m_array, m_count, x.Count);
+ m_count += x.Count;
+ m_version++;
- return m_count;
- }
+ return m_count;
+ }
- /// <summary>
- /// Adds the elements of a <see cref="Level"/> array to the current <c>LevelCollection</c>.
- /// </summary>
- /// <param name="x">The <see cref="Level"/> array whose elements should be added to the end of the <c>LevelCollection</c>.</param>
- /// <returns>The new <see cref="LevelCollection.Count"/> of the <c>LevelCollection</c>.</returns>
- public virtual int AddRange(Level[] x)
- {
- if (m_count + x.Length >= m_array.Length)
- {
- EnsureCapacity(m_count + x.Length);
- }
+ /// <summary>
+ /// Adds the elements of a <see cref="Level"/> array to the current <c>LevelCollection</c>.
+ /// </summary>
+ /// <param name="x">The <see cref="Level"/> array whose elements should be added to the end of the <c>LevelCollection</c>.</param>
+ /// <returns>The new <see cref="LevelCollection.Count"/> of the <c>LevelCollection</c>.</returns>
+ public virtual int AddRange(Level[] x)
+ {
+ if (m_count + x.Length >= m_array.Length)
+ {
+ EnsureCapacity(m_count + x.Length);
+ }
- Array.Copy(x, 0, m_array, m_count, x.Length);
- m_count += x.Length;
- m_version++;
+ Array.Copy(x, 0, m_array, m_count, x.Length);
+ m_count += x.Length;
+ m_version++;
- return m_count;
- }
+ return m_count;
+ }
- /// <summary>
- /// Adds the elements of a <see cref="Level"/> collection to the current <c>LevelCollection</c>.
- /// </summary>
- /// <param name="col">The <see cref="Level"/> collection whose elements should be added to the end of the <c>LevelCollection</c>.</param>
- /// <returns>The new <see cref="LevelCollection.Count"/> of the <c>LevelCollection</c>.</returns>
- public virtual int AddRange(ICollection col)
- {
- if (m_count + col.Count >= m_array.Length)
- {
- EnsureCapacity(m_count + col.Count);
- }
+ /// <summary>
+ /// Adds the elements of a <see cref="Level"/> collection to the current <c>LevelCollection</c>.
+ /// </summary>
+ /// <param name="col">The <see cref="Level"/> collection whose elements should be added to the end of the <c>LevelCollection</c>.</param>
+ /// <returns>The new <see cref="LevelCollection.Count"/> of the <c>LevelCollection</c>.</returns>
+ public virtual int AddRange(ICollection col)
+ {
+ if (m_count + col.Count >= m_array.Length)
+ {
+ EnsureCapacity(m_count + col.Count);
+ }
- foreach(object item in col)
- {
- Add((Level)item);
- }
+ foreach(object item in col)
+ {
+ Add((Level)item);
+ }
- return m_count;
- }
-
- /// <summary>
- /// Sets the capacity to the actual number of elements.
- /// </summary>
- public virtual void TrimToSize()
- {
- this.Capacity = m_count;
- }
+ return m_count;
+ }
+
+ /// <summary>
+ /// Sets the capacity to the actual number of elements.
+ /// </summary>
+ public virtual void TrimToSize()
+ {
+ this.Capacity = m_count;
+ }
- #endregion
+ #endregion
- #region Implementation (helpers)
+ #region Implementation (helpers)
- /// <exception cref="ArgumentOutOfRangeException">
- /// <para><paramref name="i"/> is less than zero</para>
- /// <para>-or-</para>
- /// <para><paramref name="i"/> is equal to or greater than <see cref="LevelCollection.Count"/>.</para>
- /// </exception>
- private void ValidateIndex(int i)
- {
- ValidateIndex(i, false);
- }
+ /// <exception cref="ArgumentOutOfRangeException">
+ /// <para><paramref name="i"/> is less than zero</para>
+ /// <para>-or-</para>
+ /// <para><paramref name="i"/> is equal to or greater than <see cref="LevelCollection.Count"/>.</para>
+ /// </exception>
+ private void ValidateIndex(int i)
+ {
+ ValidateIndex(i, false);
+ }
- /// <exception cref="ArgumentOutOfRangeException">
- /// <para><paramref name="i"/> is less than zero</para>
- /// <para>-or-</para>
- /// <para><paramref name="i"/> is equal to or greater than <see cref="LevelCollection.Count"/>.</para>
- /// </exception>
- private void ValidateIndex(int i, bool allowEqualEnd)
- {
- int max = (allowEqualEnd) ? (m_count) : (m_count-1);
- if (i < 0 || i > max)
- {
- throw log4net.Util.SystemInfo.CreateArgumentOutOfRangeException("i", (object)i, "Index was out of range. Must be non-negative and less than the size of the collection. [" + (object)i + "] Specified argument was out of the range of valid values.");
- }
- }
+ /// <exception cref="ArgumentOutOfRangeException">
+ /// <para><paramref name="i"/> is less than zero</para>
+ /// <para>-or-</para>
+ /// <para><paramref name="i"/> is equal to or greater than <see cref="LevelCollection.Count"/>.</para>
+ /// </exception>
+ private void ValidateIndex(int i, bool allowEqualEnd)
+ {
+ int max = (allowEqualEnd) ? (m_count) : (m_count-1);
+ if (i < 0 || i > max)
+ {
+ throw log4net.Util.SystemInfo.CreateArgumentOutOfRangeException("i", (object)i, "Index was out of range. Must be non-negative and less than the size of the collection. [" + (object)i + "] Specified argument was out of the range of valid values.");
+ }
+ }
- private void EnsureCapacity(int min)
- {
- int newCapacity = ((m_array.Length == 0) ? DEFAULT_CAPACITY : m_array.Length * 2);
- if (newCapacity < min)
- {
- newCapacity = min;
- }
+ private void EnsureCapacity(int min)
+ {
+ int newCapacity = ((m_array.Length == 0) ? DEFAULT_CAPACITY : m_array.Length * 2);
+ if (newCapacity < min)
+ {
+ newCapacity = min;
+ }
- this.Capacity = newCapacity;
- }
+ this.Capacity = newCapacity;
+ }
- #endregion
-
- #region Implementation (ICollection)
+ #endregion
+
+ #region Implementation (ICollection)
- void ICollection.CopyTo(Array array, int start)
- {
- Array.Copy(m_array, 0, array, start, m_count);
- }
+ void ICollection.CopyTo(Array array, int start)
+ {
+ Array.Copy(m_array, 0, array, start, m_count);
+ }
- #endregion
+ #endregion
- #region Implementation (IList)
+ #region Implementation (IList)
- object IList.this[int i]
- {
- get { return (object)this[i]; }
- set { this[i] = (Level)value; }
- }
+ object IList.this[int i]
+ {
+ get { return (object)this[i]; }
+ set { this[i] = (Level)value; }
+ }
- int IList.Add(object x)
- {
- return this.Add((Level)x);
- }
+ int IList.Add(object x)
+ {
+ return this.Add((Level)x);
+ }
- bool IList.Contains(object x)
- {
- return this.Contains((Level)x);
- }
+ bool IList.Contains(object x)
+ {
+ return this.Contains((Level)x);
+ }
- int IList.IndexOf(object x)
- {
- return this.IndexOf((Level)x);
- }
+ int IList.IndexOf(object x)
+ {
+ return this.IndexOf((Level)x);
+ }
- void IList.Insert(int pos, object x)
- {
- this.Insert(pos, (Level)x);
- }
+ void IList.Insert(int pos, object x)
+ {
+ this.Insert(pos, (Level)x);
+ }
- void IList.Remove(object x)
- {
- this.Remove((Level)x);
- }
+ void IList.Remove(object x)
+ {
+ this.Remove((Level)x);
+ }
- void IList.RemoveAt(int pos)
- {
- this.RemoveAt(pos);
- }
+ void IList.RemoveAt(int pos)
+ {
+ this.RemoveAt(pos);
+ }
- #endregion
+ #endregion
- #region Implementation (IEnumerable)
+ #region Implementation (IEnumerable)
- IEnumerator IEnumerable.GetEnumerator()
- {
- return (IEnumerator)(this.GetEnumerator());
- }
+ IEnumerator IEnumerable.GetEnumerator()
+ {
+ return (IEnumerator)(this.GetEnumerator());
+ }
- #endregion
+ #endregion
- #region Nested enumerator class
+ #region Nested enumerator class
- /// <summary>
- /// Supports simple iteration over a <see cref="LevelCollection"/>.
- /// </summary>
- private sealed class Enumerator : IEnumerator, ILevelCollectionEnumerator
- {
- #region Implementation (data)
-
- private readonly LevelCollection m_collection;
- private int m_index;
- private int m_version;
-
- #endregion
-
- #region Construction
-
- /// <summary>
- /// Initializes a new instance of the <c>Enumerator</c> class.
- /// </summary>
- /// <param name="tc"></param>
- internal Enumerator(LevelCollection tc)
- {
- m_collection = tc;
- m_index = -1;
- m_version = tc.m_version;
- }
-
- #endregion
-
- #region Operations (type-safe IEnumerator)
-
- /// <summary>
- /// Gets the current element in the collection.
- /// </summary>
- public Level Current
- {
- get { return m_collection[m_index]; }
- }
+ /// <summary>
+ /// Supports simple iteration over a <see cref="LevelCollection"/>.
+ /// </summary>
+ private sealed class Enumerator : IEnumerator, ILevelCollectionEnumerator
+ {
+ #region Implementation (data)
+
+ private readonly LevelCollection m_collection;
+ private int m_index;
+ private int m_version;
+
+ #endregion
+
+ #region Construction
+
+ /// <summary>
+ /// Initializes a new instance of the <c>Enumerator</c> class.
+ /// </summary>
+ /// <param name="tc"></param>
+ internal Enumerator(LevelCollection tc)
+ {
+ m_collection = tc;
+ m_index = -1;
+ m_version = tc.m_version;
+ }
+
+ #endregion
+
+ #region Operations (type-safe IEnumerator)
+
+ /// <summary>
+ /// Gets the current element in the collection.
+ /// </summary>
+ public Level Current
+ {
+ get { return m_collection[m_index]; }
+ }
- /// <summary>
- /// Advances the enumerator to the next element in the collection.
- /// </summary>
- /// <returns>
- /// <c>true</c> if the enumerator was successfully advanced to the next element;
- /// <c>false</c> if the enumerator has passed the end of the collection.
- /// </returns>
- /// <exception cref="InvalidOperationException">
- /// The collection was modified after the enumerator was created.
- /// </exception>
- public bool MoveNext()
- {
- if (m_version != m_collection.m_version)
- {
- throw new System.InvalidOperationException("Collection was modified; enumeration operation may not execute.");
- }
+ /// <summary>
+ /// Advances the enumerator to the next element in the collection.
+ /// </summary>
+ /// <returns>
+ /// <c>true</c> if the enumerator was successfully advanced to the next element;
+ /// <c>false</c> if the enumerator has passed the end of the collection.
+ /// </returns>
+ /// <exception cref="InvalidOperationException">
+ /// The collection was modified after the enumerator was created.
+ /// </exception>
+ public bool MoveNext()
+ {
+ if (m_version != m_collection.m_version)
+ {
+ throw new System.InvalidOperationException("Collection was modified; enumeration operation may not execute.");
+ }
- ++m_index;
- return (m_index < m_collection.Count);
- }
+ ++m_index;
+ return (m_index < m_collection.Count);
+ }
- /// <summary>
- /// Sets the enumerator to its initial position, before the first element in the collection.
- /// </summary>
- public void Reset()
- {
- m_index = -1;
- }
+ /// <summary>
+ /// Sets the enumerator to its initial position, before the first element in the collection.
+ /// </summary>
+ public void Reset()
+ {
+ m_index = -1;
+ }
- #endregion
-
- #region Implementation (IEnumerator)
-
- object IEnumerator.Current
- {
- get { return this.Current; }
- }
-
- #endregion
- }
+ #endregion
+
+ #region Implementation (IEnumerator)
+
+ object IEnumerator.Current
+ {
+ get { return this.Current; }
+ }
+
+ #endregion
+ }
- #endregion
+ #endregion
- #region Nested Read Only Wrapper class
+ #region Nested Read Only Wrapper class
- private sealed class ReadOnlyLevelCollection : LevelCollection
- {
- #region Implementation (data)
+ private sealed class ReadOnlyLevelCollection : LevelCollection
+ {
+ #region Implementation (data)
- private readonly LevelCollection m_collection;
+ private readonly LevelCollection m_collection;
- #endregion
+ #endregion
- #region Construction
+ #region Construction
- internal ReadOnlyLevelCollection(LevelCollection list) : base(Tag.Default)
- {
- m_collection = list;
- }
+ internal ReadOnlyLevelCollection(LevelCollection list) : base(Tag.Default)
+ {
+ m_collection = list;
+ }
- #endregion
+ #endregion
- #region Type-safe ICollection
+ #region Type-safe ICollection
- public override void CopyTo(Level[] array)
- {
- m_collection.CopyTo(array);
- }
+ public override void CopyTo(Level[] array)
+ {
+ m_collection.CopyTo(array);
+ }
- public override void CopyTo(Level[] array, int start)
- {
- m_collection.CopyTo(array,start);
- }
- public override int Count
- {
- get { return m_collection.Count; }
- }
+ public override void CopyTo(Level[] array, int start)
+ {
+ m_collection.CopyTo(array,start);
+ }
+ public override int Count
+ {
+ get { return m_collection.Count; }
+ }
- public override bool IsSynchronized
- {
- get { return m_collection.IsSynchronized; }
- }
+ public override bool IsSynchronized
+ {
+ get { return m_collection.IsSynchronized; }
+ }
- public override object SyncRoot
- {
- get { return this.m_collection.SyncRoot; }
- }
+ public override object SyncRoot
+ {
+ get { return this.m_collection.SyncRoot; }
+ }
- #endregion
+ #endregion
- #region Type-safe IList
+ #region Type-safe IList
- public override Level this[int i]
- {
- get { return m_collection[i]; }
- set { throw new NotSupportedException("This is a Read Only Collection and can not be modified"); }
- }
+ public override Level this[int i]
+ {
+ get { return m_collection[i]; }
+ set { throw new NotSupportedException("This is a Read Only Collection and can not be modified"); }
+ }
- public override int Add(Level x)
- {
- throw new NotSupportedException("This is a Read Only Collection and can not be modified");
- }
+ public override int Add(Level x)
+ {
+ throw new NotSupportedException("This is a Read Only Collection and can not be modified");
+ }
- public override void Clear()
- {
- throw new NotSupportedException("This is a Read Only Collection and can not be modified");
- }
+ public override void Clear()
+ {
+ throw new NotSupportedException("This is a Read Only Collection and can not be modified");
+ }
- public override bool Contains(Level x)
- {
- return m_collection.Contains(x);
- }
+ public override bool Contains(Level x)
+ {
+ return m_collection.Contains(x);
+ }
- public override int IndexOf(Level x)
- {
- return m_collection.IndexOf(x);
- }
+ public override int IndexOf(Level x)
+ {
+ return m_collection.IndexOf(x);
+ }
- public override void Insert(int pos, Level x)
- {
- throw new NotSupportedException("This is a Read Only Collection and can not be modified");
- }
+ public override void Insert(int pos, Level x)
+ {
+ throw new NotSupportedException("This is a Read Only Collection and can not be modified");
+ }
- public override void Remove(Level x)
- {
- throw new NotSupportedException("This is a Read Only Collection and can not be modified");
- }
+ public override void Remove(Level x)
+ {
+ throw new NotSupportedException("This is a Read Only Collection and can not be modified");
+ }
- public override void RemoveAt(int pos)
- {
- throw new NotSupportedException("This is a Read Only Collection and can not be modified");
- }
+ public override void RemoveAt(int pos)
+ {
+ throw new NotSupportedException("This is a Read Only Collection and can not be modified");
+ }
- public override bool IsFixedSize
- {
- get { return true; }
- }
+ public override bool IsFixedSize
+ {
+ get { return true; }
+ }
- public override bool IsReadOnly
- {
- get { return true; }
- }
+ public override bool IsReadOnly
+ {
+ get { return true; }
+ }
- #endregion
+ #endregion
- #region Type-safe IEnumerable
+ #region Type-safe IEnumerable
- public override ILevelCollectionEnumerator GetEnumerator()
- {
- return m_collection.GetEnumerator();
- }
+ public override ILevelCollectionEnumerator GetEnumerator()
+ {
+ return m_collection.GetEnumerator();
+ }
- #endregion
+ #endregion
- #region Public Helpers
+ #region Public Helpers
- // (just to mimic some nice features of ArrayList)
- public override int Capacity
- {
- get { return m_collection.Capacity; }
- set { throw new NotSupportedException("This is a Read Only Collection and can not be modified"); }
- }
+ // (just to mimic some nice features of ArrayList)
+ public override int Capacity
+ {
+ get { return m_collection.Capacity; }
+ set { throw new NotSupportedException("This is a Read Only Collection and can not be modified"); }
+ }
- public override int AddRange(LevelCollection x)
- {
- throw new NotSupportedException("This is a Read Only Collection and can not be modified");
- }
+ public override int AddRange(LevelCollection x)
+ {
+ throw new NotSupportedException("This is a Read Only Collection and can not be modified");
+ }
- public override int AddRange(Level[] x)
- {
- throw new NotSupportedException("This is a Read Only Collection and can not be modified");
- }
+ public override int AddRange(Level[] x)
+ {
+ throw new NotSupportedException("This is a Read Only Collection and can not be modified");
+ }
- #endregion
- }
+ #endregion
+ }
- #endregion
- }
+ #endregion
+ }
}
diff --git a/src/log4net/Core/LevelEvaluator.cs b/src/log4net/Core/LevelEvaluator.cs
index 35706df..d058cee 100644
--- a/src/log4net/Core/LevelEvaluator.cs
+++ b/src/log4net/Core/LevelEvaluator.cs
@@ -23,111 +23,111 @@
namespace log4net.Core
{
- /// <summary>
- /// An evaluator that triggers at a threshold level
- /// </summary>
- /// <remarks>
- /// <para>
- /// This evaluator will trigger if the level of the event
- /// passed to <see cref="M:IsTriggeringEvent(LoggingEvent)"/>
- /// is equal to or greater than the <see cref="Threshold"/>
- /// level.
- /// </para>
- /// </remarks>
- /// <author>Nicko Cadell</author>
- public class LevelEvaluator : ITriggeringEventEvaluator
- {
- /// <summary>
- /// The threshold for triggering
- /// </summary>
- private Level m_threshold;
+ /// <summary>
+ /// An evaluator that triggers at a threshold level
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// This evaluator will trigger if the level of the event
+ /// passed to <see cref="M:IsTriggeringEvent(LoggingEvent)"/>
+ /// is equal to or greater than the <see cref="Threshold"/>
+ /// level.
+ /// </para>
+ /// </remarks>
+ /// <author>Nicko Cadell</author>
+ public class LevelEvaluator : ITriggeringEventEvaluator
+ {
+ /// <summary>
+ /// The threshold for triggering
+ /// </summary>
+ private Level m_threshold;
- /// <summary>
- /// Create a new evaluator using the <see cref="Level.Off"/> threshold.
- /// </summary>
- /// <remarks>
- /// <para>
- /// Create a new evaluator using the <see cref="Level.Off"/> threshold.
- /// </para>
- /// <para>
- /// This evaluator will trigger if the level of the event
- /// passed to <see cref="M:IsTriggeringEvent(LoggingEvent)"/>
- /// is equal to or greater than the <see cref="Threshold"/>
- /// level.
- /// </para>
- /// </remarks>
- public LevelEvaluator() : this(Level.Off)
- {
- }
+ /// <summary>
+ /// Create a new evaluator using the <see cref="Level.Off"/> threshold.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Create a new evaluator using the <see cref="Level.Off"/> threshold.
+ /// </para>
+ /// <para>
+ /// This evaluator will trigger if the level of the event
+ /// passed to <see cref="M:IsTriggeringEvent(LoggingEvent)"/>
+ /// is equal to or greater than the <see cref="Threshold"/>
+ /// level.
+ /// </para>
+ /// </remarks>
+ public LevelEvaluator() : this(Level.Off)
+ {
+ }
- /// <summary>
- /// Create a new evaluator using the specified <see cref="Level"/> threshold.
- /// </summary>
- /// <param name="threshold">the threshold to trigger at</param>
- /// <remarks>
- /// <para>
- /// Create a new evaluator using the specified <see cref="Level"/> threshold.
- /// </para>
- /// <para>
- /// This evaluator will trigger if the level of the event
- /// passed to <see cref="M:IsTriggeringEvent(LoggingEvent)"/>
- /// is equal to or greater than the <see cref="Threshold"/>
- /// level.
- /// </para>
- /// </remarks>
- public LevelEvaluator(Level threshold)
- {
- if (threshold == null)
- {
- throw new ArgumentNullException("threshold");
- }
+ /// <summary>
+ /// Create a new evaluator using the specified <see cref="Level"/> threshold.
+ /// </summary>
+ /// <param name="threshold">the threshold to trigger at</param>
+ /// <remarks>
+ /// <para>
+ /// Create a new evaluator using the specified <see cref="Level"/> threshold.
+ /// </para>
+ /// <para>
+ /// This evaluator will trigger if the level of the event
+ /// passed to <see cref="M:IsTriggeringEvent(LoggingEvent)"/>
+ /// is equal to or greater than the <see cref="Threshold"/>
+ /// level.
+ /// </para>
+ /// </remarks>
+ public LevelEvaluator(Level threshold)
+ {
+ if (threshold == null)
+ {
+ throw new ArgumentNullException("threshold");
+ }
- m_threshold = threshold;
- }
+ m_threshold = threshold;
+ }
- /// <summary>
- /// the threshold to trigger at
- /// </summary>
- /// <value>
- /// The <see cref="Level"/> that will cause this evaluator to trigger
- /// </value>
- /// <remarks>
- /// <para>
- /// This evaluator will trigger if the level of the event
- /// passed to <see cref="M:IsTriggeringEvent(LoggingEvent)"/>
- /// is equal to or greater than the <see cref="Threshold"/>
- /// level.
- /// </para>
- /// </remarks>
- public Level Threshold
- {
- get { return m_threshold; }
- set { m_threshold = value; }
- }
+ /// <summary>
+ /// the threshold to trigger at
+ /// </summary>
+ /// <value>
+ /// The <see cref="Level"/> that will cause this evaluator to trigger
+ /// </value>
+ /// <remarks>
+ /// <para>
+ /// This evaluator will trigger if the level of the event
+ /// passed to <see cref="M:IsTriggeringEvent(LoggingEvent)"/>
+ /// is equal to or greater than the <see cref="Threshold"/>
+ /// level.
+ /// </para>
+ /// </remarks>
+ public Level Threshold
+ {
+ get { return m_threshold; }
+ set { m_threshold = value; }
+ }
- /// <summary>
- /// Is this <paramref name="loggingEvent"/> the triggering event?
- /// </summary>
- /// <param name="loggingEvent">The event to check</param>
- /// <returns>This method returns <c>true</c>, if the event level
- /// is equal or higher than the <see cref="Threshold"/>.
- /// Otherwise it returns <c>false</c></returns>
- /// <remarks>
- /// <para>
- /// This evaluator will trigger if the level of the event
- /// passed to <see cref="M:IsTriggeringEvent(LoggingEvent)"/>
- /// is equal to or greater than the <see cref="Threshold"/>
- /// level.
- /// </para>
- /// </remarks>
- public bool IsTriggeringEvent(LoggingEvent loggingEvent)
- {
- if (loggingEvent == null)
- {
- throw new ArgumentNullException("loggingEvent");
- }
+ /// <summary>
+ /// Is this <paramref name="loggingEvent"/> the triggering event?
+ /// </summary>
+ /// <param name="loggingEvent">The event to check</param>
+ /// <returns>This method returns <c>true</c>, if the event level
+ /// is equal or higher than the <see cref="Threshold"/>.
+ /// Otherwise it returns <c>false</c></returns>
+ /// <remarks>
+ /// <para>
+ /// This evaluator will trigger if the level of the event
+ /// passed to <see cref="M:IsTriggeringEvent(LoggingEvent)"/>
+ /// is equal to or greater than the <see cref="Threshold"/>
+ /// level.
+ /// </para>
+ /// </remarks>
+ public bool IsTriggeringEvent(LoggingEvent loggingEvent)
+ {
+ if (loggingEvent == null)
+ {
+ throw new ArgumentNullException("loggingEvent");
+ }
- return (loggingEvent.Level >= m_threshold);
- }
- }
+ return (loggingEvent.Level >= m_threshold);
+ }
+ }
}
diff --git a/src/log4net/Core/LevelMap.cs b/src/log4net/Core/LevelMap.cs
index d458533..7558d1a 100644
--- a/src/log4net/Core/LevelMap.cs
+++ b/src/log4net/Core/LevelMap.cs
@@ -25,205 +25,205 @@
namespace log4net.Core
{
- /// <summary>
- /// Mapping between string name and Level object
- /// </summary>
- /// <remarks>
- /// <para>
- /// Mapping between string name and <see cref="Level"/> object.
- /// This mapping is held separately for each <see cref="log4net.Repository.ILoggerRepository"/>.
- /// The level name is case insensitive.
- /// </para>
- /// </remarks>
- /// <author>Nicko Cadell</author>
- public sealed class LevelMap
- {
- #region Member Variables
+ /// <summary>
+ /// Mapping between string name and Level object
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Mapping between string name and <see cref="Level"/> object.
+ /// This mapping is held separately for each <see cref="log4net.Repository.ILoggerRepository"/>.
+ /// The level name is case insensitive.
+ /// </para>
+ /// </remarks>
+ /// <author>Nicko Cadell</author>
+ public sealed class LevelMap
+ {
+ #region Member Variables
- /// <summary>
- /// Mapping from level name to Level object. The
- /// level name is case insensitive
- /// </summary>
- private Hashtable m_mapName2Level = SystemInfo.CreateCaseInsensitiveHashtable();
+ /// <summary>
+ /// Mapping from level name to Level object. The
+ /// level name is case insensitive
+ /// </summary>
+ private Hashtable m_mapName2Level = SystemInfo.CreateCaseInsensitiveHashtable();
- #endregion
+ #endregion
- /// <summary>
- /// Construct the level map
- /// </summary>
- /// <remarks>
- /// <para>
- /// Construct the level map.
- /// </para>
- /// </remarks>
- public LevelMap()
- {
- }
+ /// <summary>
+ /// Construct the level map
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Construct the level map.
+ /// </para>
+ /// </remarks>
+ public LevelMap()
+ {
+ }
- /// <summary>
- /// Clear the internal maps of all levels
- /// </summary>
- /// <remarks>
- /// <para>
- /// Clear the internal maps of all levels
- /// </para>
- /// </remarks>
- public void Clear()
- {
- // Clear all current levels
- m_mapName2Level.Clear();
- }
+ /// <summary>
+ /// Clear the internal maps of all levels
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Clear the internal maps of all levels
+ /// </para>
+ /// </remarks>
+ public void Clear()
+ {
+ // Clear all current levels
+ m_mapName2Level.Clear();
+ }
- /// <summary>
- /// Lookup a <see cref="Level"/> by name
- /// </summary>
- /// <param name="name">The name of the Level to lookup</param>
- /// <returns>a Level from the map with the name specified</returns>
- /// <remarks>
- /// <para>
- /// Returns the <see cref="Level"/> from the
- /// map with the name specified. If the no level is
- /// found then <c>null</c> is returned.
- /// </para>
- /// </remarks>
- public Level this[string name]
- {
- get
- {
- if (name == null)
- {
- throw new ArgumentNullException("name");
- }
+ /// <summary>
+ /// Lookup a <see cref="Level"/> by name
+ /// </summary>
+ /// <param name="name">The name of the Level to lookup</param>
+ /// <returns>a Level from the map with the name specified</returns>
+ /// <remarks>
+ /// <para>
+ /// Returns the <see cref="Level"/> from the
+ /// map with the name specified. If the no level is
+ /// found then <c>null</c> is returned.
+ /// </para>
+ /// </remarks>
+ public Level this[string name]
+ {
+ get
+ {
+ if (name == null)
+ {
+ throw new ArgumentNullException("name");
+ }
- lock(this)
- {
- return (Level)m_mapName2Level[name];
- }
- }
- }
+ lock(this)
+ {
+ return (Level)m_mapName2Level[name];
+ }
+ }
+ }
- /// <summary>
- /// Create a new Level and add it to the map
- /// </summary>
- /// <param name="name">the string to display for the Level</param>
- /// <param name="value">the level value to give to the Level</param>
- /// <remarks>
- /// <para>
- /// Create a new Level and add it to the map
- /// </para>
- /// </remarks>
- /// <seealso cref="M:Add(string,int,string)"/>
- public void Add(string name, int value)
- {
- Add(name, value, null);
- }
+ /// <summary>
+ /// Create a new Level and add it to the map
+ /// </summary>
+ /// <param name="name">the string to display for the Level</param>
+ /// <param name="value">the level value to give to the Level</param>
+ /// <remarks>
+ /// <para>
+ /// Create a new Level and add it to the map
+ /// </para>
+ /// </remarks>
+ /// <seealso cref="M:Add(string,int,string)"/>
+ public void Add(string name, int value)
+ {
+ Add(name, value, null);
+ }
- /// <summary>
- /// Create a new Level and add it to the map
- /// </summary>
- /// <param name="name">the string to display for the Level</param>
- /// <param name="value">the level value to give to the Level</param>
- /// <param name="displayName">the display name to give to the Level</param>
- /// <remarks>
- /// <para>
- /// Create a new Level and add it to the map
- /// </para>
- /// </remarks>
- public void Add(string name, int value, string displayName)
- {
- if (name == null)
- {
- throw new ArgumentNullException("name");
- }
- if (name.Length == 0)
- {
- throw log4net.Util.SystemInfo.CreateArgumentOutOfRangeException("name", name, "Parameter: name, Value: ["+name+"] out of range. Level name must not be empty");
- }
+ /// <summary>
+ /// Create a new Level and add it to the map
+ /// </summary>
+ /// <param name="name">the string to display for the Level</param>
+ /// <param name="value">the level value to give to the Level</param>
+ /// <param name="displayName">the display name to give to the Level</param>
+ /// <remarks>
+ /// <para>
+ /// Create a new Level and add it to the map
+ /// </para>
+ /// </remarks>
+ public void Add(string name, int value, string displayName)
+ {
+ if (name == null)
+ {
+ throw new ArgumentNullException("name");
+ }
+ if (name.Length == 0)
+ {
+ throw log4net.Util.SystemInfo.CreateArgumentOutOfRangeException("name", name, "Parameter: name, Value: ["+name+"] out of range. Level name must not be empty");
+ }
- if (displayName == null || displayName.Length == 0)
- {
- displayName = name;
- }
+ if (displayName == null || displayName.Length == 0)
+ {
+ displayName = name;
+ }
- Add(new Level(value, name, displayName));
- }
+ Add(new Level(value, name, displayName));
+ }
- /// <summary>
- /// Add a Level to the map
- /// </summary>
- /// <param name="level">the Level to add</param>
- /// <remarks>
- /// <para>
- /// Add a Level to the map
- /// </para>
- /// </remarks>
- public void Add(Level level)
- {
- if (level == null)
- {
- throw new ArgumentNullException("level");
- }
- lock(this)
- {
- m_mapName2Level[level.Name] = level;
- }
- }
+ /// <summary>
+ /// Add a Level to the map
+ /// </summary>
+ /// <param name="level">the Level to add</param>
+ /// <remarks>
+ /// <para>
+ /// Add a Level to the map
+ /// </para>
+ /// </remarks>
+ public void Add(Level level)
+ {
+ if (level == null)
+ {
+ throw new ArgumentNullException("level");
+ }
+ lock(this)
+ {
+ m_mapName2Level[level.Name] = level;
+ }
+ }
- /// <summary>
- /// Return all possible levels as a list of Level objects.
- /// </summary>
- /// <returns>all possible levels as a list of Level objects</returns>
- /// <remarks>
- /// <para>
- /// Return all possible levels as a list of Level objects.
- /// </para>
- /// </remarks>
- public LevelCollection AllLevels
- {
- get
- {
- lock(this)
- {
- return new LevelCollection(m_mapName2Level.Values);
- }
- }
- }
+ /// <summary>
+ /// Return all possible levels as a list of Level objects.
+ /// </summary>
+ /// <returns>all possible levels as a list of Level objects</returns>
+ /// <remarks>
+ /// <para>
+ /// Return all possible levels as a list of Level objects.
+ /// </para>
+ /// </remarks>
+ public LevelCollection AllLevels
+ {
+ get
+ {
+ lock(this)
+ {
+ return new LevelCollection(m_mapName2Level.Values);
+ }
+ }
+ }
- /// <summary>
- /// Lookup a named level from the map
- /// </summary>
- /// <param name="defaultLevel">the name of the level to lookup is taken from this level.
- /// If the level is not set on the map then this level is added</param>
- /// <returns>the level in the map with the name specified</returns>
- /// <remarks>
- /// <para>
- /// Lookup a named level from the map. The name of the level to lookup is taken
- /// from the <see cref="Level.Name"/> property of the <paramref name="defaultLevel"/>
- /// argument.
- /// </para>
- /// <para>
- /// If no level with the specified name is found then the
- /// <paramref name="defaultLevel"/> argument is added to the level map
- /// and returned.
- /// </para>
- /// </remarks>
- public Level LookupWithDefault(Level defaultLevel)
- {
- if (defaultLevel == null)
- {
- throw new ArgumentNullException("defaultLevel");
- }
+ /// <summary>
+ /// Lookup a named level from the map
+ /// </summary>
+ /// <param name="defaultLevel">the name of the level to lookup is taken from this level.
+ /// If the level is not set on the map then this level is added</param>
+ /// <returns>the level in the map with the name specified</returns>
+ /// <remarks>
+ /// <para>
+ /// Lookup a named level from the map. The name of the level to lookup is taken
+ /// from the <see cref="Level.Name"/> property of the <paramref name="defaultLevel"/>
+ /// argument.
+ /// </para>
+ /// <para>
+ /// If no level with the specified name is found then the
+ /// <paramref name="defaultLevel"/> argument is added to the level map
+ /// and returned.
+ /// </para>
+ /// </remarks>
+ public Level LookupWithDefault(Level defaultLevel)
+ {
+ if (defaultLevel == null)
+ {
+ throw new ArgumentNullException("defaultLevel");
+ }
- lock(this)
- {
- Level level = (Level)m_mapName2Level[defaultLevel.Name];
- if (level == null)
- {
- m_mapName2Level[defaultLevel.Name] = defaultLevel;
- return defaultLevel;
- }
- return level;
- }
- }
- }
+ lock(this)
+ {
+ Level level = (Level)m_mapName2Level[defaultLevel.Name];
+ if (level == null)
+ {
+ m_mapName2Level[defaultLevel.Name] = defaultLevel;
+ return defaultLevel;
+ }
+ return level;
+ }
+ }
+ }
}
diff --git a/src/log4net/Core/LocationInfo.cs b/src/log4net/Core/LocationInfo.cs
index d364f9d..b240338 100644
--- a/src/log4net/Core/LocationInfo.cs
+++ b/src/log4net/Core/LocationInfo.cs
@@ -27,295 +27,295 @@
namespace log4net.Core
{
- /// <summary>
- /// The internal representation of caller location information.
- /// </summary>
- /// <remarks>
- /// <para>
- /// This class uses the <c>System.Diagnostics.StackTrace</c> class to generate
- /// a call stack. The caller's information is then extracted from this stack.
- /// </para>
- /// <para>
- /// The <c>System.Diagnostics.StackTrace</c> class is not supported on the
- /// .NET Compact Framework 1.0 therefore caller location information is not
- /// available on that framework.
- /// </para>
- /// <para>
- /// The <c>System.Diagnostics.StackTrace</c> class has this to say about Release builds:
- /// </para>
- /// <para>
- /// "StackTrace information will be most informative with Debug build configurations.
- /// By default, Debug builds include debug symbols, while Release builds do not. The
- /// debug symbols contain most of the file, method name, line number, and column
- /// information used in constructing StackFrame and StackTrace objects. StackTrace
- /// might not report as many method calls as expected, due to code transformations
- /// that occur during optimization."
- /// </para>
- /// <para>
- /// This means that in a Release build the caller information may be incomplete or may
- /// not exist at all! Therefore caller location information cannot be relied upon in a Release build.
- /// </para>
- /// </remarks>
- /// <author>Nicko Cadell</author>
- /// <author>Gert Driesen</author>
+ /// <summary>
+ /// The internal representation of caller location information.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// This class uses the <c>System.Diagnostics.StackTrace</c> class to generate
+ /// a call stack. The caller's information is then extracted from this stack.
+ /// </para>
+ /// <para>
+ /// The <c>System.Diagnostics.StackTrace</c> class is not supported on the
+ /// .NET Compact Framework 1.0 therefore caller location information is not
+ /// available on that framework.
+ /// </para>
+ /// <para>
+ /// The <c>System.Diagnostics.StackTrace</c> class has this to say about Release builds:
+ /// </para>
+ /// <para>
+ /// "StackTrace information will be most informative with Debug build configurations.
+ /// By default, Debug builds include debug symbols, while Release builds do not. The
+ /// debug symbols contain most of the file, method name, line number, and column
+ /// information used in constructing StackFrame and StackTrace objects. StackTrace
+ /// might not report as many method calls as expected, due to code transformations
+ /// that occur during optimization."
+ /// </para>
+ /// <para>
+ /// This means that in a Release build the caller information may be incomplete or may
+ /// not exist at all! Therefore caller location information cannot be relied upon in a Release build.
+ /// </para>
+ /// </remarks>
+ /// <author>Nicko Cadell</author>
+ /// <author>Gert Driesen</author>
#if !NETCF
- [Serializable]
+ [Serializable]
#endif
- public class LocationInfo
- {
- #region Public Instance Constructors
+ public class LocationInfo
+ {
+ #region Public Instance Constructors
- /// <summary>
- /// Constructor
- /// </summary>
- /// <param name="callerStackBoundaryDeclaringType">The declaring type of the method that is
- /// the stack boundary into the logging system for this call.</param>
- /// <remarks>
- /// <para>
- /// Initializes a new instance of the <see cref="LocationInfo" />
- /// class based on the current thread.
- /// </para>
- /// </remarks>
- public LocationInfo(Type callerStackBoundaryDeclaringType)
- {
- // Initialize all fields
- m_className = NA;
- m_fileName = NA;
- m_lineNumber = NA;
- m_methodName = NA;
- m_fullInfo = NA;
+ /// <summary>
+ /// Constructor
+ /// </summary>
+ /// <param name="callerStackBoundaryDeclaringType">The declaring type of the method that is
+ /// the stack boundary into the logging system for this call.</param>
+ /// <remarks>
+ /// <para>
+ /// Initializes a new instance of the <see cref="LocationInfo" />
+ /// class based on the current thread.
+ /// </para>
+ /// </remarks>
+ public LocationInfo(Type callerStackBoundaryDeclaringType)
+ {
+ // Initialize all fields
+ m_className = NA;
+ m_fileName = NA;
+ m_lineNumber = NA;
+ m_methodName = NA;
+ m_fullInfo = NA;
#if !NETCF && !NETSTANDARD1_3 // StackTrace isn't fully implemented for NETSTANDARD1_3 https://github.com/dotnet/corefx/issues/1797
- if (callerStackBoundaryDeclaringType != null)
- {
- try
- {
- StackTrace st = new StackTrace(true);
- int frameIndex = 0;
-
- // skip frames not from fqnOfCallingClass
- while (frameIndex < st.FrameCount)
- {
- StackFrame frame = st.GetFrame(frameIndex);
- if (frame != null && frame.GetMethod().DeclaringType == callerStackBoundaryDeclaringType)
- {
- break;
- }
- frameIndex++;
- }
+ if (callerStackBoundaryDeclaringType != null)
+ {
+ try
+ {
+ StackTrace st = new StackTrace(true);
+ int frameIndex = 0;
+
+ // skip frames not from fqnOfCallingClass
+ while (frameIndex < st.FrameCount)
+ {
+ StackFrame frame = st.GetFrame(frameIndex);
+ if (frame != null && frame.GetMethod().DeclaringType == callerStackBoundaryDeclaringType)
+ {
+ break;
+ }
+ frameIndex++;
+ }
- // skip frames from fqnOfCallingClass
- while (frameIndex < st.FrameCount)
- {
- StackFrame frame = st.GetFrame(frameIndex);
- if (frame != null && frame.GetMethod().DeclaringType != callerStackBoundaryDeclaringType)
- {
- break;
- }
- frameIndex++;
- }
+ // skip frames from fqnOfCallingClass
+ while (frameIndex < st.FrameCount)
+ {
+ StackFrame frame = st.GetFrame(frameIndex);
+ if (frame != null && frame.GetMethod().DeclaringType != callerStackBoundaryDeclaringType)
+ {
+ break;
+ }
+ frameIndex++;
+ }
- if (frameIndex < st.FrameCount)
- {
- // take into account the frames we skip above
- int adjustedFrameCount = st.FrameCount - frameIndex;
+ if (frameIndex < st.FrameCount)
+ {
+ // take into account the frames we skip above
+ int adjustedFrameCount = st.FrameCount - frameIndex;
ArrayList stackFramesList = new ArrayList(adjustedFrameCount);
- m_stackFrames = new StackFrameItem[adjustedFrameCount];
- for (int i=frameIndex; i < st.FrameCount; i++)
- {
- stackFramesList.Add(new StackFrameItem(st.GetFrame(i)));
- }
-
- stackFramesList.CopyTo(m_stackFrames, 0);
-
- // now frameIndex is the first 'user' caller frame
- StackFrame locationFrame = st.GetFrame(frameIndex);
+ m_stackFrames = new StackFrameItem[adjustedFrameCount];
+ for (int i=frameIndex; i < st.FrameCount; i++)
+ {
+ stackFramesList.Add(new StackFrameItem(st.GetFrame(i)));
+ }
+
+ stackFramesList.CopyTo(m_stackFrames, 0);
+
+ // now frameIndex is the first 'user' caller frame
+ StackFrame locationFrame = st.GetFrame(frameIndex);
- if (locationFrame != null)
- {
- System.Reflection.MethodBase method = locationFrame.GetMethod();
+ if (locationFrame != null)
+ {
+ System.Reflection.MethodBase method = locationFrame.GetMethod();
- if (method != null)
- {
- m_methodName = method.Name;
- if (method.DeclaringType != null)
- {
- m_className = method.DeclaringType.FullName;
- }
- }
- m_fileName = locationFrame.GetFileName();
- m_lineNumber = locationFrame.GetFileLineNumber().ToString(System.Globalization.NumberFormatInfo.InvariantInfo);
+ if (method != null)
+ {
+ m_methodName = method.Name;
+ if (method.DeclaringType != null)
+ {
+ m_className = method.DeclaringType.FullName;
+ }
+ }
+ m_fileName = locationFrame.GetFileName();
+ m_lineNumber = locationFrame.GetFileLineNumber().ToString(System.Globalization.NumberFormatInfo.InvariantInfo);
- // Combine all location info
- m_fullInfo = m_className + '.' + m_methodName + '(' + m_fileName + ':' + m_lineNumber + ')';
- }
- }
- }
- catch(System.Security.SecurityException)
- {
- // This security exception will occur if the caller does not have
- // some undefined set of SecurityPermission flags.
- LogLog.Debug(declaringType, "Security exception while trying to get caller stack frame. Error Ignored. Location Information Not Available.");
- }
- }
+ // Combine all location info
+ m_fullInfo = m_className + '.' + m_methodName + '(' + m_fileName + ':' + m_lineNumber + ')';
+ }
+ }
+ }
+ catch(System.Security.SecurityException)
+ {
+ // This security exception will occur if the caller does not have
+ // some undefined set of SecurityPermission flags.
+ LogLog.Debug(declaringType, "Security exception while trying to get caller stack frame. Error Ignored. Location Information Not Available.");
+ }
+ }
#endif
- }
+ }
- /// <summary>
- /// Constructor
- /// </summary>
- /// <param name="className">The fully qualified class name.</param>
- /// <param name="methodName">The method name.</param>
- /// <param name="fileName">The file name.</param>
- /// <param name="lineNumber">The line number of the method within the file.</param>
- /// <remarks>
- /// <para>
- /// Initializes a new instance of the <see cref="LocationInfo" />
- /// class with the specified data.
- /// </para>
- /// </remarks>
- public LocationInfo(string className, string methodName, string fileName, string lineNumber)
- {
- m_className = className;
- m_fileName = fileName;
- m_lineNumber = lineNumber;
- m_methodName = methodName;
- m_fullInfo = m_className + '.' + m_methodName + '(' + m_fileName +
- ':' + m_lineNumber + ')';
- }
+ /// <summary>
+ /// Constructor
+ /// </summary>
+ /// <param name="className">The fully qualified class name.</param>
+ /// <param name="methodName">The method name.</param>
+ /// <param name="fileName">The file name.</param>
+ /// <param name="lineNumber">The line number of the method within the file.</param>
+ /// <remarks>
+ /// <para>
+ /// Initializes a new instance of the <see cref="LocationInfo" />
+ /// class with the specified data.
+ /// </para>
+ /// </remarks>
+ public LocationInfo(string className, string methodName, string fileName, string lineNumber)
+ {
+ m_className = className;
+ m_fileName = fileName;
+ m_lineNumber = lineNumber;
+ m_methodName = methodName;
+ m_fullInfo = m_className + '.' + m_methodName + '(' + m_fileName +
+ ':' + m_lineNumber + ')';
+ }
- #endregion Public Instance Constructors
+ #endregion Public Instance Constructors
- #region Public Instance Properties
+ #region Public Instance Properties
- /// <summary>
- /// Gets the fully qualified class name of the caller making the logging
- /// request.
- /// </summary>
- /// <value>
- /// The fully qualified class name of the caller making the logging
- /// request.
- /// </value>
- /// <remarks>
- /// <para>
- /// Gets the fully qualified class name of the caller making the logging
- /// request.
- /// </para>
- /// </remarks>
- public string ClassName
- {
- get { return m_className; }
- }
+ /// <summary>
+ /// Gets the fully qualified class name of the caller making the logging
+ /// request.
+ /// </summary>
+ /// <value>
+ /// The fully qualified class name of the caller making the logging
+ /// request.
+ /// </value>
+ /// <remarks>
+ /// <para>
+ /// Gets the fully qualified class name of the caller making the logging
+ /// request.
+ /// </para>
+ /// </remarks>
+ public string ClassName
+ {
+ get { return m_className; }
+ }
- /// <summary>
- /// Gets the file name of the caller.
- /// </summary>
- /// <value>
- /// The file name of the caller.
- /// </value>
- /// <remarks>
- /// <para>
- /// Gets the file name of the caller.
- /// </para>
- /// </remarks>
- public string FileName
- {
- get { return m_fileName; }
- }
+ /// <summary>
+ /// Gets the file name of the caller.
+ /// </summary>
+ /// <value>
+ /// The file name of the caller.
+ /// </value>
+ /// <remarks>
+ /// <para>
+ /// Gets the file name of the caller.
+ /// </para>
+ /// </remarks>
+ public string FileName
+ {
+ get { return m_fileName; }
+ }
- /// <summary>
- /// Gets the line number of the caller.
- /// </summary>
- /// <value>
- /// The line number of the caller.
- /// </value>
- /// <remarks>
- /// <para>
- /// Gets the line number of the caller.
- /// </para>
- /// </remarks>
- public string LineNumber
- {
- get { return m_lineNumber; }
- }
+ /// <summary>
+ /// Gets the line number of the caller.
+ /// </summary>
+ /// <value>
+ /// The line number of the caller.
+ /// </value>
+ /// <remarks>
+ /// <para>
+ /// Gets the line number of the caller.
+ /// </para>
+ /// </remarks>
+ public string LineNumber
+ {
+ get { return m_lineNumber; }
+ }
- /// <summary>
- /// Gets the method name of the caller.
- /// </summary>
- /// <value>
- /// The method name of the caller.
- /// </value>
- /// <remarks>
- /// <para>
- /// Gets the method name of the caller.
- /// </para>
- /// </remarks>
- public string MethodName
- {
- get { return m_methodName; }
- }
+ /// <summary>
+ /// Gets the method name of the caller.
+ /// </summary>
+ /// <value>
+ /// The method name of the caller.
+ /// </value>
+ /// <remarks>
+ /// <para>
+ /// Gets the method name of the caller.
+ /// </para>
+ /// </remarks>
+ public string MethodName
+ {
+ get { return m_methodName; }
+ }
- /// <summary>
- /// Gets all available caller information
- /// </summary>
- /// <value>
- /// All available caller information, in the format
- /// <c>fully.qualified.classname.of.caller.methodName(Filename:line)</c>
- /// </value>
- /// <remarks>
- /// <para>
- /// Gets all available caller information, in the format
- /// <c>fully.qualified.classname.of.caller.methodName(Filename:line)</c>
- /// </para>
- /// </remarks>
- public string FullInfo
- {
- get { return m_fullInfo; }
- }
-
+ /// <summary>
+ /// Gets all available caller information
+ /// </summary>
+ /// <value>
+ /// All available caller information, in the format
+ /// <c>fully.qualified.classname.of.caller.methodName(Filename:line)</c>
+ /// </value>
+ /// <remarks>
+ /// <para>
+ /// Gets all available caller information, in the format
+ /// <c>fully.qualified.classname.of.caller.methodName(Filename:line)</c>
+ /// </para>
+ /// </remarks>
+ public string FullInfo
+ {
+ get { return m_fullInfo; }
+ }
+
#if !NETCF && !NETSTANDARD1_3
- /// <summary>
- /// Gets the stack frames from the stack trace of the caller making the log request
- /// </summary>
- public StackFrameItem[] StackFrames
- {
- get { return m_stackFrames; }
- }
+ /// <summary>
+ /// Gets the stack frames from the stack trace of the caller making the log request
+ /// </summary>
+ public StackFrameItem[] StackFrames
+ {
+ get { return m_stackFrames; }
+ }
#endif
- #endregion Public Instance Properties
+ #endregion Public Instance Properties
- #region Private Instance Fields
+ #region Private Instance Fields
- private readonly string m_className;
- private readonly string m_fileName;
- private readonly string m_lineNumber;
- private readonly string m_methodName;
- private readonly string m_fullInfo;
+ private readonly string m_className;
+ private readonly string m_fileName;
+ private readonly string m_lineNumber;
+ private readonly string m_methodName;
+ private readonly string m_fullInfo;
#if !NETCF && !NETSTANDARD1_3
- private readonly StackFrameItem[] m_stackFrames;
+ private readonly StackFrameItem[] m_stackFrames;
#endif
- #endregion Private Instance Fields
+ #endregion Private Instance Fields
- #region Private Static Fields
+ #region Private Static Fields
- /// <summary>
- /// The fully qualified type of the LocationInfo class.
- /// </summary>
- /// <remarks>
- /// Used by the internal logger to record the Type of the
- /// log message.
- /// </remarks>
- private static readonly Type declaringType = typeof(LocationInfo);
+ /// <summary>
+ /// The fully qualified type of the LocationInfo class.
+ /// </summary>
+ /// <remarks>
+ /// Used by the internal logger to record the Type of the
+ /// log message.
+ /// </remarks>
+ private static readonly Type declaringType = typeof(LocationInfo);
- /// <summary>
- /// When location information is not available the constant
- /// <c>NA</c> is returned. Current value of this string
- /// constant is <b>?</b>.
- /// </summary>
- private const string NA = "?";
+ /// <summary>
+ /// When location information is not available the constant
+ /// <c>NA</c> is returned. Current value of this string
+ /// constant is <b>?</b>.
+ /// </summary>
+ private const string NA = "?";
- #endregion Private Static Fields
- }
+ #endregion Private Static Fields
+ }
}
diff --git a/src/log4net/Core/LogException.cs b/src/log4net/Core/LogException.cs
index 32a64ff..8824389 100644
--- a/src/log4net/Core/LogException.cs
+++ b/src/log4net/Core/LogException.cs
@@ -24,91 +24,91 @@
namespace log4net.Core
{
- /// <summary>
- /// Exception base type for log4net.
- /// </summary>
- /// <remarks>
- /// <para>
- /// This type extends <see cref="ApplicationException"/>. It
- /// does not add any new functionality but does differentiate the
- /// type of exception being thrown.
- /// </para>
- /// </remarks>
- /// <author>Nicko Cadell</author>
- /// <author>Gert Driesen</author>
+ /// <summary>
+ /// Exception base type for log4net.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// This type extends <see cref="ApplicationException"/>. It
+ /// does not add any new functionality but does differentiate the
+ /// type of exception being thrown.
+ /// </para>
+ /// </remarks>
+ /// <author>Nicko Cadell</author>
+ /// <author>Gert Driesen</author>
#if !NETCF
- [Serializable]
+ [Serializable]
#endif
#if NETSTANDARD1_3
- public class LogException : Exception
+ public class LogException : Exception
#else
- public class LogException : ApplicationException
+ public class LogException : ApplicationException
#endif
- {
- #region Public Instance Constructors
+ {
+ #region Public Instance Constructors
- /// <summary>
- /// Constructor
- /// </summary>
- /// <remarks>
- /// <para>
- /// Initializes a new instance of the <see cref="LogException" /> class.
- /// </para>
- /// </remarks>
- public LogException()
- {
- }
+ /// <summary>
+ /// Constructor
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Initializes a new instance of the <see cref="LogException" /> class.
+ /// </para>
+ /// </remarks>
+ public LogException()
+ {
+ }
- /// <summary>
- /// Constructor
- /// </summary>
- /// <param name="message">A message to include with the exception.</param>
- /// <remarks>
- /// <para>
- /// Initializes a new instance of the <see cref="LogException" /> class with
- /// the specified message.
- /// </para>
- /// </remarks>
- public LogException(String message) : base(message)
- {
- }
-
- /// <summary>
- /// Constructor
- /// </summary>
- /// <param name="message">A message to include with the exception.</param>
- /// <param name="innerException">A nested exception to include.</param>
- /// <remarks>
- /// <para>
- /// Initializes a new instance of the <see cref="LogException" /> class
- /// with the specified message and inner exception.
- /// </para>
- /// </remarks>
- public LogException(String message, Exception innerException) : base(message, innerException)
- {
- }
+ /// <summary>
+ /// Constructor
+ /// </summary>
+ /// <param name="message">A message to include with the exception.</param>
+ /// <remarks>
+ /// <para>
+ /// Initializes a new instance of the <see cref="LogException" /> class with
+ /// the specified message.
+ /// </para>
+ /// </remarks>
+ public LogException(String message) : base(message)
+ {
+ }
+
+ /// <summary>
+ /// Constructor
+ /// </summary>
+ /// <param name="message">A message to include with the exception.</param>
+ /// <param name="innerException">A nested exception to include.</param>
+ /// <remarks>
+ /// <para>
+ /// Initializes a new instance of the <see cref="LogException" /> class
+ /// with the specified message and inner exception.
+ /// </para>
+ /// </remarks>
+ public LogException(String message, Exception innerException) : base(message, innerException)
+ {
+ }
- #endregion Public Instance Constructors
+ #endregion Public Instance Constructors
- #region Protected Instance Constructors
+ #region Protected Instance Constructors
#if !NETCF && !NETSTANDARD1_3
- /// <summary>
- /// Serialization constructor
- /// </summary>
- /// <param name="info">The <see cref="SerializationInfo" /> that holds the serialized object data about the exception being thrown.</param>
- /// <param name="context">The <see cref="StreamingContext" /> that contains contextual information about the source or destination.</param>
- /// <remarks>
- /// <para>
- /// Initializes a new instance of the <see cref="LogException" /> class
- /// with serialized data.
- /// </para>
- /// </remarks>
- protected LogException(SerializationInfo info, StreamingContext context) : base(info, context)
- {
- }
+ /// <summary>
+ /// Serialization constructor
+ /// </summary>
+ /// <param name="info">The <see cref="SerializationInfo" /> that holds the serialized object data about the exception being thrown.</param>
+ /// <param name="context">The <see cref="StreamingContext" /> that contains contextual information about the source or destination.</param>
+ /// <remarks>
+ /// <para>
+ /// Initializes a new instance of the <see cref="LogException" /> class
+ /// with serialized data.
+ /// </para>
+ /// </remarks>
+ protected LogException(SerializationInfo info, StreamingContext context) : base(info, context)
+ {
+ }
#endif
- #endregion Protected Instance Constructors
- }
+ #endregion Protected Instance Constructors
+ }
}
diff --git a/src/log4net/Core/LogImpl.cs b/src/log4net/Core/LogImpl.cs
index f997ac3..965b5aa 100644
--- a/src/log4net/Core/LogImpl.cs
+++ b/src/log4net/Core/LogImpl.cs
@@ -25,1272 +25,1272 @@
namespace log4net.Core
{
- /// <summary>
- /// Implementation of <see cref="ILog"/> wrapper interface.
- /// </summary>
- /// <remarks>
- /// <para>
- /// This implementation of the <see cref="ILog"/> interface
- /// forwards to the <see cref="ILogger"/> held by the base class.
- /// </para>
- /// <para>
- /// This logger has methods to allow the caller to log at the following
- /// levels:
- /// </para>
- /// <list type="definition">
- /// <item>
- /// <term>DEBUG</term>
- /// <description>
- /// The <see cref="M:Debug(object)"/> and <see cref="M:DebugFormat(string, object[])"/> methods log messages
- /// at the <c>DEBUG</c> level. That is the level with that name defined in the
- /// repositories <see cref="ILoggerRepository.LevelMap"/>. The default value
- /// for this level is <see cref="Level.Debug"/>. The <see cref="IsDebugEnabled"/>
- /// property tests if this level is enabled for logging.
- /// </description>
- /// </item>
- /// <item>
- /// <term>INFO</term>
- /// <description>
- /// The <see cref="M:Info(object)"/> and <see cref="M:InfoFormat(string, object[])"/> methods log messages
- /// at the <c>INFO</c> level. That is the level with that name defined in the
- /// repositories <see cref="ILoggerRepository.LevelMap"/>. The default value
- /// for this level is <see cref="Level.Info"/>. The <see cref="IsInfoEnabled"/>
- /// property tests if this level is enabled for logging.
- /// </description>
- /// </item>
- /// <item>
- /// <term>WARN</term>
- /// <description>
- /// The <see cref="M:Warn(object)"/> and <see cref="M:WarnFormat(string, object[])"/> methods log messages
- /// at the <c>WARN</c> level. That is the level with that name defined in the
- /// repositories <see cref="ILoggerRepository.LevelMap"/>. The default value
- /// for this level is <see cref="Level.Warn"/>. The <see cref="IsWarnEnabled"/>
- /// property tests if this level is enabled for logging.
- /// </description>
- /// </item>
- /// <item>
- /// <term>ERROR</term>
- /// <description>
- /// The <see cref="M:Error(object)"/> and <see cref="M:ErrorFormat(string, object[])"/> methods log messages
- /// at the <c>ERROR</c> level. That is the level with that name defined in the
- /// repositories <see cref="ILoggerRepository.LevelMap"/>. The default value
- /// for this level is <see cref="Level.Error"/>. The <see cref="IsErrorEnabled"/>
- /// property tests if this level is enabled for logging.
- /// </description>
- /// </item>
- /// <item>
- /// <term>FATAL</term>
- /// <description>
- /// The <see cref="M:Fatal(object)"/> and <see cref="M:FatalFormat(string, object[])"/> methods log messages
- /// at the <c>FATAL</c> level. That is the level with that name defined in the
- /// repositories <see cref="ILoggerRepository.LevelMap"/>. The default value
- /// for this level is <see cref="Level.Fatal"/>. The <see cref="IsFatalEnabled"/>
- /// property tests if this level is enabled for logging.
- /// </description>
- /// </item>
- /// </list>
- /// <para>
- /// The values for these levels and their semantic meanings can be changed by
- /// configuring the <see cref="ILoggerRepository.LevelMap"/> for the repository.
- /// </para>
- /// </remarks>
- /// <author>Nicko Cadell</author>
- /// <author>Gert Driesen</author>
- public class LogImpl : LoggerWrapperImpl, ILog
- {
- #region Public Instance Constructors
+ /// <summary>
+ /// Implementation of <see cref="ILog"/> wrapper interface.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// This implementation of the <see cref="ILog"/> interface
+ /// forwards to the <see cref="ILogger"/> held by the base class.
+ /// </para>
+ /// <para>
+ /// This logger has methods to allow the caller to log at the following
+ /// levels:
+ /// </para>
+ /// <list type="definition">
+ /// <item>
+ /// <term>DEBUG</term>
+ /// <description>
+ /// The <see cref="M:Debug(object)"/> and <see cref="M:DebugFormat(string, object[])"/> methods log messages
+ /// at the <c>DEBUG</c> level. That is the level with that name defined in the
+ /// repositories <see cref="ILoggerRepository.LevelMap"/>. The default value
+ /// for this level is <see cref="Level.Debug"/>. The <see cref="IsDebugEnabled"/>
+ /// property tests if this level is enabled for logging.
+ /// </description>
+ /// </item>
+ /// <item>
+ /// <term>INFO</term>
+ /// <description>
+ /// The <see cref="M:Info(object)"/> and <see cref="M:InfoFormat(string, object[])"/> methods log messages
+ /// at the <c>INFO</c> level. That is the level with that name defined in the
+ /// repositories <see cref="ILoggerRepository.LevelMap"/>. The default value
+ /// for this level is <see cref="Level.Info"/>. The <see cref="IsInfoEnabled"/>
+ /// property tests if this level is enabled for logging.
+ /// </description>
+ /// </item>
+ /// <item>
+ /// <term>WARN</term>
+ /// <description>
+ /// The <see cref="M:Warn(object)"/> and <see cref="M:WarnFormat(string, object[])"/> methods log messages
+ /// at the <c>WARN</c> level. That is the level with that name defined in the
+ /// repositories <see cref="ILoggerRepository.LevelMap"/>. The default value
+ /// for this level is <see cref="Level.Warn"/>. The <see cref="IsWarnEnabled"/>
+ /// property tests if this level is enabled for logging.
+ /// </description>
+ /// </item>
+ /// <item>
+ /// <term>ERROR</term>
+ /// <description>
+ /// The <see cref="M:Error(object)"/> and <see cref="M:ErrorFormat(string, object[])"/> methods log messages
+ /// at the <c>ERROR</c> level. That is the level with that name defined in the
+ /// repositories <see cref="ILoggerRepository.LevelMap"/>. The default value
+ /// for this level is <see cref="Level.Error"/>. The <see cref="IsErrorEnabled"/>
+ /// property tests if this level is enabled for logging.
+ /// </description>
+ /// </item>
+ /// <item>
+ /// <term>FATAL</term>
+ /// <description>
+ /// The <see cref="M:Fatal(object)"/> and <see cref="M:FatalFormat(string, object[])"/> methods log messages
+ /// at the <c>FATAL</c> level. That is the level with that name defined in the
+ /// repositories <see cref="ILoggerRepository.LevelMap"/>. The default value
+ /// for this level is <see cref="Level.Fatal"/>. The <see cref="IsFatalEnabled"/>
+ /// property tests if this level is enabled for logging.
+ /// </description>
+ /// </item>
+ /// </list>
+ /// <para>
+ /// The values for these levels and their semantic meanings can be changed by
+ /// configuring the <see cref="ILoggerRepository.LevelMap"/> for the repository.
+ /// </para>
+ /// </remarks>
+ /// <author>Nicko Cadell</author>
+ /// <author>Gert Driesen</author>
+ public class LogImpl : LoggerWrapperImpl, ILog
+ {
+ #region Public Instance Constructors
- /// <summary>
- /// Construct a new wrapper for the specified logger.
- /// </summary>
- /// <param name="logger">The logger to wrap.</param>
- /// <remarks>
- /// <para>
- /// Construct a new wrapper for the specified logger.
- /// </para>
- /// </remarks>
- public LogImpl(ILogger logger) : base(logger)
- {
- // Listen for changes to the repository
- logger.Repository.ConfigurationChanged += new LoggerRepositoryConfigurationChangedEventHandler(LoggerRepositoryConfigurationChanged);
+ /// <summary>
+ /// Construct a new wrapper for the specified logger.
+ /// </summary>
+ /// <param name="logger">The logger to wrap.</param>
+ /// <remarks>
+ /// <para>
+ /// Construct a new wrapper for the specified logger.
+ /// </para>
+ /// </remarks>
+ public LogImpl(ILogger logger) : base(logger)
+ {
+ // Listen for changes to the repository
+ logger.Repository.ConfigurationChanged += new LoggerRepositoryConfigurationChangedEventHandler(LoggerRepositoryConfigurationChanged);
- // load the current levels
- ReloadLevels(logger.Repository);
- }
+ // load the current levels
+ ReloadLevels(logger.Repository);
+ }
- #endregion Public Instance Constructors
+ #endregion Public Instance Constructors
- /// <summary>
- /// Virtual method called when the configuration of the repository changes
- /// </summary>
- /// <param name="repository">the repository holding the levels</param>
- /// <remarks>
- /// <para>
- /// Virtual method called when the configuration of the repository changes
- /// </para>
- /// </remarks>
- protected virtual void ReloadLevels(ILoggerRepository repository)
- {
- LevelMap levelMap = repository.LevelMap;
+ /// <summary>
+ /// Virtual method called when the configuration of the repository changes
+ /// </summary>
+ /// <param name="repository">the repository holding the levels</param>
+ /// <remarks>
+ /// <para>
+ /// Virtual method called when the configuration of the repository changes
+ /// </para>
+ /// </remarks>
+ protected virtual void ReloadLevels(ILoggerRepository repository)
+ {
+ LevelMap levelMap = repository.LevelMap;
- m_levelDebug = levelMap.LookupWithDefault(Level.Debug);
- m_levelInfo = levelMap.LookupWithDefault(Level.Info);
- m_levelWarn = levelMap.LookupWithDefault(Level.Warn);
- m_levelError = levelMap.LookupWithDefault(Level.Error);
- m_levelFatal = levelMap.LookupWithDefault(Level.Fatal);
- }
+ m_levelDebug = levelMap.LookupWithDefault(Level.Debug);
+ m_levelInfo = levelMap.LookupWithDefault(Level.Info);
+ m_levelWarn = levelMap.LookupWithDefault(Level.Warn);
+ m_levelError = levelMap.LookupWithDefault(Level.Error);
+ m_levelFatal = levelMap.LookupWithDefault(Level.Fatal);
+ }
- #region Implementation of ILog
+ #region Implementation of ILog
- /// <summary>
- /// Logs a message object with the <c>DEBUG</c> level.
- /// </summary>
- /// <param name="message">The message object to log.</param>
- /// <remarks>
- /// <para>
- /// This method first checks if this logger is <c>DEBUG</c>
- /// enabled by comparing the level of this logger with the
- /// <c>DEBUG</c> level. If this logger is
- /// <c>DEBUG</c> enabled, then it converts the message object
- /// (passed as parameter) to a string by invoking the appropriate
- /// <see cref="log4net.ObjectRenderer.IObjectRenderer"/>. It then
- /// proceeds to call all the registered appenders in this logger
- /// and also higher in the hierarchy depending on the value of the
- /// additivity flag.
- /// </para>
- /// <para>
- /// <b>WARNING</b> Note that passing an <see cref="Exception"/>
- /// to this method will print the name of the <see cref="Exception"/>
- /// but no stack trace. To print a stack trace use the
- /// <see cref="M:Debug(object,Exception)"/> form instead.
- /// </para>
- /// </remarks>
- public virtual void Debug(object message)
- {
- Logger.Log(ThisDeclaringType, m_levelDebug, message, null);
- }
+ /// <summary>
+ /// Logs a message object with the <c>DEBUG</c> level.
+ /// </summary>
+ /// <param name="message">The message object to log.</param>
+ /// <remarks>
+ /// <para>
+ /// This method first checks if this logger is <c>DEBUG</c>
+ /// enabled by comparing the level of this logger with the
+ /// <c>DEBUG</c> level. If this logger is
+ /// <c>DEBUG</c> enabled, then it converts the message object
+ /// (passed as parameter) to a string by invoking the appropriate
+ /// <see cref="log4net.ObjectRenderer.IObjectRenderer"/>. It then
+ /// proceeds to call all the registered appenders in this logger
+ /// and also higher in the hierarchy depending on the value of the
+ /// additivity flag.
+ /// </para>
+ /// <para>
+ /// <b>WARNING</b> Note that passing an <see cref="Exception"/>
+ /// to this method will print the name of the <see cref="Exception"/>
+ /// but no stack trace. To print a stack trace use the
+ /// <see cref="M:Debug(object,Exception)"/> form instead.
+ /// </para>
+ /// </remarks>
+ public virtual void Debug(object message)
+ {
+ Logger.Log(ThisDeclaringType, m_levelDebug, message, null);
+ }
- /// <summary>
- /// Logs a message object with the <c>DEBUG</c> level
- /// </summary>
- /// <param name="message">The message object to log.</param>
- /// <param name="exception">The exception to log, including its stack trace.</param>
- /// <remarks>
- /// <para>
- /// Logs a message object with the <c>DEBUG</c> level including
- /// the stack trace of the <see cref="Exception"/> <paramref name="exception"/> passed
- /// as a parameter.
- /// </para>
- /// <para>
- /// See the <see cref="M:Debug(object)"/> form for more detailed information.
- /// </para>
- /// </remarks>
- /// <seealso cref="M:Debug(object)"/>
- public virtual void Debug(object message, Exception exception)
- {
- Logger.Log(ThisDeclaringType, m_levelDebug, message, exception);
- }
+ /// <summary>
+ /// Logs a message object with the <c>DEBUG</c> level
+ /// </summary>
+ /// <param name="message">The message object to log.</param>
+ /// <param name="exception">The exception to log, including its stack trace.</param>
+ /// <remarks>
+ /// <para>
+ /// Logs a message object with the <c>DEBUG</c> level including
+ /// the stack trace of the <see cref="Exception"/> <paramref name="exception"/> passed
+ /// as a parameter.
+ /// </para>
+ /// <para>
+ /// See the <see cref="M:Debug(object)"/> form for more detailed information.
+ /// </para>
+ /// </remarks>
+ /// <seealso cref="M:Debug(object)"/>
+ public virtual void Debug(object message, Exception exception)
+ {
+ Logger.Log(ThisDeclaringType, m_levelDebug, message, exception);
+ }
- /// <summary>
- /// Logs a formatted message string with the <c>DEBUG</c> level.
- /// </summary>
- /// <param name="format">A String containing zero or more format items</param>
- /// <param name="args">An Object array containing zero or more objects to format</param>
- /// <remarks>
- /// <para>
- /// The message is formatted using the <see cref="M:String.Format(IFormatProvider, string, object[])"/> method. See
- /// <c>String.Format</c> for details of the syntax of the format string and the behavior
- /// of the formatting.
- /// </para>
- /// <para>
- /// The string is formatted using the <see cref="CultureInfo.InvariantCulture"/>
- /// format provider. To specify a localized provider use the
- /// <see cref="M:DebugFormat(IFormatProvider,string,object[])"/> method.
- /// </para>
- /// <para>
- /// This method does not take an <see cref="Exception"/> object to include in the
- /// log event. To pass an <see cref="Exception"/> use one of the <see cref="M:Debug(object)"/>
- /// methods instead.
- /// </para>
- /// </remarks>
- public virtual void DebugFormat(string format, params object[] args)
- {
- if (IsDebugEnabled)
- {
- Logger.Log(ThisDeclaringType, m_levelDebug, new SystemStringFormat(CultureInfo.InvariantCulture, format, args), null);
- }
- }
+ /// <summary>
+ /// Logs a formatted message string with the <c>DEBUG</c> level.
+ /// </summary>
+ /// <param name="format">A String containing zero or more format items</param>
+ /// <param name="args">An Object array containing zero or more objects to format</param>
+ /// <remarks>
+ /// <para>
+ /// The message is formatted using the <see cref="M:String.Format(IFormatProvider, string, object[])"/> method. See
+ /// <c>String.Format</c> for details of the syntax of the format string and the behavior
+ /// of the formatting.
+ /// </para>
+ /// <para>
+ /// The string is formatted using the <see cref="CultureInfo.InvariantCulture"/>
+ /// format provider. To specify a localized provider use the
+ /// <see cref="M:DebugFormat(IFormatProvider,string,object[])"/> method.
+ /// </para>
+ /// <para>
+ /// This method does not take an <see cref="Exception"/> object to include in the
+ /// log event. To pass an <see cref="Exception"/> use one of the <see cref="M:Debug(object)"/>
+ /// methods instead.
+ /// </para>
+ /// </remarks>
+ public virtual void DebugFormat(string format, params object[] args)
+ {
+ if (IsDebugEnabled)
+ {
+ Logger.Log(ThisDeclaringType, m_levelDebug, new SystemStringFormat(CultureInfo.InvariantCulture, format, args), null);
+ }
+ }
- /// <summary>
- /// Logs a formatted message string with the <c>DEBUG</c> level.
- /// </summary>
- /// <param name="format">A String containing zero or more format items</param>
- /// <param name="arg0">An Object to format</param>
- /// <remarks>
- /// <para>
- /// The message is formatted using the <see cref="M:String.Format(IFormatProvider, string, object[])"/> method. See
- /// <c>String.Format</c> for details of the syntax of the format string and the behavior
- /// of the formatting.
- /// </para>
- /// <para>
- /// The string is formatted using the <see cref="CultureInfo.InvariantCulture"/>
- /// format provider. To specify a localized provider use the
- /// <see cref="M:DebugFormat(IFormatProvider,string,object[])"/> method.
- /// </para>
- /// <para>
- /// This method does not take an <see cref="Exception"/> object to include in the
- /// log event. To pass an <see cref="Exception"/> use one of the <see cref="M:Debug(object)"/>
- /// methods instead.
- /// </para>
- /// </remarks>
- public virtual void DebugFormat(string format, object arg0)
- {
- if (IsDebugEnabled)
- {
- Logger.Log(ThisDeclaringType, m_levelDebug, new SystemStringFormat(CultureInfo.InvariantCulture, format, new object[] { arg0 }), null);
- }
- }
+ /// <summary>
+ /// Logs a formatted message string with the <c>DEBUG</c> level.
+ /// </summary>
+ /// <param name="format">A String containing zero or more format items</param>
+ /// <param name="arg0">An Object to format</param>
+ /// <remarks>
+ /// <para>
+ /// The message is formatted using the <see cref="M:String.Format(IFormatProvider, string, object[])"/> method. See
+ /// <c>String.Format</c> for details of the syntax of the format string and the behavior
+ /// of the formatting.
+ /// </para>
+ /// <para>
+ /// The string is formatted using the <see cref="CultureInfo.InvariantCulture"/>
+ /// format provider. To specify a localized provider use the
+ /// <see cref="M:DebugFormat(IFormatProvider,string,object[])"/> method.
+ /// </para>
+ /// <para>
+ /// This method does not take an <see cref="Exception"/> object to include in the
+ /// log event. To pass an <see cref="Exception"/> use one of the <see cref="M:Debug(object)"/>
+ /// methods instead.
+ /// </para>
+ /// </remarks>
+ public virtual void DebugFormat(string format, object arg0)
+ {
+ if (IsDebugEnabled)
+ {
+ Logger.Log(ThisDeclaringType, m_levelDebug, new SystemStringFormat(CultureInfo.InvariantCulture, format, new object[] { arg0 }), null);
+ }
+ }
- /// <summary>
- /// Logs a formatted message string with the <c>DEBUG</c> level.
- /// </summary>
- /// <param name="format">A String containing zero or more format items</param>
- /// <param name="arg0">An Object to format</param>
- /// <param name="arg1">An Object to format</param>
- /// <remarks>
- /// <para>
- /// The message is formatted using the <see cref="M:String.Format(IFormatProvider, string, object[])"/> method. See
- /// <c>String.Format</c> for details of the syntax of the format string and the behavior
- /// of the formatting.
- /// </para>
- /// <para>
- /// The string is formatted using the <see cref="CultureInfo.InvariantCulture"/>
- /// format provider. To specify a localized provider use the
- /// <see cref="M:DebugFormat(IFormatProvider,string,object[])"/> method.
- /// </para>
- /// <para>
- /// This method does not take an <see cref="Exception"/> object to include in the
- /// log event. To pass an <see cref="Exception"/> use one of the <see cref="M:Debug(object)"/>
- /// methods instead.
- /// </para>
- /// </remarks>
- public virtual void DebugFormat(string format, object arg0, object arg1)
- {
- if (IsDebugEnabled)
- {
- Logger.Log(ThisDeclaringType, m_levelDebug, new SystemStringFormat(CultureInfo.InvariantCulture, format, new object[] { arg0, arg1 }), null);
- }
- }
+ /// <summary>
+ /// Logs a formatted message string with the <c>DEBUG</c> level.
+ /// </summary>
+ /// <param name="format">A String containing zero or more format items</param>
+ /// <param name="arg0">An Object to format</param>
+ /// <param name="arg1">An Object to format</param>
+ /// <remarks>
+ /// <para>
+ /// The message is formatted using the <see cref="M:String.Format(IFormatProvider, string, object[])"/> method. See
+ /// <c>String.Format</c> for details of the syntax of the format string and the behavior
+ /// of the formatting.
+ /// </para>
+ /// <para>
+ /// The string is formatted using the <see cref="CultureInfo.InvariantCulture"/>
+ /// format provider. To specify a localized provider use the
+ /// <see cref="M:DebugFormat(IFormatProvider,string,object[])"/> method.
+ /// </para>
+ /// <para>
+ /// This method does not take an <see cref="Exception"/> object to include in the
+ /// log event. To pass an <see cref="Exception"/> use one of the <see cref="M:Debug(object)"/>
+ /// methods instead.
+ /// </para>
+ /// </remarks>
+ public virtual void DebugFormat(string format, object arg0, object arg1)
+ {
+ if (IsDebugEnabled)
+ {
+ Logger.Log(ThisDeclaringType, m_levelDebug, new SystemStringFormat(CultureInfo.InvariantCulture, format, new object[] { arg0, arg1 }), null);
+ }
+ }
- /// <summary>
- /// Logs a formatted message string with the <c>DEBUG</c> level.
- /// </summary>
- /// <param name="format">A String containing zero or more format items</param>
- /// <param name="arg0">An Object to format</param>
- /// <param name="arg1">An Object to format</param>
- /// <param name="arg2">An Object to format</param>
- /// <remarks>
- /// <para>
- /// The message is formatted using the <see cref="M:String.Format(IFormatProvider, string, object[])"/> method. See
- /// <c>String.Format</c> for details of the syntax of the format string and the behavior
- /// of the formatting.
- /// </para>
- /// <para>
- /// The string is formatted using the <see cref="CultureInfo.InvariantCulture"/>
- /// format provider. To specify a localized provider use the
- /// <see cref="M:DebugFormat(IFormatProvider,string,object[])"/> method.
- /// </para>
- /// <para>
- /// This method does not take an <see cref="Exception"/> object to include in the
- /// log event. To pass an <see cref="Exception"/> use one of the <see cref="M:Debug(object)"/>
- /// methods instead.
- /// </para>
- /// </remarks>
- public virtual void DebugFormat(string format, object arg0, object arg1, object arg2)
- {
- if (IsDebugEnabled)
- {
- Logger.Log(ThisDeclaringType, m_levelDebug, new SystemStringFormat(CultureInfo.InvariantCulture, format, new object[] { arg0, arg1, arg2 }), null);
- }
- }
+ /// <summary>
+ /// Logs a formatted message string with the <c>DEBUG</c> level.
+ /// </summary>
+ /// <param name="format">A String containing zero or more format items</param>
+ /// <param name="arg0">An Object to format</param>
+ /// <param name="arg1">An Object to format</param>
+ /// <param name="arg2">An Object to format</param>
+ /// <remarks>
+ /// <para>
+ /// The message is formatted using the <see cref="M:String.Format(IFormatProvider, string, object[])"/> method. See
+ /// <c>String.Format</c> for details of the syntax of the format string and the behavior
+ /// of the formatting.
+ /// </para>
+ /// <para>
+ /// The string is formatted using the <see cref="CultureInfo.InvariantCulture"/>
+ /// format provider. To specify a localized provider use the
+ /// <see cref="M:DebugFormat(IFormatProvider,string,object[])"/> method.
+ /// </para>
+ /// <para>
+ /// This method does not take an <see cref="Exception"/> object to include in the
+ /// log event. To pass an <see cref="Exception"/> use one of the <see cref="M:Debug(object)"/>
+ /// methods instead.
+ /// </para>
+ /// </remarks>
+ public virtual void DebugFormat(string format, object arg0, object arg1, object arg2)
+ {
+ if (IsDebugEnabled)
+ {
+ Logger.Log(ThisDeclaringType, m_levelDebug, new SystemStringFormat(CultureInfo.InvariantCulture, format, new object[] { arg0, arg1, arg2 }), null);
+ }
+ }
- /// <summary>
- /// Logs a formatted message string with the <c>DEBUG</c> level.
- /// </summary>
- /// <param name="provider">An <see cref="IFormatProvider"/> that supplies culture-specific formatting information</param>
- /// <param name="format">A String containing zero or more format items</param>
- /// <param name="args">An Object array containing zero or more objects to format</param>
- /// <remarks>
- /// <para>
- /// The message is formatted using the <see cref="M:String.Format(IFormatProvider, string, object[])"/> method. See
- /// <c>String.Format</c> for details of the syntax of the format string and the behavior
- /// of the formatting.
- /// </para>
- /// <para>
- /// This method does not take an <see cref="Exception"/> object to include in the
- /// log event. To pass an <see cref="Exception"/> use one of the <see cref="M:Debug(object)"/>
- /// methods instead.
- /// </para>
- /// </remarks>
- public virtual void DebugFormat(IFormatProvider provider, string format, params object[] args)
- {
- if (IsDebugEnabled)
- {
- Logger.Log(ThisDeclaringType, m_levelDebug, new SystemStringFormat(provider, format, args), null);
- }
- }
+ /// <summary>
+ /// Logs a formatted message string with the <c>DEBUG</c> level.
+ /// </summary>
+ /// <param name="provider">An <see cref="IFormatProvider"/> that supplies culture-specific formatting information</param>
+ /// <param name="format">A String containing zero or more format items</param>
+ /// <param name="args">An Object array containing zero or more objects to format</param>
+ /// <remarks>
+ /// <para>
+ /// The message is formatted using the <see cref="M:String.Format(IFormatProvider, string, object[])"/> method. See
+ /// <c>String.Format</c> for details of the syntax of the format string and the behavior
+ /// of the formatting.
+ /// </para>
+ /// <para>
+ /// This method does not take an <see cref="Exception"/> object to include in the
+ /// log event. To pass an <see cref="Exception"/> use one of the <see cref="M:Debug(object)"/>
+ /// methods instead.
+ /// </para>
+ /// </remarks>
+ public virtual void DebugFormat(IFormatProvider provider, string format, params object[] args)
+ {
+ if (IsDebugEnabled)
+ {
+ Logger.Log(ThisDeclaringType, m_levelDebug, new SystemStringFormat(provider, format, args), null);
+ }
+ }
- /// <summary>
- /// Logs a message object with the <c>INFO</c> level.
- /// </summary>
- /// <param name="message">The message object to log.</param>
- /// <remarks>
- /// <para>
- /// This method first checks if this logger is <c>INFO</c>
- /// enabled by comparing the level of this logger with the
- /// <c>INFO</c> level. If this logger is
- /// <c>INFO</c> enabled, then it converts the message object
- /// (passed as parameter) to a string by invoking the appropriate
- /// <see cref="log4net.ObjectRenderer.IObjectRenderer"/>. It then
- /// proceeds to call all the registered appenders in this logger
- /// and also higher in the hierarchy depending on the value of
- /// the additivity flag.
- /// </para>
- /// <para>
- /// <b>WARNING</b> Note that passing an <see cref="Exception"/>
- /// to this method will print the name of the <see cref="Exception"/>
- /// but no stack trace. To print a stack trace use the
- /// <see cref="M:Info(object,Exception)"/> form instead.
- /// </para>
- /// </remarks>
- public virtual void Info(object message)
- {
- Logger.Log(ThisDeclaringType, m_levelInfo, message, null);
- }
+ /// <summary>
+ /// Logs a message object with the <c>INFO</c> level.
+ /// </summary>
+ /// <param name="message">The message object to log.</param>
+ /// <remarks>
+ /// <para>
+ /// This method first checks if this logger is <c>INFO</c>
+ /// enabled by comparing the level of this logger with the
+ /// <c>INFO</c> level. If this logger is
+ /// <c>INFO</c> enabled, then it converts the message object
+ /// (passed as parameter) to a string by invoking the appropriate
+ /// <see cref="log4net.ObjectRenderer.IObjectRenderer"/>. It then
+ /// proceeds to call all the registered appenders in this logger
+ /// and also higher in the hierarchy depending on the value of
+ /// the additivity flag.
+ /// </para>
+ /// <para>
+ /// <b>WARNING</b> Note that passing an <see cref="Exception"/>
+ /// to this method will print the name of the <see cref="Exception"/>
+ /// but no stack trace. To print a stack trace use the
+ /// <see cref="M:Info(object,Exception)"/> form instead.
+ /// </para>
+ /// </remarks>
+ public virtual void Info(object message)
+ {
+ Logger.Log(ThisDeclaringType, m_levelInfo, message, null);
+ }
- /// <summary>
- /// Logs a message object with the <c>INFO</c> level.
- /// </summary>
- /// <param name="message">The message object to log.</param>
- /// <param name="exception">The exception to log, including its stack trace.</param>
- /// <remarks>
- /// <para>
- /// Logs a message object with the <c>INFO</c> level including
- /// the stack trace of the <see cref="Exception"/> <paramref name="exception"/>
- /// passed as a parameter.
- /// </para>
- /// <para>
- /// See the <see cref="M:Info(object)"/> form for more detailed information.
- /// </para>
- /// </remarks>
- /// <seealso cref="M:Info(object)"/>
- public virtual void Info(object message, Exception exception)
- {
- Logger.Log(ThisDeclaringType, m_levelInfo, message, exception);
- }
+ /// <summary>
+ /// Logs a message object with the <c>INFO</c> level.
+ /// </summary>
+ /// <param name="message">The message object to log.</param>
+ /// <param name="exception">The exception to log, including its stack trace.</param>
+ /// <remarks>
+ /// <para>
+ /// Logs a message object with the <c>INFO</c> level including
+ /// the stack trace of the <see cref="Exception"/> <paramref name="exception"/>
+ /// passed as a parameter.
+ /// </para>
+ /// <para>
+ /// See the <see cref="M:Info(object)"/> form for more detailed information.
+ /// </para>
+ /// </remarks>
+ /// <seealso cref="M:Info(object)"/>
+ public virtual void Info(object message, Exception exception)
+ {
+ Logger.Log(ThisDeclaringType, m_levelInfo, message, exception);
+ }
- /// <summary>
- /// Logs a formatted message string with the <c>INFO</c> level.
- /// </summary>
- /// <param name="format">A String containing zero or more format items</param>
- /// <param name="args">An Object array containing zero or more objects to format</param>
- /// <remarks>
- /// <para>
- /// The message is formatted using the <see cref="M:String.Format(IFormatProvider, string, object[])"/> method. See
- /// <c>String.Format</c> for details of the syntax of the format string and the behavior
- /// of the formatting.
- /// </para>
- /// <para>
- /// The string is formatted using the <see cref="CultureInfo.InvariantCulture"/>
- /// format provider. To specify a localized provider use the
- /// <see cref="M:InfoFormat(IFormatProvider,string,object[])"/> method.
- /// </para>
- /// <para>
- /// This method does not take an <see cref="Exception"/> object to include in the
- /// log event. To pass an <see cref="Exception"/> use one of the <see cref="M:Info(object)"/>
- /// methods instead.
- /// </para>
- /// </remarks>
- public virtual void InfoFormat(string format, params object[] args)
- {
- if (IsInfoEnabled)
- {
- Logger.Log(ThisDeclaringType, m_levelInfo, new SystemStringFormat(CultureInfo.InvariantCulture, format, args), null);
- }
- }
+ /// <summary>
+ /// Logs a formatted message string with the <c>INFO</c> level.
+ /// </summary>
+ /// <param name="format">A String containing zero or more format items</param>
+ /// <param name="args">An Object array containing zero or more objects to format</param>
+ /// <remarks>
+ /// <para>
+ /// The message is formatted using the <see cref="M:String.Format(IFormatProvider, string, object[])"/> method. See
+ /// <c>String.Format</c> for details of the syntax of the format string and the behavior
+ /// of the formatting.
+ /// </para>
+ /// <para>
+ /// The string is formatted using the <see cref="CultureInfo.InvariantCulture"/>
+ /// format provider. To specify a localized provider use the
+ /// <see cref="M:InfoFormat(IFormatProvider,string,object[])"/> method.
+ /// </para>
+ /// <para>
+ /// This method does not take an <see cref="Exception"/> object to include in the
+ /// log event. To pass an <see cref="Exception"/> use one of the <see cref="M:Info(object)"/>
+ /// methods instead.
+ /// </para>
+ /// </remarks>
+ public virtual void InfoFormat(string format, params object[] args)
+ {
+ if (IsInfoEnabled)
+ {
+ Logger.Log(ThisDeclaringType, m_levelInfo, new SystemStringFormat(CultureInfo.InvariantCulture, format, args), null);
+ }
+ }
- /// <summary>
- /// Logs a formatted message string with the <c>INFO</c> level.
- /// </summary>
- /// <param name="format">A String containing zero or more format items</param>
- /// <param name="arg0">An Object to format</param>
- /// <remarks>
- /// <para>
- /// The message is formatted using the <see cref="M:String.Format(IFormatProvider, string, object[])"/> method. See
- /// <c>String.Format</c> for details of the syntax of the format string and the behavior
- /// of the formatting.
- /// </para>
- /// <para>
- /// The string is formatted using the <see cref="CultureInfo.InvariantCulture"/>
- /// format provider. To specify a localized provider use the
- /// <see cref="M:InfoFormat(IFormatProvider,string,object[])"/> method.
- /// </para>
- /// <para>
- /// This method does not take an <see cref="Exception"/> object to include in the
- /// log event. To pass an <see cref="Exception"/> use one of the <see cref="M:Info(object)"/>
- /// methods instead.
- /// </para>
- /// </remarks>
- public virtual void InfoFormat(string format, object arg0)
- {
- if (IsInfoEnabled)
- {
- Logger.Log(ThisDeclaringType, m_levelInfo, new SystemStringFormat(CultureInfo.InvariantCulture, format, new object[] { arg0 }), null);
- }
- }
+ /// <summary>
+ /// Logs a formatted message string with the <c>INFO</c> level.
+ /// </summary>
+ /// <param name="format">A String containing zero or more format items</param>
+ /// <param name="arg0">An Object to format</param>
+ /// <remarks>
+ /// <para>
+ /// The message is formatted using the <see cref="M:String.Format(IFormatProvider, string, object[])"/> method. See
+ /// <c>String.Format</c> for details of the syntax of the format string and the behavior
+ /// of the formatting.
+ /// </para>
+ /// <para>
+ /// The string is formatted using the <see cref="CultureInfo.InvariantCulture"/>
+ /// format provider. To specify a localized provider use the
+ /// <see cref="M:InfoFormat(IFormatProvider,string,object[])"/> method.
+ /// </para>
+ /// <para>
+ /// This method does not take an <see cref="Exception"/> object to include in the
+ /// log event. To pass an <see cref="Exception"/> use one of the <see cref="M:Info(object)"/>
+ /// methods instead.
+ /// </para>
+ /// </remarks>
+ public virtual void InfoFormat(string format, object arg0)
+ {
+ if (IsInfoEnabled)
+ {
+ Logger.Log(ThisDeclaringType, m_levelInfo, new SystemStringFormat(CultureInfo.InvariantCulture, format, new object[] { arg0 }), null);
+ }
+ }
- /// <summary>
- /// Logs a formatted message string with the <c>INFO</c> level.
- /// </summary>
- /// <param name="format">A String containing zero or more format items</param>
- /// <param name="arg0">An Object to format</param>
- /// <param name="arg1">An Object to format</param>
- /// <remarks>
- /// <para>
- /// The message is formatted using the <see cref="M:String.Format(IFormatProvider, string, object[])"/> method. See
- /// <c>String.Format</c> for details of the syntax of the format string and the behavior
- /// of the formatting.
- /// </para>
- /// <para>
- /// The string is formatted using the <see cref="CultureInfo.InvariantCulture"/>
- /// format provider. To specify a localized provider use the
- /// <see cref="M:InfoFormat(IFormatProvider,string,object[])"/> method.
- /// </para>
- /// <para>
- /// This method does not take an <see cref="Exception"/> object to include in the
- /// log event. To pass an <see cref="Exception"/> use one of the <see cref="M:Info(object)"/>
- /// methods instead.
- /// </para>
- /// </remarks>
- public virtual void InfoFormat(string format, object arg0, object arg1)
- {
- if (IsInfoEnabled)
- {
- Logger.Log(ThisDeclaringType, m_levelInfo, new SystemStringFormat(CultureInfo.InvariantCulture, format, new object[] { arg0, arg1 }), null);
- }
- }
+ /// <summary>
+ /// Logs a formatted message string with the <c>INFO</c> level.
+ /// </summary>
+ /// <param name="format">A String containing zero or more format items</param>
+ /// <param name="arg0">An Object to format</param>
+ /// <param name="arg1">An Object to format</param>
+ /// <remarks>
+ /// <para>
+ /// The message is formatted using the <see cref="M:String.Format(IFormatProvider, string, object[])"/> method. See
+ /// <c>String.Format</c> for details of the syntax of the format string and the behavior
+ /// of the formatting.
+ /// </para>
+ /// <para>
+ /// The string is formatted using the <see cref="CultureInfo.InvariantCulture"/>
+ /// format provider. To specify a localized provider use the
+ /// <see cref="M:InfoFormat(IFormatProvider,string,object[])"/> method.
+ /// </para>
+ /// <para>
+ /// This method does not take an <see cref="Exception"/> object to include in the
+ /// log event. To pass an <see cref="Exception"/> use one of the <see cref="M:Info(object)"/>
+ /// methods instead.
+ /// </para>
+ /// </remarks>
+ public virtual void InfoFormat(string format, object arg0, object arg1)
+ {
+ if (IsInfoEnabled)
+ {
+ Logger.Log(ThisDeclaringType, m_levelInfo, new SystemStringFormat(CultureInfo.InvariantCulture, format, new object[] { arg0, arg1 }), null);
+ }
+ }
- /// <summary>
- /// Logs a formatted message string with the <c>INFO</c> level.
- /// </summary>
- /// <param name="format">A String containing zero or more format items</param>
- /// <param name="arg0">An Object to format</param>
- /// <param name="arg1">An Object to format</param>
- /// <param name="arg2">An Object to format</param>
- /// <remarks>
- /// <para>
- /// The message is formatted using the <see cref="M:String.Format(IFormatProvider, string, object[])"/> method. See
- /// <c>String.Format</c> for details of the syntax of the format string and the behavior
- /// of the formatting.
- /// </para>
- /// <para>
- /// The string is formatted using the <see cref="CultureInfo.InvariantCulture"/>
- /// format provider. To specify a localized provider use the
- /// <see cref="M:InfoFormat(IFormatProvider,string,object[])"/> method.
- /// </para>
- /// <para>
- /// This method does not take an <see cref="Exception"/> object to include in the
- /// log event. To pass an <see cref="Exception"/> use one of the <see cref="M:Info(object)"/>
- /// methods instead.
- /// </para>
- /// </remarks>
- public virtual void InfoFormat(string format, object arg0, object arg1, object arg2)
- {
- if (IsInfoEnabled)
- {
- Logger.Log(ThisDeclaringType, m_levelInfo, new SystemStringFormat(CultureInfo.InvariantCulture, format, new object[] { arg0, arg1, arg2 }), null);
- }
- }
+ /// <summary>
+ /// Logs a formatted message string with the <c>INFO</c> level.
+ /// </summary>
+ /// <param name="format">A String containing zero or more format items</param>
+ /// <param name="arg0">An Object to format</param>
+ /// <param name="arg1">An Object to format</param>
+ /// <param name="arg2">An Object to format</param>
+ /// <remarks>
+ /// <para>
+ /// The message is formatted using the <see cref="M:String.Format(IFormatProvider, string, object[])"/> method. See
+ /// <c>String.Format</c> for details of the syntax of the format string and the behavior
+ /// of the formatting.
+ /// </para>
+ /// <para>
+ /// The string is formatted using the <see cref="CultureInfo.InvariantCulture"/>
+ /// format provider. To specify a localized provider use the
+ /// <see cref="M:InfoFormat(IFormatProvider,string,object[])"/> method.
+ /// </para>
+ /// <para>
+ /// This method does not take an <see cref="Exception"/> object to include in the
+ /// log event. To pass an <see cref="Exception"/> use one of the <see cref="M:Info(object)"/>
+ /// methods instead.
+ /// </para>
+ /// </remarks>
+ public virtual void InfoFormat(string format, object arg0, object arg1, object arg2)
+ {
+ if (IsInfoEnabled)
+ {
+ Logger.Log(ThisDeclaringType, m_levelInfo, new SystemStringFormat(CultureInfo.InvariantCulture, format, new object[] { arg0, arg1, arg2 }), null);
+ }
+ }
- /// <summary>
- /// Logs a formatted message string with the <c>INFO</c> level.
- /// </summary>
- /// <param name="provider">An <see cref="IFormatProvider"/> that supplies culture-specific formatting information</param>
- /// <param name="format">A String containing zero or more format items</param>
- /// <param name="args">An Object array containing zero or more objects to format</param>
- /// <remarks>
- /// <para>
- /// The message is formatted using the <see cref="M:String.Format(IFormatProvider, string, object[])"/> method. See
- /// <c>String.Format</c> for details of the syntax of the format string and the behavior
- /// of the formatting.
- /// </para>
- /// <para>
- /// This method does not take an <see cref="Exception"/> object to include in the
- /// log event. To pass an <see cref="Exception"/> use one of the <see cref="M:Info(object)"/>
- /// methods instead.
- /// </para>
- /// </remarks>
- public virtual void InfoFormat(IFormatProvider provider, string format, params object[] args)
- {
- if (IsInfoEnabled)
- {
- Logger.Log(ThisDeclaringType, m_levelInfo, new SystemStringFormat(provider, format, args), null);
- }
- }
+ /// <summary>
+ /// Logs a formatted message string with the <c>INFO</c> level.
+ /// </summary>
+ /// <param name="provider">An <see cref="IFormatProvider"/> that supplies culture-specific formatting information</param>
+ /// <param name="format">A String containing zero or more format items</param>
+ /// <param name="args">An Object array containing zero or more objects to format</param>
+ /// <remarks>
+ /// <para>
+ /// The message is formatted using the <see cref="M:String.Format(IFormatProvider, string, object[])"/> method. See
+ /// <c>String.Format</c> for details of the syntax of the format string and the behavior
+ /// of the formatting.
+ /// </para>
+ /// <para>
+ /// This method does not take an <see cref="Exception"/> object to include in the
+ /// log event. To pass an <see cref="Exception"/> use one of the <see cref="M:Info(object)"/>
+ /// methods instead.
+ /// </para>
+ /// </remarks>
+ public virtual void InfoFormat(IFormatProvider provider, string format, params object[] args)
+ {
+ if (IsInfoEnabled)
+ {
+ Logger.Log(ThisDeclaringType, m_levelInfo, new SystemStringFormat(provider, format, args), null);
+ }
+ }
- /// <summary>
- /// Logs a message object with the <c>WARN</c> level.
- /// </summary>
- /// <param name="message">the message object to log</param>
- /// <remarks>
- /// <para>
- /// This method first checks if this logger is <c>WARN</c>
- /// enabled by comparing the level of this logger with the
- /// <c>WARN</c> level. If this logger is
- /// <c>WARN</c> enabled, then it converts the message object
- /// (passed as parameter) to a string by invoking the appropriate
- /// <see cref="log4net.ObjectRenderer.IObjectRenderer"/>. It then
- /// proceeds to call all the registered appenders in this logger and
- /// also higher in the hierarchy depending on the value of the
- /// additivity flag.
- /// </para>
- /// <para>
- /// <b>WARNING</b> Note that passing an <see cref="Exception"/> to this
- /// method will print the name of the <see cref="Exception"/> but no
- /// stack trace. To print a stack trace use the
- /// <see cref="M:Warn(object,Exception)"/> form instead.
- /// </para>
- /// </remarks>
- public virtual void Warn(object message)
- {
- Logger.Log(ThisDeclaringType, m_levelWarn, message, null);
- }
+ /// <summary>
+ /// Logs a message object with the <c>WARN</c> level.
+ /// </summary>
+ /// <param name="message">the message object to log</param>
+ /// <remarks>
+ /// <para>
+ /// This method first checks if this logger is <c>WARN</c>
+ /// enabled by comparing the level of this logger with the
+ /// <c>WARN</c> level. If this logger is
+ /// <c>WARN</c> enabled, then it converts the message object
+ /// (passed as parameter) to a string by invoking the appropriate
+ /// <see cref="log4net.ObjectRenderer.IObjectRenderer"/>. It then
+ /// proceeds to call all the registered appenders in this logger and
+ /// also higher in the hierarchy depending on the value of the
+ /// additivity flag.
+ /// </para>
+ /// <para>
+ /// <b>WARNING</b> Note that passing an <see cref="Exception"/> to this
+ /// method will print the name of the <see cref="Exception"/> but no
+ /// stack trace. To print a stack trace use the
+ /// <see cref="M:Warn(object,Exception)"/> form instead.
+ /// </para>
+ /// </remarks>
+ public virtual void Warn(object message)
+ {
+ Logger.Log(ThisDeclaringType, m_levelWarn, message, null);
+ }
- /// <summary>
- /// Logs a message object with the <c>WARN</c> level
- /// </summary>
- /// <param name="message">The message object to log.</param>
- /// <param name="exception">The exception to log, including its stack trace.</param>
- /// <remarks>
- /// <para>
- /// Logs a message object with the <c>WARN</c> level including
- /// the stack trace of the <see cref="Exception"/> <paramref name="exception"/>
- /// passed as a parameter.
- /// </para>
- /// <para>
- /// See the <see cref="M:Warn(object)"/> form for more detailed information.
- /// </para>
- /// </remarks>
- /// <seealso cref="M:Warn(object)"/>
- public virtual void Warn(object message, Exception exception)
- {
- Logger.Log(ThisDeclaringType, m_levelWarn, message, exception);
- }
+ /// <summary>
+ /// Logs a message object with the <c>WARN</c> level
+ /// </summary>
+ /// <param name="message">The message object to log.</param>
+ /// <param name="exception">The exception to log, including its stack trace.</param>
+ /// <remarks>
+ /// <para>
+ /// Logs a message object with the <c>WARN</c> level including
+ /// the stack trace of the <see cref="Exception"/> <paramref name="exception"/>
+ /// passed as a parameter.
+ /// </para>
+ /// <para>
+ /// See the <see cref="M:Warn(object)"/> form for more detailed information.
+ /// </para>
+ /// </remarks>
+ /// <seealso cref="M:Warn(object)"/>
+ public virtual void Warn(object message, Exception exception)
+ {
+ Logger.Log(ThisDeclaringType, m_levelWarn, message, exception);
+ }
- /// <summary>
- /// Logs a formatted message string with the <c>WARN</c> level.
- /// </summary>
- /// <param name="format">A String containing zero or more format items</param>
- /// <param name="args">An Object array containing zero or more objects to format</param>
- /// <remarks>
- /// <para>
- /// The message is formatted using the <see cref="M:String.Format(IFormatProvider, string, object[])"/> method. See
- /// <c>String.Format</c> for details of the syntax of the format string and the behavior
- /// of the formatting.
- /// </para>
- /// <para>
- /// The string is formatted using the <see cref="CultureInfo.InvariantCulture"/>
- /// format provider. To specify a localized provider use the
- /// <see cref="M:WarnFormat(IFormatProvider,string,object[])"/> method.
- /// </para>
- /// <para>
- /// This method does not take an <see cref="Exception"/> object to include in the
- /// log event. To pass an <see cref="Exception"/> use one of the <see cref="M:Warn(object)"/>
- /// methods instead.
- /// </para>
- /// </remarks>
- public virtual void WarnFormat(string format, params object[] args)
- {
- if (IsWarnEnabled)
- {
- Logger.Log(ThisDeclaringType, m_levelWarn, new SystemStringFormat(CultureInfo.InvariantCulture, format, args), null);
- }
- }
+ /// <summary>
+ /// Logs a formatted message string with the <c>WARN</c> level.
+ /// </summary>
+ /// <param name="format">A String containing zero or more format items</param>
+ /// <param name="args">An Object array containing zero or more objects to format</param>
+ /// <remarks>
+ /// <para>
+ /// The message is formatted using the <see cref="M:String.Format(IFormatProvider, string, object[])"/> method. See
+ /// <c>String.Format</c> for details of the syntax of the format string and the behavior
+ /// of the formatting.
+ /// </para>
+ /// <para>
+ /// The string is formatted using the <see cref="CultureInfo.InvariantCulture"/>
+ /// format provider. To specify a localized provider use the
+ /// <see cref="M:WarnFormat(IFormatProvider,string,object[])"/> method.
+ /// </para>
+ /// <para>
+ /// This method does not take an <see cref="Exception"/> object to include in the
+ /// log event. To pass an <see cref="Exception"/> use one of the <see cref="M:Warn(object)"/>
+ /// methods instead.
+ /// </para>
+ /// </remarks>
+ public virtual void WarnFormat(string format, params object[] args)
+ {
+ if (IsWarnEnabled)
+ {
+ Logger.Log(ThisDeclaringType, m_levelWarn, new SystemStringFormat(CultureInfo.InvariantCulture, format, args), null);
+ }
+ }
- /// <summary>
- /// Logs a formatted message string with the <c>WARN</c> level.
- /// </summary>
- /// <param name="format">A String containing zero or more format items</param>
- /// <param name="arg0">An Object to format</param>
- /// <remarks>
- /// <para>
- /// The message is formatted using the <see cref="M:String.Format(IFormatProvider, string, object[])"/> method. See
- /// <c>String.Format</c> for details of the syntax of the format string and the behavior
- /// of the formatting.
- /// </para>
- /// <para>
- /// The string is formatted using the <see cref="CultureInfo.InvariantCulture"/>
- /// format provider. To specify a localized provider use the
- /// <see cref="M:WarnFormat(IFormatProvider,string,object[])"/> method.
- /// </para>
- /// <para>
- /// This method does not take an <see cref="Exception"/> object to include in the
- /// log event. To pass an <see cref="Exception"/> use one of the <see cref="M:Warn(object)"/>
- /// methods instead.
- /// </para>
- /// </remarks>
- public virtual void WarnFormat(string format, object arg0)
- {
- if (IsWarnEnabled)
- {
- Logger.Log(ThisDeclaringType, m_levelWarn, new SystemStringFormat(CultureInfo.InvariantCulture, format, new object[] { arg0 }), null);
- }
- }
+ /// <summary>
+ /// Logs a formatted message string with the <c>WARN</c> level.
+ /// </summary>
+ /// <param name="format">A String containing zero or more format items</param>
+ /// <param name="arg0">An Object to format</param>
+ /// <remarks>
+ /// <para>
+ /// The message is formatted using the <see cref="M:String.Format(IFormatProvider, string, object[])"/> method. See
+ /// <c>String.Format</c> for details of the syntax of the format string and the behavior
+ /// of the formatting.
+ /// </para>
+ /// <para>
+ /// The string is formatted using the <see cref="CultureInfo.InvariantCulture"/>
+ /// format provider. To specify a localized provider use the
+ /// <see cref="M:WarnFormat(IFormatProvider,string,object[])"/> method.
+ /// </para>
+ /// <para>
+ /// This method does not take an <see cref="Exception"/> object to include in the
+ /// log event. To pass an <see cref="Exception"/> use one of the <see cref="M:Warn(object)"/>
+ /// methods instead.
+ /// </para>
+ /// </remarks>
+ public virtual void WarnFormat(string format, object arg0)
+ {
+ if (IsWarnEnabled)
+ {
+ Logger.Log(ThisDeclaringType, m_levelWarn, new SystemStringFormat(CultureInfo.InvariantCulture, format, new object[] { arg0 }), null);
+ }
+ }
- /// <summary>
- /// Logs a formatted message string with the <c>WARN</c> level.
- /// </summary>
- /// <param name="format">A String containing zero or more format items</param>
- /// <param name="arg0">An Object to format</param>
- /// <param name="arg1">An Object to format</param>
- /// <remarks>
- /// <para>
- /// The message is formatted using the <see cref="M:String.Format(IFormatProvider, string, object[])"/> method. See
- /// <c>String.Format</c> for details of the syntax of the format string and the behavior
- /// of the formatting.
- /// </para>
- /// <para>
- /// The string is formatted using the <see cref="CultureInfo.InvariantCulture"/>
- /// format provider. To specify a localized provider use the
- /// <see cref="M:WarnFormat(IFormatProvider,string,object[])"/> method.
- /// </para>
- /// <para>
- /// This method does not take an <see cref="Exception"/> object to include in the
- /// log event. To pass an <see cref="Exception"/> use one of the <see cref="M:Warn(object)"/>
- /// methods instead.
- /// </para>
- /// </remarks>
- public virtual void WarnFormat(string format, object arg0, object arg1)
- {
- if (IsWarnEnabled)
- {
- Logger.Log(ThisDeclaringType, m_levelWarn, new SystemStringFormat(CultureInfo.InvariantCulture, format, new object[] { arg0, arg1 }), null);
- }
- }
+ /// <summary>
+ /// Logs a formatted message string with the <c>WARN</c> level.
+ /// </summary>
+ /// <param name="format">A String containing zero or more format items</param>
+ /// <param name="arg0">An Object to format</param>
+ /// <param name="arg1">An Object to format</param>
+ /// <remarks>
+ /// <para>
+ /// The message is formatted using the <see cref="M:String.Format(IFormatProvider, string, object[])"/> method. See
+ /// <c>String.Format</c> for details of the syntax of the format string and the behavior
+ /// of the formatting.
+ /// </para>
+ /// <para>
+ /// The string is formatted using the <see cref="CultureInfo.InvariantCulture"/>
+ /// format provider. To specify a localized provider use the
+ /// <see cref="M:WarnFormat(IFormatProvider,string,object[])"/> method.
+ /// </para>
+ /// <para>
+ /// This method does not take an <see cref="Exception"/> object to include in the
+ /// log event. To pass an <see cref="Exception"/> use one of the <see cref="M:Warn(object)"/>
+ /// methods instead.
+ /// </para>
+ /// </remarks>
+ public virtual void WarnFormat(string format, object arg0, object arg1)
+ {
+ if (IsWarnEnabled)
+ {
+ Logger.Log(ThisDeclaringType, m_levelWarn, new SystemStringFormat(CultureInfo.InvariantCulture, format, new object[] { arg0, arg1 }), null);
+ }
+ }
- /// <summary>
- /// Logs a formatted message string with the <c>WARN</c> level.
- /// </summary>
- /// <param name="format">A String containing zero or more format items</param>
- /// <param name="arg0">An Object to format</param>
- /// <param name="arg1">An Object to format</param>
- /// <param name="arg2">An Object to format</param>
- /// <remarks>
- /// <para>
- /// The message is formatted using the <see cref="M:String.Format(IFormatProvider, string, object[])"/> method. See
- /// <c>String.Format</c> for details of the syntax of the format string and the behavior
- /// of the formatting.
- /// </para>
- /// <para>
- /// The string is formatted using the <see cref="CultureInfo.InvariantCulture"/>
- /// format provider. To specify a localized provider use the
- /// <see cref="M:WarnFormat(IFormatProvider,string,object[])"/> method.
- /// </para>
- /// <para>
- /// This method does not take an <see cref="Exception"/> object to include in the
- /// log event. To pass an <see cref="Exception"/> use one of the <see cref="M:Warn(object)"/>
- /// methods instead.
- /// </para>
- /// </remarks>
- public virtual void WarnFormat(string format, object arg0, object arg1, object arg2)
- {
- if (IsWarnEnabled)
- {
- Logger.Log(ThisDeclaringType, m_levelWarn, new SystemStringFormat(CultureInfo.InvariantCulture, format, new object[] { arg0, arg1, arg2 }), null);
- }
- }
+ /// <summary>
+ /// Logs a formatted message string with the <c>WARN</c> level.
+ /// </summary>
+ /// <param name="format">A String containing zero or more format items</param>
+ /// <param name="arg0">An Object to format</param>
+ /// <param name="arg1">An Object to format</param>
+ /// <param name="arg2">An Object to format</param>
+ /// <remarks>
+ /// <para>
+ /// The message is formatted using the <see cref="M:String.Format(IFormatProvider, string, object[])"/> method. See
+ /// <c>String.Format</c> for details of the syntax of the format string and the behavior
+ /// of the formatting.
+ /// </para>
+ /// <para>
+ /// The string is formatted using the <see cref="CultureInfo.InvariantCulture"/>
+ /// format provider. To specify a localized provider use the
+ /// <see cref="M:WarnFormat(IFormatProvider,string,object[])"/> method.
+ /// </para>
+ /// <para>
+ /// This method does not take an <see cref="Exception"/> object to include in the
+ /// log event. To pass an <see cref="Exception"/> use one of the <see cref="M:Warn(object)"/>
+ /// methods instead.
+ /// </para>
+ /// </remarks>
+ public virtual void WarnFormat(string format, object arg0, object arg1, object arg2)
+ {
+ if (IsWarnEnabled)
+ {
+ Logger.Log(ThisDeclaringType, m_levelWarn, new SystemStringFormat(CultureInfo.InvariantCulture, format, new object[] { arg0, arg1, arg2 }), null);
+ }
+ }
- /// <summary>
- /// Logs a formatted message string with the <c>WARN</c> level.
- /// </summary>
- /// <param name="provider">An <see cref="IFormatProvider"/> that supplies culture-specific formatting information</param>
- /// <param name="format">A String containing zero or more format items</param>
- /// <param name="args">An Object array containing zero or more objects to format</param>
- /// <remarks>
- /// <para>
- /// The message is formatted using the <see cref="M:String.Format(IFormatProvider, string, object[])"/> method. See
- /// <c>String.Format</c> for details of the syntax of the format string and the behavior
- /// of the formatting.
- /// </para>
- /// <para>
- /// This method does not take an <see cref="Exception"/> object to include in the
- /// log event. To pass an <see cref="Exception"/> use one of the <see cref="M:Warn(object)"/>
- /// methods instead.
- /// </para>
- /// </remarks>
- public virtual void WarnFormat(IFormatProvider provider, string format, params object[] args)
- {
- if (IsWarnEnabled)
- {
- Logger.Log(ThisDeclaringType, m_levelWarn, new SystemStringFormat(provider, format, args), null);
- }
- }
+ /// <summary>
+ /// Logs a formatted message string with the <c>WARN</c> level.
+ /// </summary>
+ /// <param name="provider">An <see cref="IFormatProvider"/> that supplies culture-specific formatting information</param>
+ /// <param name="format">A String containing zero or more format items</param>
+ /// <param name="args">An Object array containing zero or more objects to format</param>
+ /// <remarks>
+ /// <para>
+ /// The message is formatted using the <see cref="M:String.Format(IFormatProvider, string, object[])"/> method. See
+ /// <c>String.Format</c> for details of the syntax of the format string and the behavior
+ /// of the formatting.
+ /// </para>
+ /// <para>
+ /// This method does not take an <see cref="Exception"/> object to include in the
+ /// log event. To pass an <see cref="Exception"/> use one of the <see cref="M:Warn(object)"/>
+ /// methods instead.
+ /// </para>
+ /// </remarks>
+ public virtual void WarnFormat(IFormatProvider provider, string format, params object[] args)
+ {
+ if (IsWarnEnabled)
+ {
+ Logger.Log(ThisDeclaringType, m_levelWarn, new SystemStringFormat(provider, format, args), null);
+ }
+ }
- /// <summary>
- /// Logs a message object with the <c>ERROR</c> level.
- /// </summary>
- /// <param name="message">The message object to log.</param>
- /// <remarks>
- /// <para>
- /// This method first checks if this logger is <c>ERROR</c>
- /// enabled by comparing the level of this logger with the
- /// <c>ERROR</c> level. If this logger is
- /// <c>ERROR</c> enabled, then it converts the message object
- /// (passed as parameter) to a string by invoking the appropriate
- /// <see cref="log4net.ObjectRenderer.IObjectRenderer"/>. It then
- /// proceeds to call all the registered appenders in this logger and
- /// also higher in the hierarchy depending on the value of the
- /// additivity flag.
- /// </para>
- /// <para>
- /// <b>WARNING</b> Note that passing an <see cref="Exception"/> to this
- /// method will print the name of the <see cref="Exception"/> but no
- /// stack trace. To print a stack trace use the
- /// <see cref="M:Error(object,Exception)"/> form instead.
- /// </para>
- /// </remarks>
- public virtual void Error(object message)
- {
- Logger.Log(ThisDeclaringType, m_levelError, message, null);
- }
+ /// <summary>
+ /// Logs a message object with the <c>ERROR</c> level.
+ /// </summary>
+ /// <param name="message">The message object to log.</param>
+ /// <remarks>
+ /// <para>
+ /// This method first checks if this logger is <c>ERROR</c>
+ /// enabled by comparing the level of this logger with the
+ /// <c>ERROR</c> level. If this logger is
+ /// <c>ERROR</c> enabled, then it converts the message object
+ /// (passed as parameter) to a string by invoking the appropriate
+ /// <see cref="log4net.ObjectRenderer.IObjectRenderer"/>. It then
+ /// proceeds to call all the registered appenders in this logger and
+ /// also higher in the hierarchy depending on the value of the
+ /// additivity flag.
+ /// </para>
+ /// <para>
+ /// <b>WARNING</b> Note that passing an <see cref="Exception"/> to this
+ /// method will print the name of the <see cref="Exception"/> but no
+ /// stack trace. To print a stack trace use the
+ /// <see cref="M:Error(object,Exception)"/> form instead.
+ /// </para>
+ /// </remarks>
+ public virtual void Error(object message)
+ {
+ Logger.Log(ThisDeclaringType, m_levelError, message, null);
+ }
- /// <summary>
- /// Logs a message object with the <c>ERROR</c> level
- /// </summary>
- /// <param name="message">The message object to log.</param>
- /// <param name="exception">The exception to log, including its stack trace.</param>
- /// <remarks>
- /// <para>
- /// Logs a message object with the <c>ERROR</c> level including
- /// the stack trace of the <see cref="Exception"/> <paramref name="exception"/>
- /// passed as a parameter.
- /// </para>
- /// <para>
- /// See the <see cref="M:Error(object)"/> form for more detailed information.
- /// </para>
- /// </remarks>
- /// <seealso cref="M:Error(object)"/>
- public virtual void Error(object message, Exception exception)
- {
- Logger.Log(ThisDeclaringType, m_levelError, message, exception);
- }
+ /// <summary>
+ /// Logs a message object with the <c>ERROR</c> level
+ /// </summary>
+ /// <param name="message">The message object to log.</param>
+ /// <param name="exception">The exception to log, including its stack trace.</param>
+ /// <remarks>
+ /// <para>
+ /// Logs a message object with the <c>ERROR</c> level including
+ /// the stack trace of the <see cref="Exception"/> <paramref name="exception"/>
+ /// passed as a parameter.
+ /// </para>
+ /// <para>
+ /// See the <see cref="M:Error(object)"/> form for more detailed information.
+ /// </para>
+ /// </remarks>
+ /// <seealso cref="M:Error(object)"/>
+ public virtual void Error(object message, Exception exception)
+ {
+ Logger.Log(ThisDeclaringType, m_levelError, message, exception);
+ }
- /// <summary>
- /// Logs a formatted message string with the <c>ERROR</c> level.
- /// </summary>
- /// <param name="format">A String containing zero or more format items</param>
- /// <param name="args">An Object array containing zero or more objects to format</param>
- /// <remarks>
- /// <para>
- /// The message is formatted using the <see cref="M:String.Format(IFormatProvider, string, object[])"/> method. See
- /// <c>String.Format</c> for details of the syntax of the format string and the behavior
- /// of the formatting.
- /// </para>
- /// <para>
- /// The string is formatted using the <see cref="CultureInfo.InvariantCulture"/>
- /// format provider. To specify a localized provider use the
- /// <see cref="M:ErrorFormat(IFormatProvider,string,object[])"/> method.
- /// </para>
- /// <para>
- /// This method does not take an <see cref="Exception"/> object to include in the
- /// log event. To pass an <see cref="Exception"/> use one of the <see cref="M:Error(object)"/>
- /// methods instead.
- /// </para>
- /// </remarks>
- public virtual void ErrorFormat(string format, params object[] args)
- {
- if (IsErrorEnabled)
- {
- Logger.Log(ThisDeclaringType, m_levelError, new SystemStringFormat(CultureInfo.InvariantCulture, format, args), null);
- }
- }
+ /// <summary>
+ /// Logs a formatted message string with the <c>ERROR</c> level.
+ /// </summary>
+ /// <param name="format">A String containing zero or more format items</param>
+ /// <param name="args">An Object array containing zero or more objects to format</param>
+ /// <remarks>
+ /// <para>
+ /// The message is formatted using the <see cref="M:String.Format(IFormatProvider, string, object[])"/> method. See
+ /// <c>String.Format</c> for details of the syntax of the format string and the behavior
+ /// of the formatting.
+ /// </para>
+ /// <para>
+ /// The string is formatted using the <see cref="CultureInfo.InvariantCulture"/>
+ /// format provider. To specify a localized provider use the
+ /// <see cref="M:ErrorFormat(IFormatProvider,string,object[])"/> method.
+ /// </para>
+ /// <para>
+ /// This method does not take an <see cref="Exception"/> object to include in the
+ /// log event. To pass an <see cref="Exception"/> use one of the <see cref="M:Error(object)"/>
+ /// methods instead.
+ /// </para>
+ /// </remarks>
+ public virtual void ErrorFormat(string format, params object[] args)
+ {
+ if (IsErrorEnabled)
+ {
+ Logger.Log(ThisDeclaringType, m_levelError, new SystemStringFormat(CultureInfo.InvariantCulture, format, args), null);
+ }
+ }
- /// <summary>
- /// Logs a formatted message string with the <c>ERROR</c> level.
- /// </summary>
- /// <param name="format">A String containing zero or more format items</param>
- /// <param name="arg0">An Object to format</param>
- /// <remarks>
- /// <para>
- /// The message is formatted using the <see cref="M:String.Format(IFormatProvider, string, object[])"/> method. See
- /// <c>String.Format</c> for details of the syntax of the format string and the behavior
- /// of the formatting.
- /// </para>
- /// <para>
- /// The string is formatted using the <see cref="CultureInfo.InvariantCulture"/>
- /// format provider. To specify a localized provider use the
- /// <see cref="M:ErrorFormat(IFormatProvider,string,object[])"/> method.
- /// </para>
- /// <para>
- /// This method does not take an <see cref="Exception"/> object to include in the
- /// log event. To pass an <see cref="Exception"/> use one of the <see cref="M:Error(object)"/>
- /// methods instead.
- /// </para>
- /// </remarks>
- public virtual void ErrorFormat(string format, object arg0)
- {
- if (IsErrorEnabled)
- {
- Logger.Log(ThisDeclaringType, m_levelError, new SystemStringFormat(CultureInfo.InvariantCulture, format, new object[] { arg0 }), null);
- }
- }
+ /// <summary>
+ /// Logs a formatted message string with the <c>ERROR</c> level.
+ /// </summary>
+ /// <param name="format">A String containing zero or more format items</param>
+ /// <param name="arg0">An Object to format</param>
+ /// <remarks>
+ /// <para>
+ /// The message is formatted using the <see cref="M:String.Format(IFormatProvider, string, object[])"/> method. See
+ /// <c>String.Format</c> for details of the syntax of the format string and the behavior
+ /// of the formatting.
+ /// </para>
+ /// <para>
+ /// The string is formatted using the <see cref="CultureInfo.InvariantCulture"/>
+ /// format provider. To specify a localized provider use the
+ /// <see cref="M:ErrorFormat(IFormatProvider,string,object[])"/> method.
+ /// </para>
+ /// <para>
+ /// This method does not take an <see cref="Exception"/> object to include in the
+ /// log event. To pass an <see cref="Exception"/> use one of the <see cref="M:Error(object)"/>
+ /// methods instead.
+ /// </para>
+ /// </remarks>
+ public virtual void ErrorFormat(string format, object arg0)
+ {
+ if (IsErrorEnabled)
+ {
+ Logger.Log(ThisDeclaringType, m_levelError, new SystemStringFormat(CultureInfo.InvariantCulture, format, new object[] { arg0 }), null);
+ }
+ }
- /// <summary>
- /// Logs a formatted message string with the <c>ERROR</c> level.
- /// </summary>
- /// <param name="format">A String containing zero or more format items</param>
- /// <param name="arg0">An Object to format</param>
- /// <param name="arg1">An Object to format</param>
- /// <remarks>
- /// <para>
- /// The message is formatted using the <see cref="M:String.Format(IFormatProvider, string, object[])"/> method. See
- /// <c>String.Format</c> for details of the syntax of the format string and the behavior
- /// of the formatting.
- /// </para>
- /// <para>
- /// The string is formatted using the <see cref="CultureInfo.InvariantCulture"/>
- /// format provider. To specify a localized provider use the
- /// <see cref="M:ErrorFormat(IFormatProvider,string,object[])"/> method.
- /// </para>
- /// <para>
- /// This method does not take an <see cref="Exception"/> object to include in the
- /// log event. To pass an <see cref="Exception"/> use one of the <see cref="M:Error(object)"/>
- /// methods instead.
- /// </para>
- /// </remarks>
- public virtual void ErrorFormat(string format, object arg0, object arg1)
- {
- if (IsErrorEnabled)
- {
- Logger.Log(ThisDeclaringType, m_levelError, new SystemStringFormat(CultureInfo.InvariantCulture, format, new object[] { arg0, arg1 }), null);
- }
- }
+ /// <summary>
+ /// Logs a formatted message string with the <c>ERROR</c> level.
+ /// </summary>
+ /// <param name="format">A String containing zero or more format items</param>
+ /// <param name="arg0">An Object to format</param>
+ /// <param name="arg1">An Object to format</param>
+ /// <remarks>
+ /// <para>
+ /// The message is formatted using the <see cref="M:String.Format(IFormatProvider, string, object[])"/> method. See
+ /// <c>String.Format</c> for details of the syntax of the format string and the behavior
+ /// of the formatting.
+ /// </para>
+ /// <para>
+ /// The string is formatted using the <see cref="CultureInfo.InvariantCulture"/>
+ /// format provider. To specify a localized provider use the
+ /// <see cref="M:ErrorFormat(IFormatProvider,string,object[])"/> method.
+ /// </para>
+ /// <para>
+ /// This method does not take an <see cref="Exception"/> object to include in the
+ /// log event. To pass an <see cref="Exception"/> use one of the <see cref="M:Error(object)"/>
+ /// methods instead.
+ /// </para>
+ /// </remarks>
+ public virtual void ErrorFormat(string format, object arg0, object arg1)
+ {
+ if (IsErrorEnabled)
+ {
+ Logger.Log(ThisDeclaringType, m_levelError, new SystemStringFormat(CultureInfo.InvariantCulture, format, new object[] { arg0, arg1 }), null);
+ }
+ }
- /// <summary>
- /// Logs a formatted message string with the <c>ERROR</c> level.
- /// </summary>
- /// <param name="format">A String containing zero or more format items</param>
- /// <param name="arg0">An Object to format</param>
- /// <param name="arg1">An Object to format</param>
- /// <param name="arg2">An Object to format</param>
- /// <remarks>
- /// <para>
- /// The message is formatted using the <see cref="M:String.Format(IFormatProvider, string, object[])"/> method. See
- /// <c>String.Format</c> for details of the syntax of the format string and the behavior
- /// of the formatting.
- /// </para>
- /// <para>
- /// The string is formatted using the <see cref="CultureInfo.InvariantCulture"/>
- /// format provider. To specify a localized provider use the
- /// <see cref="M:ErrorFormat(IFormatProvider,string,object[])"/> method.
- /// </para>
- /// <para>
- /// This method does not take an <see cref="Exception"/> object to include in the
- /// log event. To pass an <see cref="Exception"/> use one of the <see cref="M:Error(object)"/>
- /// methods instead.
- /// </para>
- /// </remarks>
- public virtual void ErrorFormat(string format, object arg0, object arg1, object arg2)
- {
- if (IsErrorEnabled)
- {
- Logger.Log(ThisDeclaringType, m_levelError, new SystemStringFormat(CultureInfo.InvariantCulture, format, new object[] { arg0, arg1, arg2 }), null);
- }
- }
+ /// <summary>
+ /// Logs a formatted message string with the <c>ERROR</c> level.
+ /// </summary>
+ /// <param name="format">A String containing zero or more format items</param>
+ /// <param name="arg0">An Object to format</param>
+ /// <param name="arg1">An Object to format</param>
+ /// <param name="arg2">An Object to format</param>
+ /// <remarks>
+ /// <para>
+ /// The message is formatted using the <see cref="M:String.Format(IFormatProvider, string, object[])"/> method. See
+ /// <c>String.Format</c> for details of the syntax of the format string and the behavior
+ /// of the formatting.
+ /// </para>
+ /// <para>
+ /// The string is formatted using the <see cref="CultureInfo.InvariantCulture"/>
+ /// format provider. To specify a localized provider use the
+ /// <see cref="M:ErrorFormat(IFormatProvider,string,object[])"/> method.
+ /// </para>
+ /// <para>
+ /// This method does not take an <see cref="Exception"/> object to include in the
+ /// log event. To pass an <see cref="Exception"/> use one of the <see cref="M:Error(object)"/>
+ /// methods instead.
+ /// </para>
+ /// </remarks>
+ public virtual void ErrorFormat(string format, object arg0, object arg1, object arg2)
+ {
+ if (IsErrorEnabled)
+ {
+ Logger.Log(ThisDeclaringType, m_levelError, new SystemStringFormat(CultureInfo.InvariantCulture, format, new object[] { arg0, arg1, arg2 }), null);
+ }
+ }
- /// <summary>
- /// Logs a formatted message string with the <c>ERROR</c> level.
- /// </summary>
- /// <param name="provider">An <see cref="IFormatProvider"/> that supplies culture-specific formatting information</param>
- /// <param name="format">A String containing zero or more format items</param>
- /// <param name="args">An Object array containing zero or more objects to format</param>
- /// <remarks>
- /// <para>
- /// The message is formatted using the <see cref="M:String.Format(IFormatProvider, string, object[])"/> method. See
- /// <c>String.Format</c> for details of the syntax of the format string and the behavior
- /// of the formatting.
- /// </para>
- /// <para>
- /// This method does not take an <see cref="Exception"/> object to include in the
- /// log event. To pass an <see cref="Exception"/> use one of the <see cref="M:Error(object)"/>
- /// methods instead.
- /// </para>
- /// </remarks>
- public virtual void ErrorFormat(IFormatProvider provider, string format, params object[] args)
- {
- if (IsErrorEnabled)
- {
- Logger.Log(ThisDeclaringType, m_levelError, new SystemStringFormat(provider, format, args), null);
- }
- }
+ /// <summary>
+ /// Logs a formatted message string with the <c>ERROR</c> level.
+ /// </summary>
+ /// <param name="provider">An <see cref="IFormatProvider"/> that supplies culture-specific formatting information</param>
+ /// <param name="format">A String containing zero or more format items</param>
+ /// <param name="args">An Object array containing zero or more objects to format</param>
+ /// <remarks>
+ /// <para>
+ /// The message is formatted using the <see cref="M:String.Format(IFormatProvider, string, object[])"/> method. See
+ /// <c>String.Format</c> for details of the syntax of the format string and the behavior
+ /// of the formatting.
+ /// </para>
+ /// <para>
+ /// This method does not take an <see cref="Exception"/> object to include in the
+ /// log event. To pass an <see cref="Exception"/> use one of the <see cref="M:Error(object)"/>
+ /// methods instead.
+ /// </para>
+ /// </remarks>
+ public virtual void ErrorFormat(IFormatProvider provider, string format, params object[] args)
+ {
+ if (IsErrorEnabled)
+ {
+ Logger.Log(ThisDeclaringType, m_levelError, new SystemStringFormat(provider, format, args), null);
+ }
+ }
- /// <summary>
- /// Logs a message object with the <c>FATAL</c> level.
- /// </summary>
- /// <param name="message">The message object to log.</param>
- /// <remarks>
- /// <para>
- /// This method first checks if this logger is <c>FATAL</c>
- /// enabled by comparing the level of this logger with the
- /// <c>FATAL</c> level. If this logger is
- /// <c>FATAL</c> enabled, then it converts the message object
- /// (passed as parameter) to a string by invoking the appropriate
- /// <see cref="log4net.ObjectRenderer.IObjectRenderer"/>. It then
- /// proceeds to call all the registered appenders in this logger and
- /// also higher in the hierarchy depending on the value of the
- /// additivity flag.
- /// </para>
- /// <para>
- /// <b>WARNING</b> Note that passing an <see cref="Exception"/> to this
- /// method will print the name of the <see cref="Exception"/> but no
- /// stack trace. To print a stack trace use the
- /// <see cref="M:Fatal(object,Exception)"/> form instead.
- /// </para>
- /// </remarks>
- public virtual void Fatal(object message)
- {
- Logger.Log(ThisDeclaringType, m_levelFatal, message, null);
- }
+ /// <summary>
+ /// Logs a message object with the <c>FATAL</c> level.
+ /// </summary>
+ /// <param name="message">The message object to log.</param>
+ /// <remarks>
+ /// <para>
+ /// This method first checks if this logger is <c>FATAL</c>
+ /// enabled by comparing the level of this logger with the
+ /// <c>FATAL</c> level. If this logger is
+ /// <c>FATAL</c> enabled, then it converts the message object
+ /// (passed as parameter) to a string by invoking the appropriate
+ /// <see cref="log4net.ObjectRenderer.IObjectRenderer"/>. It then
+ /// proceeds to call all the registered appenders in this logger and
+ /// also higher in the hierarchy depending on the value of the
+ /// additivity flag.
+ /// </para>
+ /// <para>
+ /// <b>WARNING</b> Note that passing an <see cref="Exception"/> to this
+ /// method will print the name of the <see cref="Exception"/> but no
+ /// stack trace. To print a stack trace use the
+ /// <see cref="M:Fatal(object,Exception)"/> form instead.
+ /// </para>
+ /// </remarks>
+ public virtual void Fatal(object message)
+ {
+ Logger.Log(ThisDeclaringType, m_levelFatal, message, null);
+ }
- /// <summary>
- /// Logs a message object with the <c>FATAL</c> level
- /// </summary>
- /// <param name="message">The message object to log.</param>
- /// <param name="exception">The exception to log, including its stack trace.</param>
- /// <remarks>
- /// <para>
- /// Logs a message object with the <c>FATAL</c> level including
- /// the stack trace of the <see cref="Exception"/> <paramref name="exception"/>
- /// passed as a parameter.
- /// </para>
- /// <para>
- /// See the <see cref="M:Fatal(object)"/> form for more detailed information.
- /// </para>
- /// </remarks>
- /// <seealso cref="M:Fatal(object)"/>
- public virtual void Fatal(object message, Exception exception)
- {
- Logger.Log(ThisDeclaringType, m_levelFatal, message, exception);
- }
+ /// <summary>
+ /// Logs a message object with the <c>FATAL</c> level
+ /// </summary>
+ /// <param name="message">The message object to log.</param>
+ /// <param name="exception">The exception to log, including its stack trace.</param>
+ /// <remarks>
+ /// <para>
+ /// Logs a message object with the <c>FATAL</c> level including
+ /// the stack trace of the <see cref="Exception"/> <paramref name="exception"/>
+ /// passed as a parameter.
+ /// </para>
+ /// <para>
+ /// See the <see cref="M:Fatal(object)"/> form for more detailed information.
+ /// </para>
+ /// </remarks>
+ /// <seealso cref="M:Fatal(object)"/>
+ public virtual void Fatal(object message, Exception exception)
+ {
+ Logger.Log(ThisDeclaringType, m_levelFatal, message, exception);
+ }
- /// <summary>
- /// Logs a formatted message string with the <c>FATAL</c> level.
- /// </summary>
- /// <param name="format">A String containing zero or more format items</param>
- /// <param name="args">An Object array containing zero or more objects to format</param>
- /// <remarks>
- /// <para>
- /// The message is formatted using the <see cref="M:String.Format(IFormatProvider, string, object[])"/> method. See
- /// <c>String.Format</c> for details of the syntax of the format string and the behavior
- /// of the formatting.
- /// </para>
- /// <para>
- /// The string is formatted using the <see cref="CultureInfo.InvariantCulture"/>
- /// format provider. To specify a localized provider use the
- /// <see cref="M:FatalFormat(IFormatProvider,string,object[])"/> method.
- /// </para>
- /// <para>
- /// This method does not take an <see cref="Exception"/> object to include in the
- /// log event. To pass an <see cref="Exception"/> use one of the <see cref="M:Fatal(object)"/>
- /// methods instead.
- /// </para>
- /// </remarks>
- public virtual void FatalFormat(string format, params object[] args)
- {
- if (IsFatalEnabled)
- {
- Logger.Log(ThisDeclaringType, m_levelFatal, new SystemStringFormat(CultureInfo.InvariantCulture, format, args), null);
- }
- }
+ /// <summary>
+ /// Logs a formatted message string with the <c>FATAL</c> level.
+ /// </summary>
+ /// <param name="format">A String containing zero or more format items</param>
+ /// <param name="args">An Object array containing zero or more objects to format</param>
+ /// <remarks>
+ /// <para>
+ /// The message is formatted using the <see cref="M:String.Format(IFormatProvider, string, object[])"/> method. See
+ /// <c>String.Format</c> for details of the syntax of the format string and the behavior
+ /// of the formatting.
+ /// </para>
+ /// <para>
+ /// The string is formatted using the <see cref="CultureInfo.InvariantCulture"/>
+ /// format provider. To specify a localized provider use the
+ /// <see cref="M:FatalFormat(IFormatProvider,string,object[])"/> method.
+ /// </para>
+ /// <para>
+ /// This method does not take an <see cref="Exception"/> object to include in the
+ /// log event. To pass an <see cref="Exception"/> use one of the <see cref="M:Fatal(object)"/>
+ /// methods instead.
+ /// </para>
+ /// </remarks>
+ public virtual void FatalFormat(string format, params object[] args)
+ {
+ if (IsFatalEnabled)
+ {
+ Logger.Log(ThisDeclaringType, m_levelFatal, new SystemStringFormat(CultureInfo.InvariantCulture, format, args), null);
+ }
+ }
- /// <summary>
- /// Logs a formatted message string with the <c>FATAL</c> level.
- /// </summary>
- /// <param name="format">A String containing zero or more format items</param>
- /// <param name="arg0">An Object to format</param>
- /// <remarks>
- /// <para>
- /// The message is formatted using the <see cref="M:String.Format(IFormatProvider, string, object[])"/> method. See
- /// <c>String.Format</c> for details of the syntax of the format string and the behavior
- /// of the formatting.
- /// </para>
- /// <para>
- /// The string is formatted using the <see cref="CultureInfo.InvariantCulture"/>
- /// format provider. To specify a localized provider use the
- /// <see cref="M:FatalFormat(IFormatProvider,string,object[])"/> method.
- /// </para>
- /// <para>
- /// This method does not take an <see cref="Exception"/> object to include in the
- /// log event. To pass an <see cref="Exception"/> use one of the <see cref="M:Fatal(object)"/>
- /// methods instead.
- /// </para>
- /// </remarks>
- public virtual void FatalFormat(string format, object arg0)
- {
- if (IsFatalEnabled)
- {
- Logger.Log(ThisDeclaringType, m_levelFatal, new SystemStringFormat(CultureInfo.InvariantCulture, format, new object[] { arg0 }), null);
- }
- }
+ /// <summary>
+ /// Logs a formatted message string with the <c>FATAL</c> level.
+ /// </summary>
+ /// <param name="format">A String containing zero or more format items</param>
+ /// <param name="arg0">An Object to format</param>
+ /// <remarks>
+ /// <para>
+ /// The message is formatted using the <see cref="M:String.Format(IFormatProvider, string, object[])"/> method. See
+ /// <c>String.Format</c> for details of the syntax of the format string and the behavior
+ /// of the formatting.
+ /// </para>
+ /// <para>
+ /// The string is formatted using the <see cref="CultureInfo.InvariantCulture"/>
+ /// format provider. To specify a localized provider use the
+ /// <see cref="M:FatalFormat(IFormatProvider,string,object[])"/> method.
+ /// </para>
+ /// <para>
+ /// This method does not take an <see cref="Exception"/> object to include in the
+ /// log event. To pass an <see cref="Exception"/> use one of the <see cref="M:Fatal(object)"/>
+ /// methods instead.
+ /// </para>
+ /// </remarks>
+ public virtual void FatalFormat(string format, object arg0)
+ {
+ if (IsFatalEnabled)
+ {
+ Logger.Log(ThisDeclaringType, m_levelFatal, new SystemStringFormat(CultureInfo.InvariantCulture, format, new object[] { arg0 }), null);
+ }
+ }
- /// <summary>
- /// Logs a formatted message string with the <c>FATAL</c> level.
- /// </summary>
- /// <param name="format">A String containing zero or more format items</param>
- /// <param name="arg0">An Object to format</param>
- /// <param name="arg1">An Object to format</param>
- /// <remarks>
- /// <para>
- /// The message is formatted using the <see cref="M:String.Format(IFormatProvider, string, object[])"/> method. See
- /// <c>String.Format</c> for details of the syntax of the format string and the behavior
- /// of the formatting.
- /// </para>
- /// <para>
- /// The string is formatted using the <see cref="CultureInfo.InvariantCulture"/>
- /// format provider. To specify a localized provider use the
- /// <see cref="M:FatalFormat(IFormatProvider,string,object[])"/> method.
- /// </para>
- /// <para>
- /// This method does not take an <see cref="Exception"/> object to include in the
- /// log event. To pass an <see cref="Exception"/> use one of the <see cref="M:Fatal(object)"/>
- /// methods instead.
- /// </para>
- /// </remarks>
- public virtual void FatalFormat(string format, object arg0, object arg1)
- {
- if (IsFatalEnabled)
- {
- Logger.Log(ThisDeclaringType, m_levelFatal, new SystemStringFormat(CultureInfo.InvariantCulture, format, new object[] { arg0, arg1 }), null);
- }
- }
+ /// <summary>
+ /// Logs a formatted message string with the <c>FATAL</c> level.
+ /// </summary>
+ /// <param name="format">A String containing zero or more format items</param>
+ /// <param name="arg0">An Object to format</param>
+ /// <param name="arg1">An Object to format</param>
+ /// <remarks>
+ /// <para>
+ /// The message is formatted using the <see cref="M:String.Format(IFormatProvider, string, object[])"/> method. See
+ /// <c>String.Format</c> for details of the syntax of the format string and the behavior
+ /// of the formatting.
+ /// </para>
+ /// <para>
+ /// The string is formatted using the <see cref="CultureInfo.InvariantCulture"/>
+ /// format provider. To specify a localized provider use the
+ /// <see cref="M:FatalFormat(IFormatProvider,string,object[])"/> method.
+ /// </para>
+ /// <para>
+ /// This method does not take an <see cref="Exception"/> object to include in the
+ /// log event. To pass an <see cref="Exception"/> use one of the <see cref="M:Fatal(object)"/>
+ /// methods instead.
+ /// </para>
+ /// </remarks>
+ public virtual void FatalFormat(string format, object arg0, object arg1)
+ {
+ if (IsFatalEnabled)
+ {
+ Logger.Log(ThisDeclaringType, m_levelFatal, new SystemStringFormat(CultureInfo.InvariantCulture, format, new object[] { arg0, arg1 }), null);
+ }
+ }
- /// <summary>
- /// Logs a formatted message string with the <c>FATAL</c> level.
- /// </summary>
- /// <param name="format">A String containing zero or more format items</param>
- /// <param name="arg0">An Object to format</param>
- /// <param name="arg1">An Object to format</param>
- /// <param name="arg2">An Object to format</param>
- /// <remarks>
- /// <para>
- /// The message is formatted using the <see cref="M:String.Format(IFormatProvider, string, object[])"/> method. See
- /// <c>String.Format</c> for details of the syntax of the format string and the behavior
- /// of the formatting.
- /// </para>
- /// <para>
- /// The string is formatted using the <see cref="CultureInfo.InvariantCulture"/>
- /// format provider. To specify a localized provider use the
- /// <see cref="M:FatalFormat(IFormatProvider,string,object[])"/> method.
- /// </para>
- /// <para>
- /// This method does not take an <see cref="Exception"/> object to include in the
- /// log event. To pass an <see cref="Exception"/> use one of the <see cref="M:Fatal(object)"/>
- /// methods instead.
- /// </para>
- /// </remarks>
- public virtual void FatalFormat(string format, object arg0, object arg1, object arg2)
- {
- if (IsFatalEnabled)
- {
- Logger.Log(ThisDeclaringType, m_levelFatal, new SystemStringFormat(CultureInfo.InvariantCulture, format, new object[] { arg0, arg1, arg2 }), null);
- }
- }
+ /// <summary>
+ /// Logs a formatted message string with the <c>FATAL</c> level.
+ /// </summary>
+ /// <param name="format">A String containing zero or more format items</param>
+ /// <param name="arg0">An Object to format</param>
+ /// <param name="arg1">An Object to format</param>
+ /// <param name="arg2">An Object to format</param>
+ /// <remarks>
+ /// <para>
+ /// The message is formatted using the <see cref="M:String.Format(IFormatProvider, string, object[])"/> method. See
+ /// <c>String.Format</c> for details of the syntax of the format string and the behavior
+ /// of the formatting.
+ /// </para>
+ /// <para>
+ /// The string is formatted using the <see cref="CultureInfo.InvariantCulture"/>
+ /// format provider. To specify a localized provider use the
+ /// <see cref="M:FatalFormat(IFormatProvider,string,object[])"/> method.
+ /// </para>
+ /// <para>
+ /// This method does not take an <see cref="Exception"/> object to include in the
+ /// log event. To pass an <see cref="Exception"/> use one of the <see cref="M:Fatal(object)"/>
+ /// methods instead.
+ /// </para>
+ /// </remarks>
+ public virtual void FatalFormat(string format, object arg0, object arg1, object arg2)
+ {
+ if (IsFatalEnabled)
+ {
+ Logger.Log(ThisDeclaringType, m_levelFatal, new SystemStringFormat(CultureInfo.InvariantCulture, format, new object[] { arg0, arg1, arg2 }), null);
+ }
+ }
- /// <summary>
- /// Logs a formatted message string with the <c>FATAL</c> level.
- /// </summary>
- /// <param name="provider">An <see cref="IFormatProvider"/> that supplies culture-specific formatting information</param>
- /// <param name="format">A String containing zero or more format items</param>
- /// <param name="args">An Object array containing zero or more objects to format</param>
- /// <remarks>
- /// <para>
- /// The message is formatted using the <see cref="M:String.Format(IFormatProvider, string, object[])"/> method. See
- /// <c>String.Format</c> for details of the syntax of the format string and the behavior
- /// of the formatting.
- /// </para>
- /// <para>
- /// This method does not take an <see cref="Exception"/> object to include in the
- /// log event. To pass an <see cref="Exception"/> use one of the <see cref="M:Fatal(object)"/>
- /// methods instead.
- /// </para>
- /// </remarks>
- public virtual void FatalFormat(IFormatProvider provider, string format, params object[] args)
- {
- if (IsFatalEnabled)
- {
- Logger.Log(ThisDeclaringType, m_levelFatal, new SystemStringFormat(provider, format, args), null);
- }
- }
+ /// <summary>
+ /// Logs a formatted message string with the <c>FATAL</c> level.
+ /// </summary>
+ /// <param name="provider">An <see cref="IFormatProvider"/> that supplies culture-specific formatting information</param>
+ /// <param name="format">A String containing zero or more format items</param>
+ /// <param name="args">An Object array containing zero or more objects to format</param>
+ /// <remarks>
+ /// <para>
+ /// The message is formatted using the <see cref="M:String.Format(IFormatProvider, string, object[])"/> method. See
+ /// <c>String.Format</c> for details of the syntax of the format string and the behavior
+ /// of the formatting.
+ /// </para>
+ /// <para>
+ /// This method does not take an <see cref="Exception"/> object to include in the
+ /// log event. To pass an <see cref="Exception"/> use one of the <see cref="M:Fatal(object)"/>
+ /// methods instead.
+ /// </para>
+ /// </remarks>
+ public virtual void FatalFormat(IFormatProvider provider, string format, params object[] args)
+ {
+ if (IsFatalEnabled)
+ {
+ Logger.Log(ThisDeclaringType, m_levelFatal, new SystemStringFormat(provider, format, args), null);
+ }
+ }
- /// <summary>
- /// Checks if this logger is enabled for the <c>DEBUG</c>
- /// level.
- /// </summary>
- /// <value>
- /// <c>true</c> if this logger is enabled for <c>DEBUG</c> events,
- /// <c>false</c> otherwise.
- /// </value>
- /// <remarks>
- /// <para>
- /// This function is intended to lessen the computational cost of
- /// disabled log debug statements.
- /// </para>
- /// <para>
- /// For some <c>log</c> Logger object, when you write:
- /// </para>
- /// <code lang="C#">
- /// log.Debug("This is entry number: " + i );
- /// </code>
- /// <para>
- /// You incur the cost constructing the message, concatenation in
- /// this case, regardless of whether the message is logged or not.
- /// </para>
- /// <para>
- /// If you are worried about speed, then you should write:
- /// </para>
- /// <code lang="C#">
- /// if (log.IsDebugEnabled())
- /// {
- /// log.Debug("This is entry number: " + i );
- /// }
- /// </code>
- /// <para>
- /// This way you will not incur the cost of parameter
- /// construction if debugging is disabled for <c>log</c>. On
- /// the other hand, if the <c>log</c> is debug enabled, you
- /// will incur the cost of evaluating whether the logger is debug
- /// enabled twice. Once in <c>IsDebugEnabled</c> and once in
- /// the <c>Debug</c>. This is an insignificant overhead
- /// since evaluating a logger takes about 1% of the time it
- /// takes to actually log.
- /// </para>
- /// </remarks>
- public virtual bool IsDebugEnabled
- {
- get { return Logger.IsEnabledFor(m_levelDebug); }
- }
+ /// <summary>
+ /// Checks if this logger is enabled for the <c>DEBUG</c>
+ /// level.
+ /// </summary>
+ /// <value>
+ /// <c>true</c> if this logger is enabled for <c>DEBUG</c> events,
+ /// <c>false</c> otherwise.
+ /// </value>
+ /// <remarks>
+ /// <para>
+ /// This function is intended to lessen the computational cost of
+ /// disabled log debug statements.
+ /// </para>
+ /// <para>
+ /// For some <c>log</c> Logger object, when you write:
+ /// </para>
+ /// <code lang="C#">
+ /// log.Debug("This is entry number: " + i );
+ /// </code>
+ /// <para>
+ /// You incur the cost constructing the message, concatenation in
+ /// this case, regardless of whether the message is logged or not.
+ /// </para>
+ /// <para>
+ /// If you are worried about speed, then you should write:
+ /// </para>
+ /// <code lang="C#">
+ /// if (log.IsDebugEnabled())
+ /// {
+ /// log.Debug("This is entry number: " + i );
+ /// }
+ /// </code>
+ /// <para>
+ /// This way you will not incur the cost of parameter
+ /// construction if debugging is disabled for <c>log</c>. On
+ /// the other hand, if the <c>log</c> is debug enabled, you
+ /// will incur the cost of evaluating whether the logger is debug
+ /// enabled twice. Once in <c>IsDebugEnabled</c> and once in
+ /// the <c>Debug</c>. This is an insignificant overhead
+ /// since evaluating a logger takes about 1% of the time it
+ /// takes to actually log.
+ /// </para>
+ /// </remarks>
+ public virtual bool IsDebugEnabled
+ {
+ get { return Logger.IsEnabledFor(m_levelDebug); }
+ }
- /// <summary>
- /// Checks if this logger is enabled for the <c>INFO</c> level.
- /// </summary>
- /// <value>
- /// <c>true</c> if this logger is enabled for <c>INFO</c> events,
- /// <c>false</c> otherwise.
- /// </value>
- /// <remarks>
- /// <para>
- /// See <see cref="IsDebugEnabled"/> for more information and examples
- /// of using this method.
- /// </para>
- /// </remarks>
- /// <seealso cref="LogImpl.IsDebugEnabled"/>
- public virtual bool IsInfoEnabled
- {
- get { return Logger.IsEnabledFor(m_levelInfo); }
- }
+ /// <summary>
+ /// Checks if this logger is enabled for the <c>INFO</c> level.
+ /// </summary>
+ /// <value>
+ /// <c>true</c> if this logger is enabled for <c>INFO</c> events,
+ /// <c>false</c> otherwise.
+ /// </value>
+ /// <remarks>
+ /// <para>
+ /// See <see cref="IsDebugEnabled"/> for more information and examples
+ /// of using this method.
+ /// </para>
+ /// </remarks>
+ /// <seealso cref="LogImpl.IsDebugEnabled"/>
+ public virtual bool IsInfoEnabled
+ {
+ get { return Logger.IsEnabledFor(m_levelInfo); }
+ }
- /// <summary>
- /// Checks if this logger is enabled for the <c>WARN</c> level.
- /// </summary>
- /// <value>
- /// <c>true</c> if this logger is enabled for <c>WARN</c> events,
- /// <c>false</c> otherwise.
- /// </value>
- /// <remarks>
- /// <para>
- /// See <see cref="IsDebugEnabled"/> for more information and examples
- /// of using this method.
- /// </para>
- /// </remarks>
- /// <seealso cref="ILog.IsDebugEnabled"/>
- public virtual bool IsWarnEnabled
- {
- get { return Logger.IsEnabledFor(m_levelWarn); }
- }
+ /// <summary>
+ /// Checks if this logger is enabled for the <c>WARN</c> level.
+ /// </summary>
+ /// <value>
+ /// <c>true</c> if this logger is enabled for <c>WARN</c> events,
+ /// <c>false</c> otherwise.
+ /// </value>
+ /// <remarks>
+ /// <para>
+ /// See <see cref="IsDebugEnabled"/> for more information and examples
+ /// of using this method.
+ /// </para>
+ /// </remarks>
+ /// <seealso cref="ILog.IsDebugEnabled"/>
+ public virtual bool IsWarnEnabled
+ {
+ get { return Logger.IsEnabledFor(m_levelWarn); }
+ }
- /// <summary>
- /// Checks if this logger is enabled for the <c>ERROR</c> level.
- /// </summary>
- /// <value>
- /// <c>true</c> if this logger is enabled for <c>ERROR</c> events,
- /// <c>false</c> otherwise.
- /// </value>
- /// <remarks>
- /// <para>
- /// See <see cref="IsDebugEnabled"/> for more information and examples of using this method.
- /// </para>
- /// </remarks>
- /// <seealso cref="ILog.IsDebugEnabled"/>
- public virtual bool IsErrorEnabled
- {
- get { return Logger.IsEnabledFor(m_levelError); }
- }
+ /// <summary>
+ /// Checks if this logger is enabled for the <c>ERROR</c> level.
+ /// </summary>
+ /// <value>
+ /// <c>true</c> if this logger is enabled for <c>ERROR</c> events,
+ /// <c>false</c> otherwise.
+ /// </value>
+ /// <remarks>
+ /// <para>
+ /// See <see cref="IsDebugEnabled"/> for more information and examples of using this method.
+ /// </para>
+ /// </remarks>
+ /// <seealso cref="ILog.IsDebugEnabled"/>
+ public virtual bool IsErrorEnabled
+ {
+ get { return Logger.IsEnabledFor(m_levelError); }
+ }
- /// <summary>
- /// Checks if this logger is enabled for the <c>FATAL</c> level.
- /// </summary>
- /// <value>
- /// <c>true</c> if this logger is enabled for <c>FATAL</c> events,
- /// <c>false</c> otherwise.
- /// </value>
- /// <remarks>
- /// <para>
- /// See <see cref="IsDebugEnabled"/> for more information and examples of using this method.
- /// </para>
- /// </remarks>
- /// <seealso cref="ILog.IsDebugEnabled"/>
- public virtual bool IsFatalEnabled
- {
- get { return Logger.IsEnabledFor(m_levelFatal); }
- }
+ /// <summary>
+ /// Checks if this logger is enabled for the <c>FATAL</c> level.
+ /// </summary>
+ /// <value>
+ /// <c>true</c> if this logger is enabled for <c>FATAL</c> events,
+ /// <c>false</c> otherwise.
+ /// </value>
+ /// <remarks>
+ /// <para>
+ /// See <see cref="IsDebugEnabled"/> for more information and examples of using this method.
+ /// </para>
+ /// </remarks>
+ /// <seealso cref="ILog.IsDebugEnabled"/>
+ public virtual bool IsFatalEnabled
+ {
+ get { return Logger.IsEnabledFor(m_levelFatal); }
+ }
- #endregion Implementation of ILog
+ #endregion Implementation of ILog
- #region Private Methods
+ #region Private Methods
- /// <summary>
- /// Event handler for the <see cref="log4net.Repository.ILoggerRepository.ConfigurationChanged"/> event
- /// </summary>
- /// <param name="sender">the repository</param>
- /// <param name="e">Empty</param>
- private void LoggerRepositoryConfigurationChanged(object sender, EventArgs e)
- {
- ILoggerRepository repository = sender as ILoggerRepository;
- if (repository != null)
- {
- ReloadLevels(repository);
- }
- }
+ /// <summary>
+ /// Event handler for the <see cref="log4net.Repository.ILoggerRepository.ConfigurationChanged"/> event
+ /// </summary>
+ /// <param name="sender">the repository</param>
+ /// <param name="e">Empty</param>
+ private void LoggerRepositoryConfigurationChanged(object sender, EventArgs e)
+ {
+ ILoggerRepository repository = sender as ILoggerRepository;
+ if (repository != null)
+ {
+ ReloadLevels(repository);
+ }
+ }
- #endregion
+ #endregion
- #region Private Static Instance Fields
+ #region Private Static Instance Fields
- /// <summary>
- /// The fully qualified name of this declaring type not the type of any subclass.
- /// </summary>
- private static readonly Type ThisDeclaringType = typeof(LogImpl);
+ /// <summary>
+ /// The fully qualified name of this declaring type not the type of any subclass.
+ /// </summary>
+ private static readonly Type ThisDeclaringType = typeof(LogImpl);
- #endregion Private Static Instance Fields
+ #endregion Private Static Instance Fields
- #region Private Fields
+ #region Private Fields
- private Level m_levelDebug;
- private Level m_levelInfo;
- private Level m_levelWarn;
- private Level m_levelError;
- private Level m_levelFatal;
+ private Level m_levelDebug;
+ private Level m_levelInfo;
+ private Level m_levelWarn;
+ private Level m_levelError;
+ private Level m_levelFatal;
- #endregion
- }
+ #endregion
+ }
}
diff --git a/src/log4net/Core/LoggerManager.cs b/src/log4net/Core/LoggerManager.cs
index 98a2fe8..8fb38c8 100644
--- a/src/log4net/Core/LoggerManager.cs
+++ b/src/log4net/Core/LoggerManager.cs
@@ -28,851 +28,851 @@
namespace log4net.Core
{
- /// <summary>
- /// Static manager that controls the creation of repositories
- /// </summary>
- /// <remarks>
- /// <para>
- /// Static manager that controls the creation of repositories
- /// </para>
- /// <para>
- /// This class is used by the wrapper managers (e.g. <see cref="log4net.LogManager"/>)
- /// to provide access to the <see cref="ILogger"/> objects.
- /// </para>
- /// <para>
- /// This manager also holds the <see cref="IRepositorySelector"/> that is used to
- /// lookup and create repositories. The selector can be set either programmatically using
- /// the <see cref="RepositorySelector"/> property, or by setting the <c>log4net.RepositorySelector</c>
- /// AppSetting in the applications config file to the fully qualified type name of the
- /// selector to use.
- /// </para>
- /// </remarks>
- /// <author>Nicko Cadell</author>
- /// <author>Gert Driesen</author>
- public sealed class LoggerManager
- {
- #region Private Instance Constructors
+ /// <summary>
+ /// Static manager that controls the creation of repositories
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Static manager that controls the creation of repositories
+ /// </para>
+ /// <para>
+ /// This class is used by the wrapper managers (e.g. <see cref="log4net.LogManager"/>)
+ /// to provide access to the <see cref="ILogger"/> objects.
+ /// </para>
+ /// <para>
+ /// This manager also holds the <see cref="IRepositorySelector"/> that is used to
+ /// lookup and create repositories. The selector can be set either programmatically using
+ /// the <see cref="RepositorySelector"/> property, or by setting the <c>log4net.RepositorySelector</c>
+ /// AppSetting in the applications config file to the fully qualified type name of the
+ /// selector to use.
+ /// </para>
+ /// </remarks>
+ /// <author>Nicko Cadell</author>
+ /// <author>Gert Driesen</author>
+ public sealed class LoggerManager
+ {
+ #region Private Instance Constructors
- /// <summary>
- /// Private constructor to prevent instances. Only static methods should be used.
- /// </summary>
- /// <remarks>
- /// <para>
- /// Private constructor to prevent instances. Only static methods should be used.
- /// </para>
- /// </remarks>
- private LoggerManager()
- {
- }
+ /// <summary>
+ /// Private constructor to prevent instances. Only static methods should be used.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Private constructor to prevent instances. Only static methods should be used.
+ /// </para>
+ /// </remarks>
+ private LoggerManager()
+ {
+ }
- #endregion Private Instance Constructors
+ #endregion Private Instance Constructors
- #region Static Constructor
+ #region Static Constructor
- /// <summary>
- /// Hook the shutdown event
- /// </summary>
- /// <remarks>
- /// <para>
- /// On the full .NET runtime, the static constructor hooks up the
- /// <c>AppDomain.ProcessExit</c> and <c>AppDomain.DomainUnload</c>> events.
- /// These are used to shutdown the log4net system as the application exits.
- /// </para>
- /// </remarks>
- static LoggerManager()
- {
- try
- {
- // Register the AppDomain events, note we have to do this with a
- // method call rather than directly here because the AppDomain
- // makes a LinkDemand which throws the exception during the JIT phase.
- RegisterAppDomainEvents();
- }
- catch(System.Security.SecurityException)
- {
- LogLog.Debug(declaringType, "Security Exception (ControlAppDomain LinkDemand) while trying "+
- "to register Shutdown handler with the AppDomain. LoggerManager.Shutdown() "+
- "will not be called automatically when the AppDomain exits. It must be called "+
- "programmatically.");
- }
+ /// <summary>
+ /// Hook the shutdown event
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// On the full .NET runtime, the static constructor hooks up the
+ /// <c>AppDomain.ProcessExit</c> and <c>AppDomain.DomainUnload</c>> events.
+ /// These are used to shutdown the log4net system as the application exits.
+ /// </para>
+ /// </remarks>
+ static LoggerManager()
+ {
+ try
+ {
+ // Register the AppDomain events, note we have to do this with a
+ // method call rather than directly here because the AppDomain
+ // makes a LinkDemand which throws the exception during the JIT phase.
+ RegisterAppDomainEvents();
+ }
+ catch(System.Security.SecurityException)
+ {
+ LogLog.Debug(declaringType, "Security Exception (ControlAppDomain LinkDemand) while trying "+
+ "to register Shutdown handler with the AppDomain. LoggerManager.Shutdown() "+
+ "will not be called automatically when the AppDomain exits. It must be called "+
+ "programmatically.");
+ }
- // Dump out our assembly version into the log if debug is enabled
+ // Dump out our assembly version into the log if debug is enabled
LogLog.Debug(declaringType, GetVersionInfo());
- // Set the default repository selector
+ // Set the default repository selector
#if NETCF
- s_repositorySelector = new CompactRepositorySelector(typeof(log4net.Repository.Hierarchy.Hierarchy));
- return;
+ s_repositorySelector = new CompactRepositorySelector(typeof(log4net.Repository.Hierarchy.Hierarchy));
+ return;
#elif !NETSTANDARD1_3
- // Look for the RepositorySelector type specified in the AppSettings 'log4net.RepositorySelector'
- string appRepositorySelectorTypeName = SystemInfo.GetAppSetting("log4net.RepositorySelector");
- if (appRepositorySelectorTypeName != null && appRepositorySelectorTypeName.Length > 0)
- {
- // Resolve the config string into a Type
- Type appRepositorySelectorType = null;
- try
- {
- appRepositorySelectorType = SystemInfo.GetTypeFromString(appRepositorySelectorTypeName, false, true);
- }
- catch(Exception ex)
- {
- LogLog.Error(declaringType, "Exception while resolving RepositorySelector Type ["+appRepositorySelectorTypeName+"]", ex);
- }
+ // Look for the RepositorySelector type specified in the AppSettings 'log4net.RepositorySelector'
+ string appRepositorySelectorTypeName = SystemInfo.GetAppSetting("log4net.RepositorySelector");
+ if (appRepositorySelectorTypeName != null && appRepositorySelectorTypeName.Length > 0)
+ {
+ // Resolve the config string into a Type
+ Type appRepositorySelectorType = null;
+ try
+ {
+ appRepositorySelectorType = SystemInfo.GetTypeFromString(appRepositorySelectorTypeName, false, true);
+ }
+ catch(Exception ex)
+ {
+ LogLog.Error(declaringType, "Exception while resolving RepositorySelector Type ["+appRepositorySelectorTypeName+"]", ex);
+ }
- if (appRepositorySelectorType != null)
- {
- // Create an instance of the RepositorySelectorType
- object appRepositorySelectorObj = null;
- try
- {
- appRepositorySelectorObj = Activator.CreateInstance(appRepositorySelectorType);
- }
- catch(Exception ex)
- {
- LogLog.Error(declaringType, "Exception while creating RepositorySelector ["+appRepositorySelectorType.FullName+"]", ex);
- }
+ if (appRepositorySelectorType != null)
+ {
+ // Create an instance of the RepositorySelectorType
+ object appRepositorySelectorObj = null;
+ try
+ {
+ appRepositorySelectorObj = Activator.CreateInstance(appRepositorySelectorType);
+ }
+ catch(Exception ex)
+ {
+ LogLog.Error(declaringType, "Exception while creating RepositorySelector ["+appRepositorySelectorType.FullName+"]", ex);
+ }
- if (appRepositorySelectorObj != null && appRepositorySelectorObj is IRepositorySelector)
- {
- s_repositorySelector = (IRepositorySelector)appRepositorySelectorObj;
- }
- else
- {
- LogLog.Error(declaringType, "RepositorySelector Type ["+appRepositorySelectorType.FullName+"] is not an IRepositorySelector");
- }
- }
- }
+ if (appRepositorySelectorObj != null && appRepositorySelectorObj is IRepositorySelector)
+ {
+ s_repositorySelector = (IRepositorySelector)appRepositorySelectorObj;
+ }
+ else
+ {
+ LogLog.Error(declaringType, "RepositorySelector Type ["+appRepositorySelectorType.FullName+"] is not an IRepositorySelector");
+ }
+ }
+ }
#endif
- // Create the DefaultRepositorySelector if not configured above
- if (s_repositorySelector == null)
- {
- s_repositorySelector = new DefaultRepositorySelector(typeof(log4net.Repository.Hierarchy.Hierarchy));
- }
- }
+ // Create the DefaultRepositorySelector if not configured above
+ if (s_repositorySelector == null)
+ {
+ s_repositorySelector = new DefaultRepositorySelector(typeof(log4net.Repository.Hierarchy.Hierarchy));
+ }
+ }
- /// <summary>
- /// Register for ProcessExit and DomainUnload events on the AppDomain
- /// </summary>
- /// <remarks>
- /// <para>
- /// This needs to be in a separate method because the events make
- /// a LinkDemand for the ControlAppDomain SecurityPermission. Because
- /// this is a LinkDemand it is demanded at JIT time. Therefore we cannot
- /// catch the exception in the method itself, we have to catch it in the
- /// caller.
- /// </para>
- /// </remarks>
- private static void RegisterAppDomainEvents()
- {
+ /// <summary>
+ /// Register for ProcessExit and DomainUnload events on the AppDomain
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// This needs to be in a separate method because the events make
+ /// a LinkDemand for the ControlAppDomain SecurityPermission. Because
+ /// this is a LinkDemand it is demanded at JIT time. Therefore we cannot
+ /// catch the exception in the method itself, we have to catch it in the
+ /// caller.
+ /// </para>
+ /// </remarks>
+ private static void RegisterAppDomainEvents()
+ {
#if !NETCF && !NETSTANDARD1_3
- // ProcessExit seems to be fired if we are part of the default domain
- AppDomain.CurrentDomain.ProcessExit += new EventHandler(OnProcessExit);
+ // ProcessExit seems to be fired if we are part of the default domain
+ AppDomain.CurrentDomain.ProcessExit += new EventHandler(OnProcessExit);
- // Otherwise DomainUnload is fired
- AppDomain.CurrentDomain.DomainUnload += new EventHandler(OnDomainUnload);
+ // Otherwise DomainUnload is fired
+ AppDomain.CurrentDomain.DomainUnload += new EventHandler(OnDomainUnload);
#endif
- }
+ }
- #endregion Static Constructor
+ #endregion Static Constructor
- #region Public Static Methods
+ #region Public Static Methods
- /// <summary>
- /// Return the default <see cref="ILoggerRepository"/> instance.
- /// </summary>
- /// <param name="repository">the repository to lookup in</param>
- /// <returns>Return the default <see cref="ILoggerRepository"/> instance</returns>
- /// <remarks>
- /// <para>
- /// Gets the <see cref="ILoggerRepository"/> for the repository specified
- /// by the <paramref name="repository"/> argument.
- /// </para>
- /// </remarks>
- [Obsolete("Use GetRepository instead of GetLoggerRepository")]
- public static ILoggerRepository GetLoggerRepository(string repository)
- {
- return GetRepository(repository);
- }
+ /// <summary>
+ /// Return the default <see cref="ILoggerRepository"/> instance.
+ /// </summary>
+ /// <param name="repository">the repository to lookup in</param>
+ /// <returns>Return the default <see cref="ILoggerRepository"/> instance</returns>
+ /// <remarks>
+ /// <para>
+ /// Gets the <see cref="ILoggerRepository"/> for the repository specified
+ /// by the <paramref name="repository"/> argument.
+ /// </para>
+ /// </remarks>
+ [Obsolete("Use GetRepository instead of GetLoggerRepository")]
+ public static ILoggerRepository GetLoggerRepository(string repository)
+ {
+ return GetRepository(repository);
+ }
- /// <summary>
- /// Returns the default <see cref="ILoggerRepository"/> instance.
- /// </summary>
- /// <param name="repositoryAssembly">The assembly to use to lookup the repository.</param>
- /// <returns>The default <see cref="ILoggerRepository"/> instance.</returns>
- [Obsolete("Use GetRepository instead of GetLoggerRepository")]
- public static ILoggerRepository GetLoggerRepository(Assembly repositoryAssembly)
- {
- return GetRepository(repositoryAssembly);
- }
+ /// <summary>
+ /// Returns the default <see cref="ILoggerRepository"/> instance.
+ /// </summary>
+ /// <param name="repositoryAssembly">The assembly to use to lookup the repository.</param>
+ /// <returns>The default <see cref="ILoggerRepository"/> instance.</returns>
+ [Obsolete("Use GetRepository instead of GetLoggerRepository")]
+ public static ILoggerRepository GetLoggerRepository(Assembly repositoryAssembly)
+ {
+ return GetRepository(repositoryAssembly);
+ }
- /// <summary>
- /// Return the default <see cref="ILoggerRepository"/> instance.
- /// </summary>
- /// <param name="repository">the repository to lookup in</param>
- /// <returns>Return the default <see cref="ILoggerRepository"/> instance</returns>
- /// <remarks>
- /// <para>
- /// Gets the <see cref="ILoggerRepository"/> for the repository specified
- /// by the <paramref name="repository"/> argument.
- /// </para>
- /// </remarks>
- public static ILoggerRepository GetRepository(string repository)
- {
- if (repository == null)
- {
- throw new ArgumentNullException("repository");
- }
- return RepositorySelector.GetRepository(repository);
- }
+ /// <summary>
+ /// Return the default <see cref="ILoggerRepository"/> instance.
+ /// </summary>
+ /// <param name="repository">the repository to lookup in</param>
+ /// <returns>Return the default <see cref="ILoggerRepository"/> instance</returns>
+ /// <remarks>
+ /// <para>
+ /// Gets the <see cref="ILoggerRepository"/> for the repository specified
+ /// by the <paramref name="repository"/> argument.
+ /// </para>
+ /// </remarks>
+ public static ILoggerRepository GetRepository(string repository)
+ {
+ if (repository == null)
+ {
+ throw new ArgumentNullException("repository");
+ }
+ return RepositorySelector.GetRepository(repository);
+ }
- /// <summary>
- /// Returns the default <see cref="ILoggerRepository"/> instance.
- /// </summary>
- /// <param name="repositoryAssembly">The assembly to use to lookup the repository.</param>
- /// <returns>The default <see cref="ILoggerRepository"/> instance.</returns>
- /// <remarks>
- /// <para>
- /// Returns the default <see cref="ILoggerRepository"/> instance.
- /// </para>
- /// </remarks>
- public static ILoggerRepository GetRepository(Assembly repositoryAssembly)
- {
- if (repositoryAssembly == null)
- {
- throw new ArgumentNullException("repositoryAssembly");
- }
- return RepositorySelector.GetRepository(repositoryAssembly);
- }
+ /// <summary>
+ /// Returns the default <see cref="ILoggerRepository"/> instance.
+ /// </summary>
+ /// <param name="repositoryAssembly">The assembly to use to lookup the repository.</param>
+ /// <returns>The default <see cref="ILoggerRepository"/> instance.</returns>
+ /// <remarks>
+ /// <para>
+ /// Returns the default <see cref="ILoggerRepository"/> instance.
+ /// </para>
+ /// </remarks>
+ public static ILoggerRepository GetRepository(Assembly repositoryAssembly)
+ {
+ if (repositoryAssembly == null)
+ {
+ throw new ArgumentNullException("repositoryAssembly");
+ }
+ return RepositorySelector.GetRepository(repositoryAssembly);
+ }
- /// <summary>
- /// Returns the named logger if it exists.
- /// </summary>
- /// <param name="repository">The repository to lookup in.</param>
- /// <param name="name">The fully qualified logger name to look for.</param>
- /// <returns>
- /// The logger found, or <c>null</c> if the named logger does not exist in the
- /// specified repository.
- /// </returns>
- /// <remarks>
- /// <para>
- /// If the named logger exists (in the specified repository) then it
- /// returns a reference to the logger, otherwise it returns
- /// <c>null</c>.
- /// </para>
- /// </remarks>
- public static ILogger Exists(string repository, string name)
- {
- if (repository == null)
- {
- throw new ArgumentNullException("repository");
- }
- if (name == null)
- {
- throw new ArgumentNullException("name");
- }
- return RepositorySelector.GetRepository(repository).Exists(name);
- }
+ /// <summary>
+ /// Returns the named logger if it exists.
+ /// </summary>
+ /// <param name="repository">The repository to lookup in.</param>
+ /// <param name="name">The fully qualified logger name to look for.</param>
+ /// <returns>
+ /// The logger found, or <c>null</c> if the named logger does not exist in the
+ /// specified repository.
+ /// </returns>
+ /// <remarks>
+ /// <para>
+ /// If the named logger exists (in the specified repository) then it
+ /// returns a reference to the logger, otherwise it returns
+ /// <c>null</c>.
+ /// </para>
+ /// </remarks>
+ public static ILogger Exists(string repository, string name)
+ {
+ if (repository == null)
+ {
+ throw new ArgumentNullException("repository");
+ }
+ if (name == null)
+ {
+ throw new ArgumentNullException("name");
+ }
+ return RepositorySelector.GetRepository(repository).Exists(name);
+ }
- /// <summary>
- /// Returns the named logger if it exists.
- /// </summary>
- /// <param name="repositoryAssembly">The assembly to use to lookup the repository.</param>
- /// <param name="name">The fully qualified logger name to look for.</param>
- /// <returns>
- /// The logger found, or <c>null</c> if the named logger does not exist in the
- /// specified assembly's repository.
- /// </returns>
- /// <remarks>
- /// <para>
- /// If the named logger exists (in the specified assembly's repository) then it
- /// returns a reference to the logger, otherwise it returns
- /// <c>null</c>.
- /// </para>
- /// </remarks>
- public static ILogger Exists(Assembly repositoryAssembly, string name)
- {
- if (repositoryAssembly == null)
- {
- throw new ArgumentNullException("repositoryAssembly");
- }
- if (name == null)
- {
- throw new ArgumentNullException("name");
- }
- return RepositorySelector.GetRepository(repositoryAssembly).Exists(name);
- }
+ /// <summary>
+ /// Returns the named logger if it exists.
+ /// </summary>
+ /// <param name="repositoryAssembly">The assembly to use to lookup the repository.</param>
+ /// <param name="name">The fully qualified logger name to look for.</param>
+ /// <returns>
+ /// The logger found, or <c>null</c> if the named logger does not exist in the
+ /// specified assembly's repository.
+ /// </returns>
+ /// <remarks>
+ /// <para>
+ /// If the named logger exists (in the specified assembly's repository) then it
+ /// returns a reference to the logger, otherwise it returns
+ /// <c>null</c>.
+ /// </para>
+ /// </remarks>
+ public static ILogger Exists(Assembly repositoryAssembly, string name)
+ {
+ if (repositoryAssembly == null)
+ {
+ throw new ArgumentNullException("repositoryAssembly");
+ }
+ if (name == null)
+ {
+ throw new ArgumentNullException("name");
+ }
+ return RepositorySelector.GetRepository(repositoryAssembly).Exists(name);
+ }
- /// <summary>
- /// Returns all the currently defined loggers in the specified repository.
- /// </summary>
- /// <param name="repository">The repository to lookup in.</param>
- /// <returns>All the defined loggers.</returns>
- /// <remarks>
- /// <para>
- /// The root logger is <b>not</b> included in the returned array.
- /// </para>
- /// </remarks>
- public static ILogger[] GetCurrentLoggers(string repository)
- {
- if (repository == null)
- {
- throw new ArgumentNullException("repository");
- }
- return RepositorySelector.GetRepository(repository).GetCurrentLoggers();
- }
+ /// <summary>
+ /// Returns all the currently defined loggers in the specified repository.
+ /// </summary>
+ /// <param name="repository">The repository to lookup in.</param>
+ /// <returns>All the defined loggers.</returns>
+ /// <remarks>
+ /// <para>
+ /// The root logger is <b>not</b> included in the returned array.
+ /// </para>
+ /// </remarks>
+ public static ILogger[] GetCurrentLoggers(string repository)
+ {
+ if (repository == null)
+ {
+ throw new ArgumentNullException("repository");
+ }
+ return RepositorySelector.GetRepository(repository).GetCurrentLoggers();
+ }
- /// <summary>
- /// Returns all the currently defined loggers in the specified assembly's repository.
- /// </summary>
- /// <param name="repositoryAssembly">The assembly to use to lookup the repository.</param>
- /// <returns>All the defined loggers.</returns>
- /// <remarks>
- /// <para>
- /// The root logger is <b>not</b> included in the returned array.
- /// </para>
- /// </remarks>
- public static ILogger[] GetCurrentLoggers(Assembly repositoryAssembly)
- {
- if (repositoryAssembly == null)
- {
- throw new ArgumentNullException("repositoryAssembly");
- }
- return RepositorySelector.GetRepository(repositoryAssembly).GetCurrentLoggers();
- }
+ /// <summary>
+ /// Returns all the currently defined loggers in the specified assembly's repository.
+ /// </summary>
+ /// <param name="repositoryAssembly">The assembly to use to lookup the repository.</param>
+ /// <returns>All the defined loggers.</returns>
+ /// <remarks>
+ /// <para>
+ /// The root logger is <b>not</b> included in the returned array.
+ /// </para>
+ /// </remarks>
+ public static ILogger[] GetCurrentLoggers(Assembly repositoryAssembly)
+ {
+ if (repositoryAssembly == null)
+ {
+ throw new ArgumentNullException("repositoryAssembly");
+ }
+ return RepositorySelector.GetRepository(repositoryAssembly).GetCurrentLoggers();
+ }
- /// <summary>
- /// Retrieves or creates a named logger.
- /// </summary>
- /// <param name="repository">The repository to lookup in.</param>
- /// <param name="name">The name of the logger to retrieve.</param>
- /// <returns>The logger with the name specified.</returns>
- /// <remarks>
- /// <para>
- /// Retrieves a logger named as the <paramref name="name"/>
- /// parameter. If the named logger already exists, then the
- /// existing instance will be returned. Otherwise, a new instance is
- /// created.
- /// </para>
- /// <para>
- /// By default, loggers do not have a set level but inherit
- /// it from the hierarchy. This is one of the central features of
- /// log4net.
- /// </para>
- /// </remarks>
- public static ILogger GetLogger(string repository, string name)
- {
- if (repository == null)
- {
- throw new ArgumentNullException("repository");
- }
- if (name == null)
- {
- throw new ArgumentNullException("name");
- }
- return RepositorySelector.GetRepository(repository).GetLogger(name);
- }
+ /// <summary>
+ /// Retrieves or creates a named logger.
+ /// </summary>
+ /// <param name="repository">The repository to lookup in.</param>
+ /// <param name="name">The name of the logger to retrieve.</param>
+ /// <returns>The logger with the name specified.</returns>
+ /// <remarks>
+ /// <para>
+ /// Retrieves a logger named as the <paramref name="name"/>
+ /// parameter. If the named logger already exists, then the
+ /// existing instance will be returned. Otherwise, a new instance is
+ /// created.
+ /// </para>
+ /// <para>
+ /// By default, loggers do not have a set level but inherit
+ /// it from the hierarchy. This is one of the central features of
+ /// log4net.
+ /// </para>
+ /// </remarks>
+ public static ILogger GetLogger(string repository, string name)
+ {
+ if (repository == null)
+ {
+ throw new ArgumentNullException("repository");
+ }
+ if (name == null)
+ {
+ throw new ArgumentNullException("name");
+ }
+ return RepositorySelector.GetRepository(repository).GetLogger(name);
+ }
- /// <summary>
- /// Retrieves or creates a named logger.
- /// </summary>
- /// <param name="repositoryAssembly">The assembly to use to lookup the repository.</param>
- /// <param name="name">The name of the logger to retrieve.</param>
- /// <returns>The logger with the name specified.</returns>
- /// <remarks>
- /// <para>
- /// Retrieves a logger named as the <paramref name="name"/>
- /// parameter. If the named logger already exists, then the
- /// existing instance will be returned. Otherwise, a new instance is
- /// created.
- /// </para>
- /// <para>
- /// By default, loggers do not have a set level but inherit
- /// it from the hierarchy. This is one of the central features of
- /// log4net.
- /// </para>
- /// </remarks>
- public static ILogger GetLogger(Assembly repositoryAssembly, string name)
- {
- if (repositoryAssembly == null)
- {
- throw new ArgumentNullException("repositoryAssembly");
- }
- if (name == null)
- {
- throw new ArgumentNullException("name");
- }
- return RepositorySelector.GetRepository(repositoryAssembly).GetLogger(name);
- }
+ /// <summary>
+ /// Retrieves or creates a named logger.
+ /// </summary>
+ /// <param name="repositoryAssembly">The assembly to use to lookup the repository.</param>
+ /// <param name="name">The name of the logger to retrieve.</param>
+ /// <returns>The logger with the name specified.</returns>
+ /// <remarks>
+ /// <para>
+ /// Retrieves a logger named as the <paramref name="name"/>
+ /// parameter. If the named logger already exists, then the
+ /// existing instance will be returned. Otherwise, a new instance is
+ /// created.
+ /// </para>
+ /// <para>
+ /// By default, loggers do not have a set level but inherit
+ /// it from the hierarchy. This is one of the central features of
+ /// log4net.
+ /// </para>
+ /// </remarks>
+ public static ILogger GetLogger(Assembly repositoryAssembly, string name)
+ {
+ if (repositoryAssembly == null)
+ {
+ throw new ArgumentNullException("repositoryAssembly");
+ }
+ if (name == null)
+ {
+ throw new ArgumentNullException("name");
+ }
+ return RepositorySelector.GetRepository(repositoryAssembly).GetLogger(name);
+ }
- /// <summary>
- /// Shorthand for <see cref="M:LogManager.GetLogger(string)"/>.
- /// </summary>
- /// <param name="repository">The repository to lookup in.</param>
- /// <param name="type">The <paramref name="type"/> of which the fullname will be used as the name of the logger to retrieve.</param>
- /// <returns>The logger with the name specified.</returns>
- /// <remarks>
- /// <para>
- /// Gets the logger for the fully qualified name of the type specified.
- /// </para>
- /// </remarks>
- public static ILogger GetLogger(string repository, Type type)
- {
- if (repository == null)
- {
- throw new ArgumentNullException("repository");
- }
- if (type == null)
- {
- throw new ArgumentNullException("type");
- }
- return RepositorySelector.GetRepository(repository).GetLogger(type.FullName);
- }
+ /// <summary>
+ /// Shorthand for <see cref="M:LogManager.GetLogger(string)"/>.
+ /// </summary>
+ /// <param name="repository">The repository to lookup in.</param>
+ /// <param name="type">The <paramref name="type"/> of which the fullname will be used as the name of the logger to retrieve.</param>
+ /// <returns>The logger with the name specified.</returns>
+ /// <remarks>
+ /// <para>
+ /// Gets the logger for the fully qualified name of the type specified.
+ /// </para>
+ /// </remarks>
+ public static ILogger GetLogger(string repository, Type type)
+ {
+ if (repository == null)
+ {
+ throw new ArgumentNullException("repository");
+ }
+ if (type == null)
+ {
+ throw new ArgumentNullException("type");
+ }
+ return RepositorySelector.GetRepository(repository).GetLogger(type.FullName);
+ }
- /// <summary>
- /// Shorthand for <see cref="M:LogManager.GetLogger(string)"/>.
- /// </summary>
- /// <param name="repositoryAssembly">the assembly to use to lookup the repository</param>
- /// <param name="type">The <paramref name="type"/> of which the fullname will be used as the name of the logger to retrieve.</param>
- /// <returns>The logger with the name specified.</returns>
- /// <remarks>
- /// <para>
- /// Gets the logger for the fully qualified name of the type specified.
- /// </para>
- /// </remarks>
- public static ILogger GetLogger(Assembly repositoryAssembly, Type type)
- {
- if (repositoryAssembly == null)
- {
- throw new ArgumentNullException("repositoryAssembly");
- }
- if (type == null)
- {
- throw new ArgumentNullException("type");
- }
- return RepositorySelector.GetRepository(repositoryAssembly).GetLogger(type.FullName);
- }
+ /// <summary>
+ /// Shorthand for <see cref="M:LogManager.GetLogger(string)"/>.
+ /// </summary>
+ /// <param name="repositoryAssembly">the assembly to use to lookup the repository</param>
+ /// <param name="type">The <paramref name="type"/> of which the fullname will be used as the name of the logger to retrieve.</param>
+ /// <returns>The logger with the name specified.</returns>
+ /// <remarks>
+ /// <para>
+ /// Gets the logger for the fully qualified name of the type specified.
+ /// </para>
+ /// </remarks>
+ public static ILogger GetLogger(Assembly repositoryAssembly, Type type)
+ {
+ if (repositoryAssembly == null)
+ {
+ throw new ArgumentNullException("repositoryAssembly");
+ }
+ if (type == null)
+ {
+ throw new ArgumentNullException("type");
+ }
+ return RepositorySelector.GetRepository(repositoryAssembly).GetLogger(type.FullName);
+ }
- /// <summary>
- /// Shuts down the log4net system.
- /// </summary>
- /// <remarks>
- /// <para>
- /// Calling this method will <b>safely</b> close and remove all
- /// appenders in all the loggers including root contained in all the
- /// default repositories.
- /// </para>
- /// <para>
- /// Some appenders need to be closed before the application exists.
- /// Otherwise, pending logging events might be lost.
- /// </para>
- /// <para>
- /// The <c>shutdown</c> method is careful to close nested
- /// appenders before closing regular appenders. This is allows
- /// configurations where a regular appender is attached to a logger
- /// and again to a nested appender.
- /// </para>
- /// </remarks>
- public static void Shutdown()
- {
- foreach(ILoggerRepository repository in GetAllRepositories())
- {
- repository.Shutdown();
- }
- }
+ /// <summary>
+ /// Shuts down the log4net system.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Calling this method will <b>safely</b> close and remove all
+ /// appenders in all the loggers including root contained in all the
+ /// default repositories.
+ /// </para>
+ /// <para>
+ /// Some appenders need to be closed before the application exists.
+ /// Otherwise, pending logging events might be lost.
+ /// </para>
+ /// <para>
+ /// The <c>shutdown</c> method is careful to close nested
+ /// appenders before closing regular appenders. This is allows
+ /// configurations where a regular appender is attached to a logger
+ /// and again to a nested appender.
+ /// </para>
+ /// </remarks>
+ public static void Shutdown()
+ {
+ foreach(ILoggerRepository repository in GetAllRepositories())
+ {
+ repository.Shutdown();
+ }
+ }
- /// <summary>
- /// Shuts down the repository for the repository specified.
- /// </summary>
- /// <param name="repository">The repository to shutdown.</param>
- /// <remarks>
- /// <para>
- /// Calling this method will <b>safely</b> close and remove all
- /// appenders in all the loggers including root contained in the
- /// repository for the <paramref name="repository"/> specified.
- /// </para>
- /// <para>
- /// Some appenders need to be closed before the application exists.
- /// Otherwise, pending logging events might be lost.
- /// </para>
- /// <para>
- /// The <c>shutdown</c> method is careful to close nested
- /// appenders before closing regular appenders. This is allows
- /// configurations where a regular appender is attached to a logger
- /// and again to a nested appender.
- /// </para>
- /// </remarks>
- public static void ShutdownRepository(string repository)
- {
- if (repository == null)
- {
- throw new ArgumentNullException("repository");
- }
- RepositorySelector.GetRepository(repository).Shutdown();
- }
+ /// <summary>
+ /// Shuts down the repository for the repository specified.
+ /// </summary>
+ /// <param name="repository">The repository to shutdown.</param>
+ /// <remarks>
+ /// <para>
+ /// Calling this method will <b>safely</b> close and remove all
+ /// appenders in all the loggers including root contained in the
+ /// repository for the <paramref name="repository"/> specified.
+ /// </para>
+ /// <para>
+ /// Some appenders need to be closed before the application exists.
+ /// Otherwise, pending logging events might be lost.
+ /// </para>
+ /// <para>
+ /// The <c>shutdown</c> method is careful to close nested
+ /// appenders before closing regular appenders. This is allows
+ /// configurations where a regular appender is attached to a logger
+ /// and again to a nested appender.
+ /// </para>
+ /// </remarks>
+ public static void ShutdownRepository(string repository)
+ {
+ if (repository == null)
+ {
+ throw new ArgumentNullException("repository");
+ }
+ RepositorySelector.GetRepository(repository).Shutdown();
+ }
- /// <summary>
- /// Shuts down the repository for the repository specified.
- /// </summary>
- /// <param name="repositoryAssembly">The assembly to use to lookup the repository.</param>
- /// <remarks>
- /// <para>
- /// Calling this method will <b>safely</b> close and remove all
- /// appenders in all the loggers including root contained in the
- /// repository for the repository. The repository is looked up using
- /// the <paramref name="repositoryAssembly"/> specified.
- /// </para>
- /// <para>
- /// Some appenders need to be closed before the application exists.
- /// Otherwise, pending logging events might be lost.
- /// </para>
- /// <para>
- /// The <c>shutdown</c> method is careful to close nested
- /// appenders before closing regular appenders. This is allows
- /// configurations where a regular appender is attached to a logger
- /// and again to a nested appender.
- /// </para>
- /// </remarks>
- public static void ShutdownRepository(Assembly repositoryAssembly)
- {
- if (repositoryAssembly == null)
- {
- throw new ArgumentNullException("repositoryAssembly");
- }
- RepositorySelector.GetRepository(repositoryAssembly).Shutdown();
- }
+ /// <summary>
+ /// Shuts down the repository for the repository specified.
+ /// </summary>
+ /// <param name="repositoryAssembly">The assembly to use to lookup the repository.</param>
+ /// <remarks>
+ /// <para>
+ /// Calling this method will <b>safely</b> close and remove all
+ /// appenders in all the loggers including root contained in the
+ /// repository for the repository. The repository is looked up using
+ /// the <paramref name="repositoryAssembly"/> specified.
+ /// </para>
+ /// <para>
+ /// Some appenders need to be closed before the application exists.
+ /// Otherwise, pending logging events might be lost.
+ /// </para>
+ /// <para>
+ /// The <c>shutdown</c> method is careful to close nested
+ /// appenders before closing regular appenders. This is allows
+ /// configurations where a regular appender is attached to a logger
+ /// and again to a nested appender.
+ /// </para>
+ /// </remarks>
+ public static void ShutdownRepository(Assembly repositoryAssembly)
+ {
+ if (repositoryAssembly == null)
+ {
+ throw new ArgumentNullException("repositoryAssembly");
+ }
+ RepositorySelector.GetRepository(repositoryAssembly).Shutdown();
+ }
- /// <summary>
- /// Resets all values contained in this repository instance to their defaults.
- /// </summary>
- /// <param name="repository">The repository to reset.</param>
- /// <remarks>
- /// <para>
- /// Resets all values contained in the repository instance to their
- /// defaults. This removes all appenders from all loggers, sets
- /// the level of all non-root loggers to <c>null</c>,
- /// sets their additivity flag to <c>true</c> and sets the level
- /// of the root logger to <see cref="Level.Debug"/>. Moreover,
- /// message disabling is set its default "off" value.
- /// </para>
- /// </remarks>
- public static void ResetConfiguration(string repository)
- {
- if (repository == null)
- {
- throw new ArgumentNullException("repository");
- }
- RepositorySelector.GetRepository(repository).ResetConfiguration();
- }
+ /// <summary>
+ /// Resets all values contained in this repository instance to their defaults.
+ /// </summary>
+ /// <param name="repository">The repository to reset.</param>
+ /// <remarks>
+ /// <para>
+ /// Resets all values contained in the repository instance to their
+ /// defaults. This removes all appenders from all loggers, sets
+ /// the level of all non-root loggers to <c>null</c>,
+ /// sets their additivity flag to <c>true</c> and sets the level
+ /// of the root logger to <see cref="Level.Debug"/>. Moreover,
+ /// message disabling is set its default "off" value.
+ /// </para>
+ /// </remarks>
+ public static void ResetConfiguration(string repository)
+ {
+ if (repository == null)
+ {
+ throw new ArgumentNullException("repository");
+ }
+ RepositorySelector.GetRepository(repository).ResetConfiguration();
+ }
- /// <summary>
- /// Resets all values contained in this repository instance to their defaults.
- /// </summary>
- /// <param name="repositoryAssembly">The assembly to use to lookup the repository to reset.</param>
- /// <remarks>
- /// <para>
- /// Resets all values contained in the repository instance to their
- /// defaults. This removes all appenders from all loggers, sets
- /// the level of all non-root loggers to <c>null</c>,
- /// sets their additivity flag to <c>true</c> and sets the level
- /// of the root logger to <see cref="Level.Debug"/>. Moreover,
- /// message disabling is set its default "off" value.
- /// </para>
- /// </remarks>
- public static void ResetConfiguration(Assembly repositoryAssembly)
- {
- if (repositoryAssembly == null)
- {
- throw new ArgumentNullException("repositoryAssembly");
- }
- RepositorySelector.GetRepository(repositoryAssembly).ResetConfiguration();
- }
+ /// <summary>
+ /// Resets all values contained in this repository instance to their defaults.
+ /// </summary>
+ /// <param name="repositoryAssembly">The assembly to use to lookup the repository to reset.</param>
+ /// <remarks>
+ /// <para>
+ /// Resets all values contained in the repository instance to their
+ /// defaults. This removes all appenders from all loggers, sets
+ /// the level of all non-root loggers to <c>null</c>,
+ /// sets their additivity flag to <c>true</c> and sets the level
+ /// of the root logger to <see cref="Level.Debug"/>. Moreover,
+ /// message disabling is set its default "off" value.
+ /// </para>
+ /// </remarks>
+ public static void ResetConfiguration(Assembly repositoryAssembly)
+ {
+ if (repositoryAssembly == null)
+ {
+ throw new ArgumentNullException("repositoryAssembly");
+ }
+ RepositorySelector.GetRepository(repositoryAssembly).ResetConfiguration();
+ }
- /// <summary>
- /// Creates a repository with the specified name.
- /// </summary>
- /// <param name="repository">The name of the repository, this must be unique amongst repositories.</param>
- /// <returns>The <see cref="ILoggerRepository"/> created for the repository.</returns>
- /// <remarks>
- /// <para>
- /// <b>CreateDomain is obsolete. Use CreateRepository instead of CreateDomain.</b>
- /// </para>
- /// <para>
- /// Creates the default type of <see cref="ILoggerRepository"/> which is a
- /// <see cref="log4net.Repository.Hierarchy.Hierarchy"/> object.
- /// </para>
- /// <para>
- /// The <paramref name="repository"/> name must be unique. Repositories cannot be redefined.
- /// An <see cref="Exception"/> will be thrown if the repository already exists.
- /// </para>
- /// </remarks>
- /// <exception cref="LogException">The specified repository already exists.</exception>
- [Obsolete("Use CreateRepository instead of CreateDomain")]
- public static ILoggerRepository CreateDomain(string repository)
- {
- return CreateRepository(repository);
- }
+ /// <summary>
+ /// Creates a repository with the specified name.
+ /// </summary>
+ /// <param name="repository">The name of the repository, this must be unique amongst repositories.</param>
+ /// <returns>The <see cref="ILoggerRepository"/> created for the repository.</returns>
+ /// <remarks>
+ /// <para>
+ /// <b>CreateDomain is obsolete. Use CreateRepository instead of CreateDomain.</b>
+ /// </para>
+ /// <para>
+ /// Creates the default type of <see cref="ILoggerRepository"/> which is a
+ /// <see cref="log4net.Repository.Hierarchy.Hierarchy"/> object.
+ /// </para>
+ /// <para>
+ /// The <paramref name="repository"/> name must be unique. Repositories cannot be redefined.
+ /// An <see cref="Exception"/> will be thrown if the repository already exists.
+ /// </para>
+ /// </remarks>
+ /// <exception cref="LogException">The specified repository already exists.</exception>
+ [Obsolete("Use CreateRepository instead of CreateDomain")]
+ public static ILoggerRepository CreateDomain(string repository)
+ {
+ return CreateRepository(repository);
+ }
- /// <summary>
- /// Creates a repository with the specified name.
- /// </summary>
- /// <param name="repository">The name of the repository, this must be unique amongst repositories.</param>
- /// <returns>The <see cref="ILoggerRepository"/> created for the repository.</returns>
- /// <remarks>
- /// <para>
- /// Creates the default type of <see cref="ILoggerRepository"/> which is a
- /// <see cref="log4net.Repository.Hierarchy.Hierarchy"/> object.
- /// </para>
- /// <para>
- /// The <paramref name="repository"/> name must be unique. Repositories cannot be redefined.
- /// An <see cref="Exception"/> will be thrown if the repository already exists.
- /// </para>
- /// </remarks>
- /// <exception cref="LogException">The specified repository already exists.</exception>
- public static ILoggerRepository CreateRepository(string repository)
- {
- if (repository == null)
- {
- throw new ArgumentNullException("repository");
- }
- return RepositorySelector.CreateRepository(repository, null);
- }
+ /// <summary>
+ /// Creates a repository with the specified name.
+ /// </summary>
+ /// <param name="repository">The name of the repository, this must be unique amongst repositories.</param>
+ /// <returns>The <see cref="ILoggerRepository"/> created for the repository.</returns>
+ /// <remarks>
+ /// <para>
+ /// Creates the default type of <see cref="ILoggerRepository"/> which is a
+ /// <see cref="log4net.Repository.Hierarchy.Hierarchy"/> object.
+ /// </para>
+ /// <para>
+ /// The <paramref name="repository"/> name must be unique. Repositories cannot be redefined.
+ /// An <see cref="Exception"/> will be thrown if the repository already exists.
+ /// </para>
+ /// </remarks>
+ /// <exception cref="LogException">The specified repository already exists.</exception>
+ public static ILoggerRepository CreateRepository(string repository)
+ {
+ if (repository == null)
+ {
+ throw new ArgumentNullException("repository");
+ }
+ return RepositorySelector.CreateRepository(repository, null);
+ }
- /// <summary>
- /// Creates a repository with the specified name and repository type.
- /// </summary>
- /// <param name="repository">The name of the repository, this must be unique to the repository.</param>
- /// <param name="repositoryType">A <see cref="Type"/> that implements <see cref="ILoggerRepository"/>
- /// and has a no arg constructor. An instance of this type will be created to act
- /// as the <see cref="ILoggerRepository"/> for the repository specified.</param>
- /// <returns>The <see cref="ILoggerRepository"/> created for the repository.</returns>
- /// <remarks>
- /// <para>
- /// <b>CreateDomain is obsolete. Use CreateRepository instead of CreateDomain.</b>
- /// </para>
- /// <para>
- /// The <paramref name="repository"/> name must be unique. Repositories cannot be redefined.
- /// An Exception will be thrown if the repository already exists.
- /// </para>
- /// </remarks>
- /// <exception cref="LogException">The specified repository already exists.</exception>
- [Obsolete("Use CreateRepository instead of CreateDomain")]
- public static ILoggerRepository CreateDomain(string repository, Type repositoryType)
- {
- return CreateRepository(repository, repositoryType);
- }
+ /// <summary>
+ /// Creates a repository with the specified name and repository type.
+ /// </summary>
+ /// <param name="repository">The name of the repository, this must be unique to the repository.</param>
+ /// <param name="repositoryType">A <see cref="Type"/> that implements <see cref="ILoggerRepository"/>
+ /// and has a no arg constructor. An instance of this type will be created to act
+ /// as the <see cref="ILoggerRepository"/> for the repository specified.</param>
+ /// <returns>The <see cref="ILoggerRepository"/> created for the repository.</returns>
+ /// <remarks>
+ /// <para>
+ /// <b>CreateDomain is obsolete. Use CreateRepository instead of CreateDomain.</b>
+ /// </para>
+ /// <para>
+ /// The <paramref name="repository"/> name must be unique. Repositories cannot be redefined.
+ /// An Exception will be thrown if the repository already exists.
+ /// </para>
+ /// </remarks>
+ /// <exception cref="LogException">The specified repository already exists.</exception>
+ [Obsolete("Use CreateRepository instead of CreateDomain")]
+ public static ILoggerRepository CreateDomain(string repository, Type repositoryType)
+ {
+ return CreateRepository(repository, repositoryType);
+ }
- /// <summary>
- /// Creates a repository with the specified name and repository type.
- /// </summary>
- /// <param name="repository">The name of the repository, this must be unique to the repository.</param>
- /// <param name="repositoryType">A <see cref="Type"/> that implements <see cref="ILoggerRepository"/>
- /// and has a no arg constructor. An instance of this type will be created to act
- /// as the <see cref="ILoggerRepository"/> for the repository specified.</param>
- /// <returns>The <see cref="ILoggerRepository"/> created for the repository.</returns>
- /// <remarks>
- /// <para>
- /// The <paramref name="repository"/> name must be unique. Repositories cannot be redefined.
- /// An Exception will be thrown if the repository already exists.
- /// </para>
- /// </remarks>
- /// <exception cref="LogException">The specified repository already exists.</exception>
- public static ILoggerRepository CreateRepository(string repository, Type repositoryType)
- {
- if (repository == null)
- {
- throw new ArgumentNullException("repository");
- }
- if (repositoryType == null)
- {
- throw new ArgumentNullException("repositoryType");
- }
- return RepositorySelector.CreateRepository(repository, repositoryType);
- }
+ /// <summary>
+ /// Creates a repository with the specified name and repository type.
+ /// </summary>
+ /// <param name="repository">The name of the repository, this must be unique to the repository.</param>
+ /// <param name="repositoryType">A <see cref="Type"/> that implements <see cref="ILoggerRepository"/>
+ /// and has a no arg constructor. An instance of this type will be created to act
+ /// as the <see cref="ILoggerRepository"/> for the repository specified.</param>
+ /// <returns>The <see cref="ILoggerRepository"/> created for the repository.</returns>
+ /// <remarks>
+ /// <para>
+ /// The <paramref name="repository"/> name must be unique. Repositories cannot be redefined.
+ /// An Exception will be thrown if the repository already exists.
+ /// </para>
+ /// </remarks>
+ /// <exception cref="LogException">The specified repository already exists.</exception>
+ public static ILoggerRepository CreateRepository(string repository, Type repositoryType)
+ {
+ if (repository == null)
+ {
+ throw new ArgumentNullException("repository");
+ }
+ if (repositoryType == null)
+ {
+ throw new ArgumentNullException("repositoryType");
+ }
+ return RepositorySelector.CreateRepository(repository, repositoryType);
+ }
- /// <summary>
- /// Creates a repository for the specified assembly and repository type.
- /// </summary>
- /// <param name="repositoryAssembly">The assembly to use to get the name of the repository.</param>
- /// <param name="repositoryType">A <see cref="Type"/> that implements <see cref="ILoggerRepository"/>
- /// and has a no arg constructor. An instance of this type will be created to act
- /// as the <see cref="ILoggerRepository"/> for the repository specified.</param>
- /// <returns>The <see cref="ILoggerRepository"/> created for the repository.</returns>
- /// <remarks>
- /// <para>
- /// <b>CreateDomain is obsolete. Use CreateRepository instead of CreateDomain.</b>
- /// </para>
- /// <para>
- /// The <see cref="ILoggerRepository"/> created will be associated with the repository
- /// specified such that a call to <see cref="M:GetRepository(Assembly)"/> with the
- /// same assembly specified will return the same repository instance.
- /// </para>
- /// </remarks>
- [Obsolete("Use CreateRepository instead of CreateDomain")]
- public static ILoggerRepository CreateDomain(Assembly repositoryAssembly, Type repositoryType)
- {
- return CreateRepository(repositoryAssembly, repositoryType);
- }
+ /// <summary>
+ /// Creates a repository for the specified assembly and repository type.
+ /// </summary>
+ /// <param name="repositoryAssembly">The assembly to use to get the name of the repository.</param>
+ /// <param name="repositoryType">A <see cref="Type"/> that implements <see cref="ILoggerRepository"/>
+ /// and has a no arg constructor. An instance of this type will be created to act
+ /// as the <see cref="ILoggerRepository"/> for the repository specified.</param>
+ /// <returns>The <see cref="ILoggerRepository"/> created for the repository.</returns>
+ /// <remarks>
+ /// <para>
+ /// <b>CreateDomain is obsolete. Use CreateRepository instead of CreateDomain.</b>
+ /// </para>
+ /// <para>
+ /// The <see cref="ILoggerRepository"/> created will be associated with the repository
+ /// specified such that a call to <see cref="M:GetRepository(Assembly)"/> with the
+ /// same assembly specified will return the same repository instance.
+ /// </para>
+ /// </remarks>
+ [Obsolete("Use CreateRepository instead of CreateDomain")]
+ public static ILoggerRepository CreateDomain(Assembly repositoryAssembly, Type repositoryType)
+ {
+ return CreateRepository(repositoryAssembly, repositoryType);
+ }
- /// <summary>
- /// Creates a repository for the specified assembly and repository type.
- /// </summary>
- /// <param name="repositoryAssembly">The assembly to use to get the name of the repository.</param>
- /// <param name="repositoryType">A <see cref="Type"/> that implements <see cref="ILoggerRepository"/>
- /// and has a no arg constructor. An instance of this type will be created to act
- /// as the <see cref="ILoggerRepository"/> for the repository specified.</param>
- /// <returns>The <see cref="ILoggerRepository"/> created for the repository.</returns>
- /// <remarks>
- /// <para>
- /// The <see cref="ILoggerRepository"/> created will be associated with the repository
- /// specified such that a call to <see cref="M:GetRepository(Assembly)"/> with the
- /// same assembly specified will return the same repository instance.
- /// </para>
- /// </remarks>
- public static ILoggerRepository CreateRepository(Assembly repositoryAssembly, Type repositoryType)
- {
- if (repositoryAssembly == null)
- {
- throw new ArgumentNullException("repositoryAssembly");
- }
- if (repositoryType == null)
- {
- throw new ArgumentNullException("repositoryType");
- }
- return RepositorySelector.CreateRepository(repositoryAssembly, repositoryType);
- }
+ /// <summary>
+ /// Creates a repository for the specified assembly and repository type.
+ /// </summary>
+ /// <param name="repositoryAssembly">The assembly to use to get the name of the repository.</param>
+ /// <param name="repositoryType">A <see cref="Type"/> that implements <see cref="ILoggerRepository"/>
+ /// and has a no arg constructor. An instance of this type will be created to act
+ /// as the <see cref="ILoggerRepository"/> for the repository specified.</param>
+ /// <returns>The <see cref="ILoggerRepository"/> created for the repository.</returns>
+ /// <remarks>
+ /// <para>
+ /// The <see cref="ILoggerRepository"/> created will be associated with the repository
+ /// specified such that a call to <see cref="M:GetRepository(Assembly)"/> with the
+ /// same assembly specified will return the same repository instance.
+ /// </para>
+ /// </remarks>
+ public static ILoggerRepository CreateRepository(Assembly repositoryAssembly, Type repositoryType)
+ {
+ if (repositoryAssembly == null)
+ {
+ throw new ArgumentNullException("repositoryAssembly");
+ }
+ if (repositoryType == null)
+ {
+ throw new ArgumentNullException("repositoryType");
+ }
+ return RepositorySelector.CreateRepository(repositoryAssembly, repositoryType);
+ }
- /// <summary>
- /// Gets an array of all currently defined repositories.
- /// </summary>
- /// <returns>An array of all the known <see cref="ILoggerRepository"/> objects.</returns>
- /// <remarks>
- /// <para>
- /// Gets an array of all currently defined repositories.
- /// </para>
- /// </remarks>
- public static ILoggerRepository[] GetAllRepositories()
- {
- return RepositorySelector.GetAllRepositories();
- }
+ /// <summary>
+ /// Gets an array of all currently defined repositories.
+ /// </summary>
+ /// <returns>An array of all the known <see cref="ILoggerRepository"/> objects.</returns>
+ /// <remarks>
+ /// <para>
+ /// Gets an array of all currently defined repositories.
+ /// </para>
+ /// </remarks>
+ public static ILoggerRepository[] GetAllRepositories()
+ {
+ return RepositorySelector.GetAllRepositories();
+ }
- /// <summary>
- /// Gets or sets the repository selector used by the <see cref="LogManager" />.
- /// </summary>
- /// <value>
- /// The repository selector used by the <see cref="LogManager" />.
- /// </value>
- /// <remarks>
- /// <para>
- /// The repository selector (<see cref="IRepositorySelector"/>) is used by
- /// the <see cref="LogManager"/> to create and select repositories
- /// (<see cref="ILoggerRepository"/>).
- /// </para>
- /// <para>
- /// The caller to <see cref="LogManager"/> supplies either a string name
- /// or an assembly (if not supplied the assembly is inferred using
- /// <see cref="M:Assembly.GetCallingAssembly()"/>).
- /// </para>
- /// <para>
- /// This context is used by the selector to lookup a specific repository.
- /// </para>
- /// <para>
- /// For the full .NET Framework, the default repository is <c>DefaultRepositorySelector</c>;
- /// for the .NET Compact Framework <c>CompactRepositorySelector</c> is the default
- /// repository.
- /// </para>
- /// </remarks>
- public static IRepositorySelector RepositorySelector
- {
- get { return s_repositorySelector; }
- set { s_repositorySelector = value; }
- }
+ /// <summary>
+ /// Gets or sets the repository selector used by the <see cref="LogManager" />.
+ /// </summary>
+ /// <value>
+ /// The repository selector used by the <see cref="LogManager" />.
+ /// </value>
+ /// <remarks>
+ /// <para>
+ /// The repository selector (<see cref="IRepositorySelector"/>) is used by
+ /// the <see cref="LogManager"/> to create and select repositories
+ /// (<see cref="ILoggerRepository"/>).
+ /// </para>
+ /// <para>
+ /// The caller to <see cref="LogManager"/> supplies either a string name
+ /// or an assembly (if not supplied the assembly is inferred using
+ /// <see cref="M:Assembly.GetCallingAssembly()"/>).
+ /// </para>
+ /// <para>
+ /// This context is used by the selector to lookup a specific repository.
+ /// </para>
+ /// <para>
+ /// For the full .NET Framework, the default repository is <c>DefaultRepositorySelector</c>;
+ /// for the .NET Compact Framework <c>CompactRepositorySelector</c> is the default
+ /// repository.
+ /// </para>
+ /// </remarks>
+ public static IRepositorySelector RepositorySelector
+ {
+ get { return s_repositorySelector; }
+ set { s_repositorySelector = value; }
+ }
- #endregion Public Static Methods
+ #endregion Public Static Methods
- #region Private Static Methods
+ #region Private Static Methods
- /// <summary>
- /// Internal method to get pertinent version info.
- /// </summary>
- /// <returns>A string of version info.</returns>
- private static string GetVersionInfo()
- {
- System.Text.StringBuilder sb = new System.Text.StringBuilder();
+ /// <summary>
+ /// Internal method to get pertinent version info.
+ /// </summary>
+ /// <returns>A string of version info.</returns>
+ private static string GetVersionInfo()
+ {
+ System.Text.StringBuilder sb = new System.Text.StringBuilder();
#if NETSTANDARD1_3
- Assembly myAssembly = typeof(LoggerManager).GetTypeInfo().Assembly;
- sb.Append($"log4net assembly [{myAssembly.FullName}]. ");
- //sb.Append($"Loaded from [{myAssembly.Location}]. "); // TODO Assembly.Location available in netstandard1.5
- sb.Append($"(.NET Framework [{RuntimeInformation.FrameworkDescription}] on {RuntimeInformation.OSDescription}");
+ Assembly myAssembly = typeof(LoggerManager).GetTypeInfo().Assembly;
+ sb.Append($"log4net assembly [{myAssembly.FullName}]. ");
+ //sb.Append($"Loaded from [{myAssembly.Location}]. "); // TODO Assembly.Location available in netstandard1.5
+ sb.Append($"(.NET Framework [{RuntimeInformation.FrameworkDescription}] on {RuntimeInformation.OSDescription}");
#else
- Assembly myAssembly = Assembly.GetExecutingAssembly();
- sb.Append("log4net assembly [").Append(myAssembly.FullName).Append("]. ");
- sb.Append("Loaded from [").Append(SystemInfo.AssemblyLocationInfo(myAssembly)).Append("]. ");
- sb.Append("(.NET Runtime [").Append(Environment.Version.ToString()).Append("]");
+ Assembly myAssembly = Assembly.GetExecutingAssembly();
+ sb.Append("log4net assembly [").Append(myAssembly.FullName).Append("]. ");
+ sb.Append("Loaded from [").Append(SystemInfo.AssemblyLocationInfo(myAssembly)).Append("]. ");
+ sb.Append("(.NET Runtime [").Append(Environment.Version.ToString()).Append("]");
#if (!SSCLI)
sb.Append(" on ").Append(Environment.OSVersion.ToString());
#endif
#endif // NETSTANDARD1_3
- sb.Append(")");
- return sb.ToString();
- }
+ sb.Append(")");
+ return sb.ToString();
+ }
#if (!NETCF)
- /// <summary>
- /// Called when the <see cref="AppDomain.DomainUnload"/> event fires
- /// </summary>
- /// <param name="sender">the <see cref="AppDomain"/> that is exiting</param>
- /// <param name="e">null</param>
- /// <remarks>
- /// <para>
- /// Called when the <see cref="AppDomain.DomainUnload"/> event fires.
- /// </para>
- /// <para>
- /// When the event is triggered the log4net system is <see cref="M:Shutdown()"/>.
- /// </para>
- /// </remarks>
- private static void OnDomainUnload(object sender, EventArgs e)
- {
- Shutdown();
- }
+ /// <summary>
+ /// Called when the <see cref="AppDomain.DomainUnload"/> event fires
+ /// </summary>
+ /// <param name="sender">the <see cref="AppDomain"/> that is exiting</param>
+ /// <param name="e">null</param>
+ /// <remarks>
+ /// <para>
+ /// Called when the <see cref="AppDomain.DomainUnload"/> event fires.
+ /// </para>
+ /// <para>
+ /// When the event is triggered the log4net system is <see cref="M:Shutdown()"/>.
+ /// </para>
+ /// </remarks>
+ private static void OnDomainUnload(object sender, EventArgs e)
+ {
+ Shutdown();
+ }
- /// <summary>
- /// Called when the <see cref="AppDomain.ProcessExit"/> event fires
- /// </summary>
- /// <param name="sender">the <see cref="AppDomain"/> that is exiting</param>
- /// <param name="e">null</param>
- /// <remarks>
- /// <para>
- /// Called when the <see cref="AppDomain.ProcessExit"/> event fires.
- /// </para>
- /// <para>
- /// When the event is triggered the log4net system is <see cref="M:Shutdown()"/>.
- /// </para>
- /// </remarks>
- private static void OnProcessExit(object sender, EventArgs e)
- {
- Shutdown();
- }
+ /// <summary>
+ /// Called when the <see cref="AppDomain.ProcessExit"/> event fires
+ /// </summary>
+ /// <param name="sender">the <see cref="AppDomain"/> that is exiting</param>
+ /// <param name="e">null</param>
+ /// <remarks>
+ /// <para>
+ /// Called when the <see cref="AppDomain.ProcessExit"/> event fires.
+ /// </para>
+ /// <para>
+ /// When the event is triggered the log4net system is <see cref="M:Shutdown()"/>.
+ /// </para>
+ /// </remarks>
+ private static void OnProcessExit(object sender, EventArgs e)
+ {
+ Shutdown();
+ }
#endif
- #endregion Private Static Methods
+ #endregion Private Static Methods
- #region Private Static Fields
+ #region Private Static Fields
- /// <summary>
- /// The fully qualified type of the LoggerManager class.
- /// </summary>
- /// <remarks>
- /// Used by the internal logger to record the Type of the
- /// log message.
- /// </remarks>
- private static readonly Type declaringType = typeof(LoggerManager);
+ /// <summary>
+ /// The fully qualified type of the LoggerManager class.
+ /// </summary>
+ /// <remarks>
+ /// Used by the internal logger to record the Type of the
+ /// log message.
+ /// </remarks>
+ private static readonly Type declaringType = typeof(LoggerManager);
- /// <summary>
- /// Initialize the default repository selector
- /// </summary>
- private static IRepositorySelector s_repositorySelector;
+ /// <summary>
+ /// Initialize the default repository selector
+ /// </summary>
+ private static IRepositorySelector s_repositorySelector;
- #endregion Private Static Fields
- }
+ #endregion Private Static Fields
+ }
}
diff --git a/src/log4net/Core/LoggerWrapperImpl.cs b/src/log4net/Core/LoggerWrapperImpl.cs
index 26f016d..fbc49a4 100644
--- a/src/log4net/Core/LoggerWrapperImpl.cs
+++ b/src/log4net/Core/LoggerWrapperImpl.cs
@@ -19,68 +19,68 @@
namespace log4net.Core
{
- /// <summary>
- /// Implementation of the <see cref="ILoggerWrapper"/> interface.
- /// </summary>
- /// <remarks>
- /// <para>
- /// This class should be used as the base for all wrapper implementations.
- /// </para>
- /// </remarks>
- /// <author>Nicko Cadell</author>
- /// <author>Gert Driesen</author>
- public abstract class LoggerWrapperImpl : ILoggerWrapper
- {
- #region Protected Instance Constructors
+ /// <summary>
+ /// Implementation of the <see cref="ILoggerWrapper"/> interface.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// This class should be used as the base for all wrapper implementations.
+ /// </para>
+ /// </remarks>
+ /// <author>Nicko Cadell</author>
+ /// <author>Gert Driesen</author>
+ public abstract class LoggerWrapperImpl : ILoggerWrapper
+ {
+ #region Protected Instance Constructors
- /// <summary>
- /// Constructs a new wrapper for the specified logger.
- /// </summary>
- /// <param name="logger">The logger to wrap.</param>
- /// <remarks>
- /// <para>
- /// Constructs a new wrapper for the specified logger.
- /// </para>
- /// </remarks>
- protected LoggerWrapperImpl(ILogger logger)
- {
- m_logger = logger;
- }
+ /// <summary>
+ /// Constructs a new wrapper for the specified logger.
+ /// </summary>
+ /// <param name="logger">The logger to wrap.</param>
+ /// <remarks>
+ /// <para>
+ /// Constructs a new wrapper for the specified logger.
+ /// </para>
+ /// </remarks>
+ protected LoggerWrapperImpl(ILogger logger)
+ {
+ m_logger = logger;
+ }
- #endregion Public Instance Constructors
+ #endregion Public Instance Constructors
- #region Implementation of ILoggerWrapper
+ #region Implementation of ILoggerWrapper
- /// <summary>
- /// Gets the implementation behind this wrapper object.
- /// </summary>
- /// <value>
- /// The <see cref="ILogger"/> object that this object is implementing.
- /// </value>
- /// <remarks>
- /// <para>
- /// The <c>Logger</c> object may not be the same object as this object
- /// because of logger decorators.
- /// </para>
- /// <para>
- /// This gets the actual underlying objects that is used to process
- /// the log events.
- /// </para>
- /// </remarks>
- public virtual ILogger Logger
- {
- get { return m_logger; }
- }
+ /// <summary>
+ /// Gets the implementation behind this wrapper object.
+ /// </summary>
+ /// <value>
+ /// The <see cref="ILogger"/> object that this object is implementing.
+ /// </value>
+ /// <remarks>
+ /// <para>
+ /// The <c>Logger</c> object may not be the same object as this object
+ /// because of logger decorators.
+ /// </para>
+ /// <para>
+ /// This gets the actual underlying objects that is used to process
+ /// the log events.
+ /// </para>
+ /// </remarks>
+ public virtual ILogger Logger
+ {
+ get { return m_logger; }
+ }
- #endregion
+ #endregion
- #region Private Instance Fields
+ #region Private Instance Fields
- /// <summary>
- /// The logger that this object is wrapping
- /// </summary>
- private readonly ILogger m_logger;
+ /// <summary>
+ /// The logger that this object is wrapping
+ /// </summary>
+ private readonly ILogger m_logger;
- #endregion Private Instance Fields
- }
+ #endregion Private Instance Fields
+ }
}
diff --git a/src/log4net/Core/LoggingEvent.cs b/src/log4net/Core/LoggingEvent.cs
index d6b2fb3..4d73ddb 100644
--- a/src/log4net/Core/LoggingEvent.cs
+++ b/src/log4net/Core/LoggingEvent.cs
@@ -732,8 +732,8 @@
if (m_data.ThreadName == null && this.m_cacheUpdatable)
{
#if NETCF
- // Get thread ID only
- m_data.ThreadName =
+ // Get thread ID only
+ m_data.ThreadName =
SystemInfo.CurrentThreadId.ToString(System.Globalization.NumberFormatInfo.InvariantInfo);
#else
// '.NET ThreadPool Worker' appears as a default thread name in the .NET 6-7 thread pool.
@@ -807,12 +807,12 @@
/// <description>Results</description>
/// </listheader>
/// <item>
- /// <term><c>WindowsIdentity.GetCurrent()</c></term>
- /// <description>10000 loops, 00:00:00.2031250 seconds</description>
+ /// <term><c>WindowsIdentity.GetCurrent()</c></term>
+ /// <description>10000 loops, 00:00:00.2031250 seconds</description>
/// </item>
/// <item>
- /// <term><c>WindowsIdentity.GetCurrent().Name</c></term>
- /// <description>10000 loops, 00:00:08.0468750 seconds</description>
+ /// <term><c>WindowsIdentity.GetCurrent().Name</c></term>
+ /// <description>10000 loops, 00:00:08.0468750 seconds</description>
/// </item>
/// </list>
/// <para>
@@ -827,8 +827,8 @@
private string TryGetCurrentUserName()
{
#if (NETCF || SSCLI || NETSTANDARD1_3)
- // On compact framework there's no notion of current Windows user
- return SystemInfo.NotAvailableText;
+ // On compact framework there's no notion of current Windows user
+ return SystemInfo.NotAvailableText;
#else
if (_platformDoesNotSupportWindowsIdentity)
{
@@ -898,8 +898,8 @@
if (m_data.Identity == null && this.m_cacheUpdatable)
{
#if (NETCF || SSCLI || NETSTANDARD1_3)
- // On compact framework there's no notion of current thread principals
- m_data.Identity = SystemInfo.NotAvailableText;
+ // On compact framework there's no notion of current thread principals
+ m_data.Identity = SystemInfo.NotAvailableText;
#else
try
{
@@ -1447,27 +1447,27 @@
/// This event has composite properties that combine together properties from
/// several different contexts in the following order:
/// <list type="definition">
- /// <item>
- /// <term>this events properties</term>
- /// <description>
- /// This event has <see cref="Properties"/> that can be set. These
- /// properties are specific to this event only.
- /// </description>
- /// </item>
- /// <item>
- /// <term>the thread properties</term>
- /// <description>
- /// The <see cref="ThreadContext.Properties"/> that are set on the current
- /// thread. These properties are shared by all events logged on this thread.
- /// </description>
- /// </item>
- /// <item>
- /// <term>the global properties</term>
- /// <description>
- /// The <see cref="GlobalContext.Properties"/> that are set globally. These
- /// properties are shared by all the threads in the AppDomain.
- /// </description>
- /// </item>
+ /// <item>
+ /// <term>this events properties</term>
+ /// <description>
+ /// This event has <see cref="Properties"/> that can be set. These
+ /// properties are specific to this event only.
+ /// </description>
+ /// </item>
+ /// <item>
+ /// <term>the thread properties</term>
+ /// <description>
+ /// The <see cref="ThreadContext.Properties"/> that are set on the current
+ /// thread. These properties are shared by all events logged on this thread.
+ /// </description>
+ /// </item>
+ /// <item>
+ /// <term>the global properties</term>
+ /// <description>
+ /// The <see cref="GlobalContext.Properties"/> that are set globally. These
+ /// properties are shared by all the threads in the AppDomain.
+ /// </description>
+ /// </item>
/// </list>
/// </para>
/// </remarks>
diff --git a/src/log4net/Core/MethodItem.cs b/src/log4net/Core/MethodItem.cs
index 6d3ca19..f76ccdb 100644
--- a/src/log4net/Core/MethodItem.cs
+++ b/src/log4net/Core/MethodItem.cs
@@ -23,148 +23,148 @@
namespace log4net.Core
{
- /// <summary>
- /// provides method information without actually referencing a System.Reflection.MethodBase
- /// as that would require that the containing assembly is loaded.
- /// </summary>
- ///
+ /// <summary>
+ /// provides method information without actually referencing a System.Reflection.MethodBase
+ /// as that would require that the containing assembly is loaded.
+ /// </summary>
+ ///
#if !NETCF
- [Serializable]
+ [Serializable]
#endif
- public class MethodItem
- {
- #region Public Instance Constructors
+ public class MethodItem
+ {
+ #region Public Instance Constructors
- /// <summary>
- /// constructs a method item for an unknown method.
- /// </summary>
- public MethodItem()
- {
- m_name = NA;
- m_parameters = new string[0];
- }
+ /// <summary>
+ /// constructs a method item for an unknown method.
+ /// </summary>
+ public MethodItem()
+ {
+ m_name = NA;
+ m_parameters = new string[0];
+ }
- /// <summary>
- /// constructs a method item from the name of the method.
- /// </summary>
- /// <param name="name"></param>
- public MethodItem(string name)
- : this()
- {
- m_name = name;
- }
+ /// <summary>
+ /// constructs a method item from the name of the method.
+ /// </summary>
+ /// <param name="name"></param>
+ public MethodItem(string name)
+ : this()
+ {
+ m_name = name;
+ }
- /// <summary>
- /// constructs a method item from the name of the method and its parameters.
- /// </summary>
- /// <param name="name"></param>
- /// <param name="parameters"></param>
- public MethodItem(string name, string[] parameters)
- : this(name)
- {
- m_parameters = parameters;
- }
+ /// <summary>
+ /// constructs a method item from the name of the method and its parameters.
+ /// </summary>
+ /// <param name="name"></param>
+ /// <param name="parameters"></param>
+ public MethodItem(string name, string[] parameters)
+ : this(name)
+ {
+ m_parameters = parameters;
+ }
/// <summary>
/// constructs a method item from a method base by determining the method name and its parameters.
/// </summary>
/// <param name="methodBase"></param>
- public MethodItem(System.Reflection.MethodBase methodBase)
- : this(methodBase.Name, GetMethodParameterNames(methodBase))
+ public MethodItem(System.Reflection.MethodBase methodBase)
+ : this(methodBase.Name, GetMethodParameterNames(methodBase))
{
- }
+ }
- #endregion
+ #endregion
- private static string[] GetMethodParameterNames(System.Reflection.MethodBase methodBase)
- {
- ArrayList methodParameterNames = new ArrayList();
- try
- {
- System.Reflection.ParameterInfo[] methodBaseGetParameters = methodBase.GetParameters();
+ private static string[] GetMethodParameterNames(System.Reflection.MethodBase methodBase)
+ {
+ ArrayList methodParameterNames = new ArrayList();
+ try
+ {
+ System.Reflection.ParameterInfo[] methodBaseGetParameters = methodBase.GetParameters();
- int methodBaseGetParametersCount = methodBaseGetParameters.GetUpperBound(0);
+ int methodBaseGetParametersCount = methodBaseGetParameters.GetUpperBound(0);
- for (int i = 0; i <= methodBaseGetParametersCount; i++)
- {
- methodParameterNames.Add(methodBaseGetParameters[i].ParameterType + " " + methodBaseGetParameters[i].Name);
- }
- }
- catch (Exception ex)
- {
- LogLog.Error(declaringType, "An exception ocurred while retreiving method parameters.", ex);
- }
+ for (int i = 0; i <= methodBaseGetParametersCount; i++)
+ {
+ methodParameterNames.Add(methodBaseGetParameters[i].ParameterType + " " + methodBaseGetParameters[i].Name);
+ }
+ }
+ catch (Exception ex)
+ {
+ LogLog.Error(declaringType, "An exception ocurred while retreiving method parameters.", ex);
+ }
- return (string[])methodParameterNames.ToArray(typeof(string));
- }
+ return (string[])methodParameterNames.ToArray(typeof(string));
+ }
- #region Public Instance Properties
+ #region Public Instance Properties
- /// <summary>
- /// Gets the method name of the caller making the logging
- /// request.
- /// </summary>
- /// <value>
- /// The method name of the caller making the logging
- /// request.
- /// </value>
- /// <remarks>
- /// <para>
- /// Gets the method name of the caller making the logging
- /// request.
- /// </para>
- /// </remarks>
- public string Name
- {
- get { return m_name; }
- }
+ /// <summary>
+ /// Gets the method name of the caller making the logging
+ /// request.
+ /// </summary>
+ /// <value>
+ /// The method name of the caller making the logging
+ /// request.
+ /// </value>
+ /// <remarks>
+ /// <para>
+ /// Gets the method name of the caller making the logging
+ /// request.
+ /// </para>
+ /// </remarks>
+ public string Name
+ {
+ get { return m_name; }
+ }
- /// <summary>
- /// Gets the method parameters of the caller making
- /// the logging request.
- /// </summary>
- /// <value>
- /// The method parameters of the caller making
- /// the logging request
- /// </value>
- /// <remarks>
- /// <para>
- /// Gets the method parameters of the caller making
- /// the logging request.
- /// </para>
- /// </remarks>
- public string[] Parameters
- {
- get { return m_parameters; }
- }
+ /// <summary>
+ /// Gets the method parameters of the caller making
+ /// the logging request.
+ /// </summary>
+ /// <value>
+ /// The method parameters of the caller making
+ /// the logging request
+ /// </value>
+ /// <remarks>
+ /// <para>
+ /// Gets the method parameters of the caller making
+ /// the logging request.
+ /// </para>
+ /// </remarks>
+ public string[] Parameters
+ {
+ get { return m_parameters; }
+ }
- #endregion
+ #endregion
- #region Private Instance Fields
+ #region Private Instance Fields
- private readonly string m_name;
- private readonly string[] m_parameters;
+ private readonly string m_name;
+ private readonly string[] m_parameters;
- #endregion
+ #endregion
- #region Private Static Fields
+ #region Private Static Fields
- /// <summary>
- /// The fully qualified type of the StackFrameItem class.
- /// </summary>
- /// <remarks>
- /// Used by the internal logger to record the Type of the
- /// log message.
- /// </remarks>
- private static readonly Type declaringType = typeof(MethodItem);
+ /// <summary>
+ /// The fully qualified type of the StackFrameItem class.
+ /// </summary>
+ /// <remarks>
+ /// Used by the internal logger to record the Type of the
+ /// log message.
+ /// </remarks>
+ private static readonly Type declaringType = typeof(MethodItem);
- /// <summary>
- /// When location information is not available the constant
- /// <c>NA</c> is returned. Current value of this string
- /// constant is <b>?</b>.
- /// </summary>
- private const string NA = "?";
+ /// <summary>
+ /// When location information is not available the constant
+ /// <c>NA</c> is returned. Current value of this string
+ /// constant is <b>?</b>.
+ /// </summary>
+ private const string NA = "?";
- #endregion Private Static Fields
- }
+ #endregion Private Static Fields
+ }
}
diff --git a/src/log4net/Core/SecurityContext.cs b/src/log4net/Core/SecurityContext.cs
index fecad2b..e454c86 100644
--- a/src/log4net/Core/SecurityContext.cs
+++ b/src/log4net/Core/SecurityContext.cs
@@ -21,35 +21,35 @@
namespace log4net.Core
{
- /// <summary>
- /// A SecurityContext used by log4net when interacting with protected resources
- /// </summary>
- /// <remarks>
- /// <para>
- /// A SecurityContext used by log4net when interacting with protected resources
- /// for example with operating system services. This can be used to impersonate
- /// a principal that has been granted privileges on the system resources.
- /// </para>
- /// </remarks>
- /// <author>Nicko Cadell</author>
- public abstract class SecurityContext
- {
- /// <summary>
- /// Impersonate this SecurityContext
- /// </summary>
- /// <param name="state">State supplied by the caller</param>
- /// <returns>An <see cref="IDisposable"/> instance that will
- /// revoke the impersonation of this SecurityContext, or <c>null</c></returns>
- /// <remarks>
- /// <para>
- /// Impersonate this security context. Further calls on the current
- /// thread should now be made in the security context provided
- /// by this object. When the <see cref="IDisposable"/> result
- /// <see cref="IDisposable.Dispose"/> method is called the security
- /// context of the thread should be reverted to the state it was in
- /// before <see cref="Impersonate"/> was called.
- /// </para>
- /// </remarks>
- public abstract IDisposable Impersonate(object state);
- }
+ /// <summary>
+ /// A SecurityContext used by log4net when interacting with protected resources
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// A SecurityContext used by log4net when interacting with protected resources
+ /// for example with operating system services. This can be used to impersonate
+ /// a principal that has been granted privileges on the system resources.
+ /// </para>
+ /// </remarks>
+ /// <author>Nicko Cadell</author>
+ public abstract class SecurityContext
+ {
+ /// <summary>
+ /// Impersonate this SecurityContext
+ /// </summary>
+ /// <param name="state">State supplied by the caller</param>
+ /// <returns>An <see cref="IDisposable"/> instance that will
+ /// revoke the impersonation of this SecurityContext, or <c>null</c></returns>
+ /// <remarks>
+ /// <para>
+ /// Impersonate this security context. Further calls on the current
+ /// thread should now be made in the security context provided
+ /// by this object. When the <see cref="IDisposable"/> result
+ /// <see cref="IDisposable.Dispose"/> method is called the security
+ /// context of the thread should be reverted to the state it was in
+ /// before <see cref="Impersonate"/> was called.
+ /// </para>
+ /// </remarks>
+ public abstract IDisposable Impersonate(object state);
+ }
}
diff --git a/src/log4net/Core/SecurityContextProvider.cs b/src/log4net/Core/SecurityContextProvider.cs
index f6e99e6..a887b04 100644
--- a/src/log4net/Core/SecurityContextProvider.cs
+++ b/src/log4net/Core/SecurityContextProvider.cs
@@ -23,102 +23,102 @@
namespace log4net.Core
{
- /// <summary>
- /// The <see cref="SecurityContextProvider"/> providers default <see cref="SecurityContext"/> instances.
- /// </summary>
- /// <remarks>
- /// <para>
- /// A configured component that interacts with potentially protected system
- /// resources uses a <see cref="SecurityContext"/> to provide the elevated
- /// privileges required. If the <see cref="SecurityContext"/> object has
- /// been not been explicitly provided to the component then the component
- /// will request one from this <see cref="SecurityContextProvider"/>.
- /// </para>
- /// <para>
- /// By default the <see cref="SecurityContextProvider.DefaultProvider"/> is
- /// an instance of <see cref="SecurityContextProvider"/> which returns only
- /// <see cref="NullSecurityContext"/> objects. This is a reasonable default
- /// where the privileges required are not know by the system.
- /// </para>
- /// <para>
- /// This default behavior can be overridden by subclassing the <see cref="SecurityContextProvider"/>
- /// and overriding the <see cref="CreateSecurityContext"/> method to return
- /// the desired <see cref="SecurityContext"/> objects. The default provider
- /// can be replaced by programmatically setting the value of the
- /// <see cref="SecurityContextProvider.DefaultProvider"/> property.
- /// </para>
- /// <para>
- /// An alternative is to use the <c>log4net.Config.SecurityContextProviderAttribute</c>
- /// This attribute can be applied to an assembly in the same way as the
- /// <c>log4net.Config.XmlConfiguratorAttribute"</c>. The attribute takes
- /// the type to use as the <see cref="SecurityContextProvider"/> as an argument.
- /// </para>
- /// </remarks>
- /// <author>Nicko Cadell</author>
- public class SecurityContextProvider
- {
- /// <summary>
- /// The default provider
- /// </summary>
- private static SecurityContextProvider s_defaultProvider = new SecurityContextProvider();
+ /// <summary>
+ /// The <see cref="SecurityContextProvider"/> providers default <see cref="SecurityContext"/> instances.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// A configured component that interacts with potentially protected system
+ /// resources uses a <see cref="SecurityContext"/> to provide the elevated
+ /// privileges required. If the <see cref="SecurityContext"/> object has
+ /// been not been explicitly provided to the component then the component
+ /// will request one from this <see cref="SecurityContextProvider"/>.
+ /// </para>
+ /// <para>
+ /// By default the <see cref="SecurityContextProvider.DefaultProvider"/> is
+ /// an instance of <see cref="SecurityContextProvider"/> which returns only
+ /// <see cref="NullSecurityContext"/> objects. This is a reasonable default
+ /// where the privileges required are not know by the system.
+ /// </para>
+ /// <para>
+ /// This default behavior can be overridden by subclassing the <see cref="SecurityContextProvider"/>
+ /// and overriding the <see cref="CreateSecurityContext"/> method to return
+ /// the desired <see cref="SecurityContext"/> objects. The default provider
+ /// can be replaced by programmatically setting the value of the
+ /// <see cref="SecurityContextProvider.DefaultProvider"/> property.
+ /// </para>
+ /// <para>
+ /// An alternative is to use the <c>log4net.Config.SecurityContextProviderAttribute</c>
+ /// This attribute can be applied to an assembly in the same way as the
+ /// <c>log4net.Config.XmlConfiguratorAttribute"</c>. The attribute takes
+ /// the type to use as the <see cref="SecurityContextProvider"/> as an argument.
+ /// </para>
+ /// </remarks>
+ /// <author>Nicko Cadell</author>
+ public class SecurityContextProvider
+ {
+ /// <summary>
+ /// The default provider
+ /// </summary>
+ private static SecurityContextProvider s_defaultProvider = new SecurityContextProvider();
- /// <summary>
- /// Gets or sets the default SecurityContextProvider
- /// </summary>
- /// <value>
- /// The default SecurityContextProvider
- /// </value>
- /// <remarks>
- /// <para>
- /// The default provider is used by configured components that
- /// require a <see cref="SecurityContext"/> and have not had one
- /// given to them.
- /// </para>
- /// <para>
- /// By default this is an instance of <see cref="SecurityContextProvider"/>
- /// that returns <see cref="NullSecurityContext"/> objects.
- /// </para>
- /// <para>
- /// The default provider can be set programmatically by setting
- /// the value of this property to a sub class of <see cref="SecurityContextProvider"/>
- /// that has the desired behavior.
- /// </para>
- /// </remarks>
- public static SecurityContextProvider DefaultProvider
- {
- get { return s_defaultProvider; }
- set { s_defaultProvider = value; }
- }
+ /// <summary>
+ /// Gets or sets the default SecurityContextProvider
+ /// </summary>
+ /// <value>
+ /// The default SecurityContextProvider
+ /// </value>
+ /// <remarks>
+ /// <para>
+ /// The default provider is used by configured components that
+ /// require a <see cref="SecurityContext"/> and have not had one
+ /// given to them.
+ /// </para>
+ /// <para>
+ /// By default this is an instance of <see cref="SecurityContextProvider"/>
+ /// that returns <see cref="NullSecurityContext"/> objects.
+ /// </para>
+ /// <para>
+ /// The default provider can be set programmatically by setting
+ /// the value of this property to a sub class of <see cref="SecurityContextProvider"/>
+ /// that has the desired behavior.
+ /// </para>
+ /// </remarks>
+ public static SecurityContextProvider DefaultProvider
+ {
+ get { return s_defaultProvider; }
+ set { s_defaultProvider = value; }
+ }
- /// <summary>
- /// Protected default constructor to allow subclassing
- /// </summary>
- /// <remarks>
- /// <para>
- /// Protected default constructor to allow subclassing
- /// </para>
- /// </remarks>
- protected SecurityContextProvider()
- {
- }
+ /// <summary>
+ /// Protected default constructor to allow subclassing
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Protected default constructor to allow subclassing
+ /// </para>
+ /// </remarks>
+ protected SecurityContextProvider()
+ {
+ }
- /// <summary>
- /// Create a SecurityContext for a consumer
- /// </summary>
- /// <param name="consumer">The consumer requesting the SecurityContext</param>
- /// <returns>An impersonation context</returns>
- /// <remarks>
- /// <para>
- /// The default implementation is to return a <see cref="NullSecurityContext"/>.
- /// </para>
- /// <para>
- /// Subclasses should override this method to provide their own
- /// behavior.
- /// </para>
- /// </remarks>
- public virtual SecurityContext CreateSecurityContext(object consumer)
- {
- return NullSecurityContext.Instance;
- }
- }
+ /// <summary>
+ /// Create a SecurityContext for a consumer
+ /// </summary>
+ /// <param name="consumer">The consumer requesting the SecurityContext</param>
+ /// <returns>An impersonation context</returns>
+ /// <remarks>
+ /// <para>
+ /// The default implementation is to return a <see cref="NullSecurityContext"/>.
+ /// </para>
+ /// <para>
+ /// Subclasses should override this method to provide their own
+ /// behavior.
+ /// </para>
+ /// </remarks>
+ public virtual SecurityContext CreateSecurityContext(object consumer)
+ {
+ return NullSecurityContext.Instance;
+ }
+ }
}
diff --git a/src/log4net/Core/StackFrameItem.cs b/src/log4net/Core/StackFrameItem.cs
index 1719326..778703b 100644
--- a/src/log4net/Core/StackFrameItem.cs
+++ b/src/log4net/Core/StackFrameItem.cs
@@ -47,24 +47,24 @@
m_method = new MethodItem();
m_className = NA;
- try
- {
- // get frame values
- m_lineNumber = frame.GetFileLineNumber().ToString(System.Globalization.NumberFormatInfo.InvariantInfo);
- m_fileName = frame.GetFileName();
- // get method values
- MethodBase method = frame.GetMethod();
- if (method != null)
- {
- if(method.DeclaringType != null)
- m_className = method.DeclaringType.FullName;
- m_method = new MethodItem(method);
- }
- }
- catch (Exception ex)
- {
- LogLog.Error(declaringType, "An exception ocurred while retreiving stack frame information.", ex);
- }
+ try
+ {
+ // get frame values
+ m_lineNumber = frame.GetFileLineNumber().ToString(System.Globalization.NumberFormatInfo.InvariantInfo);
+ m_fileName = frame.GetFileName();
+ // get method values
+ MethodBase method = frame.GetMethod();
+ if (method != null)
+ {
+ if(method.DeclaringType != null)
+ m_className = method.DeclaringType.FullName;
+ m_method = new MethodItem(method);
+ }
+ }
+ catch (Exception ex)
+ {
+ LogLog.Error(declaringType, "An exception ocurred while retreiving stack frame information.", ex);
+ }
// set full info
m_fullInfo = m_className + '.' + m_method.Name + '(' + m_fileName + ':' + m_lineNumber + ')';
@@ -167,7 +167,7 @@
private readonly string m_fileName;
private readonly string m_className;
private readonly string m_fullInfo;
- private readonly MethodItem m_method;
+ private readonly MethodItem m_method;
#endregion
diff --git a/src/log4net/Core/WrapperMap.cs b/src/log4net/Core/WrapperMap.cs
index d4f5b25..e9d6cad 100644
--- a/src/log4net/Core/WrapperMap.cs
+++ b/src/log4net/Core/WrapperMap.cs
@@ -24,236 +24,236 @@
namespace log4net.Core
{
- #region WrapperCreationHandler
+ #region WrapperCreationHandler
- /// <summary>
- /// Delegate used to handle creation of new wrappers.
- /// </summary>
- /// <param name="logger">The logger to wrap in a wrapper.</param>
- /// <remarks>
- /// <para>
- /// Delegate used to handle creation of new wrappers. This delegate
- /// is called from the <see cref="WrapperMap.CreateNewWrapperObject"/>
- /// method to construct the wrapper for the specified logger.
- /// </para>
- /// <para>
- /// The delegate to use is supplied to the <see cref="WrapperMap"/>
- /// constructor.
- /// </para>
- /// </remarks>
- public delegate ILoggerWrapper WrapperCreationHandler(ILogger logger);
+ /// <summary>
+ /// Delegate used to handle creation of new wrappers.
+ /// </summary>
+ /// <param name="logger">The logger to wrap in a wrapper.</param>
+ /// <remarks>
+ /// <para>
+ /// Delegate used to handle creation of new wrappers. This delegate
+ /// is called from the <see cref="WrapperMap.CreateNewWrapperObject"/>
+ /// method to construct the wrapper for the specified logger.
+ /// </para>
+ /// <para>
+ /// The delegate to use is supplied to the <see cref="WrapperMap"/>
+ /// constructor.
+ /// </para>
+ /// </remarks>
+ public delegate ILoggerWrapper WrapperCreationHandler(ILogger logger);
- #endregion WrapperCreationHandler
+ #endregion WrapperCreationHandler
- /// <summary>
- /// Maps between logger objects and wrapper objects.
- /// </summary>
- /// <remarks>
- /// <para>
- /// This class maintains a mapping between <see cref="ILogger"/> objects and
- /// <see cref="ILoggerWrapper"/> objects. Use the <see cref="GetWrapper"/> method to
- /// lookup the <see cref="ILoggerWrapper"/> for the specified <see cref="ILogger"/>.
- /// </para>
- /// <para>
- /// New wrapper instances are created by the <see cref="CreateNewWrapperObject"/>
- /// method. The default behavior is for this method to delegate construction
- /// of the wrapper to the <see cref="WrapperCreationHandler"/> delegate supplied
- /// to the constructor. This allows specialization of the behavior without
- /// requiring subclassing of this type.
- /// </para>
- /// </remarks>
- /// <author>Nicko Cadell</author>
- /// <author>Gert Driesen</author>
- public class WrapperMap
- {
- #region Public Instance Constructors
+ /// <summary>
+ /// Maps between logger objects and wrapper objects.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// This class maintains a mapping between <see cref="ILogger"/> objects and
+ /// <see cref="ILoggerWrapper"/> objects. Use the <see cref="GetWrapper"/> method to
+ /// lookup the <see cref="ILoggerWrapper"/> for the specified <see cref="ILogger"/>.
+ /// </para>
+ /// <para>
+ /// New wrapper instances are created by the <see cref="CreateNewWrapperObject"/>
+ /// method. The default behavior is for this method to delegate construction
+ /// of the wrapper to the <see cref="WrapperCreationHandler"/> delegate supplied
+ /// to the constructor. This allows specialization of the behavior without
+ /// requiring subclassing of this type.
+ /// </para>
+ /// </remarks>
+ /// <author>Nicko Cadell</author>
+ /// <author>Gert Driesen</author>
+ public class WrapperMap
+ {
+ #region Public Instance Constructors
- /// <summary>
- /// Initializes a new instance of the <see cref="WrapperMap" />
- /// </summary>
- /// <param name="createWrapperHandler">The handler to use to create the wrapper objects.</param>
- /// <remarks>
- /// <para>
- /// Initializes a new instance of the <see cref="WrapperMap" /> class with
- /// the specified handler to create the wrapper objects.
- /// </para>
- /// </remarks>
- public WrapperMap(WrapperCreationHandler createWrapperHandler)
- {
- m_createWrapperHandler = createWrapperHandler;
+ /// <summary>
+ /// Initializes a new instance of the <see cref="WrapperMap" />
+ /// </summary>
+ /// <param name="createWrapperHandler">The handler to use to create the wrapper objects.</param>
+ /// <remarks>
+ /// <para>
+ /// Initializes a new instance of the <see cref="WrapperMap" /> class with
+ /// the specified handler to create the wrapper objects.
+ /// </para>
+ /// </remarks>
+ public WrapperMap(WrapperCreationHandler createWrapperHandler)
+ {
+ m_createWrapperHandler = createWrapperHandler;
- // Create the delegates for the event callbacks
- m_shutdownHandler = new LoggerRepositoryShutdownEventHandler(ILoggerRepository_Shutdown);
- }
+ // Create the delegates for the event callbacks
+ m_shutdownHandler = new LoggerRepositoryShutdownEventHandler(ILoggerRepository_Shutdown);
+ }
- #endregion Public Instance Constructors
+ #endregion Public Instance Constructors
- #region Public Instance Properties
+ #region Public Instance Properties
- /// <summary>
- /// Gets the wrapper object for the specified logger.
- /// </summary>
- /// <returns>The wrapper object for the specified logger</returns>
- /// <remarks>
- /// <para>
- /// If the logger is null then the corresponding wrapper is null.
- /// </para>
- /// <para>
- /// Looks up the wrapper it it has previously been requested and
- /// returns it. If the wrapper has never been requested before then
- /// the <see cref="CreateNewWrapperObject"/> virtual method is
- /// called.
- /// </para>
- /// </remarks>
- public virtual ILoggerWrapper GetWrapper(ILogger logger)
- {
- // If the logger is null then the corresponding wrapper is null
- if (logger == null)
- {
- return null;
- }
+ /// <summary>
+ /// Gets the wrapper object for the specified logger.
+ /// </summary>
+ /// <returns>The wrapper object for the specified logger</returns>
+ /// <remarks>
+ /// <para>
+ /// If the logger is null then the corresponding wrapper is null.
+ /// </para>
+ /// <para>
+ /// Looks up the wrapper it it has previously been requested and
+ /// returns it. If the wrapper has never been requested before then
+ /// the <see cref="CreateNewWrapperObject"/> virtual method is
+ /// called.
+ /// </para>
+ /// </remarks>
+ public virtual ILoggerWrapper GetWrapper(ILogger logger)
+ {
+ // If the logger is null then the corresponding wrapper is null
+ if (logger == null)
+ {
+ return null;
+ }
- lock(this)
- {
- // Lookup hierarchy in map.
- Hashtable wrappersMap = (Hashtable)m_repositories[logger.Repository];
+ lock(this)
+ {
+ // Lookup hierarchy in map.
+ Hashtable wrappersMap = (Hashtable)m_repositories[logger.Repository];
- if (wrappersMap == null)
- {
- // Hierarchy does not exist in map.
- // Must register with hierarchy
+ if (wrappersMap == null)
+ {
+ // Hierarchy does not exist in map.
+ // Must register with hierarchy
- wrappersMap = new Hashtable();
- m_repositories[logger.Repository] = wrappersMap;
+ wrappersMap = new Hashtable();
+ m_repositories[logger.Repository] = wrappersMap;
- // Register for config reset & shutdown on repository
- logger.Repository.ShutdownEvent += m_shutdownHandler;
- }
+ // Register for config reset & shutdown on repository
+ logger.Repository.ShutdownEvent += m_shutdownHandler;
+ }
- // Look for the wrapper object in the map
- ILoggerWrapper wrapperObject = wrappersMap[logger] as ILoggerWrapper;
+ // Look for the wrapper object in the map
+ ILoggerWrapper wrapperObject = wrappersMap[logger] as ILoggerWrapper;
- if (wrapperObject == null)
- {
- // No wrapper object exists for the specified logger
+ if (wrapperObject == null)
+ {
+ // No wrapper object exists for the specified logger
- // Create a new wrapper wrapping the logger
- wrapperObject = CreateNewWrapperObject(logger);
-
- // Store wrapper logger in map
- wrappersMap[logger] = wrapperObject;
- }
+ // Create a new wrapper wrapping the logger
+ wrapperObject = CreateNewWrapperObject(logger);
+
+ // Store wrapper logger in map
+ wrappersMap[logger] = wrapperObject;
+ }
- return wrapperObject;
- }
- }
+ return wrapperObject;
+ }
+ }
- #endregion Public Instance Properties
+ #endregion Public Instance Properties
- #region Protected Instance Properties
+ #region Protected Instance Properties
- /// <summary>
- /// Gets the map of logger repositories.
- /// </summary>
- /// <value>
- /// Map of logger repositories.
- /// </value>
- /// <remarks>
- /// <para>
- /// Gets the hashtable that is keyed on <see cref="ILoggerRepository"/>. The
- /// values are hashtables keyed on <see cref="ILogger"/> with the
- /// value being the corresponding <see cref="ILoggerWrapper"/>.
- /// </para>
- /// </remarks>
- protected Hashtable Repositories
- {
- get { return this.m_repositories; }
- }
+ /// <summary>
+ /// Gets the map of logger repositories.
+ /// </summary>
+ /// <value>
+ /// Map of logger repositories.
+ /// </value>
+ /// <remarks>
+ /// <para>
+ /// Gets the hashtable that is keyed on <see cref="ILoggerRepository"/>. The
+ /// values are hashtables keyed on <see cref="ILogger"/> with the
+ /// value being the corresponding <see cref="ILoggerWrapper"/>.
+ /// </para>
+ /// </remarks>
+ protected Hashtable Repositories
+ {
+ get { return this.m_repositories; }
+ }
- #endregion Protected Instance Properties
+ #endregion Protected Instance Properties
- #region Protected Instance Methods
+ #region Protected Instance Methods
- /// <summary>
- /// Creates the wrapper object for the specified logger.
- /// </summary>
- /// <param name="logger">The logger to wrap in a wrapper.</param>
- /// <returns>The wrapper object for the logger.</returns>
- /// <remarks>
- /// <para>
- /// This implementation uses the <see cref="WrapperCreationHandler"/>
- /// passed to the constructor to create the wrapper. This method
- /// can be overridden in a subclass.
- /// </para>
- /// </remarks>
- protected virtual ILoggerWrapper CreateNewWrapperObject(ILogger logger)
- {
- if (m_createWrapperHandler != null)
- {
- return m_createWrapperHandler(logger);
- }
- return null;
- }
+ /// <summary>
+ /// Creates the wrapper object for the specified logger.
+ /// </summary>
+ /// <param name="logger">The logger to wrap in a wrapper.</param>
+ /// <returns>The wrapper object for the logger.</returns>
+ /// <remarks>
+ /// <para>
+ /// This implementation uses the <see cref="WrapperCreationHandler"/>
+ /// passed to the constructor to create the wrapper. This method
+ /// can be overridden in a subclass.
+ /// </para>
+ /// </remarks>
+ protected virtual ILoggerWrapper CreateNewWrapperObject(ILogger logger)
+ {
+ if (m_createWrapperHandler != null)
+ {
+ return m_createWrapperHandler(logger);
+ }
+ return null;
+ }
- /// <summary>
- /// Called when a monitored repository shutdown event is received.
- /// </summary>
- /// <param name="repository">The <see cref="ILoggerRepository"/> that is shutting down</param>
- /// <remarks>
- /// <para>
- /// This method is called when a <see cref="ILoggerRepository"/> that this
- /// <see cref="WrapperMap"/> is holding loggers for has signaled its shutdown
- /// event <see cref="ILoggerRepository.ShutdownEvent"/>. The default
- /// behavior of this method is to release the references to the loggers
- /// and their wrappers generated for this repository.
- /// </para>
- /// </remarks>
- protected virtual void RepositoryShutdown(ILoggerRepository repository)
- {
- lock(this)
- {
- // Remove the repository from map
- m_repositories.Remove(repository);
+ /// <summary>
+ /// Called when a monitored repository shutdown event is received.
+ /// </summary>
+ /// <param name="repository">The <see cref="ILoggerRepository"/> that is shutting down</param>
+ /// <remarks>
+ /// <para>
+ /// This method is called when a <see cref="ILoggerRepository"/> that this
+ /// <see cref="WrapperMap"/> is holding loggers for has signaled its shutdown
+ /// event <see cref="ILoggerRepository.ShutdownEvent"/>. The default
+ /// behavior of this method is to release the references to the loggers
+ /// and their wrappers generated for this repository.
+ /// </para>
+ /// </remarks>
+ protected virtual void RepositoryShutdown(ILoggerRepository repository)
+ {
+ lock(this)
+ {
+ // Remove the repository from map
+ m_repositories.Remove(repository);
- // Unhook events from the repository
- repository.ShutdownEvent -= m_shutdownHandler;
- }
- }
+ // Unhook events from the repository
+ repository.ShutdownEvent -= m_shutdownHandler;
+ }
+ }
- /// <summary>
- /// Event handler for repository shutdown event.
- /// </summary>
- /// <param name="sender">The sender of the event.</param>
- /// <param name="e">The event args.</param>
- private void ILoggerRepository_Shutdown(object sender, EventArgs e)
- {
- ILoggerRepository repository = sender as ILoggerRepository;
- if (repository != null)
- {
- // Remove all repository from map
- RepositoryShutdown(repository);
- }
- }
+ /// <summary>
+ /// Event handler for repository shutdown event.
+ /// </summary>
+ /// <param name="sender">The sender of the event.</param>
+ /// <param name="e">The event args.</param>
+ private void ILoggerRepository_Shutdown(object sender, EventArgs e)
+ {
+ ILoggerRepository repository = sender as ILoggerRepository;
+ if (repository != null)
+ {
+ // Remove all repository from map
+ RepositoryShutdown(repository);
+ }
+ }
- #endregion Protected Instance Methods
+ #endregion Protected Instance Methods
- #region Private Instance Variables
+ #region Private Instance Variables
- /// <summary>
- /// Map of logger repositories to hashtables of ILogger to ILoggerWrapper mappings
- /// </summary>
- private readonly Hashtable m_repositories = new Hashtable();
+ /// <summary>
+ /// Map of logger repositories to hashtables of ILogger to ILoggerWrapper mappings
+ /// </summary>
+ private readonly Hashtable m_repositories = new Hashtable();
- /// <summary>
- /// The handler to use to create the extension wrapper objects.
- /// </summary>
- private readonly WrapperCreationHandler m_createWrapperHandler;
+ /// <summary>
+ /// The handler to use to create the extension wrapper objects.
+ /// </summary>
+ private readonly WrapperCreationHandler m_createWrapperHandler;
- /// <summary>
- /// Internal reference to the delegate used to register for repository shutdown events.
- /// </summary>
- private readonly LoggerRepositoryShutdownEventHandler m_shutdownHandler;
+ /// <summary>
+ /// Internal reference to the delegate used to register for repository shutdown events.
+ /// </summary>
+ private readonly LoggerRepositoryShutdownEventHandler m_shutdownHandler;
- #endregion Private Instance Variables
- }
+ #endregion Private Instance Variables
+ }
}
diff --git a/src/log4net/DateFormatter/AbsoluteTimeDateFormatter.cs b/src/log4net/DateFormatter/AbsoluteTimeDateFormatter.cs
index c633303..b19a1e0 100644
--- a/src/log4net/DateFormatter/AbsoluteTimeDateFormatter.cs
+++ b/src/log4net/DateFormatter/AbsoluteTimeDateFormatter.cs
@@ -24,92 +24,92 @@
namespace log4net.DateFormatter
{
- /// <summary>
- /// Formats a <see cref="DateTime"/> as <c>"HH:mm:ss,fff"</c>.
- /// </summary>
- /// <remarks>
- /// <para>
- /// Formats a <see cref="DateTime"/> in the format <c>"HH:mm:ss,fff"</c> for example, <c>"15:49:37,459"</c>.
- /// </para>
- /// </remarks>
- /// <author>Nicko Cadell</author>
- /// <author>Gert Driesen</author>
- public class AbsoluteTimeDateFormatter : IDateFormatter
- {
- #region Protected Instance Methods
+ /// <summary>
+ /// Formats a <see cref="DateTime"/> as <c>"HH:mm:ss,fff"</c>.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Formats a <see cref="DateTime"/> in the format <c>"HH:mm:ss,fff"</c> for example, <c>"15:49:37,459"</c>.
+ /// </para>
+ /// </remarks>
+ /// <author>Nicko Cadell</author>
+ /// <author>Gert Driesen</author>
+ public class AbsoluteTimeDateFormatter : IDateFormatter
+ {
+ #region Protected Instance Methods
- /// <summary>
- /// Renders the date into a string. Format is <c>"HH:mm:ss"</c>.
- /// </summary>
- /// <param name="dateToFormat">The date to render into a string.</param>
- /// <param name="buffer">The string builder to write to.</param>
- /// <remarks>
- /// <para>
- /// Subclasses should override this method to render the date
- /// into a string using a precision up to the second. This method
- /// will be called at most once per second and the result will be
- /// reused if it is needed again during the same second.
- /// </para>
- /// </remarks>
- protected virtual void FormatDateWithoutMillis(DateTime dateToFormat, StringBuilder buffer)
- {
- int hour = dateToFormat.Hour;
- if (hour < 10)
- {
- buffer.Append('0');
- }
- buffer.Append(hour);
- buffer.Append(':');
+ /// <summary>
+ /// Renders the date into a string. Format is <c>"HH:mm:ss"</c>.
+ /// </summary>
+ /// <param name="dateToFormat">The date to render into a string.</param>
+ /// <param name="buffer">The string builder to write to.</param>
+ /// <remarks>
+ /// <para>
+ /// Subclasses should override this method to render the date
+ /// into a string using a precision up to the second. This method
+ /// will be called at most once per second and the result will be
+ /// reused if it is needed again during the same second.
+ /// </para>
+ /// </remarks>
+ protected virtual void FormatDateWithoutMillis(DateTime dateToFormat, StringBuilder buffer)
+ {
+ int hour = dateToFormat.Hour;
+ if (hour < 10)
+ {
+ buffer.Append('0');
+ }
+ buffer.Append(hour);
+ buffer.Append(':');
- int mins = dateToFormat.Minute;
- if (mins < 10)
- {
- buffer.Append('0');
- }
- buffer.Append(mins);
- buffer.Append(':');
-
- int secs = dateToFormat.Second;
- if (secs < 10)
- {
- buffer.Append('0');
- }
- buffer.Append(secs);
- }
+ int mins = dateToFormat.Minute;
+ if (mins < 10)
+ {
+ buffer.Append('0');
+ }
+ buffer.Append(mins);
+ buffer.Append(':');
+
+ int secs = dateToFormat.Second;
+ if (secs < 10)
+ {
+ buffer.Append('0');
+ }
+ buffer.Append(secs);
+ }
- #endregion Protected Instance Methods
+ #endregion Protected Instance Methods
- #region Implementation of IDateFormatter
+ #region Implementation of IDateFormatter
- /// <summary>
- /// Renders the date into a string. Format is "HH:mm:ss,fff".
- /// </summary>
- /// <param name="dateToFormat">The date to render into a string.</param>
- /// <param name="writer">The writer to write to.</param>
- /// <remarks>
- /// <para>
- /// Uses the <see cref="FormatDateWithoutMillis"/> method to generate the
- /// time string up to the seconds and then appends the current
- /// milliseconds. The results from <see cref="FormatDateWithoutMillis"/> are
- /// cached and <see cref="FormatDateWithoutMillis"/> is called at most once
- /// per second.
- /// </para>
- /// <para>
- /// Sub classes should override <see cref="FormatDateWithoutMillis"/>
- /// rather than <see cref="FormatDate"/>.
- /// </para>
- /// </remarks>
- public virtual void FormatDate(DateTime dateToFormat, TextWriter writer)
- {
+ /// <summary>
+ /// Renders the date into a string. Format is "HH:mm:ss,fff".
+ /// </summary>
+ /// <param name="dateToFormat">The date to render into a string.</param>
+ /// <param name="writer">The writer to write to.</param>
+ /// <remarks>
+ /// <para>
+ /// Uses the <see cref="FormatDateWithoutMillis"/> method to generate the
+ /// time string up to the seconds and then appends the current
+ /// milliseconds. The results from <see cref="FormatDateWithoutMillis"/> are
+ /// cached and <see cref="FormatDateWithoutMillis"/> is called at most once
+ /// per second.
+ /// </para>
+ /// <para>
+ /// Sub classes should override <see cref="FormatDateWithoutMillis"/>
+ /// rather than <see cref="FormatDate"/>.
+ /// </para>
+ /// </remarks>
+ public virtual void FormatDate(DateTime dateToFormat, TextWriter writer)
+ {
lock (s_lastTimeStrings)
- {
- // Calculate the current time precise only to the second
- long currentTimeToTheSecond = (dateToFormat.Ticks - (dateToFormat.Ticks % TimeSpan.TicksPerSecond));
+ {
+ // Calculate the current time precise only to the second
+ long currentTimeToTheSecond = (dateToFormat.Ticks - (dateToFormat.Ticks % TimeSpan.TicksPerSecond));
string timeString = null;
- // Compare this time with the stored last time
- // If we are in the same second then append
- // the previously calculated time string
+ // Compare this time with the stored last time
+ // If we are in the same second then append
+ // the previously calculated time string
if (s_lastTimeToTheSecond != currentTimeToTheSecond)
{
s_lastTimeStrings.Clear();
@@ -121,93 +121,93 @@
if (timeString == null)
{
- // lock so that only one thread can use the buffer and
- // update the s_lastTimeToTheSecond and s_lastTimeStrings
+ // lock so that only one thread can use the buffer and
+ // update the s_lastTimeToTheSecond and s_lastTimeStrings
- // PERF: Try removing this lock and using a new StringBuilder each time
- lock(s_lastTimeBuf)
- {
+ // PERF: Try removing this lock and using a new StringBuilder each time
+ lock(s_lastTimeBuf)
+ {
timeString = (string) s_lastTimeStrings[GetType()];
if (timeString == null)
{
- // We are in a new second.
- s_lastTimeBuf.Length = 0;
+ // We are in a new second.
+ s_lastTimeBuf.Length = 0;
- // Calculate the new string for this second
- FormatDateWithoutMillis(dateToFormat, s_lastTimeBuf);
+ // Calculate the new string for this second
+ FormatDateWithoutMillis(dateToFormat, s_lastTimeBuf);
- // Render the string buffer to a string
+ // Render the string buffer to a string
timeString = s_lastTimeBuf.ToString();
#if NET_1_1
- // Ensure that the above string is written into the variable NOW on all threads.
- // This is only required on multiprocessor machines with weak memeory models
- System.Threading.Thread.MemoryBarrier();
+ // Ensure that the above string is written into the variable NOW on all threads.
+ // This is only required on multiprocessor machines with weak memeory models
+ System.Threading.Thread.MemoryBarrier();
#endif
- // Store the time as a string (we only have to do this once per second)
+ // Store the time as a string (we only have to do this once per second)
s_lastTimeStrings[GetType()] = timeString;
- s_lastTimeToTheSecond = currentTimeToTheSecond;
- }
- }
- }
- writer.Write(timeString);
-
- // Append the current millisecond info
- writer.Write(',');
- int millis = dateToFormat.Millisecond;
- if (millis < 100)
- {
- writer.Write('0');
- }
- if (millis < 10)
- {
- writer.Write('0');
- }
- writer.Write(millis);
+ s_lastTimeToTheSecond = currentTimeToTheSecond;
+ }
+ }
+ }
+ writer.Write(timeString);
+
+ // Append the current millisecond info
+ writer.Write(',');
+ int millis = dateToFormat.Millisecond;
+ if (millis < 100)
+ {
+ writer.Write('0');
+ }
+ if (millis < 10)
+ {
+ writer.Write('0');
+ }
+ writer.Write(millis);
}
- }
+ }
- #endregion Implementation of IDateFormatter
+ #endregion Implementation of IDateFormatter
- #region Public Static Fields
+ #region Public Static Fields
- /// <summary>
- /// String constant used to specify AbsoluteTimeDateFormat in layouts. Current value is <b>ABSOLUTE</b>.
- /// </summary>
- public const string AbsoluteTimeDateFormat = "ABSOLUTE";
+ /// <summary>
+ /// String constant used to specify AbsoluteTimeDateFormat in layouts. Current value is <b>ABSOLUTE</b>.
+ /// </summary>
+ public const string AbsoluteTimeDateFormat = "ABSOLUTE";
- /// <summary>
- /// String constant used to specify DateTimeDateFormat in layouts. Current value is <b>DATE</b>.
- /// </summary>
- public const string DateAndTimeDateFormat = "DATE";
+ /// <summary>
+ /// String constant used to specify DateTimeDateFormat in layouts. Current value is <b>DATE</b>.
+ /// </summary>
+ public const string DateAndTimeDateFormat = "DATE";
- /// <summary>
- /// String constant used to specify ISO8601DateFormat in layouts. Current value is <b>ISO8601</b>.
- /// </summary>
- public const string Iso8601TimeDateFormat = "ISO8601";
+ /// <summary>
+ /// String constant used to specify ISO8601DateFormat in layouts. Current value is <b>ISO8601</b>.
+ /// </summary>
+ public const string Iso8601TimeDateFormat = "ISO8601";
- #endregion Public Static Fields
+ #endregion Public Static Fields
- #region Private Static Fields
+ #region Private Static Fields
- /// <summary>
- /// Last stored time with precision up to the second.
- /// </summary>
- private static long s_lastTimeToTheSecond = 0;
+ /// <summary>
+ /// Last stored time with precision up to the second.
+ /// </summary>
+ private static long s_lastTimeToTheSecond = 0;
- /// <summary>
- /// Last stored time with precision up to the second, formatted
- /// as a string.
- /// </summary>
- private static StringBuilder s_lastTimeBuf = new StringBuilder();
+ /// <summary>
+ /// Last stored time with precision up to the second, formatted
+ /// as a string.
+ /// </summary>
+ private static StringBuilder s_lastTimeBuf = new StringBuilder();
- /// <summary>
- /// Last stored time with precision up to the second, formatted
- /// as a string.
- /// </summary>
- private static Hashtable s_lastTimeStrings = new Hashtable();
+ /// <summary>
+ /// Last stored time with precision up to the second, formatted
+ /// as a string.
+ /// </summary>
+ private static Hashtable s_lastTimeStrings = new Hashtable();
- #endregion Private Static Fields
- }
+ #endregion Private Static Fields
+ }
}
diff --git a/src/log4net/DateFormatter/DateTimeDateFormatter.cs b/src/log4net/DateFormatter/DateTimeDateFormatter.cs
index 7411206..90d529c 100644
--- a/src/log4net/DateFormatter/DateTimeDateFormatter.cs
+++ b/src/log4net/DateFormatter/DateTimeDateFormatter.cs
@@ -23,84 +23,84 @@
namespace log4net.DateFormatter
{
- /// <summary>
- /// Formats a <see cref="DateTime"/> as <c>"dd MMM yyyy HH:mm:ss,fff"</c>
- /// </summary>
- /// <remarks>
- /// <para>
- /// Formats a <see cref="DateTime"/> in the format
- /// <c>"dd MMM yyyy HH:mm:ss,fff"</c> for example,
- /// <c>"06 Nov 1994 15:49:37,459"</c>.
- /// </para>
- /// </remarks>
- /// <author>Nicko Cadell</author>
- /// <author>Gert Driesen</author>
- /// <author>Angelika Schnagl</author>
- public class DateTimeDateFormatter : AbsoluteTimeDateFormatter
- {
- #region Public Instance Constructors
+ /// <summary>
+ /// Formats a <see cref="DateTime"/> as <c>"dd MMM yyyy HH:mm:ss,fff"</c>
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Formats a <see cref="DateTime"/> in the format
+ /// <c>"dd MMM yyyy HH:mm:ss,fff"</c> for example,
+ /// <c>"06 Nov 1994 15:49:37,459"</c>.
+ /// </para>
+ /// </remarks>
+ /// <author>Nicko Cadell</author>
+ /// <author>Gert Driesen</author>
+ /// <author>Angelika Schnagl</author>
+ public class DateTimeDateFormatter : AbsoluteTimeDateFormatter
+ {
+ #region Public Instance Constructors
- /// <summary>
- /// Default constructor.
- /// </summary>
- /// <remarks>
- /// <para>
- /// Initializes a new instance of the <see cref="DateTimeDateFormatter" /> class.
- /// </para>
- /// </remarks>
- public DateTimeDateFormatter()
- {
- m_dateTimeFormatInfo = DateTimeFormatInfo.InvariantInfo;
- }
+ /// <summary>
+ /// Default constructor.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Initializes a new instance of the <see cref="DateTimeDateFormatter" /> class.
+ /// </para>
+ /// </remarks>
+ public DateTimeDateFormatter()
+ {
+ m_dateTimeFormatInfo = DateTimeFormatInfo.InvariantInfo;
+ }
- #endregion Public Instance Constructors
+ #endregion Public Instance Constructors
- #region Override implementation of AbsoluteTimeDateFormatter
+ #region Override implementation of AbsoluteTimeDateFormatter
- /// <summary>
- /// Formats the date without the milliseconds part
- /// </summary>
- /// <param name="dateToFormat">The date to format.</param>
- /// <param name="buffer">The string builder to write to.</param>
- /// <remarks>
- /// <para>
- /// Formats a DateTime in the format <c>"dd MMM yyyy HH:mm:ss"</c>
- /// for example, <c>"06 Nov 1994 15:49:37"</c>.
- /// </para>
- /// <para>
- /// The base class will append the <c>",fff"</c> milliseconds section.
- /// This method will only be called at most once per second.
- /// </para>
- /// </remarks>
- protected override void FormatDateWithoutMillis(DateTime dateToFormat, StringBuilder buffer)
- {
- int day = dateToFormat.Day;
- if (day < 10)
- {
- buffer.Append('0');
- }
- buffer.Append(day);
- buffer.Append(' ');
+ /// <summary>
+ /// Formats the date without the milliseconds part
+ /// </summary>
+ /// <param name="dateToFormat">The date to format.</param>
+ /// <param name="buffer">The string builder to write to.</param>
+ /// <remarks>
+ /// <para>
+ /// Formats a DateTime in the format <c>"dd MMM yyyy HH:mm:ss"</c>
+ /// for example, <c>"06 Nov 1994 15:49:37"</c>.
+ /// </para>
+ /// <para>
+ /// The base class will append the <c>",fff"</c> milliseconds section.
+ /// This method will only be called at most once per second.
+ /// </para>
+ /// </remarks>
+ protected override void FormatDateWithoutMillis(DateTime dateToFormat, StringBuilder buffer)
+ {
+ int day = dateToFormat.Day;
+ if (day < 10)
+ {
+ buffer.Append('0');
+ }
+ buffer.Append(day);
+ buffer.Append(' ');
- buffer.Append(m_dateTimeFormatInfo.GetAbbreviatedMonthName(dateToFormat.Month));
- buffer.Append(' ');
+ buffer.Append(m_dateTimeFormatInfo.GetAbbreviatedMonthName(dateToFormat.Month));
+ buffer.Append(' ');
- buffer.Append(dateToFormat.Year);
- buffer.Append(' ');
+ buffer.Append(dateToFormat.Year);
+ buffer.Append(' ');
- // Append the 'HH:mm:ss'
- base.FormatDateWithoutMillis(dateToFormat, buffer);
- }
+ // Append the 'HH:mm:ss'
+ base.FormatDateWithoutMillis(dateToFormat, buffer);
+ }
- #endregion Override implementation of AbsoluteTimeDateFormatter
+ #endregion Override implementation of AbsoluteTimeDateFormatter
- #region Private Instance Fields
+ #region Private Instance Fields
- /// <summary>
- /// The format info for the invariant culture.
- /// </summary>
- private readonly DateTimeFormatInfo m_dateTimeFormatInfo;
+ /// <summary>
+ /// The format info for the invariant culture.
+ /// </summary>
+ private readonly DateTimeFormatInfo m_dateTimeFormatInfo;
- #endregion Private Instance Fields
- }
+ #endregion Private Instance Fields
+ }
}
diff --git a/src/log4net/DateFormatter/IDateFormatter.cs b/src/log4net/DateFormatter/IDateFormatter.cs
index f5074ee..ebfb981 100644
--- a/src/log4net/DateFormatter/IDateFormatter.cs
+++ b/src/log4net/DateFormatter/IDateFormatter.cs
@@ -22,34 +22,34 @@
namespace log4net.DateFormatter
{
- /// <summary>
- /// Render a <see cref="DateTime"/> as a string.
- /// </summary>
- /// <remarks>
- /// <para>
- /// Interface to abstract the rendering of a <see cref="DateTime"/>
- /// instance into a string.
- /// </para>
- /// <para>
- /// The <see cref="FormatDate"/> method is used to render the
- /// date to a text writer.
- /// </para>
- /// </remarks>
- /// <author>Nicko Cadell</author>
- /// <author>Gert Driesen</author>
- public interface IDateFormatter
- {
- /// <summary>
- /// Formats the specified date as a string.
- /// </summary>
- /// <param name="dateToFormat">The date to format.</param>
- /// <param name="writer">The writer to write to.</param>
- /// <remarks>
- /// <para>
- /// Format the <see cref="DateTime"/> as a string and write it
- /// to the <see cref="TextWriter"/> provided.
- /// </para>
- /// </remarks>
- void FormatDate(DateTime dateToFormat, TextWriter writer);
- }
+ /// <summary>
+ /// Render a <see cref="DateTime"/> as a string.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Interface to abstract the rendering of a <see cref="DateTime"/>
+ /// instance into a string.
+ /// </para>
+ /// <para>
+ /// The <see cref="FormatDate"/> method is used to render the
+ /// date to a text writer.
+ /// </para>
+ /// </remarks>
+ /// <author>Nicko Cadell</author>
+ /// <author>Gert Driesen</author>
+ public interface IDateFormatter
+ {
+ /// <summary>
+ /// Formats the specified date as a string.
+ /// </summary>
+ /// <param name="dateToFormat">The date to format.</param>
+ /// <param name="writer">The writer to write to.</param>
+ /// <remarks>
+ /// <para>
+ /// Format the <see cref="DateTime"/> as a string and write it
+ /// to the <see cref="TextWriter"/> provided.
+ /// </para>
+ /// </remarks>
+ void FormatDate(DateTime dateToFormat, TextWriter writer);
+ }
}
diff --git a/src/log4net/DateFormatter/Iso8601DateFormatter.cs b/src/log4net/DateFormatter/Iso8601DateFormatter.cs
index 524c8a7..1ff299f 100644
--- a/src/log4net/DateFormatter/Iso8601DateFormatter.cs
+++ b/src/log4net/DateFormatter/Iso8601DateFormatter.cs
@@ -22,75 +22,75 @@
namespace log4net.DateFormatter
{
- /// <summary>
- /// Formats the <see cref="DateTime"/> as <c>"yyyy-MM-dd HH:mm:ss,fff"</c>.
- /// </summary>
- /// <remarks>
- /// <para>
- /// Formats the <see cref="DateTime"/> specified as a string: <c>"yyyy-MM-dd HH:mm:ss,fff"</c>.
- /// </para>
- /// </remarks>
- /// <author>Nicko Cadell</author>
- /// <author>Gert Driesen</author>
- public class Iso8601DateFormatter : AbsoluteTimeDateFormatter
- {
- #region Public Instance Constructors
+ /// <summary>
+ /// Formats the <see cref="DateTime"/> as <c>"yyyy-MM-dd HH:mm:ss,fff"</c>.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Formats the <see cref="DateTime"/> specified as a string: <c>"yyyy-MM-dd HH:mm:ss,fff"</c>.
+ /// </para>
+ /// </remarks>
+ /// <author>Nicko Cadell</author>
+ /// <author>Gert Driesen</author>
+ public class Iso8601DateFormatter : AbsoluteTimeDateFormatter
+ {
+ #region Public Instance Constructors
- /// <summary>
- /// Default constructor
- /// </summary>
- /// <remarks>
- /// <para>
- /// Initializes a new instance of the <see cref="Iso8601DateFormatter" /> class.
- /// </para>
- /// </remarks>
- public Iso8601DateFormatter()
- {
- }
+ /// <summary>
+ /// Default constructor
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Initializes a new instance of the <see cref="Iso8601DateFormatter" /> class.
+ /// </para>
+ /// </remarks>
+ public Iso8601DateFormatter()
+ {
+ }
- #endregion Public Instance Constructors
+ #endregion Public Instance Constructors
- #region Override implementation of AbsoluteTimeDateFormatter
+ #region Override implementation of AbsoluteTimeDateFormatter
- /// <summary>
- /// Formats the date without the milliseconds part
- /// </summary>
- /// <param name="dateToFormat">The date to format.</param>
- /// <param name="buffer">The string builder to write to.</param>
- /// <remarks>
- /// <para>
- /// Formats the date specified as a string: <c>"yyyy-MM-dd HH:mm:ss"</c>.
- /// </para>
- /// <para>
- /// The base class will append the <c>",fff"</c> milliseconds section.
- /// This method will only be called at most once per second.
- /// </para>
- /// </remarks>
- protected override void FormatDateWithoutMillis(DateTime dateToFormat, StringBuilder buffer)
- {
- buffer.Append(dateToFormat.Year);
+ /// <summary>
+ /// Formats the date without the milliseconds part
+ /// </summary>
+ /// <param name="dateToFormat">The date to format.</param>
+ /// <param name="buffer">The string builder to write to.</param>
+ /// <remarks>
+ /// <para>
+ /// Formats the date specified as a string: <c>"yyyy-MM-dd HH:mm:ss"</c>.
+ /// </para>
+ /// <para>
+ /// The base class will append the <c>",fff"</c> milliseconds section.
+ /// This method will only be called at most once per second.
+ /// </para>
+ /// </remarks>
+ protected override void FormatDateWithoutMillis(DateTime dateToFormat, StringBuilder buffer)
+ {
+ buffer.Append(dateToFormat.Year);
- buffer.Append('-');
- int month = dateToFormat.Month;
- if (month < 10)
- {
- buffer.Append('0');
- }
- buffer.Append(month);
- buffer.Append('-');
+ buffer.Append('-');
+ int month = dateToFormat.Month;
+ if (month < 10)
+ {
+ buffer.Append('0');
+ }
+ buffer.Append(month);
+ buffer.Append('-');
- int day = dateToFormat.Day;
- if (day < 10)
- {
- buffer.Append('0');
- }
- buffer.Append(day);
- buffer.Append(' ');
+ int day = dateToFormat.Day;
+ if (day < 10)
+ {
+ buffer.Append('0');
+ }
+ buffer.Append(day);
+ buffer.Append(' ');
- // Append the 'HH:mm:ss'
- base.FormatDateWithoutMillis(dateToFormat, buffer);
- }
+ // Append the 'HH:mm:ss'
+ base.FormatDateWithoutMillis(dateToFormat, buffer);
+ }
- #endregion Override implementation of AbsoluteTimeDateFormatter
- }
+ #endregion Override implementation of AbsoluteTimeDateFormatter
+ }
}
diff --git a/src/log4net/DateFormatter/SimpleDateFormatter.cs b/src/log4net/DateFormatter/SimpleDateFormatter.cs
index 3efb164..05e5e86 100644
--- a/src/log4net/DateFormatter/SimpleDateFormatter.cs
+++ b/src/log4net/DateFormatter/SimpleDateFormatter.cs
@@ -22,74 +22,74 @@
namespace log4net.DateFormatter
{
- /// <summary>
- /// Formats the <see cref="DateTime"/> using the <see cref="M:DateTime.ToString(string, IFormatProvider)"/> method.
- /// </summary>
- /// <remarks>
- /// <para>
- /// Formats the <see cref="DateTime"/> using the <see cref="DateTime"/> <see cref="M:DateTime.ToString(string, IFormatProvider)"/> method.
- /// </para>
- /// </remarks>
- /// <author>Nicko Cadell</author>
- /// <author>Gert Driesen</author>
- public class SimpleDateFormatter : IDateFormatter
- {
- #region Public Instance Constructors
+ /// <summary>
+ /// Formats the <see cref="DateTime"/> using the <see cref="M:DateTime.ToString(string, IFormatProvider)"/> method.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Formats the <see cref="DateTime"/> using the <see cref="DateTime"/> <see cref="M:DateTime.ToString(string, IFormatProvider)"/> method.
+ /// </para>
+ /// </remarks>
+ /// <author>Nicko Cadell</author>
+ /// <author>Gert Driesen</author>
+ public class SimpleDateFormatter : IDateFormatter
+ {
+ #region Public Instance Constructors
- /// <summary>
- /// Constructor
- /// </summary>
- /// <param name="format">The format string.</param>
- /// <remarks>
- /// <para>
- /// Initializes a new instance of the <see cref="SimpleDateFormatter" /> class
- /// with the specified format string.
- /// </para>
- /// <para>
- /// The format string must be compatible with the options
- /// that can be supplied to <see cref="M:DateTime.ToString(string, IFormatProvider)"/>.
- /// </para>
- /// </remarks>
- public SimpleDateFormatter(string format)
- {
- m_formatString = format;
- }
+ /// <summary>
+ /// Constructor
+ /// </summary>
+ /// <param name="format">The format string.</param>
+ /// <remarks>
+ /// <para>
+ /// Initializes a new instance of the <see cref="SimpleDateFormatter" /> class
+ /// with the specified format string.
+ /// </para>
+ /// <para>
+ /// The format string must be compatible with the options
+ /// that can be supplied to <see cref="M:DateTime.ToString(string, IFormatProvider)"/>.
+ /// </para>
+ /// </remarks>
+ public SimpleDateFormatter(string format)
+ {
+ m_formatString = format;
+ }
- #endregion Public Instance Constructors
+ #endregion Public Instance Constructors
- #region Implementation of IDateFormatter
+ #region Implementation of IDateFormatter
- /// <summary>
- /// Formats the date using <see cref="M:DateTime.ToString(string, IFormatProvider)"/>.
- /// </summary>
- /// <param name="dateToFormat">The date to convert to a string.</param>
- /// <param name="writer">The writer to write to.</param>
- /// <remarks>
- /// <para>
- /// Uses the date format string supplied to the constructor to call
- /// the <see cref="M:DateTime.ToString(string, IFormatProvider)"/> method to format the date.
- /// </para>
- /// </remarks>
- public virtual void FormatDate(DateTime dateToFormat, TextWriter writer)
- {
- writer.Write(dateToFormat.ToString(m_formatString, System.Globalization.DateTimeFormatInfo.InvariantInfo));
- }
+ /// <summary>
+ /// Formats the date using <see cref="M:DateTime.ToString(string, IFormatProvider)"/>.
+ /// </summary>
+ /// <param name="dateToFormat">The date to convert to a string.</param>
+ /// <param name="writer">The writer to write to.</param>
+ /// <remarks>
+ /// <para>
+ /// Uses the date format string supplied to the constructor to call
+ /// the <see cref="M:DateTime.ToString(string, IFormatProvider)"/> method to format the date.
+ /// </para>
+ /// </remarks>
+ public virtual void FormatDate(DateTime dateToFormat, TextWriter writer)
+ {
+ writer.Write(dateToFormat.ToString(m_formatString, System.Globalization.DateTimeFormatInfo.InvariantInfo));
+ }
- #endregion
+ #endregion
- #region Private Instance Fields
+ #region Private Instance Fields
- /// <summary>
- /// The format string used to format the <see cref="DateTime" />.
- /// </summary>
- /// <remarks>
- /// <para>
- /// The format string must be compatible with the options
- /// that can be supplied to <see cref="M:DateTime.ToString(string, IFormatProvider)"/>.
- /// </para>
- /// </remarks>
- private readonly string m_formatString;
+ /// <summary>
+ /// The format string used to format the <see cref="DateTime" />.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// The format string must be compatible with the options
+ /// that can be supplied to <see cref="M:DateTime.ToString(string, IFormatProvider)"/>.
+ /// </para>
+ /// </remarks>
+ private readonly string m_formatString;
- #endregion Private Instance Fields
- }
+ #endregion Private Instance Fields
+ }
}
diff --git a/src/log4net/Filter/DenyAllFilter.cs b/src/log4net/Filter/DenyAllFilter.cs
index ab377f1..35c1138 100644
--- a/src/log4net/Filter/DenyAllFilter.cs
+++ b/src/log4net/Filter/DenyAllFilter.cs
@@ -23,53 +23,53 @@
namespace log4net.Filter
{
- /// <summary>
- /// This filter drops all <see cref="LoggingEvent"/>.
- /// </summary>
- /// <remarks>
- /// <para>
- /// You can add this filter to the end of a filter chain to
- /// switch from the default "accept all unless instructed otherwise"
- /// filtering behavior to a "deny all unless instructed otherwise"
- /// behavior.
- /// </para>
- /// </remarks>
- /// <author>Nicko Cadell</author>
- /// <author>Gert Driesen</author>
- public sealed class DenyAllFilter : FilterSkeleton
- {
- #region Constructors
+ /// <summary>
+ /// This filter drops all <see cref="LoggingEvent"/>.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// You can add this filter to the end of a filter chain to
+ /// switch from the default "accept all unless instructed otherwise"
+ /// filtering behavior to a "deny all unless instructed otherwise"
+ /// behavior.
+ /// </para>
+ /// </remarks>
+ /// <author>Nicko Cadell</author>
+ /// <author>Gert Driesen</author>
+ public sealed class DenyAllFilter : FilterSkeleton
+ {
+ #region Constructors
- /// <summary>
- /// Default constructor
- /// </summary>
- public DenyAllFilter()
- {
- }
+ /// <summary>
+ /// Default constructor
+ /// </summary>
+ public DenyAllFilter()
+ {
+ }
- #endregion
+ #endregion
- #region Override implementation of FilterSkeleton
+ #region Override implementation of FilterSkeleton
- /// <summary>
- /// Always returns the integer constant <see cref="FilterDecision.Deny"/>
- /// </summary>
- /// <param name="loggingEvent">the LoggingEvent to filter</param>
- /// <returns>Always returns <see cref="FilterDecision.Deny"/></returns>
- /// <remarks>
- /// <para>
- /// Ignores the event being logged and just returns
- /// <see cref="FilterDecision.Deny"/>. This can be used to change the default filter
- /// chain behavior from <see cref="FilterDecision.Accept"/> to <see cref="FilterDecision.Deny"/>. This filter
- /// should only be used as the last filter in the chain
- /// as any further filters will be ignored!
- /// </para>
- /// </remarks>
- public override FilterDecision Decide(LoggingEvent loggingEvent)
- {
- return FilterDecision.Deny;
- }
+ /// <summary>
+ /// Always returns the integer constant <see cref="FilterDecision.Deny"/>
+ /// </summary>
+ /// <param name="loggingEvent">the LoggingEvent to filter</param>
+ /// <returns>Always returns <see cref="FilterDecision.Deny"/></returns>
+ /// <remarks>
+ /// <para>
+ /// Ignores the event being logged and just returns
+ /// <see cref="FilterDecision.Deny"/>. This can be used to change the default filter
+ /// chain behavior from <see cref="FilterDecision.Accept"/> to <see cref="FilterDecision.Deny"/>. This filter
+ /// should only be used as the last filter in the chain
+ /// as any further filters will be ignored!
+ /// </para>
+ /// </remarks>
+ public override FilterDecision Decide(LoggingEvent loggingEvent)
+ {
+ return FilterDecision.Deny;
+ }
- #endregion
- }
+ #endregion
+ }
}
diff --git a/src/log4net/Filter/FilterDecision.cs b/src/log4net/Filter/FilterDecision.cs
index 1b5967b..c81a156 100644
--- a/src/log4net/Filter/FilterDecision.cs
+++ b/src/log4net/Filter/FilterDecision.cs
@@ -23,32 +23,32 @@
namespace log4net.Filter
{
- /// <summary>
- /// The return result from <see cref="IFilter.Decide"/>
- /// </summary>
- /// <remarks>
- /// <para>
- /// The return result from <see cref="IFilter.Decide"/>
- /// </para>
- /// </remarks>
- public enum FilterDecision : int
- {
- /// <summary>
- /// The log event must be dropped immediately without
- /// consulting with the remaining filters, if any, in the chain.
- /// </summary>
- Deny = -1,
+ /// <summary>
+ /// The return result from <see cref="IFilter.Decide"/>
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// The return result from <see cref="IFilter.Decide"/>
+ /// </para>
+ /// </remarks>
+ public enum FilterDecision : int
+ {
+ /// <summary>
+ /// The log event must be dropped immediately without
+ /// consulting with the remaining filters, if any, in the chain.
+ /// </summary>
+ Deny = -1,
- /// <summary>
- /// This filter is neutral with respect to the log event.
- /// The remaining filters, if any, should be consulted for a final decision.
- /// </summary>
- Neutral = 0,
+ /// <summary>
+ /// This filter is neutral with respect to the log event.
+ /// The remaining filters, if any, should be consulted for a final decision.
+ /// </summary>
+ Neutral = 0,
- /// <summary>
- /// The log event must be logged immediately without
- /// consulting with the remaining filters, if any, in the chain.
- /// </summary>
- Accept = 1,
- }
+ /// <summary>
+ /// The log event must be logged immediately without
+ /// consulting with the remaining filters, if any, in the chain.
+ /// </summary>
+ Accept = 1,
+ }
}
diff --git a/src/log4net/Filter/FilterSkeleton.cs b/src/log4net/Filter/FilterSkeleton.cs
index 293d3ca..158d635 100644
--- a/src/log4net/Filter/FilterSkeleton.cs
+++ b/src/log4net/Filter/FilterSkeleton.cs
@@ -22,134 +22,134 @@
namespace log4net.Filter
{
- /// <summary>
- /// Subclass this type to implement customized logging event filtering
- /// </summary>
- /// <remarks>
- /// <para>
- /// Users should extend this class to implement customized logging
- /// event filtering. Note that <see cref="log4net.Repository.Hierarchy.Logger"/> and
- /// <see cref="log4net.Appender.AppenderSkeleton"/>, the parent class of all standard
- /// appenders, have built-in filtering rules. It is suggested that you
- /// first use and understand the built-in rules before rushing to write
- /// your own custom filters.
- /// </para>
- /// <para>
- /// This abstract class assumes and also imposes that filters be
- /// organized in a linear chain. The <see cref="Decide"/>
- /// method of each filter is called sequentially, in the order of their
- /// addition to the chain.
- /// </para>
- /// <para>
- /// The <see cref="Decide"/> method must return one
- /// of the integer constants <see cref="FilterDecision.Deny"/>,
- /// <see cref="FilterDecision.Neutral"/> or <see cref="FilterDecision.Accept"/>.
- /// </para>
- /// <para>
- /// If the value <see cref="FilterDecision.Deny"/> is returned, then the log event is dropped
- /// immediately without consulting with the remaining filters.
- /// </para>
- /// <para>
- /// If the value <see cref="FilterDecision.Neutral"/> is returned, then the next filter
- /// in the chain is consulted. If there are no more filters in the
- /// chain, then the log event is logged. Thus, in the presence of no
- /// filters, the default behavior is to log all logging events.
- /// </para>
- /// <para>
- /// If the value <see cref="FilterDecision.Accept"/> is returned, then the log
- /// event is logged without consulting the remaining filters.
- /// </para>
- /// <para>
- /// The philosophy of log4net filters is largely inspired from the
- /// Linux ipchains.
- /// </para>
- /// </remarks>
- /// <author>Nicko Cadell</author>
- /// <author>Gert Driesen</author>
- public abstract class FilterSkeleton : IFilter
- {
- #region Member Variables
+ /// <summary>
+ /// Subclass this type to implement customized logging event filtering
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Users should extend this class to implement customized logging
+ /// event filtering. Note that <see cref="log4net.Repository.Hierarchy.Logger"/> and
+ /// <see cref="log4net.Appender.AppenderSkeleton"/>, the parent class of all standard
+ /// appenders, have built-in filtering rules. It is suggested that you
+ /// first use and understand the built-in rules before rushing to write
+ /// your own custom filters.
+ /// </para>
+ /// <para>
+ /// This abstract class assumes and also imposes that filters be
+ /// organized in a linear chain. The <see cref="Decide"/>
+ /// method of each filter is called sequentially, in the order of their
+ /// addition to the chain.
+ /// </para>
+ /// <para>
+ /// The <see cref="Decide"/> method must return one
+ /// of the integer constants <see cref="FilterDecision.Deny"/>,
+ /// <see cref="FilterDecision.Neutral"/> or <see cref="FilterDecision.Accept"/>.
+ /// </para>
+ /// <para>
+ /// If the value <see cref="FilterDecision.Deny"/> is returned, then the log event is dropped
+ /// immediately without consulting with the remaining filters.
+ /// </para>
+ /// <para>
+ /// If the value <see cref="FilterDecision.Neutral"/> is returned, then the next filter
+ /// in the chain is consulted. If there are no more filters in the
+ /// chain, then the log event is logged. Thus, in the presence of no
+ /// filters, the default behavior is to log all logging events.
+ /// </para>
+ /// <para>
+ /// If the value <see cref="FilterDecision.Accept"/> is returned, then the log
+ /// event is logged without consulting the remaining filters.
+ /// </para>
+ /// <para>
+ /// The philosophy of log4net filters is largely inspired from the
+ /// Linux ipchains.
+ /// </para>
+ /// </remarks>
+ /// <author>Nicko Cadell</author>
+ /// <author>Gert Driesen</author>
+ public abstract class FilterSkeleton : IFilter
+ {
+ #region Member Variables
- /// <summary>
- /// Points to the next filter in the filter chain.
- /// </summary>
- /// <remarks>
- /// <para>
- /// See <see cref="Next"/> for more information.
- /// </para>
- /// </remarks>
- private IFilter m_next;
+ /// <summary>
+ /// Points to the next filter in the filter chain.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// See <see cref="Next"/> for more information.
+ /// </para>
+ /// </remarks>
+ private IFilter m_next;
- #endregion
+ #endregion
- #region Implementation of IOptionHandler
+ #region Implementation of IOptionHandler
- /// <summary>
- /// Initialize the filter with 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>
- /// <para>
- /// Typically filter's options become active immediately on set,
- /// however this method must still be called.
- /// </para>
- /// </remarks>
- public virtual void ActivateOptions()
- {
- }
+ /// <summary>
+ /// Initialize the filter with 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>
+ /// <para>
+ /// Typically filter's options become active immediately on set,
+ /// however this method must still be called.
+ /// </para>
+ /// </remarks>
+ public virtual void ActivateOptions()
+ {
+ }
- #endregion
+ #endregion
- #region Implementation of IFilter
+ #region Implementation of IFilter
- /// <summary>
- /// Decide if the <see cref="LoggingEvent"/> should be logged through an appender.
- /// </summary>
- /// <param name="loggingEvent">The <see cref="LoggingEvent"/> to decide upon</param>
- /// <returns>The decision of the filter</returns>
- /// <remarks>
- /// <para>
- /// If the decision is <see cref="FilterDecision.Deny"/>, then the event will be
- /// dropped. If the decision is <see cref="FilterDecision.Neutral"/>, then the next
- /// filter, if any, will be invoked. If the decision is <see cref="FilterDecision.Accept"/> then
- /// the event will be logged without consulting with other filters in
- /// the chain.
- /// </para>
- /// <para>
- /// This method is marked <c>abstract</c> and must be implemented
- /// in a subclass.
- /// </para>
- /// </remarks>
- public abstract FilterDecision Decide(LoggingEvent loggingEvent);
+ /// <summary>
+ /// Decide if the <see cref="LoggingEvent"/> should be logged through an appender.
+ /// </summary>
+ /// <param name="loggingEvent">The <see cref="LoggingEvent"/> to decide upon</param>
+ /// <returns>The decision of the filter</returns>
+ /// <remarks>
+ /// <para>
+ /// If the decision is <see cref="FilterDecision.Deny"/>, then the event will be
+ /// dropped. If the decision is <see cref="FilterDecision.Neutral"/>, then the next
+ /// filter, if any, will be invoked. If the decision is <see cref="FilterDecision.Accept"/> then
+ /// the event will be logged without consulting with other filters in
+ /// the chain.
+ /// </para>
+ /// <para>
+ /// This method is marked <c>abstract</c> and must be implemented
+ /// in a subclass.
+ /// </para>
+ /// </remarks>
+ public abstract FilterDecision Decide(LoggingEvent loggingEvent);
- /// <summary>
- /// Property to get and set the next filter
- /// </summary>
- /// <value>
- /// The next filter in the chain
- /// </value>
- /// <remarks>
- /// <para>
- /// Filters are typically composed into chains. This property allows the next filter in
- /// the chain to be accessed.
- /// </para>
- /// </remarks>
- public IFilter Next
- {
- get { return m_next; }
- set { m_next = value; }
- }
+ /// <summary>
+ /// Property to get and set the next filter
+ /// </summary>
+ /// <value>
+ /// The next filter in the chain
+ /// </value>
+ /// <remarks>
+ /// <para>
+ /// Filters are typically composed into chains. This property allows the next filter in
+ /// the chain to be accessed.
+ /// </para>
+ /// </remarks>
+ public IFilter Next
+ {
+ get { return m_next; }
+ set { m_next = value; }
+ }
- #endregion
- }
+ #endregion
+ }
}
diff --git a/src/log4net/Filter/IFilter.cs b/src/log4net/Filter/IFilter.cs
index 8c597a7..66cc91b 100644
--- a/src/log4net/Filter/IFilter.cs
+++ b/src/log4net/Filter/IFilter.cs
@@ -23,80 +23,80 @@
namespace log4net.Filter
{
- /// <summary>
- /// Implement this interface to provide customized logging event filtering
- /// </summary>
- /// <remarks>
- /// <para>
- /// Users should implement this interface to implement customized logging
- /// event filtering. Note that <see cref="log4net.Repository.Hierarchy.Logger"/> and
- /// <see cref="log4net.Appender.AppenderSkeleton"/>, the parent class of all standard
- /// appenders, have built-in filtering rules. It is suggested that you
- /// first use and understand the built-in rules before rushing to write
- /// your own custom filters.
- /// </para>
- /// <para>
- /// This abstract class assumes and also imposes that filters be
- /// organized in a linear chain. The <see cref="Decide"/>
- /// method of each filter is called sequentially, in the order of their
- /// addition to the chain.
- /// </para>
- /// <para>
- /// The <see cref="Decide"/> method must return one
- /// of the integer constants <see cref="FilterDecision.Deny"/>,
- /// <see cref="FilterDecision.Neutral"/> or <see cref="FilterDecision.Accept"/>.
- /// </para>
- /// <para>
- /// If the value <see cref="FilterDecision.Deny"/> is returned, then the log event is dropped
- /// immediately without consulting with the remaining filters.
- /// </para>
- /// <para>
- /// If the value <see cref="FilterDecision.Neutral"/> is returned, then the next filter
- /// in the chain is consulted. If there are no more filters in the
- /// chain, then the log event is logged. Thus, in the presence of no
- /// filters, the default behavior is to log all logging events.
- /// </para>
- /// <para>
- /// If the value <see cref="FilterDecision.Accept"/> is returned, then the log
- /// event is logged without consulting the remaining filters.
- /// </para>
- /// <para>
- /// The philosophy of log4net filters is largely inspired from the
- /// Linux ipchains.
- /// </para>
- /// </remarks>
- /// <author>Nicko Cadell</author>
- /// <author>Gert Driesen</author>
- public interface IFilter : IOptionHandler
- {
- /// <summary>
- /// Decide if the logging event should be logged through an appender.
- /// </summary>
- /// <param name="loggingEvent">The LoggingEvent to decide upon</param>
- /// <returns>The decision of the filter</returns>
- /// <remarks>
- /// <para>
- /// If the decision is <see cref="FilterDecision.Deny"/>, then the event will be
- /// dropped. If the decision is <see cref="FilterDecision.Neutral"/>, then the next
- /// filter, if any, will be invoked. If the decision is <see cref="FilterDecision.Accept"/> then
- /// the event will be logged without consulting with other filters in
- /// the chain.
- /// </para>
- /// </remarks>
- FilterDecision Decide(LoggingEvent loggingEvent);
+ /// <summary>
+ /// Implement this interface to provide customized logging event filtering
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Users should implement this interface to implement customized logging
+ /// event filtering. Note that <see cref="log4net.Repository.Hierarchy.Logger"/> and
+ /// <see cref="log4net.Appender.AppenderSkeleton"/>, the parent class of all standard
+ /// appenders, have built-in filtering rules. It is suggested that you
+ /// first use and understand the built-in rules before rushing to write
+ /// your own custom filters.
+ /// </para>
+ /// <para>
+ /// This abstract class assumes and also imposes that filters be
+ /// organized in a linear chain. The <see cref="Decide"/>
+ /// method of each filter is called sequentially, in the order of their
+ /// addition to the chain.
+ /// </para>
+ /// <para>
+ /// The <see cref="Decide"/> method must return one
+ /// of the integer constants <see cref="FilterDecision.Deny"/>,
+ /// <see cref="FilterDecision.Neutral"/> or <see cref="FilterDecision.Accept"/>.
+ /// </para>
+ /// <para>
+ /// If the value <see cref="FilterDecision.Deny"/> is returned, then the log event is dropped
+ /// immediately without consulting with the remaining filters.
+ /// </para>
+ /// <para>
+ /// If the value <see cref="FilterDecision.Neutral"/> is returned, then the next filter
+ /// in the chain is consulted. If there are no more filters in the
+ /// chain, then the log event is logged. Thus, in the presence of no
+ /// filters, the default behavior is to log all logging events.
+ /// </para>
+ /// <para>
+ /// If the value <see cref="FilterDecision.Accept"/> is returned, then the log
+ /// event is logged without consulting the remaining filters.
+ /// </para>
+ /// <para>
+ /// The philosophy of log4net filters is largely inspired from the
+ /// Linux ipchains.
+ /// </para>
+ /// </remarks>
+ /// <author>Nicko Cadell</author>
+ /// <author>Gert Driesen</author>
+ public interface IFilter : IOptionHandler
+ {
+ /// <summary>
+ /// Decide if the logging event should be logged through an appender.
+ /// </summary>
+ /// <param name="loggingEvent">The LoggingEvent to decide upon</param>
+ /// <returns>The decision of the filter</returns>
+ /// <remarks>
+ /// <para>
+ /// If the decision is <see cref="FilterDecision.Deny"/>, then the event will be
+ /// dropped. If the decision is <see cref="FilterDecision.Neutral"/>, then the next
+ /// filter, if any, will be invoked. If the decision is <see cref="FilterDecision.Accept"/> then
+ /// the event will be logged without consulting with other filters in
+ /// the chain.
+ /// </para>
+ /// </remarks>
+ FilterDecision Decide(LoggingEvent loggingEvent);
- /// <summary>
- /// Property to get and set the next filter
- /// </summary>
- /// <value>
- /// The next filter in the chain
- /// </value>
- /// <remarks>
- /// <para>
- /// Filters are typically composed into chains. This property allows the next filter in
- /// the chain to be accessed.
- /// </para>
- /// </remarks>
- IFilter Next { get; set; }
- }
+ /// <summary>
+ /// Property to get and set the next filter
+ /// </summary>
+ /// <value>
+ /// The next filter in the chain
+ /// </value>
+ /// <remarks>
+ /// <para>
+ /// Filters are typically composed into chains. This property allows the next filter in
+ /// the chain to be accessed.
+ /// </para>
+ /// </remarks>
+ IFilter Next { get; set; }
+ }
}
diff --git a/src/log4net/Filter/LevelMatchFilter.cs b/src/log4net/Filter/LevelMatchFilter.cs
index 34a21b3..50d291f 100644
--- a/src/log4net/Filter/LevelMatchFilter.cs
+++ b/src/log4net/Filter/LevelMatchFilter.cs
@@ -25,118 +25,118 @@
namespace log4net.Filter
{
- /// <summary>
- /// This is a very simple filter based on <see cref="Level"/> matching.
- /// </summary>
- /// <remarks>
- /// <para>
- /// The filter admits two options <see cref="LevelToMatch"/> and
- /// <see cref="AcceptOnMatch"/>. If there is an exact match between the value
- /// of the <see cref="LevelToMatch"/> option and the <see cref="Level"/> of the
- /// <see cref="LoggingEvent"/>, then the <see cref="Decide"/> method returns <see cref="FilterDecision.Accept"/> in
- /// case the <see cref="AcceptOnMatch"/> option value is set
- /// to <c>true</c>, if it is <c>false</c> then
- /// <see cref="FilterDecision.Deny"/> is returned. If the <see cref="Level"/> does not match then
- /// the result will be <see cref="FilterDecision.Neutral"/>.
- /// </para>
- /// </remarks>
- /// <author>Nicko Cadell</author>
- /// <author>Gert Driesen</author>
- public class LevelMatchFilter : FilterSkeleton
- {
- #region Member Variables
+ /// <summary>
+ /// This is a very simple filter based on <see cref="Level"/> matching.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// The filter admits two options <see cref="LevelToMatch"/> and
+ /// <see cref="AcceptOnMatch"/>. If there is an exact match between the value
+ /// of the <see cref="LevelToMatch"/> option and the <see cref="Level"/> of the
+ /// <see cref="LoggingEvent"/>, then the <see cref="Decide"/> method returns <see cref="FilterDecision.Accept"/> in
+ /// case the <see cref="AcceptOnMatch"/> option value is set
+ /// to <c>true</c>, if it is <c>false</c> then
+ /// <see cref="FilterDecision.Deny"/> is returned. If the <see cref="Level"/> does not match then
+ /// the result will be <see cref="FilterDecision.Neutral"/>.
+ /// </para>
+ /// </remarks>
+ /// <author>Nicko Cadell</author>
+ /// <author>Gert Driesen</author>
+ public class LevelMatchFilter : FilterSkeleton
+ {
+ #region Member Variables
- /// <summary>
- /// flag to indicate if the filter should <see cref="FilterDecision.Accept"/> on a match
- /// </summary>
- private bool m_acceptOnMatch = true;
+ /// <summary>
+ /// flag to indicate if the filter should <see cref="FilterDecision.Accept"/> on a match
+ /// </summary>
+ private bool m_acceptOnMatch = true;
- /// <summary>
- /// the <see cref="Level"/> to match against
- /// </summary>
- private Level m_levelToMatch;
+ /// <summary>
+ /// the <see cref="Level"/> to match against
+ /// </summary>
+ private Level m_levelToMatch;
- #endregion
+ #endregion
- #region Constructors
+ #region Constructors
- /// <summary>
- /// Default constructor
- /// </summary>
- public LevelMatchFilter()
- {
- }
+ /// <summary>
+ /// Default constructor
+ /// </summary>
+ public LevelMatchFilter()
+ {
+ }
- #endregion
+ #endregion
- /// <summary>
- /// <see cref="FilterDecision.Accept"/> when matching <see cref="LevelToMatch"/>
- /// </summary>
- /// <remarks>
- /// <para>
- /// The <see cref="AcceptOnMatch"/> property is a flag that determines
- /// the behavior when a matching <see cref="Level"/> is found. If the
- /// flag is set to true then the filter will <see cref="FilterDecision.Accept"/> the
- /// logging event, otherwise it will <see cref="FilterDecision.Deny"/> the event.
- /// </para>
- /// <para>
- /// The default is <c>true</c> i.e. to <see cref="FilterDecision.Accept"/> the event.
- /// </para>
- /// </remarks>
- public bool AcceptOnMatch
- {
- get { return m_acceptOnMatch; }
- set { m_acceptOnMatch = value; }
- }
+ /// <summary>
+ /// <see cref="FilterDecision.Accept"/> when matching <see cref="LevelToMatch"/>
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// The <see cref="AcceptOnMatch"/> property is a flag that determines
+ /// the behavior when a matching <see cref="Level"/> is found. If the
+ /// flag is set to true then the filter will <see cref="FilterDecision.Accept"/> the
+ /// logging event, otherwise it will <see cref="FilterDecision.Deny"/> the event.
+ /// </para>
+ /// <para>
+ /// The default is <c>true</c> i.e. to <see cref="FilterDecision.Accept"/> the event.
+ /// </para>
+ /// </remarks>
+ public bool AcceptOnMatch
+ {
+ get { return m_acceptOnMatch; }
+ set { m_acceptOnMatch = value; }
+ }
- /// <summary>
- /// The <see cref="Level"/> that the filter will match
- /// </summary>
- /// <remarks>
- /// <para>
- /// The level that this filter will attempt to match against the
- /// <see cref="LoggingEvent"/> level. If a match is found then
- /// the result depends on the value of <see cref="AcceptOnMatch"/>.
- /// </para>
- /// </remarks>
- public Level LevelToMatch
- {
- get { return m_levelToMatch; }
- set { m_levelToMatch = value; }
- }
+ /// <summary>
+ /// The <see cref="Level"/> that the filter will match
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// The level that this filter will attempt to match against the
+ /// <see cref="LoggingEvent"/> level. If a match is found then
+ /// the result depends on the value of <see cref="AcceptOnMatch"/>.
+ /// </para>
+ /// </remarks>
+ public Level LevelToMatch
+ {
+ get { return m_levelToMatch; }
+ set { m_levelToMatch = value; }
+ }
- #region Override implementation of FilterSkeleton
+ #region Override implementation of FilterSkeleton
- /// <summary>
- /// Tests if the <see cref="Level"/> of the logging event matches that of the filter
- /// </summary>
- /// <param name="loggingEvent">the event to filter</param>
- /// <returns>see remarks</returns>
- /// <remarks>
- /// <para>
- /// If the <see cref="Level"/> of the event matches the level of the
- /// filter then the result of the function depends on the
- /// value of <see cref="AcceptOnMatch"/>. If it is true then
- /// the function will return <see cref="FilterDecision.Accept"/>, it it is false then it
- /// will return <see cref="FilterDecision.Deny"/>. If the <see cref="Level"/> does not match then
- /// the result will be <see cref="FilterDecision.Neutral"/>.
- /// </para>
- /// </remarks>
- public override FilterDecision Decide(LoggingEvent loggingEvent)
- {
- if (loggingEvent == null)
- {
- throw new ArgumentNullException("loggingEvent");
- }
+ /// <summary>
+ /// Tests if the <see cref="Level"/> of the logging event matches that of the filter
+ /// </summary>
+ /// <param name="loggingEvent">the event to filter</param>
+ /// <returns>see remarks</returns>
+ /// <remarks>
+ /// <para>
+ /// If the <see cref="Level"/> of the event matches the level of the
+ /// filter then the result of the function depends on the
+ /// value of <see cref="AcceptOnMatch"/>. If it is true then
+ /// the function will return <see cref="FilterDecision.Accept"/>, it it is false then it
+ /// will return <see cref="FilterDecision.Deny"/>. If the <see cref="Level"/> does not match then
+ /// the result will be <see cref="FilterDecision.Neutral"/>.
+ /// </para>
+ /// </remarks>
+ public override FilterDecision Decide(LoggingEvent loggingEvent)
+ {
+ if (loggingEvent == null)
+ {
+ throw new ArgumentNullException("loggingEvent");
+ }
- if (m_levelToMatch != null && m_levelToMatch == loggingEvent.Level)
- {
- // Found match
- return m_acceptOnMatch ? FilterDecision.Accept : FilterDecision.Deny;
- }
- return FilterDecision.Neutral;
- }
+ if (m_levelToMatch != null && m_levelToMatch == loggingEvent.Level)
+ {
+ // Found match
+ return m_acceptOnMatch ? FilterDecision.Accept : FilterDecision.Deny;
+ }
+ return FilterDecision.Neutral;
+ }
- #endregion
- }
+ #endregion
+ }
}
diff --git a/src/log4net/Filter/LevelRangeFilter.cs b/src/log4net/Filter/LevelRangeFilter.cs
index f6e0be0..e2bb676 100644
--- a/src/log4net/Filter/LevelRangeFilter.cs
+++ b/src/log4net/Filter/LevelRangeFilter.cs
@@ -25,161 +25,161 @@
namespace log4net.Filter
{
- /// <summary>
- /// This is a simple filter based on <see cref="Level"/> matching.
- /// </summary>
- /// <remarks>
- /// <para>
- /// The filter admits three options <see cref="LevelMin"/> and <see cref="LevelMax"/>
- /// that determine the range of priorities that are matched, and
- /// <see cref="AcceptOnMatch"/>. If there is a match between the range
- /// of priorities and the <see cref="Level"/> of the <see cref="LoggingEvent"/>, then the
- /// <see cref="Decide"/> method returns <see cref="FilterDecision.Accept"/> in case the <see cref="AcceptOnMatch"/>
- /// option value is set to <c>true</c>, if it is <c>false</c>
- /// then <see cref="FilterDecision.Deny"/> is returned. If there is no match, <see cref="FilterDecision.Deny"/> is returned.
- /// </para>
- /// </remarks>
- /// <author>Nicko Cadell</author>
- /// <author>Gert Driesen</author>
- public class LevelRangeFilter : FilterSkeleton
- {
- #region Member Variables
+ /// <summary>
+ /// This is a simple filter based on <see cref="Level"/> matching.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// The filter admits three options <see cref="LevelMin"/> and <see cref="LevelMax"/>
+ /// that determine the range of priorities that are matched, and
+ /// <see cref="AcceptOnMatch"/>. If there is a match between the range
+ /// of priorities and the <see cref="Level"/> of the <see cref="LoggingEvent"/>, then the
+ /// <see cref="Decide"/> method returns <see cref="FilterDecision.Accept"/> in case the <see cref="AcceptOnMatch"/>
+ /// option value is set to <c>true</c>, if it is <c>false</c>
+ /// then <see cref="FilterDecision.Deny"/> is returned. If there is no match, <see cref="FilterDecision.Deny"/> is returned.
+ /// </para>
+ /// </remarks>
+ /// <author>Nicko Cadell</author>
+ /// <author>Gert Driesen</author>
+ public class LevelRangeFilter : FilterSkeleton
+ {
+ #region Member Variables
- /// <summary>
- /// Flag to indicate the behavior when matching a <see cref="Level"/>
- /// </summary>
- private bool m_acceptOnMatch = true;
+ /// <summary>
+ /// Flag to indicate the behavior when matching a <see cref="Level"/>
+ /// </summary>
+ private bool m_acceptOnMatch = true;
- /// <summary>
- /// the minimum <see cref="Level"/> value to match
- /// </summary>
- private Level m_levelMin;
+ /// <summary>
+ /// the minimum <see cref="Level"/> value to match
+ /// </summary>
+ private Level m_levelMin;
- /// <summary>
- /// the maximum <see cref="Level"/> value to match
- /// </summary>
- private Level m_levelMax;
+ /// <summary>
+ /// the maximum <see cref="Level"/> value to match
+ /// </summary>
+ private Level m_levelMax;
- #endregion
+ #endregion
- #region Constructors
+ #region Constructors
- /// <summary>
- /// Default constructor
- /// </summary>
- public LevelRangeFilter()
- {
- }
+ /// <summary>
+ /// Default constructor
+ /// </summary>
+ public LevelRangeFilter()
+ {
+ }
- #endregion
+ #endregion
- /// <summary>
- /// <see cref="FilterDecision.Accept"/> when matching <see cref="LevelMin"/> and <see cref="LevelMax"/>
- /// </summary>
- /// <remarks>
- /// <para>
- /// The <see cref="AcceptOnMatch"/> property is a flag that determines
- /// the behavior when a matching <see cref="Level"/> is found. If the
- /// flag is set to true then the filter will <see cref="FilterDecision.Accept"/> the
- /// logging event, otherwise it will <see cref="FilterDecision.Neutral"/> the event.
- /// </para>
- /// <para>
- /// The default is <c>true</c> i.e. to <see cref="FilterDecision.Accept"/> the event.
- /// </para>
- /// </remarks>
- public bool AcceptOnMatch
- {
- get { return m_acceptOnMatch; }
- set { m_acceptOnMatch = value; }
- }
+ /// <summary>
+ /// <see cref="FilterDecision.Accept"/> when matching <see cref="LevelMin"/> and <see cref="LevelMax"/>
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// The <see cref="AcceptOnMatch"/> property is a flag that determines
+ /// the behavior when a matching <see cref="Level"/> is found. If the
+ /// flag is set to true then the filter will <see cref="FilterDecision.Accept"/> the
+ /// logging event, otherwise it will <see cref="FilterDecision.Neutral"/> the event.
+ /// </para>
+ /// <para>
+ /// The default is <c>true</c> i.e. to <see cref="FilterDecision.Accept"/> the event.
+ /// </para>
+ /// </remarks>
+ public bool AcceptOnMatch
+ {
+ get { return m_acceptOnMatch; }
+ set { m_acceptOnMatch = value; }
+ }
- /// <summary>
- /// Set the minimum matched <see cref="Level"/>
- /// </summary>
- /// <remarks>
- /// <para>
- /// The minimum level that this filter will attempt to match against the
- /// <see cref="LoggingEvent"/> level. If a match is found then
- /// the result depends on the value of <see cref="AcceptOnMatch"/>.
- /// </para>
- /// </remarks>
- public Level LevelMin
- {
- get { return m_levelMin; }
- set { m_levelMin = value; }
- }
+ /// <summary>
+ /// Set the minimum matched <see cref="Level"/>
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// The minimum level that this filter will attempt to match against the
+ /// <see cref="LoggingEvent"/> level. If a match is found then
+ /// the result depends on the value of <see cref="AcceptOnMatch"/>.
+ /// </para>
+ /// </remarks>
+ public Level LevelMin
+ {
+ get { return m_levelMin; }
+ set { m_levelMin = value; }
+ }
- /// <summary>
- /// Sets the maximum matched <see cref="Level"/>
- /// </summary>
- /// <remarks>
- /// <para>
- /// The maximum level that this filter will attempt to match against the
- /// <see cref="LoggingEvent"/> level. If a match is found then
- /// the result depends on the value of <see cref="AcceptOnMatch"/>.
- /// </para>
- /// </remarks>
- public Level LevelMax
- {
- get { return m_levelMax; }
- set { m_levelMax = value; }
- }
+ /// <summary>
+ /// Sets the maximum matched <see cref="Level"/>
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// The maximum level that this filter will attempt to match against the
+ /// <see cref="LoggingEvent"/> level. If a match is found then
+ /// the result depends on the value of <see cref="AcceptOnMatch"/>.
+ /// </para>
+ /// </remarks>
+ public Level LevelMax
+ {
+ get { return m_levelMax; }
+ set { m_levelMax = value; }
+ }
- #region Override implementation of FilterSkeleton
+ #region Override implementation of FilterSkeleton
- /// <summary>
- /// Check if the event should be logged.
- /// </summary>
- /// <param name="loggingEvent">the logging event to check</param>
- /// <returns>see remarks</returns>
- /// <remarks>
- /// <para>
- /// If the <see cref="Level"/> of the logging event is outside the range
- /// matched by this filter then <see cref="FilterDecision.Deny"/>
- /// is returned. If the <see cref="Level"/> is matched then the value of
- /// <see cref="AcceptOnMatch"/> is checked. If it is true then
- /// <see cref="FilterDecision.Accept"/> is returned, otherwise
- /// <see cref="FilterDecision.Neutral"/> is returned.
- /// </para>
- /// </remarks>
- public override FilterDecision Decide(LoggingEvent loggingEvent)
- {
- if (loggingEvent == null)
- {
- throw new ArgumentNullException("loggingEvent");
- }
+ /// <summary>
+ /// Check if the event should be logged.
+ /// </summary>
+ /// <param name="loggingEvent">the logging event to check</param>
+ /// <returns>see remarks</returns>
+ /// <remarks>
+ /// <para>
+ /// If the <see cref="Level"/> of the logging event is outside the range
+ /// matched by this filter then <see cref="FilterDecision.Deny"/>
+ /// is returned. If the <see cref="Level"/> is matched then the value of
+ /// <see cref="AcceptOnMatch"/> is checked. If it is true then
+ /// <see cref="FilterDecision.Accept"/> is returned, otherwise
+ /// <see cref="FilterDecision.Neutral"/> is returned.
+ /// </para>
+ /// </remarks>
+ public override FilterDecision Decide(LoggingEvent loggingEvent)
+ {
+ if (loggingEvent == null)
+ {
+ throw new ArgumentNullException("loggingEvent");
+ }
- if (m_levelMin != null)
- {
- if (loggingEvent.Level < m_levelMin)
- {
- // level of event is less than minimum
- return FilterDecision.Deny;
- }
- }
+ if (m_levelMin != null)
+ {
+ if (loggingEvent.Level < m_levelMin)
+ {
+ // level of event is less than minimum
+ return FilterDecision.Deny;
+ }
+ }
- if (m_levelMax != null)
- {
- if (loggingEvent.Level > m_levelMax)
- {
- // level of event is greater than maximum
- return FilterDecision.Deny;
- }
- }
+ if (m_levelMax != null)
+ {
+ if (loggingEvent.Level > m_levelMax)
+ {
+ // level of event is greater than maximum
+ return FilterDecision.Deny;
+ }
+ }
- if (m_acceptOnMatch)
- {
- // this filter set up to bypass later filters and always return
- // accept if level in range
- return FilterDecision.Accept;
- }
- else
- {
- // event is ok for this filter; allow later filters to have a look..
- return FilterDecision.Neutral;
- }
- }
+ if (m_acceptOnMatch)
+ {
+ // this filter set up to bypass later filters and always return
+ // accept if level in range
+ return FilterDecision.Accept;
+ }
+ else
+ {
+ // event is ok for this filter; allow later filters to have a look..
+ return FilterDecision.Neutral;
+ }
+ }
- #endregion
- }
+ #endregion
+ }
}
diff --git a/src/log4net/Filter/LoggerMatchFilter.cs b/src/log4net/Filter/LoggerMatchFilter.cs
index 28264ec..0bc5e65 100644
--- a/src/log4net/Filter/LoggerMatchFilter.cs
+++ b/src/log4net/Filter/LoggerMatchFilter.cs
@@ -25,136 +25,136 @@
namespace log4net.Filter
{
- /// <summary>
- /// Simple filter to match a string in the event's logger name.
- /// </summary>
- /// <remarks>
- /// <para>
- /// The works very similar to the <see cref="LevelMatchFilter"/>. It admits two
- /// options <see cref="LoggerToMatch"/> and <see cref="AcceptOnMatch"/>. If the
- /// <see cref="LoggingEvent.LoggerName"/> of the <see cref="LoggingEvent"/> starts
- /// with the value of the <see cref="LoggerToMatch"/> option, then the
- /// <see cref="Decide"/> method returns <see cref="FilterDecision.Accept"/> in
- /// case the <see cref="AcceptOnMatch"/> option value is set to <c>true</c>,
- /// if it is <c>false</c> then <see cref="FilterDecision.Deny"/> is returned.
- /// </para>
- /// </remarks>
- /// <author>Daniel Cazzulino</author>
- public class LoggerMatchFilter : FilterSkeleton
- {
- #region Member Variables
+ /// <summary>
+ /// Simple filter to match a string in the event's logger name.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// The works very similar to the <see cref="LevelMatchFilter"/>. It admits two
+ /// options <see cref="LoggerToMatch"/> and <see cref="AcceptOnMatch"/>. If the
+ /// <see cref="LoggingEvent.LoggerName"/> of the <see cref="LoggingEvent"/> starts
+ /// with the value of the <see cref="LoggerToMatch"/> option, then the
+ /// <see cref="Decide"/> method returns <see cref="FilterDecision.Accept"/> in
+ /// case the <see cref="AcceptOnMatch"/> option value is set to <c>true</c>,
+ /// if it is <c>false</c> then <see cref="FilterDecision.Deny"/> is returned.
+ /// </para>
+ /// </remarks>
+ /// <author>Daniel Cazzulino</author>
+ public class LoggerMatchFilter : FilterSkeleton
+ {
+ #region Member Variables
- /// <summary>
- /// Flag to indicate the behavior when we have a match
- /// </summary>
- private bool m_acceptOnMatch = true;
+ /// <summary>
+ /// Flag to indicate the behavior when we have a match
+ /// </summary>
+ private bool m_acceptOnMatch = true;
- /// <summary>
- /// The logger name string to substring match against the event
- /// </summary>
- private string m_loggerToMatch;
+ /// <summary>
+ /// The logger name string to substring match against the event
+ /// </summary>
+ private string m_loggerToMatch;
- #endregion
+ #endregion
- #region Constructors
+ #region Constructors
- /// <summary>
- /// Default constructor
- /// </summary>
- public LoggerMatchFilter()
- {
- }
+ /// <summary>
+ /// Default constructor
+ /// </summary>
+ public LoggerMatchFilter()
+ {
+ }
- #endregion
+ #endregion
- #region Properties
+ #region Properties
- /// <summary>
- /// <see cref="FilterDecision.Accept"/> when matching <see cref="LoggerToMatch"/>
- /// </summary>
- /// <remarks>
- /// <para>
- /// The <see cref="AcceptOnMatch"/> property is a flag that determines
- /// the behavior when a matching <see cref="Level"/> is found. If the
- /// flag is set to true then the filter will <see cref="FilterDecision.Accept"/> the
- /// logging event, otherwise it will <see cref="FilterDecision.Deny"/> the event.
- /// </para>
- /// <para>
- /// The default is <c>true</c> i.e. to <see cref="FilterDecision.Accept"/> the event.
- /// </para>
- /// </remarks>
- public bool AcceptOnMatch
- {
- get { return m_acceptOnMatch; }
- set { m_acceptOnMatch = value; }
- }
+ /// <summary>
+ /// <see cref="FilterDecision.Accept"/> when matching <see cref="LoggerToMatch"/>
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// The <see cref="AcceptOnMatch"/> property is a flag that determines
+ /// the behavior when a matching <see cref="Level"/> is found. If the
+ /// flag is set to true then the filter will <see cref="FilterDecision.Accept"/> the
+ /// logging event, otherwise it will <see cref="FilterDecision.Deny"/> the event.
+ /// </para>
+ /// <para>
+ /// The default is <c>true</c> i.e. to <see cref="FilterDecision.Accept"/> the event.
+ /// </para>
+ /// </remarks>
+ public bool AcceptOnMatch
+ {
+ get { return m_acceptOnMatch; }
+ set { m_acceptOnMatch = value; }
+ }
- /// <summary>
- /// The <see cref="LoggingEvent.LoggerName"/> that the filter will match
- /// </summary>
- /// <remarks>
- /// <para>
- /// This filter will attempt to match this value against logger name in
- /// the following way. The match will be done against the beginning of the
- /// logger name (using <see cref="M:String.StartsWith(string)"/>). The match is
- /// case sensitive. If a match is found then
- /// the result depends on the value of <see cref="AcceptOnMatch"/>.
- /// </para>
- /// </remarks>
- public string LoggerToMatch
- {
- get { return m_loggerToMatch; }
- set { m_loggerToMatch = value; }
- }
+ /// <summary>
+ /// The <see cref="LoggingEvent.LoggerName"/> that the filter will match
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// This filter will attempt to match this value against logger name in
+ /// the following way. The match will be done against the beginning of the
+ /// logger name (using <see cref="M:String.StartsWith(string)"/>). The match is
+ /// case sensitive. If a match is found then
+ /// the result depends on the value of <see cref="AcceptOnMatch"/>.
+ /// </para>
+ /// </remarks>
+ public string LoggerToMatch
+ {
+ get { return m_loggerToMatch; }
+ set { m_loggerToMatch = value; }
+ }
- #endregion
+ #endregion
- #region Override implementation of FilterSkeleton
+ #region Override implementation of FilterSkeleton
- /// <summary>
- /// Check if this filter should allow the event to be logged
- /// </summary>
- /// <param name="loggingEvent">the event being logged</param>
- /// <returns>see remarks</returns>
- /// <remarks>
- /// <para>
- /// The rendered message is matched against the <see cref="LoggerToMatch"/>.
- /// If the <see cref="LoggerToMatch"/> equals the beginning of
- /// the incoming <see cref="LoggingEvent.LoggerName"/> (<see cref="M:String.StartsWith(string)"/>)
- /// then a match will have occurred. If no match occurs
- /// this function will return <see cref="FilterDecision.Neutral"/>
- /// allowing other filters to check the event. If a match occurs then
- /// the value of <see cref="AcceptOnMatch"/> is checked. If it is
- /// true then <see cref="FilterDecision.Accept"/> is returned otherwise
- /// <see cref="FilterDecision.Deny"/> is returned.
- /// </para>
- /// </remarks>
- public override FilterDecision Decide(LoggingEvent loggingEvent)
- {
- if (loggingEvent == null)
- {
- throw new ArgumentNullException("loggingEvent");
- }
+ /// <summary>
+ /// Check if this filter should allow the event to be logged
+ /// </summary>
+ /// <param name="loggingEvent">the event being logged</param>
+ /// <returns>see remarks</returns>
+ /// <remarks>
+ /// <para>
+ /// The rendered message is matched against the <see cref="LoggerToMatch"/>.
+ /// If the <see cref="LoggerToMatch"/> equals the beginning of
+ /// the incoming <see cref="LoggingEvent.LoggerName"/> (<see cref="M:String.StartsWith(string)"/>)
+ /// then a match will have occurred. If no match occurs
+ /// this function will return <see cref="FilterDecision.Neutral"/>
+ /// allowing other filters to check the event. If a match occurs then
+ /// the value of <see cref="AcceptOnMatch"/> is checked. If it is
+ /// true then <see cref="FilterDecision.Accept"/> is returned otherwise
+ /// <see cref="FilterDecision.Deny"/> is returned.
+ /// </para>
+ /// </remarks>
+ public override FilterDecision Decide(LoggingEvent loggingEvent)
+ {
+ if (loggingEvent == null)
+ {
+ throw new ArgumentNullException("loggingEvent");
+ }
- // Check if we have been setup to filter
- if ((m_loggerToMatch != null && m_loggerToMatch.Length != 0) &&
- loggingEvent.LoggerName.StartsWith(m_loggerToMatch))
- {
- // we've got a match
- if (m_acceptOnMatch)
- {
- return FilterDecision.Accept;
- }
- return FilterDecision.Deny;
- }
- else
- {
- // We cannot filter so allow the filter chain
- // to continue processing
- return FilterDecision.Neutral;
- }
- }
+ // Check if we have been setup to filter
+ if ((m_loggerToMatch != null && m_loggerToMatch.Length != 0) &&
+ loggingEvent.LoggerName.StartsWith(m_loggerToMatch))
+ {
+ // we've got a match
+ if (m_acceptOnMatch)
+ {
+ return FilterDecision.Accept;
+ }
+ return FilterDecision.Deny;
+ }
+ else
+ {
+ // We cannot filter so allow the filter chain
+ // to continue processing
+ return FilterDecision.Neutral;
+ }
+ }
- #endregion
- }
+ #endregion
+ }
}
diff --git a/src/log4net/Filter/MdcFilter.cs b/src/log4net/Filter/MdcFilter.cs
index 3ca7953..adfa6ef 100644
--- a/src/log4net/Filter/MdcFilter.cs
+++ b/src/log4net/Filter/MdcFilter.cs
@@ -26,22 +26,22 @@
namespace log4net.Filter
{
- /// <summary>
- /// Simple filter to match a keyed string in the <see cref="MDC"/>
- /// </summary>
- /// <remarks>
- /// <para>
- /// Simple filter to match a keyed string in the <see cref="MDC"/>
- /// </para>
- /// <para>
- /// As the MDC has been replaced with layered properties the
- /// <see cref="PropertyFilter"/> should be used instead.
- /// </para>
- /// </remarks>
- /// <author>Nicko Cadell</author>
- /// <author>Gert Driesen</author>
- /*[Obsolete("MdcFilter has been replaced by PropertyFilter")]*/
- public class MdcFilter : PropertyFilter
- {
- }
+ /// <summary>
+ /// Simple filter to match a keyed string in the <see cref="MDC"/>
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Simple filter to match a keyed string in the <see cref="MDC"/>
+ /// </para>
+ /// <para>
+ /// As the MDC has been replaced with layered properties the
+ /// <see cref="PropertyFilter"/> should be used instead.
+ /// </para>
+ /// </remarks>
+ /// <author>Nicko Cadell</author>
+ /// <author>Gert Driesen</author>
+ /*[Obsolete("MdcFilter has been replaced by PropertyFilter")]*/
+ public class MdcFilter : PropertyFilter
+ {
+ }
}
diff --git a/src/log4net/Filter/NdcFilter.cs b/src/log4net/Filter/NdcFilter.cs
index e1659fe..4b0a3e0 100644
--- a/src/log4net/Filter/NdcFilter.cs
+++ b/src/log4net/Filter/NdcFilter.cs
@@ -26,35 +26,35 @@
namespace log4net.Filter
{
- /// <summary>
- /// Simple filter to match a string in the <see cref="NDC"/>
- /// </summary>
- /// <remarks>
- /// <para>
- /// Simple filter to match a string in the <see cref="NDC"/>
- /// </para>
- /// <para>
- /// As the MDC has been replaced with named stacks stored in the
- /// properties collections the <see cref="PropertyFilter"/> should
- /// be used instead.
- /// </para>
- /// </remarks>
- /// <author>Nicko Cadell</author>
- /// <author>Gert Driesen</author>
- /*[Obsolete("NdcFilter has been replaced by PropertyFilter")]*/
- public class NdcFilter : PropertyFilter
- {
- /// <summary>
- /// Default constructor
- /// </summary>
- /// <remarks>
- /// <para>
- /// Sets the <see cref="PropertyFilter.Key"/> to <c>"NDC"</c>.
- /// </para>
- /// </remarks>
- public NdcFilter()
- {
- base.Key = "NDC";
- }
- }
+ /// <summary>
+ /// Simple filter to match a string in the <see cref="NDC"/>
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Simple filter to match a string in the <see cref="NDC"/>
+ /// </para>
+ /// <para>
+ /// As the MDC has been replaced with named stacks stored in the
+ /// properties collections the <see cref="PropertyFilter"/> should
+ /// be used instead.
+ /// </para>
+ /// </remarks>
+ /// <author>Nicko Cadell</author>
+ /// <author>Gert Driesen</author>
+ /*[Obsolete("NdcFilter has been replaced by PropertyFilter")]*/
+ public class NdcFilter : PropertyFilter
+ {
+ /// <summary>
+ /// Default constructor
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Sets the <see cref="PropertyFilter.Key"/> to <c>"NDC"</c>.
+ /// </para>
+ /// </remarks>
+ public NdcFilter()
+ {
+ base.Key = "NDC";
+ }
+ }
}
diff --git a/src/log4net/Filter/PropertyFilter.cs b/src/log4net/Filter/PropertyFilter.cs
index a74a03b..b8815d1 100644
--- a/src/log4net/Filter/PropertyFilter.cs
+++ b/src/log4net/Filter/PropertyFilter.cs
@@ -26,140 +26,140 @@
namespace log4net.Filter
{
- /// <summary>
- /// Simple filter to match a string an event property
- /// </summary>
- /// <remarks>
- /// <para>
- /// Simple filter to match a string in the value for a
- /// specific event property
- /// </para>
- /// </remarks>
- /// <author>Nicko Cadell</author>
- public class PropertyFilter : StringMatchFilter
- {
- #region Member Variables
+ /// <summary>
+ /// Simple filter to match a string an event property
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Simple filter to match a string in the value for a
+ /// specific event property
+ /// </para>
+ /// </remarks>
+ /// <author>Nicko Cadell</author>
+ public class PropertyFilter : StringMatchFilter
+ {
+ #region Member Variables
- /// <summary>
- /// The key to use to lookup the string from the event properties
- /// </summary>
- private string m_key;
+ /// <summary>
+ /// The key to use to lookup the string from the event properties
+ /// </summary>
+ private string m_key;
- #endregion
+ #endregion
- #region Constructors
+ #region Constructors
- /// <summary>
- /// Default constructor
- /// </summary>
- public PropertyFilter()
- {
- }
+ /// <summary>
+ /// Default constructor
+ /// </summary>
+ public PropertyFilter()
+ {
+ }
- #endregion
+ #endregion
- /// <summary>
- /// The key to lookup in the event properties and then match against.
- /// </summary>
- /// <remarks>
- /// <para>
- /// The key name to use to lookup in the properties map of the
- /// <see cref="LoggingEvent"/>. The match will be performed against
- /// the value of this property if it exists.
- /// </para>
- /// </remarks>
- public string Key
- {
- get { return m_key; }
- set { m_key = value; }
- }
+ /// <summary>
+ /// The key to lookup in the event properties and then match against.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// The key name to use to lookup in the properties map of the
+ /// <see cref="LoggingEvent"/>. The match will be performed against
+ /// the value of this property if it exists.
+ /// </para>
+ /// </remarks>
+ public string Key
+ {
+ get { return m_key; }
+ set { m_key = value; }
+ }
- #region Override implementation of FilterSkeleton
+ #region Override implementation of FilterSkeleton
- /// <summary>
- /// Check if this filter should allow the event to be logged
- /// </summary>
- /// <param name="loggingEvent">the event being logged</param>
- /// <returns>see remarks</returns>
- /// <remarks>
- /// <para>
- /// The event property for the <see cref="Key"/> is matched against
- /// the <see cref="StringMatchFilter.StringToMatch"/>.
- /// If the <see cref="StringMatchFilter.StringToMatch"/> occurs as a substring within
- /// the property value then a match will have occurred. If no match occurs
- /// this function will return <see cref="FilterDecision.Neutral"/>
- /// allowing other filters to check the event. If a match occurs then
- /// the value of <see cref="StringMatchFilter.AcceptOnMatch"/> is checked. If it is
- /// true then <see cref="FilterDecision.Accept"/> is returned otherwise
- /// <see cref="FilterDecision.Deny"/> is returned.
- /// </para>
- /// </remarks>
- public override FilterDecision Decide(LoggingEvent loggingEvent)
- {
- if (loggingEvent == null)
- {
- throw new ArgumentNullException("loggingEvent");
- }
+ /// <summary>
+ /// Check if this filter should allow the event to be logged
+ /// </summary>
+ /// <param name="loggingEvent">the event being logged</param>
+ /// <returns>see remarks</returns>
+ /// <remarks>
+ /// <para>
+ /// The event property for the <see cref="Key"/> is matched against
+ /// the <see cref="StringMatchFilter.StringToMatch"/>.
+ /// If the <see cref="StringMatchFilter.StringToMatch"/> occurs as a substring within
+ /// the property value then a match will have occurred. If no match occurs
+ /// this function will return <see cref="FilterDecision.Neutral"/>
+ /// allowing other filters to check the event. If a match occurs then
+ /// the value of <see cref="StringMatchFilter.AcceptOnMatch"/> is checked. If it is
+ /// true then <see cref="FilterDecision.Accept"/> is returned otherwise
+ /// <see cref="FilterDecision.Deny"/> is returned.
+ /// </para>
+ /// </remarks>
+ public override FilterDecision Decide(LoggingEvent loggingEvent)
+ {
+ if (loggingEvent == null)
+ {
+ throw new ArgumentNullException("loggingEvent");
+ }
- // Check if we have a key to lookup the event property value with
- if (m_key == null)
- {
- // We cannot filter so allow the filter chain
- // to continue processing
- return FilterDecision.Neutral;
- }
+ // Check if we have a key to lookup the event property value with
+ if (m_key == null)
+ {
+ // We cannot filter so allow the filter chain
+ // to continue processing
+ return FilterDecision.Neutral;
+ }
- // Lookup the string to match in from the properties using
- // the key specified.
- object msgObj = loggingEvent.LookupProperty(m_key);
+ // Lookup the string to match in from the properties using
+ // the key specified.
+ object msgObj = loggingEvent.LookupProperty(m_key);
- // Use an ObjectRenderer to convert the property value to a string
- string msg = loggingEvent.Repository.RendererMap.FindAndRender(msgObj);
+ // Use an ObjectRenderer to convert the property value to a string
+ string msg = loggingEvent.Repository.RendererMap.FindAndRender(msgObj);
- // Check if we have been setup to filter
- if (msg == null || (m_stringToMatch == null && m_regexToMatch == null))
- {
- // We cannot filter so allow the filter chain
- // to continue processing
- return FilterDecision.Neutral;
- }
+ // Check if we have been setup to filter
+ if (msg == null || (m_stringToMatch == null && m_regexToMatch == null))
+ {
+ // We cannot filter so allow the filter chain
+ // to continue processing
+ return FilterDecision.Neutral;
+ }
- // Firstly check if we are matching using a regex
- if (m_regexToMatch != null)
- {
- // Check the regex
- if (m_regexToMatch.Match(msg).Success == false)
- {
- // No match, continue processing
- return FilterDecision.Neutral;
- }
+ // Firstly check if we are matching using a regex
+ if (m_regexToMatch != null)
+ {
+ // Check the regex
+ if (m_regexToMatch.Match(msg).Success == false)
+ {
+ // No match, continue processing
+ return FilterDecision.Neutral;
+ }
- // we've got a match
- if (m_acceptOnMatch)
- {
- return FilterDecision.Accept;
- }
- return FilterDecision.Deny;
- }
- else if (m_stringToMatch != null)
- {
- // Check substring match
- if (msg.IndexOf(m_stringToMatch) == -1)
- {
- // No match, continue processing
- return FilterDecision.Neutral;
- }
+ // we've got a match
+ if (m_acceptOnMatch)
+ {
+ return FilterDecision.Accept;
+ }
+ return FilterDecision.Deny;
+ }
+ else if (m_stringToMatch != null)
+ {
+ // Check substring match
+ if (msg.IndexOf(m_stringToMatch) == -1)
+ {
+ // No match, continue processing
+ return FilterDecision.Neutral;
+ }
- // we've got a match
- if (m_acceptOnMatch)
- {
- return FilterDecision.Accept;
- }
- return FilterDecision.Deny;
- }
- return FilterDecision.Neutral;
- }
+ // we've got a match
+ if (m_acceptOnMatch)
+ {
+ return FilterDecision.Accept;
+ }
+ return FilterDecision.Deny;
+ }
+ return FilterDecision.Neutral;
+ }
- #endregion
- }
+ #endregion
+ }
}
diff --git a/src/log4net/Filter/StringMatchFilter.cs b/src/log4net/Filter/StringMatchFilter.cs
index 840a95d..b269586 100644
--- a/src/log4net/Filter/StringMatchFilter.cs
+++ b/src/log4net/Filter/StringMatchFilter.cs
@@ -26,220 +26,220 @@
namespace log4net.Filter
{
- /// <summary>
- /// Simple filter to match a string in the rendered message
- /// </summary>
- /// <remarks>
- /// <para>
- /// Simple filter to match a string in the rendered message
- /// </para>
- /// </remarks>
- /// <author>Nicko Cadell</author>
- /// <author>Gert Driesen</author>
- public class StringMatchFilter : FilterSkeleton
- {
- #region Member Variables
+ /// <summary>
+ /// Simple filter to match a string in the rendered message
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Simple filter to match a string in the rendered message
+ /// </para>
+ /// </remarks>
+ /// <author>Nicko Cadell</author>
+ /// <author>Gert Driesen</author>
+ public class StringMatchFilter : FilterSkeleton
+ {
+ #region Member Variables
- /// <summary>
- /// Flag to indicate the behavior when we have a match
- /// </summary>
- protected bool m_acceptOnMatch = true;
+ /// <summary>
+ /// Flag to indicate the behavior when we have a match
+ /// </summary>
+ protected bool m_acceptOnMatch = true;
- /// <summary>
- /// The string to substring match against the message
- /// </summary>
- protected string m_stringToMatch;
+ /// <summary>
+ /// The string to substring match against the message
+ /// </summary>
+ protected string m_stringToMatch;
- /// <summary>
- /// A string regex to match
- /// </summary>
- protected string m_stringRegexToMatch;
+ /// <summary>
+ /// A string regex to match
+ /// </summary>
+ protected string m_stringRegexToMatch;
- /// <summary>
- /// A regex object to match (generated from m_stringRegexToMatch)
- /// </summary>
- protected Regex m_regexToMatch;
+ /// <summary>
+ /// A regex object to match (generated from m_stringRegexToMatch)
+ /// </summary>
+ protected Regex m_regexToMatch;
- #endregion
+ #endregion
- #region Constructors
+ #region Constructors
- /// <summary>
- /// Default constructor
- /// </summary>
- public StringMatchFilter()
- {
- }
+ /// <summary>
+ /// Default constructor
+ /// </summary>
+ public StringMatchFilter()
+ {
+ }
- #endregion
+ #endregion
- #region Implementation of IOptionHandler
+ #region Implementation of IOptionHandler
- /// <summary>
- /// Initialize and precompile the Regex if required
- /// </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>
- public override void ActivateOptions()
- {
- if (m_stringRegexToMatch != null)
- {
+ /// <summary>
+ /// Initialize and precompile the Regex if required
+ /// </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>
+ public override void ActivateOptions()
+ {
+ if (m_stringRegexToMatch != null)
+ {
#if NETSTANDARD1_3
- m_regexToMatch = new Regex(m_stringRegexToMatch);
+ m_regexToMatch = new Regex(m_stringRegexToMatch);
#else
- m_regexToMatch = new Regex(m_stringRegexToMatch, RegexOptions.Compiled);
+ m_regexToMatch = new Regex(m_stringRegexToMatch, RegexOptions.Compiled);
#endif
- }
- }
+ }
+ }
- #endregion
+ #endregion
- /// <summary>
- /// <see cref="FilterDecision.Accept"/> when matching <see cref="StringToMatch"/> or <see cref="RegexToMatch"/>
- /// </summary>
- /// <remarks>
- /// <para>
- /// The <see cref="AcceptOnMatch"/> property is a flag that determines
- /// the behavior when a matching <see cref="Level"/> is found. If the
- /// flag is set to true then the filter will <see cref="FilterDecision.Accept"/> the
- /// logging event, otherwise it will <see cref="FilterDecision.Neutral"/> the event.
- /// </para>
- /// <para>
- /// The default is <c>true</c> i.e. to <see cref="FilterDecision.Accept"/> the event.
- /// </para>
- /// </remarks>
- public bool AcceptOnMatch
- {
- get { return m_acceptOnMatch; }
- set { m_acceptOnMatch = value; }
- }
+ /// <summary>
+ /// <see cref="FilterDecision.Accept"/> when matching <see cref="StringToMatch"/> or <see cref="RegexToMatch"/>
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// The <see cref="AcceptOnMatch"/> property is a flag that determines
+ /// the behavior when a matching <see cref="Level"/> is found. If the
+ /// flag is set to true then the filter will <see cref="FilterDecision.Accept"/> the
+ /// logging event, otherwise it will <see cref="FilterDecision.Neutral"/> the event.
+ /// </para>
+ /// <para>
+ /// The default is <c>true</c> i.e. to <see cref="FilterDecision.Accept"/> the event.
+ /// </para>
+ /// </remarks>
+ public bool AcceptOnMatch
+ {
+ get { return m_acceptOnMatch; }
+ set { m_acceptOnMatch = value; }
+ }
- /// <summary>
- /// Sets the static string to match
- /// </summary>
- /// <remarks>
- /// <para>
- /// The string that will be substring matched against
- /// the rendered message. If the message contains this
- /// string then the filter will match. If a match is found then
- /// the result depends on the value of <see cref="AcceptOnMatch"/>.
- /// </para>
- /// <para>
- /// One of <see cref="StringToMatch"/> or <see cref="RegexToMatch"/>
- /// must be specified.
- /// </para>
- /// </remarks>
- public string StringToMatch
- {
- get { return m_stringToMatch; }
- set { m_stringToMatch = value; }
- }
+ /// <summary>
+ /// Sets the static string to match
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// The string that will be substring matched against
+ /// the rendered message. If the message contains this
+ /// string then the filter will match. If a match is found then
+ /// the result depends on the value of <see cref="AcceptOnMatch"/>.
+ /// </para>
+ /// <para>
+ /// One of <see cref="StringToMatch"/> or <see cref="RegexToMatch"/>
+ /// must be specified.
+ /// </para>
+ /// </remarks>
+ public string StringToMatch
+ {
+ get { return m_stringToMatch; }
+ set { m_stringToMatch = value; }
+ }
- /// <summary>
- /// Sets the regular expression to match
- /// </summary>
- /// <remarks>
- /// <para>
- /// The regular expression pattern that will be matched against
- /// the rendered message. If the message matches this
- /// pattern then the filter will match. If a match is found then
- /// the result depends on the value of <see cref="AcceptOnMatch"/>.
- /// </para>
- /// <para>
- /// One of <see cref="StringToMatch"/> or <see cref="RegexToMatch"/>
- /// must be specified.
- /// </para>
- /// </remarks>
- public string RegexToMatch
- {
- get { return m_stringRegexToMatch; }
- set { m_stringRegexToMatch = value; }
- }
+ /// <summary>
+ /// Sets the regular expression to match
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// The regular expression pattern that will be matched against
+ /// the rendered message. If the message matches this
+ /// pattern then the filter will match. If a match is found then
+ /// the result depends on the value of <see cref="AcceptOnMatch"/>.
+ /// </para>
+ /// <para>
+ /// One of <see cref="StringToMatch"/> or <see cref="RegexToMatch"/>
+ /// must be specified.
+ /// </para>
+ /// </remarks>
+ public string RegexToMatch
+ {
+ get { return m_stringRegexToMatch; }
+ set { m_stringRegexToMatch = value; }
+ }
- #region Override implementation of FilterSkeleton
+ #region Override implementation of FilterSkeleton
- /// <summary>
- /// Check if this filter should allow the event to be logged
- /// </summary>
- /// <param name="loggingEvent">the event being logged</param>
- /// <returns>see remarks</returns>
- /// <remarks>
- /// <para>
- /// The rendered message is matched against the <see cref="StringToMatch"/>.
- /// If the <see cref="StringToMatch"/> occurs as a substring within
- /// the message then a match will have occurred. If no match occurs
- /// this function will return <see cref="FilterDecision.Neutral"/>
- /// allowing other filters to check the event. If a match occurs then
- /// the value of <see cref="AcceptOnMatch"/> is checked. If it is
- /// true then <see cref="FilterDecision.Accept"/> is returned otherwise
- /// <see cref="FilterDecision.Deny"/> is returned.
- /// </para>
- /// </remarks>
- public override FilterDecision Decide(LoggingEvent loggingEvent)
- {
- if (loggingEvent == null)
- {
- throw new ArgumentNullException("loggingEvent");
- }
+ /// <summary>
+ /// Check if this filter should allow the event to be logged
+ /// </summary>
+ /// <param name="loggingEvent">the event being logged</param>
+ /// <returns>see remarks</returns>
+ /// <remarks>
+ /// <para>
+ /// The rendered message is matched against the <see cref="StringToMatch"/>.
+ /// If the <see cref="StringToMatch"/> occurs as a substring within
+ /// the message then a match will have occurred. If no match occurs
+ /// this function will return <see cref="FilterDecision.Neutral"/>
+ /// allowing other filters to check the event. If a match occurs then
+ /// the value of <see cref="AcceptOnMatch"/> is checked. If it is
+ /// true then <see cref="FilterDecision.Accept"/> is returned otherwise
+ /// <see cref="FilterDecision.Deny"/> is returned.
+ /// </para>
+ /// </remarks>
+ public override FilterDecision Decide(LoggingEvent loggingEvent)
+ {
+ if (loggingEvent == null)
+ {
+ throw new ArgumentNullException("loggingEvent");
+ }
- string msg = loggingEvent.RenderedMessage;
+ string msg = loggingEvent.RenderedMessage;
- // Check if we have been setup to filter
- if (msg == null || (m_stringToMatch == null && m_regexToMatch == null))
- {
- // We cannot filter so allow the filter chain
- // to continue processing
- return FilterDecision.Neutral;
- }
+ // Check if we have been setup to filter
+ if (msg == null || (m_stringToMatch == null && m_regexToMatch == null))
+ {
+ // We cannot filter so allow the filter chain
+ // to continue processing
+ return FilterDecision.Neutral;
+ }
- // Firstly check if we are matching using a regex
- if (m_regexToMatch != null)
- {
- // Check the regex
- if (m_regexToMatch.Match(msg).Success == false)
- {
- // No match, continue processing
- return FilterDecision.Neutral;
- }
+ // Firstly check if we are matching using a regex
+ if (m_regexToMatch != null)
+ {
+ // Check the regex
+ if (m_regexToMatch.Match(msg).Success == false)
+ {
+ // No match, continue processing
+ return FilterDecision.Neutral;
+ }
- // we've got a match
- if (m_acceptOnMatch)
- {
- return FilterDecision.Accept;
- }
- return FilterDecision.Deny;
- }
- else if (m_stringToMatch != null)
- {
- // Check substring match
- if (msg.IndexOf(m_stringToMatch) == -1)
- {
- // No match, continue processing
- return FilterDecision.Neutral;
- }
+ // we've got a match
+ if (m_acceptOnMatch)
+ {
+ return FilterDecision.Accept;
+ }
+ return FilterDecision.Deny;
+ }
+ else if (m_stringToMatch != null)
+ {
+ // Check substring match
+ if (msg.IndexOf(m_stringToMatch) == -1)
+ {
+ // No match, continue processing
+ return FilterDecision.Neutral;
+ }
- // we've got a match
- if (m_acceptOnMatch)
- {
- return FilterDecision.Accept;
- }
- return FilterDecision.Deny;
- }
- return FilterDecision.Neutral;
+ // we've got a match
+ if (m_acceptOnMatch)
+ {
+ return FilterDecision.Accept;
+ }
+ return FilterDecision.Deny;
+ }
+ return FilterDecision.Neutral;
- }
+ }
- #endregion
- }
+ #endregion
+ }
}
diff --git a/src/log4net/GlobalContext.cs b/src/log4net/GlobalContext.cs
index 222b90c..d698858 100644
--- a/src/log4net/GlobalContext.cs
+++ b/src/log4net/GlobalContext.cs
@@ -24,79 +24,79 @@
namespace log4net
{
- /// <summary>
- /// The log4net Global Context.
- /// </summary>
- /// <remarks>
- /// <para>
- /// The <c>GlobalContext</c> provides a location for global debugging
- /// information to be stored.
- /// </para>
- /// <para>
- /// The global context has a properties map and these properties can
- /// be included in the output of log messages. The <see cref="log4net.Layout.PatternLayout"/>
- /// supports selecting and outputing these properties.
- /// </para>
- /// <para>
- /// By default the <c>log4net:HostName</c> property is set to the name of
- /// the current machine.
- /// </para>
- /// </remarks>
- /// <example>
- /// <code lang="C#">
- /// GlobalContext.Properties["hostname"] = Environment.MachineName;
- /// </code>
- /// </example>
- /// <threadsafety static="true" instance="true" />
- /// <author>Nicko Cadell</author>
- public sealed class GlobalContext
- {
- #region Private Instance Constructors
+ /// <summary>
+ /// The log4net Global Context.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// The <c>GlobalContext</c> provides a location for global debugging
+ /// information to be stored.
+ /// </para>
+ /// <para>
+ /// The global context has a properties map and these properties can
+ /// be included in the output of log messages. The <see cref="log4net.Layout.PatternLayout"/>
+ /// supports selecting and outputing these properties.
+ /// </para>
+ /// <para>
+ /// By default the <c>log4net:HostName</c> property is set to the name of
+ /// the current machine.
+ /// </para>
+ /// </remarks>
+ /// <example>
+ /// <code lang="C#">
+ /// GlobalContext.Properties["hostname"] = Environment.MachineName;
+ /// </code>
+ /// </example>
+ /// <threadsafety static="true" instance="true" />
+ /// <author>Nicko Cadell</author>
+ public sealed class GlobalContext
+ {
+ #region Private Instance Constructors
- /// <summary>
- /// Private Constructor.
- /// </summary>
- /// <remarks>
- /// Uses a private access modifier to prevent instantiation of this class.
- /// </remarks>
- private GlobalContext()
- {
- }
+ /// <summary>
+ /// Private Constructor.
+ /// </summary>
+ /// <remarks>
+ /// Uses a private access modifier to prevent instantiation of this class.
+ /// </remarks>
+ private GlobalContext()
+ {
+ }
- #endregion Private Instance Constructors
+ #endregion Private Instance Constructors
- static GlobalContext()
- {
- Properties[log4net.Core.LoggingEvent.HostNameProperty] = SystemInfo.HostName;
- }
+ static GlobalContext()
+ {
+ Properties[log4net.Core.LoggingEvent.HostNameProperty] = SystemInfo.HostName;
+ }
- #region Public Static Properties
+ #region Public Static Properties
- /// <summary>
- /// The global properties map.
- /// </summary>
- /// <value>
- /// The global properties map.
- /// </value>
- /// <remarks>
- /// <para>
- /// The global properties map.
- /// </para>
- /// </remarks>
- public static GlobalContextProperties Properties
- {
- get { return s_properties; }
- }
+ /// <summary>
+ /// The global properties map.
+ /// </summary>
+ /// <value>
+ /// The global properties map.
+ /// </value>
+ /// <remarks>
+ /// <para>
+ /// The global properties map.
+ /// </para>
+ /// </remarks>
+ public static GlobalContextProperties Properties
+ {
+ get { return s_properties; }
+ }
- #endregion Public Static Properties
+ #endregion Public Static Properties
- #region Private Static Fields
+ #region Private Static Fields
- /// <summary>
- /// The global context properties instance
- /// </summary>
- private static readonly GlobalContextProperties s_properties = new GlobalContextProperties();
+ /// <summary>
+ /// The global context properties instance
+ /// </summary>
+ private static readonly GlobalContextProperties s_properties = new GlobalContextProperties();
- #endregion Private Static Fields
- }
+ #endregion Private Static Fields
+ }
}
diff --git a/src/log4net/ILog.cs b/src/log4net/ILog.cs
index 89d01c7..ed39c16 100644
--- a/src/log4net/ILog.cs
+++ b/src/log4net/ILog.cs
@@ -24,937 +24,937 @@
namespace log4net
{
- /// <summary>
- /// The ILog interface is use by application to log messages into
- /// the log4net framework.
- /// </summary>
- /// <remarks>
- /// <para>
- /// Use the <see cref="LogManager"/> to obtain logger instances
- /// that implement this interface. The <see cref="M:LogManager.GetLogger(Assembly,Type)"/>
- /// static method is used to get logger instances.
- /// </para>
- /// <para>
- /// This class contains methods for logging at different levels and also
- /// has properties for determining if those logging levels are
- /// enabled in the current configuration.
- /// </para>
- /// <para>
- /// This interface can be implemented in different ways. This documentation
- /// specifies reasonable behavior that a caller can expect from the actual
- /// implementation, however different implementations reserve the right to
- /// do things differently.
- /// </para>
- /// </remarks>
- /// <example>Simple example of logging messages
- /// <code lang="C#">
- /// ILog log = LogManager.GetLogger("application-log");
- ///
- /// log.Info("Application Start");
- /// log.Debug("This is a debug message");
- ///
- /// if (log.IsDebugEnabled)
- /// {
- /// log.Debug("This is another debug message");
- /// }
- /// </code>
- /// </example>
- /// <seealso cref="LogManager"/>
- /// <seealso cref="M:LogManager.GetLogger(Assembly, Type)"/>
- /// <author>Nicko Cadell</author>
- /// <author>Gert Driesen</author>
- public interface ILog : ILoggerWrapper
- {
- /// <overloads>Log a message object with the <see cref="Level.Debug"/> level.</overloads>
- /// <summary>
- /// Log a message object with the <see cref="Level.Debug"/> level.
- /// </summary>
- /// <param name="message">The message object to log.</param>
- /// <remarks>
- /// <para>
- /// This method first checks if this logger is <c>DEBUG</c>
- /// enabled by comparing the level of this logger with the
- /// <see cref="Level.Debug"/> level. If this logger is
- /// <c>DEBUG</c> enabled, then it converts the message object
- /// (passed as parameter) to a string by invoking the appropriate
- /// <see cref="log4net.ObjectRenderer.IObjectRenderer"/>. It then
- /// proceeds to call all the registered appenders in this logger
- /// and also higher in the hierarchy depending on the value of
- /// the additivity flag.
- /// </para>
- /// <para><b>WARNING</b> Note that passing an <see cref="Exception"/>
- /// to this method will print the name of the <see cref="Exception"/>
- /// but no stack trace. To print a stack trace use the
- /// <see cref="M:Debug(object,Exception)"/> form instead.
- /// </para>
- /// </remarks>
- /// <seealso cref="M:Debug(object,Exception)"/>
- /// <seealso cref="IsDebugEnabled"/>
- void Debug(object message);
+ /// <summary>
+ /// The ILog interface is use by application to log messages into
+ /// the log4net framework.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Use the <see cref="LogManager"/> to obtain logger instances
+ /// that implement this interface. The <see cref="M:LogManager.GetLogger(Assembly,Type)"/>
+ /// static method is used to get logger instances.
+ /// </para>
+ /// <para>
+ /// This class contains methods for logging at different levels and also
+ /// has properties for determining if those logging levels are
+ /// enabled in the current configuration.
+ /// </para>
+ /// <para>
+ /// This interface can be implemented in different ways. This documentation
+ /// specifies reasonable behavior that a caller can expect from the actual
+ /// implementation, however different implementations reserve the right to
+ /// do things differently.
+ /// </para>
+ /// </remarks>
+ /// <example>Simple example of logging messages
+ /// <code lang="C#">
+ /// ILog log = LogManager.GetLogger("application-log");
+ ///
+ /// log.Info("Application Start");
+ /// log.Debug("This is a debug message");
+ ///
+ /// if (log.IsDebugEnabled)
+ /// {
+ /// log.Debug("This is another debug message");
+ /// }
+ /// </code>
+ /// </example>
+ /// <seealso cref="LogManager"/>
+ /// <seealso cref="M:LogManager.GetLogger(Assembly, Type)"/>
+ /// <author>Nicko Cadell</author>
+ /// <author>Gert Driesen</author>
+ public interface ILog : ILoggerWrapper
+ {
+ /// <overloads>Log a message object with the <see cref="Level.Debug"/> level.</overloads>
+ /// <summary>
+ /// Log a message object with the <see cref="Level.Debug"/> level.
+ /// </summary>
+ /// <param name="message">The message object to log.</param>
+ /// <remarks>
+ /// <para>
+ /// This method first checks if this logger is <c>DEBUG</c>
+ /// enabled by comparing the level of this logger with the
+ /// <see cref="Level.Debug"/> level. If this logger is
+ /// <c>DEBUG</c> enabled, then it converts the message object
+ /// (passed as parameter) to a string by invoking the appropriate
+ /// <see cref="log4net.ObjectRenderer.IObjectRenderer"/>. It then
+ /// proceeds to call all the registered appenders in this logger
+ /// and also higher in the hierarchy depending on the value of
+ /// the additivity flag.
+ /// </para>
+ /// <para><b>WARNING</b> Note that passing an <see cref="Exception"/>
+ /// to this method will print the name of the <see cref="Exception"/>
+ /// but no stack trace. To print a stack trace use the
+ /// <see cref="M:Debug(object,Exception)"/> form instead.
+ /// </para>
+ /// </remarks>
+ /// <seealso cref="M:Debug(object,Exception)"/>
+ /// <seealso cref="IsDebugEnabled"/>
+ void Debug(object message);
- /// <summary>
- /// Log a message object with the <see cref="Level.Debug"/> level including
- /// the stack trace of the <see cref="Exception"/> passed
- /// as a parameter.
- /// </summary>
- /// <param name="message">The message object to log.</param>
- /// <param name="exception">The exception to log, including its stack trace.</param>
- /// <remarks>
- /// <para>
- /// See the <see cref="M:Debug(object)"/> form for more detailed information.
- /// </para>
- /// </remarks>
- /// <seealso cref="M:Debug(object)"/>
- /// <seealso cref="IsDebugEnabled"/>
- void Debug(object message, Exception exception);
+ /// <summary>
+ /// Log a message object with the <see cref="Level.Debug"/> level including
+ /// the stack trace of the <see cref="Exception"/> passed
+ /// as a parameter.
+ /// </summary>
+ /// <param name="message">The message object to log.</param>
+ /// <param name="exception">The exception to log, including its stack trace.</param>
+ /// <remarks>
+ /// <para>
+ /// See the <see cref="M:Debug(object)"/> form for more detailed information.
+ /// </para>
+ /// </remarks>
+ /// <seealso cref="M:Debug(object)"/>
+ /// <seealso cref="IsDebugEnabled"/>
+ void Debug(object message, Exception exception);
- /// <overloads>Log a formatted string with the <see cref="Level.Debug"/> level.</overloads>
- /// <summary>
- /// Logs a formatted message string with the <see cref="Level.Debug"/> level.
- /// </summary>
- /// <param name="format">A String containing zero or more format items</param>
- /// <param name="args">An Object array containing zero or more objects to format</param>
- /// <remarks>
- /// <para>
- /// The message is formatted using the <c>String.Format</c> method. See
- /// <see cref="M:String.Format(string, object[])"/> for details of the syntax of the format string and the behavior
- /// of the formatting.
- /// </para>
- /// <para>
- /// This method does not take an <see cref="Exception"/> object to include in the
- /// log event. To pass an <see cref="Exception"/> use one of the <see cref="M:Debug(object,Exception)"/>
- /// methods instead.
- /// </para>
- /// </remarks>
- /// <seealso cref="M:Debug(object)"/>
- /// <seealso cref="IsDebugEnabled"/>
- void DebugFormat(string format, params object[] args);
+ /// <overloads>Log a formatted string with the <see cref="Level.Debug"/> level.</overloads>
+ /// <summary>
+ /// Logs a formatted message string with the <see cref="Level.Debug"/> level.
+ /// </summary>
+ /// <param name="format">A String containing zero or more format items</param>
+ /// <param name="args">An Object array containing zero or more objects to format</param>
+ /// <remarks>
+ /// <para>
+ /// The message is formatted using the <c>String.Format</c> method. See
+ /// <see cref="M:String.Format(string, object[])"/> for details of the syntax of the format string and the behavior
+ /// of the formatting.
+ /// </para>
+ /// <para>
+ /// This method does not take an <see cref="Exception"/> object to include in the
+ /// log event. To pass an <see cref="Exception"/> use one of the <see cref="M:Debug(object,Exception)"/>
+ /// methods instead.
+ /// </para>
+ /// </remarks>
+ /// <seealso cref="M:Debug(object)"/>
+ /// <seealso cref="IsDebugEnabled"/>
+ void DebugFormat(string format, params object[] args);
- /// <summary>
- /// Logs a formatted message string with the <see cref="Level.Debug"/> level.
- /// </summary>
- /// <param name="format">A String containing zero or more format items</param>
- /// <param name="arg0">An Object to format</param>
- /// <remarks>
- /// <para>
- /// The message is formatted using the <c>String.Format</c> method. See
- /// <see cref="M:String.Format(string, object[])"/> for details of the syntax of the format string and the behavior
- /// of the formatting.
- /// </para>
- /// <para>
- /// This method does not take an <see cref="Exception"/> object to include in the
- /// log event. To pass an <see cref="Exception"/> use one of the <see cref="M:Debug(object,Exception)"/>
- /// methods instead.
- /// </para>
- /// </remarks>
- /// <seealso cref="M:Debug(object)"/>
- /// <seealso cref="IsDebugEnabled"/>
- void DebugFormat(string format, object arg0);
+ /// <summary>
+ /// Logs a formatted message string with the <see cref="Level.Debug"/> level.
+ /// </summary>
+ /// <param name="format">A String containing zero or more format items</param>
+ /// <param name="arg0">An Object to format</param>
+ /// <remarks>
+ /// <para>
+ /// The message is formatted using the <c>String.Format</c> method. See
+ /// <see cref="M:String.Format(string, object[])"/> for details of the syntax of the format string and the behavior
+ /// of the formatting.
+ /// </para>
+ /// <para>
+ /// This method does not take an <see cref="Exception"/> object to include in the
+ /// log event. To pass an <see cref="Exception"/> use one of the <see cref="M:Debug(object,Exception)"/>
+ /// methods instead.
+ /// </para>
+ /// </remarks>
+ /// <seealso cref="M:Debug(object)"/>
+ /// <seealso cref="IsDebugEnabled"/>
+ void DebugFormat(string format, object arg0);
- /// <summary>
- /// Logs a formatted message string with the <see cref="Level.Debug"/> level.
- /// </summary>
- /// <param name="format">A String containing zero or more format items</param>
- /// <param name="arg0">An Object to format</param>
- /// <param name="arg1">An Object to format</param>
- /// <remarks>
- /// <para>
- /// The message is formatted using the <c>String.Format</c> method. See
- /// <see cref="M:String.Format(string, object[])"/> for details of the syntax of the format string and the behavior
- /// of the formatting.
- /// </para>
- /// <para>
- /// This method does not take an <see cref="Exception"/> object to include in the
- /// log event. To pass an <see cref="Exception"/> use one of the <see cref="M:Debug(object,Exception)"/>
- /// methods instead.
- /// </para>
- /// </remarks>
- /// <seealso cref="M:Debug(object)"/>
- /// <seealso cref="IsDebugEnabled"/>
- void DebugFormat(string format, object arg0, object arg1);
+ /// <summary>
+ /// Logs a formatted message string with the <see cref="Level.Debug"/> level.
+ /// </summary>
+ /// <param name="format">A String containing zero or more format items</param>
+ /// <param name="arg0">An Object to format</param>
+ /// <param name="arg1">An Object to format</param>
+ /// <remarks>
+ /// <para>
+ /// The message is formatted using the <c>String.Format</c> method. See
+ /// <see cref="M:String.Format(string, object[])"/> for details of the syntax of the format string and the behavior
+ /// of the formatting.
+ /// </para>
+ /// <para>
+ /// This method does not take an <see cref="Exception"/> object to include in the
+ /// log event. To pass an <see cref="Exception"/> use one of the <see cref="M:Debug(object,Exception)"/>
+ /// methods instead.
+ /// </para>
+ /// </remarks>
+ /// <seealso cref="M:Debug(object)"/>
+ /// <seealso cref="IsDebugEnabled"/>
+ void DebugFormat(string format, object arg0, object arg1);
- /// <summary>
- /// Logs a formatted message string with the <see cref="Level.Debug"/> level.
- /// </summary>
- /// <param name="format">A String containing zero or more format items</param>
- /// <param name="arg0">An Object to format</param>
- /// <param name="arg1">An Object to format</param>
- /// <param name="arg2">An Object to format</param>
- /// <remarks>
- /// <para>
- /// The message is formatted using the <c>String.Format</c> method. See
- /// <see cref="M:String.Format(string, object[])"/> for details of the syntax of the format string and the behavior
- /// of the formatting.
- /// </para>
- /// <para>
- /// This method does not take an <see cref="Exception"/> object to include in the
- /// log event. To pass an <see cref="Exception"/> use one of the <see cref="M:Debug(object,Exception)"/>
- /// methods instead.
- /// </para>
- /// </remarks>
- /// <seealso cref="M:Debug(object)"/>
- /// <seealso cref="IsDebugEnabled"/>
- void DebugFormat(string format, object arg0, object arg1, object arg2);
+ /// <summary>
+ /// Logs a formatted message string with the <see cref="Level.Debug"/> level.
+ /// </summary>
+ /// <param name="format">A String containing zero or more format items</param>
+ /// <param name="arg0">An Object to format</param>
+ /// <param name="arg1">An Object to format</param>
+ /// <param name="arg2">An Object to format</param>
+ /// <remarks>
+ /// <para>
+ /// The message is formatted using the <c>String.Format</c> method. See
+ /// <see cref="M:String.Format(string, object[])"/> for details of the syntax of the format string and the behavior
+ /// of the formatting.
+ /// </para>
+ /// <para>
+ /// This method does not take an <see cref="Exception"/> object to include in the
+ /// log event. To pass an <see cref="Exception"/> use one of the <see cref="M:Debug(object,Exception)"/>
+ /// methods instead.
+ /// </para>
+ /// </remarks>
+ /// <seealso cref="M:Debug(object)"/>
+ /// <seealso cref="IsDebugEnabled"/>
+ void DebugFormat(string format, object arg0, object arg1, object arg2);
- /// <summary>
- /// Logs a formatted message string with the <see cref="Level.Debug"/> level.
- /// </summary>
- /// <param name="provider">An <see cref="IFormatProvider"/> that supplies culture-specific formatting information</param>
- /// <param name="format">A String containing zero or more format items</param>
- /// <param name="args">An Object array containing zero or more objects to format</param>
- /// <remarks>
- /// <para>
- /// The message is formatted using the <c>String.Format</c> method. See
- /// <see cref="M:String.Format(string, object[])"/> for details of the syntax of the format string and the behavior
- /// of the formatting.
- /// </para>
- /// <para>
- /// This method does not take an <see cref="Exception"/> object to include in the
- /// log event. To pass an <see cref="Exception"/> use one of the <see cref="M:Debug(object,Exception)"/>
- /// methods instead.
- /// </para>
- /// </remarks>
- /// <seealso cref="M:Debug(object)"/>
- /// <seealso cref="IsDebugEnabled"/>
- void DebugFormat(IFormatProvider provider, string format, params object[] args);
+ /// <summary>
+ /// Logs a formatted message string with the <see cref="Level.Debug"/> level.
+ /// </summary>
+ /// <param name="provider">An <see cref="IFormatProvider"/> that supplies culture-specific formatting information</param>
+ /// <param name="format">A String containing zero or more format items</param>
+ /// <param name="args">An Object array containing zero or more objects to format</param>
+ /// <remarks>
+ /// <para>
+ /// The message is formatted using the <c>String.Format</c> method. See
+ /// <see cref="M:String.Format(string, object[])"/> for details of the syntax of the format string and the behavior
+ /// of the formatting.
+ /// </para>
+ /// <para>
+ /// This method does not take an <see cref="Exception"/> object to include in the
+ /// log event. To pass an <see cref="Exception"/> use one of the <see cref="M:Debug(object,Exception)"/>
+ /// methods instead.
+ /// </para>
+ /// </remarks>
+ /// <seealso cref="M:Debug(object)"/>
+ /// <seealso cref="IsDebugEnabled"/>
+ void DebugFormat(IFormatProvider provider, string format, params object[] args);
- /// <overloads>Log a message object with the <see cref="Level.Info"/> level.</overloads>
- /// <summary>
- /// Logs a message object with the <see cref="Level.Info"/> level.
- /// </summary>
- /// <remarks>
- /// <para>
- /// This method first checks if this logger is <c>INFO</c>
- /// enabled by comparing the level of this logger with the
- /// <see cref="Level.Info"/> level. If this logger is
- /// <c>INFO</c> enabled, then it converts the message object
- /// (passed as parameter) to a string by invoking the appropriate
- /// <see cref="log4net.ObjectRenderer.IObjectRenderer"/>. It then
- /// proceeds to call all the registered appenders in this logger
- /// and also higher in the hierarchy depending on the value of the
- /// additivity flag.
- /// </para>
- /// <para><b>WARNING</b> Note that passing an <see cref="Exception"/>
- /// to this method will print the name of the <see cref="Exception"/>
- /// but no stack trace. To print a stack trace use the
- /// <see cref="M:Info(object,Exception)"/> form instead.
- /// </para>
- /// </remarks>
- /// <param name="message">The message object to log.</param>
- /// <seealso cref="M:Info(object,Exception)"/>
- /// <seealso cref="IsInfoEnabled"/>
- void Info(object message);
+ /// <overloads>Log a message object with the <see cref="Level.Info"/> level.</overloads>
+ /// <summary>
+ /// Logs a message object with the <see cref="Level.Info"/> level.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// This method first checks if this logger is <c>INFO</c>
+ /// enabled by comparing the level of this logger with the
+ /// <see cref="Level.Info"/> level. If this logger is
+ /// <c>INFO</c> enabled, then it converts the message object
+ /// (passed as parameter) to a string by invoking the appropriate
+ /// <see cref="log4net.ObjectRenderer.IObjectRenderer"/>. It then
+ /// proceeds to call all the registered appenders in this logger
+ /// and also higher in the hierarchy depending on the value of the
+ /// additivity flag.
+ /// </para>
+ /// <para><b>WARNING</b> Note that passing an <see cref="Exception"/>
+ /// to this method will print the name of the <see cref="Exception"/>
+ /// but no stack trace. To print a stack trace use the
+ /// <see cref="M:Info(object,Exception)"/> form instead.
+ /// </para>
+ /// </remarks>
+ /// <param name="message">The message object to log.</param>
+ /// <seealso cref="M:Info(object,Exception)"/>
+ /// <seealso cref="IsInfoEnabled"/>
+ void Info(object message);
- /// <summary>
- /// Logs a message object with the <c>INFO</c> level including
- /// the stack trace of the <see cref="Exception"/> passed
- /// as a parameter.
- /// </summary>
- /// <param name="message">The message object to log.</param>
- /// <param name="exception">The exception to log, including its stack trace.</param>
- /// <remarks>
- /// <para>
- /// See the <see cref="M:Info(object)"/> form for more detailed information.
- /// </para>
- /// </remarks>
- /// <seealso cref="M:Info(object)"/>
- /// <seealso cref="IsInfoEnabled"/>
- void Info(object message, Exception exception);
+ /// <summary>
+ /// Logs a message object with the <c>INFO</c> level including
+ /// the stack trace of the <see cref="Exception"/> passed
+ /// as a parameter.
+ /// </summary>
+ /// <param name="message">The message object to log.</param>
+ /// <param name="exception">The exception to log, including its stack trace.</param>
+ /// <remarks>
+ /// <para>
+ /// See the <see cref="M:Info(object)"/> form for more detailed information.
+ /// </para>
+ /// </remarks>
+ /// <seealso cref="M:Info(object)"/>
+ /// <seealso cref="IsInfoEnabled"/>
+ void Info(object message, Exception exception);
- /// <overloads>Log a formatted message string with the <see cref="Level.Info"/> level.</overloads>
- /// <summary>
- /// Logs a formatted message string with the <see cref="Level.Info"/> level.
- /// </summary>
- /// <param name="format">A String containing zero or more format items</param>
- /// <param name="args">An Object array containing zero or more objects to format</param>
- /// <remarks>
- /// <para>
- /// The message is formatted using the <c>String.Format</c> method. See
- /// <see cref="M:String.Format(string, object[])"/> for details of the syntax of the format string and the behavior
- /// of the formatting.
- /// </para>
- /// <para>
- /// This method does not take an <see cref="Exception"/> object to include in the
- /// log event. To pass an <see cref="Exception"/> use one of the <see cref="M:Info(object)"/>
- /// methods instead.
- /// </para>
- /// </remarks>
- /// <seealso cref="M:Info(object,Exception)"/>
- /// <seealso cref="IsInfoEnabled"/>
- void InfoFormat(string format, params object[] args);
+ /// <overloads>Log a formatted message string with the <see cref="Level.Info"/> level.</overloads>
+ /// <summary>
+ /// Logs a formatted message string with the <see cref="Level.Info"/> level.
+ /// </summary>
+ /// <param name="format">A String containing zero or more format items</param>
+ /// <param name="args">An Object array containing zero or more objects to format</param>
+ /// <remarks>
+ /// <para>
+ /// The message is formatted using the <c>String.Format</c> method. See
+ /// <see cref="M:String.Format(string, object[])"/> for details of the syntax of the format string and the behavior
+ /// of the formatting.
+ /// </para>
+ /// <para>
+ /// This method does not take an <see cref="Exception"/> object to include in the
+ /// log event. To pass an <see cref="Exception"/> use one of the <see cref="M:Info(object)"/>
+ /// methods instead.
+ /// </para>
+ /// </remarks>
+ /// <seealso cref="M:Info(object,Exception)"/>
+ /// <seealso cref="IsInfoEnabled"/>
+ void InfoFormat(string format, params object[] args);
- /// <summary>
- /// Logs a formatted message string with the <see cref="Level.Info"/> level.
- /// </summary>
- /// <param name="format">A String containing zero or more format items</param>
- /// <param name="arg0">An Object to format</param>
- /// <remarks>
- /// <para>
- /// The message is formatted using the <c>String.Format</c> method. See
- /// <see cref="M:String.Format(string, object[])"/> for details of the syntax of the format string and the behavior
- /// of the formatting.
- /// </para>
- /// <para>
- /// This method does not take an <see cref="Exception"/> object to include in the
- /// log event. To pass an <see cref="Exception"/> use one of the <see cref="M:Info(object,Exception)"/>
- /// methods instead.
- /// </para>
- /// </remarks>
- /// <seealso cref="M:Info(object)"/>
- /// <seealso cref="IsInfoEnabled"/>
- void InfoFormat(string format, object arg0);
+ /// <summary>
+ /// Logs a formatted message string with the <see cref="Level.Info"/> level.
+ /// </summary>
+ /// <param name="format">A String containing zero or more format items</param>
+ /// <param name="arg0">An Object to format</param>
+ /// <remarks>
+ /// <para>
+ /// The message is formatted using the <c>String.Format</c> method. See
+ /// <see cref="M:String.Format(string, object[])"/> for details of the syntax of the format string and the behavior
+ /// of the formatting.
+ /// </para>
+ /// <para>
+ /// This method does not take an <see cref="Exception"/> object to include in the
+ /// log event. To pass an <see cref="Exception"/> use one of the <see cref="M:Info(object,Exception)"/>
+ /// methods instead.
+ /// </para>
+ /// </remarks>
+ /// <seealso cref="M:Info(object)"/>
+ /// <seealso cref="IsInfoEnabled"/>
+ void InfoFormat(string format, object arg0);
- /// <summary>
- /// Logs a formatted message string with the <see cref="Level.Info"/> level.
- /// </summary>
- /// <param name="format">A String containing zero or more format items</param>
- /// <param name="arg0">An Object to format</param>
- /// <param name="arg1">An Object to format</param>
- /// <remarks>
- /// <para>
- /// The message is formatted using the <c>String.Format</c> method. See
- /// <see cref="M:String.Format(string, object[])"/> for details of the syntax of the format string and the behavior
- /// of the formatting.
- /// </para>
- /// <para>
- /// This method does not take an <see cref="Exception"/> object to include in the
- /// log event. To pass an <see cref="Exception"/> use one of the <see cref="M:Info(object,Exception)"/>
- /// methods instead.
- /// </para>
- /// </remarks>
- /// <seealso cref="M:Info(object)"/>
- /// <seealso cref="IsInfoEnabled"/>
- void InfoFormat(string format, object arg0, object arg1);
+ /// <summary>
+ /// Logs a formatted message string with the <see cref="Level.Info"/> level.
+ /// </summary>
+ /// <param name="format">A String containing zero or more format items</param>
+ /// <param name="arg0">An Object to format</param>
+ /// <param name="arg1">An Object to format</param>
+ /// <remarks>
+ /// <para>
+ /// The message is formatted using the <c>String.Format</c> method. See
+ /// <see cref="M:String.Format(string, object[])"/> for details of the syntax of the format string and the behavior
+ /// of the formatting.
+ /// </para>
+ /// <para>
+ /// This method does not take an <see cref="Exception"/> object to include in the
+ /// log event. To pass an <see cref="Exception"/> use one of the <see cref="M:Info(object,Exception)"/>
+ /// methods instead.
+ /// </para>
+ /// </remarks>
+ /// <seealso cref="M:Info(object)"/>
+ /// <seealso cref="IsInfoEnabled"/>
+ void InfoFormat(string format, object arg0, object arg1);
- /// <summary>
- /// Logs a formatted message string with the <see cref="Level.Info"/> level.
- /// </summary>
- /// <param name="format">A String containing zero or more format items</param>
- /// <param name="arg0">An Object to format</param>
- /// <param name="arg1">An Object to format</param>
- /// <param name="arg2">An Object to format</param>
- /// <remarks>
- /// <para>
- /// The message is formatted using the <c>String.Format</c> method. See
- /// <see cref="M:String.Format(string, object[])"/> for details of the syntax of the format string and the behavior
- /// of the formatting.
- /// </para>
- /// <para>
- /// This method does not take an <see cref="Exception"/> object to include in the
- /// log event. To pass an <see cref="Exception"/> use one of the <see cref="M:Info(object,Exception)"/>
- /// methods instead.
- /// </para>
- /// </remarks>
- /// <seealso cref="M:Info(object)"/>
- /// <seealso cref="IsInfoEnabled"/>
- void InfoFormat(string format, object arg0, object arg1, object arg2);
+ /// <summary>
+ /// Logs a formatted message string with the <see cref="Level.Info"/> level.
+ /// </summary>
+ /// <param name="format">A String containing zero or more format items</param>
+ /// <param name="arg0">An Object to format</param>
+ /// <param name="arg1">An Object to format</param>
+ /// <param name="arg2">An Object to format</param>
+ /// <remarks>
+ /// <para>
+ /// The message is formatted using the <c>String.Format</c> method. See
+ /// <see cref="M:String.Format(string, object[])"/> for details of the syntax of the format string and the behavior
+ /// of the formatting.
+ /// </para>
+ /// <para>
+ /// This method does not take an <see cref="Exception"/> object to include in the
+ /// log event. To pass an <see cref="Exception"/> use one of the <see cref="M:Info(object,Exception)"/>
+ /// methods instead.
+ /// </para>
+ /// </remarks>
+ /// <seealso cref="M:Info(object)"/>
+ /// <seealso cref="IsInfoEnabled"/>
+ void InfoFormat(string format, object arg0, object arg1, object arg2);
- /// <summary>
- /// Logs a formatted message string with the <see cref="Level.Info"/> level.
- /// </summary>
- /// <param name="provider">An <see cref="IFormatProvider"/> that supplies culture-specific formatting information</param>
- /// <param name="format">A String containing zero or more format items</param>
- /// <param name="args">An Object array containing zero or more objects to format</param>
- /// <remarks>
- /// <para>
- /// The message is formatted using the <c>String.Format</c> method. See
- /// <see cref="M:String.Format(string, object[])"/> for details of the syntax of the format string and the behavior
- /// of the formatting.
- /// </para>
- /// <para>
- /// This method does not take an <see cref="Exception"/> object to include in the
- /// log event. To pass an <see cref="Exception"/> use one of the <see cref="M:Info(object)"/>
- /// methods instead.
- /// </para>
- /// </remarks>
- /// <seealso cref="M:Info(object,Exception)"/>
- /// <seealso cref="IsInfoEnabled"/>
- void InfoFormat(IFormatProvider provider, string format, params object[] args);
+ /// <summary>
+ /// Logs a formatted message string with the <see cref="Level.Info"/> level.
+ /// </summary>
+ /// <param name="provider">An <see cref="IFormatProvider"/> that supplies culture-specific formatting information</param>
+ /// <param name="format">A String containing zero or more format items</param>
+ /// <param name="args">An Object array containing zero or more objects to format</param>
+ /// <remarks>
+ /// <para>
+ /// The message is formatted using the <c>String.Format</c> method. See
+ /// <see cref="M:String.Format(string, object[])"/> for details of the syntax of the format string and the behavior
+ /// of the formatting.
+ /// </para>
+ /// <para>
+ /// This method does not take an <see cref="Exception"/> object to include in the
+ /// log event. To pass an <see cref="Exception"/> use one of the <see cref="M:Info(object)"/>
+ /// methods instead.
+ /// </para>
+ /// </remarks>
+ /// <seealso cref="M:Info(object,Exception)"/>
+ /// <seealso cref="IsInfoEnabled"/>
+ void InfoFormat(IFormatProvider provider, string format, params object[] args);
- /// <overloads>Log a message object with the <see cref="Level.Warn"/> level.</overloads>
- /// <summary>
- /// Log a message object with the <see cref="Level.Warn"/> level.
- /// </summary>
- /// <remarks>
- /// <para>
- /// This method first checks if this logger is <c>WARN</c>
- /// enabled by comparing the level of this logger with the
- /// <see cref="Level.Warn"/> level. If this logger is
- /// <c>WARN</c> enabled, then it converts the message object
- /// (passed as parameter) to a string by invoking the appropriate
- /// <see cref="log4net.ObjectRenderer.IObjectRenderer"/>. It then
- /// proceeds to call all the registered appenders in this logger
- /// and also higher in the hierarchy depending on the value of the
- /// additivity flag.
- /// </para>
- /// <para><b>WARNING</b> Note that passing an <see cref="Exception"/>
- /// to this method will print the name of the <see cref="Exception"/>
- /// but no stack trace. To print a stack trace use the
- /// <see cref="M:Warn(object,Exception)"/> form instead.
- /// </para>
- /// </remarks>
- /// <param name="message">The message object to log.</param>
- /// <seealso cref="M:Warn(object,Exception)"/>
- /// <seealso cref="IsWarnEnabled"/>
- void Warn(object message);
+ /// <overloads>Log a message object with the <see cref="Level.Warn"/> level.</overloads>
+ /// <summary>
+ /// Log a message object with the <see cref="Level.Warn"/> level.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// This method first checks if this logger is <c>WARN</c>
+ /// enabled by comparing the level of this logger with the
+ /// <see cref="Level.Warn"/> level. If this logger is
+ /// <c>WARN</c> enabled, then it converts the message object
+ /// (passed as parameter) to a string by invoking the appropriate
+ /// <see cref="log4net.ObjectRenderer.IObjectRenderer"/>. It then
+ /// proceeds to call all the registered appenders in this logger
+ /// and also higher in the hierarchy depending on the value of the
+ /// additivity flag.
+ /// </para>
+ /// <para><b>WARNING</b> Note that passing an <see cref="Exception"/>
+ /// to this method will print the name of the <see cref="Exception"/>
+ /// but no stack trace. To print a stack trace use the
+ /// <see cref="M:Warn(object,Exception)"/> form instead.
+ /// </para>
+ /// </remarks>
+ /// <param name="message">The message object to log.</param>
+ /// <seealso cref="M:Warn(object,Exception)"/>
+ /// <seealso cref="IsWarnEnabled"/>
+ void Warn(object message);
- /// <summary>
- /// Log a message object with the <see cref="Level.Warn"/> level including
- /// the stack trace of the <see cref="Exception"/> passed
- /// as a parameter.
- /// </summary>
- /// <param name="message">The message object to log.</param>
- /// <param name="exception">The exception to log, including its stack trace.</param>
- /// <remarks>
- /// <para>
- /// See the <see cref="M:Warn(object)"/> form for more detailed information.
- /// </para>
- /// </remarks>
- /// <seealso cref="M:Warn(object)"/>
- /// <seealso cref="IsWarnEnabled"/>
- void Warn(object message, Exception exception);
+ /// <summary>
+ /// Log a message object with the <see cref="Level.Warn"/> level including
+ /// the stack trace of the <see cref="Exception"/> passed
+ /// as a parameter.
+ /// </summary>
+ /// <param name="message">The message object to log.</param>
+ /// <param name="exception">The exception to log, including its stack trace.</param>
+ /// <remarks>
+ /// <para>
+ /// See the <see cref="M:Warn(object)"/> form for more detailed information.
+ /// </para>
+ /// </remarks>
+ /// <seealso cref="M:Warn(object)"/>
+ /// <seealso cref="IsWarnEnabled"/>
+ void Warn(object message, Exception exception);
- /// <overloads>Log a formatted message string with the <see cref="Level.Warn"/> level.</overloads>
- /// <summary>
- /// Logs a formatted message string with the <see cref="Level.Warn"/> level.
- /// </summary>
- /// <param name="format">A String containing zero or more format items</param>
- /// <param name="args">An Object array containing zero or more objects to format</param>
- /// <remarks>
- /// <para>
- /// The message is formatted using the <c>String.Format</c> method. See
- /// <see cref="M:String.Format(string, object[])"/> for details of the syntax of the format string and the behavior
- /// of the formatting.
- /// </para>
- /// <para>
- /// This method does not take an <see cref="Exception"/> object to include in the
- /// log event. To pass an <see cref="Exception"/> use one of the <see cref="M:Warn(object)"/>
- /// methods instead.
- /// </para>
- /// </remarks>
- /// <seealso cref="M:Warn(object,Exception)"/>
- /// <seealso cref="IsWarnEnabled"/>
- void WarnFormat(string format, params object[] args);
+ /// <overloads>Log a formatted message string with the <see cref="Level.Warn"/> level.</overloads>
+ /// <summary>
+ /// Logs a formatted message string with the <see cref="Level.Warn"/> level.
+ /// </summary>
+ /// <param name="format">A String containing zero or more format items</param>
+ /// <param name="args">An Object array containing zero or more objects to format</param>
+ /// <remarks>
+ /// <para>
+ /// The message is formatted using the <c>String.Format</c> method. See
+ /// <see cref="M:String.Format(string, object[])"/> for details of the syntax of the format string and the behavior
+ /// of the formatting.
+ /// </para>
+ /// <para>
+ /// This method does not take an <see cref="Exception"/> object to include in the
+ /// log event. To pass an <see cref="Exception"/> use one of the <see cref="M:Warn(object)"/>
+ /// methods instead.
+ /// </para>
+ /// </remarks>
+ /// <seealso cref="M:Warn(object,Exception)"/>
+ /// <seealso cref="IsWarnEnabled"/>
+ void WarnFormat(string format, params object[] args);
- /// <summary>
- /// Logs a formatted message string with the <see cref="Level.Warn"/> level.
- /// </summary>
- /// <param name="format">A String containing zero or more format items</param>
- /// <param name="arg0">An Object to format</param>
- /// <remarks>
- /// <para>
- /// The message is formatted using the <c>String.Format</c> method. See
- /// <see cref="M:String.Format(string, object[])"/> for details of the syntax of the format string and the behavior
- /// of the formatting.
- /// </para>
- /// <para>
- /// This method does not take an <see cref="Exception"/> object to include in the
- /// log event. To pass an <see cref="Exception"/> use one of the <see cref="M:Warn(object,Exception)"/>
- /// methods instead.
- /// </para>
- /// </remarks>
- /// <seealso cref="M:Warn(object)"/>
- /// <seealso cref="IsWarnEnabled"/>
- void WarnFormat(string format, object arg0);
+ /// <summary>
+ /// Logs a formatted message string with the <see cref="Level.Warn"/> level.
+ /// </summary>
+ /// <param name="format">A String containing zero or more format items</param>
+ /// <param name="arg0">An Object to format</param>
+ /// <remarks>
+ /// <para>
+ /// The message is formatted using the <c>String.Format</c> method. See
+ /// <see cref="M:String.Format(string, object[])"/> for details of the syntax of the format string and the behavior
+ /// of the formatting.
+ /// </para>
+ /// <para>
+ /// This method does not take an <see cref="Exception"/> object to include in the
+ /// log event. To pass an <see cref="Exception"/> use one of the <see cref="M:Warn(object,Exception)"/>
+ /// methods instead.
+ /// </para>
+ /// </remarks>
+ /// <seealso cref="M:Warn(object)"/>
+ /// <seealso cref="IsWarnEnabled"/>
+ void WarnFormat(string format, object arg0);
- /// <summary>
- /// Logs a formatted message string with the <see cref="Level.Warn"/> level.
- /// </summary>
- /// <param name="format">A String containing zero or more format items</param>
- /// <param name="arg0">An Object to format</param>
- /// <param name="arg1">An Object to format</param>
- /// <remarks>
- /// <para>
- /// The message is formatted using the <c>String.Format</c> method. See
- /// <see cref="M:String.Format(string, object[])"/> for details of the syntax of the format string and the behavior
- /// of the formatting.
- /// </para>
- /// <para>
- /// This method does not take an <see cref="Exception"/> object to include in the
- /// log event. To pass an <see cref="Exception"/> use one of the <see cref="M:Warn(object,Exception)"/>
- /// methods instead.
- /// </para>
- /// </remarks>
- /// <seealso cref="M:Warn(object)"/>
- /// <seealso cref="IsWarnEnabled"/>
- void WarnFormat(string format, object arg0, object arg1);
+ /// <summary>
+ /// Logs a formatted message string with the <see cref="Level.Warn"/> level.
+ /// </summary>
+ /// <param name="format">A String containing zero or more format items</param>
+ /// <param name="arg0">An Object to format</param>
+ /// <param name="arg1">An Object to format</param>
+ /// <remarks>
+ /// <para>
+ /// The message is formatted using the <c>String.Format</c> method. See
+ /// <see cref="M:String.Format(string, object[])"/> for details of the syntax of the format string and the behavior
+ /// of the formatting.
+ /// </para>
+ /// <para>
+ /// This method does not take an <see cref="Exception"/> object to include in the
+ /// log event. To pass an <see cref="Exception"/> use one of the <see cref="M:Warn(object,Exception)"/>
+ /// methods instead.
+ /// </para>
+ /// </remarks>
+ /// <seealso cref="M:Warn(object)"/>
+ /// <seealso cref="IsWarnEnabled"/>
+ void WarnFormat(string format, object arg0, object arg1);
- /// <summary>
- /// Logs a formatted message string with the <see cref="Level.Warn"/> level.
- /// </summary>
- /// <param name="format">A String containing zero or more format items</param>
- /// <param name="arg0">An Object to format</param>
- /// <param name="arg1">An Object to format</param>
- /// <param name="arg2">An Object to format</param>
- /// <remarks>
- /// <para>
- /// The message is formatted using the <c>String.Format</c> method. See
- /// <see cref="M:String.Format(string, object[])"/> for details of the syntax of the format string and the behavior
- /// of the formatting.
- /// </para>
- /// <para>
- /// This method does not take an <see cref="Exception"/> object to include in the
- /// log event. To pass an <see cref="Exception"/> use one of the <see cref="M:Warn(object,Exception)"/>
- /// methods instead.
- /// </para>
- /// </remarks>
- /// <seealso cref="M:Warn(object)"/>
- /// <seealso cref="IsWarnEnabled"/>
- void WarnFormat(string format, object arg0, object arg1, object arg2);
+ /// <summary>
+ /// Logs a formatted message string with the <see cref="Level.Warn"/> level.
+ /// </summary>
+ /// <param name="format">A String containing zero or more format items</param>
+ /// <param name="arg0">An Object to format</param>
+ /// <param name="arg1">An Object to format</param>
+ /// <param name="arg2">An Object to format</param>
+ /// <remarks>
+ /// <para>
+ /// The message is formatted using the <c>String.Format</c> method. See
+ /// <see cref="M:String.Format(string, object[])"/> for details of the syntax of the format string and the behavior
+ /// of the formatting.
+ /// </para>
+ /// <para>
+ /// This method does not take an <see cref="Exception"/> object to include in the
+ /// log event. To pass an <see cref="Exception"/> use one of the <see cref="M:Warn(object,Exception)"/>
+ /// methods instead.
+ /// </para>
+ /// </remarks>
+ /// <seealso cref="M:Warn(object)"/>
+ /// <seealso cref="IsWarnEnabled"/>
+ void WarnFormat(string format, object arg0, object arg1, object arg2);
- /// <summary>
- /// Logs a formatted message string with the <see cref="Level.Warn"/> level.
- /// </summary>
- /// <param name="provider">An <see cref="IFormatProvider"/> that supplies culture-specific formatting information</param>
- /// <param name="format">A String containing zero or more format items</param>
- /// <param name="args">An Object array containing zero or more objects to format</param>
- /// <remarks>
- /// <para>
- /// The message is formatted using the <c>String.Format</c> method. See
- /// <see cref="M:String.Format(string, object[])"/> for details of the syntax of the format string and the behavior
- /// of the formatting.
- /// </para>
- /// <para>
- /// This method does not take an <see cref="Exception"/> object to include in the
- /// log event. To pass an <see cref="Exception"/> use one of the <see cref="M:Warn(object)"/>
- /// methods instead.
- /// </para>
- /// </remarks>
- /// <seealso cref="M:Warn(object,Exception)"/>
- /// <seealso cref="IsWarnEnabled"/>
- void WarnFormat(IFormatProvider provider, string format, params object[] args);
+ /// <summary>
+ /// Logs a formatted message string with the <see cref="Level.Warn"/> level.
+ /// </summary>
+ /// <param name="provider">An <see cref="IFormatProvider"/> that supplies culture-specific formatting information</param>
+ /// <param name="format">A String containing zero or more format items</param>
+ /// <param name="args">An Object array containing zero or more objects to format</param>
+ /// <remarks>
+ /// <para>
+ /// The message is formatted using the <c>String.Format</c> method. See
+ /// <see cref="M:String.Format(string, object[])"/> for details of the syntax of the format string and the behavior
+ /// of the formatting.
+ /// </para>
+ /// <para>
+ /// This method does not take an <see cref="Exception"/> object to include in the
+ /// log event. To pass an <see cref="Exception"/> use one of the <see cref="M:Warn(object)"/>
+ /// methods instead.
+ /// </para>
+ /// </remarks>
+ /// <seealso cref="M:Warn(object,Exception)"/>
+ /// <seealso cref="IsWarnEnabled"/>
+ void WarnFormat(IFormatProvider provider, string format, params object[] args);
- /// <overloads>Log a message object with the <see cref="Level.Error"/> level.</overloads>
- /// <summary>
- /// Logs a message object with the <see cref="Level.Error"/> level.
- /// </summary>
- /// <param name="message">The message object to log.</param>
- /// <remarks>
- /// <para>
- /// This method first checks if this logger is <c>ERROR</c>
- /// enabled by comparing the level of this logger with the
- /// <see cref="Level.Error"/> level. If this logger is
- /// <c>ERROR</c> enabled, then it converts the message object
- /// (passed as parameter) to a string by invoking the appropriate
- /// <see cref="log4net.ObjectRenderer.IObjectRenderer"/>. It then
- /// proceeds to call all the registered appenders in this logger
- /// and also higher in the hierarchy depending on the value of the
- /// additivity flag.
- /// </para>
- /// <para><b>WARNING</b> Note that passing an <see cref="Exception"/>
- /// to this method will print the name of the <see cref="Exception"/>
- /// but no stack trace. To print a stack trace use the
- /// <see cref="M:Error(object,Exception)"/> form instead.
- /// </para>
- /// </remarks>
- /// <seealso cref="M:Error(object,Exception)"/>
- /// <seealso cref="IsErrorEnabled"/>
- void Error(object message);
+ /// <overloads>Log a message object with the <see cref="Level.Error"/> level.</overloads>
+ /// <summary>
+ /// Logs a message object with the <see cref="Level.Error"/> level.
+ /// </summary>
+ /// <param name="message">The message object to log.</param>
+ /// <remarks>
+ /// <para>
+ /// This method first checks if this logger is <c>ERROR</c>
+ /// enabled by comparing the level of this logger with the
+ /// <see cref="Level.Error"/> level. If this logger is
+ /// <c>ERROR</c> enabled, then it converts the message object
+ /// (passed as parameter) to a string by invoking the appropriate
+ /// <see cref="log4net.ObjectRenderer.IObjectRenderer"/>. It then
+ /// proceeds to call all the registered appenders in this logger
+ /// and also higher in the hierarchy depending on the value of the
+ /// additivity flag.
+ /// </para>
+ /// <para><b>WARNING</b> Note that passing an <see cref="Exception"/>
+ /// to this method will print the name of the <see cref="Exception"/>
+ /// but no stack trace. To print a stack trace use the
+ /// <see cref="M:Error(object,Exception)"/> form instead.
+ /// </para>
+ /// </remarks>
+ /// <seealso cref="M:Error(object,Exception)"/>
+ /// <seealso cref="IsErrorEnabled"/>
+ void Error(object message);
- /// <summary>
- /// Log a message object with the <see cref="Level.Error"/> level including
- /// the stack trace of the <see cref="Exception"/> passed
- /// as a parameter.
- /// </summary>
- /// <param name="message">The message object to log.</param>
- /// <param name="exception">The exception to log, including its stack trace.</param>
- /// <remarks>
- /// <para>
- /// See the <see cref="M:Error(object)"/> form for more detailed information.
- /// </para>
- /// </remarks>
- /// <seealso cref="M:Error(object)"/>
- /// <seealso cref="IsErrorEnabled"/>
- void Error(object message, Exception exception);
+ /// <summary>
+ /// Log a message object with the <see cref="Level.Error"/> level including
+ /// the stack trace of the <see cref="Exception"/> passed
+ /// as a parameter.
+ /// </summary>
+ /// <param name="message">The message object to log.</param>
+ /// <param name="exception">The exception to log, including its stack trace.</param>
+ /// <remarks>
+ /// <para>
+ /// See the <see cref="M:Error(object)"/> form for more detailed information.
+ /// </para>
+ /// </remarks>
+ /// <seealso cref="M:Error(object)"/>
+ /// <seealso cref="IsErrorEnabled"/>
+ void Error(object message, Exception exception);
- /// <overloads>Log a formatted message string with the <see cref="Level.Error"/> level.</overloads>
- /// <summary>
- /// Logs a formatted message string with the <see cref="Level.Error"/> level.
- /// </summary>
- /// <param name="format">A String containing zero or more format items</param>
- /// <param name="args">An Object array containing zero or more objects to format</param>
- /// <remarks>
- /// <para>
- /// The message is formatted using the <c>String.Format</c> method. See
- /// <see cref="M:String.Format(string, object[])"/> for details of the syntax of the format string and the behavior
- /// of the formatting.
- /// </para>
- /// <para>
- /// This method does not take an <see cref="Exception"/> object to include in the
- /// log event. To pass an <see cref="Exception"/> use one of the <see cref="M:Error(object)"/>
- /// methods instead.
- /// </para>
- /// </remarks>
- /// <seealso cref="M:Error(object,Exception)"/>
- /// <seealso cref="IsErrorEnabled"/>
- void ErrorFormat(string format, params object[] args);
+ /// <overloads>Log a formatted message string with the <see cref="Level.Error"/> level.</overloads>
+ /// <summary>
+ /// Logs a formatted message string with the <see cref="Level.Error"/> level.
+ /// </summary>
+ /// <param name="format">A String containing zero or more format items</param>
+ /// <param name="args">An Object array containing zero or more objects to format</param>
+ /// <remarks>
+ /// <para>
+ /// The message is formatted using the <c>String.Format</c> method. See
+ /// <see cref="M:String.Format(string, object[])"/> for details of the syntax of the format string and the behavior
+ /// of the formatting.
+ /// </para>
+ /// <para>
+ /// This method does not take an <see cref="Exception"/> object to include in the
+ /// log event. To pass an <see cref="Exception"/> use one of the <see cref="M:Error(object)"/>
+ /// methods instead.
+ /// </para>
+ /// </remarks>
+ /// <seealso cref="M:Error(object,Exception)"/>
+ /// <seealso cref="IsErrorEnabled"/>
+ void ErrorFormat(string format, params object[] args);
- /// <summary>
- /// Logs a formatted message string with the <see cref="Level.Error"/> level.
- /// </summary>
- /// <param name="format">A String containing zero or more format items</param>
- /// <param name="arg0">An Object to format</param>
- /// <remarks>
- /// <para>
- /// The message is formatted using the <c>String.Format</c> method. See
- /// <see cref="M:String.Format(string, object[])"/> for details of the syntax of the format string and the behavior
- /// of the formatting.
- /// </para>
- /// <para>
- /// This method does not take an <see cref="Exception"/> object to include in the
- /// log event. To pass an <see cref="Exception"/> use one of the <see cref="M:Error(object,Exception)"/>
- /// methods instead.
- /// </para>
- /// </remarks>
- /// <seealso cref="M:Error(object)"/>
- /// <seealso cref="IsErrorEnabled"/>
- void ErrorFormat(string format, object arg0);
+ /// <summary>
+ /// Logs a formatted message string with the <see cref="Level.Error"/> level.
+ /// </summary>
+ /// <param name="format">A String containing zero or more format items</param>
+ /// <param name="arg0">An Object to format</param>
+ /// <remarks>
+ /// <para>
+ /// The message is formatted using the <c>String.Format</c> method. See
+ /// <see cref="M:String.Format(string, object[])"/> for details of the syntax of the format string and the behavior
+ /// of the formatting.
+ /// </para>
+ /// <para>
+ /// This method does not take an <see cref="Exception"/> object to include in the
+ /// log event. To pass an <see cref="Exception"/> use one of the <see cref="M:Error(object,Exception)"/>
+ /// methods instead.
+ /// </para>
+ /// </remarks>
+ /// <seealso cref="M:Error(object)"/>
+ /// <seealso cref="IsErrorEnabled"/>
+ void ErrorFormat(string format, object arg0);
- /// <summary>
- /// Logs a formatted message string with the <see cref="Level.Error"/> level.
- /// </summary>
- /// <param name="format">A String containing zero or more format items</param>
- /// <param name="arg0">An Object to format</param>
- /// <param name="arg1">An Object to format</param>
- /// <remarks>
- /// <para>
- /// The message is formatted using the <c>String.Format</c> method. See
- /// <see cref="M:String.Format(string, object[])"/> for details of the syntax of the format string and the behavior
- /// of the formatting.
- /// </para>
- /// <para>
- /// This method does not take an <see cref="Exception"/> object to include in the
- /// log event. To pass an <see cref="Exception"/> use one of the <see cref="M:Error(object,Exception)"/>
- /// methods instead.
- /// </para>
- /// </remarks>
- /// <seealso cref="M:Error(object)"/>
- /// <seealso cref="IsErrorEnabled"/>
- void ErrorFormat(string format, object arg0, object arg1);
+ /// <summary>
+ /// Logs a formatted message string with the <see cref="Level.Error"/> level.
+ /// </summary>
+ /// <param name="format">A String containing zero or more format items</param>
+ /// <param name="arg0">An Object to format</param>
+ /// <param name="arg1">An Object to format</param>
+ /// <remarks>
+ /// <para>
+ /// The message is formatted using the <c>String.Format</c> method. See
+ /// <see cref="M:String.Format(string, object[])"/> for details of the syntax of the format string and the behavior
+ /// of the formatting.
+ /// </para>
+ /// <para>
+ /// This method does not take an <see cref="Exception"/> object to include in the
+ /// log event. To pass an <see cref="Exception"/> use one of the <see cref="M:Error(object,Exception)"/>
+ /// methods instead.
+ /// </para>
+ /// </remarks>
+ /// <seealso cref="M:Error(object)"/>
+ /// <seealso cref="IsErrorEnabled"/>
+ void ErrorFormat(string format, object arg0, object arg1);
- /// <summary>
- /// Logs a formatted message string with the <see cref="Level.Error"/> level.
- /// </summary>
- /// <param name="format">A String containing zero or more format items</param>
- /// <param name="arg0">An Object to format</param>
- /// <param name="arg1">An Object to format</param>
- /// <param name="arg2">An Object to format</param>
- /// <remarks>
- /// <para>
- /// The message is formatted using the <c>String.Format</c> method. See
- /// <see cref="M:String.Format(string, object[])"/> for details of the syntax of the format string and the behavior
- /// of the formatting.
- /// </para>
- /// <para>
- /// This method does not take an <see cref="Exception"/> object to include in the
- /// log event. To pass an <see cref="Exception"/> use one of the <see cref="M:Error(object,Exception)"/>
- /// methods instead.
- /// </para>
- /// </remarks>
- /// <seealso cref="M:Error(object)"/>
- /// <seealso cref="IsErrorEnabled"/>
- void ErrorFormat(string format, object arg0, object arg1, object arg2);
+ /// <summary>
+ /// Logs a formatted message string with the <see cref="Level.Error"/> level.
+ /// </summary>
+ /// <param name="format">A String containing zero or more format items</param>
+ /// <param name="arg0">An Object to format</param>
+ /// <param name="arg1">An Object to format</param>
+ /// <param name="arg2">An Object to format</param>
+ /// <remarks>
+ /// <para>
+ /// The message is formatted using the <c>String.Format</c> method. See
+ /// <see cref="M:String.Format(string, object[])"/> for details of the syntax of the format string and the behavior
+ /// of the formatting.
+ /// </para>
+ /// <para>
+ /// This method does not take an <see cref="Exception"/> object to include in the
+ /// log event. To pass an <see cref="Exception"/> use one of the <see cref="M:Error(object,Exception)"/>
+ /// methods instead.
+ /// </para>
+ /// </remarks>
+ /// <seealso cref="M:Error(object)"/>
+ /// <seealso cref="IsErrorEnabled"/>
+ void ErrorFormat(string format, object arg0, object arg1, object arg2);
- /// <summary>
- /// Logs a formatted message string with the <see cref="Level.Error"/> level.
- /// </summary>
- /// <param name="provider">An <see cref="IFormatProvider"/> that supplies culture-specific formatting information</param>
- /// <param name="format">A String containing zero or more format items</param>
- /// <param name="args">An Object array containing zero or more objects to format</param>
- /// <remarks>
- /// <para>
- /// The message is formatted using the <c>String.Format</c> method. See
- /// <see cref="M:String.Format(string, object[])"/> for details of the syntax of the format string and the behavior
- /// of the formatting.
- /// </para>
- /// <para>
- /// This method does not take an <see cref="Exception"/> object to include in the
- /// log event. To pass an <see cref="Exception"/> use one of the <see cref="M:Error(object)"/>
- /// methods instead.
- /// </para>
- /// </remarks>
- /// <seealso cref="M:Error(object,Exception)"/>
- /// <seealso cref="IsErrorEnabled"/>
- void ErrorFormat(IFormatProvider provider, string format, params object[] args);
+ /// <summary>
+ /// Logs a formatted message string with the <see cref="Level.Error"/> level.
+ /// </summary>
+ /// <param name="provider">An <see cref="IFormatProvider"/> that supplies culture-specific formatting information</param>
+ /// <param name="format">A String containing zero or more format items</param>
+ /// <param name="args">An Object array containing zero or more objects to format</param>
+ /// <remarks>
+ /// <para>
+ /// The message is formatted using the <c>String.Format</c> method. See
+ /// <see cref="M:String.Format(string, object[])"/> for details of the syntax of the format string and the behavior
+ /// of the formatting.
+ /// </para>
+ /// <para>
+ /// This method does not take an <see cref="Exception"/> object to include in the
+ /// log event. To pass an <see cref="Exception"/> use one of the <see cref="M:Error(object)"/>
+ /// methods instead.
+ /// </para>
+ /// </remarks>
+ /// <seealso cref="M:Error(object,Exception)"/>
+ /// <seealso cref="IsErrorEnabled"/>
+ void ErrorFormat(IFormatProvider provider, string format, params object[] args);
- /// <overloads>Log a message object with the <see cref="Level.Fatal"/> level.</overloads>
- /// <summary>
- /// Log a message object with the <see cref="Level.Fatal"/> level.
- /// </summary>
- /// <remarks>
- /// <para>
- /// This method first checks if this logger is <c>FATAL</c>
- /// enabled by comparing the level of this logger with the
- /// <see cref="Level.Fatal"/> level. If this logger is
- /// <c>FATAL</c> enabled, then it converts the message object
- /// (passed as parameter) to a string by invoking the appropriate
- /// <see cref="log4net.ObjectRenderer.IObjectRenderer"/>. It then
- /// proceeds to call all the registered appenders in this logger
- /// and also higher in the hierarchy depending on the value of the
- /// additivity flag.
- /// </para>
- /// <para><b>WARNING</b> Note that passing an <see cref="Exception"/>
- /// to this method will print the name of the <see cref="Exception"/>
- /// but no stack trace. To print a stack trace use the
- /// <see cref="M:Fatal(object,Exception)"/> form instead.
- /// </para>
- /// </remarks>
- /// <param name="message">The message object to log.</param>
- /// <seealso cref="M:Fatal(object,Exception)"/>
- /// <seealso cref="IsFatalEnabled"/>
- void Fatal(object message);
+ /// <overloads>Log a message object with the <see cref="Level.Fatal"/> level.</overloads>
+ /// <summary>
+ /// Log a message object with the <see cref="Level.Fatal"/> level.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// This method first checks if this logger is <c>FATAL</c>
+ /// enabled by comparing the level of this logger with the
+ /// <see cref="Level.Fatal"/> level. If this logger is
+ /// <c>FATAL</c> enabled, then it converts the message object
+ /// (passed as parameter) to a string by invoking the appropriate
+ /// <see cref="log4net.ObjectRenderer.IObjectRenderer"/>. It then
+ /// proceeds to call all the registered appenders in this logger
+ /// and also higher in the hierarchy depending on the value of the
+ /// additivity flag.
+ /// </para>
+ /// <para><b>WARNING</b> Note that passing an <see cref="Exception"/>
+ /// to this method will print the name of the <see cref="Exception"/>
+ /// but no stack trace. To print a stack trace use the
+ /// <see cref="M:Fatal(object,Exception)"/> form instead.
+ /// </para>
+ /// </remarks>
+ /// <param name="message">The message object to log.</param>
+ /// <seealso cref="M:Fatal(object,Exception)"/>
+ /// <seealso cref="IsFatalEnabled"/>
+ void Fatal(object message);
- /// <summary>
- /// Log a message object with the <see cref="Level.Fatal"/> level including
- /// the stack trace of the <see cref="Exception"/> passed
- /// as a parameter.
- /// </summary>
- /// <param name="message">The message object to log.</param>
- /// <param name="exception">The exception to log, including its stack trace.</param>
- /// <remarks>
- /// <para>
- /// See the <see cref="M:Fatal(object)"/> form for more detailed information.
- /// </para>
- /// </remarks>
- /// <seealso cref="M:Fatal(object)"/>
- /// <seealso cref="IsFatalEnabled"/>
- void Fatal(object message, Exception exception);
+ /// <summary>
+ /// Log a message object with the <see cref="Level.Fatal"/> level including
+ /// the stack trace of the <see cref="Exception"/> passed
+ /// as a parameter.
+ /// </summary>
+ /// <param name="message">The message object to log.</param>
+ /// <param name="exception">The exception to log, including its stack trace.</param>
+ /// <remarks>
+ /// <para>
+ /// See the <see cref="M:Fatal(object)"/> form for more detailed information.
+ /// </para>
+ /// </remarks>
+ /// <seealso cref="M:Fatal(object)"/>
+ /// <seealso cref="IsFatalEnabled"/>
+ void Fatal(object message, Exception exception);
- /// <overloads>Log a formatted message string with the <see cref="Level.Fatal"/> level.</overloads>
- /// <summary>
- /// Logs a formatted message string with the <see cref="Level.Fatal"/> level.
- /// </summary>
- /// <param name="format">A String containing zero or more format items</param>
- /// <param name="args">An Object array containing zero or more objects to format</param>
- /// <remarks>
- /// <para>
- /// The message is formatted using the <c>String.Format</c> method. See
- /// <see cref="M:String.Format(string, object[])"/> for details of the syntax of the format string and the behavior
- /// of the formatting.
- /// </para>
- /// <para>
- /// This method does not take an <see cref="Exception"/> object to include in the
- /// log event. To pass an <see cref="Exception"/> use one of the <see cref="M:Fatal(object)"/>
- /// methods instead.
- /// </para>
- /// </remarks>
- /// <seealso cref="M:Fatal(object,Exception)"/>
- /// <seealso cref="IsFatalEnabled"/>
- void FatalFormat(string format, params object[] args);
+ /// <overloads>Log a formatted message string with the <see cref="Level.Fatal"/> level.</overloads>
+ /// <summary>
+ /// Logs a formatted message string with the <see cref="Level.Fatal"/> level.
+ /// </summary>
+ /// <param name="format">A String containing zero or more format items</param>
+ /// <param name="args">An Object array containing zero or more objects to format</param>
+ /// <remarks>
+ /// <para>
+ /// The message is formatted using the <c>String.Format</c> method. See
+ /// <see cref="M:String.Format(string, object[])"/> for details of the syntax of the format string and the behavior
+ /// of the formatting.
+ /// </para>
+ /// <para>
+ /// This method does not take an <see cref="Exception"/> object to include in the
+ /// log event. To pass an <see cref="Exception"/> use one of the <see cref="M:Fatal(object)"/>
+ /// methods instead.
+ /// </para>
+ /// </remarks>
+ /// <seealso cref="M:Fatal(object,Exception)"/>
+ /// <seealso cref="IsFatalEnabled"/>
+ void FatalFormat(string format, params object[] args);
- /// <summary>
- /// Logs a formatted message string with the <see cref="Level.Fatal"/> level.
- /// </summary>
- /// <param name="format">A String containing zero or more format items</param>
- /// <param name="arg0">An Object to format</param>
- /// <remarks>
- /// <para>
- /// The message is formatted using the <c>String.Format</c> method. See
- /// <see cref="M:String.Format(string, object[])"/> for details of the syntax of the format string and the behavior
- /// of the formatting.
- /// </para>
- /// <para>
- /// This method does not take an <see cref="Exception"/> object to include in the
- /// log event. To pass an <see cref="Exception"/> use one of the <see cref="M:Fatal(object,Exception)"/>
- /// methods instead.
- /// </para>
- /// </remarks>
- /// <seealso cref="M:Fatal(object)"/>
- /// <seealso cref="IsFatalEnabled"/>
- void FatalFormat(string format, object arg0);
+ /// <summary>
+ /// Logs a formatted message string with the <see cref="Level.Fatal"/> level.
+ /// </summary>
+ /// <param name="format">A String containing zero or more format items</param>
+ /// <param name="arg0">An Object to format</param>
+ /// <remarks>
+ /// <para>
+ /// The message is formatted using the <c>String.Format</c> method. See
+ /// <see cref="M:String.Format(string, object[])"/> for details of the syntax of the format string and the behavior
+ /// of the formatting.
+ /// </para>
+ /// <para>
+ /// This method does not take an <see cref="Exception"/> object to include in the
+ /// log event. To pass an <see cref="Exception"/> use one of the <see cref="M:Fatal(object,Exception)"/>
+ /// methods instead.
+ /// </para>
+ /// </remarks>
+ /// <seealso cref="M:Fatal(object)"/>
+ /// <seealso cref="IsFatalEnabled"/>
+ void FatalFormat(string format, object arg0);
- /// <summary>
- /// Logs a formatted message string with the <see cref="Level.Fatal"/> level.
- /// </summary>
- /// <param name="format">A String containing zero or more format items</param>
- /// <param name="arg0">An Object to format</param>
- /// <param name="arg1">An Object to format</param>
- /// <remarks>
- /// <para>
- /// The message is formatted using the <c>String.Format</c> method. See
- /// <see cref="M:String.Format(string, object[])"/> for details of the syntax of the format string and the behavior
- /// of the formatting.
- /// </para>
- /// <para>
- /// This method does not take an <see cref="Exception"/> object to include in the
- /// log event. To pass an <see cref="Exception"/> use one of the <see cref="M:Fatal(object,Exception)"/>
- /// methods instead.
- /// </para>
- /// </remarks>
- /// <seealso cref="M:Fatal(object)"/>
- /// <seealso cref="IsFatalEnabled"/>
- void FatalFormat(string format, object arg0, object arg1);
+ /// <summary>
+ /// Logs a formatted message string with the <see cref="Level.Fatal"/> level.
+ /// </summary>
+ /// <param name="format">A String containing zero or more format items</param>
+ /// <param name="arg0">An Object to format</param>
+ /// <param name="arg1">An Object to format</param>
+ /// <remarks>
+ /// <para>
+ /// The message is formatted using the <c>String.Format</c> method. See
+ /// <see cref="M:String.Format(string, object[])"/> for details of the syntax of the format string and the behavior
+ /// of the formatting.
+ /// </para>
+ /// <para>
+ /// This method does not take an <see cref="Exception"/> object to include in the
+ /// log event. To pass an <see cref="Exception"/> use one of the <see cref="M:Fatal(object,Exception)"/>
+ /// methods instead.
+ /// </para>
+ /// </remarks>
+ /// <seealso cref="M:Fatal(object)"/>
+ /// <seealso cref="IsFatalEnabled"/>
+ void FatalFormat(string format, object arg0, object arg1);
- /// <summary>
- /// Logs a formatted message string with the <see cref="Level.Fatal"/> level.
- /// </summary>
- /// <param name="format">A String containing zero or more format items</param>
- /// <param name="arg0">An Object to format</param>
- /// <param name="arg1">An Object to format</param>
- /// <param name="arg2">An Object to format</param>
- /// <remarks>
- /// <para>
- /// The message is formatted using the <c>String.Format</c> method. See
- /// <see cref="M:String.Format(string, object[])"/> for details of the syntax of the format string and the behavior
- /// of the formatting.
- /// </para>
- /// <para>
- /// This method does not take an <see cref="Exception"/> object to include in the
- /// log event. To pass an <see cref="Exception"/> use one of the <see cref="M:Fatal(object,Exception)"/>
- /// methods instead.
- /// </para>
- /// </remarks>
- /// <seealso cref="M:Fatal(object)"/>
- /// <seealso cref="IsFatalEnabled"/>
- void FatalFormat(string format, object arg0, object arg1, object arg2);
+ /// <summary>
+ /// Logs a formatted message string with the <see cref="Level.Fatal"/> level.
+ /// </summary>
+ /// <param name="format">A String containing zero or more format items</param>
+ /// <param name="arg0">An Object to format</param>
+ /// <param name="arg1">An Object to format</param>
+ /// <param name="arg2">An Object to format</param>
+ /// <remarks>
+ /// <para>
+ /// The message is formatted using the <c>String.Format</c> method. See
+ /// <see cref="M:String.Format(string, object[])"/> for details of the syntax of the format string and the behavior
+ /// of the formatting.
+ /// </para>
+ /// <para>
+ /// This method does not take an <see cref="Exception"/> object to include in the
+ /// log event. To pass an <see cref="Exception"/> use one of the <see cref="M:Fatal(object,Exception)"/>
+ /// methods instead.
+ /// </para>
+ /// </remarks>
+ /// <seealso cref="M:Fatal(object)"/>
+ /// <seealso cref="IsFatalEnabled"/>
+ void FatalFormat(string format, object arg0, object arg1, object arg2);
- /// <summary>
- /// Logs a formatted message string with the <see cref="Level.Fatal"/> level.
- /// </summary>
- /// <param name="provider">An <see cref="IFormatProvider"/> that supplies culture-specific formatting information</param>
- /// <param name="format">A String containing zero or more format items</param>
- /// <param name="args">An Object array containing zero or more objects to format</param>
- /// <remarks>
- /// <para>
- /// The message is formatted using the <c>String.Format</c> method. See
- /// <see cref="M:String.Format(string, object[])"/> for details of the syntax of the format string and the behavior
- /// of the formatting.
- /// </para>
- /// <para>
- /// This method does not take an <see cref="Exception"/> object to include in the
- /// log event. To pass an <see cref="Exception"/> use one of the <see cref="M:Fatal(object)"/>
- /// methods instead.
- /// </para>
- /// </remarks>
- /// <seealso cref="M:Fatal(object,Exception)"/>
- /// <seealso cref="IsFatalEnabled"/>
- void FatalFormat(IFormatProvider provider, string format, params object[] args);
+ /// <summary>
+ /// Logs a formatted message string with the <see cref="Level.Fatal"/> level.
+ /// </summary>
+ /// <param name="provider">An <see cref="IFormatProvider"/> that supplies culture-specific formatting information</param>
+ /// <param name="format">A String containing zero or more format items</param>
+ /// <param name="args">An Object array containing zero or more objects to format</param>
+ /// <remarks>
+ /// <para>
+ /// The message is formatted using the <c>String.Format</c> method. See
+ /// <see cref="M:String.Format(string, object[])"/> for details of the syntax of the format string and the behavior
+ /// of the formatting.
+ /// </para>
+ /// <para>
+ /// This method does not take an <see cref="Exception"/> object to include in the
+ /// log event. To pass an <see cref="Exception"/> use one of the <see cref="M:Fatal(object)"/>
+ /// methods instead.
+ /// </para>
+ /// </remarks>
+ /// <seealso cref="M:Fatal(object,Exception)"/>
+ /// <seealso cref="IsFatalEnabled"/>
+ void FatalFormat(IFormatProvider provider, string format, params object[] args);
- /// <summary>
- /// Checks if this logger is enabled for the <see cref="Level.Debug"/> level.
- /// </summary>
- /// <value>
- /// <c>true</c> if this logger is enabled for <see cref="Level.Debug"/> events, <c>false</c> otherwise.
- /// </value>
- /// <remarks>
- /// <para>
- /// This function is intended to lessen the computational cost of
- /// disabled log debug statements.
- /// </para>
- /// <para> For some ILog interface <c>log</c>, when you write:</para>
- /// <code lang="C#">
- /// log.Debug("This is entry number: " + i );
- /// </code>
- /// <para>
- /// You incur the cost constructing the message, string construction and concatenation in
- /// this case, regardless of whether the message is logged or not.
- /// </para>
- /// <para>
- /// If you are worried about speed (who isn't), then you should write:
- /// </para>
- /// <code lang="C#">
- /// if (log.IsDebugEnabled)
- /// {
- /// log.Debug("This is entry number: " + i );
- /// }
- /// </code>
- /// <para>
- /// This way you will not incur the cost of parameter
- /// construction if debugging is disabled for <c>log</c>. On
- /// the other hand, if the <c>log</c> is debug enabled, you
- /// will incur the cost of evaluating whether the logger is debug
- /// enabled twice. Once in <see cref="IsDebugEnabled"/> and once in
- /// the <see cref="M:Debug(object)"/>. This is an insignificant overhead
- /// since evaluating a logger takes about 1% of the time it
- /// takes to actually log. This is the preferred style of logging.
- /// </para>
- /// <para>Alternatively if your logger is available statically then the is debug
- /// enabled state can be stored in a static variable like this:
- /// </para>
- /// <code lang="C#">
- /// private static readonly bool isDebugEnabled = log.IsDebugEnabled;
- /// </code>
- /// <para>
- /// Then when you come to log you can write:
- /// </para>
- /// <code lang="C#">
- /// if (isDebugEnabled)
- /// {
- /// log.Debug("This is entry number: " + i );
- /// }
- /// </code>
- /// <para>
- /// This way the debug enabled state is only queried once
- /// when the class is loaded. Using a <c>private static readonly</c>
- /// variable is the most efficient because it is a run time constant
- /// and can be heavily optimized by the JIT compiler.
- /// </para>
- /// <para>
- /// Of course if you use a static readonly variable to
- /// hold the enabled state of the logger then you cannot
- /// change the enabled state at runtime to vary the logging
- /// that is produced. You have to decide if you need absolute
- /// speed or runtime flexibility.
- /// </para>
- /// </remarks>
- /// <seealso cref="M:Debug(object)"/>
- /// <seealso cref="M:DebugFormat(IFormatProvider, string, object[])"/>
- bool IsDebugEnabled { get; }
+ /// <summary>
+ /// Checks if this logger is enabled for the <see cref="Level.Debug"/> level.
+ /// </summary>
+ /// <value>
+ /// <c>true</c> if this logger is enabled for <see cref="Level.Debug"/> events, <c>false</c> otherwise.
+ /// </value>
+ /// <remarks>
+ /// <para>
+ /// This function is intended to lessen the computational cost of
+ /// disabled log debug statements.
+ /// </para>
+ /// <para> For some ILog interface <c>log</c>, when you write:</para>
+ /// <code lang="C#">
+ /// log.Debug("This is entry number: " + i );
+ /// </code>
+ /// <para>
+ /// You incur the cost constructing the message, string construction and concatenation in
+ /// this case, regardless of whether the message is logged or not.
+ /// </para>
+ /// <para>
+ /// If you are worried about speed (who isn't), then you should write:
+ /// </para>
+ /// <code lang="C#">
+ /// if (log.IsDebugEnabled)
+ /// {
+ /// log.Debug("This is entry number: " + i );
+ /// }
+ /// </code>
+ /// <para>
+ /// This way you will not incur the cost of parameter
+ /// construction if debugging is disabled for <c>log</c>. On
+ /// the other hand, if the <c>log</c> is debug enabled, you
+ /// will incur the cost of evaluating whether the logger is debug
+ /// enabled twice. Once in <see cref="IsDebugEnabled"/> and once in
+ /// the <see cref="M:Debug(object)"/>. This is an insignificant overhead
+ /// since evaluating a logger takes about 1% of the time it
+ /// takes to actually log. This is the preferred style of logging.
+ /// </para>
+ /// <para>Alternatively if your logger is available statically then the is debug
+ /// enabled state can be stored in a static variable like this:
+ /// </para>
+ /// <code lang="C#">
+ /// private static readonly bool isDebugEnabled = log.IsDebugEnabled;
+ /// </code>
+ /// <para>
+ /// Then when you come to log you can write:
+ /// </para>
+ /// <code lang="C#">
+ /// if (isDebugEnabled)
+ /// {
+ /// log.Debug("This is entry number: " + i );
+ /// }
+ /// </code>
+ /// <para>
+ /// This way the debug enabled state is only queried once
+ /// when the class is loaded. Using a <c>private static readonly</c>
+ /// variable is the most efficient because it is a run time constant
+ /// and can be heavily optimized by the JIT compiler.
+ /// </para>
+ /// <para>
+ /// Of course if you use a static readonly variable to
+ /// hold the enabled state of the logger then you cannot
+ /// change the enabled state at runtime to vary the logging
+ /// that is produced. You have to decide if you need absolute
+ /// speed or runtime flexibility.
+ /// </para>
+ /// </remarks>
+ /// <seealso cref="M:Debug(object)"/>
+ /// <seealso cref="M:DebugFormat(IFormatProvider, string, object[])"/>
+ bool IsDebugEnabled { get; }
- /// <summary>
- /// Checks if this logger is enabled for the <see cref="Level.Info"/> level.
- /// </summary>
- /// <value>
- /// <c>true</c> if this logger is enabled for <see cref="Level.Info"/> events, <c>false</c> otherwise.
- /// </value>
- /// <remarks>
- /// For more information see <see cref="ILog.IsDebugEnabled"/>.
- /// </remarks>
- /// <seealso cref="M:Info(object)"/>
- /// <seealso cref="M:InfoFormat(IFormatProvider, string, object[])"/>
- /// <seealso cref="ILog.IsDebugEnabled"/>
- bool IsInfoEnabled { get; }
+ /// <summary>
+ /// Checks if this logger is enabled for the <see cref="Level.Info"/> level.
+ /// </summary>
+ /// <value>
+ /// <c>true</c> if this logger is enabled for <see cref="Level.Info"/> events, <c>false</c> otherwise.
+ /// </value>
+ /// <remarks>
+ /// For more information see <see cref="ILog.IsDebugEnabled"/>.
+ /// </remarks>
+ /// <seealso cref="M:Info(object)"/>
+ /// <seealso cref="M:InfoFormat(IFormatProvider, string, object[])"/>
+ /// <seealso cref="ILog.IsDebugEnabled"/>
+ bool IsInfoEnabled { get; }
- /// <summary>
- /// Checks if this logger is enabled for the <see cref="Level.Warn"/> level.
- /// </summary>
- /// <value>
- /// <c>true</c> if this logger is enabled for <see cref="Level.Warn"/> events, <c>false</c> otherwise.
- /// </value>
- /// <remarks>
- /// For more information see <see cref="ILog.IsDebugEnabled"/>.
- /// </remarks>
- /// <seealso cref="M:Warn(object)"/>
- /// <seealso cref="M:WarnFormat(IFormatProvider, string, object[])"/>
- /// <seealso cref="ILog.IsDebugEnabled"/>
- bool IsWarnEnabled { get; }
+ /// <summary>
+ /// Checks if this logger is enabled for the <see cref="Level.Warn"/> level.
+ /// </summary>
+ /// <value>
+ /// <c>true</c> if this logger is enabled for <see cref="Level.Warn"/> events, <c>false</c> otherwise.
+ /// </value>
+ /// <remarks>
+ /// For more information see <see cref="ILog.IsDebugEnabled"/>.
+ /// </remarks>
+ /// <seealso cref="M:Warn(object)"/>
+ /// <seealso cref="M:WarnFormat(IFormatProvider, string, object[])"/>
+ /// <seealso cref="ILog.IsDebugEnabled"/>
+ bool IsWarnEnabled { get; }
- /// <summary>
- /// Checks if this logger is enabled for the <see cref="Level.Error"/> level.
- /// </summary>
- /// <value>
- /// <c>true</c> if this logger is enabled for <see cref="Level.Error"/> events, <c>false</c> otherwise.
- /// </value>
- /// <remarks>
- /// For more information see <see cref="ILog.IsDebugEnabled"/>.
- /// </remarks>
- /// <seealso cref="M:Error(object)"/>
- /// <seealso cref="M:ErrorFormat(IFormatProvider, string, object[])"/>
- /// <seealso cref="ILog.IsDebugEnabled"/>
- bool IsErrorEnabled { get; }
+ /// <summary>
+ /// Checks if this logger is enabled for the <see cref="Level.Error"/> level.
+ /// </summary>
+ /// <value>
+ /// <c>true</c> if this logger is enabled for <see cref="Level.Error"/> events, <c>false</c> otherwise.
+ /// </value>
+ /// <remarks>
+ /// For more information see <see cref="ILog.IsDebugEnabled"/>.
+ /// </remarks>
+ /// <seealso cref="M:Error(object)"/>
+ /// <seealso cref="M:ErrorFormat(IFormatProvider, string, object[])"/>
+ /// <seealso cref="ILog.IsDebugEnabled"/>
+ bool IsErrorEnabled { get; }
- /// <summary>
- /// Checks if this logger is enabled for the <see cref="Level.Fatal"/> level.
- /// </summary>
- /// <value>
- /// <c>true</c> if this logger is enabled for <see cref="Level.Fatal"/> events, <c>false</c> otherwise.
- /// </value>
- /// <remarks>
- /// For more information see <see cref="ILog.IsDebugEnabled"/>.
- /// </remarks>
- /// <seealso cref="M:Fatal(object)"/>
- /// <seealso cref="M:FatalFormat(IFormatProvider, string, object[])"/>
- /// <seealso cref="ILog.IsDebugEnabled"/>
- bool IsFatalEnabled { get; }
- }
+ /// <summary>
+ /// Checks if this logger is enabled for the <see cref="Level.Fatal"/> level.
+ /// </summary>
+ /// <value>
+ /// <c>true</c> if this logger is enabled for <see cref="Level.Fatal"/> events, <c>false</c> otherwise.
+ /// </value>
+ /// <remarks>
+ /// For more information see <see cref="ILog.IsDebugEnabled"/>.
+ /// </remarks>
+ /// <seealso cref="M:Fatal(object)"/>
+ /// <seealso cref="M:FatalFormat(IFormatProvider, string, object[])"/>
+ /// <seealso cref="ILog.IsDebugEnabled"/>
+ bool IsFatalEnabled { get; }
+ }
}
diff --git a/src/log4net/Layout/DynamicPatternLayout.cs b/src/log4net/Layout/DynamicPatternLayout.cs
index 28174be..2f3e002 100644
--- a/src/log4net/Layout/DynamicPatternLayout.cs
+++ b/src/log4net/Layout/DynamicPatternLayout.cs
@@ -28,116 +28,116 @@
namespace log4net.Layout
{
- /// <summary>
- /// A flexible layout configurable with pattern string that re-evaluates on each call.
- /// </summary>
- /// <remarks>
- /// <para>This class is built on <see cref="PatternLayout"></see> and provides all the
- /// features and capabilities of PatternLayout. PatternLayout is a 'static' class
- /// in that its layout is done once at configuration time. This class will recreate
- /// the layout on each reference.</para>
- /// <para>One important difference between PatternLayout and DynamicPatternLayout is the
- /// treatment of the Header and Footer parameters in the configuration. The Header and Footer
- /// parameters for DynamicPatternLayout must be syntactically in the form of a PatternString,
- /// but should not be marked as type log4net.Util.PatternString. Doing so causes the
- /// pattern to be statically converted at configuration time and causes DynamicPatternLayout
- /// to perform the same as PatternLayout.</para>
- /// <para>Please see <see cref="PatternLayout"/> for complete documentation.</para>
- /// <example>
- /// <layout type="log4net.Layout.DynamicPatternLayout">
- /// <param name="Header" value="%newline**** Trace Opened Local: %date{yyyy-MM-dd HH:mm:ss.fff} UTC: %utcdate{yyyy-MM-dd HH:mm:ss.fff} ****%newline" />
- /// <param name="Footer" value="**** Trace Closed %date{yyyy-MM-dd HH:mm:ss.fff} ****%newline" />
- /// </layout>
- /// </example>
- /// </remarks>
- public class DynamicPatternLayout: PatternLayout
- {
- #region Member Variables
- /// <summary>
- /// The header PatternString
- /// </summary>
- private PatternString m_headerPatternString = new PatternString("");
+ /// <summary>
+ /// A flexible layout configurable with pattern string that re-evaluates on each call.
+ /// </summary>
+ /// <remarks>
+ /// <para>This class is built on <see cref="PatternLayout"></see> and provides all the
+ /// features and capabilities of PatternLayout. PatternLayout is a 'static' class
+ /// in that its layout is done once at configuration time. This class will recreate
+ /// the layout on each reference.</para>
+ /// <para>One important difference between PatternLayout and DynamicPatternLayout is the
+ /// treatment of the Header and Footer parameters in the configuration. The Header and Footer
+ /// parameters for DynamicPatternLayout must be syntactically in the form of a PatternString,
+ /// but should not be marked as type log4net.Util.PatternString. Doing so causes the
+ /// pattern to be statically converted at configuration time and causes DynamicPatternLayout
+ /// to perform the same as PatternLayout.</para>
+ /// <para>Please see <see cref="PatternLayout"/> for complete documentation.</para>
+ /// <example>
+ /// <layout type="log4net.Layout.DynamicPatternLayout">
+ /// <param name="Header" value="%newline**** Trace Opened Local: %date{yyyy-MM-dd HH:mm:ss.fff} UTC: %utcdate{yyyy-MM-dd HH:mm:ss.fff} ****%newline" />
+ /// <param name="Footer" value="**** Trace Closed %date{yyyy-MM-dd HH:mm:ss.fff} ****%newline" />
+ /// </layout>
+ /// </example>
+ /// </remarks>
+ public class DynamicPatternLayout: PatternLayout
+ {
+ #region Member Variables
+ /// <summary>
+ /// The header PatternString
+ /// </summary>
+ private PatternString m_headerPatternString = new PatternString("");
- /// <summary>
- /// The footer PatternString
- /// </summary>
- private PatternString m_footerPatternString = new PatternString("");
- #endregion
+ /// <summary>
+ /// The footer PatternString
+ /// </summary>
+ private PatternString m_footerPatternString = new PatternString("");
+ #endregion
- #region Constructors
- /// <summary>
- /// Constructs a DynamicPatternLayout using the DefaultConversionPattern
- /// </summary>
- /// <remarks>
- /// <para>
- /// The default pattern just produces the application supplied message.
- /// </para>
- /// </remarks>
- public DynamicPatternLayout()
- : base()
- {
- }
+ #region Constructors
+ /// <summary>
+ /// Constructs a DynamicPatternLayout using the DefaultConversionPattern
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// The default pattern just produces the application supplied message.
+ /// </para>
+ /// </remarks>
+ public DynamicPatternLayout()
+ : base()
+ {
+ }
- /// <summary>
- /// Constructs a DynamicPatternLayout using the supplied conversion pattern
- /// </summary>
- /// <param name="pattern">the pattern to use</param>
- /// <remarks>
- /// </remarks>
- public DynamicPatternLayout (string pattern)
- : base(pattern)
- {
- }
- #endregion
+ /// <summary>
+ /// Constructs a DynamicPatternLayout using the supplied conversion pattern
+ /// </summary>
+ /// <param name="pattern">the pattern to use</param>
+ /// <remarks>
+ /// </remarks>
+ public DynamicPatternLayout (string pattern)
+ : base(pattern)
+ {
+ }
+ #endregion
- #region Override implementation of LayoutSkeleton
- /// <summary>
- /// The header for the layout format.
- /// </summary>
- /// <value>the layout header</value>
- /// <remarks>
- /// <para>
- /// The Header text will be appended before any logging events
- /// are formatted and appended.
- /// </para>
- /// The pattern will be formatted on each get operation.
- /// </remarks>
- public override string Header
- {
- get
- {
- return m_headerPatternString.Format();
- }
- set
- {
- base.Header = value;
- m_headerPatternString = new PatternString(value);
- }
- } /* property DynamicPatternLayout Header */
+ #region Override implementation of LayoutSkeleton
+ /// <summary>
+ /// The header for the layout format.
+ /// </summary>
+ /// <value>the layout header</value>
+ /// <remarks>
+ /// <para>
+ /// The Header text will be appended before any logging events
+ /// are formatted and appended.
+ /// </para>
+ /// The pattern will be formatted on each get operation.
+ /// </remarks>
+ public override string Header
+ {
+ get
+ {
+ return m_headerPatternString.Format();
+ }
+ set
+ {
+ base.Header = value;
+ m_headerPatternString = new PatternString(value);
+ }
+ } /* property DynamicPatternLayout Header */
- /// <summary>
- /// The footer for the layout format.
- /// </summary>
- /// <value>the layout footer</value>
- /// <remarks>
- /// <para>
- /// The Footer text will be appended after all the logging events
- /// have been formatted and appended.
- /// </para>
- /// The pattern will be formatted on each get operation.
- /// </remarks>
- public override string Footer
- {
- get
- {
- return m_footerPatternString.Format();
- }
- set
- {
- base.Footer = value;
- m_footerPatternString = new PatternString(value);
- }
- } /* property DynamicPatternLayout Footer */
- #endregion
- } /* class DynamicPatternLayout */
-} /* namespace log4net.Layout */
+ /// <summary>
+ /// The footer for the layout format.
+ /// </summary>
+ /// <value>the layout footer</value>
+ /// <remarks>
+ /// <para>
+ /// The Footer text will be appended after all the logging events
+ /// have been formatted and appended.
+ /// </para>
+ /// The pattern will be formatted on each get operation.
+ /// </remarks>
+ public override string Footer
+ {
+ get
+ {
+ return m_footerPatternString.Format();
+ }
+ set
+ {
+ base.Footer = value;
+ m_footerPatternString = new PatternString(value);
+ }
+ } /* property DynamicPatternLayout Footer */
+ #endregion
+ } /* class DynamicPatternLayout */
+} /* namespace log4net.Layout */
diff --git a/src/log4net/Layout/ExceptionLayout.cs b/src/log4net/Layout/ExceptionLayout.cs
index 9021707..2748b0d 100644
--- a/src/log4net/Layout/ExceptionLayout.cs
+++ b/src/log4net/Layout/ExceptionLayout.cs
@@ -26,83 +26,83 @@
namespace log4net.Layout
{
- /// <summary>
- /// A Layout that renders only the Exception text from the logging event
- /// </summary>
- /// <remarks>
- /// <para>
- /// A Layout that renders only the Exception text from the logging event.
- /// </para>
- /// <para>
- /// This Layout should only be used with appenders that utilize multiple
- /// layouts (e.g. <see cref="log4net.Appender.AdoNetAppender"/>).
- /// </para>
- /// </remarks>
- /// <author>Nicko Cadell</author>
- /// <author>Gert Driesen</author>
- public class ExceptionLayout : LayoutSkeleton
- {
- #region Constructors
+ /// <summary>
+ /// A Layout that renders only the Exception text from the logging event
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// A Layout that renders only the Exception text from the logging event.
+ /// </para>
+ /// <para>
+ /// This Layout should only be used with appenders that utilize multiple
+ /// layouts (e.g. <see cref="log4net.Appender.AdoNetAppender"/>).
+ /// </para>
+ /// </remarks>
+ /// <author>Nicko Cadell</author>
+ /// <author>Gert Driesen</author>
+ public class ExceptionLayout : LayoutSkeleton
+ {
+ #region Constructors
- /// <summary>
- /// Default constructor
- /// </summary>
- /// <remarks>
- /// <para>
- /// Constructs a ExceptionLayout
- /// </para>
- /// </remarks>
- public ExceptionLayout()
- {
- this.IgnoresException = false;
- }
+ /// <summary>
+ /// Default constructor
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Constructs a ExceptionLayout
+ /// </para>
+ /// </remarks>
+ public ExceptionLayout()
+ {
+ this.IgnoresException = false;
+ }
- #endregion
+ #endregion
- #region Implementation of IOptionHandler
+ #region Implementation of IOptionHandler
- /// <summary>
- /// Activate component options
- /// </summary>
- /// <remarks>
- /// <para>
- /// Part of the <see cref="IOptionHandler"/> component activation
- /// framework.
- /// </para>
- /// <para>
- /// This method does nothing as options become effective immediately.
- /// </para>
- /// </remarks>
- public override void ActivateOptions()
- {
- // nothing to do.
- }
+ /// <summary>
+ /// Activate component options
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Part of the <see cref="IOptionHandler"/> component activation
+ /// framework.
+ /// </para>
+ /// <para>
+ /// This method does nothing as options become effective immediately.
+ /// </para>
+ /// </remarks>
+ public override void ActivateOptions()
+ {
+ // nothing to do.
+ }
- #endregion
+ #endregion
- #region Override implementation of LayoutSkeleton
+ #region Override implementation of LayoutSkeleton
- /// <summary>
- /// Gets the exception text from the logging event
- /// </summary>
- /// <param name="writer">The TextWriter to write the formatted event to</param>
- /// <param name="loggingEvent">the event being logged</param>
- /// <remarks>
- /// <para>
- /// Write the exception string to the <see cref="TextWriter"/>.
- /// The exception string is retrieved from <see cref="M:LoggingEvent.GetExceptionString()"/>.
- /// </para>
- /// </remarks>
- public override void Format(TextWriter writer, LoggingEvent loggingEvent)
- {
- if (loggingEvent == null)
- {
- throw new ArgumentNullException("loggingEvent");
- }
+ /// <summary>
+ /// Gets the exception text from the logging event
+ /// </summary>
+ /// <param name="writer">The TextWriter to write the formatted event to</param>
+ /// <param name="loggingEvent">the event being logged</param>
+ /// <remarks>
+ /// <para>
+ /// Write the exception string to the <see cref="TextWriter"/>.
+ /// The exception string is retrieved from <see cref="M:LoggingEvent.GetExceptionString()"/>.
+ /// </para>
+ /// </remarks>
+ public override void Format(TextWriter writer, LoggingEvent loggingEvent)
+ {
+ if (loggingEvent == null)
+ {
+ throw new ArgumentNullException("loggingEvent");
+ }
- writer.Write(loggingEvent.GetExceptionString());
- }
+ writer.Write(loggingEvent.GetExceptionString());
+ }
- #endregion
- }
+ #endregion
+ }
}
diff --git a/src/log4net/Layout/ILayout.cs b/src/log4net/Layout/ILayout.cs
index 2bb6aef..6e2e997 100644
--- a/src/log4net/Layout/ILayout.cs
+++ b/src/log4net/Layout/ILayout.cs
@@ -25,97 +25,97 @@
namespace log4net.Layout
{
- /// <summary>
- /// Interface implemented by layout objects
- /// </summary>
- /// <remarks>
- /// <para>
- /// An <see cref="ILayout"/> object is used to format a <see cref="LoggingEvent"/>
- /// as text. The <see cref="M:Format(TextWriter,LoggingEvent)"/> method is called by an
- /// appender to transform the <see cref="LoggingEvent"/> into a string.
- /// </para>
- /// <para>
- /// The layout can also supply <see cref="Header"/> and <see cref="Footer"/>
- /// text that is appender before any events and after all the events respectively.
- /// </para>
- /// </remarks>
- /// <author>Nicko Cadell</author>
- /// <author>Gert Driesen</author>
- public interface ILayout
- {
- /// <summary>
- /// Implement this method to create your own layout format.
- /// </summary>
- /// <param name="writer">The TextWriter to write the formatted event to</param>
- /// <param name="loggingEvent">The event to format</param>
- /// <remarks>
- /// <para>
- /// This method is called by an appender to format
- /// the <paramref name="loggingEvent"/> as text and output to a writer.
- /// </para>
- /// <para>
- /// If the caller does not have a <see cref="TextWriter"/> and prefers the
- /// event to be formatted as a <see cref="String"/> then the following
- /// code can be used to format the event into a <see cref="StringWriter"/>.
- /// </para>
- /// <code lang="C#">
- /// StringWriter writer = new StringWriter();
- /// Layout.Format(writer, loggingEvent);
- /// string formattedEvent = writer.ToString();
- /// </code>
- /// </remarks>
- void Format(TextWriter writer, LoggingEvent loggingEvent);
+ /// <summary>
+ /// Interface implemented by layout objects
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// An <see cref="ILayout"/> object is used to format a <see cref="LoggingEvent"/>
+ /// as text. The <see cref="M:Format(TextWriter,LoggingEvent)"/> method is called by an
+ /// appender to transform the <see cref="LoggingEvent"/> into a string.
+ /// </para>
+ /// <para>
+ /// The layout can also supply <see cref="Header"/> and <see cref="Footer"/>
+ /// text that is appender before any events and after all the events respectively.
+ /// </para>
+ /// </remarks>
+ /// <author>Nicko Cadell</author>
+ /// <author>Gert Driesen</author>
+ public interface ILayout
+ {
+ /// <summary>
+ /// Implement this method to create your own layout format.
+ /// </summary>
+ /// <param name="writer">The TextWriter to write the formatted event to</param>
+ /// <param name="loggingEvent">The event to format</param>
+ /// <remarks>
+ /// <para>
+ /// This method is called by an appender to format
+ /// the <paramref name="loggingEvent"/> as text and output to a writer.
+ /// </para>
+ /// <para>
+ /// If the caller does not have a <see cref="TextWriter"/> and prefers the
+ /// event to be formatted as a <see cref="String"/> then the following
+ /// code can be used to format the event into a <see cref="StringWriter"/>.
+ /// </para>
+ /// <code lang="C#">
+ /// StringWriter writer = new StringWriter();
+ /// Layout.Format(writer, loggingEvent);
+ /// string formattedEvent = writer.ToString();
+ /// </code>
+ /// </remarks>
+ void Format(TextWriter writer, LoggingEvent loggingEvent);
- /// <summary>
- /// The content type output by this layout.
- /// </summary>
- /// <value>The content type</value>
- /// <remarks>
- /// <para>
- /// The content type output by this layout.
- /// </para>
- /// <para>
- /// This is a MIME type e.g. <c>"text/plain"</c>.
- /// </para>
- /// </remarks>
- string ContentType { get; }
+ /// <summary>
+ /// The content type output by this layout.
+ /// </summary>
+ /// <value>The content type</value>
+ /// <remarks>
+ /// <para>
+ /// The content type output by this layout.
+ /// </para>
+ /// <para>
+ /// This is a MIME type e.g. <c>"text/plain"</c>.
+ /// </para>
+ /// </remarks>
+ string ContentType { get; }
- /// <summary>
- /// The header for the layout format.
- /// </summary>
- /// <value>the layout header</value>
- /// <remarks>
- /// <para>
- /// The Header text will be appended before any logging events
- /// are formatted and appended.
- /// </para>
- /// </remarks>
- string Header { get; }
+ /// <summary>
+ /// The header for the layout format.
+ /// </summary>
+ /// <value>the layout header</value>
+ /// <remarks>
+ /// <para>
+ /// The Header text will be appended before any logging events
+ /// are formatted and appended.
+ /// </para>
+ /// </remarks>
+ string Header { get; }
- /// <summary>
- /// The footer for the layout format.
- /// </summary>
- /// <value>the layout footer</value>
- /// <remarks>
- /// <para>
- /// The Footer text will be appended after all the logging events
- /// have been formatted and appended.
- /// </para>
- /// </remarks>
- string Footer { get; }
+ /// <summary>
+ /// The footer for the layout format.
+ /// </summary>
+ /// <value>the layout footer</value>
+ /// <remarks>
+ /// <para>
+ /// The Footer text will be appended after all the logging events
+ /// have been formatted and appended.
+ /// </para>
+ /// </remarks>
+ string Footer { get; }
- /// <summary>
- /// Flag indicating if this layout handle exceptions
- /// </summary>
- /// <value><c>false</c> if this layout handles exceptions</value>
- /// <remarks>
- /// <para>
- /// If this layout handles the exception object contained within
- /// <see cref="LoggingEvent"/>, then the layout should return
- /// <c>false</c>. Otherwise, if the layout ignores the exception
- /// object, then the layout should return <c>true</c>.
- /// </para>
- /// </remarks>
- bool IgnoresException { get; }
- }
+ /// <summary>
+ /// Flag indicating if this layout handle exceptions
+ /// </summary>
+ /// <value><c>false</c> if this layout handles exceptions</value>
+ /// <remarks>
+ /// <para>
+ /// If this layout handles the exception object contained within
+ /// <see cref="LoggingEvent"/>, then the layout should return
+ /// <c>false</c>. Otherwise, if the layout ignores the exception
+ /// object, then the layout should return <c>true</c>.
+ /// </para>
+ /// </remarks>
+ bool IgnoresException { get; }
+ }
}
diff --git a/src/log4net/Layout/IRawLayout.cs b/src/log4net/Layout/IRawLayout.cs
index 41cbf97..4f93b01 100644
--- a/src/log4net/Layout/IRawLayout.cs
+++ b/src/log4net/Layout/IRawLayout.cs
@@ -25,37 +25,37 @@
namespace log4net.Layout
{
- /// <summary>
- /// Interface for raw layout objects
- /// </summary>
- /// <remarks>
- /// <para>
- /// Interface used to format a <see cref="LoggingEvent"/>
- /// to an object.
- /// </para>
- /// <para>
- /// This interface should not be confused with the
- /// <see cref="ILayout"/> interface. This interface is used in
- /// only certain specialized situations where a raw object is
- /// required rather than a formatted string. The <see cref="ILayout"/>
- /// is not generally useful than this interface.
- /// </para>
- /// </remarks>
- /// <author>Nicko Cadell</author>
- /// <author>Gert Driesen</author>
- [TypeConverter(typeof(RawLayoutConverter))]
- public interface IRawLayout
- {
- /// <summary>
- /// Implement this method to create your own layout format.
- /// </summary>
- /// <param name="loggingEvent">The event to format</param>
- /// <returns>returns the formatted event</returns>
- /// <remarks>
- /// <para>
- /// Implement this method to create your own layout format.
- /// </para>
- /// </remarks>
- object Format(LoggingEvent loggingEvent);
- }
+ /// <summary>
+ /// Interface for raw layout objects
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Interface used to format a <see cref="LoggingEvent"/>
+ /// to an object.
+ /// </para>
+ /// <para>
+ /// This interface should not be confused with the
+ /// <see cref="ILayout"/> interface. This interface is used in
+ /// only certain specialized situations where a raw object is
+ /// required rather than a formatted string. The <see cref="ILayout"/>
+ /// is not generally useful than this interface.
+ /// </para>
+ /// </remarks>
+ /// <author>Nicko Cadell</author>
+ /// <author>Gert Driesen</author>
+ [TypeConverter(typeof(RawLayoutConverter))]
+ public interface IRawLayout
+ {
+ /// <summary>
+ /// Implement this method to create your own layout format.
+ /// </summary>
+ /// <param name="loggingEvent">The event to format</param>
+ /// <returns>returns the formatted event</returns>
+ /// <remarks>
+ /// <para>
+ /// Implement this method to create your own layout format.
+ /// </para>
+ /// </remarks>
+ object Format(LoggingEvent loggingEvent);
+ }
}
diff --git a/src/log4net/Layout/Layout2RawLayoutAdapter.cs b/src/log4net/Layout/Layout2RawLayoutAdapter.cs
index 9b92bf4..7f8ff25 100644
--- a/src/log4net/Layout/Layout2RawLayoutAdapter.cs
+++ b/src/log4net/Layout/Layout2RawLayoutAdapter.cs
@@ -25,69 +25,69 @@
namespace log4net.Layout
{
- /// <summary>
- /// Adapts any <see cref="ILayout"/> to a <see cref="IRawLayout"/>
- /// </summary>
- /// <remarks>
- /// <para>
- /// Where an <see cref="IRawLayout"/> is required this adapter
- /// allows a <see cref="ILayout"/> to be specified.
- /// </para>
- /// </remarks>
- /// <author>Nicko Cadell</author>
- /// <author>Gert Driesen</author>
- public class Layout2RawLayoutAdapter : IRawLayout
- {
- #region Member Variables
+ /// <summary>
+ /// Adapts any <see cref="ILayout"/> to a <see cref="IRawLayout"/>
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Where an <see cref="IRawLayout"/> is required this adapter
+ /// allows a <see cref="ILayout"/> to be specified.
+ /// </para>
+ /// </remarks>
+ /// <author>Nicko Cadell</author>
+ /// <author>Gert Driesen</author>
+ public class Layout2RawLayoutAdapter : IRawLayout
+ {
+ #region Member Variables
- /// <summary>
- /// The layout to adapt
- /// </summary>
- private ILayout m_layout;
+ /// <summary>
+ /// The layout to adapt
+ /// </summary>
+ private ILayout m_layout;
- #endregion
+ #endregion
- #region Constructors
+ #region Constructors
- /// <summary>
- /// Construct a new adapter
- /// </summary>
- /// <param name="layout">the layout to adapt</param>
- /// <remarks>
- /// <para>
- /// Create the adapter for the specified <paramref name="layout"/>.
- /// </para>
- /// </remarks>
- public Layout2RawLayoutAdapter(ILayout layout)
- {
- m_layout = layout;
- }
+ /// <summary>
+ /// Construct a new adapter
+ /// </summary>
+ /// <param name="layout">the layout to adapt</param>
+ /// <remarks>
+ /// <para>
+ /// Create the adapter for the specified <paramref name="layout"/>.
+ /// </para>
+ /// </remarks>
+ public Layout2RawLayoutAdapter(ILayout layout)
+ {
+ m_layout = layout;
+ }
- #endregion
+ #endregion
- #region Implementation of IRawLayout
+ #region Implementation of IRawLayout
- /// <summary>
- /// Format the logging event as an object.
- /// </summary>
- /// <param name="loggingEvent">The event to format</param>
- /// <returns>returns the formatted event</returns>
- /// <remarks>
- /// <para>
- /// Format the logging event as an object.
- /// </para>
- /// <para>
- /// Uses the <see cref="ILayout"/> object supplied to
- /// the constructor to perform the formatting.
- /// </para>
- /// </remarks>
- public virtual object Format(LoggingEvent loggingEvent)
- {
- using StringWriter writer = new StringWriter(System.Globalization.CultureInfo.InvariantCulture);
- m_layout.Format(writer, loggingEvent);
- return writer.ToString();
- }
+ /// <summary>
+ /// Format the logging event as an object.
+ /// </summary>
+ /// <param name="loggingEvent">The event to format</param>
+ /// <returns>returns the formatted event</returns>
+ /// <remarks>
+ /// <para>
+ /// Format the logging event as an object.
+ /// </para>
+ /// <para>
+ /// Uses the <see cref="ILayout"/> object supplied to
+ /// the constructor to perform the formatting.
+ /// </para>
+ /// </remarks>
+ public virtual object Format(LoggingEvent loggingEvent)
+ {
+ using StringWriter writer = new StringWriter(System.Globalization.CultureInfo.InvariantCulture);
+ m_layout.Format(writer, loggingEvent);
+ return writer.ToString();
+ }
- #endregion
- }
+ #endregion
+ }
}
diff --git a/src/log4net/Layout/LayoutSkeleton.cs b/src/log4net/Layout/LayoutSkeleton.cs
index 1f26c8e..e61374d 100644
--- a/src/log4net/Layout/LayoutSkeleton.cs
+++ b/src/log4net/Layout/LayoutSkeleton.cs
@@ -25,208 +25,208 @@
namespace log4net.Layout
{
- /// <summary>
- /// Extend this abstract class to create your own log layout format.
- /// </summary>
- /// <remarks>
- /// <para>
- /// This is the base implementation of the <see cref="ILayout"/>
- /// interface. Most layout objects should extend this class.
- /// </para>
- /// </remarks>
- /// <remarks>
- /// <note type="inheritinfo">
- /// <para>
- /// Subclasses must implement the <see cref="M:Format(TextWriter,LoggingEvent)"/>
- /// method.
- /// </para>
- /// <para>
- /// Subclasses should set the <see cref="IgnoresException"/> in their default
- /// constructor.
- /// </para>
- /// </note>
- /// </remarks>
- /// <author>Nicko Cadell</author>
- /// <author>Gert Driesen</author>
- public abstract class LayoutSkeleton : ILayout, IOptionHandler
- {
- #region Member Variables
+ /// <summary>
+ /// Extend this abstract class to create your own log layout format.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// This is the base implementation of the <see cref="ILayout"/>
+ /// interface. Most layout objects should extend this class.
+ /// </para>
+ /// </remarks>
+ /// <remarks>
+ /// <note type="inheritinfo">
+ /// <para>
+ /// Subclasses must implement the <see cref="M:Format(TextWriter,LoggingEvent)"/>
+ /// method.
+ /// </para>
+ /// <para>
+ /// Subclasses should set the <see cref="IgnoresException"/> in their default
+ /// constructor.
+ /// </para>
+ /// </note>
+ /// </remarks>
+ /// <author>Nicko Cadell</author>
+ /// <author>Gert Driesen</author>
+ public abstract class LayoutSkeleton : ILayout, IOptionHandler
+ {
+ #region Member Variables
- /// <summary>
- /// The header text
- /// </summary>
- /// <remarks>
- /// <para>
- /// See <see cref="Header"/> for more information.
- /// </para>
- /// </remarks>
- private string m_header = null;
+ /// <summary>
+ /// The header text
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// See <see cref="Header"/> for more information.
+ /// </para>
+ /// </remarks>
+ private string m_header = null;
- /// <summary>
- /// The footer text
- /// </summary>
- /// <remarks>
- /// <para>
- /// See <see cref="Footer"/> for more information.
- /// </para>
- /// </remarks>
- private string m_footer = null;
+ /// <summary>
+ /// The footer text
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// See <see cref="Footer"/> for more information.
+ /// </para>
+ /// </remarks>
+ private string m_footer = null;
- /// <summary>
- /// Flag indicating if this layout handles exceptions
- /// </summary>
- /// <remarks>
- /// <para>
- /// <c>false</c> if this layout handles exceptions
- /// </para>
- /// </remarks>
- private bool m_ignoresException = true;
+ /// <summary>
+ /// Flag indicating if this layout handles exceptions
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// <c>false</c> if this layout handles exceptions
+ /// </para>
+ /// </remarks>
+ private bool m_ignoresException = true;
- #endregion
+ #endregion
- #region Constructors
+ #region Constructors
- /// <summary>
- /// Empty default constructor
- /// </summary>
- /// <remarks>
- /// <para>
- /// Empty default constructor
- /// </para>
- /// </remarks>
- protected LayoutSkeleton()
- {
- }
+ /// <summary>
+ /// Empty default constructor
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Empty default constructor
+ /// </para>
+ /// </remarks>
+ protected LayoutSkeleton()
+ {
+ }
- #endregion
+ #endregion
- #region Implementation of IOptionHandler
+ #region Implementation of IOptionHandler
- /// <summary>
- /// Activate component options
- /// </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>
- /// <para>
- /// This method must be implemented by the subclass.
- /// </para>
- /// </remarks>
- public abstract void ActivateOptions();
+ /// <summary>
+ /// Activate component options
+ /// </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>
+ /// <para>
+ /// This method must be implemented by the subclass.
+ /// </para>
+ /// </remarks>
+ public abstract void ActivateOptions();
- #endregion
+ #endregion
- #region Implementation of ILayout
+ #region Implementation of ILayout
- /// <summary>
- /// Implement this method to create your own layout format.
- /// </summary>
- /// <param name="writer">The TextWriter to write the formatted event to</param>
- /// <param name="loggingEvent">The event to format</param>
- /// <remarks>
- /// <para>
- /// This method is called by an appender to format
- /// the <paramref name="loggingEvent"/> as text.
- /// </para>
- /// </remarks>
- public abstract void Format(TextWriter writer, LoggingEvent loggingEvent);
+ /// <summary>
+ /// Implement this method to create your own layout format.
+ /// </summary>
+ /// <param name="writer">The TextWriter to write the formatted event to</param>
+ /// <param name="loggingEvent">The event to format</param>
+ /// <remarks>
+ /// <para>
+ /// This method is called by an appender to format
+ /// the <paramref name="loggingEvent"/> as text.
+ /// </para>
+ /// </remarks>
+ public abstract void Format(TextWriter writer, LoggingEvent loggingEvent);
- /// <summary>
- /// Convenience method for easily formatting the logging event into a string variable.
- /// </summary>
- /// <param name="loggingEvent"></param>
- /// <remarks>
- /// Creates a new StringWriter instance to store the formatted logging event.
- /// </remarks>
- public string Format(LoggingEvent loggingEvent)
- {
- using StringWriter writer = new StringWriter(System.Globalization.CultureInfo.InvariantCulture);
- Format(writer, loggingEvent);
- return writer.ToString();
- }
+ /// <summary>
+ /// Convenience method for easily formatting the logging event into a string variable.
+ /// </summary>
+ /// <param name="loggingEvent"></param>
+ /// <remarks>
+ /// Creates a new StringWriter instance to store the formatted logging event.
+ /// </remarks>
+ public string Format(LoggingEvent loggingEvent)
+ {
+ using StringWriter writer = new StringWriter(System.Globalization.CultureInfo.InvariantCulture);
+ Format(writer, loggingEvent);
+ return writer.ToString();
+ }
- /// <summary>
- /// The content type output by this layout.
- /// </summary>
- /// <value>The content type is <c>"text/plain"</c></value>
- /// <remarks>
- /// <para>
- /// The content type output by this layout.
- /// </para>
- /// <para>
- /// This base class uses the value <c>"text/plain"</c>.
- /// To change this value a subclass must override this
- /// property.
- /// </para>
- /// </remarks>
- public virtual string ContentType
- {
- get { return "text/plain"; }
- }
+ /// <summary>
+ /// The content type output by this layout.
+ /// </summary>
+ /// <value>The content type is <c>"text/plain"</c></value>
+ /// <remarks>
+ /// <para>
+ /// The content type output by this layout.
+ /// </para>
+ /// <para>
+ /// This base class uses the value <c>"text/plain"</c>.
+ /// To change this value a subclass must override this
+ /// property.
+ /// </para>
+ /// </remarks>
+ public virtual string ContentType
+ {
+ get { return "text/plain"; }
+ }
- /// <summary>
- /// The header for the layout format.
- /// </summary>
- /// <value>the layout header</value>
- /// <remarks>
- /// <para>
- /// The Header text will be appended before any logging events
- /// are formatted and appended.
- /// </para>
- /// </remarks>
- public virtual string Header
- {
- get { return m_header; }
- set { m_header = value; }
- }
+ /// <summary>
+ /// The header for the layout format.
+ /// </summary>
+ /// <value>the layout header</value>
+ /// <remarks>
+ /// <para>
+ /// The Header text will be appended before any logging events
+ /// are formatted and appended.
+ /// </para>
+ /// </remarks>
+ public virtual string Header
+ {
+ get { return m_header; }
+ set { m_header = value; }
+ }
- /// <summary>
- /// The footer for the layout format.
- /// </summary>
- /// <value>the layout footer</value>
- /// <remarks>
- /// <para>
- /// The Footer text will be appended after all the logging events
- /// have been formatted and appended.
- /// </para>
- /// </remarks>
- public virtual string Footer
- {
- get { return m_footer; }
- set { m_footer = value; }
- }
+ /// <summary>
+ /// The footer for the layout format.
+ /// </summary>
+ /// <value>the layout footer</value>
+ /// <remarks>
+ /// <para>
+ /// The Footer text will be appended after all the logging events
+ /// have been formatted and appended.
+ /// </para>
+ /// </remarks>
+ public virtual string Footer
+ {
+ get { return m_footer; }
+ set { m_footer = value; }
+ }
- /// <summary>
- /// Flag indicating if this layout handles exceptions
- /// </summary>
- /// <value><c>false</c> if this layout handles exceptions</value>
- /// <remarks>
- /// <para>
- /// If this layout handles the exception object contained within
- /// <see cref="LoggingEvent"/>, then the layout should return
- /// <c>false</c>. Otherwise, if the layout ignores the exception
- /// object, then the layout should return <c>true</c>.
- /// </para>
- /// <para>
- /// Set this value to override a this default setting. The default
- /// value is <c>true</c>, this layout does not handle the exception.
- /// </para>
- /// </remarks>
- public virtual bool IgnoresException
- {
- get { return m_ignoresException; }
- set { m_ignoresException = value; }
- }
+ /// <summary>
+ /// Flag indicating if this layout handles exceptions
+ /// </summary>
+ /// <value><c>false</c> if this layout handles exceptions</value>
+ /// <remarks>
+ /// <para>
+ /// If this layout handles the exception object contained within
+ /// <see cref="LoggingEvent"/>, then the layout should return
+ /// <c>false</c>. Otherwise, if the layout ignores the exception
+ /// object, then the layout should return <c>true</c>.
+ /// </para>
+ /// <para>
+ /// Set this value to override a this default setting. The default
+ /// value is <c>true</c>, this layout does not handle the exception.
+ /// </para>
+ /// </remarks>
+ public virtual bool IgnoresException
+ {
+ get { return m_ignoresException; }
+ set { m_ignoresException = value; }
+ }
- #endregion
- }
+ #endregion
+ }
}
diff --git a/src/log4net/Layout/Pattern/AppDomainPatternConverter.cs b/src/log4net/Layout/Pattern/AppDomainPatternConverter.cs
index 30b7f09..83eb2d5 100644
--- a/src/log4net/Layout/Pattern/AppDomainPatternConverter.cs
+++ b/src/log4net/Layout/Pattern/AppDomainPatternConverter.cs
@@ -25,31 +25,31 @@
namespace log4net.Layout.Pattern
{
- /// <summary>
- /// Write the event appdomain name to the output
- /// </summary>
- /// <remarks>
- /// <para>
- /// Writes the <see cref="LoggingEvent.Domain"/> to the output writer.
- /// </para>
- /// </remarks>
- /// <author>Daniel Cazzulino</author>
- /// <author>Nicko Cadell</author>
- internal sealed class AppDomainPatternConverter : PatternLayoutConverter
- {
- /// <summary>
- /// Write the event appdomain name to the output
- /// </summary>
- /// <param name="writer"><see cref="TextWriter" /> that will receive the formatted result.</param>
- /// <param name="loggingEvent">the event being logged</param>
- /// <remarks>
- /// <para>
- /// Writes the <see cref="LoggingEvent.Domain"/> to the output <paramref name="writer"/>.
- /// </para>
- /// </remarks>
- protected override void Convert(TextWriter writer, LoggingEvent loggingEvent)
- {
- writer.Write(loggingEvent.Domain);
- }
- }
+ /// <summary>
+ /// Write the event appdomain name to the output
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Writes the <see cref="LoggingEvent.Domain"/> to the output writer.
+ /// </para>
+ /// </remarks>
+ /// <author>Daniel Cazzulino</author>
+ /// <author>Nicko Cadell</author>
+ internal sealed class AppDomainPatternConverter : PatternLayoutConverter
+ {
+ /// <summary>
+ /// Write the event appdomain name to the output
+ /// </summary>
+ /// <param name="writer"><see cref="TextWriter" /> that will receive the formatted result.</param>
+ /// <param name="loggingEvent">the event being logged</param>
+ /// <remarks>
+ /// <para>
+ /// Writes the <see cref="LoggingEvent.Domain"/> to the output <paramref name="writer"/>.
+ /// </para>
+ /// </remarks>
+ protected override void Convert(TextWriter writer, LoggingEvent loggingEvent)
+ {
+ writer.Write(loggingEvent.Domain);
+ }
+ }
}
diff --git a/src/log4net/Layout/Pattern/AspNetCachePatternConverter.cs b/src/log4net/Layout/Pattern/AspNetCachePatternConverter.cs
index 31f2fc4..32c8cca 100644
--- a/src/log4net/Layout/Pattern/AspNetCachePatternConverter.cs
+++ b/src/log4net/Layout/Pattern/AspNetCachePatternConverter.cs
@@ -29,50 +29,50 @@
namespace log4net.Layout.Pattern
{
- /// <summary>
- /// Converter for items in the ASP.Net Cache.
- /// </summary>
- /// <remarks>
- /// <para>
- /// Outputs an item from the <see cref="HttpRuntime.Cache" />.
- /// </para>
- /// </remarks>
- /// <author>Ron Grabowski</author>
- internal sealed class AspNetCachePatternConverter : AspNetPatternLayoutConverter
- {
- /// <summary>
- /// Write the ASP.Net Cache item to the output
- /// </summary>
- /// <param name="writer"><see cref="TextWriter" /> that will receive the formatted result.</param>
- /// <param name="loggingEvent">The <see cref="LoggingEvent" /> on which the pattern converter should be executed.</param>
- /// <param name="httpContext">The <see cref="HttpContext" /> under which the ASP.Net request is running.</param>
- /// <remarks>
- /// <para>
- /// Writes out the value of a named property. The property name
- /// should be set in the <see cref="log4net.Util.PatternConverter.Option"/>
- /// property. If no property has been set, all key value pairs from the Cache will
- /// be written to the output.
- /// </para>
- /// </remarks>
- protected override void Convert(TextWriter writer, LoggingEvent loggingEvent, HttpContext httpContext)
- {
- if (HttpRuntime.Cache != null)
- {
- if (Option != null)
- {
- WriteObject(writer, loggingEvent.Repository, HttpRuntime.Cache[Option]);
- }
- else
- {
- WriteObject(writer, loggingEvent.Repository, HttpRuntime.Cache.GetEnumerator());
- }
- }
- else
- {
- writer.Write(SystemInfo.NotAvailableText);
- }
- }
- }
+ /// <summary>
+ /// Converter for items in the ASP.Net Cache.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Outputs an item from the <see cref="HttpRuntime.Cache" />.
+ /// </para>
+ /// </remarks>
+ /// <author>Ron Grabowski</author>
+ internal sealed class AspNetCachePatternConverter : AspNetPatternLayoutConverter
+ {
+ /// <summary>
+ /// Write the ASP.Net Cache item to the output
+ /// </summary>
+ /// <param name="writer"><see cref="TextWriter" /> that will receive the formatted result.</param>
+ /// <param name="loggingEvent">The <see cref="LoggingEvent" /> on which the pattern converter should be executed.</param>
+ /// <param name="httpContext">The <see cref="HttpContext" /> under which the ASP.Net request is running.</param>
+ /// <remarks>
+ /// <para>
+ /// Writes out the value of a named property. The property name
+ /// should be set in the <see cref="log4net.Util.PatternConverter.Option"/>
+ /// property. If no property has been set, all key value pairs from the Cache will
+ /// be written to the output.
+ /// </para>
+ /// </remarks>
+ protected override void Convert(TextWriter writer, LoggingEvent loggingEvent, HttpContext httpContext)
+ {
+ if (HttpRuntime.Cache != null)
+ {
+ if (Option != null)
+ {
+ WriteObject(writer, loggingEvent.Repository, HttpRuntime.Cache[Option]);
+ }
+ else
+ {
+ WriteObject(writer, loggingEvent.Repository, HttpRuntime.Cache.GetEnumerator());
+ }
+ }
+ else
+ {
+ writer.Write(SystemInfo.NotAvailableText);
+ }
+ }
+ }
}
#endif // !NETCF && !SSCLI && !CLIENT_PROFILE
diff --git a/src/log4net/Layout/Pattern/AspNetContextPatternConverter.cs b/src/log4net/Layout/Pattern/AspNetContextPatternConverter.cs
index effefe1..1cd902f 100644
--- a/src/log4net/Layout/Pattern/AspNetContextPatternConverter.cs
+++ b/src/log4net/Layout/Pattern/AspNetContextPatternConverter.cs
@@ -28,42 +28,42 @@
namespace log4net.Layout.Pattern
{
- /// <summary>
- /// Converter for items in the <see cref="HttpContext" />.
- /// </summary>
- /// <remarks>
- /// <para>
- /// Outputs an item from the <see cref="HttpContext" />.
- /// </para>
- /// </remarks>
- /// <author>Ron Grabowski</author>
- internal sealed class AspNetContextPatternConverter : AspNetPatternLayoutConverter
- {
- /// <summary>
- /// Write the ASP.Net HttpContext item to the output
- /// </summary>
- /// <param name="writer"><see cref="TextWriter" /> that will receive the formatted result.</param>
- /// <param name="loggingEvent">The <see cref="LoggingEvent" /> on which the pattern converter should be executed.</param>
- /// <param name="httpContext">The <see cref="HttpContext" /> under which the ASP.Net request is running.</param>
- /// <remarks>
- /// <para>
- /// Writes out the value of a named property. The property name
- /// should be set in the <see cref="log4net.Util.PatternConverter.Option"/>
- /// property.
- /// </para>
- /// </remarks>
- protected override void Convert(TextWriter writer, LoggingEvent loggingEvent, HttpContext httpContext)
- {
- if (Option != null)
- {
- WriteObject(writer, loggingEvent.Repository, httpContext.Items[Option]);
- }
- else
- {
- WriteObject(writer, loggingEvent.Repository, httpContext.Items);
- }
- }
- }
+ /// <summary>
+ /// Converter for items in the <see cref="HttpContext" />.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Outputs an item from the <see cref="HttpContext" />.
+ /// </para>
+ /// </remarks>
+ /// <author>Ron Grabowski</author>
+ internal sealed class AspNetContextPatternConverter : AspNetPatternLayoutConverter
+ {
+ /// <summary>
+ /// Write the ASP.Net HttpContext item to the output
+ /// </summary>
+ /// <param name="writer"><see cref="TextWriter" /> that will receive the formatted result.</param>
+ /// <param name="loggingEvent">The <see cref="LoggingEvent" /> on which the pattern converter should be executed.</param>
+ /// <param name="httpContext">The <see cref="HttpContext" /> under which the ASP.Net request is running.</param>
+ /// <remarks>
+ /// <para>
+ /// Writes out the value of a named property. The property name
+ /// should be set in the <see cref="log4net.Util.PatternConverter.Option"/>
+ /// property.
+ /// </para>
+ /// </remarks>
+ protected override void Convert(TextWriter writer, LoggingEvent loggingEvent, HttpContext httpContext)
+ {
+ if (Option != null)
+ {
+ WriteObject(writer, loggingEvent.Repository, httpContext.Items[Option]);
+ }
+ else
+ {
+ WriteObject(writer, loggingEvent.Repository, httpContext.Items);
+ }
+ }
+ }
}
#endif // !NETCF && !SSCLI && !CLIENT_PROFILE
diff --git a/src/log4net/Layout/Pattern/AspNetPatternConverter.cs b/src/log4net/Layout/Pattern/AspNetPatternConverter.cs
index f764790..17d2ca1 100644
--- a/src/log4net/Layout/Pattern/AspNetPatternConverter.cs
+++ b/src/log4net/Layout/Pattern/AspNetPatternConverter.cs
@@ -29,38 +29,38 @@
namespace log4net.Layout.Pattern
{
- /// <summary>
- /// Abstract class that provides access to the current HttpContext (<see cref="HttpContext.Current" />) that
- /// derived classes need.
- /// </summary>
- /// <remarks>
- /// This class handles the case when HttpContext.Current is null by writing
- /// <see cref="SystemInfo.NotAvailableText" /> to the writer.
- /// </remarks>
- /// <author>Ron Grabowski</author>
- internal abstract class AspNetPatternLayoutConverter : PatternLayoutConverter
- {
- protected override void Convert(TextWriter writer, LoggingEvent loggingEvent)
- {
- if (HttpContext.Current == null)
- {
- writer.Write(SystemInfo.NotAvailableText);
- }
- else
- {
- Convert(writer, loggingEvent, HttpContext.Current);
- }
- }
+ /// <summary>
+ /// Abstract class that provides access to the current HttpContext (<see cref="HttpContext.Current" />) that
+ /// derived classes need.
+ /// </summary>
+ /// <remarks>
+ /// This class handles the case when HttpContext.Current is null by writing
+ /// <see cref="SystemInfo.NotAvailableText" /> to the writer.
+ /// </remarks>
+ /// <author>Ron Grabowski</author>
+ internal abstract class AspNetPatternLayoutConverter : PatternLayoutConverter
+ {
+ protected override void Convert(TextWriter writer, LoggingEvent loggingEvent)
+ {
+ if (HttpContext.Current == null)
+ {
+ writer.Write(SystemInfo.NotAvailableText);
+ }
+ else
+ {
+ Convert(writer, loggingEvent, HttpContext.Current);
+ }
+ }
- /// <summary>
- /// Derived pattern converters must override this method in order to
- /// convert conversion specifiers in the correct way.
- /// </summary>
- /// <param name="writer"><see cref="TextWriter" /> that will receive the formatted result.</param>
- /// <param name="loggingEvent">The <see cref="LoggingEvent" /> on which the pattern converter should be executed.</param>
- /// <param name="httpContext">The <see cref="HttpContext" /> under which the ASP.Net request is running.</param>
- protected abstract void Convert(TextWriter writer, LoggingEvent loggingEvent, HttpContext httpContext);
- }
+ /// <summary>
+ /// Derived pattern converters must override this method in order to
+ /// convert conversion specifiers in the correct way.
+ /// </summary>
+ /// <param name="writer"><see cref="TextWriter" /> that will receive the formatted result.</param>
+ /// <param name="loggingEvent">The <see cref="LoggingEvent" /> on which the pattern converter should be executed.</param>
+ /// <param name="httpContext">The <see cref="HttpContext" /> under which the ASP.Net request is running.</param>
+ protected abstract void Convert(TextWriter writer, LoggingEvent loggingEvent, HttpContext httpContext);
+ }
}
#endif // !NETCF && !SSCLI && !CLIENT_PROFILE
diff --git a/src/log4net/Layout/Pattern/AspNetRequestPatternConverter.cs b/src/log4net/Layout/Pattern/AspNetRequestPatternConverter.cs
index 9a7c67b..2be5043 100644
--- a/src/log4net/Layout/Pattern/AspNetRequestPatternConverter.cs
+++ b/src/log4net/Layout/Pattern/AspNetRequestPatternConverter.cs
@@ -29,59 +29,59 @@
namespace log4net.Layout.Pattern
{
- /// <summary>
- /// Converter for items in the ASP.Net Cache.
- /// </summary>
- /// <remarks>
- /// <para>
- /// Outputs an item from the <see cref="HttpRuntime.Cache" />.
- /// </para>
- /// </remarks>
- /// <author>Ron Grabowski</author>
- internal sealed class AspNetRequestPatternConverter : AspNetPatternLayoutConverter
- {
- /// <summary>
- /// Write the ASP.Net Cache item to the output
- /// </summary>
- /// <param name="writer"><see cref="TextWriter" /> that will receive the formatted result.</param>
- /// <param name="loggingEvent">The <see cref="LoggingEvent" /> on which the pattern converter should be executed.</param>
- /// <param name="httpContext">The <see cref="HttpContext" /> under which the ASP.Net request is running.</param>
- /// <remarks>
- /// <para>
- /// Writes out the value of a named property. The property name
- /// should be set in the <see cref="log4net.Util.PatternConverter.Option"/>
- /// property.
- /// </para>
- /// </remarks>
- protected override void Convert(TextWriter writer, LoggingEvent loggingEvent, HttpContext httpContext)
- {
- HttpRequest request = null;
- try {
- request = httpContext.Request;
- } catch (HttpException) {
- // likely a case of running in IIS integrated mode
- // when inside an Application_Start event.
- // treat it like a case of the Request
- // property returning null
- }
+ /// <summary>
+ /// Converter for items in the ASP.Net Cache.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Outputs an item from the <see cref="HttpRuntime.Cache" />.
+ /// </para>
+ /// </remarks>
+ /// <author>Ron Grabowski</author>
+ internal sealed class AspNetRequestPatternConverter : AspNetPatternLayoutConverter
+ {
+ /// <summary>
+ /// Write the ASP.Net Cache item to the output
+ /// </summary>
+ /// <param name="writer"><see cref="TextWriter" /> that will receive the formatted result.</param>
+ /// <param name="loggingEvent">The <see cref="LoggingEvent" /> on which the pattern converter should be executed.</param>
+ /// <param name="httpContext">The <see cref="HttpContext" /> under which the ASP.Net request is running.</param>
+ /// <remarks>
+ /// <para>
+ /// Writes out the value of a named property. The property name
+ /// should be set in the <see cref="log4net.Util.PatternConverter.Option"/>
+ /// property.
+ /// </para>
+ /// </remarks>
+ protected override void Convert(TextWriter writer, LoggingEvent loggingEvent, HttpContext httpContext)
+ {
+ HttpRequest request = null;
+ try {
+ request = httpContext.Request;
+ } catch (HttpException) {
+ // likely a case of running in IIS integrated mode
+ // when inside an Application_Start event.
+ // treat it like a case of the Request
+ // property returning null
+ }
- if (request != null)
- {
- if (Option != null)
- {
- WriteObject(writer, loggingEvent.Repository, httpContext.Request.Params[Option]);
- }
- else
- {
- WriteObject(writer, loggingEvent.Repository, httpContext.Request.Params);
- }
- }
- else
- {
- writer.Write(SystemInfo.NotAvailableText);
- }
- }
- }
+ if (request != null)
+ {
+ if (Option != null)
+ {
+ WriteObject(writer, loggingEvent.Repository, httpContext.Request.Params[Option]);
+ }
+ else
+ {
+ WriteObject(writer, loggingEvent.Repository, httpContext.Request.Params);
+ }
+ }
+ else
+ {
+ writer.Write(SystemInfo.NotAvailableText);
+ }
+ }
+ }
}
#endif // !NETCF && !SSCLI && !CLIENT_PROFILE
diff --git a/src/log4net/Layout/Pattern/AspNetSessionPatternConverter.cs b/src/log4net/Layout/Pattern/AspNetSessionPatternConverter.cs
index d7e52b2..8cbcae6 100644
--- a/src/log4net/Layout/Pattern/AspNetSessionPatternConverter.cs
+++ b/src/log4net/Layout/Pattern/AspNetSessionPatternConverter.cs
@@ -29,50 +29,50 @@
namespace log4net.Layout.Pattern
{
- /// <summary>
- /// Converter for items in the ASP.Net Cache.
- /// </summary>
- /// <remarks>
- /// <para>
- /// Outputs an item from the <see cref="HttpRuntime.Cache" />.
- /// </para>
- /// </remarks>
- /// <author>Ron Grabowski</author>
- internal sealed class AspNetSessionPatternConverter : AspNetPatternLayoutConverter
- {
- /// <summary>
- /// Write the ASP.Net Cache item to the output
- /// </summary>
- /// <param name="writer"><see cref="TextWriter" /> that will receive the formatted result.</param>
- /// <param name="loggingEvent">The <see cref="LoggingEvent" /> on which the pattern converter should be executed.</param>
- /// <param name="httpContext">The <see cref="HttpContext" /> under which the ASP.Net request is running.</param>
- /// <remarks>
- /// <para>
- /// Writes out the value of a named property. The property name
- /// should be set in the <see cref="log4net.Util.PatternConverter.Option"/>
- /// property. If no property has been set, all key value pairs from the Session will
- /// be written to the output.
- /// </para>
- /// </remarks>
- protected override void Convert(TextWriter writer, LoggingEvent loggingEvent, HttpContext httpContext)
- {
- if (httpContext.Session != null)
- {
- if (Option != null)
- {
- WriteObject(writer, loggingEvent.Repository, httpContext.Session.Contents[Option]);
- }
- else
- {
- WriteObject(writer, loggingEvent.Repository, httpContext.Session);
- }
- }
- else
- {
- writer.Write(SystemInfo.NotAvailableText);
- }
- }
- }
+ /// <summary>
+ /// Converter for items in the ASP.Net Cache.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Outputs an item from the <see cref="HttpRuntime.Cache" />.
+ /// </para>
+ /// </remarks>
+ /// <author>Ron Grabowski</author>
+ internal sealed class AspNetSessionPatternConverter : AspNetPatternLayoutConverter
+ {
+ /// <summary>
+ /// Write the ASP.Net Cache item to the output
+ /// </summary>
+ /// <param name="writer"><see cref="TextWriter" /> that will receive the formatted result.</param>
+ /// <param name="loggingEvent">The <see cref="LoggingEvent" /> on which the pattern converter should be executed.</param>
+ /// <param name="httpContext">The <see cref="HttpContext" /> under which the ASP.Net request is running.</param>
+ /// <remarks>
+ /// <para>
+ /// Writes out the value of a named property. The property name
+ /// should be set in the <see cref="log4net.Util.PatternConverter.Option"/>
+ /// property. If no property has been set, all key value pairs from the Session will
+ /// be written to the output.
+ /// </para>
+ /// </remarks>
+ protected override void Convert(TextWriter writer, LoggingEvent loggingEvent, HttpContext httpContext)
+ {
+ if (httpContext.Session != null)
+ {
+ if (Option != null)
+ {
+ WriteObject(writer, loggingEvent.Repository, httpContext.Session.Contents[Option]);
+ }
+ else
+ {
+ WriteObject(writer, loggingEvent.Repository, httpContext.Session);
+ }
+ }
+ else
+ {
+ writer.Write(SystemInfo.NotAvailableText);
+ }
+ }
+ }
}
#endif // !NETCF && !SSCLI && !CLIENT_PROFILE
diff --git a/src/log4net/Layout/Pattern/DatePatternConverter.cs b/src/log4net/Layout/Pattern/DatePatternConverter.cs
index c283ba1..a111b8f 100644
--- a/src/log4net/Layout/Pattern/DatePatternConverter.cs
+++ b/src/log4net/Layout/Pattern/DatePatternConverter.cs
@@ -26,164 +26,164 @@
namespace log4net.Layout.Pattern
{
- /// <summary>
- /// Date pattern converter, uses a <see cref="IDateFormatter"/> to format
- /// the date of a <see cref="LoggingEvent"/>.
- /// </summary>
- /// <remarks>
- /// <para>
- /// Render the <see cref="LoggingEvent.TimeStamp"/> to the writer as a string.
- /// </para>
- /// <para>
- /// The value of the <see cref="log4net.Util.PatternConverter.Option"/> determines
- /// the formatting of the date. The following values are allowed:
- /// <list type="definition">
- /// <listheader>
- /// <term>Option value</term>
- /// <description>Output</description>
- /// </listheader>
- /// <item>
- /// <term>ISO8601</term>
- /// <description>
- /// Uses the <see cref="Iso8601DateFormatter"/> formatter.
- /// Formats using the <c>"yyyy-MM-dd HH:mm:ss,fff"</c> pattern.
- /// </description>
- /// </item>
- /// <item>
- /// <term>DATE</term>
- /// <description>
- /// Uses the <see cref="DateTimeDateFormatter"/> formatter.
- /// Formats using the <c>"dd MMM yyyy HH:mm:ss,fff"</c> for example, <c>"06 Nov 1994 15:49:37,459"</c>.
- /// </description>
- /// </item>
- /// <item>
- /// <term>ABSOLUTE</term>
- /// <description>
- /// Uses the <see cref="AbsoluteTimeDateFormatter"/> formatter.
- /// Formats using the <c>"HH:mm:ss,yyyy"</c> for example, <c>"15:49:37,459"</c>.
- /// </description>
- /// </item>
- /// <item>
- /// <term>other</term>
- /// <description>
- /// Any other pattern string uses the <see cref="SimpleDateFormatter"/> formatter.
- /// This formatter passes the pattern string to the <see cref="DateTime"/>
- /// <see cref="M:DateTime.ToString(string)"/> method.
- /// For details on valid patterns see
- /// <a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemglobalizationdatetimeformatinfoclasstopic.asp">DateTimeFormatInfo Class</a>.
- /// </description>
- /// </item>
- /// </list>
- /// </para>
- /// <para>
- /// The <see cref="LoggingEvent.TimeStamp"/> is in the local time zone and is rendered in that zone.
- /// To output the time in Universal time see <see cref="UtcDatePatternConverter"/>.
- /// </para>
- /// </remarks>
- /// <author>Nicko Cadell</author>
- internal class DatePatternConverter : PatternLayoutConverter, IOptionHandler
- {
- /// <summary>
- /// The <see cref="IDateFormatter"/> used to render the date to a string
- /// </summary>
- /// <remarks>
- /// <para>
- /// The <see cref="IDateFormatter"/> used to render the date to a string
- /// </para>
- /// </remarks>
- protected IDateFormatter m_dateFormatter;
-
- #region Implementation of IOptionHandler
+ /// <summary>
+ /// Date pattern converter, uses a <see cref="IDateFormatter"/> to format
+ /// the date of a <see cref="LoggingEvent"/>.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Render the <see cref="LoggingEvent.TimeStamp"/> to the writer as a string.
+ /// </para>
+ /// <para>
+ /// The value of the <see cref="log4net.Util.PatternConverter.Option"/> determines
+ /// the formatting of the date. The following values are allowed:
+ /// <list type="definition">
+ /// <listheader>
+ /// <term>Option value</term>
+ /// <description>Output</description>
+ /// </listheader>
+ /// <item>
+ /// <term>ISO8601</term>
+ /// <description>
+ /// Uses the <see cref="Iso8601DateFormatter"/> formatter.
+ /// Formats using the <c>"yyyy-MM-dd HH:mm:ss,fff"</c> pattern.
+ /// </description>
+ /// </item>
+ /// <item>
+ /// <term>DATE</term>
+ /// <description>
+ /// Uses the <see cref="DateTimeDateFormatter"/> formatter.
+ /// Formats using the <c>"dd MMM yyyy HH:mm:ss,fff"</c> for example, <c>"06 Nov 1994 15:49:37,459"</c>.
+ /// </description>
+ /// </item>
+ /// <item>
+ /// <term>ABSOLUTE</term>
+ /// <description>
+ /// Uses the <see cref="AbsoluteTimeDateFormatter"/> formatter.
+ /// Formats using the <c>"HH:mm:ss,yyyy"</c> for example, <c>"15:49:37,459"</c>.
+ /// </description>
+ /// </item>
+ /// <item>
+ /// <term>other</term>
+ /// <description>
+ /// Any other pattern string uses the <see cref="SimpleDateFormatter"/> formatter.
+ /// This formatter passes the pattern string to the <see cref="DateTime"/>
+ /// <see cref="M:DateTime.ToString(string)"/> method.
+ /// For details on valid patterns see
+ /// <a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemglobalizationdatetimeformatinfoclasstopic.asp">DateTimeFormatInfo Class</a>.
+ /// </description>
+ /// </item>
+ /// </list>
+ /// </para>
+ /// <para>
+ /// The <see cref="LoggingEvent.TimeStamp"/> is in the local time zone and is rendered in that zone.
+ /// To output the time in Universal time see <see cref="UtcDatePatternConverter"/>.
+ /// </para>
+ /// </remarks>
+ /// <author>Nicko Cadell</author>
+ internal class DatePatternConverter : PatternLayoutConverter, IOptionHandler
+ {
+ /// <summary>
+ /// The <see cref="IDateFormatter"/> used to render the date to a string
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// The <see cref="IDateFormatter"/> used to render the date to a string
+ /// </para>
+ /// </remarks>
+ protected IDateFormatter m_dateFormatter;
+
+ #region Implementation of IOptionHandler
- /// <summary>
- /// Initialize the converter pattern based on the <see cref="PatternConverter.Option"/> property.
- /// </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>
- public void ActivateOptions()
- {
- string dateFormatStr = Option;
- if (dateFormatStr == null)
- {
- dateFormatStr = AbsoluteTimeDateFormatter.Iso8601TimeDateFormat;
- }
+ /// <summary>
+ /// Initialize the converter pattern based on the <see cref="PatternConverter.Option"/> property.
+ /// </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>
+ public void ActivateOptions()
+ {
+ string dateFormatStr = Option;
+ if (dateFormatStr == null)
+ {
+ dateFormatStr = AbsoluteTimeDateFormatter.Iso8601TimeDateFormat;
+ }
- if (SystemInfo.EqualsIgnoringCase(dateFormatStr, AbsoluteTimeDateFormatter.Iso8601TimeDateFormat))
- {
- m_dateFormatter = new Iso8601DateFormatter();
- }
- else if (SystemInfo.EqualsIgnoringCase(dateFormatStr, AbsoluteTimeDateFormatter.AbsoluteTimeDateFormat))
- {
- m_dateFormatter = new AbsoluteTimeDateFormatter();
- }
- else if (SystemInfo.EqualsIgnoringCase(dateFormatStr, AbsoluteTimeDateFormatter.DateAndTimeDateFormat))
- {
- m_dateFormatter = new DateTimeDateFormatter();
- }
- else
- {
- try
- {
- m_dateFormatter = new SimpleDateFormatter(dateFormatStr);
- }
- catch (Exception e)
- {
- LogLog.Error(declaringType, "Could not instantiate SimpleDateFormatter with ["+dateFormatStr+"]", e);
- m_dateFormatter = new Iso8601DateFormatter();
- }
- }
- }
+ if (SystemInfo.EqualsIgnoringCase(dateFormatStr, AbsoluteTimeDateFormatter.Iso8601TimeDateFormat))
+ {
+ m_dateFormatter = new Iso8601DateFormatter();
+ }
+ else if (SystemInfo.EqualsIgnoringCase(dateFormatStr, AbsoluteTimeDateFormatter.AbsoluteTimeDateFormat))
+ {
+ m_dateFormatter = new AbsoluteTimeDateFormatter();
+ }
+ else if (SystemInfo.EqualsIgnoringCase(dateFormatStr, AbsoluteTimeDateFormatter.DateAndTimeDateFormat))
+ {
+ m_dateFormatter = new DateTimeDateFormatter();
+ }
+ else
+ {
+ try
+ {
+ m_dateFormatter = new SimpleDateFormatter(dateFormatStr);
+ }
+ catch (Exception e)
+ {
+ LogLog.Error(declaringType, "Could not instantiate SimpleDateFormatter with ["+dateFormatStr+"]", e);
+ m_dateFormatter = new Iso8601DateFormatter();
+ }
+ }
+ }
- #endregion
+ #endregion
- /// <summary>
- /// Convert the pattern into the rendered message
- /// </summary>
- /// <param name="writer"><see cref="TextWriter" /> that will receive the formatted result.</param>
- /// <param name="loggingEvent">the event being logged</param>
- /// <remarks>
- /// <para>
- /// Pass the <see cref="LoggingEvent.TimeStamp"/> to the <see cref="IDateFormatter"/>
- /// for it to render it to the writer.
- /// </para>
- /// <para>
- /// The <see cref="LoggingEvent.TimeStamp"/> passed is in the local time zone.
- /// </para>
- /// </remarks>
- protected override void Convert(TextWriter writer, LoggingEvent loggingEvent)
- {
- try
- {
- m_dateFormatter.FormatDate(loggingEvent.TimeStamp, writer);
- }
- catch (Exception ex)
- {
- LogLog.Error(declaringType, "Error occurred while converting date.", ex);
- }
- }
+ /// <summary>
+ /// Convert the pattern into the rendered message
+ /// </summary>
+ /// <param name="writer"><see cref="TextWriter" /> that will receive the formatted result.</param>
+ /// <param name="loggingEvent">the event being logged</param>
+ /// <remarks>
+ /// <para>
+ /// Pass the <see cref="LoggingEvent.TimeStamp"/> to the <see cref="IDateFormatter"/>
+ /// for it to render it to the writer.
+ /// </para>
+ /// <para>
+ /// The <see cref="LoggingEvent.TimeStamp"/> passed is in the local time zone.
+ /// </para>
+ /// </remarks>
+ protected override void Convert(TextWriter writer, LoggingEvent loggingEvent)
+ {
+ try
+ {
+ m_dateFormatter.FormatDate(loggingEvent.TimeStamp, writer);
+ }
+ catch (Exception ex)
+ {
+ LogLog.Error(declaringType, "Error occurred while converting date.", ex);
+ }
+ }
- #region Private Static Fields
+ #region Private Static Fields
- /// <summary>
- /// The fully qualified type of the DatePatternConverter class.
- /// </summary>
- /// <remarks>
- /// Used by the internal logger to record the Type of the
- /// log message.
- /// </remarks>
- private static readonly Type declaringType = typeof(DatePatternConverter);
+ /// <summary>
+ /// The fully qualified type of the DatePatternConverter class.
+ /// </summary>
+ /// <remarks>
+ /// Used by the internal logger to record the Type of the
+ /// log message.
+ /// </remarks>
+ private static readonly Type declaringType = typeof(DatePatternConverter);
- #endregion Private Static Fields
- }
+ #endregion Private Static Fields
+ }
}
diff --git a/src/log4net/Layout/Pattern/ExceptionPatternConverter.cs b/src/log4net/Layout/Pattern/ExceptionPatternConverter.cs
index 0091304..275959b 100644
--- a/src/log4net/Layout/Pattern/ExceptionPatternConverter.cs
+++ b/src/log4net/Layout/Pattern/ExceptionPatternConverter.cs
@@ -23,115 +23,115 @@
namespace log4net.Layout.Pattern
{
- /// <summary>
- /// Write the exception text to the output
- /// </summary>
- /// <remarks>
- /// <para>
- /// If an exception object is stored in the logging event
- /// it will be rendered into the pattern output with a
- /// trailing newline.
- /// </para>
- /// <para>
- /// If there is no exception then nothing will be output
- /// and no trailing newline will be appended.
- /// It is typical to put a newline before the exception
- /// and to have the exception as the last data in the pattern.
- /// </para>
- /// </remarks>
- /// <author>Nicko Cadell</author>
- internal sealed class ExceptionPatternConverter : PatternLayoutConverter
- {
- /// <summary>
- /// Default constructor
- /// </summary>
- public ExceptionPatternConverter()
- {
- // This converter handles the exception
- IgnoresException = false;
- }
+ /// <summary>
+ /// Write the exception text to the output
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// If an exception object is stored in the logging event
+ /// it will be rendered into the pattern output with a
+ /// trailing newline.
+ /// </para>
+ /// <para>
+ /// If there is no exception then nothing will be output
+ /// and no trailing newline will be appended.
+ /// It is typical to put a newline before the exception
+ /// and to have the exception as the last data in the pattern.
+ /// </para>
+ /// </remarks>
+ /// <author>Nicko Cadell</author>
+ internal sealed class ExceptionPatternConverter : PatternLayoutConverter
+ {
+ /// <summary>
+ /// Default constructor
+ /// </summary>
+ public ExceptionPatternConverter()
+ {
+ // This converter handles the exception
+ IgnoresException = false;
+ }
- /// <summary>
- /// Write the exception text to the output
- /// </summary>
- /// <param name="writer"><see cref="TextWriter" /> that will receive the formatted result.</param>
- /// <param name="loggingEvent">the event being logged</param>
- /// <remarks>
- /// <para>
- /// If an exception object is stored in the logging event
- /// it will be rendered into the pattern output with a
- /// trailing newline.
- /// </para>
- /// <para>
- /// If there is no exception or the exception property specified
- /// by the Option value does not exist then nothing will be output
- /// and no trailing newline will be appended.
- /// It is typical to put a newline before the exception
- /// and to have the exception as the last data in the pattern.
- /// </para>
- /// <para>
- /// Recognized values for the Option parameter are:
- /// </para>
- /// <list type="bullet">
- /// <item>
- /// <description>Message</description>
- /// </item>
- /// <item>
- /// <description>Source</description>
- /// </item>
- /// <item>
- /// <description>StackTrace</description>
- /// </item>
- /// <item>
- /// <description>TargetSite</description>
- /// </item>
- /// <item>
- /// <description>HelpLink</description>
- /// </item>
- /// </list>
- /// </remarks>
- protected override void Convert(TextWriter writer, LoggingEvent loggingEvent)
- {
- if (loggingEvent.ExceptionObject != null && Option != null && Option.Length > 0)
- {
- switch (Option.ToLower())
- {
- case "message":
- WriteObject(writer, loggingEvent.Repository, loggingEvent.ExceptionObject.Message);
- break;
-#if !NETCF
- case "source":
- WriteObject(writer, loggingEvent.Repository, loggingEvent.ExceptionObject.Source);
- break;
- case "stacktrace":
- WriteObject(writer, loggingEvent.Repository, loggingEvent.ExceptionObject.StackTrace);
- break;
+ /// <summary>
+ /// Write the exception text to the output
+ /// </summary>
+ /// <param name="writer"><see cref="TextWriter" /> that will receive the formatted result.</param>
+ /// <param name="loggingEvent">the event being logged</param>
+ /// <remarks>
+ /// <para>
+ /// If an exception object is stored in the logging event
+ /// it will be rendered into the pattern output with a
+ /// trailing newline.
+ /// </para>
+ /// <para>
+ /// If there is no exception or the exception property specified
+ /// by the Option value does not exist then nothing will be output
+ /// and no trailing newline will be appended.
+ /// It is typical to put a newline before the exception
+ /// and to have the exception as the last data in the pattern.
+ /// </para>
+ /// <para>
+ /// Recognized values for the Option parameter are:
+ /// </para>
+ /// <list type="bullet">
+ /// <item>
+ /// <description>Message</description>
+ /// </item>
+ /// <item>
+ /// <description>Source</description>
+ /// </item>
+ /// <item>
+ /// <description>StackTrace</description>
+ /// </item>
+ /// <item>
+ /// <description>TargetSite</description>
+ /// </item>
+ /// <item>
+ /// <description>HelpLink</description>
+ /// </item>
+ /// </list>
+ /// </remarks>
+ protected override void Convert(TextWriter writer, LoggingEvent loggingEvent)
+ {
+ if (loggingEvent.ExceptionObject != null && Option != null && Option.Length > 0)
+ {
+ switch (Option.ToLower())
+ {
+ case "message":
+ WriteObject(writer, loggingEvent.Repository, loggingEvent.ExceptionObject.Message);
+ break;
+#if !NETCF
+ case "source":
+ WriteObject(writer, loggingEvent.Repository, loggingEvent.ExceptionObject.Source);
+ break;
+ case "stacktrace":
+ WriteObject(writer, loggingEvent.Repository, loggingEvent.ExceptionObject.StackTrace);
+ break;
#if !NETSTANDARD
- case "targetsite":
- WriteObject(writer, loggingEvent.Repository, loggingEvent.ExceptionObject.TargetSite);
- break;
+ case "targetsite":
+ WriteObject(writer, loggingEvent.Repository, loggingEvent.ExceptionObject.TargetSite);
+ break;
#endif
- case "helplink":
- WriteObject(writer, loggingEvent.Repository, loggingEvent.ExceptionObject.HelpLink);
- break;
-#endif
- default:
- // do not output SystemInfo.NotAvailableText
- break;
- }
- }
- else
- {
- string exceptionString = loggingEvent.GetExceptionString();
- if (exceptionString != null && exceptionString.Length > 0)
- {
- writer.WriteLine(exceptionString);
- }
- else
- {
- // do not output SystemInfo.NotAvailableText
- }
- }
- }
- }
+ case "helplink":
+ WriteObject(writer, loggingEvent.Repository, loggingEvent.ExceptionObject.HelpLink);
+ break;
+#endif
+ default:
+ // do not output SystemInfo.NotAvailableText
+ break;
+ }
+ }
+ else
+ {
+ string exceptionString = loggingEvent.GetExceptionString();
+ if (exceptionString != null && exceptionString.Length > 0)
+ {
+ writer.WriteLine(exceptionString);
+ }
+ else
+ {
+ // do not output SystemInfo.NotAvailableText
+ }
+ }
+ }
+ }
}
diff --git a/src/log4net/Layout/Pattern/FileLocationPatternConverter.cs b/src/log4net/Layout/Pattern/FileLocationPatternConverter.cs
index d555c61..7f87e75 100644
--- a/src/log4net/Layout/Pattern/FileLocationPatternConverter.cs
+++ b/src/log4net/Layout/Pattern/FileLocationPatternConverter.cs
@@ -25,32 +25,32 @@
namespace log4net.Layout.Pattern
{
- /// <summary>
- /// Writes the caller location file name to the output
- /// </summary>
- /// <remarks>
- /// <para>
- /// Writes the value of the <see cref="LocationInfo.FileName"/> for
- /// the event to the output writer.
- /// </para>
- /// </remarks>
- /// <author>Nicko Cadell</author>
- internal sealed class FileLocationPatternConverter : PatternLayoutConverter
- {
- /// <summary>
- /// Write the caller location file name to the output
- /// </summary>
- /// <param name="writer"><see cref="TextWriter" /> that will receive the formatted result.</param>
- /// <param name="loggingEvent">the event being logged</param>
- /// <remarks>
- /// <para>
- /// Writes the value of the <see cref="LocationInfo.FileName"/> for
- /// the <paramref name="loggingEvent"/> to the output <paramref name="writer"/>.
- /// </para>
- /// </remarks>
- protected override void Convert(TextWriter writer, LoggingEvent loggingEvent)
- {
- writer.Write(loggingEvent.LocationInformation.FileName);
- }
- }
+ /// <summary>
+ /// Writes the caller location file name to the output
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Writes the value of the <see cref="LocationInfo.FileName"/> for
+ /// the event to the output writer.
+ /// </para>
+ /// </remarks>
+ /// <author>Nicko Cadell</author>
+ internal sealed class FileLocationPatternConverter : PatternLayoutConverter
+ {
+ /// <summary>
+ /// Write the caller location file name to the output
+ /// </summary>
+ /// <param name="writer"><see cref="TextWriter" /> that will receive the formatted result.</param>
+ /// <param name="loggingEvent">the event being logged</param>
+ /// <remarks>
+ /// <para>
+ /// Writes the value of the <see cref="LocationInfo.FileName"/> for
+ /// the <paramref name="loggingEvent"/> to the output <paramref name="writer"/>.
+ /// </para>
+ /// </remarks>
+ protected override void Convert(TextWriter writer, LoggingEvent loggingEvent)
+ {
+ writer.Write(loggingEvent.LocationInformation.FileName);
+ }
+ }
}
diff --git a/src/log4net/Layout/Pattern/FullLocationPatternConverter.cs b/src/log4net/Layout/Pattern/FullLocationPatternConverter.cs
index ac5dab6..bb39c0d 100644
--- a/src/log4net/Layout/Pattern/FullLocationPatternConverter.cs
+++ b/src/log4net/Layout/Pattern/FullLocationPatternConverter.cs
@@ -25,30 +25,30 @@
namespace log4net.Layout.Pattern
{
- /// <summary>
- /// Write the caller location info to the output
- /// </summary>
- /// <remarks>
- /// <para>
- /// Writes the <see cref="LocationInfo.FullInfo"/> to the output writer.
- /// </para>
- /// </remarks>
- /// <author>Nicko Cadell</author>
- internal sealed class FullLocationPatternConverter : PatternLayoutConverter
- {
- /// <summary>
- /// Write the caller location info to the output
- /// </summary>
- /// <param name="writer"><see cref="TextWriter" /> that will receive the formatted result.</param>
- /// <param name="loggingEvent">the event being logged</param>
- /// <remarks>
- /// <para>
- /// Writes the <see cref="LocationInfo.FullInfo"/> to the output writer.
- /// </para>
- /// </remarks>
- protected override void Convert(TextWriter writer, LoggingEvent loggingEvent)
- {
- writer.Write( loggingEvent.LocationInformation.FullInfo );
- }
- }
+ /// <summary>
+ /// Write the caller location info to the output
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Writes the <see cref="LocationInfo.FullInfo"/> to the output writer.
+ /// </para>
+ /// </remarks>
+ /// <author>Nicko Cadell</author>
+ internal sealed class FullLocationPatternConverter : PatternLayoutConverter
+ {
+ /// <summary>
+ /// Write the caller location info to the output
+ /// </summary>
+ /// <param name="writer"><see cref="TextWriter" /> that will receive the formatted result.</param>
+ /// <param name="loggingEvent">the event being logged</param>
+ /// <remarks>
+ /// <para>
+ /// Writes the <see cref="LocationInfo.FullInfo"/> to the output writer.
+ /// </para>
+ /// </remarks>
+ protected override void Convert(TextWriter writer, LoggingEvent loggingEvent)
+ {
+ writer.Write( loggingEvent.LocationInformation.FullInfo );
+ }
+ }
}
diff --git a/src/log4net/Layout/Pattern/IdentityPatternConverter.cs b/src/log4net/Layout/Pattern/IdentityPatternConverter.cs
index 0ef245c..c13a788 100644
--- a/src/log4net/Layout/Pattern/IdentityPatternConverter.cs
+++ b/src/log4net/Layout/Pattern/IdentityPatternConverter.cs
@@ -25,34 +25,34 @@
namespace log4net.Layout.Pattern
{
- /// <summary>
- /// Writes the event identity to the output
- /// </summary>
- /// <remarks>
- /// <para>
- /// Writes the value of the <see cref="LoggingEvent.Identity"/> to
- /// the output writer.
- /// </para>
- /// </remarks>
- /// <author>Daniel Cazzulino</author>
- /// <author>Nicko Cadell</author>
- internal sealed class IdentityPatternConverter : PatternLayoutConverter
- {
- /// <summary>
- /// Writes the event identity to the output
- /// </summary>
- /// <param name="writer"><see cref="TextWriter" /> that will receive the formatted result.</param>
- /// <param name="loggingEvent">the event being logged</param>
- /// <remarks>
- /// <para>
- /// Writes the value of the <paramref name="loggingEvent"/>
- /// <see cref="LoggingEvent.Identity"/> to
- /// the output <paramref name="writer"/>.
- /// </para>
- /// </remarks>
- protected override void Convert(TextWriter writer, LoggingEvent loggingEvent)
- {
- writer.Write(loggingEvent.Identity);
- }
- }
+ /// <summary>
+ /// Writes the event identity to the output
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Writes the value of the <see cref="LoggingEvent.Identity"/> to
+ /// the output writer.
+ /// </para>
+ /// </remarks>
+ /// <author>Daniel Cazzulino</author>
+ /// <author>Nicko Cadell</author>
+ internal sealed class IdentityPatternConverter : PatternLayoutConverter
+ {
+ /// <summary>
+ /// Writes the event identity to the output
+ /// </summary>
+ /// <param name="writer"><see cref="TextWriter" /> that will receive the formatted result.</param>
+ /// <param name="loggingEvent">the event being logged</param>
+ /// <remarks>
+ /// <para>
+ /// Writes the value of the <paramref name="loggingEvent"/>
+ /// <see cref="LoggingEvent.Identity"/> to
+ /// the output <paramref name="writer"/>.
+ /// </para>
+ /// </remarks>
+ protected override void Convert(TextWriter writer, LoggingEvent loggingEvent)
+ {
+ writer.Write(loggingEvent.Identity);
+ }
+ }
}
diff --git a/src/log4net/Layout/Pattern/LevelPatternConverter.cs b/src/log4net/Layout/Pattern/LevelPatternConverter.cs
index 21af92b..75b57ec 100644
--- a/src/log4net/Layout/Pattern/LevelPatternConverter.cs
+++ b/src/log4net/Layout/Pattern/LevelPatternConverter.cs
@@ -25,32 +25,32 @@
namespace log4net.Layout.Pattern
{
- /// <summary>
- /// Write the event level to the output
- /// </summary>
- /// <remarks>
- /// <para>
- /// Writes the display name of the event <see cref="LoggingEvent.Level"/>
- /// to the writer.
- /// </para>
- /// </remarks>
- /// <author>Nicko Cadell</author>
- internal sealed class LevelPatternConverter : PatternLayoutConverter
- {
- /// <summary>
- /// Write the event level to the output
- /// </summary>
- /// <param name="writer"><see cref="TextWriter" /> that will receive the formatted result.</param>
- /// <param name="loggingEvent">the event being logged</param>
- /// <remarks>
- /// <para>
- /// Writes the <see cref="Level.DisplayName"/> of the <paramref name="loggingEvent"/> <see cref="LoggingEvent.Level"/>
- /// to the <paramref name="writer"/>.
- /// </para>
- /// </remarks>
- protected override void Convert(TextWriter writer, LoggingEvent loggingEvent)
- {
- writer.Write( loggingEvent.Level.DisplayName );
- }
- }
+ /// <summary>
+ /// Write the event level to the output
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Writes the display name of the event <see cref="LoggingEvent.Level"/>
+ /// to the writer.
+ /// </para>
+ /// </remarks>
+ /// <author>Nicko Cadell</author>
+ internal sealed class LevelPatternConverter : PatternLayoutConverter
+ {
+ /// <summary>
+ /// Write the event level to the output
+ /// </summary>
+ /// <param name="writer"><see cref="TextWriter" /> that will receive the formatted result.</param>
+ /// <param name="loggingEvent">the event being logged</param>
+ /// <remarks>
+ /// <para>
+ /// Writes the <see cref="Level.DisplayName"/> of the <paramref name="loggingEvent"/> <see cref="LoggingEvent.Level"/>
+ /// to the <paramref name="writer"/>.
+ /// </para>
+ /// </remarks>
+ protected override void Convert(TextWriter writer, LoggingEvent loggingEvent)
+ {
+ writer.Write( loggingEvent.Level.DisplayName );
+ }
+ }
}
diff --git a/src/log4net/Layout/Pattern/LineLocationPatternConverter.cs b/src/log4net/Layout/Pattern/LineLocationPatternConverter.cs
index 07c91e8..b9ce0a3 100644
--- a/src/log4net/Layout/Pattern/LineLocationPatternConverter.cs
+++ b/src/log4net/Layout/Pattern/LineLocationPatternConverter.cs
@@ -25,32 +25,32 @@
namespace log4net.Layout.Pattern
{
- /// <summary>
- /// Write the caller location line number to the output
- /// </summary>
- /// <remarks>
- /// <para>
- /// Writes the value of the <see cref="LocationInfo.LineNumber"/> for
- /// the event to the output writer.
- /// </para>
- /// </remarks>
- /// <author>Nicko Cadell</author>
- internal sealed class LineLocationPatternConverter : PatternLayoutConverter
- {
- /// <summary>
- /// Write the caller location line number to the output
- /// </summary>
- /// <param name="writer"><see cref="TextWriter" /> that will receive the formatted result.</param>
- /// <param name="loggingEvent">the event being logged</param>
- /// <remarks>
- /// <para>
- /// Writes the value of the <see cref="LocationInfo.LineNumber"/> for
- /// the <paramref name="loggingEvent"/> to the output <paramref name="writer"/>.
- /// </para>
- /// </remarks>
- protected override void Convert(TextWriter writer, LoggingEvent loggingEvent)
- {
- writer.Write(loggingEvent.LocationInformation.LineNumber);
- }
- }
+ /// <summary>
+ /// Write the caller location line number to the output
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Writes the value of the <see cref="LocationInfo.LineNumber"/> for
+ /// the event to the output writer.
+ /// </para>
+ /// </remarks>
+ /// <author>Nicko Cadell</author>
+ internal sealed class LineLocationPatternConverter : PatternLayoutConverter
+ {
+ /// <summary>
+ /// Write the caller location line number to the output
+ /// </summary>
+ /// <param name="writer"><see cref="TextWriter" /> that will receive the formatted result.</param>
+ /// <param name="loggingEvent">the event being logged</param>
+ /// <remarks>
+ /// <para>
+ /// Writes the value of the <see cref="LocationInfo.LineNumber"/> for
+ /// the <paramref name="loggingEvent"/> to the output <paramref name="writer"/>.
+ /// </para>
+ /// </remarks>
+ protected override void Convert(TextWriter writer, LoggingEvent loggingEvent)
+ {
+ writer.Write(loggingEvent.LocationInformation.LineNumber);
+ }
+ }
}
diff --git a/src/log4net/Layout/Pattern/LoggerPatternConverter.cs b/src/log4net/Layout/Pattern/LoggerPatternConverter.cs
index 471b4aa..087ab01 100644
--- a/src/log4net/Layout/Pattern/LoggerPatternConverter.cs
+++ b/src/log4net/Layout/Pattern/LoggerPatternConverter.cs
@@ -25,30 +25,30 @@
namespace log4net.Layout.Pattern
{
- /// <summary>
- /// Converter for logger name
- /// </summary>
- /// <remarks>
- /// <para>
- /// Outputs the <see cref="LoggingEvent.LoggerName"/> of the event.
- /// </para>
- /// </remarks>
- /// <author>Nicko Cadell</author>
- internal sealed class LoggerPatternConverter : NamedPatternConverter
- {
- /// <summary>
- /// Gets the fully qualified name of the logger
- /// </summary>
- /// <param name="loggingEvent">the event being logged</param>
- /// <returns>The fully qualified logger name</returns>
- /// <remarks>
- /// <para>
- /// Returns the <see cref="LoggingEvent.LoggerName"/> of the <paramref name="loggingEvent"/>.
- /// </para>
- /// </remarks>
- protected override string GetFullyQualifiedName(LoggingEvent loggingEvent)
- {
- return loggingEvent.LoggerName;
- }
- }
+ /// <summary>
+ /// Converter for logger name
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Outputs the <see cref="LoggingEvent.LoggerName"/> of the event.
+ /// </para>
+ /// </remarks>
+ /// <author>Nicko Cadell</author>
+ internal sealed class LoggerPatternConverter : NamedPatternConverter
+ {
+ /// <summary>
+ /// Gets the fully qualified name of the logger
+ /// </summary>
+ /// <param name="loggingEvent">the event being logged</param>
+ /// <returns>The fully qualified logger name</returns>
+ /// <remarks>
+ /// <para>
+ /// Returns the <see cref="LoggingEvent.LoggerName"/> of the <paramref name="loggingEvent"/>.
+ /// </para>
+ /// </remarks>
+ protected override string GetFullyQualifiedName(LoggingEvent loggingEvent)
+ {
+ return loggingEvent.LoggerName;
+ }
+ }
}
diff --git a/src/log4net/Layout/Pattern/MessagePatternConverter.cs b/src/log4net/Layout/Pattern/MessagePatternConverter.cs
index cf0f5af..25fc421 100644
--- a/src/log4net/Layout/Pattern/MessagePatternConverter.cs
+++ b/src/log4net/Layout/Pattern/MessagePatternConverter.cs
@@ -25,32 +25,32 @@
namespace log4net.Layout.Pattern
{
- /// <summary>
- /// Writes the event message to the output
- /// </summary>
- /// <remarks>
- /// <para>
- /// Uses the <see cref="LoggingEvent.WriteRenderedMessage"/> method
- /// to write out the event message.
- /// </para>
- /// </remarks>
- /// <author>Nicko Cadell</author>
- internal sealed class MessagePatternConverter : PatternLayoutConverter
- {
- /// <summary>
- /// Writes the event message to the output
- /// </summary>
- /// <param name="writer"><see cref="TextWriter" /> that will receive the formatted result.</param>
- /// <param name="loggingEvent">the event being logged</param>
- /// <remarks>
- /// <para>
- /// Uses the <see cref="LoggingEvent.WriteRenderedMessage"/> method
- /// to write out the event message.
- /// </para>
- /// </remarks>
- protected override void Convert(TextWriter writer, LoggingEvent loggingEvent)
- {
- loggingEvent.WriteRenderedMessage(writer);
- }
- }
+ /// <summary>
+ /// Writes the event message to the output
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Uses the <see cref="LoggingEvent.WriteRenderedMessage"/> method
+ /// to write out the event message.
+ /// </para>
+ /// </remarks>
+ /// <author>Nicko Cadell</author>
+ internal sealed class MessagePatternConverter : PatternLayoutConverter
+ {
+ /// <summary>
+ /// Writes the event message to the output
+ /// </summary>
+ /// <param name="writer"><see cref="TextWriter" /> that will receive the formatted result.</param>
+ /// <param name="loggingEvent">the event being logged</param>
+ /// <remarks>
+ /// <para>
+ /// Uses the <see cref="LoggingEvent.WriteRenderedMessage"/> method
+ /// to write out the event message.
+ /// </para>
+ /// </remarks>
+ protected override void Convert(TextWriter writer, LoggingEvent loggingEvent)
+ {
+ loggingEvent.WriteRenderedMessage(writer);
+ }
+ }
}
diff --git a/src/log4net/Layout/Pattern/MethodLocationPatternConverter.cs b/src/log4net/Layout/Pattern/MethodLocationPatternConverter.cs
index 90fa755..cbbbc6d 100644
--- a/src/log4net/Layout/Pattern/MethodLocationPatternConverter.cs
+++ b/src/log4net/Layout/Pattern/MethodLocationPatternConverter.cs
@@ -25,32 +25,32 @@
namespace log4net.Layout.Pattern
{
- /// <summary>
- /// Write the method name to the output
- /// </summary>
- /// <remarks>
- /// <para>
- /// Writes the caller location <see cref="LocationInfo.MethodName"/> to
- /// the output.
- /// </para>
- /// </remarks>
- /// <author>Nicko Cadell</author>
- internal sealed class MethodLocationPatternConverter : PatternLayoutConverter
- {
- /// <summary>
- /// Write the method name to the output
- /// </summary>
- /// <param name="writer"><see cref="TextWriter" /> that will receive the formatted result.</param>
- /// <param name="loggingEvent">the event being logged</param>
- /// <remarks>
- /// <para>
- /// Writes the caller location <see cref="LocationInfo.MethodName"/> to
- /// the output.
- /// </para>
- /// </remarks>
- protected override void Convert(TextWriter writer, LoggingEvent loggingEvent)
- {
- writer.Write(loggingEvent.LocationInformation.MethodName);
- }
- }
+ /// <summary>
+ /// Write the method name to the output
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Writes the caller location <see cref="LocationInfo.MethodName"/> to
+ /// the output.
+ /// </para>
+ /// </remarks>
+ /// <author>Nicko Cadell</author>
+ internal sealed class MethodLocationPatternConverter : PatternLayoutConverter
+ {
+ /// <summary>
+ /// Write the method name to the output
+ /// </summary>
+ /// <param name="writer"><see cref="TextWriter" /> that will receive the formatted result.</param>
+ /// <param name="loggingEvent">the event being logged</param>
+ /// <remarks>
+ /// <para>
+ /// Writes the caller location <see cref="LocationInfo.MethodName"/> to
+ /// the output.
+ /// </para>
+ /// </remarks>
+ protected override void Convert(TextWriter writer, LoggingEvent loggingEvent)
+ {
+ writer.Write(loggingEvent.LocationInformation.MethodName);
+ }
+ }
}
diff --git a/src/log4net/Layout/Pattern/NamedPatternConverter.cs b/src/log4net/Layout/Pattern/NamedPatternConverter.cs
index d94a9c8..2fba1f5 100644
--- a/src/log4net/Layout/Pattern/NamedPatternConverter.cs
+++ b/src/log4net/Layout/Pattern/NamedPatternConverter.cs
@@ -27,109 +27,109 @@
namespace log4net.Layout.Pattern
{
- /// <summary>
- /// Converter to output and truncate <c>'.'</c> separated strings
- /// </summary>
- /// <remarks>
- /// <para>
- /// This abstract class supports truncating a <c>'.'</c> separated string
- /// to show a specified number of elements from the right hand side.
- /// This is used to truncate class names that are fully qualified.
- /// </para>
- /// <para>
- /// Subclasses should override the <see cref="GetFullyQualifiedName"/> method to
- /// return the fully qualified string.
- /// </para>
- /// </remarks>
- /// <author>Nicko Cadell</author>
- public abstract class NamedPatternConverter : PatternLayoutConverter, IOptionHandler
- {
- private int m_precision = 0;
+ /// <summary>
+ /// Converter to output and truncate <c>'.'</c> separated strings
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// This abstract class supports truncating a <c>'.'</c> separated string
+ /// to show a specified number of elements from the right hand side.
+ /// This is used to truncate class names that are fully qualified.
+ /// </para>
+ /// <para>
+ /// Subclasses should override the <see cref="GetFullyQualifiedName"/> method to
+ /// return the fully qualified string.
+ /// </para>
+ /// </remarks>
+ /// <author>Nicko Cadell</author>
+ public abstract class NamedPatternConverter : PatternLayoutConverter, IOptionHandler
+ {
+ private int m_precision = 0;
- #region Implementation of IOptionHandler
+ #region Implementation of IOptionHandler
- /// <summary>
- /// Initialize the converter
- /// </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>
- public void ActivateOptions()
- {
- m_precision = 0;
+ /// <summary>
+ /// Initialize the converter
+ /// </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>
+ public void ActivateOptions()
+ {
+ m_precision = 0;
- if (Option != null)
- {
- string optStr = Option.Trim();
- if (optStr.Length > 0)
- {
- int precisionVal;
- if (SystemInfo.TryParse(optStr, out precisionVal))
- {
- if (precisionVal <= 0)
- {
- LogLog.Error(declaringType, "NamedPatternConverter: Precision option (" + optStr + ") isn't a positive integer.");
- }
- else
- {
- m_precision = precisionVal;
- }
- }
- else
- {
- LogLog.Error(declaringType, "NamedPatternConverter: Precision option \"" + optStr + "\" not a decimal integer.");
- }
- }
- }
- }
+ if (Option != null)
+ {
+ string optStr = Option.Trim();
+ if (optStr.Length > 0)
+ {
+ int precisionVal;
+ if (SystemInfo.TryParse(optStr, out precisionVal))
+ {
+ if (precisionVal <= 0)
+ {
+ LogLog.Error(declaringType, "NamedPatternConverter: Precision option (" + optStr + ") isn't a positive integer.");
+ }
+ else
+ {
+ m_precision = precisionVal;
+ }
+ }
+ else
+ {
+ LogLog.Error(declaringType, "NamedPatternConverter: Precision option \"" + optStr + "\" not a decimal integer.");
+ }
+ }
+ }
+ }
- #endregion
+ #endregion
- /// <summary>
- /// Get the fully qualified string data
- /// </summary>
- /// <param name="loggingEvent">the event being logged</param>
- /// <returns>the fully qualified name</returns>
- /// <remarks>
- /// <para>
- /// Overridden by subclasses to get the fully qualified name before the
- /// precision is applied to it.
- /// </para>
- /// <para>
- /// Return the fully qualified <c>'.'</c> (dot/period) separated string.
- /// </para>
- /// </remarks>
- protected abstract string GetFullyQualifiedName(LoggingEvent loggingEvent);
-
- /// <summary>
- /// Convert the pattern to the rendered message
- /// </summary>
- /// <param name="writer"><see cref="TextWriter" /> that will receive the formatted result.</param>
- /// <param name="loggingEvent">the event being logged</param>
- /// <remarks>
- /// Render the <see cref="GetFullyQualifiedName"/> to the precision
- /// specified by the <see cref="PatternConverter.Option"/> property.
- /// </remarks>
- protected sealed override void Convert(TextWriter writer, LoggingEvent loggingEvent)
- {
- string name = GetFullyQualifiedName(loggingEvent);
- if (m_precision <= 0 || name == null || name.Length < 2)
- {
- writer.Write(name);
- }
- else
- {
- int len = name.Length;
+ /// <summary>
+ /// Get the fully qualified string data
+ /// </summary>
+ /// <param name="loggingEvent">the event being logged</param>
+ /// <returns>the fully qualified name</returns>
+ /// <remarks>
+ /// <para>
+ /// Overridden by subclasses to get the fully qualified name before the
+ /// precision is applied to it.
+ /// </para>
+ /// <para>
+ /// Return the fully qualified <c>'.'</c> (dot/period) separated string.
+ /// </para>
+ /// </remarks>
+ protected abstract string GetFullyQualifiedName(LoggingEvent loggingEvent);
+
+ /// <summary>
+ /// Convert the pattern to the rendered message
+ /// </summary>
+ /// <param name="writer"><see cref="TextWriter" /> that will receive the formatted result.</param>
+ /// <param name="loggingEvent">the event being logged</param>
+ /// <remarks>
+ /// Render the <see cref="GetFullyQualifiedName"/> to the precision
+ /// specified by the <see cref="PatternConverter.Option"/> property.
+ /// </remarks>
+ protected sealed override void Convert(TextWriter writer, LoggingEvent loggingEvent)
+ {
+ string name = GetFullyQualifiedName(loggingEvent);
+ if (m_precision <= 0 || name == null || name.Length < 2)
+ {
+ writer.Write(name);
+ }
+ else
+ {
+ int len = name.Length;
string trailingDot = string.Empty;
if (name.EndsWith(DOT))
{
@@ -139,8 +139,8 @@
}
int end = name.LastIndexOf(DOT);
- for(int i = 1; end > 0 && i < m_precision; i++)
- {
+ for(int i = 1; end > 0 && i < m_precision; i++)
+ {
end = name.LastIndexOf('.', end - 1);
}
if (end == -1)
@@ -151,21 +151,21 @@
{
writer.Write(name.Substring(end + 1, len - end - 1) + trailingDot);
}
- }
- }
+ }
+ }
- #region Private Static Fields
+ #region Private Static Fields
- /// <summary>
- /// The fully qualified type of the NamedPatternConverter class.
- /// </summary>
- /// <remarks>
- /// Used by the internal logger to record the Type of the
- /// log message.
- /// </remarks>
- private static readonly Type declaringType = typeof(NamedPatternConverter);
+ /// <summary>
+ /// The fully qualified type of the NamedPatternConverter class.
+ /// </summary>
+ /// <remarks>
+ /// Used by the internal logger to record the Type of the
+ /// log message.
+ /// </remarks>
+ private static readonly Type declaringType = typeof(NamedPatternConverter);
private const string DOT = ".";
- #endregion Private Static Fields
- }
+ #endregion Private Static Fields
+ }
}
diff --git a/src/log4net/Layout/Pattern/NdcPatternConverter.cs b/src/log4net/Layout/Pattern/NdcPatternConverter.cs
index 5721681..edf1ff1 100644
--- a/src/log4net/Layout/Pattern/NdcPatternConverter.cs
+++ b/src/log4net/Layout/Pattern/NdcPatternConverter.cs
@@ -25,38 +25,38 @@
namespace log4net.Layout.Pattern
{
- /// <summary>
- /// Converter to include event NDC
- /// </summary>
- /// <remarks>
- /// <para>
- /// Outputs the value of the event property named <c>NDC</c>.
- /// </para>
- /// <para>
- /// The <see cref="PropertyPatternConverter"/> should be used instead.
- /// </para>
- /// </remarks>
- /// <author>Nicko Cadell</author>
- internal sealed class NdcPatternConverter : PatternLayoutConverter
- {
- /// <summary>
- /// Write the event NDC to the output
- /// </summary>
- /// <param name="writer"><see cref="TextWriter" /> that will receive the formatted result.</param>
- /// <param name="loggingEvent">the event being logged</param>
- /// <remarks>
- /// <para>
- /// As the thread context stacks are now stored in named event properties
- /// this converter simply looks up the value of the <c>NDC</c> property.
- /// </para>
- /// <para>
- /// The <see cref="PropertyPatternConverter"/> should be used instead.
- /// </para>
- /// </remarks>
- protected override void Convert(TextWriter writer, LoggingEvent loggingEvent)
- {
- // Write the value for the specified key
- WriteObject(writer, loggingEvent.Repository, loggingEvent.LookupProperty("NDC"));
- }
- }
+ /// <summary>
+ /// Converter to include event NDC
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Outputs the value of the event property named <c>NDC</c>.
+ /// </para>
+ /// <para>
+ /// The <see cref="PropertyPatternConverter"/> should be used instead.
+ /// </para>
+ /// </remarks>
+ /// <author>Nicko Cadell</author>
+ internal sealed class NdcPatternConverter : PatternLayoutConverter
+ {
+ /// <summary>
+ /// Write the event NDC to the output
+ /// </summary>
+ /// <param name="writer"><see cref="TextWriter" /> that will receive the formatted result.</param>
+ /// <param name="loggingEvent">the event being logged</param>
+ /// <remarks>
+ /// <para>
+ /// As the thread context stacks are now stored in named event properties
+ /// this converter simply looks up the value of the <c>NDC</c> property.
+ /// </para>
+ /// <para>
+ /// The <see cref="PropertyPatternConverter"/> should be used instead.
+ /// </para>
+ /// </remarks>
+ protected override void Convert(TextWriter writer, LoggingEvent loggingEvent)
+ {
+ // Write the value for the specified key
+ WriteObject(writer, loggingEvent.Repository, loggingEvent.LookupProperty("NDC"));
+ }
+ }
}
diff --git a/src/log4net/Layout/Pattern/PatternLayoutConverter.cs b/src/log4net/Layout/Pattern/PatternLayoutConverter.cs
index b805b39..4886f7f 100644
--- a/src/log4net/Layout/Pattern/PatternLayoutConverter.cs
+++ b/src/log4net/Layout/Pattern/PatternLayoutConverter.cs
@@ -28,96 +28,96 @@
namespace log4net.Layout.Pattern
{
- /// <summary>
- /// Abstract class that provides the formatting functionality that
- /// derived classes need.
- /// </summary>
- /// <remarks>
- /// Conversion specifiers in a conversion patterns are parsed to
- /// individual PatternConverters. Each of which is responsible for
- /// converting a logging event in a converter specific manner.
- /// </remarks>
- /// <author>Nicko Cadell</author>
- public abstract class PatternLayoutConverter : PatternConverter
- {
- #region Protected Instance Constructors
+ /// <summary>
+ /// Abstract class that provides the formatting functionality that
+ /// derived classes need.
+ /// </summary>
+ /// <remarks>
+ /// Conversion specifiers in a conversion patterns are parsed to
+ /// individual PatternConverters. Each of which is responsible for
+ /// converting a logging event in a converter specific manner.
+ /// </remarks>
+ /// <author>Nicko Cadell</author>
+ public abstract class PatternLayoutConverter : PatternConverter
+ {
+ #region Protected Instance Constructors
- /// <summary>
- /// Initializes a new instance of the <see cref="PatternLayoutConverter" /> class.
- /// </summary>
- protected PatternLayoutConverter()
- {
- }
+ /// <summary>
+ /// Initializes a new instance of the <see cref="PatternLayoutConverter" /> class.
+ /// </summary>
+ protected PatternLayoutConverter()
+ {
+ }
- #endregion Protected Instance Constructors
+ #endregion Protected Instance Constructors
- #region Public Properties
+ #region Public Properties
- /// <summary>
- /// Flag indicating if this converter handles the logging event exception
- /// </summary>
- /// <value><c>false</c> if this converter handles the logging event exception</value>
- /// <remarks>
- /// <para>
- /// If this converter handles the exception object contained within
- /// <see cref="LoggingEvent"/>, then this property should be set to
- /// <c>false</c>. Otherwise, if the layout ignores the exception
- /// object, then the property should be set to <c>true</c>.
- /// </para>
- /// <para>
- /// Set this value to override a this default setting. The default
- /// value is <c>true</c>, this converter does not handle the exception.
- /// </para>
- /// </remarks>
- public virtual bool IgnoresException
- {
- get { return m_ignoresException; }
- set { m_ignoresException = value; }
- }
+ /// <summary>
+ /// Flag indicating if this converter handles the logging event exception
+ /// </summary>
+ /// <value><c>false</c> if this converter handles the logging event exception</value>
+ /// <remarks>
+ /// <para>
+ /// If this converter handles the exception object contained within
+ /// <see cref="LoggingEvent"/>, then this property should be set to
+ /// <c>false</c>. Otherwise, if the layout ignores the exception
+ /// object, then the property should be set to <c>true</c>.
+ /// </para>
+ /// <para>
+ /// Set this value to override a this default setting. The default
+ /// value is <c>true</c>, this converter does not handle the exception.
+ /// </para>
+ /// </remarks>
+ public virtual bool IgnoresException
+ {
+ get { return m_ignoresException; }
+ set { m_ignoresException = value; }
+ }
- #endregion Public Properties
+ #endregion Public Properties
- #region Protected Abstract Methods
+ #region Protected Abstract Methods
- /// <summary>
- /// Derived pattern converters must override this method in order to
- /// convert conversion specifiers in the correct way.
- /// </summary>
- /// <param name="writer"><see cref="TextWriter" /> that will receive the formatted result.</param>
- /// <param name="loggingEvent">The <see cref="LoggingEvent" /> on which the pattern converter should be executed.</param>
- protected abstract void Convert(TextWriter writer, LoggingEvent loggingEvent);
+ /// <summary>
+ /// Derived pattern converters must override this method in order to
+ /// convert conversion specifiers in the correct way.
+ /// </summary>
+ /// <param name="writer"><see cref="TextWriter" /> that will receive the formatted result.</param>
+ /// <param name="loggingEvent">The <see cref="LoggingEvent" /> on which the pattern converter should be executed.</param>
+ protected abstract void Convert(TextWriter writer, LoggingEvent loggingEvent);
- #endregion Protected Abstract Methods
+ #endregion Protected Abstract Methods
- #region Protected Methods
+ #region Protected Methods
- /// <summary>
- /// Derived pattern converters must override this method in order to
- /// convert conversion specifiers in the correct way.
- /// </summary>
- /// <param name="writer"><see cref="TextWriter" /> that will receive the formatted result.</param>
- /// <param name="state">The state object on which the pattern converter should be executed.</param>
- protected override void Convert(TextWriter writer, object state)
- {
- LoggingEvent loggingEvent = state as LoggingEvent;
- if (loggingEvent != null)
- {
- Convert(writer, loggingEvent);
- }
- else
- {
- throw new ArgumentException("state must be of type ["+typeof(LoggingEvent).FullName+"]", "state");
- }
- }
+ /// <summary>
+ /// Derived pattern converters must override this method in order to
+ /// convert conversion specifiers in the correct way.
+ /// </summary>
+ /// <param name="writer"><see cref="TextWriter" /> that will receive the formatted result.</param>
+ /// <param name="state">The state object on which the pattern converter should be executed.</param>
+ protected override void Convert(TextWriter writer, object state)
+ {
+ LoggingEvent loggingEvent = state as LoggingEvent;
+ if (loggingEvent != null)
+ {
+ Convert(writer, loggingEvent);
+ }
+ else
+ {
+ throw new ArgumentException("state must be of type ["+typeof(LoggingEvent).FullName+"]", "state");
+ }
+ }
- #endregion Protected Methods
+ #endregion Protected Methods
- /// <summary>
- /// Flag indicating if this converter handles exceptions
- /// </summary>
- /// <remarks>
- /// <c>false</c> if this converter handles exceptions
- /// </remarks>
- private bool m_ignoresException = true;
- }
+ /// <summary>
+ /// Flag indicating if this converter handles exceptions
+ /// </summary>
+ /// <remarks>
+ /// <c>false</c> if this converter handles exceptions
+ /// </remarks>
+ private bool m_ignoresException = true;
+ }
}
diff --git a/src/log4net/Layout/Pattern/PropertyPatternConverter.cs b/src/log4net/Layout/Pattern/PropertyPatternConverter.cs
index 44a096b..1857f03 100644
--- a/src/log4net/Layout/Pattern/PropertyPatternConverter.cs
+++ b/src/log4net/Layout/Pattern/PropertyPatternConverter.cs
@@ -27,51 +27,51 @@
namespace log4net.Layout.Pattern
{
- /// <summary>
- /// Property pattern converter
- /// </summary>
- /// <remarks>
- /// <para>
- /// Writes out the value of a named property. The property name
- /// should be set in the <see cref="log4net.Util.PatternConverter.Option"/>
- /// property.
- /// </para>
- /// <para>
- /// If the <see cref="log4net.Util.PatternConverter.Option"/> is set to <c>null</c>
- /// then all the properties are written as key value pairs.
- /// </para>
- /// </remarks>
- /// <author>Nicko Cadell</author>
- internal sealed class PropertyPatternConverter : PatternLayoutConverter
- {
- /// <summary>
- /// Write the property value to the output
- /// </summary>
- /// <param name="writer"><see cref="TextWriter" /> that will receive the formatted result.</param>
- /// <param name="loggingEvent">the event being logged</param>
- /// <remarks>
- /// <para>
- /// Writes out the value of a named property. The property name
- /// should be set in the <see cref="log4net.Util.PatternConverter.Option"/>
- /// property.
- /// </para>
- /// <para>
- /// If the <see cref="log4net.Util.PatternConverter.Option"/> is set to <c>null</c>
- /// then all the properties are written as key value pairs.
- /// </para>
- /// </remarks>
- protected override void Convert(TextWriter writer, LoggingEvent loggingEvent)
- {
- if (Option != null)
- {
- // Write the value for the specified key
- WriteObject(writer, loggingEvent.Repository, loggingEvent.LookupProperty(Option));
- }
- else
- {
- // Write all the key value pairs
- WriteDictionary(writer, loggingEvent.Repository, loggingEvent.GetProperties());
- }
- }
- }
+ /// <summary>
+ /// Property pattern converter
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Writes out the value of a named property. The property name
+ /// should be set in the <see cref="log4net.Util.PatternConverter.Option"/>
+ /// property.
+ /// </para>
+ /// <para>
+ /// If the <see cref="log4net.Util.PatternConverter.Option"/> is set to <c>null</c>
+ /// then all the properties are written as key value pairs.
+ /// </para>
+ /// </remarks>
+ /// <author>Nicko Cadell</author>
+ internal sealed class PropertyPatternConverter : PatternLayoutConverter
+ {
+ /// <summary>
+ /// Write the property value to the output
+ /// </summary>
+ /// <param name="writer"><see cref="TextWriter" /> that will receive the formatted result.</param>
+ /// <param name="loggingEvent">the event being logged</param>
+ /// <remarks>
+ /// <para>
+ /// Writes out the value of a named property. The property name
+ /// should be set in the <see cref="log4net.Util.PatternConverter.Option"/>
+ /// property.
+ /// </para>
+ /// <para>
+ /// If the <see cref="log4net.Util.PatternConverter.Option"/> is set to <c>null</c>
+ /// then all the properties are written as key value pairs.
+ /// </para>
+ /// </remarks>
+ protected override void Convert(TextWriter writer, LoggingEvent loggingEvent)
+ {
+ if (Option != null)
+ {
+ // Write the value for the specified key
+ WriteObject(writer, loggingEvent.Repository, loggingEvent.LookupProperty(Option));
+ }
+ else
+ {
+ // Write all the key value pairs
+ WriteDictionary(writer, loggingEvent.Repository, loggingEvent.GetProperties());
+ }
+ }
+ }
}
diff --git a/src/log4net/Layout/Pattern/RelativeTimePatternConverter.cs b/src/log4net/Layout/Pattern/RelativeTimePatternConverter.cs
index 01b9ae2..7020400 100644
--- a/src/log4net/Layout/Pattern/RelativeTimePatternConverter.cs
+++ b/src/log4net/Layout/Pattern/RelativeTimePatternConverter.cs
@@ -25,46 +25,46 @@
namespace log4net.Layout.Pattern
{
- /// <summary>
- /// Converter to output the relative time of the event
- /// </summary>
- /// <remarks>
- /// <para>
- /// Converter to output the time of the event relative to the start of the program.
- /// </para>
- /// </remarks>
- /// <author>Nicko Cadell</author>
- internal sealed class RelativeTimePatternConverter : PatternLayoutConverter
- {
- /// <summary>
- /// Write the relative time to the output
- /// </summary>
- /// <param name="writer"><see cref="TextWriter" /> that will receive the formatted result.</param>
- /// <param name="loggingEvent">the event being logged</param>
- /// <remarks>
- /// <para>
- /// Writes out the relative time of the event in milliseconds.
- /// That is the number of milliseconds between the event <see cref="LoggingEvent.TimeStamp"/>
- /// and the <see cref="LoggingEvent.StartTime"/>.
- /// </para>
- /// </remarks>
- protected override void Convert(TextWriter writer, LoggingEvent loggingEvent)
- {
- writer.Write( TimeDifferenceInMillis(LoggingEvent.StartTimeUtc, loggingEvent.TimeStampUtc).ToString(System.Globalization.NumberFormatInfo.InvariantInfo) );
- }
+ /// <summary>
+ /// Converter to output the relative time of the event
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Converter to output the time of the event relative to the start of the program.
+ /// </para>
+ /// </remarks>
+ /// <author>Nicko Cadell</author>
+ internal sealed class RelativeTimePatternConverter : PatternLayoutConverter
+ {
+ /// <summary>
+ /// Write the relative time to the output
+ /// </summary>
+ /// <param name="writer"><see cref="TextWriter" /> that will receive the formatted result.</param>
+ /// <param name="loggingEvent">the event being logged</param>
+ /// <remarks>
+ /// <para>
+ /// Writes out the relative time of the event in milliseconds.
+ /// That is the number of milliseconds between the event <see cref="LoggingEvent.TimeStamp"/>
+ /// and the <see cref="LoggingEvent.StartTime"/>.
+ /// </para>
+ /// </remarks>
+ protected override void Convert(TextWriter writer, LoggingEvent loggingEvent)
+ {
+ writer.Write( TimeDifferenceInMillis(LoggingEvent.StartTimeUtc, loggingEvent.TimeStampUtc).ToString(System.Globalization.NumberFormatInfo.InvariantInfo) );
+ }
- /// <summary>
- /// Helper method to get the time difference between two DateTime objects
- /// </summary>
- /// <param name="start">start time (in the current local time zone)</param>
- /// <param name="end">end time (in the current local time zone)</param>
- /// <returns>the time difference in milliseconds</returns>
- private static long TimeDifferenceInMillis(DateTime start, DateTime end)
- {
- // We must convert all times to UTC before performing any mathematical
- // operations on them. This allows use to take into account discontinuities
- // caused by daylight savings time transitions.
- return (long)(end.ToUniversalTime() - start.ToUniversalTime()).TotalMilliseconds;
- }
- }
+ /// <summary>
+ /// Helper method to get the time difference between two DateTime objects
+ /// </summary>
+ /// <param name="start">start time (in the current local time zone)</param>
+ /// <param name="end">end time (in the current local time zone)</param>
+ /// <returns>the time difference in milliseconds</returns>
+ private static long TimeDifferenceInMillis(DateTime start, DateTime end)
+ {
+ // We must convert all times to UTC before performing any mathematical
+ // operations on them. This allows use to take into account discontinuities
+ // caused by daylight savings time transitions.
+ return (long)(end.ToUniversalTime() - start.ToUniversalTime()).TotalMilliseconds;
+ }
+ }
}
diff --git a/src/log4net/Layout/Pattern/StackTracePatternConverter.cs b/src/log4net/Layout/Pattern/StackTracePatternConverter.cs
index 7773868..022113c 100644
--- a/src/log4net/Layout/Pattern/StackTracePatternConverter.cs
+++ b/src/log4net/Layout/Pattern/StackTracePatternConverter.cs
@@ -25,101 +25,101 @@
namespace log4net.Layout.Pattern
{
- /// <summary>
- /// Write the caller stack frames to the output
- /// </summary>
- /// <remarks>
- /// <para>
- /// Writes the <see cref="LocationInfo.StackFrames"/> to the output writer, using format:
- /// type3.MethodCall3 > type2.MethodCall2 > type1.MethodCall1
- /// </para>
- /// </remarks>
- /// <author>Michael Cromwell</author>
- internal class StackTracePatternConverter : PatternLayoutConverter, IOptionHandler
- {
- private int m_stackFrameLevel = 1;
-
- /// <summary>
- /// Initialize the converter
- /// </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>
- public void ActivateOptions()
- {
- if (Option == null)
- return;
-
- string optStr = Option.Trim();
- if (optStr.Length != 0)
- {
- int stackLevelVal;
- if (SystemInfo.TryParse(optStr, out stackLevelVal))
- {
- if (stackLevelVal <= 0)
- {
- LogLog.Error(declaringType, "StackTracePatternConverter: StackeFrameLevel option (" + optStr + ") isn't a positive integer.");
- }
- else
- {
- m_stackFrameLevel = stackLevelVal;
- }
- }
- else
- {
- LogLog.Error(declaringType, "StackTracePatternConverter: StackFrameLevel option \"" + optStr + "\" not a decimal integer.");
- }
- }
- }
-
- /// <summary>
- /// Write the strack frames to the output
- /// </summary>
- /// <param name="writer"><see cref="TextWriter" /> that will receive the formatted result.</param>
- /// <param name="loggingEvent">the event being logged</param>
- /// <remarks>
- /// <para>
- /// Writes the <see cref="LocationInfo.StackFrames"/> to the output writer.
- /// </para>
- /// </remarks>
- protected override void Convert(TextWriter writer, LoggingEvent loggingEvent)
- {
- StackFrameItem[] stackframes = loggingEvent.LocationInformation.StackFrames;
- if ((stackframes == null) || (stackframes.Length <= 0))
- {
- LogLog.Error(declaringType, "loggingEvent.LocationInformation.StackFrames was null or empty.");
- return;
- }
-
- int stackFrameIndex = m_stackFrameLevel - 1;
- while (stackFrameIndex >= 0)
- {
- if (stackFrameIndex >= stackframes.Length)
- {
- stackFrameIndex--;
- continue;
- }
-
- StackFrameItem stackFrame = stackframes[stackFrameIndex];
+ /// <summary>
+ /// Write the caller stack frames to the output
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Writes the <see cref="LocationInfo.StackFrames"/> to the output writer, using format:
+ /// type3.MethodCall3 > type2.MethodCall2 > type1.MethodCall1
+ /// </para>
+ /// </remarks>
+ /// <author>Michael Cromwell</author>
+ internal class StackTracePatternConverter : PatternLayoutConverter, IOptionHandler
+ {
+ private int m_stackFrameLevel = 1;
+
+ /// <summary>
+ /// Initialize the converter
+ /// </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>
+ public void ActivateOptions()
+ {
+ if (Option == null)
+ return;
+
+ string optStr = Option.Trim();
+ if (optStr.Length != 0)
+ {
+ int stackLevelVal;
+ if (SystemInfo.TryParse(optStr, out stackLevelVal))
+ {
+ if (stackLevelVal <= 0)
+ {
+ LogLog.Error(declaringType, "StackTracePatternConverter: StackeFrameLevel option (" + optStr + ") isn't a positive integer.");
+ }
+ else
+ {
+ m_stackFrameLevel = stackLevelVal;
+ }
+ }
+ else
+ {
+ LogLog.Error(declaringType, "StackTracePatternConverter: StackFrameLevel option \"" + optStr + "\" not a decimal integer.");
+ }
+ }
+ }
+
+ /// <summary>
+ /// Write the strack frames to the output
+ /// </summary>
+ /// <param name="writer"><see cref="TextWriter" /> that will receive the formatted result.</param>
+ /// <param name="loggingEvent">the event being logged</param>
+ /// <remarks>
+ /// <para>
+ /// Writes the <see cref="LocationInfo.StackFrames"/> to the output writer.
+ /// </para>
+ /// </remarks>
+ protected override void Convert(TextWriter writer, LoggingEvent loggingEvent)
+ {
+ StackFrameItem[] stackframes = loggingEvent.LocationInformation.StackFrames;
+ if ((stackframes == null) || (stackframes.Length <= 0))
+ {
+ LogLog.Error(declaringType, "loggingEvent.LocationInformation.StackFrames was null or empty.");
+ return;
+ }
+
+ int stackFrameIndex = m_stackFrameLevel - 1;
+ while (stackFrameIndex >= 0)
+ {
+ if (stackFrameIndex >= stackframes.Length)
+ {
+ stackFrameIndex--;
+ continue;
+ }
+
+ StackFrameItem stackFrame = stackframes[stackFrameIndex];
writer.Write("{0}.{1}", stackFrame.ClassName, GetMethodInformation(stackFrame.Method));
- if (stackFrameIndex > 0)
- {
+ if (stackFrameIndex > 0)
+ {
// TODO: make this user settable?
- writer.Write(" > ");
- }
- stackFrameIndex--;
- }
- }
+ writer.Write(" > ");
+ }
+ stackFrameIndex--;
+ }
+ }
/// <summary>
/// Returns the Name of the method
@@ -131,19 +131,19 @@
{
return method.Name;
}
-
- #region Private Static Fields
+
+ #region Private Static Fields
- /// <summary>
- /// The fully qualified type of the StackTracePatternConverter class.
- /// </summary>
- /// <remarks>
- /// Used by the internal logger to record the Type of the
- /// log message.
- /// </remarks>
- private static readonly Type declaringType = typeof(StackTracePatternConverter);
+ /// <summary>
+ /// The fully qualified type of the StackTracePatternConverter class.
+ /// </summary>
+ /// <remarks>
+ /// Used by the internal logger to record the Type of the
+ /// log message.
+ /// </remarks>
+ private static readonly Type declaringType = typeof(StackTracePatternConverter);
- #endregion Private Static Fields
- }
+ #endregion Private Static Fields
+ }
}
#endif // !NETCF && NET_2_0
diff --git a/src/log4net/Layout/Pattern/ThreadPatternConverter.cs b/src/log4net/Layout/Pattern/ThreadPatternConverter.cs
index 122c361..faae9a9 100644
--- a/src/log4net/Layout/Pattern/ThreadPatternConverter.cs
+++ b/src/log4net/Layout/Pattern/ThreadPatternConverter.cs
@@ -25,30 +25,30 @@
namespace log4net.Layout.Pattern
{
- /// <summary>
- /// Converter to include event thread name
- /// </summary>
- /// <remarks>
- /// <para>
- /// Writes the <see cref="LoggingEvent.ThreadName"/> to the output.
- /// </para>
- /// </remarks>
- /// <author>Nicko Cadell</author>
- internal sealed class ThreadPatternConverter : PatternLayoutConverter
- {
- /// <summary>
- /// Write the ThreadName to the output
- /// </summary>
- /// <param name="writer"><see cref="TextWriter" /> that will receive the formatted result.</param>
- /// <param name="loggingEvent">the event being logged</param>
- /// <remarks>
- /// <para>
- /// Writes the <see cref="LoggingEvent.ThreadName"/> to the <paramref name="writer" />.
- /// </para>
- /// </remarks>
- protected override void Convert(TextWriter writer, LoggingEvent loggingEvent)
- {
- writer.Write(loggingEvent.ThreadName);
- }
- }
+ /// <summary>
+ /// Converter to include event thread name
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Writes the <see cref="LoggingEvent.ThreadName"/> to the output.
+ /// </para>
+ /// </remarks>
+ /// <author>Nicko Cadell</author>
+ internal sealed class ThreadPatternConverter : PatternLayoutConverter
+ {
+ /// <summary>
+ /// Write the ThreadName to the output
+ /// </summary>
+ /// <param name="writer"><see cref="TextWriter" /> that will receive the formatted result.</param>
+ /// <param name="loggingEvent">the event being logged</param>
+ /// <remarks>
+ /// <para>
+ /// Writes the <see cref="LoggingEvent.ThreadName"/> to the <paramref name="writer" />.
+ /// </para>
+ /// </remarks>
+ protected override void Convert(TextWriter writer, LoggingEvent loggingEvent)
+ {
+ writer.Write(loggingEvent.ThreadName);
+ }
+ }
}
diff --git a/src/log4net/Layout/Pattern/TypeNamePatternConverter.cs b/src/log4net/Layout/Pattern/TypeNamePatternConverter.cs
index 8b5fce8..faa47d2 100644
--- a/src/log4net/Layout/Pattern/TypeNamePatternConverter.cs
+++ b/src/log4net/Layout/Pattern/TypeNamePatternConverter.cs
@@ -25,40 +25,40 @@
namespace log4net.Layout.Pattern
{
- /// <summary>
- /// Pattern converter for the class name
- /// </summary>
- /// <remarks>
- /// <para>
- /// Outputs the <see cref="LocationInfo.ClassName"/> of the event.
- /// </para>
- /// </remarks>
- /// <author>Nicko Cadell</author>
- internal sealed class TypeNamePatternConverter : NamedPatternConverter
- {
- /// <summary>
- /// Gets the fully qualified name of the class
- /// </summary>
- /// <param name="loggingEvent">the event being logged</param>
- /// <returns>The fully qualified type name for the caller location</returns>
- /// <remarks>
- /// <para>
- /// Returns the <see cref="LocationInfo.ClassName"/> of the <paramref name="loggingEvent"/>.
- /// </para>
- /// </remarks>
- protected override string GetFullyQualifiedName(LoggingEvent loggingEvent)
- {
- if (loggingEvent == null)
- {
- return string.Empty;
- }
-
- if (loggingEvent.LocationInformation == null)
- {
- return string.Empty;
- }
-
- return loggingEvent.LocationInformation.ClassName;
- }
- }
+ /// <summary>
+ /// Pattern converter for the class name
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Outputs the <see cref="LocationInfo.ClassName"/> of the event.
+ /// </para>
+ /// </remarks>
+ /// <author>Nicko Cadell</author>
+ internal sealed class TypeNamePatternConverter : NamedPatternConverter
+ {
+ /// <summary>
+ /// Gets the fully qualified name of the class
+ /// </summary>
+ /// <param name="loggingEvent">the event being logged</param>
+ /// <returns>The fully qualified type name for the caller location</returns>
+ /// <remarks>
+ /// <para>
+ /// Returns the <see cref="LocationInfo.ClassName"/> of the <paramref name="loggingEvent"/>.
+ /// </para>
+ /// </remarks>
+ protected override string GetFullyQualifiedName(LoggingEvent loggingEvent)
+ {
+ if (loggingEvent == null)
+ {
+ return string.Empty;
+ }
+
+ if (loggingEvent.LocationInformation == null)
+ {
+ return string.Empty;
+ }
+
+ return loggingEvent.LocationInformation.ClassName;
+ }
+ }
}
diff --git a/src/log4net/Layout/Pattern/UserNamePatternConverter.cs b/src/log4net/Layout/Pattern/UserNamePatternConverter.cs
index 1f64c0c..932f40d 100644
--- a/src/log4net/Layout/Pattern/UserNamePatternConverter.cs
+++ b/src/log4net/Layout/Pattern/UserNamePatternConverter.cs
@@ -25,21 +25,21 @@
namespace log4net.Layout.Pattern
{
- /// <summary>
- /// Converter to include event user name
- /// </summary>
- /// <author>Douglas de la Torre</author>
- /// <author>Nicko Cadell</author>
- internal sealed class UserNamePatternConverter : PatternLayoutConverter
- {
- /// <summary>
- /// Convert the pattern to the rendered message
- /// </summary>
- /// <param name="writer"><see cref="TextWriter" /> that will receive the formatted result.</param>
- /// <param name="loggingEvent">the event being logged</param>
- protected override void Convert(TextWriter writer, LoggingEvent loggingEvent)
- {
- writer.Write( loggingEvent.UserName );
- }
- }
+ /// <summary>
+ /// Converter to include event user name
+ /// </summary>
+ /// <author>Douglas de la Torre</author>
+ /// <author>Nicko Cadell</author>
+ internal sealed class UserNamePatternConverter : PatternLayoutConverter
+ {
+ /// <summary>
+ /// Convert the pattern to the rendered message
+ /// </summary>
+ /// <param name="writer"><see cref="TextWriter" /> that will receive the formatted result.</param>
+ /// <param name="loggingEvent">the event being logged</param>
+ protected override void Convert(TextWriter writer, LoggingEvent loggingEvent)
+ {
+ writer.Write( loggingEvent.UserName );
+ }
+ }
}
diff --git a/src/log4net/Layout/Pattern/UtcDatePatternConverter.cs b/src/log4net/Layout/Pattern/UtcDatePatternConverter.cs
index 95227f7..5e6b912 100644
--- a/src/log4net/Layout/Pattern/UtcDatePatternConverter.cs
+++ b/src/log4net/Layout/Pattern/UtcDatePatternConverter.cs
@@ -27,65 +27,65 @@
namespace log4net.Layout.Pattern
{
- /// <summary>
- /// Write the TimeStamp to the output
- /// </summary>
- /// <remarks>
- /// <para>
- /// Date pattern converter, uses a <see cref="IDateFormatter"/> to format
- /// the date of a <see cref="LoggingEvent"/>.
- /// </para>
- /// <para>
- /// Uses a <see cref="IDateFormatter"/> to format the <see cref="LoggingEvent.TimeStamp"/>
- /// in Universal time.
- /// </para>
- /// <para>
- /// See the <see cref="DatePatternConverter"/> for details on the date pattern syntax.
- /// </para>
- /// </remarks>
- /// <seealso cref="DatePatternConverter"/>
- /// <author>Nicko Cadell</author>
- internal class UtcDatePatternConverter : DatePatternConverter
- {
- /// <summary>
- /// Write the TimeStamp to the output
- /// </summary>
- /// <param name="writer"><see cref="TextWriter" /> that will receive the formatted result.</param>
- /// <param name="loggingEvent">the event being logged</param>
- /// <remarks>
- /// <para>
- /// Pass the <see cref="LoggingEvent.TimeStamp"/> to the <see cref="IDateFormatter"/>
- /// for it to render it to the writer.
- /// </para>
- /// <para>
- /// The <see cref="LoggingEvent.TimeStamp"/> passed is in the local time zone, this is converted
- /// to Universal time before it is rendered.
- /// </para>
- /// </remarks>
- /// <seealso cref="DatePatternConverter"/>
- protected override void Convert(TextWriter writer, LoggingEvent loggingEvent)
- {
- try
- {
- m_dateFormatter.FormatDate(loggingEvent.TimeStampUtc, writer);
- }
- catch (Exception ex)
- {
- LogLog.Error(declaringType, "Error occurred while converting date.", ex);
- }
- }
+ /// <summary>
+ /// Write the TimeStamp to the output
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Date pattern converter, uses a <see cref="IDateFormatter"/> to format
+ /// the date of a <see cref="LoggingEvent"/>.
+ /// </para>
+ /// <para>
+ /// Uses a <see cref="IDateFormatter"/> to format the <see cref="LoggingEvent.TimeStamp"/>
+ /// in Universal time.
+ /// </para>
+ /// <para>
+ /// See the <see cref="DatePatternConverter"/> for details on the date pattern syntax.
+ /// </para>
+ /// </remarks>
+ /// <seealso cref="DatePatternConverter"/>
+ /// <author>Nicko Cadell</author>
+ internal class UtcDatePatternConverter : DatePatternConverter
+ {
+ /// <summary>
+ /// Write the TimeStamp to the output
+ /// </summary>
+ /// <param name="writer"><see cref="TextWriter" /> that will receive the formatted result.</param>
+ /// <param name="loggingEvent">the event being logged</param>
+ /// <remarks>
+ /// <para>
+ /// Pass the <see cref="LoggingEvent.TimeStamp"/> to the <see cref="IDateFormatter"/>
+ /// for it to render it to the writer.
+ /// </para>
+ /// <para>
+ /// The <see cref="LoggingEvent.TimeStamp"/> passed is in the local time zone, this is converted
+ /// to Universal time before it is rendered.
+ /// </para>
+ /// </remarks>
+ /// <seealso cref="DatePatternConverter"/>
+ protected override void Convert(TextWriter writer, LoggingEvent loggingEvent)
+ {
+ try
+ {
+ m_dateFormatter.FormatDate(loggingEvent.TimeStampUtc, writer);
+ }
+ catch (Exception ex)
+ {
+ LogLog.Error(declaringType, "Error occurred while converting date.", ex);
+ }
+ }
- #region Private Static Fields
+ #region Private Static Fields
- /// <summary>
- /// The fully qualified type of the UtcDatePatternConverter class.
- /// </summary>
- /// <remarks>
- /// Used by the internal logger to record the Type of the
- /// log message.
- /// </remarks>
- private static readonly Type declaringType = typeof(UtcDatePatternConverter);
+ /// <summary>
+ /// The fully qualified type of the UtcDatePatternConverter class.
+ /// </summary>
+ /// <remarks>
+ /// Used by the internal logger to record the Type of the
+ /// log message.
+ /// </remarks>
+ private static readonly Type declaringType = typeof(UtcDatePatternConverter);
- #endregion Private Static Fields
- }
+ #endregion Private Static Fields
+ }
}
diff --git a/src/log4net/Layout/PatternLayout.cs b/src/log4net/Layout/PatternLayout.cs
index 49cad59..60a1495 100644
--- a/src/log4net/Layout/PatternLayout.cs
+++ b/src/log4net/Layout/PatternLayout.cs
@@ -34,89 +34,89 @@
namespace log4net.Layout
{
- /// <summary>
- /// A flexible layout configurable with pattern string.
- /// </summary>
- /// <remarks>
- /// <para>
- /// The goal of this class is to <see cref="M:PatternLayout.Format(TextWriter,LoggingEvent)"/> a
- /// <see cref="LoggingEvent"/> as a string. The results
- /// depend on the <i>conversion pattern</i>.
- /// </para>
- /// <para>
- /// The conversion pattern is closely related to the conversion
- /// pattern of the printf function in C. A conversion pattern is
- /// composed of literal text and format control expressions called
- /// <i>conversion specifiers</i>.
- /// </para>
- /// <para>
- /// <i>You are free to insert any literal text within the conversion
- /// pattern.</i>
- /// </para>
- /// <para>
- /// Each conversion specifier starts with a percent sign (%) and is
- /// followed by optional <i>format modifiers</i> and a <i>conversion
- /// pattern name</i>. The conversion pattern name specifies the type of
- /// data, e.g. logger, level, date, thread name. The format
- /// modifiers control such things as field width, padding, left and
- /// right justification. The following is a simple example.
- /// </para>
- /// <para>
- /// Let the conversion pattern be <b>"%-5level [%thread]: %message%newline"</b> and assume
- /// that the log4net environment was set to use a PatternLayout. Then the
- /// statements
- /// </para>
- /// <code lang="C#">
- /// ILog log = LogManager.GetLogger(typeof(TestApp));
- /// log.Debug("Message 1");
- /// log.Warn("Message 2");
- /// </code>
- /// <para>would yield the output</para>
- /// <code>
- /// DEBUG [main]: Message 1
- /// WARN [main]: Message 2
- /// </code>
- /// <para>
- /// Note that there is no explicit separator between text and
- /// conversion specifiers. The pattern parser knows when it has reached
- /// the end of a conversion specifier when it reads a conversion
- /// character. In the example above the conversion specifier
- /// <b>%-5level</b> means the level of the logging event should be left
- /// justified to a width of five characters.
- /// </para>
- /// <para>
- /// The recognized conversion pattern names are:
- /// </para>
- /// <list type="table">
- /// <listheader>
- /// <term>Conversion Pattern Name</term>
- /// <description>Effect</description>
- /// </listheader>
- /// <item>
- /// <term>a</term>
- /// <description>Equivalent to <b>appdomain</b></description>
- /// </item>
- /// <item>
- /// <term>appdomain</term>
- /// <description>
- /// Used to output the friendly name of the AppDomain where the
- /// logging event was generated.
- /// </description>
- /// </item>
- /// <item>
- /// <term>aspnet-cache</term>
- /// <description>
+ /// <summary>
+ /// A flexible layout configurable with pattern string.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// The goal of this class is to <see cref="M:PatternLayout.Format(TextWriter,LoggingEvent)"/> a
+ /// <see cref="LoggingEvent"/> as a string. The results
+ /// depend on the <i>conversion pattern</i>.
+ /// </para>
+ /// <para>
+ /// The conversion pattern is closely related to the conversion
+ /// pattern of the printf function in C. A conversion pattern is
+ /// composed of literal text and format control expressions called
+ /// <i>conversion specifiers</i>.
+ /// </para>
+ /// <para>
+ /// <i>You are free to insert any literal text within the conversion
+ /// pattern.</i>
+ /// </para>
+ /// <para>
+ /// Each conversion specifier starts with a percent sign (%) and is
+ /// followed by optional <i>format modifiers</i> and a <i>conversion
+ /// pattern name</i>. The conversion pattern name specifies the type of
+ /// data, e.g. logger, level, date, thread name. The format
+ /// modifiers control such things as field width, padding, left and
+ /// right justification. The following is a simple example.
+ /// </para>
+ /// <para>
+ /// Let the conversion pattern be <b>"%-5level [%thread]: %message%newline"</b> and assume
+ /// that the log4net environment was set to use a PatternLayout. Then the
+ /// statements
+ /// </para>
+ /// <code lang="C#">
+ /// ILog log = LogManager.GetLogger(typeof(TestApp));
+ /// log.Debug("Message 1");
+ /// log.Warn("Message 2");
+ /// </code>
+ /// <para>would yield the output</para>
+ /// <code>
+ /// DEBUG [main]: Message 1
+ /// WARN [main]: Message 2
+ /// </code>
+ /// <para>
+ /// Note that there is no explicit separator between text and
+ /// conversion specifiers. The pattern parser knows when it has reached
+ /// the end of a conversion specifier when it reads a conversion
+ /// character. In the example above the conversion specifier
+ /// <b>%-5level</b> means the level of the logging event should be left
+ /// justified to a width of five characters.
+ /// </para>
+ /// <para>
+ /// The recognized conversion pattern names are:
+ /// </para>
+ /// <list type="table">
+ /// <listheader>
+ /// <term>Conversion Pattern Name</term>
+ /// <description>Effect</description>
+ /// </listheader>
+ /// <item>
+ /// <term>a</term>
+ /// <description>Equivalent to <b>appdomain</b></description>
+ /// </item>
+ /// <item>
+ /// <term>appdomain</term>
+ /// <description>
+ /// Used to output the friendly name of the AppDomain where the
+ /// logging event was generated.
+ /// </description>
+ /// </item>
+ /// <item>
+ /// <term>aspnet-cache</term>
+ /// <description>
/// <para>
/// Used to output all cache items in the case of <b>%aspnet-cache</b> or just one named item if used as <b>%aspnet-cache{key}</b>
/// </para>
/// <para>
/// This pattern is not available for Compact Framework or Client Profile assemblies.
/// </para>
- /// </description>
- /// </item>
- /// <item>
- /// <term>aspnet-context</term>
- /// <description>
+ /// </description>
+ /// </item>
+ /// <item>
+ /// <term>aspnet-context</term>
+ /// <description>
/// <para>
/// Used to output all context items in the case of <b>%aspnet-context</b> or just one named item if used as <b>%aspnet-context{key}</b>
/// </para>
@@ -124,10 +124,10 @@
/// This pattern is not available for Compact Framework or Client Profile assemblies.
/// </para>
/// </description>
- /// </item>
- /// <item>
- /// <term>aspnet-request</term>
- /// <description>
+ /// </item>
+ /// <item>
+ /// <term>aspnet-request</term>
+ /// <description>
/// <para>
/// Used to output all request parameters in the case of <b>%aspnet-request</b> or just one named param if used as <b>%aspnet-request{key}</b>
/// </para>
@@ -135,10 +135,10 @@
/// This pattern is not available for Compact Framework or Client Profile assemblies.
/// </para>
/// </description>
- /// </item>
- /// <item>
- /// <term>aspnet-session</term>
- /// <description>
+ /// </item>
+ /// <item>
+ /// <term>aspnet-session</term>
+ /// <description>
/// <para>
/// Used to output all session items in the case of <b>%aspnet-session</b> or just one named item if used as <b>%aspnet-session{key}</b>
/// </para>
@@ -146,990 +146,990 @@
/// This pattern is not available for Compact Framework or Client Profile assemblies.
/// </para>
/// </description>
- /// </item>
- /// <item>
- /// <term>c</term>
- /// <description>Equivalent to <b>logger</b></description>
- /// </item>
- /// <item>
- /// <term>C</term>
- /// <description>Equivalent to <b>type</b></description>
- /// </item>
- /// <item>
- /// <term>class</term>
- /// <description>Equivalent to <b>type</b></description>
- /// </item>
- /// <item>
- /// <term>d</term>
- /// <description>Equivalent to <b>date</b></description>
- /// </item>
- /// <item>
- /// <term>date</term>
- /// <description>
- /// <para>
- /// Used to output the date of the logging event in the local time zone.
- /// To output the date in universal time use the <c>%utcdate</c> pattern.
- /// The date conversion
- /// specifier may be followed by a <i>date format specifier</i> enclosed
- /// between braces. For example, <b>%date{HH:mm:ss,fff}</b> or
- /// <b>%date{dd MMM yyyy HH:mm:ss,fff}</b>. If no date format specifier is
- /// given then ISO8601 format is
- /// assumed (<see cref="log4net.DateFormatter.Iso8601DateFormatter"/>).
- /// </para>
- /// <para>
- /// The date format specifier admits the same syntax as the
- /// time pattern string of the <see cref="M:DateTime.ToString(string)"/>.
- /// </para>
- /// <para>
- /// For better results it is recommended to use the log4net date
- /// formatters. These can be specified using one of the strings
- /// "ABSOLUTE", "DATE" and "ISO8601" for specifying
- /// <see cref="log4net.DateFormatter.AbsoluteTimeDateFormatter"/>,
- /// <see cref="log4net.DateFormatter.DateTimeDateFormatter"/> and respectively
- /// <see cref="log4net.DateFormatter.Iso8601DateFormatter"/>. For example,
- /// <b>%date{ISO8601}</b> or <b>%date{ABSOLUTE}</b>.
- /// </para>
- /// <para>
- /// These dedicated date formatters perform significantly
- /// better than <see cref="M:DateTime.ToString(string)"/>.
- /// </para>
- /// </description>
- /// </item>
- /// <item>
- /// <term>exception</term>
- /// <description>
- /// <para>
- /// Used to output the exception passed in with the log message.
- /// </para>
- /// <para>
- /// If an exception object is stored in the logging event
- /// it will be rendered into the pattern output with a
- /// trailing newline.
- /// If there is no exception then nothing will be output
- /// and no trailing newline will be appended.
- /// It is typical to put a newline before the exception
- /// and to have the exception as the last data in the pattern.
- /// </para>
- /// </description>
- /// </item>
- /// <item>
- /// <term>F</term>
- /// <description>Equivalent to <b>file</b></description>
- /// </item>
- /// <item>
- /// <term>file</term>
- /// <description>
- /// <para>
- /// Used to output the file name where the logging request was
- /// issued.
- /// </para>
- /// <para>
- /// <b>WARNING</b> Generating caller location information is
- /// extremely slow. Its use should be avoided unless execution speed
- /// is not an issue.
- /// </para>
- /// <para>
- /// See the note below on the availability of caller location information.
- /// </para>
- /// </description>
- /// </item>
- /// <item>
- /// <term>identity</term>
- /// <description>
- /// <para>
- /// Used to output the user name for the currently active user
- /// (Principal.Identity.Name).
- /// </para>
- /// <para>
- /// <b>WARNING</b> Generating caller information is
- /// extremely slow. Its use should be avoided unless execution speed
- /// is not an issue.
- /// </para>
- /// </description>
- /// </item>
- /// <item>
- /// <term>l</term>
- /// <description>Equivalent to <b>location</b></description>
- /// </item>
- /// <item>
- /// <term>L</term>
- /// <description>Equivalent to <b>line</b></description>
- /// </item>
- /// <item>
- /// <term>location</term>
- /// <description>
- /// <para>
- /// Used to output location information of the caller which generated
- /// the logging event.
- /// </para>
- /// <para>
- /// The location information depends on the CLI implementation but
- /// usually consists of the fully qualified name of the calling
- /// method followed by the callers source the file name and line
- /// number between parentheses.
- /// </para>
- /// <para>
- /// The location information can be very useful. However, its
- /// generation is <b>extremely</b> slow. Its use should be avoided
- /// unless execution speed is not an issue.
- /// </para>
- /// <para>
- /// See the note below on the availability of caller location information.
- /// </para>
- /// </description>
- /// </item>
- /// <item>
- /// <term>level</term>
- /// <description>
- /// <para>
- /// Used to output the level of the logging event.
- /// </para>
- /// </description>
- /// </item>
- /// <item>
- /// <term>line</term>
- /// <description>
- /// <para>
- /// Used to output the line number from where the logging request
- /// was issued.
- /// </para>
- /// <para>
- /// <b>WARNING</b> Generating caller location information is
- /// extremely slow. Its use should be avoided unless execution speed
- /// is not an issue.
- /// </para>
- /// <para>
- /// See the note below on the availability of caller location information.
- /// </para>
- /// </description>
- /// </item>
- /// <item>
- /// <term>logger</term>
- /// <description>
- /// <para>
- /// Used to output the logger of the logging event. The
- /// logger conversion specifier can be optionally followed by
- /// <i>precision specifier</i>, that is a decimal constant in
- /// brackets.
- /// </para>
- /// <para>
- /// If a precision specifier is given, then only the corresponding
- /// number of right most components of the logger name will be
- /// printed. By default the logger name is printed in full.
- /// </para>
- /// <para>
- /// For example, for the logger name "a.b.c" the pattern
- /// <b>%logger{2}</b> will output "b.c".
- /// </para>
- /// </description>
- /// </item>
- /// <item>
- /// <term>m</term>
- /// <description>Equivalent to <b>message</b></description>
- /// </item>
- /// <item>
- /// <term>M</term>
- /// <description>Equivalent to <b>method</b></description>
- /// </item>
- /// <item>
- /// <term>message</term>
- /// <description>
- /// <para>
- /// Used to output the application supplied message associated with
- /// the logging event.
- /// </para>
- /// </description>
- /// </item>
- /// <item>
- /// <term>mdc</term>
- /// <description>
- /// <para>
- /// The MDC (old name for the ThreadContext.Properties) is now part of the
- /// combined event properties. This pattern is supported for compatibility
- /// but is equivalent to <b>property</b>.
- /// </para>
- /// </description>
- /// </item>
- /// <item>
- /// <term>method</term>
- /// <description>
- /// <para>
- /// Used to output the method name where the logging request was
- /// issued.
- /// </para>
- /// <para>
- /// <b>WARNING</b> Generating caller location information is
- /// extremely slow. Its use should be avoided unless execution speed
- /// is not an issue.
- /// </para>
- /// <para>
- /// See the note below on the availability of caller location information.
- /// </para>
- /// </description>
- /// </item>
- /// <item>
- /// <term>n</term>
- /// <description>Equivalent to <b>newline</b></description>
- /// </item>
- /// <item>
- /// <term>newline</term>
- /// <description>
- /// <para>
- /// Outputs the platform dependent line separator character or
- /// characters.
- /// </para>
- /// <para>
- /// This conversion pattern offers the same performance as using
- /// non-portable line separator strings such as "\n", or "\r\n".
- /// Thus, it is the preferred way of specifying a line separator.
- /// </para>
- /// </description>
- /// </item>
- /// <item>
- /// <term>ndc</term>
- /// <description>
- /// <para>
- /// Used to output the NDC (nested diagnostic context) associated
- /// with the thread that generated the logging event.
- /// </para>
- /// </description>
- /// </item>
- /// <item>
- /// <term>p</term>
- /// <description>Equivalent to <b>level</b></description>
- /// </item>
- /// <item>
- /// <term>P</term>
- /// <description>Equivalent to <b>property</b></description>
- /// </item>
- /// <item>
- /// <term>properties</term>
- /// <description>Equivalent to <b>property</b></description>
- /// </item>
- /// <item>
- /// <term>property</term>
- /// <description>
- /// <para>
- /// Used to output the an event specific property. The key to
- /// lookup must be specified within braces and directly following the
- /// pattern specifier, e.g. <b>%property{user}</b> would include the value
- /// from the property that is keyed by the string 'user'. Each property value
- /// that is to be included in the log must be specified separately.
- /// Properties are added to events by loggers or appenders. By default
- /// the <c>log4net:HostName</c> property is set to the name of machine on
- /// which the event was originally logged.
- /// </para>
- /// <para>
- /// If no key is specified, e.g. <b>%property</b> then all the keys and their
- /// values are printed in a comma separated list.
- /// </para>
- /// <para>
- /// The properties of an event are combined from a number of different
- /// contexts. These are listed below in the order in which they are searched.
- /// </para>
- /// <list type="definition">
- /// <item>
- /// <term>the event properties</term>
- /// <description>
- /// The event has <see cref="LoggingEvent.Properties"/> that can be set. These
- /// properties are specific to this event only.
- /// </description>
- /// </item>
- /// <item>
- /// <term>the thread properties</term>
- /// <description>
- /// The <see cref="ThreadContext.Properties"/> that are set on the current
- /// thread. These properties are shared by all events logged on this thread.
- /// </description>
- /// </item>
- /// <item>
- /// <term>the global properties</term>
- /// <description>
- /// The <see cref="GlobalContext.Properties"/> that are set globally. These
- /// properties are shared by all the threads in the AppDomain.
- /// </description>
- /// </item>
- /// </list>
- ///
- /// </description>
- /// </item>
- /// <item>
- /// <term>r</term>
- /// <description>Equivalent to <b>timestamp</b></description>
- /// </item>
- /// <item>
- /// <term>stacktrace</term>
- /// <description>
- /// <para>
- /// Used to output the stack trace of the logging event
- /// The stack trace level specifier may be enclosed
- /// between braces. For example, <b>%stacktrace{level}</b>.
- /// If no stack trace level specifier is given then 1 is assumed
- /// </para>
- /// <para>
- /// Output uses the format:
- /// type3.MethodCall3 > type2.MethodCall2 > type1.MethodCall1
- /// </para>
+ /// </item>
+ /// <item>
+ /// <term>c</term>
+ /// <description>Equivalent to <b>logger</b></description>
+ /// </item>
+ /// <item>
+ /// <term>C</term>
+ /// <description>Equivalent to <b>type</b></description>
+ /// </item>
+ /// <item>
+ /// <term>class</term>
+ /// <description>Equivalent to <b>type</b></description>
+ /// </item>
+ /// <item>
+ /// <term>d</term>
+ /// <description>Equivalent to <b>date</b></description>
+ /// </item>
+ /// <item>
+ /// <term>date</term>
+ /// <description>
+ /// <para>
+ /// Used to output the date of the logging event in the local time zone.
+ /// To output the date in universal time use the <c>%utcdate</c> pattern.
+ /// The date conversion
+ /// specifier may be followed by a <i>date format specifier</i> enclosed
+ /// between braces. For example, <b>%date{HH:mm:ss,fff}</b> or
+ /// <b>%date{dd MMM yyyy HH:mm:ss,fff}</b>. If no date format specifier is
+ /// given then ISO8601 format is
+ /// assumed (<see cref="log4net.DateFormatter.Iso8601DateFormatter"/>).
+ /// </para>
+ /// <para>
+ /// The date format specifier admits the same syntax as the
+ /// time pattern string of the <see cref="M:DateTime.ToString(string)"/>.
+ /// </para>
+ /// <para>
+ /// For better results it is recommended to use the log4net date
+ /// formatters. These can be specified using one of the strings
+ /// "ABSOLUTE", "DATE" and "ISO8601" for specifying
+ /// <see cref="log4net.DateFormatter.AbsoluteTimeDateFormatter"/>,
+ /// <see cref="log4net.DateFormatter.DateTimeDateFormatter"/> and respectively
+ /// <see cref="log4net.DateFormatter.Iso8601DateFormatter"/>. For example,
+ /// <b>%date{ISO8601}</b> or <b>%date{ABSOLUTE}</b>.
+ /// </para>
+ /// <para>
+ /// These dedicated date formatters perform significantly
+ /// better than <see cref="M:DateTime.ToString(string)"/>.
+ /// </para>
+ /// </description>
+ /// </item>
+ /// <item>
+ /// <term>exception</term>
+ /// <description>
+ /// <para>
+ /// Used to output the exception passed in with the log message.
+ /// </para>
+ /// <para>
+ /// If an exception object is stored in the logging event
+ /// it will be rendered into the pattern output with a
+ /// trailing newline.
+ /// If there is no exception then nothing will be output
+ /// and no trailing newline will be appended.
+ /// It is typical to put a newline before the exception
+ /// and to have the exception as the last data in the pattern.
+ /// </para>
+ /// </description>
+ /// </item>
+ /// <item>
+ /// <term>F</term>
+ /// <description>Equivalent to <b>file</b></description>
+ /// </item>
+ /// <item>
+ /// <term>file</term>
+ /// <description>
+ /// <para>
+ /// Used to output the file name where the logging request was
+ /// issued.
+ /// </para>
+ /// <para>
+ /// <b>WARNING</b> Generating caller location information is
+ /// extremely slow. Its use should be avoided unless execution speed
+ /// is not an issue.
+ /// </para>
+ /// <para>
+ /// See the note below on the availability of caller location information.
+ /// </para>
+ /// </description>
+ /// </item>
+ /// <item>
+ /// <term>identity</term>
+ /// <description>
+ /// <para>
+ /// Used to output the user name for the currently active user
+ /// (Principal.Identity.Name).
+ /// </para>
+ /// <para>
+ /// <b>WARNING</b> Generating caller information is
+ /// extremely slow. Its use should be avoided unless execution speed
+ /// is not an issue.
+ /// </para>
+ /// </description>
+ /// </item>
+ /// <item>
+ /// <term>l</term>
+ /// <description>Equivalent to <b>location</b></description>
+ /// </item>
+ /// <item>
+ /// <term>L</term>
+ /// <description>Equivalent to <b>line</b></description>
+ /// </item>
+ /// <item>
+ /// <term>location</term>
+ /// <description>
+ /// <para>
+ /// Used to output location information of the caller which generated
+ /// the logging event.
+ /// </para>
+ /// <para>
+ /// The location information depends on the CLI implementation but
+ /// usually consists of the fully qualified name of the calling
+ /// method followed by the callers source the file name and line
+ /// number between parentheses.
+ /// </para>
+ /// <para>
+ /// The location information can be very useful. However, its
+ /// generation is <b>extremely</b> slow. Its use should be avoided
+ /// unless execution speed is not an issue.
+ /// </para>
+ /// <para>
+ /// See the note below on the availability of caller location information.
+ /// </para>
+ /// </description>
+ /// </item>
+ /// <item>
+ /// <term>level</term>
+ /// <description>
+ /// <para>
+ /// Used to output the level of the logging event.
+ /// </para>
+ /// </description>
+ /// </item>
+ /// <item>
+ /// <term>line</term>
+ /// <description>
+ /// <para>
+ /// Used to output the line number from where the logging request
+ /// was issued.
+ /// </para>
+ /// <para>
+ /// <b>WARNING</b> Generating caller location information is
+ /// extremely slow. Its use should be avoided unless execution speed
+ /// is not an issue.
+ /// </para>
+ /// <para>
+ /// See the note below on the availability of caller location information.
+ /// </para>
+ /// </description>
+ /// </item>
+ /// <item>
+ /// <term>logger</term>
+ /// <description>
+ /// <para>
+ /// Used to output the logger of the logging event. The
+ /// logger conversion specifier can be optionally followed by
+ /// <i>precision specifier</i>, that is a decimal constant in
+ /// brackets.
+ /// </para>
+ /// <para>
+ /// If a precision specifier is given, then only the corresponding
+ /// number of right most components of the logger name will be
+ /// printed. By default the logger name is printed in full.
+ /// </para>
+ /// <para>
+ /// For example, for the logger name "a.b.c" the pattern
+ /// <b>%logger{2}</b> will output "b.c".
+ /// </para>
+ /// </description>
+ /// </item>
+ /// <item>
+ /// <term>m</term>
+ /// <description>Equivalent to <b>message</b></description>
+ /// </item>
+ /// <item>
+ /// <term>M</term>
+ /// <description>Equivalent to <b>method</b></description>
+ /// </item>
+ /// <item>
+ /// <term>message</term>
+ /// <description>
+ /// <para>
+ /// Used to output the application supplied message associated with
+ /// the logging event.
+ /// </para>
+ /// </description>
+ /// </item>
+ /// <item>
+ /// <term>mdc</term>
+ /// <description>
+ /// <para>
+ /// The MDC (old name for the ThreadContext.Properties) is now part of the
+ /// combined event properties. This pattern is supported for compatibility
+ /// but is equivalent to <b>property</b>.
+ /// </para>
+ /// </description>
+ /// </item>
+ /// <item>
+ /// <term>method</term>
+ /// <description>
+ /// <para>
+ /// Used to output the method name where the logging request was
+ /// issued.
+ /// </para>
+ /// <para>
+ /// <b>WARNING</b> Generating caller location information is
+ /// extremely slow. Its use should be avoided unless execution speed
+ /// is not an issue.
+ /// </para>
+ /// <para>
+ /// See the note below on the availability of caller location information.
+ /// </para>
+ /// </description>
+ /// </item>
+ /// <item>
+ /// <term>n</term>
+ /// <description>Equivalent to <b>newline</b></description>
+ /// </item>
+ /// <item>
+ /// <term>newline</term>
+ /// <description>
+ /// <para>
+ /// Outputs the platform dependent line separator character or
+ /// characters.
+ /// </para>
+ /// <para>
+ /// This conversion pattern offers the same performance as using
+ /// non-portable line separator strings such as "\n", or "\r\n".
+ /// Thus, it is the preferred way of specifying a line separator.
+ /// </para>
+ /// </description>
+ /// </item>
+ /// <item>
+ /// <term>ndc</term>
+ /// <description>
+ /// <para>
+ /// Used to output the NDC (nested diagnostic context) associated
+ /// with the thread that generated the logging event.
+ /// </para>
+ /// </description>
+ /// </item>
+ /// <item>
+ /// <term>p</term>
+ /// <description>Equivalent to <b>level</b></description>
+ /// </item>
+ /// <item>
+ /// <term>P</term>
+ /// <description>Equivalent to <b>property</b></description>
+ /// </item>
+ /// <item>
+ /// <term>properties</term>
+ /// <description>Equivalent to <b>property</b></description>
+ /// </item>
+ /// <item>
+ /// <term>property</term>
+ /// <description>
+ /// <para>
+ /// Used to output the an event specific property. The key to
+ /// lookup must be specified within braces and directly following the
+ /// pattern specifier, e.g. <b>%property{user}</b> would include the value
+ /// from the property that is keyed by the string 'user'. Each property value
+ /// that is to be included in the log must be specified separately.
+ /// Properties are added to events by loggers or appenders. By default
+ /// the <c>log4net:HostName</c> property is set to the name of machine on
+ /// which the event was originally logged.
+ /// </para>
+ /// <para>
+ /// If no key is specified, e.g. <b>%property</b> then all the keys and their
+ /// values are printed in a comma separated list.
+ /// </para>
+ /// <para>
+ /// The properties of an event are combined from a number of different
+ /// contexts. These are listed below in the order in which they are searched.
+ /// </para>
+ /// <list type="definition">
+ /// <item>
+ /// <term>the event properties</term>
+ /// <description>
+ /// The event has <see cref="LoggingEvent.Properties"/> that can be set. These
+ /// properties are specific to this event only.
+ /// </description>
+ /// </item>
+ /// <item>
+ /// <term>the thread properties</term>
+ /// <description>
+ /// The <see cref="ThreadContext.Properties"/> that are set on the current
+ /// thread. These properties are shared by all events logged on this thread.
+ /// </description>
+ /// </item>
+ /// <item>
+ /// <term>the global properties</term>
+ /// <description>
+ /// The <see cref="GlobalContext.Properties"/> that are set globally. These
+ /// properties are shared by all the threads in the AppDomain.
+ /// </description>
+ /// </item>
+ /// </list>
+ ///
+ /// </description>
+ /// </item>
+ /// <item>
+ /// <term>r</term>
+ /// <description>Equivalent to <b>timestamp</b></description>
+ /// </item>
+ /// <item>
+ /// <term>stacktrace</term>
+ /// <description>
+ /// <para>
+ /// Used to output the stack trace of the logging event
+ /// The stack trace level specifier may be enclosed
+ /// between braces. For example, <b>%stacktrace{level}</b>.
+ /// If no stack trace level specifier is given then 1 is assumed
+ /// </para>
+ /// <para>
+ /// Output uses the format:
+ /// type3.MethodCall3 > type2.MethodCall2 > type1.MethodCall1
+ /// </para>
/// <para>
/// This pattern is not available for Compact Framework assemblies.
/// </para>
- /// </description>
- /// </item>
- /// <item>
- /// <term>stacktracedetail</term>
- /// <description>
- /// <para>
- /// Used to output the stack trace of the logging event
- /// The stack trace level specifier may be enclosed
- /// between braces. For example, <b>%stacktracedetail{level}</b>.
- /// If no stack trace level specifier is given then 1 is assumed
- /// </para>
- /// <para>
- /// Output uses the format:
+ /// </description>
+ /// </item>
+ /// <item>
+ /// <term>stacktracedetail</term>
+ /// <description>
+ /// <para>
+ /// Used to output the stack trace of the logging event
+ /// The stack trace level specifier may be enclosed
+ /// between braces. For example, <b>%stacktracedetail{level}</b>.
+ /// If no stack trace level specifier is given then 1 is assumed
+ /// </para>
+ /// <para>
+ /// Output uses the format:
/// type3.MethodCall3(type param,...) > type2.MethodCall2(type param,...) > type1.MethodCall1(type param,...)
- /// </para>
+ /// </para>
/// <para>
/// This pattern is not available for Compact Framework assemblies.
/// </para>
- /// </description>
- /// </item>
+ /// </description>
+ /// </item>
/// <item>
- /// <term>t</term>
- /// <description>Equivalent to <b>thread</b></description>
- /// </item>
- /// <item>
- /// <term>timestamp</term>
- /// <description>
- /// <para>
- /// Used to output the number of milliseconds elapsed since the start
- /// of the application until the creation of the logging event.
- /// </para>
- /// </description>
- /// </item>
- /// <item>
- /// <term>thread</term>
- /// <description>
- /// <para>
- /// Used to output the name of the thread that generated the
- /// logging event. Uses the thread number if no name is available.
- /// </para>
- /// </description>
- /// </item>
- /// <item>
- /// <term>type</term>
- /// <description>
- /// <para>
- /// Used to output the fully qualified type name of the caller
- /// issuing the logging request. This conversion specifier
- /// can be optionally followed by <i>precision specifier</i>, that
- /// is a decimal constant in brackets.
- /// </para>
- /// <para>
- /// If a precision specifier is given, then only the corresponding
- /// number of right most components of the class name will be
- /// printed. By default the class name is output in fully qualified form.
- /// </para>
- /// <para>
- /// For example, for the class name "log4net.Layout.PatternLayout", the
- /// pattern <b>%type{1}</b> will output "PatternLayout".
- /// </para>
- /// <para>
- /// <b>WARNING</b> Generating the caller class information is
- /// slow. Thus, its use should be avoided unless execution speed is
- /// not an issue.
- /// </para>
- /// <para>
- /// See the note below on the availability of caller location information.
- /// </para>
- /// </description>
- /// </item>
- /// <item>
- /// <term>u</term>
- /// <description>Equivalent to <b>identity</b></description>
- /// </item>
- /// <item>
- /// <term>username</term>
- /// <description>
- /// <para>
- /// Used to output the WindowsIdentity for the currently
- /// active user.
- /// </para>
- /// <para>
- /// <b>WARNING</b> Generating caller WindowsIdentity information is
- /// extremely slow. Its use should be avoided unless execution speed
- /// is not an issue.
- /// </para>
- /// </description>
- /// </item>
- /// <item>
- /// <term>utcdate</term>
- /// <description>
- /// <para>
- /// Used to output the date of the logging event in universal time.
- /// The date conversion
- /// specifier may be followed by a <i>date format specifier</i> enclosed
- /// between braces. For example, <b>%utcdate{HH:mm:ss,fff}</b> or
- /// <b>%utcdate{dd MMM yyyy HH:mm:ss,fff}</b>. If no date format specifier is
- /// given then ISO8601 format is
- /// assumed (<see cref="log4net.DateFormatter.Iso8601DateFormatter"/>).
- /// </para>
- /// <para>
- /// The date format specifier admits the same syntax as the
- /// time pattern string of the <see cref="M:DateTime.ToString(string)"/>.
- /// </para>
- /// <para>
- /// For better results it is recommended to use the log4net date
- /// formatters. These can be specified using one of the strings
- /// "ABSOLUTE", "DATE" and "ISO8601" for specifying
- /// <see cref="log4net.DateFormatter.AbsoluteTimeDateFormatter"/>,
- /// <see cref="log4net.DateFormatter.DateTimeDateFormatter"/> and respectively
- /// <see cref="log4net.DateFormatter.Iso8601DateFormatter"/>. For example,
- /// <b>%utcdate{ISO8601}</b> or <b>%utcdate{ABSOLUTE}</b>.
- /// </para>
- /// <para>
- /// These dedicated date formatters perform significantly
- /// better than <see cref="M:DateTime.ToString(string)"/>.
- /// </para>
- /// </description>
- /// </item>
- /// <item>
- /// <term>w</term>
- /// <description>Equivalent to <b>username</b></description>
- /// </item>
- /// <item>
- /// <term>x</term>
- /// <description>Equivalent to <b>ndc</b></description>
- /// </item>
- /// <item>
- /// <term>X</term>
- /// <description>Equivalent to <b>mdc</b></description>
- /// </item>
- /// <item>
- /// <term>%</term>
- /// <description>
- /// <para>
- /// The sequence %% outputs a single percent sign.
- /// </para>
- /// </description>
- /// </item>
- /// </list>
- /// <para>
- /// The single letter patterns are deprecated in favor of the
- /// longer more descriptive pattern names.
- /// </para>
- /// <para>
- /// By default the relevant information is output as is. However,
- /// with the aid of format modifiers it is possible to change the
- /// minimum field width, the maximum field width and justification.
- /// </para>
- /// <para>
- /// The optional format modifier is placed between the percent sign
- /// and the conversion pattern name.
- /// </para>
- /// <para>
- /// The first optional format modifier is the <i>left justification
- /// flag</i> which is just the minus (-) character. Then comes the
- /// optional <i>minimum field width</i> modifier. This is a decimal
- /// constant that represents the minimum number of characters to
- /// output. If the data item requires fewer characters, it is padded on
- /// either the left or the right until the minimum width is
- /// reached. The default is to pad on the left (right justify) but you
- /// can specify right padding with the left justification flag. The
- /// padding character is space. If the data item is larger than the
- /// minimum field width, the field is expanded to accommodate the
- /// data. The value is never truncated.
- /// </para>
- /// <para>
- /// This behavior can be changed using the <i>maximum field
- /// width</i> modifier which is designated by a period followed by a
- /// decimal constant. If the data item is longer than the maximum
- /// field, then the extra characters are removed from the
- /// <i>beginning</i> of the data item and not from the end. For
- /// example, it the maximum field width is eight and the data item is
- /// ten characters long, then the first two characters of the data item
- /// are dropped. This behavior deviates from the printf function in C
- /// where truncation is done from the end.
- /// </para>
- /// <para>
- /// Below are various format modifier examples for the logger
- /// conversion specifier.
- /// </para>
- /// <div class="tablediv">
- /// <table class="dtTABLE" cellspacing="0">
- /// <tr>
- /// <th>Format modifier</th>
- /// <th>left justify</th>
- /// <th>minimum width</th>
- /// <th>maximum width</th>
- /// <th>comment</th>
- /// </tr>
- /// <tr>
- /// <td align="center">%20logger</td>
- /// <td align="center">false</td>
- /// <td align="center">20</td>
- /// <td align="center">none</td>
- /// <td>
- /// <para>
- /// Left pad with spaces if the logger name is less than 20
- /// characters long.
- /// </para>
- /// </td>
- /// </tr>
- /// <tr>
- /// <td align="center">%-20logger</td>
- /// <td align="center">true</td>
- /// <td align="center">20</td>
- /// <td align="center">none</td>
- /// <td>
- /// <para>
- /// Right pad with spaces if the logger
- /// name is less than 20 characters long.
- /// </para>
- /// </td>
- /// </tr>
- /// <tr>
- /// <td align="center">%.30logger</td>
- /// <td align="center">NA</td>
- /// <td align="center">none</td>
- /// <td align="center">30</td>
- /// <td>
- /// <para>
- /// Truncate from the beginning if the logger
- /// name is longer than 30 characters.
- /// </para>
- /// </td>
- /// </tr>
- /// <tr>
- /// <td align="center"><nobr>%20.30logger</nobr></td>
- /// <td align="center">false</td>
- /// <td align="center">20</td>
- /// <td align="center">30</td>
- /// <td>
- /// <para>
- /// Left pad with spaces if the logger name is shorter than 20
- /// characters. However, if logger name is longer than 30 characters,
- /// then truncate from the beginning.
- /// </para>
- /// </td>
- /// </tr>
- /// <tr>
- /// <td align="center">%-20.30logger</td>
- /// <td align="center">true</td>
- /// <td align="center">20</td>
- /// <td align="center">30</td>
- /// <td>
- /// <para>
- /// Right pad with spaces if the logger name is shorter than 20
- /// characters. However, if logger name is longer than 30 characters,
- /// then truncate from the beginning.
- /// </para>
- /// </td>
- /// </tr>
- /// </table>
- /// </div>
- /// <para>
- /// <b>Note about caller location information.</b><br />
- /// The following patterns <c>%type %file %line %method %location %class %C %F %L %l %M</c>
- /// all generate caller location information.
- /// Location information uses the <c>System.Diagnostics.StackTrace</c> class to generate
- /// a call stack. The caller's information is then extracted from this stack.
- /// </para>
- /// <note type="caution">
- /// <para>
- /// The <c>System.Diagnostics.StackTrace</c> class is not supported on the
- /// .NET Compact Framework 1.0 therefore caller location information is not
- /// available on that framework.
- /// </para>
- /// </note>
- /// <note type="caution">
- /// <para>
- /// The <c>System.Diagnostics.StackTrace</c> class has this to say about Release builds:
- /// </para>
- /// <para>
- /// "StackTrace information will be most informative with Debug build configurations.
- /// By default, Debug builds include debug symbols, while Release builds do not. The
- /// debug symbols contain most of the file, method name, line number, and column
- /// information used in constructing StackFrame and StackTrace objects. StackTrace
- /// might not report as many method calls as expected, due to code transformations
- /// that occur during optimization."
- /// </para>
- /// <para>
- /// This means that in a Release build the caller information may be incomplete or may
- /// not exist at all! Therefore caller location information cannot be relied upon in a Release build.
- /// </para>
- /// </note>
- /// <para>
- /// Additional pattern converters may be registered with a specific <see cref="PatternLayout"/>
- /// instance using the <see cref="M:AddConverter(string, Type)"/> method.
- /// </para>
- /// </remarks>
- /// <example>
- /// This is a more detailed pattern.
- /// <code><b>%timestamp [%thread] %level %logger %ndc - %message%newline</b></code>
- /// </example>
- /// <example>
- /// A similar pattern except that the relative time is
- /// right padded if less than 6 digits, thread name is right padded if
- /// less than 15 characters and truncated if longer and the logger
- /// name is left padded if shorter than 30 characters and truncated if
- /// longer.
- /// <code><b>%-6timestamp [%15.15thread] %-5level %30.30logger %ndc - %message%newline</b></code>
- /// </example>
- /// <author>Nicko Cadell</author>
- /// <author>Gert Driesen</author>
- /// <author>Douglas de la Torre</author>
- /// <author>Daniel Cazzulino</author>
- public class PatternLayout : LayoutSkeleton
- {
- #region Constants
+ /// <term>t</term>
+ /// <description>Equivalent to <b>thread</b></description>
+ /// </item>
+ /// <item>
+ /// <term>timestamp</term>
+ /// <description>
+ /// <para>
+ /// Used to output the number of milliseconds elapsed since the start
+ /// of the application until the creation of the logging event.
+ /// </para>
+ /// </description>
+ /// </item>
+ /// <item>
+ /// <term>thread</term>
+ /// <description>
+ /// <para>
+ /// Used to output the name of the thread that generated the
+ /// logging event. Uses the thread number if no name is available.
+ /// </para>
+ /// </description>
+ /// </item>
+ /// <item>
+ /// <term>type</term>
+ /// <description>
+ /// <para>
+ /// Used to output the fully qualified type name of the caller
+ /// issuing the logging request. This conversion specifier
+ /// can be optionally followed by <i>precision specifier</i>, that
+ /// is a decimal constant in brackets.
+ /// </para>
+ /// <para>
+ /// If a precision specifier is given, then only the corresponding
+ /// number of right most components of the class name will be
+ /// printed. By default the class name is output in fully qualified form.
+ /// </para>
+ /// <para>
+ /// For example, for the class name "log4net.Layout.PatternLayout", the
+ /// pattern <b>%type{1}</b> will output "PatternLayout".
+ /// </para>
+ /// <para>
+ /// <b>WARNING</b> Generating the caller class information is
+ /// slow. Thus, its use should be avoided unless execution speed is
+ /// not an issue.
+ /// </para>
+ /// <para>
+ /// See the note below on the availability of caller location information.
+ /// </para>
+ /// </description>
+ /// </item>
+ /// <item>
+ /// <term>u</term>
+ /// <description>Equivalent to <b>identity</b></description>
+ /// </item>
+ /// <item>
+ /// <term>username</term>
+ /// <description>
+ /// <para>
+ /// Used to output the WindowsIdentity for the currently
+ /// active user.
+ /// </para>
+ /// <para>
+ /// <b>WARNING</b> Generating caller WindowsIdentity information is
+ /// extremely slow. Its use should be avoided unless execution speed
+ /// is not an issue.
+ /// </para>
+ /// </description>
+ /// </item>
+ /// <item>
+ /// <term>utcdate</term>
+ /// <description>
+ /// <para>
+ /// Used to output the date of the logging event in universal time.
+ /// The date conversion
+ /// specifier may be followed by a <i>date format specifier</i> enclosed
+ /// between braces. For example, <b>%utcdate{HH:mm:ss,fff}</b> or
+ /// <b>%utcdate{dd MMM yyyy HH:mm:ss,fff}</b>. If no date format specifier is
+ /// given then ISO8601 format is
+ /// assumed (<see cref="log4net.DateFormatter.Iso8601DateFormatter"/>).
+ /// </para>
+ /// <para>
+ /// The date format specifier admits the same syntax as the
+ /// time pattern string of the <see cref="M:DateTime.ToString(string)"/>.
+ /// </para>
+ /// <para>
+ /// For better results it is recommended to use the log4net date
+ /// formatters. These can be specified using one of the strings
+ /// "ABSOLUTE", "DATE" and "ISO8601" for specifying
+ /// <see cref="log4net.DateFormatter.AbsoluteTimeDateFormatter"/>,
+ /// <see cref="log4net.DateFormatter.DateTimeDateFormatter"/> and respectively
+ /// <see cref="log4net.DateFormatter.Iso8601DateFormatter"/>. For example,
+ /// <b>%utcdate{ISO8601}</b> or <b>%utcdate{ABSOLUTE}</b>.
+ /// </para>
+ /// <para>
+ /// These dedicated date formatters perform significantly
+ /// better than <see cref="M:DateTime.ToString(string)"/>.
+ /// </para>
+ /// </description>
+ /// </item>
+ /// <item>
+ /// <term>w</term>
+ /// <description>Equivalent to <b>username</b></description>
+ /// </item>
+ /// <item>
+ /// <term>x</term>
+ /// <description>Equivalent to <b>ndc</b></description>
+ /// </item>
+ /// <item>
+ /// <term>X</term>
+ /// <description>Equivalent to <b>mdc</b></description>
+ /// </item>
+ /// <item>
+ /// <term>%</term>
+ /// <description>
+ /// <para>
+ /// The sequence %% outputs a single percent sign.
+ /// </para>
+ /// </description>
+ /// </item>
+ /// </list>
+ /// <para>
+ /// The single letter patterns are deprecated in favor of the
+ /// longer more descriptive pattern names.
+ /// </para>
+ /// <para>
+ /// By default the relevant information is output as is. However,
+ /// with the aid of format modifiers it is possible to change the
+ /// minimum field width, the maximum field width and justification.
+ /// </para>
+ /// <para>
+ /// The optional format modifier is placed between the percent sign
+ /// and the conversion pattern name.
+ /// </para>
+ /// <para>
+ /// The first optional format modifier is the <i>left justification
+ /// flag</i> which is just the minus (-) character. Then comes the
+ /// optional <i>minimum field width</i> modifier. This is a decimal
+ /// constant that represents the minimum number of characters to
+ /// output. If the data item requires fewer characters, it is padded on
+ /// either the left or the right until the minimum width is
+ /// reached. The default is to pad on the left (right justify) but you
+ /// can specify right padding with the left justification flag. The
+ /// padding character is space. If the data item is larger than the
+ /// minimum field width, the field is expanded to accommodate the
+ /// data. The value is never truncated.
+ /// </para>
+ /// <para>
+ /// This behavior can be changed using the <i>maximum field
+ /// width</i> modifier which is designated by a period followed by a
+ /// decimal constant. If the data item is longer than the maximum
+ /// field, then the extra characters are removed from the
+ /// <i>beginning</i> of the data item and not from the end. For
+ /// example, it the maximum field width is eight and the data item is
+ /// ten characters long, then the first two characters of the data item
+ /// are dropped. This behavior deviates from the printf function in C
+ /// where truncation is done from the end.
+ /// </para>
+ /// <para>
+ /// Below are various format modifier examples for the logger
+ /// conversion specifier.
+ /// </para>
+ /// <div class="tablediv">
+ /// <table class="dtTABLE" cellspacing="0">
+ /// <tr>
+ /// <th>Format modifier</th>
+ /// <th>left justify</th>
+ /// <th>minimum width</th>
+ /// <th>maximum width</th>
+ /// <th>comment</th>
+ /// </tr>
+ /// <tr>
+ /// <td align="center">%20logger</td>
+ /// <td align="center">false</td>
+ /// <td align="center">20</td>
+ /// <td align="center">none</td>
+ /// <td>
+ /// <para>
+ /// Left pad with spaces if the logger name is less than 20
+ /// characters long.
+ /// </para>
+ /// </td>
+ /// </tr>
+ /// <tr>
+ /// <td align="center">%-20logger</td>
+ /// <td align="center">true</td>
+ /// <td align="center">20</td>
+ /// <td align="center">none</td>
+ /// <td>
+ /// <para>
+ /// Right pad with spaces if the logger
+ /// name is less than 20 characters long.
+ /// </para>
+ /// </td>
+ /// </tr>
+ /// <tr>
+ /// <td align="center">%.30logger</td>
+ /// <td align="center">NA</td>
+ /// <td align="center">none</td>
+ /// <td align="center">30</td>
+ /// <td>
+ /// <para>
+ /// Truncate from the beginning if the logger
+ /// name is longer than 30 characters.
+ /// </para>
+ /// </td>
+ /// </tr>
+ /// <tr>
+ /// <td align="center"><nobr>%20.30logger</nobr></td>
+ /// <td align="center">false</td>
+ /// <td align="center">20</td>
+ /// <td align="center">30</td>
+ /// <td>
+ /// <para>
+ /// Left pad with spaces if the logger name is shorter than 20
+ /// characters. However, if logger name is longer than 30 characters,
+ /// then truncate from the beginning.
+ /// </para>
+ /// </td>
+ /// </tr>
+ /// <tr>
+ /// <td align="center">%-20.30logger</td>
+ /// <td align="center">true</td>
+ /// <td align="center">20</td>
+ /// <td align="center">30</td>
+ /// <td>
+ /// <para>
+ /// Right pad with spaces if the logger name is shorter than 20
+ /// characters. However, if logger name is longer than 30 characters,
+ /// then truncate from the beginning.
+ /// </para>
+ /// </td>
+ /// </tr>
+ /// </table>
+ /// </div>
+ /// <para>
+ /// <b>Note about caller location information.</b><br />
+ /// The following patterns <c>%type %file %line %method %location %class %C %F %L %l %M</c>
+ /// all generate caller location information.
+ /// Location information uses the <c>System.Diagnostics.StackTrace</c> class to generate
+ /// a call stack. The caller's information is then extracted from this stack.
+ /// </para>
+ /// <note type="caution">
+ /// <para>
+ /// The <c>System.Diagnostics.StackTrace</c> class is not supported on the
+ /// .NET Compact Framework 1.0 therefore caller location information is not
+ /// available on that framework.
+ /// </para>
+ /// </note>
+ /// <note type="caution">
+ /// <para>
+ /// The <c>System.Diagnostics.StackTrace</c> class has this to say about Release builds:
+ /// </para>
+ /// <para>
+ /// "StackTrace information will be most informative with Debug build configurations.
+ /// By default, Debug builds include debug symbols, while Release builds do not. The
+ /// debug symbols contain most of the file, method name, line number, and column
+ /// information used in constructing StackFrame and StackTrace objects. StackTrace
+ /// might not report as many method calls as expected, due to code transformations
+ /// that occur during optimization."
+ /// </para>
+ /// <para>
+ /// This means that in a Release build the caller information may be incomplete or may
+ /// not exist at all! Therefore caller location information cannot be relied upon in a Release build.
+ /// </para>
+ /// </note>
+ /// <para>
+ /// Additional pattern converters may be registered with a specific <see cref="PatternLayout"/>
+ /// instance using the <see cref="M:AddConverter(string, Type)"/> method.
+ /// </para>
+ /// </remarks>
+ /// <example>
+ /// This is a more detailed pattern.
+ /// <code><b>%timestamp [%thread] %level %logger %ndc - %message%newline</b></code>
+ /// </example>
+ /// <example>
+ /// A similar pattern except that the relative time is
+ /// right padded if less than 6 digits, thread name is right padded if
+ /// less than 15 characters and truncated if longer and the logger
+ /// name is left padded if shorter than 30 characters and truncated if
+ /// longer.
+ /// <code><b>%-6timestamp [%15.15thread] %-5level %30.30logger %ndc - %message%newline</b></code>
+ /// </example>
+ /// <author>Nicko Cadell</author>
+ /// <author>Gert Driesen</author>
+ /// <author>Douglas de la Torre</author>
+ /// <author>Daniel Cazzulino</author>
+ public class PatternLayout : LayoutSkeleton
+ {
+ #region Constants
- /// <summary>
- /// Default pattern string for log output.
- /// </summary>
- /// <remarks>
- /// <para>
- /// Default pattern string for log output.
- /// Currently set to the string <b>"%message%newline"</b>
- /// which just prints the application supplied message.
- /// </para>
- /// </remarks>
- public const string DefaultConversionPattern ="%message%newline";
+ /// <summary>
+ /// Default pattern string for log output.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Default pattern string for log output.
+ /// Currently set to the string <b>"%message%newline"</b>
+ /// which just prints the application supplied message.
+ /// </para>
+ /// </remarks>
+ public const string DefaultConversionPattern ="%message%newline";
- /// <summary>
- /// A detailed conversion pattern
- /// </summary>
- /// <remarks>
- /// <para>
- /// A conversion pattern which includes Time, Thread, Logger, and Nested Context.
- /// Current value is <b>%timestamp [%thread] %level %logger %ndc - %message%newline</b>.
- /// </para>
- /// </remarks>
- public const string DetailConversionPattern = "%timestamp [%thread] %level %logger %ndc - %message%newline";
+ /// <summary>
+ /// A detailed conversion pattern
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// A conversion pattern which includes Time, Thread, Logger, and Nested Context.
+ /// Current value is <b>%timestamp [%thread] %level %logger %ndc - %message%newline</b>.
+ /// </para>
+ /// </remarks>
+ public const string DetailConversionPattern = "%timestamp [%thread] %level %logger %ndc - %message%newline";
- #endregion
+ #endregion
- #region Static Fields
+ #region Static Fields
- /// <summary>
- /// Internal map of converter identifiers to converter types.
- /// </summary>
- /// <remarks>
- /// <para>
- /// This static map is overridden by the m_converterRegistry instance map
- /// </para>
- /// </remarks>
- private static Hashtable s_globalRulesRegistry;
+ /// <summary>
+ /// Internal map of converter identifiers to converter types.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// This static map is overridden by the m_converterRegistry instance map
+ /// </para>
+ /// </remarks>
+ private static Hashtable s_globalRulesRegistry;
- #endregion Static Fields
+ #endregion Static Fields
- #region Member Variables
+ #region Member Variables
- /// <summary>
- /// the pattern
- /// </summary>
- private string m_pattern;
+ /// <summary>
+ /// the pattern
+ /// </summary>
+ private string m_pattern;
- /// <summary>
- /// the head of the pattern converter chain
- /// </summary>
- private PatternConverter m_head;
+ /// <summary>
+ /// the head of the pattern converter chain
+ /// </summary>
+ private PatternConverter m_head;
- /// <summary>
- /// patterns defined on this PatternLayout only
- /// </summary>
- private Hashtable m_instanceRulesRegistry = new Hashtable();
+ /// <summary>
+ /// patterns defined on this PatternLayout only
+ /// </summary>
+ private Hashtable m_instanceRulesRegistry = new Hashtable();
- #endregion
+ #endregion
- #region Static Constructor
+ #region Static Constructor
- /// <summary>
- /// Initialize the global registry
- /// </summary>
- /// <remarks>
- /// <para>
- /// Defines the builtin global rules.
- /// </para>
- /// </remarks>
- static PatternLayout()
- {
- s_globalRulesRegistry = new Hashtable(45);
+ /// <summary>
+ /// Initialize the global registry
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Defines the builtin global rules.
+ /// </para>
+ /// </remarks>
+ static PatternLayout()
+ {
+ s_globalRulesRegistry = new Hashtable(45);
- s_globalRulesRegistry.Add("literal", typeof(LiteralPatternConverter));
- s_globalRulesRegistry.Add("newline", typeof(NewLinePatternConverter));
- s_globalRulesRegistry.Add("n", typeof(NewLinePatternConverter));
+ s_globalRulesRegistry.Add("literal", typeof(LiteralPatternConverter));
+ s_globalRulesRegistry.Add("newline", typeof(NewLinePatternConverter));
+ s_globalRulesRegistry.Add("n", typeof(NewLinePatternConverter));
// .NET Compact Framework 1.0 has no support for ASP.NET
// SSCLI 1.0 has no support for ASP.NET
#if !NETCF && !SSCLI && !CLIENT_PROFILE && !NETSTANDARD
- s_globalRulesRegistry.Add("aspnet-cache", typeof(AspNetCachePatternConverter));
- s_globalRulesRegistry.Add("aspnet-context", typeof(AspNetContextPatternConverter));
- s_globalRulesRegistry.Add("aspnet-request", typeof(AspNetRequestPatternConverter));
- s_globalRulesRegistry.Add("aspnet-session", typeof(AspNetSessionPatternConverter));
+ s_globalRulesRegistry.Add("aspnet-cache", typeof(AspNetCachePatternConverter));
+ s_globalRulesRegistry.Add("aspnet-context", typeof(AspNetContextPatternConverter));
+ s_globalRulesRegistry.Add("aspnet-request", typeof(AspNetRequestPatternConverter));
+ s_globalRulesRegistry.Add("aspnet-session", typeof(AspNetSessionPatternConverter));
#endif
- s_globalRulesRegistry.Add("c", typeof(LoggerPatternConverter));
- s_globalRulesRegistry.Add("logger", typeof(LoggerPatternConverter));
+ s_globalRulesRegistry.Add("c", typeof(LoggerPatternConverter));
+ s_globalRulesRegistry.Add("logger", typeof(LoggerPatternConverter));
- s_globalRulesRegistry.Add("C", typeof(TypeNamePatternConverter));
- s_globalRulesRegistry.Add("class", typeof(TypeNamePatternConverter));
- s_globalRulesRegistry.Add("type", typeof(TypeNamePatternConverter));
+ s_globalRulesRegistry.Add("C", typeof(TypeNamePatternConverter));
+ s_globalRulesRegistry.Add("class", typeof(TypeNamePatternConverter));
+ s_globalRulesRegistry.Add("type", typeof(TypeNamePatternConverter));
- s_globalRulesRegistry.Add("d", typeof(DatePatternConverter));
- s_globalRulesRegistry.Add("date", typeof(DatePatternConverter));
+ s_globalRulesRegistry.Add("d", typeof(DatePatternConverter));
+ s_globalRulesRegistry.Add("date", typeof(DatePatternConverter));
- s_globalRulesRegistry.Add("exception", typeof(ExceptionPatternConverter));
+ s_globalRulesRegistry.Add("exception", typeof(ExceptionPatternConverter));
- s_globalRulesRegistry.Add("F", typeof(FileLocationPatternConverter));
- s_globalRulesRegistry.Add("file", typeof(FileLocationPatternConverter));
+ s_globalRulesRegistry.Add("F", typeof(FileLocationPatternConverter));
+ s_globalRulesRegistry.Add("file", typeof(FileLocationPatternConverter));
- s_globalRulesRegistry.Add("l", typeof(FullLocationPatternConverter));
- s_globalRulesRegistry.Add("location", typeof(FullLocationPatternConverter));
+ s_globalRulesRegistry.Add("l", typeof(FullLocationPatternConverter));
+ s_globalRulesRegistry.Add("location", typeof(FullLocationPatternConverter));
- s_globalRulesRegistry.Add("L", typeof(LineLocationPatternConverter));
- s_globalRulesRegistry.Add("line", typeof(LineLocationPatternConverter));
+ s_globalRulesRegistry.Add("L", typeof(LineLocationPatternConverter));
+ s_globalRulesRegistry.Add("line", typeof(LineLocationPatternConverter));
- s_globalRulesRegistry.Add("m", typeof(MessagePatternConverter));
- s_globalRulesRegistry.Add("message", typeof(MessagePatternConverter));
+ s_globalRulesRegistry.Add("m", typeof(MessagePatternConverter));
+ s_globalRulesRegistry.Add("message", typeof(MessagePatternConverter));
- s_globalRulesRegistry.Add("M", typeof(MethodLocationPatternConverter));
- s_globalRulesRegistry.Add("method", typeof(MethodLocationPatternConverter));
+ s_globalRulesRegistry.Add("M", typeof(MethodLocationPatternConverter));
+ s_globalRulesRegistry.Add("method", typeof(MethodLocationPatternConverter));
- s_globalRulesRegistry.Add("p", typeof(LevelPatternConverter));
- s_globalRulesRegistry.Add("level", typeof(LevelPatternConverter));
+ s_globalRulesRegistry.Add("p", typeof(LevelPatternConverter));
+ s_globalRulesRegistry.Add("level", typeof(LevelPatternConverter));
- s_globalRulesRegistry.Add("P", typeof(PropertyPatternConverter));
- s_globalRulesRegistry.Add("property", typeof(PropertyPatternConverter));
- s_globalRulesRegistry.Add("properties", typeof(PropertyPatternConverter));
+ s_globalRulesRegistry.Add("P", typeof(PropertyPatternConverter));
+ s_globalRulesRegistry.Add("property", typeof(PropertyPatternConverter));
+ s_globalRulesRegistry.Add("properties", typeof(PropertyPatternConverter));
- s_globalRulesRegistry.Add("r", typeof(RelativeTimePatternConverter));
- s_globalRulesRegistry.Add("timestamp", typeof(RelativeTimePatternConverter));
-
+ s_globalRulesRegistry.Add("r", typeof(RelativeTimePatternConverter));
+ s_globalRulesRegistry.Add("timestamp", typeof(RelativeTimePatternConverter));
+
#if !NETCF && !NETSTANDARD1_3
- s_globalRulesRegistry.Add("stacktrace", typeof(StackTracePatternConverter));
+ s_globalRulesRegistry.Add("stacktrace", typeof(StackTracePatternConverter));
s_globalRulesRegistry.Add("stacktracedetail", typeof(StackTraceDetailPatternConverter));
#endif
- s_globalRulesRegistry.Add("t", typeof(ThreadPatternConverter));
- s_globalRulesRegistry.Add("thread", typeof(ThreadPatternConverter));
+ s_globalRulesRegistry.Add("t", typeof(ThreadPatternConverter));
+ s_globalRulesRegistry.Add("thread", typeof(ThreadPatternConverter));
- // For backwards compatibility the NDC patterns
- s_globalRulesRegistry.Add("x", typeof(NdcPatternConverter));
- s_globalRulesRegistry.Add("ndc", typeof(NdcPatternConverter));
+ // For backwards compatibility the NDC patterns
+ s_globalRulesRegistry.Add("x", typeof(NdcPatternConverter));
+ s_globalRulesRegistry.Add("ndc", typeof(NdcPatternConverter));
- // For backwards compatibility the MDC patterns just do a property lookup
- s_globalRulesRegistry.Add("X", typeof(PropertyPatternConverter));
- s_globalRulesRegistry.Add("mdc", typeof(PropertyPatternConverter));
+ // For backwards compatibility the MDC patterns just do a property lookup
+ s_globalRulesRegistry.Add("X", typeof(PropertyPatternConverter));
+ s_globalRulesRegistry.Add("mdc", typeof(PropertyPatternConverter));
- s_globalRulesRegistry.Add("a", typeof(AppDomainPatternConverter));
- s_globalRulesRegistry.Add("appdomain", typeof(AppDomainPatternConverter));
+ s_globalRulesRegistry.Add("a", typeof(AppDomainPatternConverter));
+ s_globalRulesRegistry.Add("appdomain", typeof(AppDomainPatternConverter));
- s_globalRulesRegistry.Add("u", typeof(IdentityPatternConverter));
- s_globalRulesRegistry.Add("identity", typeof(IdentityPatternConverter));
+ s_globalRulesRegistry.Add("u", typeof(IdentityPatternConverter));
+ s_globalRulesRegistry.Add("identity", typeof(IdentityPatternConverter));
- s_globalRulesRegistry.Add("utcdate", typeof(UtcDatePatternConverter));
- s_globalRulesRegistry.Add("utcDate", typeof(UtcDatePatternConverter));
- s_globalRulesRegistry.Add("UtcDate", typeof(UtcDatePatternConverter));
+ s_globalRulesRegistry.Add("utcdate", typeof(UtcDatePatternConverter));
+ s_globalRulesRegistry.Add("utcDate", typeof(UtcDatePatternConverter));
+ s_globalRulesRegistry.Add("UtcDate", typeof(UtcDatePatternConverter));
- s_globalRulesRegistry.Add("w", typeof(UserNamePatternConverter));
- s_globalRulesRegistry.Add("username", typeof(UserNamePatternConverter));
- }
+ s_globalRulesRegistry.Add("w", typeof(UserNamePatternConverter));
+ s_globalRulesRegistry.Add("username", typeof(UserNamePatternConverter));
+ }
- #endregion Static Constructor
+ #endregion Static Constructor
- #region Constructors
+ #region Constructors
- /// <summary>
- /// Constructs a PatternLayout using the DefaultConversionPattern
- /// </summary>
- /// <remarks>
- /// <para>
- /// The default pattern just produces the application supplied message.
- /// </para>
- /// <para>
- /// Note to Inheritors: This constructor calls the virtual method
- /// <see cref="CreatePatternParser"/>. If you override this method be
- /// aware that it will be called before your is called constructor.
- /// </para>
- /// <para>
- /// As per the <see cref="IOptionHandler"/> contract the <see cref="ActivateOptions"/>
- /// method must be called after the properties on this object have been
- /// configured.
- /// </para>
- /// </remarks>
- public PatternLayout() : this(DefaultConversionPattern)
- {
- }
+ /// <summary>
+ /// Constructs a PatternLayout using the DefaultConversionPattern
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// The default pattern just produces the application supplied message.
+ /// </para>
+ /// <para>
+ /// Note to Inheritors: This constructor calls the virtual method
+ /// <see cref="CreatePatternParser"/>. If you override this method be
+ /// aware that it will be called before your is called constructor.
+ /// </para>
+ /// <para>
+ /// As per the <see cref="IOptionHandler"/> contract the <see cref="ActivateOptions"/>
+ /// method must be called after the properties on this object have been
+ /// configured.
+ /// </para>
+ /// </remarks>
+ public PatternLayout() : this(DefaultConversionPattern)
+ {
+ }
- /// <summary>
- /// Constructs a PatternLayout using the supplied conversion pattern
- /// </summary>
- /// <param name="pattern">the pattern to use</param>
- /// <remarks>
- /// <para>
- /// Note to Inheritors: This constructor calls the virtual method
- /// <see cref="CreatePatternParser"/>. If you override this method be
- /// aware that it will be called before your is called constructor.
- /// </para>
- /// <para>
- /// When using this constructor the <see cref="ActivateOptions"/> method
- /// need not be called. This may not be the case when using a subclass.
- /// </para>
- /// </remarks>
- public PatternLayout(string pattern)
- {
- // By default we do not process the exception
- IgnoresException = true;
+ /// <summary>
+ /// Constructs a PatternLayout using the supplied conversion pattern
+ /// </summary>
+ /// <param name="pattern">the pattern to use</param>
+ /// <remarks>
+ /// <para>
+ /// Note to Inheritors: This constructor calls the virtual method
+ /// <see cref="CreatePatternParser"/>. If you override this method be
+ /// aware that it will be called before your is called constructor.
+ /// </para>
+ /// <para>
+ /// When using this constructor the <see cref="ActivateOptions"/> method
+ /// need not be called. This may not be the case when using a subclass.
+ /// </para>
+ /// </remarks>
+ public PatternLayout(string pattern)
+ {
+ // By default we do not process the exception
+ IgnoresException = true;
- m_pattern = pattern;
- if (m_pattern == null)
- {
- m_pattern = DefaultConversionPattern;
- }
+ m_pattern = pattern;
+ if (m_pattern == null)
+ {
+ m_pattern = DefaultConversionPattern;
+ }
- ActivateOptions();
- }
+ ActivateOptions();
+ }
- #endregion
+ #endregion
- /// <summary>
- /// The pattern formatting string
- /// </summary>
- /// <remarks>
- /// <para>
- /// The <b>ConversionPattern</b> option. This is the string which
- /// controls formatting and consists of a mix of literal content and
- /// conversion specifiers.
- /// </para>
- /// </remarks>
- public string ConversionPattern
- {
- get { return m_pattern; }
- set { m_pattern = value; }
- }
+ /// <summary>
+ /// The pattern formatting string
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// The <b>ConversionPattern</b> option. This is the string which
+ /// controls formatting and consists of a mix of literal content and
+ /// conversion specifiers.
+ /// </para>
+ /// </remarks>
+ public string ConversionPattern
+ {
+ get { return m_pattern; }
+ set { m_pattern = value; }
+ }
- /// <summary>
- /// Create the pattern parser instance
- /// </summary>
- /// <param name="pattern">the pattern to parse</param>
- /// <returns>The <see cref="PatternParser"/> that will format the event</returns>
- /// <remarks>
- /// <para>
- /// Creates the <see cref="PatternParser"/> used to parse the conversion string. Sets the
- /// global and instance rules on the <see cref="PatternParser"/>.
- /// </para>
- /// </remarks>
- protected virtual PatternParser CreatePatternParser(string pattern)
- {
- PatternParser patternParser = new PatternParser(pattern);
+ /// <summary>
+ /// Create the pattern parser instance
+ /// </summary>
+ /// <param name="pattern">the pattern to parse</param>
+ /// <returns>The <see cref="PatternParser"/> that will format the event</returns>
+ /// <remarks>
+ /// <para>
+ /// Creates the <see cref="PatternParser"/> used to parse the conversion string. Sets the
+ /// global and instance rules on the <see cref="PatternParser"/>.
+ /// </para>
+ /// </remarks>
+ protected virtual PatternParser CreatePatternParser(string pattern)
+ {
+ PatternParser patternParser = new PatternParser(pattern);
- // Add all the builtin patterns
- foreach(DictionaryEntry entry in s_globalRulesRegistry)
- {
+ // Add all the builtin patterns
+ foreach(DictionaryEntry entry in s_globalRulesRegistry)
+ {
ConverterInfo converterInfo = new ConverterInfo();
converterInfo.Name = (string)entry.Key;
converterInfo.Type = (Type)entry.Value;
patternParser.PatternConverters[entry.Key] = converterInfo;
- }
- // Add the instance patterns
- foreach(DictionaryEntry entry in m_instanceRulesRegistry)
- {
- patternParser.PatternConverters[entry.Key] = entry.Value;
- }
+ }
+ // Add the instance patterns
+ foreach(DictionaryEntry entry in m_instanceRulesRegistry)
+ {
+ patternParser.PatternConverters[entry.Key] = entry.Value;
+ }
- return patternParser;
- }
+ return patternParser;
+ }
- #region Implementation of IOptionHandler
+ #region Implementation of IOptionHandler
- /// <summary>
- /// Initialize layout options
- /// </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>
- public override void ActivateOptions()
- {
- m_head = CreatePatternParser(m_pattern).Parse();
+ /// <summary>
+ /// Initialize layout options
+ /// </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>
+ public override void ActivateOptions()
+ {
+ m_head = CreatePatternParser(m_pattern).Parse();
- PatternConverter curConverter = m_head;
- while(curConverter != null)
- {
- PatternLayoutConverter layoutConverter = curConverter as PatternLayoutConverter;
- if (layoutConverter != null)
- {
- if (!layoutConverter.IgnoresException)
- {
- // Found converter that handles the exception
- this.IgnoresException = false;
+ PatternConverter curConverter = m_head;
+ while(curConverter != null)
+ {
+ PatternLayoutConverter layoutConverter = curConverter as PatternLayoutConverter;
+ if (layoutConverter != null)
+ {
+ if (!layoutConverter.IgnoresException)
+ {
+ // Found converter that handles the exception
+ this.IgnoresException = false;
- break;
- }
- }
- curConverter = curConverter.Next;
- }
- }
+ break;
+ }
+ }
+ curConverter = curConverter.Next;
+ }
+ }
- #endregion
+ #endregion
- #region Override implementation of LayoutSkeleton
+ #region Override implementation of LayoutSkeleton
- /// <summary>
- /// Produces a formatted string as specified by the conversion pattern.
- /// </summary>
- /// <param name="loggingEvent">the event being logged</param>
- /// <param name="writer">The TextWriter to write the formatted event to</param>
- /// <remarks>
- /// <para>
- /// Parse the <see cref="LoggingEvent"/> using the patter format
- /// specified in the <see cref="ConversionPattern"/> property.
- /// </para>
- /// </remarks>
- public override void Format(TextWriter writer, LoggingEvent loggingEvent)
- {
- if (writer == null)
- {
- throw new ArgumentNullException("writer");
- }
- if (loggingEvent == null)
- {
- throw new ArgumentNullException("loggingEvent");
- }
+ /// <summary>
+ /// Produces a formatted string as specified by the conversion pattern.
+ /// </summary>
+ /// <param name="loggingEvent">the event being logged</param>
+ /// <param name="writer">The TextWriter to write the formatted event to</param>
+ /// <remarks>
+ /// <para>
+ /// Parse the <see cref="LoggingEvent"/> using the patter format
+ /// specified in the <see cref="ConversionPattern"/> property.
+ /// </para>
+ /// </remarks>
+ public override void Format(TextWriter writer, LoggingEvent loggingEvent)
+ {
+ if (writer == null)
+ {
+ throw new ArgumentNullException("writer");
+ }
+ if (loggingEvent == null)
+ {
+ throw new ArgumentNullException("loggingEvent");
+ }
- PatternConverter c = m_head;
+ PatternConverter c = m_head;
- // loop through the chain of pattern converters
- while(c != null)
- {
- c.Format(writer, loggingEvent);
- c = c.Next;
- }
- }
+ // loop through the chain of pattern converters
+ while(c != null)
+ {
+ c.Format(writer, loggingEvent);
+ c = c.Next;
+ }
+ }
- #endregion
+ #endregion
- /// <summary>
- /// Add a converter to this PatternLayout
- /// </summary>
- /// <param name="converterInfo">the converter info</param>
- /// <remarks>
- /// <para>
- /// This version of the method is used by the configurator.
- /// Programmatic users should use the alternative <see cref="M:AddConverter(string,Type)"/> method.
- /// </para>
- /// </remarks>
- public void AddConverter(ConverterInfo converterInfo)
- {
+ /// <summary>
+ /// Add a converter to this PatternLayout
+ /// </summary>
+ /// <param name="converterInfo">the converter info</param>
+ /// <remarks>
+ /// <para>
+ /// This version of the method is used by the configurator.
+ /// Programmatic users should use the alternative <see cref="M:AddConverter(string,Type)"/> method.
+ /// </para>
+ /// </remarks>
+ public void AddConverter(ConverterInfo converterInfo)
+ {
if (converterInfo == null) throw new ArgumentNullException("converterInfo");
if (!typeof(PatternConverter).IsAssignableFrom(converterInfo.Type))
@@ -1137,26 +1137,26 @@
throw new ArgumentException("The converter type specified [" + converterInfo.Type + "] must be a subclass of log4net.Util.PatternConverter", "converterInfo");
}
m_instanceRulesRegistry[converterInfo.Name] = converterInfo;
- }
+ }
- /// <summary>
- /// Add a converter to this PatternLayout
- /// </summary>
- /// <param name="name">the name of the conversion pattern for this converter</param>
- /// <param name="type">the type of the converter</param>
- /// <remarks>
- /// <para>
- /// Add a named pattern converter to this instance. This
- /// converter will be used in the formatting of the event.
- /// This method must be called before <see cref="ActivateOptions"/>.
- /// </para>
- /// <para>
- /// The <paramref name="type"/> specified must extend the
- /// <see cref="PatternConverter"/> type.
- /// </para>
- /// </remarks>
- public void AddConverter(string name, Type type)
- {
+ /// <summary>
+ /// Add a converter to this PatternLayout
+ /// </summary>
+ /// <param name="name">the name of the conversion pattern for this converter</param>
+ /// <param name="type">the type of the converter</param>
+ /// <remarks>
+ /// <para>
+ /// Add a named pattern converter to this instance. This
+ /// converter will be used in the formatting of the event.
+ /// This method must be called before <see cref="ActivateOptions"/>.
+ /// </para>
+ /// <para>
+ /// The <paramref name="type"/> specified must extend the
+ /// <see cref="PatternConverter"/> type.
+ /// </para>
+ /// </remarks>
+ public void AddConverter(string name, Type type)
+ {
if (name == null) throw new ArgumentNullException("name");
if (type == null) throw new ArgumentNullException("type");
@@ -1165,6 +1165,6 @@
converterInfo.Type = type;
AddConverter(converterInfo);
- }
- }
+ }
+ }
}
diff --git a/src/log4net/Layout/RawLayoutConverter.cs b/src/log4net/Layout/RawLayoutConverter.cs
index 1a210e6..3667f81 100644
--- a/src/log4net/Layout/RawLayoutConverter.cs
+++ b/src/log4net/Layout/RawLayoutConverter.cs
@@ -23,64 +23,64 @@
namespace log4net.Layout
{
- /// <summary>
- /// Type converter for the <see cref="IRawLayout"/> interface
- /// </summary>
- /// <remarks>
- /// <para>
- /// Used to convert objects to the <see cref="IRawLayout"/> interface.
- /// Supports converting from the <see cref="ILayout"/> interface to
- /// the <see cref="IRawLayout"/> interface using the <see cref="Layout2RawLayoutAdapter"/>.
- /// </para>
- /// </remarks>
- /// <author>Nicko Cadell</author>
- /// <author>Gert Driesen</author>
- public class RawLayoutConverter : IConvertFrom
- {
- #region Override Implementation of IRawLayout
+ /// <summary>
+ /// Type converter for the <see cref="IRawLayout"/> interface
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Used to convert objects to the <see cref="IRawLayout"/> interface.
+ /// Supports converting from the <see cref="ILayout"/> interface to
+ /// the <see cref="IRawLayout"/> interface using the <see cref="Layout2RawLayoutAdapter"/>.
+ /// </para>
+ /// </remarks>
+ /// <author>Nicko Cadell</author>
+ /// <author>Gert Driesen</author>
+ public class RawLayoutConverter : IConvertFrom
+ {
+ #region Override Implementation of IRawLayout
- /// <summary>
- /// Can the sourceType be converted to an <see cref="IRawLayout"/>
- /// </summary>
- /// <param name="sourceType">the source to be to be converted</param>
- /// <returns><c>true</c> if the source type can be converted to <see cref="IRawLayout"/></returns>
- /// <remarks>
- /// <para>
- /// Test if the <paramref name="sourceType"/> can be converted to a
- /// <see cref="IRawLayout"/>. Only <see cref="ILayout"/> is supported
- /// as the <paramref name="sourceType"/>.
- /// </para>
- /// </remarks>
- public bool CanConvertFrom(Type sourceType)
- {
- // Accept an ILayout object
- return (typeof(ILayout).IsAssignableFrom(sourceType));
- }
+ /// <summary>
+ /// Can the sourceType be converted to an <see cref="IRawLayout"/>
+ /// </summary>
+ /// <param name="sourceType">the source to be to be converted</param>
+ /// <returns><c>true</c> if the source type can be converted to <see cref="IRawLayout"/></returns>
+ /// <remarks>
+ /// <para>
+ /// Test if the <paramref name="sourceType"/> can be converted to a
+ /// <see cref="IRawLayout"/>. Only <see cref="ILayout"/> is supported
+ /// as the <paramref name="sourceType"/>.
+ /// </para>
+ /// </remarks>
+ public bool CanConvertFrom(Type sourceType)
+ {
+ // Accept an ILayout object
+ return (typeof(ILayout).IsAssignableFrom(sourceType));
+ }
- /// <summary>
- /// Convert the value to a <see cref="IRawLayout"/> object
- /// </summary>
- /// <param name="source">the value to convert</param>
- /// <returns>the <see cref="IRawLayout"/> object</returns>
- /// <remarks>
- /// <para>
- /// Convert the <paramref name="source"/> object to a
- /// <see cref="IRawLayout"/> object. If the <paramref name="source"/> object
- /// is a <see cref="ILayout"/> then the <see cref="Layout2RawLayoutAdapter"/>
- /// is used to adapt between the two interfaces, otherwise an
- /// exception is thrown.
- /// </para>
- /// </remarks>
- public object ConvertFrom(object source)
- {
- ILayout layout = source as ILayout;
- if (layout != null)
- {
- return new Layout2RawLayoutAdapter(layout);
- }
- throw ConversionNotSupportedException.Create(typeof(IRawLayout), source);
- }
+ /// <summary>
+ /// Convert the value to a <see cref="IRawLayout"/> object
+ /// </summary>
+ /// <param name="source">the value to convert</param>
+ /// <returns>the <see cref="IRawLayout"/> object</returns>
+ /// <remarks>
+ /// <para>
+ /// Convert the <paramref name="source"/> object to a
+ /// <see cref="IRawLayout"/> object. If the <paramref name="source"/> object
+ /// is a <see cref="ILayout"/> then the <see cref="Layout2RawLayoutAdapter"/>
+ /// is used to adapt between the two interfaces, otherwise an
+ /// exception is thrown.
+ /// </para>
+ /// </remarks>
+ public object ConvertFrom(object source)
+ {
+ ILayout layout = source as ILayout;
+ if (layout != null)
+ {
+ return new Layout2RawLayoutAdapter(layout);
+ }
+ throw ConversionNotSupportedException.Create(typeof(IRawLayout), source);
+ }
- #endregion
- }
+ #endregion
+ }
}
diff --git a/src/log4net/Layout/RawPropertyLayout.cs b/src/log4net/Layout/RawPropertyLayout.cs
index f50dda2..6c4303e 100644
--- a/src/log4net/Layout/RawPropertyLayout.cs
+++ b/src/log4net/Layout/RawPropertyLayout.cs
@@ -25,66 +25,66 @@
namespace log4net.Layout
{
- /// <summary>
- /// Extract the value of a property from the <see cref="LoggingEvent"/>
- /// </summary>
- /// <remarks>
- /// <para>
- /// Extract the value of a property from the <see cref="LoggingEvent"/>
- /// </para>
- /// </remarks>
- /// <author>Nicko Cadell</author>
- public class RawPropertyLayout : IRawLayout
- {
- #region Constructors
+ /// <summary>
+ /// Extract the value of a property from the <see cref="LoggingEvent"/>
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Extract the value of a property from the <see cref="LoggingEvent"/>
+ /// </para>
+ /// </remarks>
+ /// <author>Nicko Cadell</author>
+ public class RawPropertyLayout : IRawLayout
+ {
+ #region Constructors
- /// <summary>
- /// Constructs a RawPropertyLayout
- /// </summary>
- public RawPropertyLayout()
- {
- }
+ /// <summary>
+ /// Constructs a RawPropertyLayout
+ /// </summary>
+ public RawPropertyLayout()
+ {
+ }
- #endregion
+ #endregion
- private string m_key;
+ private string m_key;
- /// <summary>
- /// The name of the value to lookup in the LoggingEvent Properties collection.
- /// </summary>
- /// <value>
- /// Value to lookup in the LoggingEvent Properties collection
- /// </value>
- /// <remarks>
- /// <para>
- /// String name of the property to lookup in the <see cref="LoggingEvent"/>.
- /// </para>
- /// </remarks>
- public string Key
- {
- get { return m_key; }
- set { m_key = value; }
- }
+ /// <summary>
+ /// The name of the value to lookup in the LoggingEvent Properties collection.
+ /// </summary>
+ /// <value>
+ /// Value to lookup in the LoggingEvent Properties collection
+ /// </value>
+ /// <remarks>
+ /// <para>
+ /// String name of the property to lookup in the <see cref="LoggingEvent"/>.
+ /// </para>
+ /// </remarks>
+ public string Key
+ {
+ get { return m_key; }
+ set { m_key = value; }
+ }
- #region Implementation of IRawLayout
+ #region Implementation of IRawLayout
- /// <summary>
- /// Lookup the property for <see cref="Key"/>
- /// </summary>
- /// <param name="loggingEvent">The event to format</param>
- /// <returns>returns property value</returns>
- /// <remarks>
- /// <para>
- /// Looks up and returns the object value of the property
- /// named <see cref="Key"/>. If there is no property defined
- /// with than name then <c>null</c> will be returned.
- /// </para>
- /// </remarks>
- public virtual object Format(LoggingEvent loggingEvent)
- {
- return loggingEvent.LookupProperty(m_key);
- }
+ /// <summary>
+ /// Lookup the property for <see cref="Key"/>
+ /// </summary>
+ /// <param name="loggingEvent">The event to format</param>
+ /// <returns>returns property value</returns>
+ /// <remarks>
+ /// <para>
+ /// Looks up and returns the object value of the property
+ /// named <see cref="Key"/>. If there is no property defined
+ /// with than name then <c>null</c> will be returned.
+ /// </para>
+ /// </remarks>
+ public virtual object Format(LoggingEvent loggingEvent)
+ {
+ return loggingEvent.LookupProperty(m_key);
+ }
- #endregion
- }
+ #endregion
+ }
}
diff --git a/src/log4net/Layout/RawTimeStampLayout.cs b/src/log4net/Layout/RawTimeStampLayout.cs
index 66a4dec..81c37b4 100644
--- a/src/log4net/Layout/RawTimeStampLayout.cs
+++ b/src/log4net/Layout/RawTimeStampLayout.cs
@@ -25,50 +25,50 @@
namespace log4net.Layout
{
- /// <summary>
- /// Extract the date from the <see cref="LoggingEvent"/>
- /// </summary>
- /// <remarks>
- /// <para>
- /// Extract the date from the <see cref="LoggingEvent"/>
- /// </para>
- /// </remarks>
- /// <author>Nicko Cadell</author>
- /// <author>Gert Driesen</author>
- public class RawTimeStampLayout : IRawLayout
- {
- #region Constructors
+ /// <summary>
+ /// Extract the date from the <see cref="LoggingEvent"/>
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Extract the date from the <see cref="LoggingEvent"/>
+ /// </para>
+ /// </remarks>
+ /// <author>Nicko Cadell</author>
+ /// <author>Gert Driesen</author>
+ public class RawTimeStampLayout : IRawLayout
+ {
+ #region Constructors
- /// <summary>
- /// Constructs a RawTimeStampLayout
- /// </summary>
- public RawTimeStampLayout()
- {
- }
+ /// <summary>
+ /// Constructs a RawTimeStampLayout
+ /// </summary>
+ public RawTimeStampLayout()
+ {
+ }
- #endregion
+ #endregion
- #region Implementation of IRawLayout
+ #region Implementation of IRawLayout
- /// <summary>
- /// Gets the <see cref="LoggingEvent.TimeStamp"/> as a <see cref="DateTime"/>.
- /// </summary>
- /// <param name="loggingEvent">The event to format</param>
- /// <returns>returns the time stamp</returns>
- /// <remarks>
- /// <para>
- /// Gets the <see cref="LoggingEvent.TimeStamp"/> as a <see cref="DateTime"/>.
- /// </para>
- /// <para>
- /// The time stamp is in local time. To format the time stamp
- /// in universal time use <see cref="RawUtcTimeStampLayout"/>.
- /// </para>
- /// </remarks>
- public virtual object Format(LoggingEvent loggingEvent)
- {
- return loggingEvent.TimeStamp;
- }
+ /// <summary>
+ /// Gets the <see cref="LoggingEvent.TimeStamp"/> as a <see cref="DateTime"/>.
+ /// </summary>
+ /// <param name="loggingEvent">The event to format</param>
+ /// <returns>returns the time stamp</returns>
+ /// <remarks>
+ /// <para>
+ /// Gets the <see cref="LoggingEvent.TimeStamp"/> as a <see cref="DateTime"/>.
+ /// </para>
+ /// <para>
+ /// The time stamp is in local time. To format the time stamp
+ /// in universal time use <see cref="RawUtcTimeStampLayout"/>.
+ /// </para>
+ /// </remarks>
+ public virtual object Format(LoggingEvent loggingEvent)
+ {
+ return loggingEvent.TimeStamp;
+ }
- #endregion
- }
+ #endregion
+ }
}
diff --git a/src/log4net/Layout/RawUtcTimeStampLayout.cs b/src/log4net/Layout/RawUtcTimeStampLayout.cs
index 2c232ae..55bec72 100644
--- a/src/log4net/Layout/RawUtcTimeStampLayout.cs
+++ b/src/log4net/Layout/RawUtcTimeStampLayout.cs
@@ -25,50 +25,50 @@
namespace log4net.Layout
{
- /// <summary>
- /// Extract the date from the <see cref="LoggingEvent"/>
- /// </summary>
- /// <remarks>
- /// <para>
- /// Extract the date from the <see cref="LoggingEvent"/>
- /// </para>
- /// </remarks>
- /// <author>Nicko Cadell</author>
- /// <author>Gert Driesen</author>
- public class RawUtcTimeStampLayout : IRawLayout
- {
- #region Constructors
+ /// <summary>
+ /// Extract the date from the <see cref="LoggingEvent"/>
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Extract the date from the <see cref="LoggingEvent"/>
+ /// </para>
+ /// </remarks>
+ /// <author>Nicko Cadell</author>
+ /// <author>Gert Driesen</author>
+ public class RawUtcTimeStampLayout : IRawLayout
+ {
+ #region Constructors
- /// <summary>
- /// Constructs a RawUtcTimeStampLayout
- /// </summary>
- public RawUtcTimeStampLayout()
- {
- }
+ /// <summary>
+ /// Constructs a RawUtcTimeStampLayout
+ /// </summary>
+ public RawUtcTimeStampLayout()
+ {
+ }
- #endregion
+ #endregion
- #region Implementation of IRawLayout
+ #region Implementation of IRawLayout
- /// <summary>
- /// Gets the <see cref="LoggingEvent.TimeStamp"/> as a <see cref="DateTime"/>.
- /// </summary>
- /// <param name="loggingEvent">The event to format</param>
- /// <returns>returns the time stamp</returns>
- /// <remarks>
- /// <para>
- /// Gets the <see cref="LoggingEvent.TimeStamp"/> as a <see cref="DateTime"/>.
- /// </para>
- /// <para>
- /// The time stamp is in universal time. To format the time stamp
- /// in local time use <see cref="RawTimeStampLayout"/>.
- /// </para>
- /// </remarks>
- public virtual object Format(LoggingEvent loggingEvent)
- {
- return loggingEvent.TimeStampUtc;
- }
+ /// <summary>
+ /// Gets the <see cref="LoggingEvent.TimeStamp"/> as a <see cref="DateTime"/>.
+ /// </summary>
+ /// <param name="loggingEvent">The event to format</param>
+ /// <returns>returns the time stamp</returns>
+ /// <remarks>
+ /// <para>
+ /// Gets the <see cref="LoggingEvent.TimeStamp"/> as a <see cref="DateTime"/>.
+ /// </para>
+ /// <para>
+ /// The time stamp is in universal time. To format the time stamp
+ /// in local time use <see cref="RawTimeStampLayout"/>.
+ /// </para>
+ /// </remarks>
+ public virtual object Format(LoggingEvent loggingEvent)
+ {
+ return loggingEvent.TimeStampUtc;
+ }
- #endregion
- }
+ #endregion
+ }
}
diff --git a/src/log4net/Layout/SimpleLayout.cs b/src/log4net/Layout/SimpleLayout.cs
index 5efe0d0..8d4640a 100644
--- a/src/log4net/Layout/SimpleLayout.cs
+++ b/src/log4net/Layout/SimpleLayout.cs
@@ -26,86 +26,86 @@
namespace log4net.Layout
{
- /// <summary>
- /// A very simple layout
- /// </summary>
- /// <remarks>
- /// <para>
- /// SimpleLayout consists of the level of the log statement,
- /// followed by " - " and then the log message itself. For example,
- /// <code>
- /// DEBUG - Hello world
- /// </code>
- /// </para>
- /// </remarks>
- /// <author>Nicko Cadell</author>
- /// <author>Gert Driesen</author>
- public class SimpleLayout : LayoutSkeleton
- {
- #region Constructors
+ /// <summary>
+ /// A very simple layout
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// SimpleLayout consists of the level of the log statement,
+ /// followed by " - " and then the log message itself. For example,
+ /// <code>
+ /// DEBUG - Hello world
+ /// </code>
+ /// </para>
+ /// </remarks>
+ /// <author>Nicko Cadell</author>
+ /// <author>Gert Driesen</author>
+ public class SimpleLayout : LayoutSkeleton
+ {
+ #region Constructors
- /// <summary>
- /// Constructs a SimpleLayout
- /// </summary>
- public SimpleLayout()
- {
- IgnoresException = true;
- }
+ /// <summary>
+ /// Constructs a SimpleLayout
+ /// </summary>
+ public SimpleLayout()
+ {
+ IgnoresException = true;
+ }
- #endregion
+ #endregion
- #region Implementation of IOptionHandler
+ #region Implementation of IOptionHandler
- /// <summary>
- /// Initialize layout options
- /// </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>
- public override void ActivateOptions()
- {
- // nothing to do.
- }
+ /// <summary>
+ /// Initialize layout options
+ /// </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>
+ public override void ActivateOptions()
+ {
+ // nothing to do.
+ }
- #endregion
+ #endregion
- #region Override implementation of LayoutSkeleton
+ #region Override implementation of LayoutSkeleton
- /// <summary>
- /// Produces a simple formatted output.
- /// </summary>
- /// <param name="loggingEvent">the event being logged</param>
- /// <param name="writer">The TextWriter to write the formatted event to</param>
- /// <remarks>
- /// <para>
- /// Formats the event as the level of the even,
- /// followed by " - " and then the log message itself. The
- /// output is terminated by a newline.
- /// </para>
- /// </remarks>
- public override void Format(TextWriter writer, LoggingEvent loggingEvent)
- {
- if (loggingEvent == null)
- {
- throw new ArgumentNullException("loggingEvent");
- }
+ /// <summary>
+ /// Produces a simple formatted output.
+ /// </summary>
+ /// <param name="loggingEvent">the event being logged</param>
+ /// <param name="writer">The TextWriter to write the formatted event to</param>
+ /// <remarks>
+ /// <para>
+ /// Formats the event as the level of the even,
+ /// followed by " - " and then the log message itself. The
+ /// output is terminated by a newline.
+ /// </para>
+ /// </remarks>
+ public override void Format(TextWriter writer, LoggingEvent loggingEvent)
+ {
+ if (loggingEvent == null)
+ {
+ throw new ArgumentNullException("loggingEvent");
+ }
- writer.Write(loggingEvent.Level.DisplayName);
- writer.Write(" - ");
- loggingEvent.WriteRenderedMessage(writer);
- writer.WriteLine();
- }
+ writer.Write(loggingEvent.Level.DisplayName);
+ writer.Write(" - ");
+ loggingEvent.WriteRenderedMessage(writer);
+ writer.WriteLine();
+ }
- #endregion
- }
+ #endregion
+ }
}
diff --git a/src/log4net/Layout/XmlLayout.cs b/src/log4net/Layout/XmlLayout.cs
index 7c5c0c2..15c925e 100644
--- a/src/log4net/Layout/XmlLayout.cs
+++ b/src/log4net/Layout/XmlLayout.cs
@@ -26,362 +26,362 @@
namespace log4net.Layout
{
- /// <summary>
- /// Layout that formats the log events as XML elements.
- /// </summary>
- /// <remarks>
- /// <para>
- /// The output of the <see cref="XmlLayout" /> consists of a series of
- /// log4net:event elements. It does not output a complete well-formed XML
- /// file. The output is designed to be included as an <em>external entity</em>
- /// in a separate file to form a correct XML file.
- /// </para>
- /// <para>
- /// For example, if <c>abc</c> is the name of the file where
- /// the <see cref="XmlLayout" /> output goes, then a well-formed XML file would
- /// be:
- /// </para>
- /// <code lang="XML">
- /// <?xml version="1.0" ?>
- ///
- /// <!DOCTYPE log4net:events SYSTEM "log4net-events.dtd" [<!ENTITY data SYSTEM "abc">]>
- ///
- /// <log4net:events version="1.2" xmlns:log4net="http://logging.apache.org/log4net/schemas/log4net-events-1.2>
- /// &data;
- /// </log4net:events>
- /// </code>
- /// <para>
- /// This approach enforces the independence of the <see cref="XmlLayout" />
- /// and the appender where it is embedded.
- /// </para>
- /// <para>
- /// The <c>version</c> attribute helps components to correctly
- /// interpret output generated by <see cref="XmlLayout" />. The value of
- /// this attribute should be "1.2" for release 1.2 and later.
- /// </para>
- /// <para>
- /// Alternatively the <c>Header</c> and <c>Footer</c> properties can be
- /// configured to output the correct XML header, open tag and close tag.
- /// When setting the <c>Header</c> and <c>Footer</c> properties it is essential
- /// that the underlying data store not be appendable otherwise the data
- /// will become invalid XML.
- /// </para>
- /// </remarks>
- /// <author>Nicko Cadell</author>
- /// <author>Gert Driesen</author>
- public class XmlLayout : XmlLayoutBase
- {
- #region Public Instance Constructors
+ /// <summary>
+ /// Layout that formats the log events as XML elements.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// The output of the <see cref="XmlLayout" /> consists of a series of
+ /// log4net:event elements. It does not output a complete well-formed XML
+ /// file. The output is designed to be included as an <em>external entity</em>
+ /// in a separate file to form a correct XML file.
+ /// </para>
+ /// <para>
+ /// For example, if <c>abc</c> is the name of the file where
+ /// the <see cref="XmlLayout" /> output goes, then a well-formed XML file would
+ /// be:
+ /// </para>
+ /// <code lang="XML">
+ /// <?xml version="1.0" ?>
+ ///
+ /// <!DOCTYPE log4net:events SYSTEM "log4net-events.dtd" [<!ENTITY data SYSTEM "abc">]>
+ ///
+ /// <log4net:events version="1.2" xmlns:log4net="http://logging.apache.org/log4net/schemas/log4net-events-1.2>
+ /// &data;
+ /// </log4net:events>
+ /// </code>
+ /// <para>
+ /// This approach enforces the independence of the <see cref="XmlLayout" />
+ /// and the appender where it is embedded.
+ /// </para>
+ /// <para>
+ /// The <c>version</c> attribute helps components to correctly
+ /// interpret output generated by <see cref="XmlLayout" />. The value of
+ /// this attribute should be "1.2" for release 1.2 and later.
+ /// </para>
+ /// <para>
+ /// Alternatively the <c>Header</c> and <c>Footer</c> properties can be
+ /// configured to output the correct XML header, open tag and close tag.
+ /// When setting the <c>Header</c> and <c>Footer</c> properties it is essential
+ /// that the underlying data store not be appendable otherwise the data
+ /// will become invalid XML.
+ /// </para>
+ /// </remarks>
+ /// <author>Nicko Cadell</author>
+ /// <author>Gert Driesen</author>
+ public class XmlLayout : XmlLayoutBase
+ {
+ #region Public Instance Constructors
- /// <summary>
- /// Constructs an XmlLayout
- /// </summary>
- public XmlLayout() : base()
- {
- }
+ /// <summary>
+ /// Constructs an XmlLayout
+ /// </summary>
+ public XmlLayout() : base()
+ {
+ }
- /// <summary>
- /// Constructs an XmlLayout.
- /// </summary>
- /// <remarks>
- /// <para>
- /// The <b>LocationInfo</b> option takes a boolean value. By
- /// default, it is set to false which means there will be no location
- /// information output by this layout. If the the option is set to
- /// true, then the file name and line number of the statement
- /// at the origin of the log statement will be output.
- /// </para>
- /// <para>
- /// If you are embedding this layout within an SmtpAppender
- /// then make sure to set the <b>LocationInfo</b> option of that
- /// appender as well.
- /// </para>
- /// </remarks>
- public XmlLayout(bool locationInfo) : base(locationInfo)
- {
- }
+ /// <summary>
+ /// Constructs an XmlLayout.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// The <b>LocationInfo</b> option takes a boolean value. By
+ /// default, it is set to false which means there will be no location
+ /// information output by this layout. If the the option is set to
+ /// true, then the file name and line number of the statement
+ /// at the origin of the log statement will be output.
+ /// </para>
+ /// <para>
+ /// If you are embedding this layout within an SmtpAppender
+ /// then make sure to set the <b>LocationInfo</b> option of that
+ /// appender as well.
+ /// </para>
+ /// </remarks>
+ public XmlLayout(bool locationInfo) : base(locationInfo)
+ {
+ }
- #endregion Public Instance Constructors
+ #endregion Public Instance Constructors
- #region Public Instance Properties
+ #region Public Instance Properties
- /// <summary>
- /// The prefix to use for all element names
- /// </summary>
- /// <remarks>
- /// <para>
- /// The default prefix is <b>log4net</b>. Set this property
- /// to change the prefix. If the prefix is set to an empty string
- /// then no prefix will be written.
- /// </para>
- /// </remarks>
- public string Prefix
- {
- get { return m_prefix; }
- set { m_prefix = value; }
- }
+ /// <summary>
+ /// The prefix to use for all element names
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// The default prefix is <b>log4net</b>. Set this property
+ /// to change the prefix. If the prefix is set to an empty string
+ /// then no prefix will be written.
+ /// </para>
+ /// </remarks>
+ public string Prefix
+ {
+ get { return m_prefix; }
+ set { m_prefix = value; }
+ }
-
- /// <summary>
- /// Set whether or not to base64 encode the message.
- /// </summary>
- /// <remarks>
- /// <para>
- /// By default the log message will be written as text to the xml
- /// output. This can cause problems when the message contains binary
- /// data. By setting this to true the contents of the message will be
- /// base64 encoded. If this is set then invalid character replacement
- /// (see <see cref="XmlLayoutBase.InvalidCharReplacement"/>) will not be performed
- /// on the log message.
- /// </para>
- /// </remarks>
- public bool Base64EncodeMessage
- {
- get {return m_base64Message;}
- set {m_base64Message=value;}
- }
+
+ /// <summary>
+ /// Set whether or not to base64 encode the message.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// By default the log message will be written as text to the xml
+ /// output. This can cause problems when the message contains binary
+ /// data. By setting this to true the contents of the message will be
+ /// base64 encoded. If this is set then invalid character replacement
+ /// (see <see cref="XmlLayoutBase.InvalidCharReplacement"/>) will not be performed
+ /// on the log message.
+ /// </para>
+ /// </remarks>
+ public bool Base64EncodeMessage
+ {
+ get {return m_base64Message;}
+ set {m_base64Message=value;}
+ }
- /// <summary>
- /// Set whether or not to base64 encode the property values.
- /// </summary>
- /// <remarks>
- /// <para>
- /// By default the properties will be written as text to the xml
- /// output. This can cause problems when one or more properties contain
- /// binary data. By setting this to true the values of the properties
- /// will be base64 encoded. If this is set then invalid character replacement
- /// (see <see cref="XmlLayoutBase.InvalidCharReplacement"/>) will not be performed
- /// on the property values.
- /// </para>
- /// </remarks>
- public bool Base64EncodeProperties
- {
- get {return m_base64Properties;}
- set {m_base64Properties=value;}
- }
+ /// <summary>
+ /// Set whether or not to base64 encode the property values.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// By default the properties will be written as text to the xml
+ /// output. This can cause problems when one or more properties contain
+ /// binary data. By setting this to true the values of the properties
+ /// will be base64 encoded. If this is set then invalid character replacement
+ /// (see <see cref="XmlLayoutBase.InvalidCharReplacement"/>) will not be performed
+ /// on the property values.
+ /// </para>
+ /// </remarks>
+ public bool Base64EncodeProperties
+ {
+ get {return m_base64Properties;}
+ set {m_base64Properties=value;}
+ }
- #endregion Public Instance Properties
+ #endregion Public Instance Properties
- #region Implementation of IOptionHandler
+ #region Implementation of IOptionHandler
- /// <summary>
- /// Initialize layout options
- /// </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>
- /// <para>
- /// Builds a cache of the element names
- /// </para>
- /// </remarks>
- public override void ActivateOptions()
- {
- base.ActivateOptions();
+ /// <summary>
+ /// Initialize layout options
+ /// </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>
+ /// <para>
+ /// Builds a cache of the element names
+ /// </para>
+ /// </remarks>
+ public override void ActivateOptions()
+ {
+ base.ActivateOptions();
- // Cache the full element names including the prefix
- if (m_prefix != null && m_prefix.Length > 0)
- {
- m_elmEvent = m_prefix + ":" + ELM_EVENT;
- m_elmMessage = m_prefix + ":" + ELM_MESSAGE;
- m_elmProperties = m_prefix + ":" + ELM_PROPERTIES;
- m_elmData = m_prefix + ":" + ELM_DATA;
- m_elmException = m_prefix + ":" + ELM_EXCEPTION;
- m_elmLocation = m_prefix + ":" + ELM_LOCATION;
- }
- }
-
- #endregion Implementation of IOptionHandler
+ // Cache the full element names including the prefix
+ if (m_prefix != null && m_prefix.Length > 0)
+ {
+ m_elmEvent = m_prefix + ":" + ELM_EVENT;
+ m_elmMessage = m_prefix + ":" + ELM_MESSAGE;
+ m_elmProperties = m_prefix + ":" + ELM_PROPERTIES;
+ m_elmData = m_prefix + ":" + ELM_DATA;
+ m_elmException = m_prefix + ":" + ELM_EXCEPTION;
+ m_elmLocation = m_prefix + ":" + ELM_LOCATION;
+ }
+ }
+
+ #endregion Implementation of IOptionHandler
- #region Override implementation of XMLLayoutBase
+ #region Override implementation of XMLLayoutBase
- /// <summary>
- /// Does the actual writing of the XML.
- /// </summary>
- /// <param name="writer">The writer to use to output the event to.</param>
- /// <param name="loggingEvent">The event to write.</param>
- /// <remarks>
- /// <para>
- /// Override the base class <see cref="XmlLayoutBase.FormatXml"/> method
- /// to write the <see cref="LoggingEvent"/> to the <see cref="XmlWriter"/>.
- /// </para>
- /// </remarks>
- protected override void FormatXml(XmlWriter writer, LoggingEvent loggingEvent)
- {
- #if NETSTANDARD
- writer.WriteStartElement(m_prefix, ELM_EVENT, m_prefix);
- // writer.WriteAttributeString("xmlns", "log4net", null, "http://logging.apache.org/log4net/schemas/log4net-events-1.2");
- #else
- writer.WriteStartElement(m_elmEvent);
- #endif
- writer.WriteAttributeString(ATTR_LOGGER, loggingEvent.LoggerName);
+ /// <summary>
+ /// Does the actual writing of the XML.
+ /// </summary>
+ /// <param name="writer">The writer to use to output the event to.</param>
+ /// <param name="loggingEvent">The event to write.</param>
+ /// <remarks>
+ /// <para>
+ /// Override the base class <see cref="XmlLayoutBase.FormatXml"/> method
+ /// to write the <see cref="LoggingEvent"/> to the <see cref="XmlWriter"/>.
+ /// </para>
+ /// </remarks>
+ protected override void FormatXml(XmlWriter writer, LoggingEvent loggingEvent)
+ {
+ #if NETSTANDARD
+ writer.WriteStartElement(m_prefix, ELM_EVENT, m_prefix);
+ // writer.WriteAttributeString("xmlns", "log4net", null, "http://logging.apache.org/log4net/schemas/log4net-events-1.2");
+ #else
+ writer.WriteStartElement(m_elmEvent);
+ #endif
+ writer.WriteAttributeString(ATTR_LOGGER, loggingEvent.LoggerName);
#if NET_2_0 || NETCF_2_0 || MONO_2_0 || NETSTANDARD
- writer.WriteAttributeString(ATTR_TIMESTAMP, XmlConvert.ToString(loggingEvent.TimeStamp, XmlDateTimeSerializationMode.Local));
+ writer.WriteAttributeString(ATTR_TIMESTAMP, XmlConvert.ToString(loggingEvent.TimeStamp, XmlDateTimeSerializationMode.Local));
#else
- writer.WriteAttributeString(ATTR_TIMESTAMP, XmlConvert.ToString(loggingEvent.TimeStamp));
+ writer.WriteAttributeString(ATTR_TIMESTAMP, XmlConvert.ToString(loggingEvent.TimeStamp));
#endif
- writer.WriteAttributeString(ATTR_LEVEL, loggingEvent.Level.DisplayName);
- writer.WriteAttributeString(ATTR_THREAD, loggingEvent.ThreadName);
+ writer.WriteAttributeString(ATTR_LEVEL, loggingEvent.Level.DisplayName);
+ writer.WriteAttributeString(ATTR_THREAD, loggingEvent.ThreadName);
- if (loggingEvent.Domain != null && loggingEvent.Domain.Length > 0)
- {
- writer.WriteAttributeString(ATTR_DOMAIN, loggingEvent.Domain);
- }
- if (loggingEvent.Identity != null && loggingEvent.Identity.Length > 0)
- {
- writer.WriteAttributeString(ATTR_IDENTITY, loggingEvent.Identity);
- }
- if (loggingEvent.UserName != null && loggingEvent.UserName.Length > 0)
- {
- writer.WriteAttributeString(ATTR_USERNAME, loggingEvent.UserName);
- }
+ if (loggingEvent.Domain != null && loggingEvent.Domain.Length > 0)
+ {
+ writer.WriteAttributeString(ATTR_DOMAIN, loggingEvent.Domain);
+ }
+ if (loggingEvent.Identity != null && loggingEvent.Identity.Length > 0)
+ {
+ writer.WriteAttributeString(ATTR_IDENTITY, loggingEvent.Identity);
+ }
+ if (loggingEvent.UserName != null && loggingEvent.UserName.Length > 0)
+ {
+ writer.WriteAttributeString(ATTR_USERNAME, loggingEvent.UserName);
+ }
- // Append the message text
- #if NETSTANDARD
- writer.WriteStartElement(m_prefix, ELM_MESSAGE, m_prefix);
- #else
- writer.WriteStartElement(m_elmMessage);
- #endif
- if (!this.Base64EncodeMessage)
- {
- Transform.WriteEscapedXmlString(writer, loggingEvent.RenderedMessage, this.InvalidCharReplacement);
- }
- else
- {
- byte[] messageBytes = Encoding.UTF8.GetBytes(loggingEvent.RenderedMessage);
- string base64Message = Convert.ToBase64String(messageBytes, 0, messageBytes.Length);
- Transform.WriteEscapedXmlString(writer, base64Message,this.InvalidCharReplacement);
- }
- writer.WriteEndElement();
+ // Append the message text
+ #if NETSTANDARD
+ writer.WriteStartElement(m_prefix, ELM_MESSAGE, m_prefix);
+ #else
+ writer.WriteStartElement(m_elmMessage);
+ #endif
+ if (!this.Base64EncodeMessage)
+ {
+ Transform.WriteEscapedXmlString(writer, loggingEvent.RenderedMessage, this.InvalidCharReplacement);
+ }
+ else
+ {
+ byte[] messageBytes = Encoding.UTF8.GetBytes(loggingEvent.RenderedMessage);
+ string base64Message = Convert.ToBase64String(messageBytes, 0, messageBytes.Length);
+ Transform.WriteEscapedXmlString(writer, base64Message,this.InvalidCharReplacement);
+ }
+ writer.WriteEndElement();
- PropertiesDictionary properties = loggingEvent.GetProperties();
+ PropertiesDictionary properties = loggingEvent.GetProperties();
- // Append the properties text
- if (properties.Count > 0)
- {
- #if NETSTANDARD
- writer.WriteStartElement(m_prefix, ELM_PROPERTIES, m_prefix);
- #else
- writer.WriteStartElement(m_elmProperties);
- #endif
- foreach(System.Collections.DictionaryEntry entry in properties)
- {
- #if NETSTANDARD
- writer.WriteStartElement(m_prefix, ELM_DATA, m_prefix);
- #else
- writer.WriteStartElement(m_elmData);
- #endif
- writer.WriteAttributeString(ATTR_NAME, Transform.MaskXmlInvalidCharacters((string)entry.Key,this.InvalidCharReplacement));
+ // Append the properties text
+ if (properties.Count > 0)
+ {
+ #if NETSTANDARD
+ writer.WriteStartElement(m_prefix, ELM_PROPERTIES, m_prefix);
+ #else
+ writer.WriteStartElement(m_elmProperties);
+ #endif
+ foreach(System.Collections.DictionaryEntry entry in properties)
+ {
+ #if NETSTANDARD
+ writer.WriteStartElement(m_prefix, ELM_DATA, m_prefix);
+ #else
+ writer.WriteStartElement(m_elmData);
+ #endif
+ writer.WriteAttributeString(ATTR_NAME, Transform.MaskXmlInvalidCharacters((string)entry.Key,this.InvalidCharReplacement));
- // Use an ObjectRenderer to convert the object to a string
- string valueStr =null;
- if (!this.Base64EncodeProperties)
- {
- valueStr = Transform.MaskXmlInvalidCharacters(loggingEvent.Repository.RendererMap.FindAndRender(entry.Value),this.InvalidCharReplacement);
- }
- else
- {
- byte[] propertyValueBytes = Encoding.UTF8.GetBytes(loggingEvent.Repository.RendererMap.FindAndRender(entry.Value));
- valueStr = Convert.ToBase64String(propertyValueBytes, 0, propertyValueBytes.Length);
- }
- writer.WriteAttributeString(ATTR_VALUE, valueStr);
+ // Use an ObjectRenderer to convert the object to a string
+ string valueStr =null;
+ if (!this.Base64EncodeProperties)
+ {
+ valueStr = Transform.MaskXmlInvalidCharacters(loggingEvent.Repository.RendererMap.FindAndRender(entry.Value),this.InvalidCharReplacement);
+ }
+ else
+ {
+ byte[] propertyValueBytes = Encoding.UTF8.GetBytes(loggingEvent.Repository.RendererMap.FindAndRender(entry.Value));
+ valueStr = Convert.ToBase64String(propertyValueBytes, 0, propertyValueBytes.Length);
+ }
+ writer.WriteAttributeString(ATTR_VALUE, valueStr);
- writer.WriteEndElement();
- }
- writer.WriteEndElement();
- }
+ writer.WriteEndElement();
+ }
+ writer.WriteEndElement();
+ }
- string exceptionStr = loggingEvent.GetExceptionString();
- if (exceptionStr != null && exceptionStr.Length > 0)
- {
- // Append the stack trace line
- #if NETSTANDARD
- writer.WriteStartElement(m_prefix, ELM_EXCEPTION, m_prefix);
- #else
- writer.WriteStartElement(m_elmException);
- #endif
- Transform.WriteEscapedXmlString(writer, exceptionStr,this.InvalidCharReplacement);
- writer.WriteEndElement();
- }
+ string exceptionStr = loggingEvent.GetExceptionString();
+ if (exceptionStr != null && exceptionStr.Length > 0)
+ {
+ // Append the stack trace line
+ #if NETSTANDARD
+ writer.WriteStartElement(m_prefix, ELM_EXCEPTION, m_prefix);
+ #else
+ writer.WriteStartElement(m_elmException);
+ #endif
+ Transform.WriteEscapedXmlString(writer, exceptionStr,this.InvalidCharReplacement);
+ writer.WriteEndElement();
+ }
- if (LocationInfo)
- {
- LocationInfo locationInfo = loggingEvent.LocationInformation;
+ if (LocationInfo)
+ {
+ LocationInfo locationInfo = loggingEvent.LocationInformation;
- #if NETSTANDARD
- writer.WriteStartElement(m_prefix, ELM_LOCATION, m_prefix);
- #else
- writer.WriteStartElement(m_elmLocation);
- #endif
- writer.WriteAttributeString(ATTR_CLASS, locationInfo.ClassName);
- writer.WriteAttributeString(ATTR_METHOD, locationInfo.MethodName);
- writer.WriteAttributeString(ATTR_FILE, locationInfo.FileName);
- writer.WriteAttributeString(ATTR_LINE, locationInfo.LineNumber);
- writer.WriteEndElement();
- }
+ #if NETSTANDARD
+ writer.WriteStartElement(m_prefix, ELM_LOCATION, m_prefix);
+ #else
+ writer.WriteStartElement(m_elmLocation);
+ #endif
+ writer.WriteAttributeString(ATTR_CLASS, locationInfo.ClassName);
+ writer.WriteAttributeString(ATTR_METHOD, locationInfo.MethodName);
+ writer.WriteAttributeString(ATTR_FILE, locationInfo.FileName);
+ writer.WriteAttributeString(ATTR_LINE, locationInfo.LineNumber);
+ writer.WriteEndElement();
+ }
- writer.WriteEndElement();
- }
+ writer.WriteEndElement();
+ }
- #endregion Override implementation of XMLLayoutBase
+ #endregion Override implementation of XMLLayoutBase
- #region Private Instance Fields
+ #region Private Instance Fields
- /// <summary>
- /// The prefix to use for all generated element names
- /// </summary>
- private string m_prefix = PREFIX;
+ /// <summary>
+ /// The prefix to use for all generated element names
+ /// </summary>
+ private string m_prefix = PREFIX;
- private string m_elmEvent = ELM_EVENT;
- private string m_elmMessage = ELM_MESSAGE;
- private string m_elmData = ELM_DATA;
- private string m_elmProperties = ELM_PROPERTIES;
- private string m_elmException = ELM_EXCEPTION;
- private string m_elmLocation = ELM_LOCATION;
+ private string m_elmEvent = ELM_EVENT;
+ private string m_elmMessage = ELM_MESSAGE;
+ private string m_elmData = ELM_DATA;
+ private string m_elmProperties = ELM_PROPERTIES;
+ private string m_elmException = ELM_EXCEPTION;
+ private string m_elmLocation = ELM_LOCATION;
- private bool m_base64Message=false;
- private bool m_base64Properties=false;
+ private bool m_base64Message=false;
+ private bool m_base64Properties=false;
- #endregion Private Instance Fields
+ #endregion Private Instance Fields
- #region Private Static Fields
+ #region Private Static Fields
- private const string PREFIX = "log4net";
+ private const string PREFIX = "log4net";
- private const string ELM_EVENT = "event";
- private const string ELM_MESSAGE = "message";
- private const string ELM_PROPERTIES = "properties";
- private const string ELM_GLOBAL_PROPERTIES = "global-properties";
- private const string ELM_DATA = "data";
- private const string ELM_EXCEPTION = "exception";
- private const string ELM_LOCATION = "locationInfo";
+ private const string ELM_EVENT = "event";
+ private const string ELM_MESSAGE = "message";
+ private const string ELM_PROPERTIES = "properties";
+ private const string ELM_GLOBAL_PROPERTIES = "global-properties";
+ private const string ELM_DATA = "data";
+ private const string ELM_EXCEPTION = "exception";
+ private const string ELM_LOCATION = "locationInfo";
- private const string ATTR_LOGGER = "logger";
- private const string ATTR_TIMESTAMP = "timestamp";
- private const string ATTR_LEVEL = "level";
- private const string ATTR_THREAD = "thread";
- private const string ATTR_DOMAIN = "domain";
- private const string ATTR_IDENTITY = "identity";
- private const string ATTR_USERNAME = "username";
- private const string ATTR_CLASS = "class";
- private const string ATTR_METHOD = "method";
- private const string ATTR_FILE = "file";
- private const string ATTR_LINE = "line";
- private const string ATTR_NAME = "name";
- private const string ATTR_VALUE = "value";
+ private const string ATTR_LOGGER = "logger";
+ private const string ATTR_TIMESTAMP = "timestamp";
+ private const string ATTR_LEVEL = "level";
+ private const string ATTR_THREAD = "thread";
+ private const string ATTR_DOMAIN = "domain";
+ private const string ATTR_IDENTITY = "identity";
+ private const string ATTR_USERNAME = "username";
+ private const string ATTR_CLASS = "class";
+ private const string ATTR_METHOD = "method";
+ private const string ATTR_FILE = "file";
+ private const string ATTR_LINE = "line";
+ private const string ATTR_NAME = "name";
+ private const string ATTR_VALUE = "value";
- #endregion Private Static Fields
- }
+ #endregion Private Static Fields
+ }
}
diff --git a/src/log4net/Layout/XmlLayoutBase.cs b/src/log4net/Layout/XmlLayoutBase.cs
index 2f35f8b..3bee490 100644
--- a/src/log4net/Layout/XmlLayoutBase.cs
+++ b/src/log4net/Layout/XmlLayoutBase.cs
@@ -27,229 +27,229 @@
namespace log4net.Layout
{
- /// <summary>
- /// Layout that formats the log events as XML elements.
- /// </summary>
- /// <remarks>
- /// <para>
- /// This is an abstract class that must be subclassed by an implementation
- /// to conform to a specific schema.
- /// </para>
- /// <para>
- /// Deriving classes must implement the <see cref="FormatXml"/> method.
- /// </para>
- /// </remarks>
- /// <author>Nicko Cadell</author>
- /// <author>Gert Driesen</author>
- public abstract class XmlLayoutBase : LayoutSkeleton
- {
- #region Protected Instance Constructors
+ /// <summary>
+ /// Layout that formats the log events as XML elements.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// This is an abstract class that must be subclassed by an implementation
+ /// to conform to a specific schema.
+ /// </para>
+ /// <para>
+ /// Deriving classes must implement the <see cref="FormatXml"/> method.
+ /// </para>
+ /// </remarks>
+ /// <author>Nicko Cadell</author>
+ /// <author>Gert Driesen</author>
+ public abstract class XmlLayoutBase : LayoutSkeleton
+ {
+ #region Protected Instance Constructors
- /// <summary>
- /// Protected constructor to support subclasses
- /// </summary>
- /// <remarks>
- /// <para>
- /// Initializes a new instance of the <see cref="XmlLayoutBase" /> class
- /// with no location info.
- /// </para>
- /// </remarks>
- protected XmlLayoutBase() : this(false)
- {
- IgnoresException = false;
- }
+ /// <summary>
+ /// Protected constructor to support subclasses
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Initializes a new instance of the <see cref="XmlLayoutBase" /> class
+ /// with no location info.
+ /// </para>
+ /// </remarks>
+ protected XmlLayoutBase() : this(false)
+ {
+ IgnoresException = false;
+ }
- /// <summary>
- /// Protected constructor to support subclasses
- /// </summary>
- /// <remarks>
- /// <para>
- /// The <paramref name="locationInfo" /> parameter determines whether
- /// location information will be output by the layout. If
- /// <paramref name="locationInfo" /> is set to <c>true</c>, then the
- /// file name and line number of the statement at the origin of the log
- /// statement will be output.
- /// </para>
- /// <para>
- /// If you are embedding this layout within an SMTPAppender
- /// then make sure to set the <b>LocationInfo</b> option of that
- /// appender as well.
- /// </para>
- /// </remarks>
- protected XmlLayoutBase(bool locationInfo)
- {
- IgnoresException = false;
- m_locationInfo = locationInfo;
- }
+ /// <summary>
+ /// Protected constructor to support subclasses
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// The <paramref name="locationInfo" /> parameter determines whether
+ /// location information will be output by the layout. If
+ /// <paramref name="locationInfo" /> is set to <c>true</c>, then the
+ /// file name and line number of the statement at the origin of the log
+ /// statement will be output.
+ /// </para>
+ /// <para>
+ /// If you are embedding this layout within an SMTPAppender
+ /// then make sure to set the <b>LocationInfo</b> option of that
+ /// appender as well.
+ /// </para>
+ /// </remarks>
+ protected XmlLayoutBase(bool locationInfo)
+ {
+ IgnoresException = false;
+ m_locationInfo = locationInfo;
+ }
- #endregion Protected Instance Constructors
+ #endregion Protected Instance Constructors
- #region Public Instance Properties
+ #region Public Instance Properties
- /// <summary>
- /// Gets a value indicating whether to include location information in
- /// the XML events.
- /// </summary>
- /// <value>
- /// <c>true</c> if location information should be included in the XML
- /// events; otherwise, <c>false</c>.
- /// </value>
- /// <remarks>
- /// <para>
- /// If <see cref="LocationInfo" /> is set to <c>true</c>, then the file
- /// name and line number of the statement at the origin of the log
- /// statement will be output.
- /// </para>
- /// <para>
- /// If you are embedding this layout within an <c>SMTPAppender</c>
- /// then make sure to set the <b>LocationInfo</b> option of that
- /// appender as well.
- /// </para>
- /// </remarks>
- public bool LocationInfo
- {
- get { return m_locationInfo; }
- set { m_locationInfo = value; }
- }
- /// <summary>
- /// The string to replace characters that can not be expressed in XML with.
- /// <remarks>
- /// <para>
- /// Not all characters may be expressed in XML. This property contains the
- /// string to replace those that can not with. This defaults to a ?. Set it
- /// to the empty string to simply remove offending characters. For more
- /// details on the allowed character ranges see http://www.w3.org/TR/REC-xml/#charsets
- /// Character replacement will occur in the log message, the property names
- /// and the property values.
- /// </para>
- /// </remarks>
- /// </summary>
- public string InvalidCharReplacement
- {
- get {return m_invalidCharReplacement;}
- set {m_invalidCharReplacement=value;}
- }
- #endregion
+ /// <summary>
+ /// Gets a value indicating whether to include location information in
+ /// the XML events.
+ /// </summary>
+ /// <value>
+ /// <c>true</c> if location information should be included in the XML
+ /// events; otherwise, <c>false</c>.
+ /// </value>
+ /// <remarks>
+ /// <para>
+ /// If <see cref="LocationInfo" /> is set to <c>true</c>, then the file
+ /// name and line number of the statement at the origin of the log
+ /// statement will be output.
+ /// </para>
+ /// <para>
+ /// If you are embedding this layout within an <c>SMTPAppender</c>
+ /// then make sure to set the <b>LocationInfo</b> option of that
+ /// appender as well.
+ /// </para>
+ /// </remarks>
+ public bool LocationInfo
+ {
+ get { return m_locationInfo; }
+ set { m_locationInfo = value; }
+ }
+ /// <summary>
+ /// The string to replace characters that can not be expressed in XML with.
+ /// <remarks>
+ /// <para>
+ /// Not all characters may be expressed in XML. This property contains the
+ /// string to replace those that can not with. This defaults to a ?. Set it
+ /// to the empty string to simply remove offending characters. For more
+ /// details on the allowed character ranges see http://www.w3.org/TR/REC-xml/#charsets
+ /// Character replacement will occur in the log message, the property names
+ /// and the property values.
+ /// </para>
+ /// </remarks>
+ /// </summary>
+ public string InvalidCharReplacement
+ {
+ get {return m_invalidCharReplacement;}
+ set {m_invalidCharReplacement=value;}
+ }
+ #endregion
- #region Implementation of IOptionHandler
+ #region Implementation of IOptionHandler
- /// <summary>
- /// Initialize layout options
- /// </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>
- public override void ActivateOptions()
- {
- // nothing to do
- }
+ /// <summary>
+ /// Initialize layout options
+ /// </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>
+ public override void ActivateOptions()
+ {
+ // nothing to do
+ }
- #endregion Implementation of IOptionHandler
+ #endregion Implementation of IOptionHandler
- #region Override implementation of LayoutSkeleton
+ #region Override implementation of LayoutSkeleton
- /// <summary>
- /// Gets the content type output by this layout.
- /// </summary>
- /// <value>
- /// As this is the XML layout, the value is always <c>"text/xml"</c>.
- /// </value>
- /// <remarks>
- /// <para>
- /// As this is the XML layout, the value is always <c>"text/xml"</c>.
- /// </para>
- /// </remarks>
- public override string ContentType
- {
- get { return "text/xml"; }
- }
+ /// <summary>
+ /// Gets the content type output by this layout.
+ /// </summary>
+ /// <value>
+ /// As this is the XML layout, the value is always <c>"text/xml"</c>.
+ /// </value>
+ /// <remarks>
+ /// <para>
+ /// As this is the XML layout, the value is always <c>"text/xml"</c>.
+ /// </para>
+ /// </remarks>
+ public override string ContentType
+ {
+ get { return "text/xml"; }
+ }
- /// <summary>
- /// Produces a formatted string.
- /// </summary>
- /// <param name="loggingEvent">The event being logged.</param>
- /// <param name="writer">The TextWriter to write the formatted event to</param>
- /// <remarks>
- /// <para>
- /// Format the <see cref="LoggingEvent"/> and write it to the <see cref="TextWriter"/>.
- /// </para>
- /// <para>
- /// This method creates an <see cref="XmlTextWriter"/> that writes to the
- /// <paramref name="writer"/>. The <see cref="XmlTextWriter"/> is passed
- /// to the <see cref="FormatXml"/> method. Subclasses should override the
- /// <see cref="FormatXml"/> method rather than this method.
- /// </para>
- /// </remarks>
- public override void Format(TextWriter writer, LoggingEvent loggingEvent)
- {
- if (loggingEvent == null)
- {
- throw new ArgumentNullException("loggingEvent");
- }
+ /// <summary>
+ /// Produces a formatted string.
+ /// </summary>
+ /// <param name="loggingEvent">The event being logged.</param>
+ /// <param name="writer">The TextWriter to write the formatted event to</param>
+ /// <remarks>
+ /// <para>
+ /// Format the <see cref="LoggingEvent"/> and write it to the <see cref="TextWriter"/>.
+ /// </para>
+ /// <para>
+ /// This method creates an <see cref="XmlTextWriter"/> that writes to the
+ /// <paramref name="writer"/>. The <see cref="XmlTextWriter"/> is passed
+ /// to the <see cref="FormatXml"/> method. Subclasses should override the
+ /// <see cref="FormatXml"/> method rather than this method.
+ /// </para>
+ /// </remarks>
+ public override void Format(TextWriter writer, LoggingEvent loggingEvent)
+ {
+ if (loggingEvent == null)
+ {
+ throw new ArgumentNullException("loggingEvent");
+ }
#if NETSTANDARD
- var settings = new XmlWriterSettings
- {
- Indent = false,
- OmitXmlDeclaration = true
- };
- using var xmlWriter = XmlWriter.Create(new ProtectCloseTextWriter(writer), settings);
+ var settings = new XmlWriterSettings
+ {
+ Indent = false,
+ OmitXmlDeclaration = true
+ };
+ using var xmlWriter = XmlWriter.Create(new ProtectCloseTextWriter(writer), settings);
#else
- using XmlTextWriter xmlWriter = new XmlTextWriter(new ProtectCloseTextWriter(writer));
- xmlWriter.Formatting = Formatting.None;
- xmlWriter.Namespaces = false;
+ using XmlTextWriter xmlWriter = new XmlTextWriter(new ProtectCloseTextWriter(writer));
+ xmlWriter.Formatting = Formatting.None;
+ xmlWriter.Namespaces = false;
#endif
- // Write the event to the writer
- FormatXml(xmlWriter, loggingEvent);
+ // Write the event to the writer
+ FormatXml(xmlWriter, loggingEvent);
- xmlWriter.WriteWhitespace(SystemInfo.NewLine);
+ xmlWriter.WriteWhitespace(SystemInfo.NewLine);
- // Close on xmlWriter will ensure xml is flushed
- // the protected writer will ignore the actual close
- // -> Dispose from using var will close & flush
- }
+ // Close on xmlWriter will ensure xml is flushed
+ // the protected writer will ignore the actual close
+ // -> Dispose from using var will close & flush
+ }
- #endregion Override implementation of LayoutSkeleton
+ #endregion Override implementation of LayoutSkeleton
- #region Protected Instance Methods
+ #region Protected Instance Methods
- /// <summary>
- /// Does the actual writing of the XML.
- /// </summary>
- /// <param name="writer">The writer to use to output the event to.</param>
- /// <param name="loggingEvent">The event to write.</param>
- /// <remarks>
- /// <para>
- /// Subclasses should override this method to format
- /// the <see cref="LoggingEvent"/> as XML.
- /// </para>
- /// </remarks>
- protected abstract void FormatXml(XmlWriter writer, LoggingEvent loggingEvent);
+ /// <summary>
+ /// Does the actual writing of the XML.
+ /// </summary>
+ /// <param name="writer">The writer to use to output the event to.</param>
+ /// <param name="loggingEvent">The event to write.</param>
+ /// <remarks>
+ /// <para>
+ /// Subclasses should override this method to format
+ /// the <see cref="LoggingEvent"/> as XML.
+ /// </para>
+ /// </remarks>
+ protected abstract void FormatXml(XmlWriter writer, LoggingEvent loggingEvent);
- #endregion Protected Instance Methods
+ #endregion Protected Instance Methods
- #region Private Instance Fields
+ #region Private Instance Fields
- /// <summary>
- /// Flag to indicate if location information should be included in
- /// the XML events.
- /// </summary>
- private bool m_locationInfo = false;
+ /// <summary>
+ /// Flag to indicate if location information should be included in
+ /// the XML events.
+ /// </summary>
+ private bool m_locationInfo = false;
- /// <summary>
- /// The string to replace invalid chars with
- /// </summary>
- private string m_invalidCharReplacement="?";
+ /// <summary>
+ /// The string to replace invalid chars with
+ /// </summary>
+ private string m_invalidCharReplacement="?";
- #endregion Private Instance Fields
- }
+ #endregion Private Instance Fields
+ }
}
diff --git a/src/log4net/Layout/XmlLayoutSchemaLog4j.cs b/src/log4net/Layout/XmlLayoutSchemaLog4j.cs
index d5ac73f..db6fb5a 100644
--- a/src/log4net/Layout/XmlLayoutSchemaLog4j.cs
+++ b/src/log4net/Layout/XmlLayoutSchemaLog4j.cs
@@ -27,83 +27,83 @@
namespace log4net.Layout
{
- /// <summary>
- /// Layout that formats the log events as XML elements compatible with the log4j schema
- /// </summary>
- /// <remarks>
- /// <para>
- /// Formats the log events according to the http://logging.apache.org/log4j schema.
- /// </para>
- /// </remarks>
- /// <author>Nicko Cadell</author>
- public class XmlLayoutSchemaLog4j : XmlLayoutBase
- {
- #region Static Members
+ /// <summary>
+ /// Layout that formats the log events as XML elements compatible with the log4j schema
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Formats the log events according to the http://logging.apache.org/log4j schema.
+ /// </para>
+ /// </remarks>
+ /// <author>Nicko Cadell</author>
+ public class XmlLayoutSchemaLog4j : XmlLayoutBase
+ {
+ #region Static Members
- /// <summary>
- /// The 1st of January 1970 in UTC
- /// </summary>
- private static readonly DateTime s_date1970 = new DateTime(1970, 1, 1);
+ /// <summary>
+ /// The 1st of January 1970 in UTC
+ /// </summary>
+ private static readonly DateTime s_date1970 = new DateTime(1970, 1, 1);
- #endregion
+ #endregion
- #region Constructors
+ #region Constructors
- /// <summary>
- /// Constructs an XMLLayoutSchemaLog4j
- /// </summary>
- public XmlLayoutSchemaLog4j() : base()
- {
- }
+ /// <summary>
+ /// Constructs an XMLLayoutSchemaLog4j
+ /// </summary>
+ public XmlLayoutSchemaLog4j() : base()
+ {
+ }
- /// <summary>
- /// Constructs an XMLLayoutSchemaLog4j.
- /// </summary>
- /// <remarks>
- /// <para>
- /// The <b>LocationInfo</b> option takes a boolean value. By
- /// default, it is set to false which means there will be no location
- /// information output by this layout. If the the option is set to
- /// true, then the file name and line number of the statement
- /// at the origin of the log statement will be output.
- /// </para>
- /// <para>
- /// If you are embedding this layout within an SMTPAppender
- /// then make sure to set the <b>LocationInfo</b> option of that
- /// appender as well.
- /// </para>
- /// </remarks>
- public XmlLayoutSchemaLog4j(bool locationInfo) : base(locationInfo)
- {
- }
+ /// <summary>
+ /// Constructs an XMLLayoutSchemaLog4j.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// The <b>LocationInfo</b> option takes a boolean value. By
+ /// default, it is set to false which means there will be no location
+ /// information output by this layout. If the the option is set to
+ /// true, then the file name and line number of the statement
+ /// at the origin of the log statement will be output.
+ /// </para>
+ /// <para>
+ /// If you are embedding this layout within an SMTPAppender
+ /// then make sure to set the <b>LocationInfo</b> option of that
+ /// appender as well.
+ /// </para>
+ /// </remarks>
+ public XmlLayoutSchemaLog4j(bool locationInfo) : base(locationInfo)
+ {
+ }
- #endregion
+ #endregion
- #region Public Properties
+ #region Public Properties
- /// <summary>
- /// The version of the log4j schema to use.
- /// </summary>
- /// <remarks>
- /// <para>
- /// Only version 1.2 of the log4j schema is supported.
- /// </para>
- /// </remarks>
- public string Version
- {
- get { return "1.2"; }
- set
- {
- if (value != "1.2")
- {
- throw new ArgumentException("Only version 1.2 of the log4j schema is currently supported");
- }
- }
- }
+ /// <summary>
+ /// The version of the log4j schema to use.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Only version 1.2 of the log4j schema is supported.
+ /// </para>
+ /// </remarks>
+ public string Version
+ {
+ get { return "1.2"; }
+ set
+ {
+ if (value != "1.2")
+ {
+ throw new ArgumentException("Only version 1.2 of the log4j schema is currently supported");
+ }
+ }
+ }
- #endregion
+ #endregion
- /* Example log4j schema event
+ /* Example log4j schema event
<log4j:event logger="first logger" level="ERROR" thread="Thread-3" timestamp="1051494121460">
<log4j:message><![CDATA[errormsg 3]]></log4j:message>
@@ -112,7 +112,7 @@
<log4j:data name="some string" value="some valuethird"/>
</log4j:MDC>
<log4j:throwable><![CDATA[java.lang.Exception: someexception-third
- at org.apache.log4j.chainsaw.Generator.run(Generator.java:94)
+ at org.apache.log4j.chainsaw.Generator.run(Generator.java:94)
]]></log4j:throwable>
<log4j:locationInfo class="org.apache.log4j.chainsaw.Generator"
method="run" file="Generator.java" line="94"/>
@@ -122,159 +122,159 @@
</log4j:properties>
</log4j:event>
- */
+ */
- /* Since log4j 1.3 the log4j:MDC has been combined into the log4j:properties element */
+ /* Since log4j 1.3 the log4j:MDC has been combined into the log4j:properties element */
- /// <summary>
- /// Actually do the writing of the xml
- /// </summary>
- /// <param name="writer">the writer to use</param>
- /// <param name="loggingEvent">the event to write</param>
- /// <remarks>
- /// <para>
- /// Generate XML that is compatible with the log4j schema.
- /// </para>
- /// </remarks>
- protected override void FormatXml(XmlWriter writer, LoggingEvent loggingEvent)
- {
- // Translate logging events for log4j
+ /// <summary>
+ /// Actually do the writing of the xml
+ /// </summary>
+ /// <param name="writer">the writer to use</param>
+ /// <param name="loggingEvent">the event to write</param>
+ /// <remarks>
+ /// <para>
+ /// Generate XML that is compatible with the log4j schema.
+ /// </para>
+ /// </remarks>
+ protected override void FormatXml(XmlWriter writer, LoggingEvent loggingEvent)
+ {
+ // Translate logging events for log4j
- // Translate hostname property
- if (loggingEvent.LookupProperty(LoggingEvent.HostNameProperty) != null &&
- loggingEvent.LookupProperty("log4jmachinename") == null)
- {
- loggingEvent.GetProperties()["log4jmachinename"] = loggingEvent.LookupProperty(LoggingEvent.HostNameProperty);
- }
+ // Translate hostname property
+ if (loggingEvent.LookupProperty(LoggingEvent.HostNameProperty) != null &&
+ loggingEvent.LookupProperty("log4jmachinename") == null)
+ {
+ loggingEvent.GetProperties()["log4jmachinename"] = loggingEvent.LookupProperty(LoggingEvent.HostNameProperty);
+ }
- // translate appdomain name
- if (loggingEvent.LookupProperty("log4japp") == null &&
- loggingEvent.Domain != null &&
- loggingEvent.Domain.Length > 0)
- {
- loggingEvent.GetProperties()["log4japp"] = loggingEvent.Domain;
- }
+ // translate appdomain name
+ if (loggingEvent.LookupProperty("log4japp") == null &&
+ loggingEvent.Domain != null &&
+ loggingEvent.Domain.Length > 0)
+ {
+ loggingEvent.GetProperties()["log4japp"] = loggingEvent.Domain;
+ }
- // translate identity name
- if (loggingEvent.Identity != null &&
- loggingEvent.Identity.Length > 0 &&
- loggingEvent.LookupProperty(LoggingEvent.IdentityProperty) == null)
- {
- loggingEvent.GetProperties()[LoggingEvent.IdentityProperty] = loggingEvent.Identity;
- }
+ // translate identity name
+ if (loggingEvent.Identity != null &&
+ loggingEvent.Identity.Length > 0 &&
+ loggingEvent.LookupProperty(LoggingEvent.IdentityProperty) == null)
+ {
+ loggingEvent.GetProperties()[LoggingEvent.IdentityProperty] = loggingEvent.Identity;
+ }
- // translate user name
- if (loggingEvent.UserName != null &&
- loggingEvent.UserName.Length > 0 &&
- loggingEvent.LookupProperty(LoggingEvent.UserNameProperty) == null)
- {
- loggingEvent.GetProperties()[LoggingEvent.UserNameProperty] = loggingEvent.UserName;
- }
+ // translate user name
+ if (loggingEvent.UserName != null &&
+ loggingEvent.UserName.Length > 0 &&
+ loggingEvent.LookupProperty(LoggingEvent.UserNameProperty) == null)
+ {
+ loggingEvent.GetProperties()[LoggingEvent.UserNameProperty] = loggingEvent.UserName;
+ }
- // Write the start element
- #if NETSTANDARD
- writer.WriteStartElement("log4j", "event", "log4net");
- #else
- writer.WriteStartElement("log4j:event");
- #endif
- writer.WriteAttributeString("logger", loggingEvent.LoggerName);
+ // Write the start element
+ #if NETSTANDARD
+ writer.WriteStartElement("log4j", "event", "log4net");
+ #else
+ writer.WriteStartElement("log4j:event");
+ #endif
+ writer.WriteAttributeString("logger", loggingEvent.LoggerName);
- // Calculate the timestamp as the number of milliseconds since january 1970
- //
- // We must convert the TimeStamp to UTC before performing any mathematical
- // operations. This allows use to take into account discontinuities
- // caused by daylight savings time transitions.
- TimeSpan timeSince1970 = loggingEvent.TimeStampUtc - s_date1970;
+ // Calculate the timestamp as the number of milliseconds since january 1970
+ //
+ // We must convert the TimeStamp to UTC before performing any mathematical
+ // operations. This allows use to take into account discontinuities
+ // caused by daylight savings time transitions.
+ TimeSpan timeSince1970 = loggingEvent.TimeStampUtc - s_date1970;
- writer.WriteAttributeString("timestamp", XmlConvert.ToString((long)timeSince1970.TotalMilliseconds));
- writer.WriteAttributeString("level", loggingEvent.Level.DisplayName);
- writer.WriteAttributeString("thread", loggingEvent.ThreadName);
+ writer.WriteAttributeString("timestamp", XmlConvert.ToString((long)timeSince1970.TotalMilliseconds));
+ writer.WriteAttributeString("level", loggingEvent.Level.DisplayName);
+ writer.WriteAttributeString("thread", loggingEvent.ThreadName);
- // Append the message text
- #if NETSTANDARD
- writer.WriteStartElement("log4j", "message", "log4net");
- #else
- writer.WriteStartElement("log4j:message");
- #endif
- Transform.WriteEscapedXmlString(writer, loggingEvent.RenderedMessage,this.InvalidCharReplacement);
- writer.WriteEndElement();
+ // Append the message text
+ #if NETSTANDARD
+ writer.WriteStartElement("log4j", "message", "log4net");
+ #else
+ writer.WriteStartElement("log4j:message");
+ #endif
+ Transform.WriteEscapedXmlString(writer, loggingEvent.RenderedMessage,this.InvalidCharReplacement);
+ writer.WriteEndElement();
- object ndcObj = loggingEvent.LookupProperty("NDC");
- if (ndcObj != null)
- {
- string valueStr = loggingEvent.Repository.RendererMap.FindAndRender(ndcObj);
+ object ndcObj = loggingEvent.LookupProperty("NDC");
+ if (ndcObj != null)
+ {
+ string valueStr = loggingEvent.Repository.RendererMap.FindAndRender(ndcObj);
- if (valueStr != null && valueStr.Length > 0)
- {
- // Append the NDC text
- #if NETSTANDARD
- writer.WriteStartElement("log4j", "NDC", "log4net");
- #else
- writer.WriteStartElement("log4j:NDC");
- #endif
- Transform.WriteEscapedXmlString(writer, valueStr,this.InvalidCharReplacement);
- writer.WriteEndElement();
- }
- }
+ if (valueStr != null && valueStr.Length > 0)
+ {
+ // Append the NDC text
+ #if NETSTANDARD
+ writer.WriteStartElement("log4j", "NDC", "log4net");
+ #else
+ writer.WriteStartElement("log4j:NDC");
+ #endif
+ Transform.WriteEscapedXmlString(writer, valueStr,this.InvalidCharReplacement);
+ writer.WriteEndElement();
+ }
+ }
- // Append the properties text
- PropertiesDictionary properties = loggingEvent.GetProperties();
- if (properties.Count > 0)
- {
- #if NETSTANDARD
- writer.WriteStartElement("log4j", "properties", "log4net");
- #else
- writer.WriteStartElement("log4j:properties");
- #endif
- foreach(System.Collections.DictionaryEntry entry in properties)
- {
- #if NETSTANDARD
- writer.WriteStartElement("log4j", "data", "log4net");
- #else
- writer.WriteStartElement("log4j:data");
- #endif
- writer.WriteAttributeString("name", (string)entry.Key);
+ // Append the properties text
+ PropertiesDictionary properties = loggingEvent.GetProperties();
+ if (properties.Count > 0)
+ {
+ #if NETSTANDARD
+ writer.WriteStartElement("log4j", "properties", "log4net");
+ #else
+ writer.WriteStartElement("log4j:properties");
+ #endif
+ foreach(System.Collections.DictionaryEntry entry in properties)
+ {
+ #if NETSTANDARD
+ writer.WriteStartElement("log4j", "data", "log4net");
+ #else
+ writer.WriteStartElement("log4j:data");
+ #endif
+ writer.WriteAttributeString("name", (string)entry.Key);
- // Use an ObjectRenderer to convert the object to a string
- string valueStr = loggingEvent.Repository.RendererMap.FindAndRender(entry.Value);
- writer.WriteAttributeString("value", valueStr);
+ // Use an ObjectRenderer to convert the object to a string
+ string valueStr = loggingEvent.Repository.RendererMap.FindAndRender(entry.Value);
+ writer.WriteAttributeString("value", valueStr);
- writer.WriteEndElement();
- }
- writer.WriteEndElement();
- }
+ writer.WriteEndElement();
+ }
+ writer.WriteEndElement();
+ }
- string exceptionStr = loggingEvent.GetExceptionString();
- if (exceptionStr != null && exceptionStr.Length > 0)
- {
- // Append the stack trace line
- #if NETSTANDARD
- writer.WriteStartElement("log4j", "throwable", "log4net");
- #else
- writer.WriteStartElement("log4j:throwable");
- #endif
- Transform.WriteEscapedXmlString(writer, exceptionStr,this.InvalidCharReplacement);
- writer.WriteEndElement();
- }
+ string exceptionStr = loggingEvent.GetExceptionString();
+ if (exceptionStr != null && exceptionStr.Length > 0)
+ {
+ // Append the stack trace line
+ #if NETSTANDARD
+ writer.WriteStartElement("log4j", "throwable", "log4net");
+ #else
+ writer.WriteStartElement("log4j:throwable");
+ #endif
+ Transform.WriteEscapedXmlString(writer, exceptionStr,this.InvalidCharReplacement);
+ writer.WriteEndElement();
+ }
- if (LocationInfo)
- {
- LocationInfo locationInfo = loggingEvent.LocationInformation;
+ if (LocationInfo)
+ {
+ LocationInfo locationInfo = loggingEvent.LocationInformation;
- #if NETSTANDARD
- writer.WriteStartElement("log4j", "locationInfo", "log4net");
- #else
- writer.WriteStartElement("log4j:locationInfo");
- #endif
- writer.WriteAttributeString("class", locationInfo.ClassName);
- writer.WriteAttributeString("method", locationInfo.MethodName);
- writer.WriteAttributeString("file", locationInfo.FileName);
- writer.WriteAttributeString("line", locationInfo.LineNumber);
- writer.WriteEndElement();
- }
+ #if NETSTANDARD
+ writer.WriteStartElement("log4j", "locationInfo", "log4net");
+ #else
+ writer.WriteStartElement("log4j:locationInfo");
+ #endif
+ writer.WriteAttributeString("class", locationInfo.ClassName);
+ writer.WriteAttributeString("method", locationInfo.MethodName);
+ writer.WriteAttributeString("file", locationInfo.FileName);
+ writer.WriteAttributeString("line", locationInfo.LineNumber);
+ writer.WriteEndElement();
+ }
- writer.WriteEndElement();
- }
- }
+ writer.WriteEndElement();
+ }
+ }
}
diff --git a/src/log4net/LogManager.cs b/src/log4net/LogManager.cs
index b3598e2..664d39c 100644
--- a/src/log4net/LogManager.cs
+++ b/src/log4net/LogManager.cs
@@ -25,107 +25,107 @@
namespace log4net
{
- /// <summary>
- /// This class is used by client applications to request logger instances.
- /// </summary>
- /// <remarks>
- /// <para>
- /// This class has static methods that are used by a client to request
- /// a logger instance. The <see cref="M:GetLogger(string)"/> method is
- /// used to retrieve a logger.
- /// </para>
- /// <para>
- /// See the <see cref="ILog"/> interface for more details.
- /// </para>
- /// </remarks>
- /// <example>Simple example of logging messages
- /// <code lang="C#">
- /// ILog log = LogManager.GetLogger("application-log");
- ///
- /// log.Info("Application Start");
- /// log.Debug("This is a debug message");
- ///
- /// if (log.IsDebugEnabled)
- /// {
- /// log.Debug("This is another debug message");
- /// }
- /// </code>
- /// </example>
- /// <threadsafety static="true" instance="true" />
- /// <seealso cref="ILog"/>
- /// <author>Nicko Cadell</author>
- /// <author>Gert Driesen</author>
- public sealed class LogManager
- {
- #region Private Instance Constructors
+ /// <summary>
+ /// This class is used by client applications to request logger instances.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// This class has static methods that are used by a client to request
+ /// a logger instance. The <see cref="M:GetLogger(string)"/> method is
+ /// used to retrieve a logger.
+ /// </para>
+ /// <para>
+ /// See the <see cref="ILog"/> interface for more details.
+ /// </para>
+ /// </remarks>
+ /// <example>Simple example of logging messages
+ /// <code lang="C#">
+ /// ILog log = LogManager.GetLogger("application-log");
+ ///
+ /// log.Info("Application Start");
+ /// log.Debug("This is a debug message");
+ ///
+ /// if (log.IsDebugEnabled)
+ /// {
+ /// log.Debug("This is another debug message");
+ /// }
+ /// </code>
+ /// </example>
+ /// <threadsafety static="true" instance="true" />
+ /// <seealso cref="ILog"/>
+ /// <author>Nicko Cadell</author>
+ /// <author>Gert Driesen</author>
+ public sealed class LogManager
+ {
+ #region Private Instance Constructors
- /// <summary>
- /// Initializes a new instance of the <see cref="LogManager" /> class.
- /// </summary>
- /// <remarks>
- /// Uses a private access modifier to prevent instantiation of this class.
- /// </remarks>
- private LogManager()
- {
- }
+ /// <summary>
+ /// Initializes a new instance of the <see cref="LogManager" /> class.
+ /// </summary>
+ /// <remarks>
+ /// Uses a private access modifier to prevent instantiation of this class.
+ /// </remarks>
+ private LogManager()
+ {
+ }
- #endregion Private Instance Constructors
+ #endregion Private Instance Constructors
- #region Type Specific Manager Methods
+ #region Type Specific Manager Methods
#if !NETSTANDARD1_3 // Excluded because GetCallingAssembly() is not available in CoreFX (https://github.com/dotnet/corefx/issues/2221).
- /// <overloads>Returns the named logger if it exists.</overloads>
- /// <summary>
- /// Returns the named logger if it exists.
- /// </summary>
- /// <remarks>
- /// <para>
- /// If the named logger exists (in the default repository) then it
- /// returns a reference to the logger, otherwise it returns <c>null</c>.
- /// </para>
- /// </remarks>
- /// <param name="name">The fully qualified logger name to look for.</param>
- /// <returns>The logger found, or <c>null</c> if no logger could be found.</returns>
- public static ILog Exists(string name)
- {
- return Exists(Assembly.GetCallingAssembly(), name);
- }
+ /// <overloads>Returns the named logger if it exists.</overloads>
+ /// <summary>
+ /// Returns the named logger if it exists.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// If the named logger exists (in the default repository) then it
+ /// returns a reference to the logger, otherwise it returns <c>null</c>.
+ /// </para>
+ /// </remarks>
+ /// <param name="name">The fully qualified logger name to look for.</param>
+ /// <returns>The logger found, or <c>null</c> if no logger could be found.</returns>
+ public static ILog Exists(string name)
+ {
+ return Exists(Assembly.GetCallingAssembly(), name);
+ }
- /// <overloads>Get the currently defined loggers.</overloads>
- /// <summary>
- /// Returns all the currently defined loggers in the default repository.
- /// </summary>
- /// <remarks>
- /// <para>The root logger is <b>not</b> included in the returned array.</para>
- /// </remarks>
- /// <returns>All the defined loggers.</returns>
- public static ILog[] GetCurrentLoggers()
- {
- return GetCurrentLoggers(Assembly.GetCallingAssembly());
- }
+ /// <overloads>Get the currently defined loggers.</overloads>
+ /// <summary>
+ /// Returns all the currently defined loggers in the default repository.
+ /// </summary>
+ /// <remarks>
+ /// <para>The root logger is <b>not</b> included in the returned array.</para>
+ /// </remarks>
+ /// <returns>All the defined loggers.</returns>
+ public static ILog[] GetCurrentLoggers()
+ {
+ return GetCurrentLoggers(Assembly.GetCallingAssembly());
+ }
- /// <overloads>Get or create a logger.</overloads>
- /// <summary>
- /// Retrieves or creates a named logger.
- /// </summary>
- /// <remarks>
- /// <para>
- /// Retrieves a logger named as the <paramref name="name"/>
- /// parameter. If the named logger already exists, then the
- /// existing instance will be returned. Otherwise, a new instance is
- /// created.
- /// </para>
- /// <para>By default, loggers do not have a set level but inherit
- /// it from the hierarchy. This is one of the central features of
- /// log4net.
- /// </para>
- /// </remarks>
- /// <param name="name">The name of the logger to retrieve.</param>
- /// <returns>The logger with the name specified.</returns>
- public static ILog GetLogger(string name)
- {
- return GetLogger(Assembly.GetCallingAssembly(), name);
- }
+ /// <overloads>Get or create a logger.</overloads>
+ /// <summary>
+ /// Retrieves or creates a named logger.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Retrieves a logger named as the <paramref name="name"/>
+ /// parameter. If the named logger already exists, then the
+ /// existing instance will be returned. Otherwise, a new instance is
+ /// created.
+ /// </para>
+ /// <para>By default, loggers do not have a set level but inherit
+ /// it from the hierarchy. This is one of the central features of
+ /// log4net.
+ /// </para>
+ /// </remarks>
+ /// <param name="name">The name of the logger to retrieve.</param>
+ /// <returns>The logger with the name specified.</returns>
+ public static ILog GetLogger(string name)
+ {
+ return GetLogger(Assembly.GetCallingAssembly(), name);
+ }
#endif // !NETSTANDARD1_3
/// <summary>
@@ -145,611 +145,611 @@
/// repository.
/// </returns>
public static ILog Exists(string repository, string name)
- {
- return WrapLogger(LoggerManager.Exists(repository, name));
- }
+ {
+ return WrapLogger(LoggerManager.Exists(repository, name));
+ }
- /// <summary>
- /// Returns the named logger if it exists.
- /// </summary>
- /// <remarks>
- /// <para>
- /// If the named logger exists (in the repository for the specified assembly) then it
- /// returns a reference to the logger, otherwise it returns
- /// <c>null</c>.
- /// </para>
- /// </remarks>
- /// <param name="repositoryAssembly">The assembly to use to lookup the repository.</param>
- /// <param name="name">The fully qualified logger name to look for.</param>
- /// <returns>
- /// The logger, or <c>null</c> if the logger doesn't exist in the specified
- /// assembly's repository.
- /// </returns>
- public static ILog Exists(Assembly repositoryAssembly, string name)
- {
- return WrapLogger(LoggerManager.Exists(repositoryAssembly, name));
- }
+ /// <summary>
+ /// Returns the named logger if it exists.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// If the named logger exists (in the repository for the specified assembly) then it
+ /// returns a reference to the logger, otherwise it returns
+ /// <c>null</c>.
+ /// </para>
+ /// </remarks>
+ /// <param name="repositoryAssembly">The assembly to use to lookup the repository.</param>
+ /// <param name="name">The fully qualified logger name to look for.</param>
+ /// <returns>
+ /// The logger, or <c>null</c> if the logger doesn't exist in the specified
+ /// assembly's repository.
+ /// </returns>
+ public static ILog Exists(Assembly repositoryAssembly, string name)
+ {
+ return WrapLogger(LoggerManager.Exists(repositoryAssembly, name));
+ }
- /// <summary>
- /// Returns all the currently defined loggers in the specified repository.
- /// </summary>
- /// <param name="repository">The repository to lookup in.</param>
- /// <remarks>
- /// The root logger is <b>not</b> included in the returned array.
- /// </remarks>
- /// <returns>All the defined loggers.</returns>
- public static ILog[] GetCurrentLoggers(string repository)
- {
- return WrapLoggers(LoggerManager.GetCurrentLoggers(repository));
- }
+ /// <summary>
+ /// Returns all the currently defined loggers in the specified repository.
+ /// </summary>
+ /// <param name="repository">The repository to lookup in.</param>
+ /// <remarks>
+ /// The root logger is <b>not</b> included in the returned array.
+ /// </remarks>
+ /// <returns>All the defined loggers.</returns>
+ public static ILog[] GetCurrentLoggers(string repository)
+ {
+ return WrapLoggers(LoggerManager.GetCurrentLoggers(repository));
+ }
- /// <summary>
- /// Returns all the currently defined loggers in the specified assembly's repository.
- /// </summary>
- /// <param name="repositoryAssembly">The assembly to use to lookup the repository.</param>
- /// <remarks>
- /// The root logger is <b>not</b> included in the returned array.
- /// </remarks>
- /// <returns>All the defined loggers.</returns>
- public static ILog[] GetCurrentLoggers(Assembly repositoryAssembly)
- {
- return WrapLoggers(LoggerManager.GetCurrentLoggers(repositoryAssembly));
- }
+ /// <summary>
+ /// Returns all the currently defined loggers in the specified assembly's repository.
+ /// </summary>
+ /// <param name="repositoryAssembly">The assembly to use to lookup the repository.</param>
+ /// <remarks>
+ /// The root logger is <b>not</b> included in the returned array.
+ /// </remarks>
+ /// <returns>All the defined loggers.</returns>
+ public static ILog[] GetCurrentLoggers(Assembly repositoryAssembly)
+ {
+ return WrapLoggers(LoggerManager.GetCurrentLoggers(repositoryAssembly));
+ }
- /// <summary>
- /// Retrieves or creates a named logger.
- /// </summary>
- /// <remarks>
- /// <para>
- /// Retrieve a logger named as the <paramref name="name"/>
- /// parameter. If the named logger already exists, then the
- /// existing instance will be returned. Otherwise, a new instance is
- /// created.
- /// </para>
- /// <para>
- /// By default, loggers do not have a set level but inherit
- /// it from the hierarchy. This is one of the central features of
- /// log4net.
- /// </para>
- /// </remarks>
- /// <param name="repository">The repository to lookup in.</param>
- /// <param name="name">The name of the logger to retrieve.</param>
- /// <returns>The logger with the name specified.</returns>
- public static ILog GetLogger(string repository, string name)
- {
- return WrapLogger(LoggerManager.GetLogger(repository, name));
- }
+ /// <summary>
+ /// Retrieves or creates a named logger.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Retrieve a logger named as the <paramref name="name"/>
+ /// parameter. If the named logger already exists, then the
+ /// existing instance will be returned. Otherwise, a new instance is
+ /// created.
+ /// </para>
+ /// <para>
+ /// By default, loggers do not have a set level but inherit
+ /// it from the hierarchy. This is one of the central features of
+ /// log4net.
+ /// </para>
+ /// </remarks>
+ /// <param name="repository">The repository to lookup in.</param>
+ /// <param name="name">The name of the logger to retrieve.</param>
+ /// <returns>The logger with the name specified.</returns>
+ public static ILog GetLogger(string repository, string name)
+ {
+ return WrapLogger(LoggerManager.GetLogger(repository, name));
+ }
- /// <summary>
- /// Retrieves or creates a named logger.
- /// </summary>
- /// <remarks>
- /// <para>
- /// Retrieve a logger named as the <paramref name="name"/>
- /// parameter. If the named logger already exists, then the
- /// existing instance will be returned. Otherwise, a new instance is
- /// created.
- /// </para>
- /// <para>
- /// By default, loggers do not have a set level but inherit
- /// it from the hierarchy. This is one of the central features of
- /// log4net.
- /// </para>
- /// </remarks>
- /// <param name="repositoryAssembly">The assembly to use to lookup the repository.</param>
- /// <param name="name">The name of the logger to retrieve.</param>
- /// <returns>The logger with the name specified.</returns>
- public static ILog GetLogger(Assembly repositoryAssembly, string name)
- {
- return WrapLogger(LoggerManager.GetLogger(repositoryAssembly, name));
- }
+ /// <summary>
+ /// Retrieves or creates a named logger.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Retrieve a logger named as the <paramref name="name"/>
+ /// parameter. If the named logger already exists, then the
+ /// existing instance will be returned. Otherwise, a new instance is
+ /// created.
+ /// </para>
+ /// <para>
+ /// By default, loggers do not have a set level but inherit
+ /// it from the hierarchy. This is one of the central features of
+ /// log4net.
+ /// </para>
+ /// </remarks>
+ /// <param name="repositoryAssembly">The assembly to use to lookup the repository.</param>
+ /// <param name="name">The name of the logger to retrieve.</param>
+ /// <returns>The logger with the name specified.</returns>
+ public static ILog GetLogger(Assembly repositoryAssembly, string name)
+ {
+ return WrapLogger(LoggerManager.GetLogger(repositoryAssembly, name));
+ }
- /// <summary>
- /// Shorthand for <see cref="M:LogManager.GetLogger(string)"/>.
- /// </summary>
- /// <remarks>
- /// Get the logger for the fully qualified name of the type specified.
- /// </remarks>
- /// <param name="type">The full name of <paramref name="type"/> will be used as the name of the logger to retrieve.</param>
- /// <returns>The logger with the name specified.</returns>
- public static ILog GetLogger(Type type)
- {
+ /// <summary>
+ /// Shorthand for <see cref="M:LogManager.GetLogger(string)"/>.
+ /// </summary>
+ /// <remarks>
+ /// Get the logger for the fully qualified name of the type specified.
+ /// </remarks>
+ /// <param name="type">The full name of <paramref name="type"/> will be used as the name of the logger to retrieve.</param>
+ /// <returns>The logger with the name specified.</returns>
+ public static ILog GetLogger(Type type)
+ {
#if NETSTANDARD1_3
- return GetLogger(type.GetTypeInfo().Assembly, type.FullName);
+ return GetLogger(type.GetTypeInfo().Assembly, type.FullName);
#else
- return GetLogger(Assembly.GetCallingAssembly(), type.FullName);
+ return GetLogger(Assembly.GetCallingAssembly(), type.FullName);
#endif
- }
+ }
- /// <summary>
- /// Shorthand for <see cref="M:LogManager.GetLogger(string)"/>.
- /// </summary>
- /// <remarks>
- /// Gets the logger for the fully qualified name of the type specified.
- /// </remarks>
- /// <param name="repository">The repository to lookup in.</param>
- /// <param name="type">The full name of <paramref name="type"/> will be used as the name of the logger to retrieve.</param>
- /// <returns>The logger with the name specified.</returns>
- public static ILog GetLogger(string repository, Type type)
- {
- return WrapLogger(LoggerManager.GetLogger(repository, type));
- }
+ /// <summary>
+ /// Shorthand for <see cref="M:LogManager.GetLogger(string)"/>.
+ /// </summary>
+ /// <remarks>
+ /// Gets the logger for the fully qualified name of the type specified.
+ /// </remarks>
+ /// <param name="repository">The repository to lookup in.</param>
+ /// <param name="type">The full name of <paramref name="type"/> will be used as the name of the logger to retrieve.</param>
+ /// <returns>The logger with the name specified.</returns>
+ public static ILog GetLogger(string repository, Type type)
+ {
+ return WrapLogger(LoggerManager.GetLogger(repository, type));
+ }
- /// <summary>
- /// Shorthand for <see cref="M:LogManager.GetLogger(string)"/>.
- /// </summary>
- /// <remarks>
- /// Gets the logger for the fully qualified name of the type specified.
- /// </remarks>
- /// <param name="repositoryAssembly">The assembly to use to lookup the repository.</param>
- /// <param name="type">The full name of <paramref name="type"/> will be used as the name of the logger to retrieve.</param>
- /// <returns>The logger with the name specified.</returns>
- public static ILog GetLogger(Assembly repositoryAssembly, Type type)
- {
- return WrapLogger(LoggerManager.GetLogger(repositoryAssembly, type));
- }
+ /// <summary>
+ /// Shorthand for <see cref="M:LogManager.GetLogger(string)"/>.
+ /// </summary>
+ /// <remarks>
+ /// Gets the logger for the fully qualified name of the type specified.
+ /// </remarks>
+ /// <param name="repositoryAssembly">The assembly to use to lookup the repository.</param>
+ /// <param name="type">The full name of <paramref name="type"/> will be used as the name of the logger to retrieve.</param>
+ /// <returns>The logger with the name specified.</returns>
+ public static ILog GetLogger(Assembly repositoryAssembly, Type type)
+ {
+ return WrapLogger(LoggerManager.GetLogger(repositoryAssembly, type));
+ }
- #endregion Type Specific Manager Methods
+ #endregion Type Specific Manager Methods
- #region Domain & Repository Manager Methods
+ #region Domain & Repository Manager Methods
- /// <summary>
- /// Shuts down the log4net system.
- /// </summary>
- /// <remarks>
- /// <para>
- /// Calling this method will <b>safely</b> close and remove all
- /// appenders in all the loggers including root contained in all the
- /// default repositories.
- /// </para>
- /// <para>
- /// Some appenders need to be closed before the application exists.
- /// Otherwise, pending logging events might be lost.
- /// </para>
- /// <para>The <c>shutdown</c> method is careful to close nested
- /// appenders before closing regular appenders. This is allows
- /// configurations where a regular appender is attached to a logger
- /// and again to a nested appender.
- /// </para>
- /// </remarks>
- public static void Shutdown()
- {
- LoggerManager.Shutdown();
- }
+ /// <summary>
+ /// Shuts down the log4net system.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Calling this method will <b>safely</b> close and remove all
+ /// appenders in all the loggers including root contained in all the
+ /// default repositories.
+ /// </para>
+ /// <para>
+ /// Some appenders need to be closed before the application exists.
+ /// Otherwise, pending logging events might be lost.
+ /// </para>
+ /// <para>The <c>shutdown</c> method is careful to close nested
+ /// appenders before closing regular appenders. This is allows
+ /// configurations where a regular appender is attached to a logger
+ /// and again to a nested appender.
+ /// </para>
+ /// </remarks>
+ public static void Shutdown()
+ {
+ LoggerManager.Shutdown();
+ }
#if !NETSTANDARD1_3
- /// <overloads>Shutdown a logger repository.</overloads>
- /// <summary>
- /// Shuts down the default repository.
- /// </summary>
- /// <remarks>
- /// <para>
- /// Calling this method will <b>safely</b> close and remove all
- /// appenders in all the loggers including root contained in the
- /// default repository.
- /// </para>
- /// <para>Some appenders need to be closed before the application exists.
- /// Otherwise, pending logging events might be lost.
- /// </para>
- /// <para>The <c>shutdown</c> method is careful to close nested
- /// appenders before closing regular appenders. This is allows
- /// configurations where a regular appender is attached to a logger
- /// and again to a nested appender.
- /// </para>
- /// </remarks>
- public static void ShutdownRepository()
- {
- ShutdownRepository(Assembly.GetCallingAssembly());
- }
+ /// <overloads>Shutdown a logger repository.</overloads>
+ /// <summary>
+ /// Shuts down the default repository.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Calling this method will <b>safely</b> close and remove all
+ /// appenders in all the loggers including root contained in the
+ /// default repository.
+ /// </para>
+ /// <para>Some appenders need to be closed before the application exists.
+ /// Otherwise, pending logging events might be lost.
+ /// </para>
+ /// <para>The <c>shutdown</c> method is careful to close nested
+ /// appenders before closing regular appenders. This is allows
+ /// configurations where a regular appender is attached to a logger
+ /// and again to a nested appender.
+ /// </para>
+ /// </remarks>
+ public static void ShutdownRepository()
+ {
+ ShutdownRepository(Assembly.GetCallingAssembly());
+ }
#endif
- /// <summary>
- /// Shuts down the repository for the repository specified.
- /// </summary>
- /// <remarks>
- /// <para>
- /// Calling this method will <b>safely</b> close and remove all
- /// appenders in all the loggers including root contained in the
- /// <paramref name="repository"/> specified.
- /// </para>
- /// <para>
- /// Some appenders need to be closed before the application exists.
- /// Otherwise, pending logging events might be lost.
- /// </para>
- /// <para>The <c>shutdown</c> method is careful to close nested
- /// appenders before closing regular appenders. This is allows
- /// configurations where a regular appender is attached to a logger
- /// and again to a nested appender.
- /// </para>
- /// </remarks>
- /// <param name="repository">The repository to shutdown.</param>
- public static void ShutdownRepository(string repository)
- {
- LoggerManager.ShutdownRepository(repository);
- }
+ /// <summary>
+ /// Shuts down the repository for the repository specified.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Calling this method will <b>safely</b> close and remove all
+ /// appenders in all the loggers including root contained in the
+ /// <paramref name="repository"/> specified.
+ /// </para>
+ /// <para>
+ /// Some appenders need to be closed before the application exists.
+ /// Otherwise, pending logging events might be lost.
+ /// </para>
+ /// <para>The <c>shutdown</c> method is careful to close nested
+ /// appenders before closing regular appenders. This is allows
+ /// configurations where a regular appender is attached to a logger
+ /// and again to a nested appender.
+ /// </para>
+ /// </remarks>
+ /// <param name="repository">The repository to shutdown.</param>
+ public static void ShutdownRepository(string repository)
+ {
+ LoggerManager.ShutdownRepository(repository);
+ }
- /// <summary>
- /// Shuts down the repository specified.
- /// </summary>
- /// <remarks>
- /// <para>
- /// Calling this method will <b>safely</b> close and remove all
- /// appenders in all the loggers including root contained in the
- /// repository. The repository is looked up using
- /// the <paramref name="repositoryAssembly"/> specified.
- /// </para>
- /// <para>
- /// Some appenders need to be closed before the application exists.
- /// Otherwise, pending logging events might be lost.
- /// </para>
- /// <para>
- /// The <c>shutdown</c> method is careful to close nested
- /// appenders before closing regular appenders. This is allows
- /// configurations where a regular appender is attached to a logger
- /// and again to a nested appender.
- /// </para>
- /// </remarks>
- /// <param name="repositoryAssembly">The assembly to use to lookup the repository.</param>
- public static void ShutdownRepository(Assembly repositoryAssembly)
- {
- LoggerManager.ShutdownRepository(repositoryAssembly);
- }
+ /// <summary>
+ /// Shuts down the repository specified.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Calling this method will <b>safely</b> close and remove all
+ /// appenders in all the loggers including root contained in the
+ /// repository. The repository is looked up using
+ /// the <paramref name="repositoryAssembly"/> specified.
+ /// </para>
+ /// <para>
+ /// Some appenders need to be closed before the application exists.
+ /// Otherwise, pending logging events might be lost.
+ /// </para>
+ /// <para>
+ /// The <c>shutdown</c> method is careful to close nested
+ /// appenders before closing regular appenders. This is allows
+ /// configurations where a regular appender is attached to a logger
+ /// and again to a nested appender.
+ /// </para>
+ /// </remarks>
+ /// <param name="repositoryAssembly">The assembly to use to lookup the repository.</param>
+ public static void ShutdownRepository(Assembly repositoryAssembly)
+ {
+ LoggerManager.ShutdownRepository(repositoryAssembly);
+ }
#if !NETSTANDARD1_3
- /// <overloads>Reset the configuration of a repository</overloads>
- /// <summary>
- /// Resets all values contained in this repository instance to their defaults.
- /// </summary>
- /// <remarks>
- /// <para>
- /// Resets all values contained in the repository instance to their
- /// defaults. This removes all appenders from all loggers, sets
- /// the level of all non-root loggers to <c>null</c>,
- /// sets their additivity flag to <c>true</c> and sets the level
- /// of the root logger to <see cref="Level.Debug"/>. Moreover,
- /// message disabling is set to its default "off" value.
- /// </para>
- /// </remarks>
- public static void ResetConfiguration()
- {
- ResetConfiguration(Assembly.GetCallingAssembly());
- }
+ /// <overloads>Reset the configuration of a repository</overloads>
+ /// <summary>
+ /// Resets all values contained in this repository instance to their defaults.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Resets all values contained in the repository instance to their
+ /// defaults. This removes all appenders from all loggers, sets
+ /// the level of all non-root loggers to <c>null</c>,
+ /// sets their additivity flag to <c>true</c> and sets the level
+ /// of the root logger to <see cref="Level.Debug"/>. Moreover,
+ /// message disabling is set to its default "off" value.
+ /// </para>
+ /// </remarks>
+ public static void ResetConfiguration()
+ {
+ ResetConfiguration(Assembly.GetCallingAssembly());
+ }
#endif
- /// <summary>
- /// Resets all values contained in this repository instance to their defaults.
- /// </summary>
- /// <remarks>
- /// <para>
- /// Reset all values contained in the repository instance to their
- /// defaults. This removes all appenders from all loggers, sets
- /// the level of all non-root loggers to <c>null</c>,
- /// sets their additivity flag to <c>true</c> and sets the level
- /// of the root logger to <see cref="Level.Debug"/>. Moreover,
- /// message disabling is set to its default "off" value.
- /// </para>
- /// </remarks>
- /// <param name="repository">The repository to reset.</param>
- public static void ResetConfiguration(string repository)
- {
- LoggerManager.ResetConfiguration(repository);
- }
+ /// <summary>
+ /// Resets all values contained in this repository instance to their defaults.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Reset all values contained in the repository instance to their
+ /// defaults. This removes all appenders from all loggers, sets
+ /// the level of all non-root loggers to <c>null</c>,
+ /// sets their additivity flag to <c>true</c> and sets the level
+ /// of the root logger to <see cref="Level.Debug"/>. Moreover,
+ /// message disabling is set to its default "off" value.
+ /// </para>
+ /// </remarks>
+ /// <param name="repository">The repository to reset.</param>
+ public static void ResetConfiguration(string repository)
+ {
+ LoggerManager.ResetConfiguration(repository);
+ }
- /// <summary>
- /// Resets all values contained in this repository instance to their defaults.
- /// </summary>
- /// <remarks>
- /// <para>
- /// Reset all values contained in the repository instance to their
- /// defaults. This removes all appenders from all loggers, sets
- /// the level of all non-root loggers to <c>null</c>,
- /// sets their additivity flag to <c>true</c> and sets the level
- /// of the root logger to <see cref="Level.Debug"/>. Moreover,
- /// message disabling is set to its default "off" value.
- /// </para>
- /// </remarks>
- /// <param name="repositoryAssembly">The assembly to use to lookup the repository to reset.</param>
- public static void ResetConfiguration(Assembly repositoryAssembly)
- {
- LoggerManager.ResetConfiguration(repositoryAssembly);
- }
+ /// <summary>
+ /// Resets all values contained in this repository instance to their defaults.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Reset all values contained in the repository instance to their
+ /// defaults. This removes all appenders from all loggers, sets
+ /// the level of all non-root loggers to <c>null</c>,
+ /// sets their additivity flag to <c>true</c> and sets the level
+ /// of the root logger to <see cref="Level.Debug"/>. Moreover,
+ /// message disabling is set to its default "off" value.
+ /// </para>
+ /// </remarks>
+ /// <param name="repositoryAssembly">The assembly to use to lookup the repository to reset.</param>
+ public static void ResetConfiguration(Assembly repositoryAssembly)
+ {
+ LoggerManager.ResetConfiguration(repositoryAssembly);
+ }
#if !NETSTANDARD1_3
- /// <overloads>Get the logger repository.</overloads>
- /// <summary>
- /// Returns the default <see cref="ILoggerRepository"/> instance.
- /// </summary>
- /// <remarks>
- /// <para>
- /// Gets the <see cref="ILoggerRepository"/> for the repository specified
- /// by the callers assembly (<see cref="M:Assembly.GetCallingAssembly()"/>).
- /// </para>
- /// </remarks>
- /// <returns>The <see cref="ILoggerRepository"/> instance for the default repository.</returns>
- [Obsolete("Use GetRepository instead of GetLoggerRepository")]
- public static ILoggerRepository GetLoggerRepository()
- {
- return GetRepository(Assembly.GetCallingAssembly());
- }
+ /// <overloads>Get the logger repository.</overloads>
+ /// <summary>
+ /// Returns the default <see cref="ILoggerRepository"/> instance.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Gets the <see cref="ILoggerRepository"/> for the repository specified
+ /// by the callers assembly (<see cref="M:Assembly.GetCallingAssembly()"/>).
+ /// </para>
+ /// </remarks>
+ /// <returns>The <see cref="ILoggerRepository"/> instance for the default repository.</returns>
+ [Obsolete("Use GetRepository instead of GetLoggerRepository")]
+ public static ILoggerRepository GetLoggerRepository()
+ {
+ return GetRepository(Assembly.GetCallingAssembly());
+ }
#endif
- /// <summary>
- /// Returns the default <see cref="ILoggerRepository"/> instance.
- /// </summary>
- /// <returns>The default <see cref="ILoggerRepository"/> instance.</returns>
- /// <remarks>
- /// <para>
- /// Gets the <see cref="ILoggerRepository"/> for the repository specified
- /// by the <paramref name="repository"/> argument.
- /// </para>
- /// </remarks>
- /// <param name="repository">The repository to lookup in.</param>
- [Obsolete("Use GetRepository instead of GetLoggerRepository")]
- public static ILoggerRepository GetLoggerRepository(string repository)
- {
- return GetRepository(repository);
- }
+ /// <summary>
+ /// Returns the default <see cref="ILoggerRepository"/> instance.
+ /// </summary>
+ /// <returns>The default <see cref="ILoggerRepository"/> instance.</returns>
+ /// <remarks>
+ /// <para>
+ /// Gets the <see cref="ILoggerRepository"/> for the repository specified
+ /// by the <paramref name="repository"/> argument.
+ /// </para>
+ /// </remarks>
+ /// <param name="repository">The repository to lookup in.</param>
+ [Obsolete("Use GetRepository instead of GetLoggerRepository")]
+ public static ILoggerRepository GetLoggerRepository(string repository)
+ {
+ return GetRepository(repository);
+ }
- /// <summary>
- /// Returns the default <see cref="ILoggerRepository"/> instance.
- /// </summary>
- /// <returns>The default <see cref="ILoggerRepository"/> instance.</returns>
- /// <remarks>
- /// <para>
- /// Gets the <see cref="ILoggerRepository"/> for the repository specified
- /// by the <paramref name="repositoryAssembly"/> argument.
- /// </para>
- /// </remarks>
- /// <param name="repositoryAssembly">The assembly to use to lookup the repository.</param>
- [Obsolete("Use GetRepository instead of GetLoggerRepository")]
- public static ILoggerRepository GetLoggerRepository(Assembly repositoryAssembly)
- {
- return GetRepository(repositoryAssembly);
- }
+ /// <summary>
+ /// Returns the default <see cref="ILoggerRepository"/> instance.
+ /// </summary>
+ /// <returns>The default <see cref="ILoggerRepository"/> instance.</returns>
+ /// <remarks>
+ /// <para>
+ /// Gets the <see cref="ILoggerRepository"/> for the repository specified
+ /// by the <paramref name="repositoryAssembly"/> argument.
+ /// </para>
+ /// </remarks>
+ /// <param name="repositoryAssembly">The assembly to use to lookup the repository.</param>
+ [Obsolete("Use GetRepository instead of GetLoggerRepository")]
+ public static ILoggerRepository GetLoggerRepository(Assembly repositoryAssembly)
+ {
+ return GetRepository(repositoryAssembly);
+ }
#if !NETSTANDARD1_3
- /// <overloads>Get a logger repository.</overloads>
- /// <summary>
- /// Returns the default <see cref="ILoggerRepository"/> instance.
- /// </summary>
- /// <remarks>
- /// <para>
- /// Gets the <see cref="ILoggerRepository"/> for the repository specified
- /// by the callers assembly (<see cref="M:Assembly.GetCallingAssembly()"/>).
- /// </para>
- /// </remarks>
- /// <returns>The <see cref="ILoggerRepository"/> instance for the default repository.</returns>
- public static ILoggerRepository GetRepository()
- {
- return GetRepository(Assembly.GetCallingAssembly());
- }
+ /// <overloads>Get a logger repository.</overloads>
+ /// <summary>
+ /// Returns the default <see cref="ILoggerRepository"/> instance.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Gets the <see cref="ILoggerRepository"/> for the repository specified
+ /// by the callers assembly (<see cref="M:Assembly.GetCallingAssembly()"/>).
+ /// </para>
+ /// </remarks>
+ /// <returns>The <see cref="ILoggerRepository"/> instance for the default repository.</returns>
+ public static ILoggerRepository GetRepository()
+ {
+ return GetRepository(Assembly.GetCallingAssembly());
+ }
#endif
- /// <summary>
- /// Returns the default <see cref="ILoggerRepository"/> instance.
- /// </summary>
- /// <returns>The default <see cref="ILoggerRepository"/> instance.</returns>
- /// <remarks>
- /// <para>
- /// Gets the <see cref="ILoggerRepository"/> for the repository specified
- /// by the <paramref name="repository"/> argument.
- /// </para>
- /// </remarks>
- /// <param name="repository">The repository to lookup in.</param>
- public static ILoggerRepository GetRepository(string repository)
- {
- return LoggerManager.GetRepository(repository);
- }
+ /// <summary>
+ /// Returns the default <see cref="ILoggerRepository"/> instance.
+ /// </summary>
+ /// <returns>The default <see cref="ILoggerRepository"/> instance.</returns>
+ /// <remarks>
+ /// <para>
+ /// Gets the <see cref="ILoggerRepository"/> for the repository specified
+ /// by the <paramref name="repository"/> argument.
+ /// </para>
+ /// </remarks>
+ /// <param name="repository">The repository to lookup in.</param>
+ public static ILoggerRepository GetRepository(string repository)
+ {
+ return LoggerManager.GetRepository(repository);
+ }
- /// <summary>
- /// Returns the default <see cref="ILoggerRepository"/> instance.
- /// </summary>
- /// <returns>The default <see cref="ILoggerRepository"/> instance.</returns>
- /// <remarks>
- /// <para>
- /// Gets the <see cref="ILoggerRepository"/> for the repository specified
- /// by the <paramref name="repositoryAssembly"/> argument.
- /// </para>
- /// </remarks>
- /// <param name="repositoryAssembly">The assembly to use to lookup the repository.</param>
- public static ILoggerRepository GetRepository(Assembly repositoryAssembly)
- {
- return LoggerManager.GetRepository(repositoryAssembly);
- }
+ /// <summary>
+ /// Returns the default <see cref="ILoggerRepository"/> instance.
+ /// </summary>
+ /// <returns>The default <see cref="ILoggerRepository"/> instance.</returns>
+ /// <remarks>
+ /// <para>
+ /// Gets the <see cref="ILoggerRepository"/> for the repository specified
+ /// by the <paramref name="repositoryAssembly"/> argument.
+ /// </para>
+ /// </remarks>
+ /// <param name="repositoryAssembly">The assembly to use to lookup the repository.</param>
+ public static ILoggerRepository GetRepository(Assembly repositoryAssembly)
+ {
+ return LoggerManager.GetRepository(repositoryAssembly);
+ }
#if !NETSTANDARD1_3
- /// <overloads>Create a domain</overloads>
- /// <summary>
- /// Creates a repository with the specified repository type.
- /// </summary>
- /// <remarks>
- /// <para>
- /// <b>CreateDomain is obsolete. Use CreateRepository instead of CreateDomain.</b>
- /// </para>
- /// <para>
- /// The <see cref="ILoggerRepository"/> created will be associated with the repository
- /// specified such that a call to <see cref="M:GetRepository()"/> will return
- /// the same repository instance.
- /// </para>
- /// </remarks>
- /// <param name="repositoryType">A <see cref="Type"/> that implements <see cref="ILoggerRepository"/>
- /// and has a no arg constructor. An instance of this type will be created to act
- /// as the <see cref="ILoggerRepository"/> for the repository specified.</param>
- /// <returns>The <see cref="ILoggerRepository"/> created for the repository.</returns>
- [Obsolete("Use CreateRepository instead of CreateDomain")]
- public static ILoggerRepository CreateDomain(Type repositoryType)
- {
- return CreateRepository(Assembly.GetCallingAssembly(), repositoryType);
- }
+ /// <overloads>Create a domain</overloads>
+ /// <summary>
+ /// Creates a repository with the specified repository type.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// <b>CreateDomain is obsolete. Use CreateRepository instead of CreateDomain.</b>
+ /// </para>
+ /// <para>
+ /// The <see cref="ILoggerRepository"/> created will be associated with the repository
+ /// specified such that a call to <see cref="M:GetRepository()"/> will return
+ /// the same repository instance.
+ /// </para>
+ /// </remarks>
+ /// <param name="repositoryType">A <see cref="Type"/> that implements <see cref="ILoggerRepository"/>
+ /// and has a no arg constructor. An instance of this type will be created to act
+ /// as the <see cref="ILoggerRepository"/> for the repository specified.</param>
+ /// <returns>The <see cref="ILoggerRepository"/> created for the repository.</returns>
+ [Obsolete("Use CreateRepository instead of CreateDomain")]
+ public static ILoggerRepository CreateDomain(Type repositoryType)
+ {
+ return CreateRepository(Assembly.GetCallingAssembly(), repositoryType);
+ }
- /// <overloads>Create a logger repository.</overloads>
- /// <summary>
- /// Creates a repository with the specified repository type.
- /// </summary>
- /// <param name="repositoryType">A <see cref="Type"/> that implements <see cref="ILoggerRepository"/>
- /// and has a no arg constructor. An instance of this type will be created to act
- /// as the <see cref="ILoggerRepository"/> for the repository specified.</param>
- /// <returns>The <see cref="ILoggerRepository"/> created for the repository.</returns>
- /// <remarks>
- /// <para>
- /// The <see cref="ILoggerRepository"/> created will be associated with the repository
- /// specified such that a call to <see cref="M:GetRepository()"/> will return
- /// the same repository instance.
- /// </para>
- /// </remarks>
- public static ILoggerRepository CreateRepository(Type repositoryType)
- {
- return CreateRepository(Assembly.GetCallingAssembly(), repositoryType);
- }
+ /// <overloads>Create a logger repository.</overloads>
+ /// <summary>
+ /// Creates a repository with the specified repository type.
+ /// </summary>
+ /// <param name="repositoryType">A <see cref="Type"/> that implements <see cref="ILoggerRepository"/>
+ /// and has a no arg constructor. An instance of this type will be created to act
+ /// as the <see cref="ILoggerRepository"/> for the repository specified.</param>
+ /// <returns>The <see cref="ILoggerRepository"/> created for the repository.</returns>
+ /// <remarks>
+ /// <para>
+ /// The <see cref="ILoggerRepository"/> created will be associated with the repository
+ /// specified such that a call to <see cref="M:GetRepository()"/> will return
+ /// the same repository instance.
+ /// </para>
+ /// </remarks>
+ public static ILoggerRepository CreateRepository(Type repositoryType)
+ {
+ return CreateRepository(Assembly.GetCallingAssembly(), repositoryType);
+ }
#endif
- /// <summary>
- /// Creates a repository with the specified name.
- /// </summary>
- /// <remarks>
- /// <para>
- /// <b>CreateDomain is obsolete. Use CreateRepository instead of CreateDomain.</b>
- /// </para>
- /// <para>
- /// Creates the default type of <see cref="ILoggerRepository"/> which is a
- /// <see cref="log4net.Repository.Hierarchy.Hierarchy"/> object.
- /// </para>
- /// <para>
- /// The <paramref name="repository"/> name must be unique. Repositories cannot be redefined.
- /// An <see cref="Exception"/> will be thrown if the repository already exists.
- /// </para>
- /// </remarks>
- /// <param name="repository">The name of the repository, this must be unique amongst repositories.</param>
- /// <returns>The <see cref="ILoggerRepository"/> created for the repository.</returns>
- /// <exception cref="LogException">The specified repository already exists.</exception>
- [Obsolete("Use CreateRepository instead of CreateDomain")]
- public static ILoggerRepository CreateDomain(string repository)
- {
- return LoggerManager.CreateRepository(repository);
- }
+ /// <summary>
+ /// Creates a repository with the specified name.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// <b>CreateDomain is obsolete. Use CreateRepository instead of CreateDomain.</b>
+ /// </para>
+ /// <para>
+ /// Creates the default type of <see cref="ILoggerRepository"/> which is a
+ /// <see cref="log4net.Repository.Hierarchy.Hierarchy"/> object.
+ /// </para>
+ /// <para>
+ /// The <paramref name="repository"/> name must be unique. Repositories cannot be redefined.
+ /// An <see cref="Exception"/> will be thrown if the repository already exists.
+ /// </para>
+ /// </remarks>
+ /// <param name="repository">The name of the repository, this must be unique amongst repositories.</param>
+ /// <returns>The <see cref="ILoggerRepository"/> created for the repository.</returns>
+ /// <exception cref="LogException">The specified repository already exists.</exception>
+ [Obsolete("Use CreateRepository instead of CreateDomain")]
+ public static ILoggerRepository CreateDomain(string repository)
+ {
+ return LoggerManager.CreateRepository(repository);
+ }
- /// <summary>
- /// Creates a repository with the specified name.
- /// </summary>
- /// <remarks>
- /// <para>
- /// Creates the default type of <see cref="ILoggerRepository"/> which is a
- /// <see cref="log4net.Repository.Hierarchy.Hierarchy"/> object.
- /// </para>
- /// <para>
- /// The <paramref name="repository"/> name must be unique. Repositories cannot be redefined.
- /// An <see cref="Exception"/> will be thrown if the repository already exists.
- /// </para>
- /// </remarks>
- /// <param name="repository">The name of the repository, this must be unique amongst repositories.</param>
- /// <returns>The <see cref="ILoggerRepository"/> created for the repository.</returns>
- /// <exception cref="LogException">The specified repository already exists.</exception>
- public static ILoggerRepository CreateRepository(string repository)
- {
- return LoggerManager.CreateRepository(repository);
- }
+ /// <summary>
+ /// Creates a repository with the specified name.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Creates the default type of <see cref="ILoggerRepository"/> which is a
+ /// <see cref="log4net.Repository.Hierarchy.Hierarchy"/> object.
+ /// </para>
+ /// <para>
+ /// The <paramref name="repository"/> name must be unique. Repositories cannot be redefined.
+ /// An <see cref="Exception"/> will be thrown if the repository already exists.
+ /// </para>
+ /// </remarks>
+ /// <param name="repository">The name of the repository, this must be unique amongst repositories.</param>
+ /// <returns>The <see cref="ILoggerRepository"/> created for the repository.</returns>
+ /// <exception cref="LogException">The specified repository already exists.</exception>
+ public static ILoggerRepository CreateRepository(string repository)
+ {
+ return LoggerManager.CreateRepository(repository);
+ }
- /// <summary>
- /// Creates a repository with the specified name and repository type.
- /// </summary>
- /// <remarks>
- /// <para>
- /// <b>CreateDomain is obsolete. Use CreateRepository instead of CreateDomain.</b>
- /// </para>
- /// <para>
- /// The <paramref name="repository"/> name must be unique. Repositories cannot be redefined.
- /// An <see cref="Exception"/> will be thrown if the repository already exists.
- /// </para>
- /// </remarks>
- /// <param name="repository">The name of the repository, this must be unique to the repository.</param>
- /// <param name="repositoryType">A <see cref="Type"/> that implements <see cref="ILoggerRepository"/>
- /// and has a no arg constructor. An instance of this type will be created to act
- /// as the <see cref="ILoggerRepository"/> for the repository specified.</param>
- /// <returns>The <see cref="ILoggerRepository"/> created for the repository.</returns>
- /// <exception cref="LogException">The specified repository already exists.</exception>
- [Obsolete("Use CreateRepository instead of CreateDomain")]
- public static ILoggerRepository CreateDomain(string repository, Type repositoryType)
- {
- return LoggerManager.CreateRepository(repository, repositoryType);
- }
+ /// <summary>
+ /// Creates a repository with the specified name and repository type.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// <b>CreateDomain is obsolete. Use CreateRepository instead of CreateDomain.</b>
+ /// </para>
+ /// <para>
+ /// The <paramref name="repository"/> name must be unique. Repositories cannot be redefined.
+ /// An <see cref="Exception"/> will be thrown if the repository already exists.
+ /// </para>
+ /// </remarks>
+ /// <param name="repository">The name of the repository, this must be unique to the repository.</param>
+ /// <param name="repositoryType">A <see cref="Type"/> that implements <see cref="ILoggerRepository"/>
+ /// and has a no arg constructor. An instance of this type will be created to act
+ /// as the <see cref="ILoggerRepository"/> for the repository specified.</param>
+ /// <returns>The <see cref="ILoggerRepository"/> created for the repository.</returns>
+ /// <exception cref="LogException">The specified repository already exists.</exception>
+ [Obsolete("Use CreateRepository instead of CreateDomain")]
+ public static ILoggerRepository CreateDomain(string repository, Type repositoryType)
+ {
+ return LoggerManager.CreateRepository(repository, repositoryType);
+ }
- /// <summary>
- /// Creates a repository with the specified name and repository type.
- /// </summary>
- /// <remarks>
- /// <para>
- /// The <paramref name="repository"/> name must be unique. Repositories cannot be redefined.
- /// An <see cref="Exception"/> will be thrown if the repository already exists.
- /// </para>
- /// </remarks>
- /// <param name="repository">The name of the repository, this must be unique to the repository.</param>
- /// <param name="repositoryType">A <see cref="Type"/> that implements <see cref="ILoggerRepository"/>
- /// and has a no arg constructor. An instance of this type will be created to act
- /// as the <see cref="ILoggerRepository"/> for the repository specified.</param>
- /// <returns>The <see cref="ILoggerRepository"/> created for the repository.</returns>
- /// <exception cref="LogException">The specified repository already exists.</exception>
- public static ILoggerRepository CreateRepository(string repository, Type repositoryType)
- {
- return LoggerManager.CreateRepository(repository, repositoryType);
- }
+ /// <summary>
+ /// Creates a repository with the specified name and repository type.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// The <paramref name="repository"/> name must be unique. Repositories cannot be redefined.
+ /// An <see cref="Exception"/> will be thrown if the repository already exists.
+ /// </para>
+ /// </remarks>
+ /// <param name="repository">The name of the repository, this must be unique to the repository.</param>
+ /// <param name="repositoryType">A <see cref="Type"/> that implements <see cref="ILoggerRepository"/>
+ /// and has a no arg constructor. An instance of this type will be created to act
+ /// as the <see cref="ILoggerRepository"/> for the repository specified.</param>
+ /// <returns>The <see cref="ILoggerRepository"/> created for the repository.</returns>
+ /// <exception cref="LogException">The specified repository already exists.</exception>
+ public static ILoggerRepository CreateRepository(string repository, Type repositoryType)
+ {
+ return LoggerManager.CreateRepository(repository, repositoryType);
+ }
- /// <summary>
- /// Creates a repository for the specified assembly and repository type.
- /// </summary>
- /// <remarks>
- /// <para>
- /// <b>CreateDomain is obsolete. Use CreateRepository instead of CreateDomain.</b>
- /// </para>
- /// <para>
- /// The <see cref="ILoggerRepository"/> created will be associated with the repository
- /// specified such that a call to <see cref="M:GetRepository(Assembly)"/> with the
- /// same assembly specified will return the same repository instance.
- /// </para>
- /// </remarks>
- /// <param name="repositoryAssembly">The assembly to use to get the name of the repository.</param>
- /// <param name="repositoryType">A <see cref="Type"/> that implements <see cref="ILoggerRepository"/>
- /// and has a no arg constructor. An instance of this type will be created to act
- /// as the <see cref="ILoggerRepository"/> for the repository specified.</param>
- /// <returns>The <see cref="ILoggerRepository"/> created for the repository.</returns>
- [Obsolete("Use CreateRepository instead of CreateDomain")]
- public static ILoggerRepository CreateDomain(Assembly repositoryAssembly, Type repositoryType)
- {
- return LoggerManager.CreateRepository(repositoryAssembly, repositoryType);
- }
+ /// <summary>
+ /// Creates a repository for the specified assembly and repository type.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// <b>CreateDomain is obsolete. Use CreateRepository instead of CreateDomain.</b>
+ /// </para>
+ /// <para>
+ /// The <see cref="ILoggerRepository"/> created will be associated with the repository
+ /// specified such that a call to <see cref="M:GetRepository(Assembly)"/> with the
+ /// same assembly specified will return the same repository instance.
+ /// </para>
+ /// </remarks>
+ /// <param name="repositoryAssembly">The assembly to use to get the name of the repository.</param>
+ /// <param name="repositoryType">A <see cref="Type"/> that implements <see cref="ILoggerRepository"/>
+ /// and has a no arg constructor. An instance of this type will be created to act
+ /// as the <see cref="ILoggerRepository"/> for the repository specified.</param>
+ /// <returns>The <see cref="ILoggerRepository"/> created for the repository.</returns>
+ [Obsolete("Use CreateRepository instead of CreateDomain")]
+ public static ILoggerRepository CreateDomain(Assembly repositoryAssembly, Type repositoryType)
+ {
+ return LoggerManager.CreateRepository(repositoryAssembly, repositoryType);
+ }
- /// <summary>
- /// Creates a repository for the specified assembly and repository type.
- /// </summary>
- /// <remarks>
- /// <para>
- /// The <see cref="ILoggerRepository"/> created will be associated with the repository
- /// specified such that a call to <see cref="M:GetRepository(Assembly)"/> with the
- /// same assembly specified will return the same repository instance.
- /// </para>
- /// </remarks>
- /// <param name="repositoryAssembly">The assembly to use to get the name of the repository.</param>
- /// <param name="repositoryType">A <see cref="Type"/> that implements <see cref="ILoggerRepository"/>
- /// and has a no arg constructor. An instance of this type will be created to act
- /// as the <see cref="ILoggerRepository"/> for the repository specified.</param>
- /// <returns>The <see cref="ILoggerRepository"/> created for the repository.</returns>
- public static ILoggerRepository CreateRepository(Assembly repositoryAssembly, Type repositoryType)
- {
- return LoggerManager.CreateRepository(repositoryAssembly, repositoryType);
- }
+ /// <summary>
+ /// Creates a repository for the specified assembly and repository type.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// The <see cref="ILoggerRepository"/> created will be associated with the repository
+ /// specified such that a call to <see cref="M:GetRepository(Assembly)"/> with the
+ /// same assembly specified will return the same repository instance.
+ /// </para>
+ /// </remarks>
+ /// <param name="repositoryAssembly">The assembly to use to get the name of the repository.</param>
+ /// <param name="repositoryType">A <see cref="Type"/> that implements <see cref="ILoggerRepository"/>
+ /// and has a no arg constructor. An instance of this type will be created to act
+ /// as the <see cref="ILoggerRepository"/> for the repository specified.</param>
+ /// <returns>The <see cref="ILoggerRepository"/> created for the repository.</returns>
+ public static ILoggerRepository CreateRepository(Assembly repositoryAssembly, Type repositoryType)
+ {
+ return LoggerManager.CreateRepository(repositoryAssembly, repositoryType);
+ }
- /// <summary>
- /// Gets the list of currently defined repositories.
- /// </summary>
- /// <remarks>
- /// <para>
- /// Get an array of all the <see cref="ILoggerRepository"/> objects that have been created.
- /// </para>
- /// </remarks>
- /// <returns>An array of all the known <see cref="ILoggerRepository"/> objects.</returns>
- public static ILoggerRepository[] GetAllRepositories()
- {
- return LoggerManager.GetAllRepositories();
- }
+ /// <summary>
+ /// Gets the list of currently defined repositories.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Get an array of all the <see cref="ILoggerRepository"/> objects that have been created.
+ /// </para>
+ /// </remarks>
+ /// <returns>An array of all the known <see cref="ILoggerRepository"/> objects.</returns>
+ public static ILoggerRepository[] GetAllRepositories()
+ {
+ return LoggerManager.GetAllRepositories();
+ }
/// <summary>
/// Flushes logging events buffered in all configured appenders in the default repository.
@@ -773,55 +773,55 @@
#endif
}
- #endregion Domain & Repository Manager Methods
+ #endregion Domain & Repository Manager Methods
- #region Extension Handlers
+ #region Extension Handlers
- /// <summary>
- /// Looks up the wrapper object for the logger specified.
- /// </summary>
- /// <param name="logger">The logger to get the wrapper for.</param>
- /// <returns>The wrapper for the logger specified.</returns>
- private static ILog WrapLogger(ILogger logger)
- {
- return (ILog)s_wrapperMap.GetWrapper(logger);
- }
+ /// <summary>
+ /// Looks up the wrapper object for the logger specified.
+ /// </summary>
+ /// <param name="logger">The logger to get the wrapper for.</param>
+ /// <returns>The wrapper for the logger specified.</returns>
+ private static ILog WrapLogger(ILogger logger)
+ {
+ return (ILog)s_wrapperMap.GetWrapper(logger);
+ }
- /// <summary>
- /// Looks up the wrapper objects for the loggers specified.
- /// </summary>
- /// <param name="loggers">The loggers to get the wrappers for.</param>
- /// <returns>The wrapper objects for the loggers specified.</returns>
- private static ILog[] WrapLoggers(ILogger[] loggers)
- {
- ILog[] results = new ILog[loggers.Length];
- for(int i=0; i<loggers.Length; i++)
- {
- results[i] = WrapLogger(loggers[i]);
- }
- return results;
- }
+ /// <summary>
+ /// Looks up the wrapper objects for the loggers specified.
+ /// </summary>
+ /// <param name="loggers">The loggers to get the wrappers for.</param>
+ /// <returns>The wrapper objects for the loggers specified.</returns>
+ private static ILog[] WrapLoggers(ILogger[] loggers)
+ {
+ ILog[] results = new ILog[loggers.Length];
+ for(int i=0; i<loggers.Length; i++)
+ {
+ results[i] = WrapLogger(loggers[i]);
+ }
+ return results;
+ }
- /// <summary>
- /// Create the <see cref="ILoggerWrapper"/> objects used by
- /// this manager.
- /// </summary>
- /// <param name="logger">The logger to wrap.</param>
- /// <returns>The wrapper for the logger specified.</returns>
- private static ILoggerWrapper WrapperCreationHandler(ILogger logger)
- {
- return new LogImpl(logger);
- }
+ /// <summary>
+ /// Create the <see cref="ILoggerWrapper"/> objects used by
+ /// this manager.
+ /// </summary>
+ /// <param name="logger">The logger to wrap.</param>
+ /// <returns>The wrapper for the logger specified.</returns>
+ private static ILoggerWrapper WrapperCreationHandler(ILogger logger)
+ {
+ return new LogImpl(logger);
+ }
- #endregion
+ #endregion
- #region Private Static Fields
+ #region Private Static Fields
- /// <summary>
- /// The wrapper map to use to hold the <see cref="LogImpl"/> objects.
- /// </summary>
- private static readonly WrapperMap s_wrapperMap = new WrapperMap(new WrapperCreationHandler(WrapperCreationHandler));
+ /// <summary>
+ /// The wrapper map to use to hold the <see cref="LogImpl"/> objects.
+ /// </summary>
+ private static readonly WrapperMap s_wrapperMap = new WrapperMap(new WrapperCreationHandler(WrapperCreationHandler));
- #endregion Private Static Fields
- }
+ #endregion Private Static Fields
+ }
}
diff --git a/src/log4net/LogicalThreadContext.cs b/src/log4net/LogicalThreadContext.cs
index 937f952..79da8fc 100644
--- a/src/log4net/LogicalThreadContext.cs
+++ b/src/log4net/LogicalThreadContext.cs
@@ -24,130 +24,130 @@
namespace log4net
{
- /// <summary>
- /// The log4net Logical Thread Context.
- /// </summary>
- /// <remarks>
- /// <para>
- /// The <c>LogicalThreadContext</c> provides a location for <see cref="System.Runtime.Remoting.Messaging.CallContext"/> specific debugging
- /// information to be stored.
- /// The <c>LogicalThreadContext</c> properties override any <see cref="ThreadContext"/> or <see cref="GlobalContext"/>
- /// properties with the same name.
- /// </para>
- /// <para>
- /// For .NET Standard 1.3 this class uses
- /// System.Threading.AsyncLocal rather than <see
- /// cref="System.Runtime.Remoting.Messaging.CallContext"/>.
- /// </para>
- /// <para>
- /// The Logical Thread Context has a properties map and a stack.
- /// The properties and stack can
- /// be included in the output of log messages. The <see cref="log4net.Layout.PatternLayout"/>
- /// supports selecting and outputting these properties.
- /// </para>
- /// <para>
- /// The Logical Thread Context provides a diagnostic context for the current call context.
- /// This is an instrument for distinguishing interleaved log
- /// output from different sources. Log output is typically interleaved
- /// when a server handles multiple clients near-simultaneously.
- /// </para>
- /// <para>
- /// The Logical Thread Context is managed on a per <see cref="System.Runtime.Remoting.Messaging.CallContext"/> basis.
- /// </para>
- /// <para>
- /// The <see cref="System.Runtime.Remoting.Messaging.CallContext"/> requires a link time
- /// <see cref="System.Security.Permissions.SecurityPermission"/> for the
- /// <see cref="System.Security.Permissions.SecurityPermissionFlag.Infrastructure"/>.
- /// If the calling code does not have this permission then this context will be disabled.
- /// It will not store any property values set on it.
- /// </para>
- /// </remarks>
- /// <example>Example of using the thread context properties to store a username.
- /// <code lang="C#">
- /// LogicalThreadContext.Properties["user"] = userName;
- /// log.Info("This log message has a LogicalThreadContext Property called 'user'");
- /// </code>
- /// </example>
- /// <example>Example of how to push a message into the context stack
- /// <code lang="C#">
- /// using(LogicalThreadContext.Stacks["LDC"].Push("my context message"))
- /// {
- /// log.Info("This log message has a LogicalThreadContext Stack message that includes 'my context message'");
- ///
- /// } // at the end of the using block the message is automatically popped
- /// </code>
- /// </example>
- /// <threadsafety static="true" instance="true" />
- /// <author>Nicko Cadell</author>
- public sealed class LogicalThreadContext
- {
- #region Private Instance Constructors
+ /// <summary>
+ /// The log4net Logical Thread Context.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// The <c>LogicalThreadContext</c> provides a location for <see cref="System.Runtime.Remoting.Messaging.CallContext"/> specific debugging
+ /// information to be stored.
+ /// The <c>LogicalThreadContext</c> properties override any <see cref="ThreadContext"/> or <see cref="GlobalContext"/>
+ /// properties with the same name.
+ /// </para>
+ /// <para>
+ /// For .NET Standard 1.3 this class uses
+ /// System.Threading.AsyncLocal rather than <see
+ /// cref="System.Runtime.Remoting.Messaging.CallContext"/>.
+ /// </para>
+ /// <para>
+ /// The Logical Thread Context has a properties map and a stack.
+ /// The properties and stack can
+ /// be included in the output of log messages. The <see cref="log4net.Layout.PatternLayout"/>
+ /// supports selecting and outputting these properties.
+ /// </para>
+ /// <para>
+ /// The Logical Thread Context provides a diagnostic context for the current call context.
+ /// This is an instrument for distinguishing interleaved log
+ /// output from different sources. Log output is typically interleaved
+ /// when a server handles multiple clients near-simultaneously.
+ /// </para>
+ /// <para>
+ /// The Logical Thread Context is managed on a per <see cref="System.Runtime.Remoting.Messaging.CallContext"/> basis.
+ /// </para>
+ /// <para>
+ /// The <see cref="System.Runtime.Remoting.Messaging.CallContext"/> requires a link time
+ /// <see cref="System.Security.Permissions.SecurityPermission"/> for the
+ /// <see cref="System.Security.Permissions.SecurityPermissionFlag.Infrastructure"/>.
+ /// If the calling code does not have this permission then this context will be disabled.
+ /// It will not store any property values set on it.
+ /// </para>
+ /// </remarks>
+ /// <example>Example of using the thread context properties to store a username.
+ /// <code lang="C#">
+ /// LogicalThreadContext.Properties["user"] = userName;
+ /// log.Info("This log message has a LogicalThreadContext Property called 'user'");
+ /// </code>
+ /// </example>
+ /// <example>Example of how to push a message into the context stack
+ /// <code lang="C#">
+ /// using(LogicalThreadContext.Stacks["LDC"].Push("my context message"))
+ /// {
+ /// log.Info("This log message has a LogicalThreadContext Stack message that includes 'my context message'");
+ ///
+ /// } // at the end of the using block the message is automatically popped
+ /// </code>
+ /// </example>
+ /// <threadsafety static="true" instance="true" />
+ /// <author>Nicko Cadell</author>
+ public sealed class LogicalThreadContext
+ {
+ #region Private Instance Constructors
- /// <summary>
- /// Private Constructor.
- /// </summary>
- /// <remarks>
- /// <para>
- /// Uses a private access modifier to prevent instantiation of this class.
- /// </para>
- /// </remarks>
- private LogicalThreadContext()
- {
- }
+ /// <summary>
+ /// Private Constructor.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Uses a private access modifier to prevent instantiation of this class.
+ /// </para>
+ /// </remarks>
+ private LogicalThreadContext()
+ {
+ }
- #endregion Private Instance Constructors
+ #endregion Private Instance Constructors
- #region Public Static Properties
+ #region Public Static Properties
- /// <summary>
- /// The thread properties map
- /// </summary>
- /// <value>
- /// The thread properties map
- /// </value>
- /// <remarks>
- /// <para>
- /// The <c>LogicalThreadContext</c> properties override any <see cref="ThreadContext"/>
- /// or <see cref="GlobalContext"/> properties with the same name.
- /// </para>
- /// </remarks>
- public static LogicalThreadContextProperties Properties
- {
- get { return s_properties; }
- }
+ /// <summary>
+ /// The thread properties map
+ /// </summary>
+ /// <value>
+ /// The thread properties map
+ /// </value>
+ /// <remarks>
+ /// <para>
+ /// The <c>LogicalThreadContext</c> properties override any <see cref="ThreadContext"/>
+ /// or <see cref="GlobalContext"/> properties with the same name.
+ /// </para>
+ /// </remarks>
+ public static LogicalThreadContextProperties Properties
+ {
+ get { return s_properties; }
+ }
- /// <summary>
- /// The thread stacks
- /// </summary>
- /// <value>
- /// stack map
- /// </value>
- /// <remarks>
- /// <para>
- /// The logical thread stacks.
- /// </para>
- /// </remarks>
- public static LogicalThreadContextStacks Stacks
- {
- get { return s_stacks; }
- }
+ /// <summary>
+ /// The thread stacks
+ /// </summary>
+ /// <value>
+ /// stack map
+ /// </value>
+ /// <remarks>
+ /// <para>
+ /// The logical thread stacks.
+ /// </para>
+ /// </remarks>
+ public static LogicalThreadContextStacks Stacks
+ {
+ get { return s_stacks; }
+ }
- #endregion Public Static Properties
+ #endregion Public Static Properties
- #region Private Static Fields
+ #region Private Static Fields
- /// <summary>
- /// The thread context properties instance
- /// </summary>
- private static readonly LogicalThreadContextProperties s_properties = new LogicalThreadContextProperties();
+ /// <summary>
+ /// The thread context properties instance
+ /// </summary>
+ private static readonly LogicalThreadContextProperties s_properties = new LogicalThreadContextProperties();
- /// <summary>
- /// The thread context stacks instance
- /// </summary>
- private static readonly LogicalThreadContextStacks s_stacks = new LogicalThreadContextStacks(s_properties);
+ /// <summary>
+ /// The thread context stacks instance
+ /// </summary>
+ private static readonly LogicalThreadContextStacks s_stacks = new LogicalThreadContextStacks(s_properties);
- #endregion Private Static Fields
- }
+ #endregion Private Static Fields
+ }
}
#endif
\ No newline at end of file
diff --git a/src/log4net/MDC.cs b/src/log4net/MDC.cs
index 06e1b1d..f0d2531 100644
--- a/src/log4net/MDC.cs
+++ b/src/log4net/MDC.cs
@@ -22,148 +22,148 @@
namespace log4net
{
- /// <summary>
- /// Implementation of Mapped Diagnostic Contexts.
- /// </summary>
- /// <remarks>
- /// <note>
- /// <para>
- /// The MDC is deprecated and has been replaced by the <see cref="ThreadContext.Properties"/>.
- /// The current MDC implementation forwards to the <c>ThreadContext.Properties</c>.
- /// </para>
- /// </note>
- /// <para>
- /// The MDC class is similar to the <see cref="NDC"/> class except that it is
- /// based on a map instead of a stack. It provides <i>mapped
- /// diagnostic contexts</i>. A <i>Mapped Diagnostic Context</i>, or
- /// MDC in short, is an instrument for distinguishing interleaved log
- /// output from different sources. Log output is typically interleaved
- /// when a server handles multiple clients near-simultaneously.
- /// </para>
- /// <para>
- /// The MDC is managed on a per thread basis.
- /// </para>
- /// </remarks>
- /// <threadsafety static="true" instance="true" />
- /// <author>Nicko Cadell</author>
- /// <author>Gert Driesen</author>
- /*[Obsolete("MDC has been replaced by ThreadContext.Properties")]*/
- public sealed class MDC
- {
- #region Private Instance Constructors
+ /// <summary>
+ /// Implementation of Mapped Diagnostic Contexts.
+ /// </summary>
+ /// <remarks>
+ /// <note>
+ /// <para>
+ /// The MDC is deprecated and has been replaced by the <see cref="ThreadContext.Properties"/>.
+ /// The current MDC implementation forwards to the <c>ThreadContext.Properties</c>.
+ /// </para>
+ /// </note>
+ /// <para>
+ /// The MDC class is similar to the <see cref="NDC"/> class except that it is
+ /// based on a map instead of a stack. It provides <i>mapped
+ /// diagnostic contexts</i>. A <i>Mapped Diagnostic Context</i>, or
+ /// MDC in short, is an instrument for distinguishing interleaved log
+ /// output from different sources. Log output is typically interleaved
+ /// when a server handles multiple clients near-simultaneously.
+ /// </para>
+ /// <para>
+ /// The MDC is managed on a per thread basis.
+ /// </para>
+ /// </remarks>
+ /// <threadsafety static="true" instance="true" />
+ /// <author>Nicko Cadell</author>
+ /// <author>Gert Driesen</author>
+ /*[Obsolete("MDC has been replaced by ThreadContext.Properties")]*/
+ public sealed class MDC
+ {
+ #region Private Instance Constructors
- /// <summary>
- /// Initializes a new instance of the <see cref="MDC" /> class.
- /// </summary>
- /// <remarks>
- /// Uses a private access modifier to prevent instantiation of this class.
- /// </remarks>
- private MDC()
- {
- }
+ /// <summary>
+ /// Initializes a new instance of the <see cref="MDC" /> class.
+ /// </summary>
+ /// <remarks>
+ /// Uses a private access modifier to prevent instantiation of this class.
+ /// </remarks>
+ private MDC()
+ {
+ }
- #endregion Private Instance Constructors
+ #endregion Private Instance Constructors
- #region Public Static Methods
+ #region Public Static Methods
- /// <summary>
- /// Gets the context value identified by the <paramref name="key" /> parameter.
- /// </summary>
- /// <param name="key">The key to lookup in the MDC.</param>
- /// <returns>The string value held for the key, or a <c>null</c> reference if no corresponding value is found.</returns>
- /// <remarks>
- /// <note>
- /// <para>
- /// The MDC is deprecated and has been replaced by the <see cref="ThreadContext.Properties"/>.
- /// The current MDC implementation forwards to the <c>ThreadContext.Properties</c>.
- /// </para>
- /// </note>
- /// <para>
- /// If the <paramref name="key" /> parameter does not look up to a
- /// previously defined context then <c>null</c> will be returned.
- /// </para>
- /// </remarks>
- /*[Obsolete("MDC has been replaced by ThreadContext.Properties")]*/
- public static string Get(string key)
- {
- object obj = ThreadContext.Properties[key];
- if (obj == null)
- {
- return null;
- }
- return obj.ToString();
- }
+ /// <summary>
+ /// Gets the context value identified by the <paramref name="key" /> parameter.
+ /// </summary>
+ /// <param name="key">The key to lookup in the MDC.</param>
+ /// <returns>The string value held for the key, or a <c>null</c> reference if no corresponding value is found.</returns>
+ /// <remarks>
+ /// <note>
+ /// <para>
+ /// The MDC is deprecated and has been replaced by the <see cref="ThreadContext.Properties"/>.
+ /// The current MDC implementation forwards to the <c>ThreadContext.Properties</c>.
+ /// </para>
+ /// </note>
+ /// <para>
+ /// If the <paramref name="key" /> parameter does not look up to a
+ /// previously defined context then <c>null</c> will be returned.
+ /// </para>
+ /// </remarks>
+ /*[Obsolete("MDC has been replaced by ThreadContext.Properties")]*/
+ public static string Get(string key)
+ {
+ object obj = ThreadContext.Properties[key];
+ if (obj == null)
+ {
+ return null;
+ }
+ return obj.ToString();
+ }
- /// <summary>
- /// Add an entry to the MDC
- /// </summary>
- /// <param name="key">The key to store the value under.</param>
- /// <param name="value">The value to store.</param>
- /// <remarks>
- /// <note>
- /// <para>
- /// The MDC is deprecated and has been replaced by the <see cref="ThreadContext.Properties"/>.
- /// The current MDC implementation forwards to the <c>ThreadContext.Properties</c>.
- /// </para>
- /// </note>
- /// <para>
- /// Puts a context value (the <paramref name="value" /> parameter) as identified
- /// with the <paramref name="key" /> parameter into the current thread's
- /// context map.
- /// </para>
- /// <para>
- /// If a value is already defined for the <paramref name="key" />
- /// specified then the value will be replaced. If the <paramref name="value" />
- /// is specified as <c>null</c> then the key value mapping will be removed.
- /// </para>
- /// </remarks>
- /*[Obsolete("MDC has been replaced by ThreadContext.Properties")]*/
- public static void Set(string key, string value)
- {
- ThreadContext.Properties[key] = value;
- }
+ /// <summary>
+ /// Add an entry to the MDC
+ /// </summary>
+ /// <param name="key">The key to store the value under.</param>
+ /// <param name="value">The value to store.</param>
+ /// <remarks>
+ /// <note>
+ /// <para>
+ /// The MDC is deprecated and has been replaced by the <see cref="ThreadContext.Properties"/>.
+ /// The current MDC implementation forwards to the <c>ThreadContext.Properties</c>.
+ /// </para>
+ /// </note>
+ /// <para>
+ /// Puts a context value (the <paramref name="value" /> parameter) as identified
+ /// with the <paramref name="key" /> parameter into the current thread's
+ /// context map.
+ /// </para>
+ /// <para>
+ /// If a value is already defined for the <paramref name="key" />
+ /// specified then the value will be replaced. If the <paramref name="value" />
+ /// is specified as <c>null</c> then the key value mapping will be removed.
+ /// </para>
+ /// </remarks>
+ /*[Obsolete("MDC has been replaced by ThreadContext.Properties")]*/
+ public static void Set(string key, string value)
+ {
+ ThreadContext.Properties[key] = value;
+ }
- /// <summary>
- /// Removes the key value mapping for the key specified.
- /// </summary>
- /// <param name="key">The key to remove.</param>
- /// <remarks>
- /// <note>
- /// <para>
- /// The MDC is deprecated and has been replaced by the <see cref="ThreadContext.Properties"/>.
- /// The current MDC implementation forwards to the <c>ThreadContext.Properties</c>.
- /// </para>
- /// </note>
- /// <para>
- /// Remove the specified entry from this thread's MDC
- /// </para>
- /// </remarks>
- /*[Obsolete("MDC has been replaced by ThreadContext.Properties")]*/
- public static void Remove(string key)
- {
- ThreadContext.Properties.Remove(key);
- }
+ /// <summary>
+ /// Removes the key value mapping for the key specified.
+ /// </summary>
+ /// <param name="key">The key to remove.</param>
+ /// <remarks>
+ /// <note>
+ /// <para>
+ /// The MDC is deprecated and has been replaced by the <see cref="ThreadContext.Properties"/>.
+ /// The current MDC implementation forwards to the <c>ThreadContext.Properties</c>.
+ /// </para>
+ /// </note>
+ /// <para>
+ /// Remove the specified entry from this thread's MDC
+ /// </para>
+ /// </remarks>
+ /*[Obsolete("MDC has been replaced by ThreadContext.Properties")]*/
+ public static void Remove(string key)
+ {
+ ThreadContext.Properties.Remove(key);
+ }
- /// <summary>
- /// Clear all entries in the MDC
- /// </summary>
- /// <remarks>
- /// <note>
- /// <para>
- /// The MDC is deprecated and has been replaced by the <see cref="ThreadContext.Properties"/>.
- /// The current MDC implementation forwards to the <c>ThreadContext.Properties</c>.
- /// </para>
- /// </note>
- /// <para>
- /// Remove all the entries from this thread's MDC
- /// </para>
- /// </remarks>
- /*[Obsolete("MDC has been replaced by ThreadContext.Properties")]*/
- public static void Clear()
- {
- ThreadContext.Properties.Clear();
- }
+ /// <summary>
+ /// Clear all entries in the MDC
+ /// </summary>
+ /// <remarks>
+ /// <note>
+ /// <para>
+ /// The MDC is deprecated and has been replaced by the <see cref="ThreadContext.Properties"/>.
+ /// The current MDC implementation forwards to the <c>ThreadContext.Properties</c>.
+ /// </para>
+ /// </note>
+ /// <para>
+ /// Remove all the entries from this thread's MDC
+ /// </para>
+ /// </remarks>
+ /*[Obsolete("MDC has been replaced by ThreadContext.Properties")]*/
+ public static void Clear()
+ {
+ ThreadContext.Properties.Clear();
+ }
- #endregion Public Static Methods
- }
+ #endregion Public Static Methods
+ }
}
diff --git a/src/log4net/NDC.cs b/src/log4net/NDC.cs
index 6b79619..1c4c7b1 100644
--- a/src/log4net/NDC.cs
+++ b/src/log4net/NDC.cs
@@ -26,324 +26,324 @@
namespace log4net
{
- /// <summary>
- /// Implementation of Nested Diagnostic Contexts.
- /// </summary>
- /// <remarks>
- /// <note>
- /// <para>
- /// The NDC is deprecated and has been replaced by the <see cref="ThreadContext.Stacks"/>.
- /// The current NDC implementation forwards to the <c>ThreadContext.Stacks["NDC"]</c>.
- /// </para>
- /// </note>
- /// <para>
- /// A Nested Diagnostic Context, or NDC in short, is an instrument
- /// to distinguish interleaved log output from different sources. Log
- /// output is typically interleaved when a server handles multiple
- /// clients near-simultaneously.
- /// </para>
- /// <para>
- /// Interleaved log output can still be meaningful if each log entry
- /// from different contexts had a distinctive stamp. This is where NDCs
- /// come into play.
- /// </para>
- /// <para>
- /// Note that NDCs are managed on a per thread basis. The NDC class
- /// is made up of static methods that operate on the context of the
- /// calling thread.
- /// </para>
- /// </remarks>
- /// <example>How to push a message into the context
- /// <code lang="C#">
- /// using(NDC.Push("my context message"))
- /// {
- /// ... all log calls will have 'my context message' included ...
- ///
- /// } // at the end of the using block the message is automatically removed
- /// </code>
- /// </example>
- /// <threadsafety static="true" instance="true" />
- /// <author>Nicko Cadell</author>
- /// <author>Gert Driesen</author>
- /*[Obsolete("NDC has been replaced by ThreadContext.Stacks")]*/
- public sealed class NDC
- {
- #region Private Instance Constructors
+ /// <summary>
+ /// Implementation of Nested Diagnostic Contexts.
+ /// </summary>
+ /// <remarks>
+ /// <note>
+ /// <para>
+ /// The NDC is deprecated and has been replaced by the <see cref="ThreadContext.Stacks"/>.
+ /// The current NDC implementation forwards to the <c>ThreadContext.Stacks["NDC"]</c>.
+ /// </para>
+ /// </note>
+ /// <para>
+ /// A Nested Diagnostic Context, or NDC in short, is an instrument
+ /// to distinguish interleaved log output from different sources. Log
+ /// output is typically interleaved when a server handles multiple
+ /// clients near-simultaneously.
+ /// </para>
+ /// <para>
+ /// Interleaved log output can still be meaningful if each log entry
+ /// from different contexts had a distinctive stamp. This is where NDCs
+ /// come into play.
+ /// </para>
+ /// <para>
+ /// Note that NDCs are managed on a per thread basis. The NDC class
+ /// is made up of static methods that operate on the context of the
+ /// calling thread.
+ /// </para>
+ /// </remarks>
+ /// <example>How to push a message into the context
+ /// <code lang="C#">
+ /// using(NDC.Push("my context message"))
+ /// {
+ /// ... all log calls will have 'my context message' included ...
+ ///
+ /// } // at the end of the using block the message is automatically removed
+ /// </code>
+ /// </example>
+ /// <threadsafety static="true" instance="true" />
+ /// <author>Nicko Cadell</author>
+ /// <author>Gert Driesen</author>
+ /*[Obsolete("NDC has been replaced by ThreadContext.Stacks")]*/
+ public sealed class NDC
+ {
+ #region Private Instance Constructors
- /// <summary>
- /// Initializes a new instance of the <see cref="NDC" /> class.
- /// </summary>
- /// <remarks>
- /// Uses a private access modifier to prevent instantiation of this class.
- /// </remarks>
- private NDC()
- {
- }
+ /// <summary>
+ /// Initializes a new instance of the <see cref="NDC" /> class.
+ /// </summary>
+ /// <remarks>
+ /// Uses a private access modifier to prevent instantiation of this class.
+ /// </remarks>
+ private NDC()
+ {
+ }
- #endregion Private Instance Constructors
+ #endregion Private Instance Constructors
- #region Public Static Properties
+ #region Public Static Properties
- /// <summary>
- /// Gets the current context depth.
- /// </summary>
- /// <value>The current context depth.</value>
- /// <remarks>
- /// <note>
- /// <para>
- /// The NDC is deprecated and has been replaced by the <see cref="ThreadContext.Stacks"/>.
- /// The current NDC implementation forwards to the <c>ThreadContext.Stacks["NDC"]</c>.
- /// </para>
- /// </note>
- /// <para>
- /// The number of context values pushed onto the context stack.
- /// </para>
- /// <para>
- /// Used to record the current depth of the context. This can then
- /// be restored using the <see cref="SetMaxDepth"/> method.
- /// </para>
- /// </remarks>
- /// <seealso cref="SetMaxDepth"/>
- /*[Obsolete("NDC has been replaced by ThreadContext.Stacks")]*/
- public static int Depth
- {
- get { return ThreadContext.Stacks["NDC"].Count; }
- }
+ /// <summary>
+ /// Gets the current context depth.
+ /// </summary>
+ /// <value>The current context depth.</value>
+ /// <remarks>
+ /// <note>
+ /// <para>
+ /// The NDC is deprecated and has been replaced by the <see cref="ThreadContext.Stacks"/>.
+ /// The current NDC implementation forwards to the <c>ThreadContext.Stacks["NDC"]</c>.
+ /// </para>
+ /// </note>
+ /// <para>
+ /// The number of context values pushed onto the context stack.
+ /// </para>
+ /// <para>
+ /// Used to record the current depth of the context. This can then
+ /// be restored using the <see cref="SetMaxDepth"/> method.
+ /// </para>
+ /// </remarks>
+ /// <seealso cref="SetMaxDepth"/>
+ /*[Obsolete("NDC has been replaced by ThreadContext.Stacks")]*/
+ public static int Depth
+ {
+ get { return ThreadContext.Stacks["NDC"].Count; }
+ }
- #endregion Public Static Properties
+ #endregion Public Static Properties
- #region Public Static Methods
+ #region Public Static Methods
- /// <summary>
- /// Clears all the contextual information held on the current thread.
- /// </summary>
- /// <remarks>
- /// <note>
- /// <para>
- /// The NDC is deprecated and has been replaced by the <see cref="ThreadContext.Stacks"/>.
- /// The current NDC implementation forwards to the <c>ThreadContext.Stacks["NDC"]</c>.
- /// </para>
- /// </note>
- /// <para>
- /// Clears the stack of NDC data held on the current thread.
- /// </para>
- /// </remarks>
- /*[Obsolete("NDC has been replaced by ThreadContext.Stacks")]*/
- public static void Clear()
- {
- ThreadContext.Stacks["NDC"].Clear();
- }
+ /// <summary>
+ /// Clears all the contextual information held on the current thread.
+ /// </summary>
+ /// <remarks>
+ /// <note>
+ /// <para>
+ /// The NDC is deprecated and has been replaced by the <see cref="ThreadContext.Stacks"/>.
+ /// The current NDC implementation forwards to the <c>ThreadContext.Stacks["NDC"]</c>.
+ /// </para>
+ /// </note>
+ /// <para>
+ /// Clears the stack of NDC data held on the current thread.
+ /// </para>
+ /// </remarks>
+ /*[Obsolete("NDC has been replaced by ThreadContext.Stacks")]*/
+ public static void Clear()
+ {
+ ThreadContext.Stacks["NDC"].Clear();
+ }
- /// <summary>
- /// Creates a clone of the stack of context information.
- /// </summary>
- /// <returns>A clone of the context info for this thread.</returns>
- /// <remarks>
- /// <note>
- /// <para>
- /// The NDC is deprecated and has been replaced by the <see cref="ThreadContext.Stacks"/>.
- /// The current NDC implementation forwards to the <c>ThreadContext.Stacks["NDC"]</c>.
- /// </para>
- /// </note>
- /// <para>
- /// The results of this method can be passed to the <see cref="Inherit"/>
- /// method to allow child threads to inherit the context of their
- /// parent thread.
- /// </para>
- /// </remarks>
- /*[Obsolete("NDC has been replaced by ThreadContext.Stacks")]*/
- public static Stack CloneStack()
- {
- return ThreadContext.Stacks["NDC"].InternalStack;
- }
+ /// <summary>
+ /// Creates a clone of the stack of context information.
+ /// </summary>
+ /// <returns>A clone of the context info for this thread.</returns>
+ /// <remarks>
+ /// <note>
+ /// <para>
+ /// The NDC is deprecated and has been replaced by the <see cref="ThreadContext.Stacks"/>.
+ /// The current NDC implementation forwards to the <c>ThreadContext.Stacks["NDC"]</c>.
+ /// </para>
+ /// </note>
+ /// <para>
+ /// The results of this method can be passed to the <see cref="Inherit"/>
+ /// method to allow child threads to inherit the context of their
+ /// parent thread.
+ /// </para>
+ /// </remarks>
+ /*[Obsolete("NDC has been replaced by ThreadContext.Stacks")]*/
+ public static Stack CloneStack()
+ {
+ return ThreadContext.Stacks["NDC"].InternalStack;
+ }
- /// <summary>
- /// Inherits the contextual information from another thread.
- /// </summary>
- /// <param name="stack">The context stack to inherit.</param>
- /// <remarks>
- /// <note>
- /// <para>
- /// The NDC is deprecated and has been replaced by the <see cref="ThreadContext.Stacks"/>.
- /// The current NDC implementation forwards to the <c>ThreadContext.Stacks["NDC"]</c>.
- /// </para>
- /// </note>
- /// <para>
- /// This thread will use the context information from the stack
- /// supplied. This can be used to initialize child threads with
- /// the same contextual information as their parent threads. These
- /// contexts will <b>NOT</b> be shared. Any further contexts that
- /// are pushed onto the stack will not be visible to the other.
- /// Call <see cref="CloneStack"/> to obtain a stack to pass to
- /// this method.
- /// </para>
- /// </remarks>
- /*[Obsolete("NDC has been replaced by ThreadContext.Stacks", true)]*/
- public static void Inherit(Stack stack)
- {
- ThreadContext.Stacks["NDC"].InternalStack = stack;
- }
+ /// <summary>
+ /// Inherits the contextual information from another thread.
+ /// </summary>
+ /// <param name="stack">The context stack to inherit.</param>
+ /// <remarks>
+ /// <note>
+ /// <para>
+ /// The NDC is deprecated and has been replaced by the <see cref="ThreadContext.Stacks"/>.
+ /// The current NDC implementation forwards to the <c>ThreadContext.Stacks["NDC"]</c>.
+ /// </para>
+ /// </note>
+ /// <para>
+ /// This thread will use the context information from the stack
+ /// supplied. This can be used to initialize child threads with
+ /// the same contextual information as their parent threads. These
+ /// contexts will <b>NOT</b> be shared. Any further contexts that
+ /// are pushed onto the stack will not be visible to the other.
+ /// Call <see cref="CloneStack"/> to obtain a stack to pass to
+ /// this method.
+ /// </para>
+ /// </remarks>
+ /*[Obsolete("NDC has been replaced by ThreadContext.Stacks", true)]*/
+ public static void Inherit(Stack stack)
+ {
+ ThreadContext.Stacks["NDC"].InternalStack = stack;
+ }
- /// <summary>
- /// Removes the top context from the stack.
- /// </summary>
- /// <returns>
- /// The message in the context that was removed from the top
- /// of the stack.
- /// </returns>
- /// <remarks>
- /// <note>
- /// <para>
- /// The NDC is deprecated and has been replaced by the <see cref="ThreadContext.Stacks"/>.
- /// The current NDC implementation forwards to the <c>ThreadContext.Stacks["NDC"]</c>.
- /// </para>
- /// </note>
- /// <para>
- /// Remove the top context from the stack, and return
- /// it to the caller. If the stack is empty then an
- /// empty string (not <c>null</c>) is returned.
- /// </para>
- /// </remarks>
- /*[Obsolete("NDC has been replaced by ThreadContext.Stacks")]*/
- public static string Pop()
- {
- return ThreadContext.Stacks["NDC"].Pop();
- }
+ /// <summary>
+ /// Removes the top context from the stack.
+ /// </summary>
+ /// <returns>
+ /// The message in the context that was removed from the top
+ /// of the stack.
+ /// </returns>
+ /// <remarks>
+ /// <note>
+ /// <para>
+ /// The NDC is deprecated and has been replaced by the <see cref="ThreadContext.Stacks"/>.
+ /// The current NDC implementation forwards to the <c>ThreadContext.Stacks["NDC"]</c>.
+ /// </para>
+ /// </note>
+ /// <para>
+ /// Remove the top context from the stack, and return
+ /// it to the caller. If the stack is empty then an
+ /// empty string (not <c>null</c>) is returned.
+ /// </para>
+ /// </remarks>
+ /*[Obsolete("NDC has been replaced by ThreadContext.Stacks")]*/
+ public static string Pop()
+ {
+ return ThreadContext.Stacks["NDC"].Pop();
+ }
- /// <summary>
- /// Pushes a new context message.
- /// </summary>
- /// <param name="message">The new context message.</param>
- /// <returns>
- /// An <see cref="IDisposable"/> that can be used to clean up
- /// the context stack.
- /// </returns>
- /// <remarks>
- /// <note>
- /// <para>
- /// The NDC is deprecated and has been replaced by the <see cref="ThreadContext.Stacks"/>.
- /// The current NDC implementation forwards to the <c>ThreadContext.Stacks["NDC"]</c>.
- /// </para>
- /// </note>
- /// <para>
- /// Pushes a new context onto the context stack. An <see cref="IDisposable"/>
- /// is returned that can be used to clean up the context stack. This
- /// can be easily combined with the <c>using</c> keyword to scope the
- /// context.
- /// </para>
- /// </remarks>
- /// <example>Simple example of using the <c>Push</c> method with the <c>using</c> keyword.
- /// <code lang="C#">
- /// using(log4net.NDC.Push("NDC_Message"))
- /// {
- /// log.Warn("This should have an NDC message");
- /// }
- /// </code>
- /// </example>
- /*[Obsolete("NDC has been replaced by ThreadContext.Stacks")]*/
- public static IDisposable Push(string message)
- {
- return ThreadContext.Stacks["NDC"].Push(message);
- }
+ /// <summary>
+ /// Pushes a new context message.
+ /// </summary>
+ /// <param name="message">The new context message.</param>
+ /// <returns>
+ /// An <see cref="IDisposable"/> that can be used to clean up
+ /// the context stack.
+ /// </returns>
+ /// <remarks>
+ /// <note>
+ /// <para>
+ /// The NDC is deprecated and has been replaced by the <see cref="ThreadContext.Stacks"/>.
+ /// The current NDC implementation forwards to the <c>ThreadContext.Stacks["NDC"]</c>.
+ /// </para>
+ /// </note>
+ /// <para>
+ /// Pushes a new context onto the context stack. An <see cref="IDisposable"/>
+ /// is returned that can be used to clean up the context stack. This
+ /// can be easily combined with the <c>using</c> keyword to scope the
+ /// context.
+ /// </para>
+ /// </remarks>
+ /// <example>Simple example of using the <c>Push</c> method with the <c>using</c> keyword.
+ /// <code lang="C#">
+ /// using(log4net.NDC.Push("NDC_Message"))
+ /// {
+ /// log.Warn("This should have an NDC message");
+ /// }
+ /// </code>
+ /// </example>
+ /*[Obsolete("NDC has been replaced by ThreadContext.Stacks")]*/
+ public static IDisposable Push(string message)
+ {
+ return ThreadContext.Stacks["NDC"].Push(message);
+ }
- /// <summary>
- /// Pushes a new context message.
- /// </summary>
- /// <param name="messageFormat">The new context message string format.</param>
- /// <param name="args">Arguments to be passed into messageFormat.</param>
- /// <returns>
- /// An <see cref="IDisposable"/> that can be used to clean up
- /// the context stack.
- /// </returns>
- /// <remarks>
- /// <note>
- /// <para>
- /// The NDC is deprecated and has been replaced by the <see cref="ThreadContext.Stacks"/>.
- /// The current NDC implementation forwards to the <c>ThreadContext.Stacks["NDC"]</c>.
- /// </para>
- /// </note>
- /// <para>
- /// Pushes a new context onto the context stack. An <see cref="IDisposable"/>
- /// is returned that can be used to clean up the context stack. This
- /// can be easily combined with the <c>using</c> keyword to scope the
- /// context.
- /// </para>
- /// </remarks>
- /// <example>Simple example of using the <c>Push</c> method with the <c>using</c> keyword.
- /// <code lang="C#">
- /// var someValue = "ExampleContext"
- /// using(log4net.NDC.PushFormat("NDC_Message {0}", someValue))
- /// {
- /// log.Warn("This should have an NDC message");
- /// }
- /// </code>
- /// </example>
- /*[Obsolete("NDC has been replaced by ThreadContext.Stacks")]*/
- public static IDisposable PushFormat(string messageFormat, params object[] args)
- {
- return Push(string.Format(messageFormat, args));
- }
+ /// <summary>
+ /// Pushes a new context message.
+ /// </summary>
+ /// <param name="messageFormat">The new context message string format.</param>
+ /// <param name="args">Arguments to be passed into messageFormat.</param>
+ /// <returns>
+ /// An <see cref="IDisposable"/> that can be used to clean up
+ /// the context stack.
+ /// </returns>
+ /// <remarks>
+ /// <note>
+ /// <para>
+ /// The NDC is deprecated and has been replaced by the <see cref="ThreadContext.Stacks"/>.
+ /// The current NDC implementation forwards to the <c>ThreadContext.Stacks["NDC"]</c>.
+ /// </para>
+ /// </note>
+ /// <para>
+ /// Pushes a new context onto the context stack. An <see cref="IDisposable"/>
+ /// is returned that can be used to clean up the context stack. This
+ /// can be easily combined with the <c>using</c> keyword to scope the
+ /// context.
+ /// </para>
+ /// </remarks>
+ /// <example>Simple example of using the <c>Push</c> method with the <c>using</c> keyword.
+ /// <code lang="C#">
+ /// var someValue = "ExampleContext"
+ /// using(log4net.NDC.PushFormat("NDC_Message {0}", someValue))
+ /// {
+ /// log.Warn("This should have an NDC message");
+ /// }
+ /// </code>
+ /// </example>
+ /*[Obsolete("NDC has been replaced by ThreadContext.Stacks")]*/
+ public static IDisposable PushFormat(string messageFormat, params object[] args)
+ {
+ return Push(string.Format(messageFormat, args));
+ }
- /// <summary>
- /// Removes the context information for this thread. It is
- /// not required to call this method.
- /// </summary>
- /// <remarks>
- /// <note>
- /// <para>
- /// The NDC is deprecated and has been replaced by the <see cref="ThreadContext.Stacks"/>.
- /// The current NDC implementation forwards to the <c>ThreadContext.Stacks["NDC"]</c>.
- /// </para>
- /// </note>
- /// <para>
- /// This method is not implemented.
- /// </para>
- /// </remarks>
- /*[Obsolete("NDC has been replaced by ThreadContext.Stacks")]*/
- public static void Remove()
- {
- }
+ /// <summary>
+ /// Removes the context information for this thread. It is
+ /// not required to call this method.
+ /// </summary>
+ /// <remarks>
+ /// <note>
+ /// <para>
+ /// The NDC is deprecated and has been replaced by the <see cref="ThreadContext.Stacks"/>.
+ /// The current NDC implementation forwards to the <c>ThreadContext.Stacks["NDC"]</c>.
+ /// </para>
+ /// </note>
+ /// <para>
+ /// This method is not implemented.
+ /// </para>
+ /// </remarks>
+ /*[Obsolete("NDC has been replaced by ThreadContext.Stacks")]*/
+ public static void Remove()
+ {
+ }
- /// <summary>
- /// Forces the stack depth to be at most <paramref name="maxDepth"/>.
- /// </summary>
- /// <param name="maxDepth">The maximum depth of the stack</param>
- /// <remarks>
- /// <note>
- /// <para>
- /// The NDC is deprecated and has been replaced by the <see cref="ThreadContext.Stacks"/>.
- /// The current NDC implementation forwards to the <c>ThreadContext.Stacks["NDC"]</c>.
- /// </para>
- /// </note>
- /// <para>
- /// Forces the stack depth to be at most <paramref name="maxDepth"/>.
- /// This may truncate the head of the stack. This only affects the
- /// stack in the current thread. Also it does not prevent it from
- /// growing, it only sets the maximum depth at the time of the
- /// call. This can be used to return to a known context depth.
- /// </para>
- /// </remarks>
- /*[Obsolete("NDC has been replaced by ThreadContext.Stacks")]*/
- public static void SetMaxDepth(int maxDepth)
- {
- if (maxDepth >= 0)
- {
- log4net.Util.ThreadContextStack stack = ThreadContext.Stacks["NDC"];
+ /// <summary>
+ /// Forces the stack depth to be at most <paramref name="maxDepth"/>.
+ /// </summary>
+ /// <param name="maxDepth">The maximum depth of the stack</param>
+ /// <remarks>
+ /// <note>
+ /// <para>
+ /// The NDC is deprecated and has been replaced by the <see cref="ThreadContext.Stacks"/>.
+ /// The current NDC implementation forwards to the <c>ThreadContext.Stacks["NDC"]</c>.
+ /// </para>
+ /// </note>
+ /// <para>
+ /// Forces the stack depth to be at most <paramref name="maxDepth"/>.
+ /// This may truncate the head of the stack. This only affects the
+ /// stack in the current thread. Also it does not prevent it from
+ /// growing, it only sets the maximum depth at the time of the
+ /// call. This can be used to return to a known context depth.
+ /// </para>
+ /// </remarks>
+ /*[Obsolete("NDC has been replaced by ThreadContext.Stacks")]*/
+ public static void SetMaxDepth(int maxDepth)
+ {
+ if (maxDepth >= 0)
+ {
+ log4net.Util.ThreadContextStack stack = ThreadContext.Stacks["NDC"];
- if (maxDepth == 0)
- {
- stack.Clear();
- }
- else
- {
- while(stack.Count > maxDepth)
- {
- stack.Pop();
- }
- }
- }
- }
+ if (maxDepth == 0)
+ {
+ stack.Clear();
+ }
+ else
+ {
+ while(stack.Count > maxDepth)
+ {
+ stack.Pop();
+ }
+ }
+ }
+ }
- #endregion Public Static Methods
- }
+ #endregion Public Static Methods
+ }
}
diff --git a/src/log4net/ObjectRenderer/DefaultRenderer.cs b/src/log4net/ObjectRenderer/DefaultRenderer.cs
index 8dc603d..73add46 100644
--- a/src/log4net/ObjectRenderer/DefaultRenderer.cs
+++ b/src/log4net/ObjectRenderer/DefaultRenderer.cs
@@ -26,285 +26,285 @@
namespace log4net.ObjectRenderer
{
- /// <summary>
- /// The default object Renderer.
- /// </summary>
- /// <remarks>
- /// <para>
- /// The default renderer supports rendering objects and collections to strings.
- /// </para>
- /// <para>
- /// See the <see cref="RenderObject"/> method for details of the output.
- /// </para>
- /// </remarks>
- /// <author>Nicko Cadell</author>
- /// <author>Gert Driesen</author>
- public sealed class DefaultRenderer : IObjectRenderer
- {
- #region Constructors
+ /// <summary>
+ /// The default object Renderer.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// The default renderer supports rendering objects and collections to strings.
+ /// </para>
+ /// <para>
+ /// See the <see cref="RenderObject"/> method for details of the output.
+ /// </para>
+ /// </remarks>
+ /// <author>Nicko Cadell</author>
+ /// <author>Gert Driesen</author>
+ public sealed class DefaultRenderer : IObjectRenderer
+ {
+ #region Constructors
- /// <summary>
- /// Default constructor
- /// </summary>
- /// <remarks>
- /// <para>
- /// Default constructor
- /// </para>
- /// </remarks>
- public DefaultRenderer()
- {
- }
+ /// <summary>
+ /// Default constructor
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Default constructor
+ /// </para>
+ /// </remarks>
+ public DefaultRenderer()
+ {
+ }
- #endregion
+ #endregion
- #region Implementation of IObjectRenderer
+ #region Implementation of IObjectRenderer
- /// <summary>
- /// Render the object <paramref name="obj"/> to a string
- /// </summary>
- /// <param name="rendererMap">The map used to lookup renderers</param>
- /// <param name="obj">The object to render</param>
- /// <param name="writer">The writer to render to</param>
- /// <remarks>
- /// <para>
- /// Render the object <paramref name="obj"/> to a string.
- /// </para>
- /// <para>
- /// The <paramref name="rendererMap"/> parameter is
- /// provided to lookup and render other objects. This is
- /// very useful where <paramref name="obj"/> contains
- /// nested objects of unknown type. The <see cref="M:RendererMap.FindAndRender(object)"/>
- /// method can be used to render these objects.
- /// </para>
- /// <para>
- /// The default renderer supports rendering objects to strings as follows:
- /// </para>
- /// <list type="table">
- /// <listheader>
- /// <term>Value</term>
- /// <description>Rendered String</description>
- /// </listheader>
- /// <item>
- /// <term><c>null</c></term>
- /// <description>
- /// <para>"(null)"</para>
- /// </description>
- /// </item>
- /// <item>
- /// <term><see cref="Array"/></term>
- /// <description>
- /// <para>
- /// For a one dimensional array this is the
- /// array type name, an open brace, followed by a comma
- /// separated list of the elements (using the appropriate
- /// renderer), followed by a close brace.
- /// </para>
- /// <para>
- /// For example: <c>int[] {1, 2, 3}</c>.
- /// </para>
- /// <para>
- /// If the array is not one dimensional the
- /// <c>Array.ToString()</c> is returned.
- /// </para>
- /// </description>
- /// </item>
- /// <item>
- /// <term><see cref="IEnumerable"/>, <see cref="ICollection"/> & <see cref="IEnumerator"/></term>
- /// <description>
- /// <para>
- /// Rendered as an open brace, followed by a comma
- /// separated list of the elements (using the appropriate
- /// renderer), followed by a close brace.
- /// </para>
- /// <para>
- /// For example: <c>{a, b, c}</c>.
- /// </para>
- /// <para>
- /// All collection classes that implement <see cref="ICollection"/> its subclasses,
- /// or generic equivalents all implement the <see cref="IEnumerable"/> interface.
- /// </para>
- /// </description>
- /// </item>
- /// <item>
- /// <term><see cref="DictionaryEntry"/></term>
- /// <description>
- /// <para>
- /// Rendered as the key, an equals sign ('='), and the value (using the appropriate
- /// renderer).
- /// </para>
- /// <para>
- /// For example: <c>key=value</c>.
- /// </para>
- /// </description>
- /// </item>
- /// <item>
- /// <term>other</term>
- /// <description>
- /// <para><c>Object.ToString()</c></para>
- /// </description>
- /// </item>
- /// </list>
- /// </remarks>
- public void RenderObject(RendererMap rendererMap, object obj, TextWriter writer)
- {
- if (rendererMap == null)
- {
- throw new ArgumentNullException("rendererMap");
- }
+ /// <summary>
+ /// Render the object <paramref name="obj"/> to a string
+ /// </summary>
+ /// <param name="rendererMap">The map used to lookup renderers</param>
+ /// <param name="obj">The object to render</param>
+ /// <param name="writer">The writer to render to</param>
+ /// <remarks>
+ /// <para>
+ /// Render the object <paramref name="obj"/> to a string.
+ /// </para>
+ /// <para>
+ /// The <paramref name="rendererMap"/> parameter is
+ /// provided to lookup and render other objects. This is
+ /// very useful where <paramref name="obj"/> contains
+ /// nested objects of unknown type. The <see cref="M:RendererMap.FindAndRender(object)"/>
+ /// method can be used to render these objects.
+ /// </para>
+ /// <para>
+ /// The default renderer supports rendering objects to strings as follows:
+ /// </para>
+ /// <list type="table">
+ /// <listheader>
+ /// <term>Value</term>
+ /// <description>Rendered String</description>
+ /// </listheader>
+ /// <item>
+ /// <term><c>null</c></term>
+ /// <description>
+ /// <para>"(null)"</para>
+ /// </description>
+ /// </item>
+ /// <item>
+ /// <term><see cref="Array"/></term>
+ /// <description>
+ /// <para>
+ /// For a one dimensional array this is the
+ /// array type name, an open brace, followed by a comma
+ /// separated list of the elements (using the appropriate
+ /// renderer), followed by a close brace.
+ /// </para>
+ /// <para>
+ /// For example: <c>int[] {1, 2, 3}</c>.
+ /// </para>
+ /// <para>
+ /// If the array is not one dimensional the
+ /// <c>Array.ToString()</c> is returned.
+ /// </para>
+ /// </description>
+ /// </item>
+ /// <item>
+ /// <term><see cref="IEnumerable"/>, <see cref="ICollection"/> & <see cref="IEnumerator"/></term>
+ /// <description>
+ /// <para>
+ /// Rendered as an open brace, followed by a comma
+ /// separated list of the elements (using the appropriate
+ /// renderer), followed by a close brace.
+ /// </para>
+ /// <para>
+ /// For example: <c>{a, b, c}</c>.
+ /// </para>
+ /// <para>
+ /// All collection classes that implement <see cref="ICollection"/> its subclasses,
+ /// or generic equivalents all implement the <see cref="IEnumerable"/> interface.
+ /// </para>
+ /// </description>
+ /// </item>
+ /// <item>
+ /// <term><see cref="DictionaryEntry"/></term>
+ /// <description>
+ /// <para>
+ /// Rendered as the key, an equals sign ('='), and the value (using the appropriate
+ /// renderer).
+ /// </para>
+ /// <para>
+ /// For example: <c>key=value</c>.
+ /// </para>
+ /// </description>
+ /// </item>
+ /// <item>
+ /// <term>other</term>
+ /// <description>
+ /// <para><c>Object.ToString()</c></para>
+ /// </description>
+ /// </item>
+ /// </list>
+ /// </remarks>
+ public void RenderObject(RendererMap rendererMap, object obj, TextWriter writer)
+ {
+ if (rendererMap == null)
+ {
+ throw new ArgumentNullException("rendererMap");
+ }
- if (obj == null)
- {
- writer.Write(SystemInfo.NullText);
- return;
- }
-
- Array objArray = obj as Array;
- if (objArray != null)
- {
- RenderArray(rendererMap, objArray, writer);
- return;
- }
+ if (obj == null)
+ {
+ writer.Write(SystemInfo.NullText);
+ return;
+ }
+
+ Array objArray = obj as Array;
+ if (objArray != null)
+ {
+ RenderArray(rendererMap, objArray, writer);
+ return;
+ }
- // Test if we are dealing with some form of collection object
- IEnumerable objEnumerable = obj as IEnumerable;
- if (objEnumerable != null)
- {
- // Get a collection interface if we can as its .Count property may be more
- // performant than getting the IEnumerator object and trying to advance it.
- ICollection objCollection = obj as ICollection;
- if (objCollection != null && objCollection.Count == 0)
- {
- writer.Write("{}");
- return;
- }
-
- // This is a special check to allow us to get the enumerator from the IDictionary
- // interface as this guarantees us DictionaryEntry objects. Note that in .NET 2.0
- // the generic IDictionary<> interface enumerates KeyValuePair objects rather than
- // DictionaryEntry ones. However the implementation of the plain IDictionary
- // interface on the generic Dictionary<> still returns DictionaryEntry objects.
- IDictionary objDictionary = obj as IDictionary;
- if (objDictionary != null)
- {
- RenderEnumerator(rendererMap, objDictionary.GetEnumerator(), writer);
- return;
- }
+ // Test if we are dealing with some form of collection object
+ IEnumerable objEnumerable = obj as IEnumerable;
+ if (objEnumerable != null)
+ {
+ // Get a collection interface if we can as its .Count property may be more
+ // performant than getting the IEnumerator object and trying to advance it.
+ ICollection objCollection = obj as ICollection;
+ if (objCollection != null && objCollection.Count == 0)
+ {
+ writer.Write("{}");
+ return;
+ }
+
+ // This is a special check to allow us to get the enumerator from the IDictionary
+ // interface as this guarantees us DictionaryEntry objects. Note that in .NET 2.0
+ // the generic IDictionary<> interface enumerates KeyValuePair objects rather than
+ // DictionaryEntry ones. However the implementation of the plain IDictionary
+ // interface on the generic Dictionary<> still returns DictionaryEntry objects.
+ IDictionary objDictionary = obj as IDictionary;
+ if (objDictionary != null)
+ {
+ RenderEnumerator(rendererMap, objDictionary.GetEnumerator(), writer);
+ return;
+ }
- RenderEnumerator(rendererMap, objEnumerable.GetEnumerator(), writer);
- return;
- }
+ RenderEnumerator(rendererMap, objEnumerable.GetEnumerator(), writer);
+ return;
+ }
- IEnumerator objEnumerator = obj as IEnumerator;
- if (objEnumerator != null)
- {
- RenderEnumerator(rendererMap, objEnumerator, writer);
- return;
- }
-
- if (obj is DictionaryEntry)
- {
- RenderDictionaryEntry(rendererMap, (DictionaryEntry)obj, writer);
- return;
- }
+ IEnumerator objEnumerator = obj as IEnumerator;
+ if (objEnumerator != null)
+ {
+ RenderEnumerator(rendererMap, objEnumerator, writer);
+ return;
+ }
+
+ if (obj is DictionaryEntry)
+ {
+ RenderDictionaryEntry(rendererMap, (DictionaryEntry)obj, writer);
+ return;
+ }
- string str = obj.ToString();
- writer.Write( (str==null) ? SystemInfo.NullText : str );
- }
+ string str = obj.ToString();
+ writer.Write( (str==null) ? SystemInfo.NullText : str );
+ }
- #endregion
+ #endregion
- /// <summary>
- /// Render the array argument into a string
- /// </summary>
- /// <param name="rendererMap">The map used to lookup renderers</param>
- /// <param name="array">the array to render</param>
- /// <param name="writer">The writer to render to</param>
- /// <remarks>
- /// <para>
- /// For a one dimensional array this is the
- /// array type name, an open brace, followed by a comma
- /// separated list of the elements (using the appropriate
- /// renderer), followed by a close brace. For example:
- /// <c>int[] {1, 2, 3}</c>.
- /// </para>
- /// <para>
- /// If the array is not one dimensional the
- /// <c>Array.ToString()</c> is returned.
- /// </para>
- /// </remarks>
- private void RenderArray(RendererMap rendererMap, Array array, TextWriter writer)
- {
- if (array.Rank != 1)
- {
- writer.Write(array.ToString());
- }
- else
- {
- writer.Write(array.GetType().Name + " {");
- int len = array.Length;
+ /// <summary>
+ /// Render the array argument into a string
+ /// </summary>
+ /// <param name="rendererMap">The map used to lookup renderers</param>
+ /// <param name="array">the array to render</param>
+ /// <param name="writer">The writer to render to</param>
+ /// <remarks>
+ /// <para>
+ /// For a one dimensional array this is the
+ /// array type name, an open brace, followed by a comma
+ /// separated list of the elements (using the appropriate
+ /// renderer), followed by a close brace. For example:
+ /// <c>int[] {1, 2, 3}</c>.
+ /// </para>
+ /// <para>
+ /// If the array is not one dimensional the
+ /// <c>Array.ToString()</c> is returned.
+ /// </para>
+ /// </remarks>
+ private void RenderArray(RendererMap rendererMap, Array array, TextWriter writer)
+ {
+ if (array.Rank != 1)
+ {
+ writer.Write(array.ToString());
+ }
+ else
+ {
+ writer.Write(array.GetType().Name + " {");
+ int len = array.Length;
- if (len > 0)
- {
- rendererMap.FindAndRender(array.GetValue(0), writer);
- for(int i=1; i<len; i++)
- {
- writer.Write(", ");
- rendererMap.FindAndRender(array.GetValue(i), writer);
- }
- }
- writer.Write("}");
- }
- }
+ if (len > 0)
+ {
+ rendererMap.FindAndRender(array.GetValue(0), writer);
+ for(int i=1; i<len; i++)
+ {
+ writer.Write(", ");
+ rendererMap.FindAndRender(array.GetValue(i), writer);
+ }
+ }
+ writer.Write("}");
+ }
+ }
- /// <summary>
- /// Render the enumerator argument into a string
- /// </summary>
- /// <param name="rendererMap">The map used to lookup renderers</param>
- /// <param name="enumerator">the enumerator to render</param>
- /// <param name="writer">The writer to render to</param>
- /// <remarks>
- /// <para>
- /// Rendered as an open brace, followed by a comma
- /// separated list of the elements (using the appropriate
- /// renderer), followed by a close brace. For example:
- /// <c>{a, b, c}</c>.
- /// </para>
- /// </remarks>
- private void RenderEnumerator(RendererMap rendererMap, IEnumerator enumerator, TextWriter writer)
- {
- writer.Write("{");
+ /// <summary>
+ /// Render the enumerator argument into a string
+ /// </summary>
+ /// <param name="rendererMap">The map used to lookup renderers</param>
+ /// <param name="enumerator">the enumerator to render</param>
+ /// <param name="writer">The writer to render to</param>
+ /// <remarks>
+ /// <para>
+ /// Rendered as an open brace, followed by a comma
+ /// separated list of the elements (using the appropriate
+ /// renderer), followed by a close brace. For example:
+ /// <c>{a, b, c}</c>.
+ /// </para>
+ /// </remarks>
+ private void RenderEnumerator(RendererMap rendererMap, IEnumerator enumerator, TextWriter writer)
+ {
+ writer.Write("{");
- if (enumerator != null && enumerator.MoveNext())
- {
- rendererMap.FindAndRender(enumerator.Current, writer);
+ if (enumerator != null && enumerator.MoveNext())
+ {
+ rendererMap.FindAndRender(enumerator.Current, writer);
- while (enumerator.MoveNext())
- {
- writer.Write(", ");
- rendererMap.FindAndRender(enumerator.Current, writer);
- }
- }
+ while (enumerator.MoveNext())
+ {
+ writer.Write(", ");
+ rendererMap.FindAndRender(enumerator.Current, writer);
+ }
+ }
- writer.Write("}");
- }
+ writer.Write("}");
+ }
- /// <summary>
- /// Render the DictionaryEntry argument into a string
- /// </summary>
- /// <param name="rendererMap">The map used to lookup renderers</param>
- /// <param name="entry">the DictionaryEntry to render</param>
- /// <param name="writer">The writer to render to</param>
- /// <remarks>
- /// <para>
- /// Render the key, an equals sign ('='), and the value (using the appropriate
- /// renderer). For example: <c>key=value</c>.
- /// </para>
- /// </remarks>
- private void RenderDictionaryEntry(RendererMap rendererMap, DictionaryEntry entry, TextWriter writer)
- {
- rendererMap.FindAndRender(entry.Key, writer);
- writer.Write("=");
- rendererMap.FindAndRender(entry.Value, writer);
- }
- }
+ /// <summary>
+ /// Render the DictionaryEntry argument into a string
+ /// </summary>
+ /// <param name="rendererMap">The map used to lookup renderers</param>
+ /// <param name="entry">the DictionaryEntry to render</param>
+ /// <param name="writer">The writer to render to</param>
+ /// <remarks>
+ /// <para>
+ /// Render the key, an equals sign ('='), and the value (using the appropriate
+ /// renderer). For example: <c>key=value</c>.
+ /// </para>
+ /// </remarks>
+ private void RenderDictionaryEntry(RendererMap rendererMap, DictionaryEntry entry, TextWriter writer)
+ {
+ rendererMap.FindAndRender(entry.Key, writer);
+ writer.Write("=");
+ rendererMap.FindAndRender(entry.Value, writer);
+ }
+ }
}
diff --git a/src/log4net/ObjectRenderer/IObjectRenderer.cs b/src/log4net/ObjectRenderer/IObjectRenderer.cs
index 3a79d1e..b9d673b 100644
--- a/src/log4net/ObjectRenderer/IObjectRenderer.cs
+++ b/src/log4net/ObjectRenderer/IObjectRenderer.cs
@@ -22,40 +22,40 @@
namespace log4net.ObjectRenderer
{
- /// <summary>
- /// Implement this interface in order to render objects as strings
- /// </summary>
- /// <remarks>
- /// <para>
- /// Certain types require special case conversion to
- /// string form. This conversion is done by an object renderer.
- /// Object renderers implement the <see cref="IObjectRenderer"/>
- /// interface.
- /// </para>
- /// </remarks>
- /// <author>Nicko Cadell</author>
- /// <author>Gert Driesen</author>
- public interface IObjectRenderer
- {
- /// <summary>
- /// Render the object <paramref name="obj"/> to a string
- /// </summary>
- /// <param name="rendererMap">The map used to lookup renderers</param>
- /// <param name="obj">The object to render</param>
- /// <param name="writer">The writer to render to</param>
- /// <remarks>
- /// <para>
- /// Render the object <paramref name="obj"/> to a
- /// string.
- /// </para>
- /// <para>
- /// The <paramref name="rendererMap"/> parameter is
- /// provided to lookup and render other objects. This is
- /// very useful where <paramref name="obj"/> contains
- /// nested objects of unknown type. The <see cref="M:RendererMap.FindAndRender(object, TextWriter)"/>
- /// method can be used to render these objects.
- /// </para>
- /// </remarks>
- void RenderObject(RendererMap rendererMap, object obj, TextWriter writer);
- }
+ /// <summary>
+ /// Implement this interface in order to render objects as strings
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Certain types require special case conversion to
+ /// string form. This conversion is done by an object renderer.
+ /// Object renderers implement the <see cref="IObjectRenderer"/>
+ /// interface.
+ /// </para>
+ /// </remarks>
+ /// <author>Nicko Cadell</author>
+ /// <author>Gert Driesen</author>
+ public interface IObjectRenderer
+ {
+ /// <summary>
+ /// Render the object <paramref name="obj"/> to a string
+ /// </summary>
+ /// <param name="rendererMap">The map used to lookup renderers</param>
+ /// <param name="obj">The object to render</param>
+ /// <param name="writer">The writer to render to</param>
+ /// <remarks>
+ /// <para>
+ /// Render the object <paramref name="obj"/> to a
+ /// string.
+ /// </para>
+ /// <para>
+ /// The <paramref name="rendererMap"/> parameter is
+ /// provided to lookup and render other objects. This is
+ /// very useful where <paramref name="obj"/> contains
+ /// nested objects of unknown type. The <see cref="M:RendererMap.FindAndRender(object, TextWriter)"/>
+ /// method can be used to render these objects.
+ /// </para>
+ /// </remarks>
+ void RenderObject(RendererMap rendererMap, object obj, TextWriter writer);
+ }
}
diff --git a/src/log4net/ObjectRenderer/RendererMap.cs b/src/log4net/ObjectRenderer/RendererMap.cs
index a20ae19..c3ba590 100644
--- a/src/log4net/ObjectRenderer/RendererMap.cs
+++ b/src/log4net/ObjectRenderer/RendererMap.cs
@@ -27,307 +27,307 @@
namespace log4net.ObjectRenderer
{
- /// <summary>
- /// Map class objects to an <see cref="IObjectRenderer"/>.
- /// </summary>
- /// <remarks>
- /// <para>
- /// Maintains a mapping between types that require special
- /// rendering and the <see cref="IObjectRenderer"/> that
- /// is used to render them.
- /// </para>
- /// <para>
- /// The <see cref="M:FindAndRender(object)"/> method is used to render an
- /// <c>object</c> using the appropriate renderers defined in this map.
- /// </para>
- /// </remarks>
- /// <author>Nicko Cadell</author>
- /// <author>Gert Driesen</author>
- public class RendererMap
- {
- private static readonly Type declaringType = typeof(RendererMap);
+ /// <summary>
+ /// Map class objects to an <see cref="IObjectRenderer"/>.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Maintains a mapping between types that require special
+ /// rendering and the <see cref="IObjectRenderer"/> that
+ /// is used to render them.
+ /// </para>
+ /// <para>
+ /// The <see cref="M:FindAndRender(object)"/> method is used to render an
+ /// <c>object</c> using the appropriate renderers defined in this map.
+ /// </para>
+ /// </remarks>
+ /// <author>Nicko Cadell</author>
+ /// <author>Gert Driesen</author>
+ public class RendererMap
+ {
+ private static readonly Type declaringType = typeof(RendererMap);
- #region Member Variables
+ #region Member Variables
- private readonly Hashtable m_map = new();
- private readonly Hashtable m_cache = new();
+ private readonly Hashtable m_map = new();
+ private readonly Hashtable m_cache = new();
- private static IObjectRenderer s_defaultRenderer = new DefaultRenderer();
+ private static IObjectRenderer s_defaultRenderer = new DefaultRenderer();
- #endregion
+ #endregion
- /// <summary>
- /// Render <paramref name="obj"/> using the appropriate renderer.
- /// </summary>
- /// <param name="obj">the object to render to a string</param>
- /// <returns>the object rendered as a string</returns>
- /// <remarks>
- /// <para>
- /// This is a convenience method used to render an object to a string.
- /// The alternative method <see cref="M:FindAndRender(object,TextWriter)"/>
- /// should be used when streaming output to a <see cref="TextWriter"/>.
- /// </para>
- /// </remarks>
- public string FindAndRender(object obj)
- {
- // Optimisation for strings
- string strData = obj as String;
- if (strData != null)
- {
- return strData;
- }
+ /// <summary>
+ /// Render <paramref name="obj"/> using the appropriate renderer.
+ /// </summary>
+ /// <param name="obj">the object to render to a string</param>
+ /// <returns>the object rendered as a string</returns>
+ /// <remarks>
+ /// <para>
+ /// This is a convenience method used to render an object to a string.
+ /// The alternative method <see cref="M:FindAndRender(object,TextWriter)"/>
+ /// should be used when streaming output to a <see cref="TextWriter"/>.
+ /// </para>
+ /// </remarks>
+ public string FindAndRender(object obj)
+ {
+ // Optimisation for strings
+ string strData = obj as String;
+ if (strData != null)
+ {
+ return strData;
+ }
- using StringWriter stringWriter = new StringWriter(System.Globalization.CultureInfo.InvariantCulture);
- FindAndRender(obj, stringWriter);
- return stringWriter.ToString();
- }
+ using StringWriter stringWriter = new StringWriter(System.Globalization.CultureInfo.InvariantCulture);
+ FindAndRender(obj, stringWriter);
+ return stringWriter.ToString();
+ }
- /// <summary>
- /// Render <paramref name="obj"/> using the appropriate renderer.
- /// </summary>
- /// <param name="obj">the object to render to a string</param>
- /// <param name="writer">The writer to render to</param>
- /// <remarks>
- /// <para>
- /// Find the appropriate renderer for the type of the
- /// <paramref name="obj"/> parameter. This is accomplished by calling the
- /// <see cref="M:Get(Type)"/> method. Once a renderer is found, it is
- /// applied on the object <paramref name="obj"/> and the result is returned
- /// as a <see cref="string"/>.
- /// </para>
- /// </remarks>
- public void FindAndRender(object obj, TextWriter writer)
- {
- if (obj == null)
- {
- writer.Write(SystemInfo.NullText);
- }
- else
- {
- // Optimisation for strings
- string str = obj as string;
- if (str != null)
- {
- writer.Write(str);
- }
- else
- {
- // Lookup the renderer for the specific type
- try
- {
- Get(obj.GetType()).RenderObject(this, obj, writer);
- }
- catch(Exception ex)
- {
- // Exception rendering the object
- LogLog.Error(declaringType, "Exception while rendering object of type ["+obj.GetType().FullName+"]", ex);
+ /// <summary>
+ /// Render <paramref name="obj"/> using the appropriate renderer.
+ /// </summary>
+ /// <param name="obj">the object to render to a string</param>
+ /// <param name="writer">The writer to render to</param>
+ /// <remarks>
+ /// <para>
+ /// Find the appropriate renderer for the type of the
+ /// <paramref name="obj"/> parameter. This is accomplished by calling the
+ /// <see cref="M:Get(Type)"/> method. Once a renderer is found, it is
+ /// applied on the object <paramref name="obj"/> and the result is returned
+ /// as a <see cref="string"/>.
+ /// </para>
+ /// </remarks>
+ public void FindAndRender(object obj, TextWriter writer)
+ {
+ if (obj == null)
+ {
+ writer.Write(SystemInfo.NullText);
+ }
+ else
+ {
+ // Optimisation for strings
+ string str = obj as string;
+ if (str != null)
+ {
+ writer.Write(str);
+ }
+ else
+ {
+ // Lookup the renderer for the specific type
+ try
+ {
+ Get(obj.GetType()).RenderObject(this, obj, writer);
+ }
+ catch(Exception ex)
+ {
+ // Exception rendering the object
+ LogLog.Error(declaringType, "Exception while rendering object of type ["+obj.GetType().FullName+"]", ex);
- // return default message
- string objectTypeName = "";
- if (obj != null && obj.GetType() != null)
- {
- objectTypeName = obj.GetType().FullName;
- }
+ // return default message
+ string objectTypeName = "";
+ if (obj != null && obj.GetType() != null)
+ {
+ objectTypeName = obj.GetType().FullName;
+ }
- writer.Write("<log4net.Error>Exception rendering object type ["+objectTypeName+"]");
- if (ex != null)
- {
- string exceptionText = null;
+ writer.Write("<log4net.Error>Exception rendering object type ["+objectTypeName+"]");
+ if (ex != null)
+ {
+ string exceptionText = null;
- try
- {
- exceptionText = ex.ToString();
- }
- catch
- {
- // Ignore exception
- }
+ try
+ {
+ exceptionText = ex.ToString();
+ }
+ catch
+ {
+ // Ignore exception
+ }
- writer.Write("<stackTrace>" + exceptionText + "</stackTrace>");
- }
- writer.Write("</log4net.Error>");
- }
- }
- }
- }
+ writer.Write("<stackTrace>" + exceptionText + "</stackTrace>");
+ }
+ writer.Write("</log4net.Error>");
+ }
+ }
+ }
+ }
- /// <summary>
- /// Gets the renderer for the specified object type
- /// </summary>
- /// <param name="obj">the object to lookup the renderer for</param>
- /// <returns>the renderer for <paramref name="obj"/></returns>
- /// <remarks>
- /// <param>
- /// Gets the renderer for the specified object type.
- /// </param>
- /// <param>
- /// Syntactic sugar method that calls <see cref="M:Get(Type)"/>
- /// with the type of the object parameter.
- /// </param>
- /// </remarks>
- public IObjectRenderer Get(Object obj)
- {
- if (obj == null)
- {
- return null;
- }
- else
- {
- return Get(obj.GetType());
- }
- }
+ /// <summary>
+ /// Gets the renderer for the specified object type
+ /// </summary>
+ /// <param name="obj">the object to lookup the renderer for</param>
+ /// <returns>the renderer for <paramref name="obj"/></returns>
+ /// <remarks>
+ /// <param>
+ /// Gets the renderer for the specified object type.
+ /// </param>
+ /// <param>
+ /// Syntactic sugar method that calls <see cref="M:Get(Type)"/>
+ /// with the type of the object parameter.
+ /// </param>
+ /// </remarks>
+ public IObjectRenderer Get(Object obj)
+ {
+ if (obj == null)
+ {
+ return null;
+ }
+ else
+ {
+ return Get(obj.GetType());
+ }
+ }
- /// <summary>
- /// Gets the renderer for the specified type
- /// </summary>
- /// <param name="type">the type to lookup the renderer for</param>
- /// <returns>the renderer for the specified type</returns>
- /// <remarks>
- /// <para>
- /// Returns the renderer for the specified type.
- /// If no specific renderer has been defined the
- /// <see cref="DefaultRenderer"/> will be returned.
- /// </para>
- /// </remarks>
- public IObjectRenderer Get(Type type)
- {
- if (type == null)
- {
- throw new ArgumentNullException("type");
- }
+ /// <summary>
+ /// Gets the renderer for the specified type
+ /// </summary>
+ /// <param name="type">the type to lookup the renderer for</param>
+ /// <returns>the renderer for the specified type</returns>
+ /// <remarks>
+ /// <para>
+ /// Returns the renderer for the specified type.
+ /// If no specific renderer has been defined the
+ /// <see cref="DefaultRenderer"/> will be returned.
+ /// </para>
+ /// </remarks>
+ public IObjectRenderer Get(Type type)
+ {
+ if (type == null)
+ {
+ throw new ArgumentNullException("type");
+ }
- IObjectRenderer result = null;
+ IObjectRenderer result = null;
- // Check cache
- result = (IObjectRenderer)m_cache[type];
+ // Check cache
+ result = (IObjectRenderer)m_cache[type];
- if (result == null)
- {
+ if (result == null)
+ {
#if NETSTANDARD1_3
- for (Type cur = type; cur != null; cur = cur.GetTypeInfo().BaseType)
+ for (Type cur = type; cur != null; cur = cur.GetTypeInfo().BaseType)
#else
- for(Type cur = type; cur != null; cur = cur.BaseType)
+ for(Type cur = type; cur != null; cur = cur.BaseType)
#endif
- {
- // Search the type's interfaces
- result = SearchTypeAndInterfaces(cur);
- if (result != null)
- {
- break;
- }
- }
+ {
+ // Search the type's interfaces
+ result = SearchTypeAndInterfaces(cur);
+ if (result != null)
+ {
+ break;
+ }
+ }
- // if not set then use the default renderer
- if (result == null)
- {
- result = s_defaultRenderer;
- }
+ // if not set then use the default renderer
+ if (result == null)
+ {
+ result = s_defaultRenderer;
+ }
- // Add to cache
- lock (m_cache)
- {
- m_cache[type] = result;
- }
- }
+ // Add to cache
+ lock (m_cache)
+ {
+ m_cache[type] = result;
+ }
+ }
- return result;
- }
+ return result;
+ }
- /// <summary>
- /// Internal function to recursively search interfaces
- /// </summary>
- /// <param name="type">the type to lookup the renderer for</param>
- /// <returns>the renderer for the specified type</returns>
- private IObjectRenderer SearchTypeAndInterfaces(Type type)
- {
- IObjectRenderer r = (IObjectRenderer)m_map[type];
- if (r != null)
- {
- return r;
- }
- else
- {
- foreach(Type t in type.GetInterfaces())
- {
- r = SearchTypeAndInterfaces(t);
- if (r != null)
- {
- return r;
- }
- }
- }
- return null;
- }
+ /// <summary>
+ /// Internal function to recursively search interfaces
+ /// </summary>
+ /// <param name="type">the type to lookup the renderer for</param>
+ /// <returns>the renderer for the specified type</returns>
+ private IObjectRenderer SearchTypeAndInterfaces(Type type)
+ {
+ IObjectRenderer r = (IObjectRenderer)m_map[type];
+ if (r != null)
+ {
+ return r;
+ }
+ else
+ {
+ foreach(Type t in type.GetInterfaces())
+ {
+ r = SearchTypeAndInterfaces(t);
+ if (r != null)
+ {
+ return r;
+ }
+ }
+ }
+ return null;
+ }
- /// <summary>
- /// Get the default renderer instance
- /// </summary>
- /// <value>the default renderer</value>
- /// <remarks>
- /// <para>
- /// Get the default renderer
- /// </para>
- /// </remarks>
- public IObjectRenderer DefaultRenderer
- {
- get { return s_defaultRenderer; }
- }
+ /// <summary>
+ /// Get the default renderer instance
+ /// </summary>
+ /// <value>the default renderer</value>
+ /// <remarks>
+ /// <para>
+ /// Get the default renderer
+ /// </para>
+ /// </remarks>
+ public IObjectRenderer DefaultRenderer
+ {
+ get { return s_defaultRenderer; }
+ }
- /// <summary>
- /// Clear the map of renderers
- /// </summary>
- /// <remarks>
- /// <para>
- /// Clear the custom renderers defined by using
- /// <see cref="Put"/>. The <see cref="DefaultRenderer"/>
- /// cannot be removed.
- /// </para>
- /// </remarks>
- public void Clear()
- {
- lock (m_map)
- {
- m_map.Clear();
- }
+ /// <summary>
+ /// Clear the map of renderers
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Clear the custom renderers defined by using
+ /// <see cref="Put"/>. The <see cref="DefaultRenderer"/>
+ /// cannot be removed.
+ /// </para>
+ /// </remarks>
+ public void Clear()
+ {
+ lock (m_map)
+ {
+ m_map.Clear();
+ }
- lock (m_cache)
- {
- m_cache.Clear();
- }
- }
+ lock (m_cache)
+ {
+ m_cache.Clear();
+ }
+ }
- /// <summary>
- /// Register an <see cref="IObjectRenderer"/> for <paramref name="typeToRender"/>.
- /// </summary>
- /// <param name="typeToRender">the type that will be rendered by <paramref name="renderer"/></param>
- /// <param name="renderer">the renderer for <paramref name="typeToRender"/></param>
- /// <remarks>
- /// <para>
- /// Register an object renderer for a specific source type.
- /// This renderer will be returned from a call to <see cref="M:Get(Type)"/>
- /// specifying the same <paramref name="typeToRender"/> as an argument.
- /// </para>
- /// </remarks>
- public void Put(Type typeToRender, IObjectRenderer renderer)
- {
- lock (m_cache)
- {
- m_cache.Clear();
- }
+ /// <summary>
+ /// Register an <see cref="IObjectRenderer"/> for <paramref name="typeToRender"/>.
+ /// </summary>
+ /// <param name="typeToRender">the type that will be rendered by <paramref name="renderer"/></param>
+ /// <param name="renderer">the renderer for <paramref name="typeToRender"/></param>
+ /// <remarks>
+ /// <para>
+ /// Register an object renderer for a specific source type.
+ /// This renderer will be returned from a call to <see cref="M:Get(Type)"/>
+ /// specifying the same <paramref name="typeToRender"/> as an argument.
+ /// </para>
+ /// </remarks>
+ public void Put(Type typeToRender, IObjectRenderer renderer)
+ {
+ lock (m_cache)
+ {
+ m_cache.Clear();
+ }
- if (typeToRender == null)
- {
- throw new ArgumentNullException("typeToRender");
- }
- if (renderer == null)
- {
- throw new ArgumentNullException("renderer");
- }
+ if (typeToRender == null)
+ {
+ throw new ArgumentNullException("typeToRender");
+ }
+ if (renderer == null)
+ {
+ throw new ArgumentNullException("renderer");
+ }
- lock (m_map)
- {
- m_map[typeToRender] = renderer;
- }
- }
- }
+ lock (m_map)
+ {
+ m_map[typeToRender] = renderer;
+ }
+ }
+ }
}
diff --git a/src/log4net/Plugin/IPlugin.cs b/src/log4net/Plugin/IPlugin.cs
index 065898e..da66a9c 100644
--- a/src/log4net/Plugin/IPlugin.cs
+++ b/src/log4net/Plugin/IPlugin.cs
@@ -21,65 +21,65 @@
namespace log4net.Plugin
{
- /// <summary>
- /// Interface implemented by logger repository plugins.
- /// </summary>
- /// <remarks>
- /// <para>
- /// Plugins define additional behavior that can be associated
- /// with a <see cref="log4net.Repository.ILoggerRepository"/>.
- /// The <see cref="PluginMap"/> held by the <see cref="log4net.Repository.ILoggerRepository.PluginMap"/>
- /// property is used to store the plugins for a repository.
- /// </para>
- /// <para>
- /// The <c>log4net.Config.PluginAttribute</c> can be used to
- /// attach plugins to repositories created using configuration
- /// attributes.
- /// </para>
- /// </remarks>
- /// <author>Nicko Cadell</author>
- /// <author>Gert Driesen</author>
- public interface IPlugin
- {
- /// <summary>
- /// Gets the name of the plugin.
- /// </summary>
- /// <value>
- /// The name of the plugin.
- /// </value>
- /// <remarks>
- /// <para>
- /// Plugins are stored in the <see cref="PluginMap"/>
- /// keyed by name. Each plugin instance attached to a
- /// repository must be a unique name.
- /// </para>
- /// </remarks>
- string Name { get; }
+ /// <summary>
+ /// Interface implemented by logger repository plugins.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Plugins define additional behavior that can be associated
+ /// with a <see cref="log4net.Repository.ILoggerRepository"/>.
+ /// The <see cref="PluginMap"/> held by the <see cref="log4net.Repository.ILoggerRepository.PluginMap"/>
+ /// property is used to store the plugins for a repository.
+ /// </para>
+ /// <para>
+ /// The <c>log4net.Config.PluginAttribute</c> can be used to
+ /// attach plugins to repositories created using configuration
+ /// attributes.
+ /// </para>
+ /// </remarks>
+ /// <author>Nicko Cadell</author>
+ /// <author>Gert Driesen</author>
+ public interface IPlugin
+ {
+ /// <summary>
+ /// Gets the name of the plugin.
+ /// </summary>
+ /// <value>
+ /// The name of the plugin.
+ /// </value>
+ /// <remarks>
+ /// <para>
+ /// Plugins are stored in the <see cref="PluginMap"/>
+ /// keyed by name. Each plugin instance attached to a
+ /// repository must be a unique name.
+ /// </para>
+ /// </remarks>
+ string Name { get; }
- /// <summary>
- /// Attaches the plugin to the specified <see cref="ILoggerRepository"/>.
- /// </summary>
- /// <param name="repository">The <see cref="ILoggerRepository"/> that this plugin should be attached to.</param>
- /// <remarks>
- /// <para>
- /// A plugin may only be attached to a single repository.
- /// </para>
- /// <para>
- /// This method is called when the plugin is attached to the repository.
- /// </para>
- /// </remarks>
- void Attach(ILoggerRepository repository);
+ /// <summary>
+ /// Attaches the plugin to the specified <see cref="ILoggerRepository"/>.
+ /// </summary>
+ /// <param name="repository">The <see cref="ILoggerRepository"/> that this plugin should be attached to.</param>
+ /// <remarks>
+ /// <para>
+ /// A plugin may only be attached to a single repository.
+ /// </para>
+ /// <para>
+ /// This method is called when the plugin is attached to the repository.
+ /// </para>
+ /// </remarks>
+ void Attach(ILoggerRepository repository);
- /// <summary>
- /// Is called when the plugin is to shutdown.
- /// </summary>
- /// <remarks>
- /// <para>
- /// This method is called to notify the plugin that
- /// it should stop operating and should detach from
- /// the repository.
- /// </para>
- /// </remarks>
- void Shutdown();
- }
+ /// <summary>
+ /// Is called when the plugin is to shutdown.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// This method is called to notify the plugin that
+ /// it should stop operating and should detach from
+ /// the repository.
+ /// </para>
+ /// </remarks>
+ void Shutdown();
+ }
}
diff --git a/src/log4net/Plugin/IPluginFactory.cs b/src/log4net/Plugin/IPluginFactory.cs
index 460a4d4..ce168a9 100644
--- a/src/log4net/Plugin/IPluginFactory.cs
+++ b/src/log4net/Plugin/IPluginFactory.cs
@@ -19,27 +19,27 @@
namespace log4net.Plugin
{
- /// <summary>
- /// Interface used to create plugins.
- /// </summary>
- /// <remarks>
- /// <para>
- /// Interface used to create a plugin.
- /// </para>
- /// </remarks>
- /// <author>Nicko Cadell</author>
- /// <author>Gert Driesen</author>
- public interface IPluginFactory
- {
- /// <summary>
- /// Creates the plugin object.
- /// </summary>
- /// <returns>the new plugin instance</returns>
- /// <remarks>
- /// <para>
- /// Create and return a new plugin instance.
- /// </para>
- /// </remarks>
- IPlugin CreatePlugin();
- }
+ /// <summary>
+ /// Interface used to create plugins.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Interface used to create a plugin.
+ /// </para>
+ /// </remarks>
+ /// <author>Nicko Cadell</author>
+ /// <author>Gert Driesen</author>
+ public interface IPluginFactory
+ {
+ /// <summary>
+ /// Creates the plugin object.
+ /// </summary>
+ /// <returns>the new plugin instance</returns>
+ /// <remarks>
+ /// <para>
+ /// Create and return a new plugin instance.
+ /// </para>
+ /// </remarks>
+ IPlugin CreatePlugin();
+ }
}
diff --git a/src/log4net/Plugin/PluginCollection.cs b/src/log4net/Plugin/PluginCollection.cs
index 7e7d4e2..c3c28e7 100644
--- a/src/log4net/Plugin/PluginCollection.cs
+++ b/src/log4net/Plugin/PluginCollection.cs
@@ -22,855 +22,855 @@
namespace log4net.Plugin
{
- /// <summary>
- /// A strongly-typed collection of <see cref="IPlugin"/> objects.
- /// </summary>
- /// <author>Nicko Cadell</author>
- public class PluginCollection : ICollection, IList, IEnumerable
+ /// <summary>
+ /// A strongly-typed collection of <see cref="IPlugin"/> objects.
+ /// </summary>
+ /// <author>Nicko Cadell</author>
+ public class PluginCollection : ICollection, IList, IEnumerable
#if !NETSTANDARD1_3
- , ICloneable
+ , ICloneable
#endif
- {
- #region Interfaces
+ {
+ #region Interfaces
- /// <summary>
- /// Supports type-safe iteration over a <see cref="PluginCollection"/>.
- /// </summary>
- /// <exclude/>
- public interface IPluginCollectionEnumerator
- {
- /// <summary>
- /// Gets the current element in the collection.
- /// </summary>
- IPlugin Current { get; }
+ /// <summary>
+ /// Supports type-safe iteration over a <see cref="PluginCollection"/>.
+ /// </summary>
+ /// <exclude/>
+ public interface IPluginCollectionEnumerator
+ {
+ /// <summary>
+ /// Gets the current element in the collection.
+ /// </summary>
+ IPlugin Current { get; }
- /// <summary>
- /// Advances the enumerator to the next element in the collection.
- /// </summary>
- /// <returns>
- /// <c>true</c> if the enumerator was successfully advanced to the next element;
- /// <c>false</c> if the enumerator has passed the end of the collection.
- /// </returns>
- /// <exception cref="InvalidOperationException">
- /// The collection was modified after the enumerator was created.
- /// </exception>
- bool MoveNext();
+ /// <summary>
+ /// Advances the enumerator to the next element in the collection.
+ /// </summary>
+ /// <returns>
+ /// <c>true</c> if the enumerator was successfully advanced to the next element;
+ /// <c>false</c> if the enumerator has passed the end of the collection.
+ /// </returns>
+ /// <exception cref="InvalidOperationException">
+ /// The collection was modified after the enumerator was created.
+ /// </exception>
+ bool MoveNext();
- /// <summary>
- /// Sets the enumerator to its initial position, before the first element in the collection.
- /// </summary>
- void Reset();
- }
+ /// <summary>
+ /// Sets the enumerator to its initial position, before the first element in the collection.
+ /// </summary>
+ void Reset();
+ }
- #endregion Interfaces
+ #endregion Interfaces
- private const int DEFAULT_CAPACITY = 16;
+ private const int DEFAULT_CAPACITY = 16;
- #region Implementation (data)
+ #region Implementation (data)
- private IPlugin[] m_array;
- private int m_count = 0;
- private int m_version = 0;
+ private IPlugin[] m_array;
+ private int m_count = 0;
+ private int m_version = 0;
- #endregion Implementation (data)
-
- #region Static Wrappers
+ #endregion Implementation (data)
+
+ #region Static Wrappers
- /// <summary>
- /// Creates a read-only wrapper for a <c>PluginCollection</c> instance.
- /// </summary>
- /// <param name="list">list to create a readonly wrapper arround</param>
- /// <returns>
- /// A <c>PluginCollection</c> wrapper that is read-only.
- /// </returns>
- public static PluginCollection ReadOnly(PluginCollection list)
- {
- if(list == null) throw new ArgumentNullException("list");
+ /// <summary>
+ /// Creates a read-only wrapper for a <c>PluginCollection</c> instance.
+ /// </summary>
+ /// <param name="list">list to create a readonly wrapper arround</param>
+ /// <returns>
+ /// A <c>PluginCollection</c> wrapper that is read-only.
+ /// </returns>
+ public static PluginCollection ReadOnly(PluginCollection list)
+ {
+ if(list == null) throw new ArgumentNullException("list");
- return new ReadOnlyPluginCollection(list);
- }
+ return new ReadOnlyPluginCollection(list);
+ }
- #endregion
+ #endregion
- #region Constructors
+ #region Constructors
- /// <summary>
- /// Initializes a new instance of the <c>PluginCollection</c> class
- /// that is empty and has the default initial capacity.
- /// </summary>
- public PluginCollection()
- {
- m_array = new IPlugin[DEFAULT_CAPACITY];
- }
-
- /// <summary>
- /// Initializes a new instance of the <c>PluginCollection</c> class
- /// that has the specified initial capacity.
- /// </summary>
- /// <param name="capacity">
- /// The number of elements that the new <c>PluginCollection</c> is initially capable of storing.
- /// </param>
- public PluginCollection(int capacity)
- {
- m_array = new IPlugin[capacity];
- }
+ /// <summary>
+ /// Initializes a new instance of the <c>PluginCollection</c> class
+ /// that is empty and has the default initial capacity.
+ /// </summary>
+ public PluginCollection()
+ {
+ m_array = new IPlugin[DEFAULT_CAPACITY];
+ }
+
+ /// <summary>
+ /// Initializes a new instance of the <c>PluginCollection</c> class
+ /// that has the specified initial capacity.
+ /// </summary>
+ /// <param name="capacity">
+ /// The number of elements that the new <c>PluginCollection</c> is initially capable of storing.
+ /// </param>
+ public PluginCollection(int capacity)
+ {
+ m_array = new IPlugin[capacity];
+ }
- /// <summary>
- /// Initializes a new instance of the <c>PluginCollection</c> class
- /// that contains elements copied from the specified <c>PluginCollection</c>.
- /// </summary>
- /// <param name="c">The <c>PluginCollection</c> whose elements are copied to the new collection.</param>
- public PluginCollection(PluginCollection c)
- {
- m_array = new IPlugin[c.Count];
- AddRange(c);
- }
+ /// <summary>
+ /// Initializes a new instance of the <c>PluginCollection</c> class
+ /// that contains elements copied from the specified <c>PluginCollection</c>.
+ /// </summary>
+ /// <param name="c">The <c>PluginCollection</c> whose elements are copied to the new collection.</param>
+ public PluginCollection(PluginCollection c)
+ {
+ m_array = new IPlugin[c.Count];
+ AddRange(c);
+ }
- /// <summary>
- /// Initializes a new instance of the <c>PluginCollection</c> class
- /// that contains elements copied from the specified <see cref="IPlugin"/> array.
- /// </summary>
- /// <param name="a">The <see cref="IPlugin"/> array whose elements are copied to the new list.</param>
- public PluginCollection(IPlugin[] a)
- {
- m_array = new IPlugin[a.Length];
- AddRange(a);
- }
-
- /// <summary>
- /// Initializes a new instance of the <c>PluginCollection</c> class
- /// that contains elements copied from the specified <see cref="IPlugin"/> collection.
- /// </summary>
- /// <param name="col">The <see cref="IPlugin"/> collection whose elements are copied to the new list.</param>
- public PluginCollection(ICollection col)
- {
- m_array = new IPlugin[col.Count];
- AddRange(col);
- }
+ /// <summary>
+ /// Initializes a new instance of the <c>PluginCollection</c> class
+ /// that contains elements copied from the specified <see cref="IPlugin"/> array.
+ /// </summary>
+ /// <param name="a">The <see cref="IPlugin"/> array whose elements are copied to the new list.</param>
+ public PluginCollection(IPlugin[] a)
+ {
+ m_array = new IPlugin[a.Length];
+ AddRange(a);
+ }
+
+ /// <summary>
+ /// Initializes a new instance of the <c>PluginCollection</c> class
+ /// that contains elements copied from the specified <see cref="IPlugin"/> collection.
+ /// </summary>
+ /// <param name="col">The <see cref="IPlugin"/> collection whose elements are copied to the new list.</param>
+ public PluginCollection(ICollection col)
+ {
+ m_array = new IPlugin[col.Count];
+ AddRange(col);
+ }
- /// <summary>
- /// Type visible only to our subclasses
- /// Used to access protected constructor
- /// </summary>
- /// <exclude/>
- protected internal enum Tag
- {
- /// <summary>
- /// A value
- /// </summary>
- Default
- }
+ /// <summary>
+ /// Type visible only to our subclasses
+ /// Used to access protected constructor
+ /// </summary>
+ /// <exclude/>
+ protected internal enum Tag
+ {
+ /// <summary>
+ /// A value
+ /// </summary>
+ Default
+ }
- /// <summary>
- /// Allow subclasses to avoid our default constructors
- /// </summary>
- /// <param name="tag"></param>
- /// <exclude/>
- protected internal PluginCollection(Tag tag)
- {
- m_array = null;
- }
+ /// <summary>
+ /// Allow subclasses to avoid our default constructors
+ /// </summary>
+ /// <param name="tag"></param>
+ /// <exclude/>
+ protected internal PluginCollection(Tag tag)
+ {
+ m_array = null;
+ }
- #endregion
-
- #region Operations (type-safe ICollection)
+ #endregion
+
+ #region Operations (type-safe ICollection)
- /// <summary>
- /// Gets the number of elements actually contained in the <c>PluginCollection</c>.
- /// </summary>
- public virtual int Count
- {
- get { return m_count; }
- }
+ /// <summary>
+ /// Gets the number of elements actually contained in the <c>PluginCollection</c>.
+ /// </summary>
+ public virtual int Count
+ {
+ get { return m_count; }
+ }
- /// <summary>
- /// Copies the entire <c>PluginCollection</c> to a one-dimensional
- /// <see cref="IPlugin"/> array.
- /// </summary>
- /// <param name="array">The one-dimensional <see cref="IPlugin"/> array to copy to.</param>
- public virtual void CopyTo(IPlugin[] array)
- {
- this.CopyTo(array, 0);
- }
+ /// <summary>
+ /// Copies the entire <c>PluginCollection</c> to a one-dimensional
+ /// <see cref="IPlugin"/> array.
+ /// </summary>
+ /// <param name="array">The one-dimensional <see cref="IPlugin"/> array to copy to.</param>
+ public virtual void CopyTo(IPlugin[] array)
+ {
+ this.CopyTo(array, 0);
+ }
- /// <summary>
- /// Copies the entire <c>PluginCollection</c> to a one-dimensional
- /// <see cref="IPlugin"/> array, starting at the specified index of the target array.
- /// </summary>
- /// <param name="array">The one-dimensional <see cref="IPlugin"/> array to copy to.</param>
- /// <param name="start">The zero-based index in <paramref name="array"/> at which copying begins.</param>
- public virtual void CopyTo(IPlugin[] array, int start)
- {
- if (m_count > array.GetUpperBound(0) + 1 - start)
- {
- throw new System.ArgumentException("Destination array was not long enough.");
- }
-
- Array.Copy(m_array, 0, array, start, m_count);
- }
+ /// <summary>
+ /// Copies the entire <c>PluginCollection</c> to a one-dimensional
+ /// <see cref="IPlugin"/> array, starting at the specified index of the target array.
+ /// </summary>
+ /// <param name="array">The one-dimensional <see cref="IPlugin"/> array to copy to.</param>
+ /// <param name="start">The zero-based index in <paramref name="array"/> at which copying begins.</param>
+ public virtual void CopyTo(IPlugin[] array, int start)
+ {
+ if (m_count > array.GetUpperBound(0) + 1 - start)
+ {
+ throw new System.ArgumentException("Destination array was not long enough.");
+ }
+
+ Array.Copy(m_array, 0, array, start, m_count);
+ }
- /// <summary>
- /// Gets a value indicating whether access to the collection is synchronized (thread-safe).
- /// </summary>
- /// <returns>false, because the backing type is an array, which is never thread-safe.</returns>
- public virtual bool IsSynchronized
- {
- get { return false; }
- }
+ /// <summary>
+ /// Gets a value indicating whether access to the collection is synchronized (thread-safe).
+ /// </summary>
+ /// <returns>false, because the backing type is an array, which is never thread-safe.</returns>
+ public virtual bool IsSynchronized
+ {
+ get { return false; }
+ }
- /// <summary>
- /// Gets an object that can be used to synchronize access to the collection.
- /// </summary>
- /// <value>
- /// An object that can be used to synchronize access to the collection.
- /// </value>
- public virtual object SyncRoot
- {
- get { return m_array; }
- }
+ /// <summary>
+ /// Gets an object that can be used to synchronize access to the collection.
+ /// </summary>
+ /// <value>
+ /// An object that can be used to synchronize access to the collection.
+ /// </value>
+ public virtual object SyncRoot
+ {
+ get { return m_array; }
+ }
- #endregion
-
- #region Operations (type-safe IList)
+ #endregion
+
+ #region Operations (type-safe IList)
- /// <summary>
- /// Gets or sets the <see cref="IPlugin"/> at the specified index.
- /// </summary>
- /// <value>
- /// The <see cref="IPlugin"/> at the specified index.
- /// </value>
- /// <param name="index">The zero-based index of the element to get or set.</param>
- /// <exception cref="ArgumentOutOfRangeException">
- /// <para><paramref name="index"/> is less than zero.</para>
- /// <para>-or-</para>
- /// <para><paramref name="index"/> is equal to or greater than <see cref="PluginCollection.Count"/>.</para>
- /// </exception>
- public virtual IPlugin this[int index]
- {
- get
- {
- ValidateIndex(index); // throws
- return m_array[index];
- }
- set
- {
- ValidateIndex(index); // throws
- ++m_version;
- m_array[index] = value;
- }
- }
+ /// <summary>
+ /// Gets or sets the <see cref="IPlugin"/> at the specified index.
+ /// </summary>
+ /// <value>
+ /// The <see cref="IPlugin"/> at the specified index.
+ /// </value>
+ /// <param name="index">The zero-based index of the element to get or set.</param>
+ /// <exception cref="ArgumentOutOfRangeException">
+ /// <para><paramref name="index"/> is less than zero.</para>
+ /// <para>-or-</para>
+ /// <para><paramref name="index"/> is equal to or greater than <see cref="PluginCollection.Count"/>.</para>
+ /// </exception>
+ public virtual IPlugin this[int index]
+ {
+ get
+ {
+ ValidateIndex(index); // throws
+ return m_array[index];
+ }
+ set
+ {
+ ValidateIndex(index); // throws
+ ++m_version;
+ m_array[index] = value;
+ }
+ }
- /// <summary>
- /// Adds a <see cref="IPlugin"/> to the end of the <c>PluginCollection</c>.
- /// </summary>
- /// <param name="item">The <see cref="IPlugin"/> to be added to the end of the <c>PluginCollection</c>.</param>
- /// <returns>The index at which the value has been added.</returns>
- public virtual int Add(IPlugin item)
- {
- if (m_count == m_array.Length)
- {
- EnsureCapacity(m_count + 1);
- }
+ /// <summary>
+ /// Adds a <see cref="IPlugin"/> to the end of the <c>PluginCollection</c>.
+ /// </summary>
+ /// <param name="item">The <see cref="IPlugin"/> to be added to the end of the <c>PluginCollection</c>.</param>
+ /// <returns>The index at which the value has been added.</returns>
+ public virtual int Add(IPlugin item)
+ {
+ if (m_count == m_array.Length)
+ {
+ EnsureCapacity(m_count + 1);
+ }
- m_array[m_count] = item;
- m_version++;
+ m_array[m_count] = item;
+ m_version++;
- return m_count++;
- }
-
- /// <summary>
- /// Removes all elements from the <c>PluginCollection</c>.
- /// </summary>
- public virtual void Clear()
- {
- ++m_version;
- m_array = new IPlugin[DEFAULT_CAPACITY];
- m_count = 0;
- }
-
- /// <summary>
- /// Creates a shallow copy of the <see cref="PluginCollection"/>.
- /// </summary>
- /// <returns>A new <see cref="PluginCollection"/> with a shallow copy of the collection data.</returns>
- public virtual object Clone()
- {
- PluginCollection newCol = new PluginCollection(m_count);
- Array.Copy(m_array, 0, newCol.m_array, 0, m_count);
- newCol.m_count = m_count;
- newCol.m_version = m_version;
+ return m_count++;
+ }
+
+ /// <summary>
+ /// Removes all elements from the <c>PluginCollection</c>.
+ /// </summary>
+ public virtual void Clear()
+ {
+ ++m_version;
+ m_array = new IPlugin[DEFAULT_CAPACITY];
+ m_count = 0;
+ }
+
+ /// <summary>
+ /// Creates a shallow copy of the <see cref="PluginCollection"/>.
+ /// </summary>
+ /// <returns>A new <see cref="PluginCollection"/> with a shallow copy of the collection data.</returns>
+ public virtual object Clone()
+ {
+ PluginCollection newCol = new PluginCollection(m_count);
+ Array.Copy(m_array, 0, newCol.m_array, 0, m_count);
+ newCol.m_count = m_count;
+ newCol.m_version = m_version;
- return newCol;
- }
+ return newCol;
+ }
- /// <summary>
- /// Determines whether a given <see cref="IPlugin"/> is in the <c>PluginCollection</c>.
- /// </summary>
- /// <param name="item">The <see cref="IPlugin"/> to check for.</param>
- /// <returns><c>true</c> if <paramref name="item"/> is found in the <c>PluginCollection</c>; otherwise, <c>false</c>.</returns>
- public virtual bool Contains(IPlugin item)
- {
- for (int i=0; i != m_count; ++i)
- {
- if (m_array[i].Equals(item))
- {
- return true;
- }
- }
- return false;
- }
+ /// <summary>
+ /// Determines whether a given <see cref="IPlugin"/> is in the <c>PluginCollection</c>.
+ /// </summary>
+ /// <param name="item">The <see cref="IPlugin"/> to check for.</param>
+ /// <returns><c>true</c> if <paramref name="item"/> is found in the <c>PluginCollection</c>; otherwise, <c>false</c>.</returns>
+ public virtual bool Contains(IPlugin item)
+ {
+ for (int i=0; i != m_count; ++i)
+ {
+ if (m_array[i].Equals(item))
+ {
+ return true;
+ }
+ }
+ return false;
+ }
- /// <summary>
- /// Returns the zero-based index of the first occurrence of a <see cref="IPlugin"/>
- /// in the <c>PluginCollection</c>.
- /// </summary>
- /// <param name="item">The <see cref="IPlugin"/> to locate in the <c>PluginCollection</c>.</param>
- /// <returns>
- /// The zero-based index of the first occurrence of <paramref name="item"/>
- /// in the entire <c>PluginCollection</c>, if found; otherwise, -1.
- /// </returns>
- public virtual int IndexOf(IPlugin item)
- {
- for (int i=0; i != m_count; ++i)
- {
- if (m_array[i].Equals(item))
- {
- return i;
- }
- }
- return -1;
- }
+ /// <summary>
+ /// Returns the zero-based index of the first occurrence of a <see cref="IPlugin"/>
+ /// in the <c>PluginCollection</c>.
+ /// </summary>
+ /// <param name="item">The <see cref="IPlugin"/> to locate in the <c>PluginCollection</c>.</param>
+ /// <returns>
+ /// The zero-based index of the first occurrence of <paramref name="item"/>
+ /// in the entire <c>PluginCollection</c>, if found; otherwise, -1.
+ /// </returns>
+ public virtual int IndexOf(IPlugin item)
+ {
+ for (int i=0; i != m_count; ++i)
+ {
+ if (m_array[i].Equals(item))
+ {
+ return i;
+ }
+ }
+ return -1;
+ }
- /// <summary>
- /// Inserts an element into the <c>PluginCollection</c> at the specified index.
- /// </summary>
- /// <param name="index">The zero-based index at which <paramref name="item"/> should be inserted.</param>
- /// <param name="item">The <see cref="IPlugin"/> to insert.</param>
- /// <exception cref="ArgumentOutOfRangeException">
- /// <para><paramref name="index"/> is less than zero</para>
- /// <para>-or-</para>
- /// <para><paramref name="index"/> is equal to or greater than <see cref="PluginCollection.Count"/>.</para>
- /// </exception>
- public virtual void Insert(int index, IPlugin item)
- {
- ValidateIndex(index, true); // throws
-
- if (m_count == m_array.Length)
- {
- EnsureCapacity(m_count + 1);
- }
+ /// <summary>
+ /// Inserts an element into the <c>PluginCollection</c> at the specified index.
+ /// </summary>
+ /// <param name="index">The zero-based index at which <paramref name="item"/> should be inserted.</param>
+ /// <param name="item">The <see cref="IPlugin"/> to insert.</param>
+ /// <exception cref="ArgumentOutOfRangeException">
+ /// <para><paramref name="index"/> is less than zero</para>
+ /// <para>-or-</para>
+ /// <para><paramref name="index"/> is equal to or greater than <see cref="PluginCollection.Count"/>.</para>
+ /// </exception>
+ public virtual void Insert(int index, IPlugin item)
+ {
+ ValidateIndex(index, true); // throws
+
+ if (m_count == m_array.Length)
+ {
+ EnsureCapacity(m_count + 1);
+ }
- if (index < m_count)
- {
- Array.Copy(m_array, index, m_array, index + 1, m_count - index);
- }
+ if (index < m_count)
+ {
+ Array.Copy(m_array, index, m_array, index + 1, m_count - index);
+ }
- m_array[index] = item;
- m_count++;
- m_version++;
- }
+ m_array[index] = item;
+ m_count++;
+ m_version++;
+ }
- /// <summary>
- /// Removes the first occurrence of a specific <see cref="IPlugin"/> from the <c>PluginCollection</c>.
- /// </summary>
- /// <param name="item">The <see cref="IPlugin"/> to remove from the <c>PluginCollection</c>.</param>
- /// <exception cref="ArgumentException">
- /// The specified <see cref="IPlugin"/> was not found in the <c>PluginCollection</c>.
- /// </exception>
- public virtual void Remove(IPlugin item)
- {
- int i = IndexOf(item);
- if (i < 0)
- {
- throw new System.ArgumentException("Cannot remove the specified item because it was not found in the specified Collection.");
- }
- ++m_version;
- RemoveAt(i);
- }
+ /// <summary>
+ /// Removes the first occurrence of a specific <see cref="IPlugin"/> from the <c>PluginCollection</c>.
+ /// </summary>
+ /// <param name="item">The <see cref="IPlugin"/> to remove from the <c>PluginCollection</c>.</param>
+ /// <exception cref="ArgumentException">
+ /// The specified <see cref="IPlugin"/> was not found in the <c>PluginCollection</c>.
+ /// </exception>
+ public virtual void Remove(IPlugin item)
+ {
+ int i = IndexOf(item);
+ if (i < 0)
+ {
+ throw new System.ArgumentException("Cannot remove the specified item because it was not found in the specified Collection.");
+ }
+ ++m_version;
+ RemoveAt(i);
+ }
- /// <summary>
- /// Removes the element at the specified index of the <c>PluginCollection</c>.
- /// </summary>
- /// <param name="index">The zero-based index of the element to remove.</param>
- /// <exception cref="ArgumentOutOfRangeException">
- /// <para><paramref name="index"/> is less than zero.</para>
- /// <para>-or-</para>
- /// <para><paramref name="index"/> is equal to or greater than <see cref="PluginCollection.Count"/>.</para>
- /// </exception>
- public virtual void RemoveAt(int index)
- {
- ValidateIndex(index); // throws
-
- m_count--;
+ /// <summary>
+ /// Removes the element at the specified index of the <c>PluginCollection</c>.
+ /// </summary>
+ /// <param name="index">The zero-based index of the element to remove.</param>
+ /// <exception cref="ArgumentOutOfRangeException">
+ /// <para><paramref name="index"/> is less than zero.</para>
+ /// <para>-or-</para>
+ /// <para><paramref name="index"/> is equal to or greater than <see cref="PluginCollection.Count"/>.</para>
+ /// </exception>
+ public virtual void RemoveAt(int index)
+ {
+ ValidateIndex(index); // throws
+
+ m_count--;
- if (index < m_count)
- {
- Array.Copy(m_array, index + 1, m_array, index, m_count - index);
- }
-
- // We can't set the deleted entry equal to null, because it might be a value type.
- // Instead, we'll create an empty single-element array of the right type and copy it
- // over the entry we want to erase.
- IPlugin[] temp = new IPlugin[1];
- Array.Copy(temp, 0, m_array, m_count, 1);
- m_version++;
- }
+ if (index < m_count)
+ {
+ Array.Copy(m_array, index + 1, m_array, index, m_count - index);
+ }
+
+ // We can't set the deleted entry equal to null, because it might be a value type.
+ // Instead, we'll create an empty single-element array of the right type and copy it
+ // over the entry we want to erase.
+ IPlugin[] temp = new IPlugin[1];
+ Array.Copy(temp, 0, m_array, m_count, 1);
+ m_version++;
+ }
- /// <summary>
- /// Gets a value indicating whether the collection has a fixed size.
- /// </summary>
- /// <value><c>true</c> if the collection has a fixed size; otherwise, <c>false</c>. The default is <c>false</c>.</value>
- public virtual bool IsFixedSize
- {
- get { return false; }
- }
+ /// <summary>
+ /// Gets a value indicating whether the collection has a fixed size.
+ /// </summary>
+ /// <value><c>true</c> if the collection has a fixed size; otherwise, <c>false</c>. The default is <c>false</c>.</value>
+ public virtual bool IsFixedSize
+ {
+ get { return false; }
+ }
- /// <summary>
- /// Gets a value indicating whether the IList is read-only.
- /// </summary>
- /// <value><c>true</c> if the collection is read-only; otherwise, <c>false</c>. The default is <c>false</c>.</value>
- public virtual bool IsReadOnly
- {
- get { return false; }
- }
+ /// <summary>
+ /// Gets a value indicating whether the IList is read-only.
+ /// </summary>
+ /// <value><c>true</c> if the collection is read-only; otherwise, <c>false</c>. The default is <c>false</c>.</value>
+ public virtual bool IsReadOnly
+ {
+ get { return false; }
+ }
- #endregion
+ #endregion
- #region Operations (type-safe IEnumerable)
-
- /// <summary>
- /// Returns an enumerator that can iterate through the <c>PluginCollection</c>.
- /// </summary>
- /// <returns>An <see cref="Enumerator"/> for the entire <c>PluginCollection</c>.</returns>
- public virtual IPluginCollectionEnumerator GetEnumerator()
- {
- return new Enumerator(this);
- }
+ #region Operations (type-safe IEnumerable)
+
+ /// <summary>
+ /// Returns an enumerator that can iterate through the <c>PluginCollection</c>.
+ /// </summary>
+ /// <returns>An <see cref="Enumerator"/> for the entire <c>PluginCollection</c>.</returns>
+ public virtual IPluginCollectionEnumerator GetEnumerator()
+ {
+ return new Enumerator(this);
+ }
- #endregion
+ #endregion
- #region Public helpers (just to mimic some nice features of ArrayList)
-
- /// <summary>
- /// Gets or sets the number of elements the <c>PluginCollection</c> can contain.
- /// </summary>
- /// <value>
- /// The number of elements the <c>PluginCollection</c> can contain.
- /// </value>
- public virtual int Capacity
- {
- get
- {
- return m_array.Length;
- }
- set
- {
- if (value < m_count)
- {
- value = m_count;
- }
+ #region Public helpers (just to mimic some nice features of ArrayList)
+
+ /// <summary>
+ /// Gets or sets the number of elements the <c>PluginCollection</c> can contain.
+ /// </summary>
+ /// <value>
+ /// The number of elements the <c>PluginCollection</c> can contain.
+ /// </value>
+ public virtual int Capacity
+ {
+ get
+ {
+ return m_array.Length;
+ }
+ set
+ {
+ if (value < m_count)
+ {
+ value = m_count;
+ }
- if (value != m_array.Length)
- {
- if (value > 0)
- {
- IPlugin[] temp = new IPlugin[value];
- Array.Copy(m_array, 0, temp, 0, m_count);
- m_array = temp;
- }
- else
- {
- m_array = new IPlugin[DEFAULT_CAPACITY];
- }
- }
- }
- }
+ if (value != m_array.Length)
+ {
+ if (value > 0)
+ {
+ IPlugin[] temp = new IPlugin[value];
+ Array.Copy(m_array, 0, temp, 0, m_count);
+ m_array = temp;
+ }
+ else
+ {
+ m_array = new IPlugin[DEFAULT_CAPACITY];
+ }
+ }
+ }
+ }
- /// <summary>
- /// Adds the elements of another <c>PluginCollection</c> to the current <c>PluginCollection</c>.
- /// </summary>
- /// <param name="x">The <c>PluginCollection</c> whose elements should be added to the end of the current <c>PluginCollection</c>.</param>
- /// <returns>The new <see cref="PluginCollection.Count"/> of the <c>PluginCollection</c>.</returns>
- public virtual int AddRange(PluginCollection x)
- {
- if (m_count + x.Count >= m_array.Length)
- {
- EnsureCapacity(m_count + x.Count);
- }
-
- Array.Copy(x.m_array, 0, m_array, m_count, x.Count);
- m_count += x.Count;
- m_version++;
+ /// <summary>
+ /// Adds the elements of another <c>PluginCollection</c> to the current <c>PluginCollection</c>.
+ /// </summary>
+ /// <param name="x">The <c>PluginCollection</c> whose elements should be added to the end of the current <c>PluginCollection</c>.</param>
+ /// <returns>The new <see cref="PluginCollection.Count"/> of the <c>PluginCollection</c>.</returns>
+ public virtual int AddRange(PluginCollection x)
+ {
+ if (m_count + x.Count >= m_array.Length)
+ {
+ EnsureCapacity(m_count + x.Count);
+ }
+
+ Array.Copy(x.m_array, 0, m_array, m_count, x.Count);
+ m_count += x.Count;
+ m_version++;
- return m_count;
- }
+ return m_count;
+ }
- /// <summary>
- /// Adds the elements of a <see cref="IPlugin"/> array to the current <c>PluginCollection</c>.
- /// </summary>
- /// <param name="x">The <see cref="IPlugin"/> array whose elements should be added to the end of the <c>PluginCollection</c>.</param>
- /// <returns>The new <see cref="PluginCollection.Count"/> of the <c>PluginCollection</c>.</returns>
- public virtual int AddRange(IPlugin[] x)
- {
- if (m_count + x.Length >= m_array.Length)
- {
- EnsureCapacity(m_count + x.Length);
- }
+ /// <summary>
+ /// Adds the elements of a <see cref="IPlugin"/> array to the current <c>PluginCollection</c>.
+ /// </summary>
+ /// <param name="x">The <see cref="IPlugin"/> array whose elements should be added to the end of the <c>PluginCollection</c>.</param>
+ /// <returns>The new <see cref="PluginCollection.Count"/> of the <c>PluginCollection</c>.</returns>
+ public virtual int AddRange(IPlugin[] x)
+ {
+ if (m_count + x.Length >= m_array.Length)
+ {
+ EnsureCapacity(m_count + x.Length);
+ }
- Array.Copy(x, 0, m_array, m_count, x.Length);
- m_count += x.Length;
- m_version++;
+ Array.Copy(x, 0, m_array, m_count, x.Length);
+ m_count += x.Length;
+ m_version++;
- return m_count;
- }
+ return m_count;
+ }
- /// <summary>
- /// Adds the elements of a <see cref="IPlugin"/> collection to the current <c>PluginCollection</c>.
- /// </summary>
- /// <param name="col">The <see cref="IPlugin"/> collection whose elements should be added to the end of the <c>PluginCollection</c>.</param>
- /// <returns>The new <see cref="PluginCollection.Count"/> of the <c>PluginCollection</c>.</returns>
- public virtual int AddRange(ICollection col)
- {
- if (m_count + col.Count >= m_array.Length)
- {
- EnsureCapacity(m_count + col.Count);
- }
+ /// <summary>
+ /// Adds the elements of a <see cref="IPlugin"/> collection to the current <c>PluginCollection</c>.
+ /// </summary>
+ /// <param name="col">The <see cref="IPlugin"/> collection whose elements should be added to the end of the <c>PluginCollection</c>.</param>
+ /// <returns>The new <see cref="PluginCollection.Count"/> of the <c>PluginCollection</c>.</returns>
+ public virtual int AddRange(ICollection col)
+ {
+ if (m_count + col.Count >= m_array.Length)
+ {
+ EnsureCapacity(m_count + col.Count);
+ }
- foreach(object item in col)
- {
- Add((IPlugin)item);
- }
+ foreach(object item in col)
+ {
+ Add((IPlugin)item);
+ }
- return m_count;
- }
-
- /// <summary>
- /// Sets the capacity to the actual number of elements.
- /// </summary>
- public virtual void TrimToSize()
- {
- this.Capacity = m_count;
- }
+ return m_count;
+ }
+
+ /// <summary>
+ /// Sets the capacity to the actual number of elements.
+ /// </summary>
+ public virtual void TrimToSize()
+ {
+ this.Capacity = m_count;
+ }
- #endregion
+ #endregion
- #region Implementation (helpers)
+ #region Implementation (helpers)
- /// <exception cref="ArgumentOutOfRangeException">
- /// <para><paramref name="i"/> is less than zero.</para>
- /// <para>-or-</para>
- /// <para><paramref name="i"/> is equal to or greater than <see cref="PluginCollection.Count"/>.</para>
- /// </exception>
- private void ValidateIndex(int i)
- {
- ValidateIndex(i, false);
- }
+ /// <exception cref="ArgumentOutOfRangeException">
+ /// <para><paramref name="i"/> is less than zero.</para>
+ /// <para>-or-</para>
+ /// <para><paramref name="i"/> is equal to or greater than <see cref="PluginCollection.Count"/>.</para>
+ /// </exception>
+ private void ValidateIndex(int i)
+ {
+ ValidateIndex(i, false);
+ }
- /// <exception cref="ArgumentOutOfRangeException">
- /// <para><paramref name="i"/> is less than zero.</para>
- /// <para>-or-</para>
- /// <para><paramref name="i"/> is equal to or greater than <see cref="PluginCollection.Count"/>.</para>
- /// </exception>
- private void ValidateIndex(int i, bool allowEqualEnd)
- {
- int max = (allowEqualEnd) ? (m_count) : (m_count-1);
- if (i < 0 || i > max)
- {
- throw log4net.Util.SystemInfo.CreateArgumentOutOfRangeException("i", (object)i, "Index was out of range. Must be non-negative and less than the size of the collection. [" + (object)i + "] Specified argument was out of the range of valid values.");
- }
- }
+ /// <exception cref="ArgumentOutOfRangeException">
+ /// <para><paramref name="i"/> is less than zero.</para>
+ /// <para>-or-</para>
+ /// <para><paramref name="i"/> is equal to or greater than <see cref="PluginCollection.Count"/>.</para>
+ /// </exception>
+ private void ValidateIndex(int i, bool allowEqualEnd)
+ {
+ int max = (allowEqualEnd) ? (m_count) : (m_count-1);
+ if (i < 0 || i > max)
+ {
+ throw log4net.Util.SystemInfo.CreateArgumentOutOfRangeException("i", (object)i, "Index was out of range. Must be non-negative and less than the size of the collection. [" + (object)i + "] Specified argument was out of the range of valid values.");
+ }
+ }
- private void EnsureCapacity(int min)
- {
- int newCapacity = ((m_array.Length == 0) ? DEFAULT_CAPACITY : m_array.Length * 2);
- if (newCapacity < min)
- {
- newCapacity = min;
- }
+ private void EnsureCapacity(int min)
+ {
+ int newCapacity = ((m_array.Length == 0) ? DEFAULT_CAPACITY : m_array.Length * 2);
+ if (newCapacity < min)
+ {
+ newCapacity = min;
+ }
- this.Capacity = newCapacity;
- }
+ this.Capacity = newCapacity;
+ }
- #endregion
-
- #region Implementation (ICollection)
+ #endregion
+
+ #region Implementation (ICollection)
- void ICollection.CopyTo(Array array, int start)
- {
- Array.Copy(m_array, 0, array, start, m_count);
- }
+ void ICollection.CopyTo(Array array, int start)
+ {
+ Array.Copy(m_array, 0, array, start, m_count);
+ }
- #endregion
+ #endregion
- #region Implementation (IList)
+ #region Implementation (IList)
- object IList.this[int i]
- {
- get { return (object)this[i]; }
- set { this[i] = (IPlugin)value; }
- }
+ object IList.this[int i]
+ {
+ get { return (object)this[i]; }
+ set { this[i] = (IPlugin)value; }
+ }
- int IList.Add(object x)
- {
- return this.Add((IPlugin)x);
- }
+ int IList.Add(object x)
+ {
+ return this.Add((IPlugin)x);
+ }
- bool IList.Contains(object x)
- {
- return this.Contains((IPlugin)x);
- }
+ bool IList.Contains(object x)
+ {
+ return this.Contains((IPlugin)x);
+ }
- int IList.IndexOf(object x)
- {
- return this.IndexOf((IPlugin)x);
- }
+ int IList.IndexOf(object x)
+ {
+ return this.IndexOf((IPlugin)x);
+ }
- void IList.Insert(int pos, object x)
- {
- this.Insert(pos, (IPlugin)x);
- }
+ void IList.Insert(int pos, object x)
+ {
+ this.Insert(pos, (IPlugin)x);
+ }
- void IList.Remove(object x)
- {
- this.Remove((IPlugin)x);
- }
+ void IList.Remove(object x)
+ {
+ this.Remove((IPlugin)x);
+ }
- void IList.RemoveAt(int pos)
- {
- this.RemoveAt(pos);
- }
+ void IList.RemoveAt(int pos)
+ {
+ this.RemoveAt(pos);
+ }
- #endregion
+ #endregion
- #region Implementation (IEnumerable)
+ #region Implementation (IEnumerable)
- IEnumerator IEnumerable.GetEnumerator()
- {
- return (IEnumerator)(this.GetEnumerator());
- }
+ IEnumerator IEnumerable.GetEnumerator()
+ {
+ return (IEnumerator)(this.GetEnumerator());
+ }
- #endregion Implementation (IEnumerable)
+ #endregion Implementation (IEnumerable)
- #region Nested enumerator class
+ #region Nested enumerator class
- /// <summary>
- /// Supports simple iteration over a <see cref="PluginCollection"/>.
- /// </summary>
- /// <exclude/>
- private sealed class Enumerator : IEnumerator, IPluginCollectionEnumerator
- {
- #region Implementation (data)
-
- private readonly PluginCollection m_collection;
- private int m_index;
- private int m_version;
-
- #endregion Implementation (data)
-
- #region Construction
-
- /// <summary>
- /// Initializes a new instance of the <c>Enumerator</c> class.
- /// </summary>
- /// <param name="tc"></param>
- internal Enumerator(PluginCollection tc)
- {
- m_collection = tc;
- m_index = -1;
- m_version = tc.m_version;
- }
-
- #endregion
-
- #region Operations (type-safe IEnumerator)
-
- /// <summary>
- /// Gets the current element in the collection.
- /// </summary>
- /// <value>
- /// The current element in the collection.
- /// </value>
- public IPlugin Current
- {
- get { return m_collection[m_index]; }
- }
+ /// <summary>
+ /// Supports simple iteration over a <see cref="PluginCollection"/>.
+ /// </summary>
+ /// <exclude/>
+ private sealed class Enumerator : IEnumerator, IPluginCollectionEnumerator
+ {
+ #region Implementation (data)
+
+ private readonly PluginCollection m_collection;
+ private int m_index;
+ private int m_version;
+
+ #endregion Implementation (data)
+
+ #region Construction
+
+ /// <summary>
+ /// Initializes a new instance of the <c>Enumerator</c> class.
+ /// </summary>
+ /// <param name="tc"></param>
+ internal Enumerator(PluginCollection tc)
+ {
+ m_collection = tc;
+ m_index = -1;
+ m_version = tc.m_version;
+ }
+
+ #endregion
+
+ #region Operations (type-safe IEnumerator)
+
+ /// <summary>
+ /// Gets the current element in the collection.
+ /// </summary>
+ /// <value>
+ /// The current element in the collection.
+ /// </value>
+ public IPlugin Current
+ {
+ get { return m_collection[m_index]; }
+ }
- /// <summary>
- /// Advances the enumerator to the next element in the collection.
- /// </summary>
- /// <returns>
- /// <c>true</c> if the enumerator was successfully advanced to the next element;
- /// <c>false</c> if the enumerator has passed the end of the collection.
- /// </returns>
- /// <exception cref="InvalidOperationException">
- /// The collection was modified after the enumerator was created.
- /// </exception>
- public bool MoveNext()
- {
- if (m_version != m_collection.m_version)
- {
- throw new System.InvalidOperationException("Collection was modified; enumeration operation may not execute.");
- }
+ /// <summary>
+ /// Advances the enumerator to the next element in the collection.
+ /// </summary>
+ /// <returns>
+ /// <c>true</c> if the enumerator was successfully advanced to the next element;
+ /// <c>false</c> if the enumerator has passed the end of the collection.
+ /// </returns>
+ /// <exception cref="InvalidOperationException">
+ /// The collection was modified after the enumerator was created.
+ /// </exception>
+ public bool MoveNext()
+ {
+ if (m_version != m_collection.m_version)
+ {
+ throw new System.InvalidOperationException("Collection was modified; enumeration operation may not execute.");
+ }
- ++m_index;
- return (m_index < m_collection.Count);
- }
+ ++m_index;
+ return (m_index < m_collection.Count);
+ }
- /// <summary>
- /// Sets the enumerator to its initial position, before the first element in the collection.
- /// </summary>
- public void Reset()
- {
- m_index = -1;
- }
+ /// <summary>
+ /// Sets the enumerator to its initial position, before the first element in the collection.
+ /// </summary>
+ public void Reset()
+ {
+ m_index = -1;
+ }
- #endregion
-
- #region Implementation (IEnumerator)
-
- object IEnumerator.Current
- {
- get { return this.Current; }
- }
-
- #endregion
- }
+ #endregion
+
+ #region Implementation (IEnumerator)
+
+ object IEnumerator.Current
+ {
+ get { return this.Current; }
+ }
+
+ #endregion
+ }
- #endregion
+ #endregion
- #region Nested Read Only Wrapper class
+ #region Nested Read Only Wrapper class
- /// <exclude/>
- private sealed class ReadOnlyPluginCollection : PluginCollection
- {
- #region Implementation (data)
+ /// <exclude/>
+ private sealed class ReadOnlyPluginCollection : PluginCollection
+ {
+ #region Implementation (data)
- private readonly PluginCollection m_collection;
+ private readonly PluginCollection m_collection;
- #endregion
+ #endregion
- #region Construction
+ #region Construction
- internal ReadOnlyPluginCollection(PluginCollection list) : base(Tag.Default)
- {
- m_collection = list;
- }
+ internal ReadOnlyPluginCollection(PluginCollection list) : base(Tag.Default)
+ {
+ m_collection = list;
+ }
- #endregion
+ #endregion
- #region Type-safe ICollection
+ #region Type-safe ICollection
- public override void CopyTo(IPlugin[] array)
- {
- m_collection.CopyTo(array);
- }
+ public override void CopyTo(IPlugin[] array)
+ {
+ m_collection.CopyTo(array);
+ }
- public override void CopyTo(IPlugin[] array, int start)
- {
- m_collection.CopyTo(array,start);
- }
- public override int Count
- {
- get { return m_collection.Count; }
- }
+ public override void CopyTo(IPlugin[] array, int start)
+ {
+ m_collection.CopyTo(array,start);
+ }
+ public override int Count
+ {
+ get { return m_collection.Count; }
+ }
- public override bool IsSynchronized
- {
- get { return m_collection.IsSynchronized; }
- }
+ public override bool IsSynchronized
+ {
+ get { return m_collection.IsSynchronized; }
+ }
- public override object SyncRoot
- {
- get { return this.m_collection.SyncRoot; }
- }
+ public override object SyncRoot
+ {
+ get { return this.m_collection.SyncRoot; }
+ }
- #endregion
+ #endregion
- #region Type-safe IList
+ #region Type-safe IList
- public override IPlugin this[int i]
- {
- get { return m_collection[i]; }
- set { throw new NotSupportedException("This is a Read Only Collection and can not be modified"); }
- }
+ public override IPlugin this[int i]
+ {
+ get { return m_collection[i]; }
+ set { throw new NotSupportedException("This is a Read Only Collection and can not be modified"); }
+ }
- public override int Add(IPlugin x)
- {
- throw new NotSupportedException("This is a Read Only Collection and can not be modified");
- }
+ public override int Add(IPlugin x)
+ {
+ throw new NotSupportedException("This is a Read Only Collection and can not be modified");
+ }
- public override void Clear()
- {
- throw new NotSupportedException("This is a Read Only Collection and can not be modified");
- }
+ public override void Clear()
+ {
+ throw new NotSupportedException("This is a Read Only Collection and can not be modified");
+ }
- public override bool Contains(IPlugin x)
- {
- return m_collection.Contains(x);
- }
+ public override bool Contains(IPlugin x)
+ {
+ return m_collection.Contains(x);
+ }
- public override int IndexOf(IPlugin x)
- {
- return m_collection.IndexOf(x);
- }
+ public override int IndexOf(IPlugin x)
+ {
+ return m_collection.IndexOf(x);
+ }
- public override void Insert(int pos, IPlugin x)
- {
- throw new NotSupportedException("This is a Read Only Collection and can not be modified");
- }
+ public override void Insert(int pos, IPlugin x)
+ {
+ throw new NotSupportedException("This is a Read Only Collection and can not be modified");
+ }
- public override void Remove(IPlugin x)
- {
- throw new NotSupportedException("This is a Read Only Collection and can not be modified");
- }
+ public override void Remove(IPlugin x)
+ {
+ throw new NotSupportedException("This is a Read Only Collection and can not be modified");
+ }
- public override void RemoveAt(int pos)
- {
- throw new NotSupportedException("This is a Read Only Collection and can not be modified");
- }
+ public override void RemoveAt(int pos)
+ {
+ throw new NotSupportedException("This is a Read Only Collection and can not be modified");
+ }
- public override bool IsFixedSize
- {
- get { return true; }
- }
+ public override bool IsFixedSize
+ {
+ get { return true; }
+ }
- public override bool IsReadOnly
- {
- get { return true; }
- }
+ public override bool IsReadOnly
+ {
+ get { return true; }
+ }
- #endregion
+ #endregion
- #region Type-safe IEnumerable
+ #region Type-safe IEnumerable
- public override IPluginCollectionEnumerator GetEnumerator()
- {
- return m_collection.GetEnumerator();
- }
+ public override IPluginCollectionEnumerator GetEnumerator()
+ {
+ return m_collection.GetEnumerator();
+ }
- #endregion
+ #endregion
- #region Public Helpers
+ #region Public Helpers
- // (just to mimic some nice features of ArrayList)
- public override int Capacity
- {
- get { return m_collection.Capacity; }
- set { throw new NotSupportedException("This is a Read Only Collection and can not be modified"); }
- }
+ // (just to mimic some nice features of ArrayList)
+ public override int Capacity
+ {
+ get { return m_collection.Capacity; }
+ set { throw new NotSupportedException("This is a Read Only Collection and can not be modified"); }
+ }
- public override int AddRange(PluginCollection x)
- {
- throw new NotSupportedException("This is a Read Only Collection and can not be modified");
- }
+ public override int AddRange(PluginCollection x)
+ {
+ throw new NotSupportedException("This is a Read Only Collection and can not be modified");
+ }
- public override int AddRange(IPlugin[] x)
- {
- throw new NotSupportedException("This is a Read Only Collection and can not be modified");
- }
+ public override int AddRange(IPlugin[] x)
+ {
+ throw new NotSupportedException("This is a Read Only Collection and can not be modified");
+ }
- #endregion
- }
+ #endregion
+ }
- #endregion
- }
+ #endregion
+ }
}
diff --git a/src/log4net/Plugin/PluginMap.cs b/src/log4net/Plugin/PluginMap.cs
index d05223f..5c818d3 100644
--- a/src/log4net/Plugin/PluginMap.cs
+++ b/src/log4net/Plugin/PluginMap.cs
@@ -25,165 +25,165 @@
namespace log4net.Plugin
{
- /// <summary>
- /// Map of repository plugins.
- /// </summary>
- /// <remarks>
- /// <para>
- /// This class is a name keyed map of the plugins that are
- /// attached to a repository.
- /// </para>
- /// </remarks>
- /// <author>Nicko Cadell</author>
- /// <author>Gert Driesen</author>
- public sealed class PluginMap
- {
- #region Public Instance Constructors
+ /// <summary>
+ /// Map of repository plugins.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// This class is a name keyed map of the plugins that are
+ /// attached to a repository.
+ /// </para>
+ /// </remarks>
+ /// <author>Nicko Cadell</author>
+ /// <author>Gert Driesen</author>
+ public sealed class PluginMap
+ {
+ #region Public Instance Constructors
- /// <summary>
- /// Constructor
- /// </summary>
- /// <param name="repository">The repository that the plugins should be attached to.</param>
- /// <remarks>
- /// <para>
- /// Initialize a new instance of the <see cref="PluginMap" /> class with a
- /// repository that the plugins should be attached to.
- /// </para>
- /// </remarks>
- public PluginMap(ILoggerRepository repository)
- {
- m_repository = repository;
- }
+ /// <summary>
+ /// Constructor
+ /// </summary>
+ /// <param name="repository">The repository that the plugins should be attached to.</param>
+ /// <remarks>
+ /// <para>
+ /// Initialize a new instance of the <see cref="PluginMap" /> class with a
+ /// repository that the plugins should be attached to.
+ /// </para>
+ /// </remarks>
+ public PluginMap(ILoggerRepository repository)
+ {
+ m_repository = repository;
+ }
- #endregion Public Instance Constructors
+ #endregion Public Instance Constructors
- #region Public Instance Properties
+ #region Public Instance Properties
- /// <summary>
- /// Gets a <see cref="IPlugin" /> by name.
- /// </summary>
- /// <param name="name">The name of the <see cref="IPlugin" /> to lookup.</param>
- /// <returns>
- /// The <see cref="IPlugin" /> from the map with the name specified, or
- /// <c>null</c> if no plugin is found.
- /// </returns>
- /// <remarks>
- /// <para>
- /// Lookup a plugin by name. If the plugin is not found <c>null</c>
- /// will be returned.
- /// </para>
- /// </remarks>
- public IPlugin this[string name]
- {
- get
- {
- if (name == null)
- {
- throw new ArgumentNullException("name");
- }
+ /// <summary>
+ /// Gets a <see cref="IPlugin" /> by name.
+ /// </summary>
+ /// <param name="name">The name of the <see cref="IPlugin" /> to lookup.</param>
+ /// <returns>
+ /// The <see cref="IPlugin" /> from the map with the name specified, or
+ /// <c>null</c> if no plugin is found.
+ /// </returns>
+ /// <remarks>
+ /// <para>
+ /// Lookup a plugin by name. If the plugin is not found <c>null</c>
+ /// will be returned.
+ /// </para>
+ /// </remarks>
+ public IPlugin this[string name]
+ {
+ get
+ {
+ if (name == null)
+ {
+ throw new ArgumentNullException("name");
+ }
- lock(this)
- {
- return (IPlugin)m_mapName2Plugin[name];
- }
- }
- }
+ lock(this)
+ {
+ return (IPlugin)m_mapName2Plugin[name];
+ }
+ }
+ }
- /// <summary>
- /// Gets all possible plugins as a list of <see cref="IPlugin" /> objects.
- /// </summary>
- /// <value>All possible plugins as a list of <see cref="IPlugin" /> objects.</value>
- /// <remarks>
- /// <para>
- /// Get a collection of all the plugins defined in this map.
- /// </para>
- /// </remarks>
- public PluginCollection AllPlugins
- {
- get
- {
- lock(this)
- {
- return new PluginCollection(m_mapName2Plugin.Values);
- }
- }
- }
-
- #endregion Public Instance Properties
+ /// <summary>
+ /// Gets all possible plugins as a list of <see cref="IPlugin" /> objects.
+ /// </summary>
+ /// <value>All possible plugins as a list of <see cref="IPlugin" /> objects.</value>
+ /// <remarks>
+ /// <para>
+ /// Get a collection of all the plugins defined in this map.
+ /// </para>
+ /// </remarks>
+ public PluginCollection AllPlugins
+ {
+ get
+ {
+ lock(this)
+ {
+ return new PluginCollection(m_mapName2Plugin.Values);
+ }
+ }
+ }
+
+ #endregion Public Instance Properties
- #region Public Instance Methods
+ #region Public Instance Methods
- /// <summary>
- /// Adds a <see cref="IPlugin" /> to the map.
- /// </summary>
- /// <param name="plugin">The <see cref="IPlugin" /> to add to the map.</param>
- /// <remarks>
- /// <para>
- /// The <see cref="IPlugin" /> will be attached to the repository when added.
- /// </para>
- /// <para>
- /// If there already exists a plugin with the same name
- /// attached to the repository then the old plugin will
- /// be <see cref="IPlugin.Shutdown"/> and replaced with
- /// the new plugin.
- /// </para>
- /// </remarks>
- public void Add(IPlugin plugin)
- {
- if (plugin == null)
- {
- throw new ArgumentNullException("plugin");
- }
+ /// <summary>
+ /// Adds a <see cref="IPlugin" /> to the map.
+ /// </summary>
+ /// <param name="plugin">The <see cref="IPlugin" /> to add to the map.</param>
+ /// <remarks>
+ /// <para>
+ /// The <see cref="IPlugin" /> will be attached to the repository when added.
+ /// </para>
+ /// <para>
+ /// If there already exists a plugin with the same name
+ /// attached to the repository then the old plugin will
+ /// be <see cref="IPlugin.Shutdown"/> and replaced with
+ /// the new plugin.
+ /// </para>
+ /// </remarks>
+ public void Add(IPlugin plugin)
+ {
+ if (plugin == null)
+ {
+ throw new ArgumentNullException("plugin");
+ }
- IPlugin curPlugin = null;
+ IPlugin curPlugin = null;
- lock(this)
- {
- // Get the current plugin if it exists
- curPlugin = m_mapName2Plugin[plugin.Name] as IPlugin;
+ lock(this)
+ {
+ // Get the current plugin if it exists
+ curPlugin = m_mapName2Plugin[plugin.Name] as IPlugin;
- // Store new plugin
- m_mapName2Plugin[plugin.Name] = plugin;
- }
+ // Store new plugin
+ m_mapName2Plugin[plugin.Name] = plugin;
+ }
- // Shutdown existing plugin with same name
- if (curPlugin != null)
- {
- curPlugin.Shutdown();
- }
+ // Shutdown existing plugin with same name
+ if (curPlugin != null)
+ {
+ curPlugin.Shutdown();
+ }
- // Attach new plugin to repository
- plugin.Attach(m_repository);
- }
+ // Attach new plugin to repository
+ plugin.Attach(m_repository);
+ }
- /// <summary>
- /// Removes a <see cref="IPlugin" /> from the map.
- /// </summary>
- /// <param name="plugin">The <see cref="IPlugin" /> to remove from the map.</param>
- /// <remarks>
- /// <para>
- /// Remove a specific plugin from this map.
- /// </para>
- /// </remarks>
- public void Remove(IPlugin plugin)
- {
- if (plugin == null)
- {
- throw new ArgumentNullException("plugin");
- }
- lock(this)
- {
- m_mapName2Plugin.Remove(plugin.Name);
- }
- }
+ /// <summary>
+ /// Removes a <see cref="IPlugin" /> from the map.
+ /// </summary>
+ /// <param name="plugin">The <see cref="IPlugin" /> to remove from the map.</param>
+ /// <remarks>
+ /// <para>
+ /// Remove a specific plugin from this map.
+ /// </para>
+ /// </remarks>
+ public void Remove(IPlugin plugin)
+ {
+ if (plugin == null)
+ {
+ throw new ArgumentNullException("plugin");
+ }
+ lock(this)
+ {
+ m_mapName2Plugin.Remove(plugin.Name);
+ }
+ }
- #endregion Public Instance Methods
+ #endregion Public Instance Methods
- #region Private Instance Fields
+ #region Private Instance Fields
- private readonly Hashtable m_mapName2Plugin = new Hashtable();
- private readonly ILoggerRepository m_repository;
+ private readonly Hashtable m_mapName2Plugin = new Hashtable();
+ private readonly ILoggerRepository m_repository;
- #endregion Private Instance Fields
- }
+ #endregion Private Instance Fields
+ }
}
diff --git a/src/log4net/Plugin/PluginSkeleton.cs b/src/log4net/Plugin/PluginSkeleton.cs
index 56ce5c3..2c3d0f9 100644
--- a/src/log4net/Plugin/PluginSkeleton.cs
+++ b/src/log4net/Plugin/PluginSkeleton.cs
@@ -21,128 +21,128 @@
namespace log4net.Plugin
{
- /// <summary>
- /// Base implementation of <see cref="IPlugin"/>
- /// </summary>
- /// <remarks>
- /// <para>
- /// Default abstract implementation of the <see cref="IPlugin"/>
- /// interface. This base class can be used by implementors
- /// of the <see cref="IPlugin"/> interface.
- /// </para>
- /// </remarks>
- /// <author>Nicko Cadell</author>
- /// <author>Gert Driesen</author>
- public abstract class PluginSkeleton : IPlugin
- {
- #region Protected Instance Constructors
+ /// <summary>
+ /// Base implementation of <see cref="IPlugin"/>
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Default abstract implementation of the <see cref="IPlugin"/>
+ /// interface. This base class can be used by implementors
+ /// of the <see cref="IPlugin"/> interface.
+ /// </para>
+ /// </remarks>
+ /// <author>Nicko Cadell</author>
+ /// <author>Gert Driesen</author>
+ public abstract class PluginSkeleton : IPlugin
+ {
+ #region Protected Instance Constructors
- /// <summary>
- /// Constructor
- /// </summary>
- /// <param name="name">the name of the plugin</param>
- /// <remarks>
- /// Initializes a new Plugin with the specified name.
- /// </remarks>
- protected PluginSkeleton(string name)
- {
- m_name = name;
- }
+ /// <summary>
+ /// Constructor
+ /// </summary>
+ /// <param name="name">the name of the plugin</param>
+ /// <remarks>
+ /// Initializes a new Plugin with the specified name.
+ /// </remarks>
+ protected PluginSkeleton(string name)
+ {
+ m_name = name;
+ }
- #endregion Protected Instance Constructors
+ #endregion Protected Instance Constructors
- #region Implementation of IPlugin
+ #region Implementation of IPlugin
- /// <summary>
- /// Gets or sets the name of the plugin.
- /// </summary>
- /// <value>
- /// The name of the plugin.
- /// </value>
- /// <remarks>
- /// <para>
- /// Plugins are stored in the <see cref="PluginMap"/>
- /// keyed by name. Each plugin instance attached to a
- /// repository must be a unique name.
- /// </para>
- /// <para>
- /// The name of the plugin must not change one the
- /// plugin has been attached to a repository.
- /// </para>
- /// </remarks>
- public virtual string Name
- {
- get { return m_name; }
- set { m_name = value; }
- }
+ /// <summary>
+ /// Gets or sets the name of the plugin.
+ /// </summary>
+ /// <value>
+ /// The name of the plugin.
+ /// </value>
+ /// <remarks>
+ /// <para>
+ /// Plugins are stored in the <see cref="PluginMap"/>
+ /// keyed by name. Each plugin instance attached to a
+ /// repository must be a unique name.
+ /// </para>
+ /// <para>
+ /// The name of the plugin must not change one the
+ /// plugin has been attached to a repository.
+ /// </para>
+ /// </remarks>
+ public virtual string Name
+ {
+ get { return m_name; }
+ set { m_name = value; }
+ }
- /// <summary>
- /// Attaches this plugin to a <see cref="ILoggerRepository"/>.
- /// </summary>
- /// <param name="repository">The <see cref="ILoggerRepository"/> that this plugin should be attached to.</param>
- /// <remarks>
- /// <para>
- /// A plugin may only be attached to a single repository.
- /// </para>
- /// <para>
- /// This method is called when the plugin is attached to the repository.
- /// </para>
- /// </remarks>
- public virtual void Attach(ILoggerRepository repository)
- {
- m_repository = repository;
- }
+ /// <summary>
+ /// Attaches this plugin to a <see cref="ILoggerRepository"/>.
+ /// </summary>
+ /// <param name="repository">The <see cref="ILoggerRepository"/> that this plugin should be attached to.</param>
+ /// <remarks>
+ /// <para>
+ /// A plugin may only be attached to a single repository.
+ /// </para>
+ /// <para>
+ /// This method is called when the plugin is attached to the repository.
+ /// </para>
+ /// </remarks>
+ public virtual void Attach(ILoggerRepository repository)
+ {
+ m_repository = repository;
+ }
- /// <summary>
- /// Is called when the plugin is to shutdown.
- /// </summary>
- /// <remarks>
- /// <para>
- /// This method is called to notify the plugin that
- /// it should stop operating and should detach from
- /// the repository.
- /// </para>
- /// </remarks>
- public virtual void Shutdown()
- {
- }
+ /// <summary>
+ /// Is called when the plugin is to shutdown.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// This method is called to notify the plugin that
+ /// it should stop operating and should detach from
+ /// the repository.
+ /// </para>
+ /// </remarks>
+ public virtual void Shutdown()
+ {
+ }
- #endregion Implementation of IPlugin
+ #endregion Implementation of IPlugin
- #region Protected Instance Properties
+ #region Protected Instance Properties
- /// <summary>
- /// The repository for this plugin
- /// </summary>
- /// <value>
- /// The <see cref="ILoggerRepository" /> that this plugin is attached to.
- /// </value>
- /// <remarks>
- /// <para>
- /// Gets or sets the <see cref="ILoggerRepository" /> that this plugin is
- /// attached to.
- /// </para>
- /// </remarks>
- protected virtual ILoggerRepository LoggerRepository
- {
- get { return this.m_repository; }
- set { this.m_repository = value; }
- }
+ /// <summary>
+ /// The repository for this plugin
+ /// </summary>
+ /// <value>
+ /// The <see cref="ILoggerRepository" /> that this plugin is attached to.
+ /// </value>
+ /// <remarks>
+ /// <para>
+ /// Gets or sets the <see cref="ILoggerRepository" /> that this plugin is
+ /// attached to.
+ /// </para>
+ /// </remarks>
+ protected virtual ILoggerRepository LoggerRepository
+ {
+ get { return this.m_repository; }
+ set { this.m_repository = value; }
+ }
- #endregion Protected Instance Properties
+ #endregion Protected Instance Properties
- #region Private Instance Fields
+ #region Private Instance Fields
- /// <summary>
- /// The name of this plugin.
- /// </summary>
- private string m_name;
+ /// <summary>
+ /// The name of this plugin.
+ /// </summary>
+ private string m_name;
- /// <summary>
- /// The repository this plugin is attached to.
- /// </summary>
- private ILoggerRepository m_repository;
+ /// <summary>
+ /// The repository this plugin is attached to.
+ /// </summary>
+ private ILoggerRepository m_repository;
- #endregion Private Instance Fields
- }
+ #endregion Private Instance Fields
+ }
}
diff --git a/src/log4net/Plugin/RemoteLoggingServerPlugin.cs b/src/log4net/Plugin/RemoteLoggingServerPlugin.cs
index ff5824b..ec05978 100644
--- a/src/log4net/Plugin/RemoteLoggingServerPlugin.cs
+++ b/src/log4net/Plugin/RemoteLoggingServerPlugin.cs
@@ -31,250 +31,250 @@
namespace log4net.Plugin
{
- /// <summary>
- /// Plugin that listens for events from the <see cref="log4net.Appender.RemotingAppender"/>
- /// </summary>
- /// <remarks>
- /// <para>
- /// This plugin publishes an instance of <see cref="IRemoteLoggingSink"/>
- /// on a specified <see cref="SinkUri"/>. This listens for logging events delivered from
- /// a remote <see cref="log4net.Appender.RemotingAppender"/>.
- /// </para>
- /// <para>
- /// When an event is received it is relogged within the attached repository
- /// as if it had been raised locally.
- /// </para>
- /// </remarks>
- /// <author>Nicko Cadell</author>
- /// <author>Gert Driesen</author>
- public class RemoteLoggingServerPlugin : PluginSkeleton
- {
- #region Public Instance Constructors
+ /// <summary>
+ /// Plugin that listens for events from the <see cref="log4net.Appender.RemotingAppender"/>
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// This plugin publishes an instance of <see cref="IRemoteLoggingSink"/>
+ /// on a specified <see cref="SinkUri"/>. This listens for logging events delivered from
+ /// a remote <see cref="log4net.Appender.RemotingAppender"/>.
+ /// </para>
+ /// <para>
+ /// When an event is received it is relogged within the attached repository
+ /// as if it had been raised locally.
+ /// </para>
+ /// </remarks>
+ /// <author>Nicko Cadell</author>
+ /// <author>Gert Driesen</author>
+ public class RemoteLoggingServerPlugin : PluginSkeleton
+ {
+ #region Public Instance Constructors
- /// <summary>
- /// Default constructor
- /// </summary>
- /// <remarks>
- /// <para>
- /// Initializes a new instance of the <see cref="RemoteLoggingServerPlugin" /> class.
- /// </para>
- /// <para>
- /// The <see cref="SinkUri"/> property must be set.
- /// </para>
- /// </remarks>
- public RemoteLoggingServerPlugin() : base("RemoteLoggingServerPlugin:Unset URI")
- {
- }
+ /// <summary>
+ /// Default constructor
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Initializes a new instance of the <see cref="RemoteLoggingServerPlugin" /> class.
+ /// </para>
+ /// <para>
+ /// The <see cref="SinkUri"/> property must be set.
+ /// </para>
+ /// </remarks>
+ public RemoteLoggingServerPlugin() : base("RemoteLoggingServerPlugin:Unset URI")
+ {
+ }
- /// <summary>
- /// Construct with sink Uri.
- /// </summary>
- /// <param name="sinkUri">The name to publish the sink under in the remoting infrastructure.
- /// See <see cref="SinkUri"/> for more details.</param>
- /// <remarks>
- /// <para>
- /// Initializes a new instance of the <see cref="RemoteLoggingServerPlugin" /> class
- /// with specified name.
- /// </para>
- /// </remarks>
- public RemoteLoggingServerPlugin(string sinkUri) : base("RemoteLoggingServerPlugin:"+sinkUri)
- {
- m_sinkUri = sinkUri;
- }
+ /// <summary>
+ /// Construct with sink Uri.
+ /// </summary>
+ /// <param name="sinkUri">The name to publish the sink under in the remoting infrastructure.
+ /// See <see cref="SinkUri"/> for more details.</param>
+ /// <remarks>
+ /// <para>
+ /// Initializes a new instance of the <see cref="RemoteLoggingServerPlugin" /> class
+ /// with specified name.
+ /// </para>
+ /// </remarks>
+ public RemoteLoggingServerPlugin(string sinkUri) : base("RemoteLoggingServerPlugin:"+sinkUri)
+ {
+ m_sinkUri = sinkUri;
+ }
- #endregion Public Instance Constructors
+ #endregion Public Instance Constructors
- #region Public Instance Properties
+ #region Public Instance Properties
- /// <summary>
- /// Gets or sets the URI of this sink.
- /// </summary>
- /// <value>
- /// The URI of this sink.
- /// </value>
- /// <remarks>
- /// <para>
- /// This is the name under which the object is marshaled.
- /// <see cref="M:RemotingServices.Marshal(MarshalByRefObject,String,Type)"/>
- /// </para>
- /// </remarks>
- public virtual string SinkUri
- {
- get { return m_sinkUri; }
- set { m_sinkUri = value; }
- }
+ /// <summary>
+ /// Gets or sets the URI of this sink.
+ /// </summary>
+ /// <value>
+ /// The URI of this sink.
+ /// </value>
+ /// <remarks>
+ /// <para>
+ /// This is the name under which the object is marshaled.
+ /// <see cref="M:RemotingServices.Marshal(MarshalByRefObject,String,Type)"/>
+ /// </para>
+ /// </remarks>
+ public virtual string SinkUri
+ {
+ get { return m_sinkUri; }
+ set { m_sinkUri = value; }
+ }
- #endregion Public Instance Properties
+ #endregion Public Instance Properties
- #region Override implementation of PluginSkeleton
+ #region Override implementation of PluginSkeleton
- /// <summary>
- /// Attaches this plugin to a <see cref="ILoggerRepository"/>.
- /// </summary>
- /// <param name="repository">The <see cref="ILoggerRepository"/> that this plugin should be attached to.</param>
- /// <remarks>
- /// <para>
- /// A plugin may only be attached to a single repository.
- /// </para>
- /// <para>
- /// This method is called when the plugin is attached to the repository.
- /// </para>
- /// </remarks>
+ /// <summary>
+ /// Attaches this plugin to a <see cref="ILoggerRepository"/>.
+ /// </summary>
+ /// <param name="repository">The <see cref="ILoggerRepository"/> that this plugin should be attached to.</param>
+ /// <remarks>
+ /// <para>
+ /// A plugin may only be attached to a single repository.
+ /// </para>
+ /// <para>
+ /// This method is called when the plugin is attached to the repository.
+ /// </para>
+ /// </remarks>
#if NET_4_0 || MONO_4_0
- [System.Security.SecuritySafeCritical]
+ [System.Security.SecuritySafeCritical]
#endif
- public override void Attach(ILoggerRepository repository)
- {
- base.Attach(repository);
+ public override void Attach(ILoggerRepository repository)
+ {
+ base.Attach(repository);
- // Create the sink and marshal it
- m_sink = new RemoteLoggingSinkImpl(repository);
+ // Create the sink and marshal it
+ m_sink = new RemoteLoggingSinkImpl(repository);
- try
- {
- RemotingServices.Marshal(m_sink, m_sinkUri, typeof(IRemoteLoggingSink));
- }
- catch(Exception ex)
- {
- LogLog.Error(declaringType, "Failed to Marshal remoting sink", ex);
- }
- }
+ try
+ {
+ RemotingServices.Marshal(m_sink, m_sinkUri, typeof(IRemoteLoggingSink));
+ }
+ catch(Exception ex)
+ {
+ LogLog.Error(declaringType, "Failed to Marshal remoting sink", ex);
+ }
+ }
- /// <summary>
- /// Is called when the plugin is to shutdown.
- /// </summary>
- /// <remarks>
- /// <para>
- /// When the plugin is shutdown the remote logging
- /// sink is disconnected.
- /// </para>
- /// </remarks>
+ /// <summary>
+ /// Is called when the plugin is to shutdown.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// When the plugin is shutdown the remote logging
+ /// sink is disconnected.
+ /// </para>
+ /// </remarks>
#if NET_4_0 || MONO_4_0
[System.Security.SecuritySafeCritical]
#endif
public override void Shutdown()
- {
- // Stops the sink from receiving messages
- RemotingServices.Disconnect(m_sink);
- m_sink = null;
+ {
+ // Stops the sink from receiving messages
+ RemotingServices.Disconnect(m_sink);
+ m_sink = null;
- base.Shutdown();
- }
+ base.Shutdown();
+ }
- #endregion Override implementation of PluginSkeleton
+ #endregion Override implementation of PluginSkeleton
- #region Private Instance Fields
+ #region Private Instance Fields
- private RemoteLoggingSinkImpl m_sink;
- private string m_sinkUri;
+ private RemoteLoggingSinkImpl m_sink;
+ private string m_sinkUri;
- #endregion Private Instance Fields
+ #endregion Private Instance Fields
- #region Private Static Fields
+ #region Private Static Fields
- /// <summary>
- /// The fully qualified type of the RemoteLoggingServerPlugin class.
- /// </summary>
- /// <remarks>
- /// Used by the internal logger to record the Type of the
- /// log message.
- /// </remarks>
- private static readonly Type declaringType = typeof(RemoteLoggingServerPlugin);
+ /// <summary>
+ /// The fully qualified type of the RemoteLoggingServerPlugin class.
+ /// </summary>
+ /// <remarks>
+ /// Used by the internal logger to record the Type of the
+ /// log message.
+ /// </remarks>
+ private static readonly Type declaringType = typeof(RemoteLoggingServerPlugin);
- #endregion Private Static Fields
+ #endregion Private Static Fields
- /// <summary>
- /// Delivers <see cref="LoggingEvent"/> objects to a remote sink.
- /// </summary>
- /// <remarks>
- /// <para>
- /// Internal class used to listen for logging events
- /// and deliver them to the local repository.
- /// </para>
- /// </remarks>
- private class RemoteLoggingSinkImpl : MarshalByRefObject, IRemoteLoggingSink
- {
- #region Public Instance Constructors
+ /// <summary>
+ /// Delivers <see cref="LoggingEvent"/> objects to a remote sink.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Internal class used to listen for logging events
+ /// and deliver them to the local repository.
+ /// </para>
+ /// </remarks>
+ private class RemoteLoggingSinkImpl : MarshalByRefObject, IRemoteLoggingSink
+ {
+ #region Public Instance Constructors
- /// <summary>
- /// Constructor
- /// </summary>
- /// <param name="repository">The repository to log to.</param>
- /// <remarks>
- /// <para>
- /// Initializes a new instance of the <see cref="RemoteLoggingSinkImpl"/> for the
- /// specified <see cref="ILoggerRepository"/>.
- /// </para>
- /// </remarks>
- public RemoteLoggingSinkImpl(ILoggerRepository repository)
- {
- m_repository = repository;
- }
+ /// <summary>
+ /// Constructor
+ /// </summary>
+ /// <param name="repository">The repository to log to.</param>
+ /// <remarks>
+ /// <para>
+ /// Initializes a new instance of the <see cref="RemoteLoggingSinkImpl"/> for the
+ /// specified <see cref="ILoggerRepository"/>.
+ /// </para>
+ /// </remarks>
+ public RemoteLoggingSinkImpl(ILoggerRepository repository)
+ {
+ m_repository = repository;
+ }
- #endregion Public Instance Constructors
+ #endregion Public Instance Constructors
- #region Implementation of IRemoteLoggingSink
+ #region Implementation of IRemoteLoggingSink
- /// <summary>
- /// Logs the events to the repository.
- /// </summary>
- /// <param name="events">The events to log.</param>
- /// <remarks>
- /// <para>
- /// The events passed are logged to the <see cref="ILoggerRepository"/>
- /// </para>
- /// </remarks>
- public void LogEvents(LoggingEvent[] events)
- {
- if (events != null)
- {
- foreach(LoggingEvent logEvent in events)
- {
- if (logEvent != null)
- {
- m_repository.Log(logEvent);
- }
- }
- }
- }
+ /// <summary>
+ /// Logs the events to the repository.
+ /// </summary>
+ /// <param name="events">The events to log.</param>
+ /// <remarks>
+ /// <para>
+ /// The events passed are logged to the <see cref="ILoggerRepository"/>
+ /// </para>
+ /// </remarks>
+ public void LogEvents(LoggingEvent[] events)
+ {
+ if (events != null)
+ {
+ foreach(LoggingEvent logEvent in events)
+ {
+ if (logEvent != null)
+ {
+ m_repository.Log(logEvent);
+ }
+ }
+ }
+ }
- #endregion Implementation of IRemoteLoggingSink
+ #endregion Implementation of IRemoteLoggingSink
- #region Override implementation of MarshalByRefObject
+ #region Override implementation of MarshalByRefObject
- /// <summary>
- /// Obtains a lifetime service object to control the lifetime
- /// policy for this instance.
- /// </summary>
- /// <returns><c>null</c> to indicate that this instance should live forever.</returns>
- /// <remarks>
- /// <para>
- /// Obtains a lifetime service object to control the lifetime
- /// policy for this instance. This object should live forever
- /// therefore this implementation returns <c>null</c>.
- /// </para>
- /// </remarks>
+ /// <summary>
+ /// Obtains a lifetime service object to control the lifetime
+ /// policy for this instance.
+ /// </summary>
+ /// <returns><c>null</c> to indicate that this instance should live forever.</returns>
+ /// <remarks>
+ /// <para>
+ /// Obtains a lifetime service object to control the lifetime
+ /// policy for this instance. This object should live forever
+ /// therefore this implementation returns <c>null</c>.
+ /// </para>
+ /// </remarks>
#if NET_4_0 || MONO_4_0
[System.Security.SecurityCritical]
#endif
public override object InitializeLifetimeService()
- {
- return null;
- }
+ {
+ return null;
+ }
- #endregion Override implementation of MarshalByRefObject
+ #endregion Override implementation of MarshalByRefObject
- #region Private Instance Fields
+ #region Private Instance Fields
- /// <summary>
- /// The underlying <see cref="ILoggerRepository" /> that events should
- /// be logged to.
- /// </summary>
- private readonly ILoggerRepository m_repository;
+ /// <summary>
+ /// The underlying <see cref="ILoggerRepository" /> that events should
+ /// be logged to.
+ /// </summary>
+ private readonly ILoggerRepository m_repository;
- #endregion Private Instance Fields
- }
- }
+ #endregion Private Instance Fields
+ }
+ }
}
#endif // NET_2_0
\ No newline at end of file
diff --git a/src/log4net/Repository/Hierarchy/DefaultLoggerFactory.cs b/src/log4net/Repository/Hierarchy/DefaultLoggerFactory.cs
index 78239c5..9bb079b 100644
--- a/src/log4net/Repository/Hierarchy/DefaultLoggerFactory.cs
+++ b/src/log4net/Repository/Hierarchy/DefaultLoggerFactory.cs
@@ -21,94 +21,94 @@
namespace log4net.Repository.Hierarchy
{
- /// <summary>
- /// Default implementation of <see cref="ILoggerFactory"/>
- /// </summary>
- /// <remarks>
- /// <para>
- /// This default implementation of the <see cref="ILoggerFactory"/>
- /// interface is used to create the default subclass
- /// of the <see cref="Logger"/> object.
- /// </para>
- /// </remarks>
- /// <author>Nicko Cadell</author>
- /// <author>Gert Driesen</author>
- internal class DefaultLoggerFactory : ILoggerFactory
- {
- #region Internal Instance Constructors
+ /// <summary>
+ /// Default implementation of <see cref="ILoggerFactory"/>
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// This default implementation of the <see cref="ILoggerFactory"/>
+ /// interface is used to create the default subclass
+ /// of the <see cref="Logger"/> object.
+ /// </para>
+ /// </remarks>
+ /// <author>Nicko Cadell</author>
+ /// <author>Gert Driesen</author>
+ internal class DefaultLoggerFactory : ILoggerFactory
+ {
+ #region Internal Instance Constructors
- /// <summary>
- /// Default constructor
- /// </summary>
- /// <remarks>
- /// <para>
- /// Initializes a new instance of the <see cref="DefaultLoggerFactory" /> class.
- /// </para>
- /// </remarks>
- internal DefaultLoggerFactory()
- {
- }
+ /// <summary>
+ /// Default constructor
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Initializes a new instance of the <see cref="DefaultLoggerFactory" /> class.
+ /// </para>
+ /// </remarks>
+ internal DefaultLoggerFactory()
+ {
+ }
- #endregion Internal Instance Constructors
+ #endregion Internal Instance Constructors
- #region Implementation of ILoggerFactory
+ #region Implementation of ILoggerFactory
- /// <summary>
- /// Create a new <see cref="Logger" /> instance
- /// </summary>
- /// <param name="repository">The <see cref="ILoggerRepository" /> that will own the <see cref="Logger" />.</param>
- /// <param name="name">The name of the <see cref="Logger" />.</param>
- /// <returns>The <see cref="Logger" /> instance for the specified name.</returns>
- /// <remarks>
- /// <para>
- /// Create a new <see cref="Logger" /> instance with the
- /// specified name.
- /// </para>
- /// <para>
- /// Called by the <see cref="Hierarchy"/> to create
- /// new named <see cref="Logger"/> instances.
- /// </para>
- /// <para>
- /// If the <paramref name="name"/> is <c>null</c> then the root logger
- /// must be returned.
- /// </para>
- /// </remarks>
- public Logger CreateLogger(ILoggerRepository repository, string name)
- {
- if (name == null)
- {
- return new RootLogger(repository.LevelMap.LookupWithDefault(Level.Debug));
- }
- return new LoggerImpl(name);
- }
+ /// <summary>
+ /// Create a new <see cref="Logger" /> instance
+ /// </summary>
+ /// <param name="repository">The <see cref="ILoggerRepository" /> that will own the <see cref="Logger" />.</param>
+ /// <param name="name">The name of the <see cref="Logger" />.</param>
+ /// <returns>The <see cref="Logger" /> instance for the specified name.</returns>
+ /// <remarks>
+ /// <para>
+ /// Create a new <see cref="Logger" /> instance with the
+ /// specified name.
+ /// </para>
+ /// <para>
+ /// Called by the <see cref="Hierarchy"/> to create
+ /// new named <see cref="Logger"/> instances.
+ /// </para>
+ /// <para>
+ /// If the <paramref name="name"/> is <c>null</c> then the root logger
+ /// must be returned.
+ /// </para>
+ /// </remarks>
+ public Logger CreateLogger(ILoggerRepository repository, string name)
+ {
+ if (name == null)
+ {
+ return new RootLogger(repository.LevelMap.LookupWithDefault(Level.Debug));
+ }
+ return new LoggerImpl(name);
+ }
- #endregion
+ #endregion
- /// <summary>
- /// Default internal subclass of <see cref="Logger"/>
- /// </summary>
- /// <remarks>
- /// <para>
- /// This subclass has no additional behavior over the
- /// <see cref="Logger"/> class but does allow instances
- /// to be created.
- /// </para>
- /// </remarks>
- internal sealed class LoggerImpl : Logger
- {
- /// <summary>
- /// Construct a new Logger
- /// </summary>
- /// <param name="name">the name of the logger</param>
- /// <remarks>
- /// <para>
- /// Initializes a new instance of the <see cref="LoggerImpl" /> class
- /// with the specified name.
- /// </para>
- /// </remarks>
- internal LoggerImpl(string name) : base(name)
- {
- }
- }
- }
+ /// <summary>
+ /// Default internal subclass of <see cref="Logger"/>
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// This subclass has no additional behavior over the
+ /// <see cref="Logger"/> class but does allow instances
+ /// to be created.
+ /// </para>
+ /// </remarks>
+ internal sealed class LoggerImpl : Logger
+ {
+ /// <summary>
+ /// Construct a new Logger
+ /// </summary>
+ /// <param name="name">the name of the logger</param>
+ /// <remarks>
+ /// <para>
+ /// Initializes a new instance of the <see cref="LoggerImpl" /> class
+ /// with the specified name.
+ /// </para>
+ /// </remarks>
+ internal LoggerImpl(string name) : base(name)
+ {
+ }
+ }
+ }
}
diff --git a/src/log4net/Repository/Hierarchy/Hierarchy.cs b/src/log4net/Repository/Hierarchy/Hierarchy.cs
index c21d09a..ce215be 100644
--- a/src/log4net/Repository/Hierarchy/Hierarchy.cs
+++ b/src/log4net/Repository/Hierarchy/Hierarchy.cs
@@ -26,523 +26,523 @@
namespace log4net.Repository.Hierarchy
{
- #region LoggerCreationEvent
+ #region LoggerCreationEvent
- /// <summary>
- /// Delegate used to handle logger creation event notifications.
- /// </summary>
- /// <param name="sender">The <see cref="Hierarchy"/> in which the <see cref="Logger"/> has been created.</param>
- /// <param name="e">The <see cref="LoggerCreationEventArgs"/> event args that hold the <see cref="Logger"/> instance that has been created.</param>
- /// <remarks>
- /// <para>
- /// Delegate used to handle logger creation event notifications.
- /// </para>
- /// </remarks>
- public delegate void LoggerCreationEventHandler(object sender, LoggerCreationEventArgs e);
+ /// <summary>
+ /// Delegate used to handle logger creation event notifications.
+ /// </summary>
+ /// <param name="sender">The <see cref="Hierarchy"/> in which the <see cref="Logger"/> has been created.</param>
+ /// <param name="e">The <see cref="LoggerCreationEventArgs"/> event args that hold the <see cref="Logger"/> instance that has been created.</param>
+ /// <remarks>
+ /// <para>
+ /// Delegate used to handle logger creation event notifications.
+ /// </para>
+ /// </remarks>
+ public delegate void LoggerCreationEventHandler(object sender, LoggerCreationEventArgs e);
- /// <summary>
- /// Provides data for the <see cref="Hierarchy.LoggerCreatedEvent"/> event.
- /// </summary>
- /// <remarks>
- /// <para>
- /// A <see cref="Hierarchy.LoggerCreatedEvent"/> event is raised every time a
- /// <see cref="Logger"/> is created.
- /// </para>
- /// </remarks>
- public class LoggerCreationEventArgs : EventArgs
- {
- /// <summary>
- /// The <see cref="Logger"/> created
- /// </summary>
- private Logger m_log;
+ /// <summary>
+ /// Provides data for the <see cref="Hierarchy.LoggerCreatedEvent"/> event.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// A <see cref="Hierarchy.LoggerCreatedEvent"/> event is raised every time a
+ /// <see cref="Logger"/> is created.
+ /// </para>
+ /// </remarks>
+ public class LoggerCreationEventArgs : EventArgs
+ {
+ /// <summary>
+ /// The <see cref="Logger"/> created
+ /// </summary>
+ private Logger m_log;
- /// <summary>
- /// Constructor
- /// </summary>
- /// <param name="log">The <see cref="Logger"/> that has been created.</param>
- /// <remarks>
- /// <para>
- /// Initializes a new instance of the <see cref="LoggerCreationEventArgs" /> event argument
- /// class,with the specified <see cref="Logger"/>.
- /// </para>
- /// </remarks>
- public LoggerCreationEventArgs(Logger log)
- {
- m_log = log;
- }
+ /// <summary>
+ /// Constructor
+ /// </summary>
+ /// <param name="log">The <see cref="Logger"/> that has been created.</param>
+ /// <remarks>
+ /// <para>
+ /// Initializes a new instance of the <see cref="LoggerCreationEventArgs" /> event argument
+ /// class,with the specified <see cref="Logger"/>.
+ /// </para>
+ /// </remarks>
+ public LoggerCreationEventArgs(Logger log)
+ {
+ m_log = log;
+ }
- /// <summary>
- /// Gets the <see cref="Logger"/> that has been created.
- /// </summary>
- /// <value>
- /// The <see cref="Logger"/> that has been created.
- /// </value>
- /// <remarks>
- /// <para>
- /// The <see cref="Logger"/> that has been created.
- /// </para>
- /// </remarks>
- public Logger Logger
- {
- get { return m_log; }
- }
- }
+ /// <summary>
+ /// Gets the <see cref="Logger"/> that has been created.
+ /// </summary>
+ /// <value>
+ /// The <see cref="Logger"/> that has been created.
+ /// </value>
+ /// <remarks>
+ /// <para>
+ /// The <see cref="Logger"/> that has been created.
+ /// </para>
+ /// </remarks>
+ public Logger Logger
+ {
+ get { return m_log; }
+ }
+ }
- #endregion LoggerCreationEvent
+ #endregion LoggerCreationEvent
- /// <summary>
- /// Hierarchical organization of loggers
- /// </summary>
- /// <remarks>
- /// <para>
- /// <i>The casual user should not have to deal with this class
- /// directly.</i>
- /// </para>
- /// <para>
- /// This class is specialized in retrieving loggers by name and
- /// also maintaining the logger hierarchy. Implements the
- /// <see cref="ILoggerRepository"/> interface.
- /// </para>
- /// <para>
- /// The structure of the logger hierarchy is maintained by the
- /// <see cref="M:GetLogger(string)"/> method. The hierarchy is such that children
- /// link to their parent but parents do not have any references to their
- /// children. Moreover, loggers can be instantiated in any order, in
- /// particular descendant before ancestor.
- /// </para>
- /// <para>
- /// In case a descendant is created before a particular ancestor,
- /// then it creates a provision node for the ancestor and adds itself
- /// to the provision node. Other descendants of the same ancestor add
- /// themselves to the previously created provision node.
- /// </para>
- /// </remarks>
- /// <author>Nicko Cadell</author>
- /// <author>Gert Driesen</author>
- public class Hierarchy : LoggerRepositorySkeleton, IBasicRepositoryConfigurator, IXmlRepositoryConfigurator
- {
- #region Public Events
+ /// <summary>
+ /// Hierarchical organization of loggers
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// <i>The casual user should not have to deal with this class
+ /// directly.</i>
+ /// </para>
+ /// <para>
+ /// This class is specialized in retrieving loggers by name and
+ /// also maintaining the logger hierarchy. Implements the
+ /// <see cref="ILoggerRepository"/> interface.
+ /// </para>
+ /// <para>
+ /// The structure of the logger hierarchy is maintained by the
+ /// <see cref="M:GetLogger(string)"/> method. The hierarchy is such that children
+ /// link to their parent but parents do not have any references to their
+ /// children. Moreover, loggers can be instantiated in any order, in
+ /// particular descendant before ancestor.
+ /// </para>
+ /// <para>
+ /// In case a descendant is created before a particular ancestor,
+ /// then it creates a provision node for the ancestor and adds itself
+ /// to the provision node. Other descendants of the same ancestor add
+ /// themselves to the previously created provision node.
+ /// </para>
+ /// </remarks>
+ /// <author>Nicko Cadell</author>
+ /// <author>Gert Driesen</author>
+ public class Hierarchy : LoggerRepositorySkeleton, IBasicRepositoryConfigurator, IXmlRepositoryConfigurator
+ {
+ #region Public Events
- /// <summary>
- /// Event used to notify that a logger has been created.
- /// </summary>
- /// <remarks>
- /// <para>
- /// Event raised when a logger is created.
- /// </para>
- /// </remarks>
- public event LoggerCreationEventHandler LoggerCreatedEvent
- {
- add { m_loggerCreatedEvent += value; }
- remove { m_loggerCreatedEvent -= value; }
- }
+ /// <summary>
+ /// Event used to notify that a logger has been created.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Event raised when a logger is created.
+ /// </para>
+ /// </remarks>
+ public event LoggerCreationEventHandler LoggerCreatedEvent
+ {
+ add { m_loggerCreatedEvent += value; }
+ remove { m_loggerCreatedEvent -= value; }
+ }
- #endregion Public Events
+ #endregion Public Events
- #region Public Instance Constructors
+ #region Public Instance Constructors
- /// <summary>
- /// Default constructor
- /// </summary>
- /// <remarks>
- /// <para>
- /// Initializes a new instance of the <see cref="Hierarchy" /> class.
- /// </para>
- /// </remarks>
- public Hierarchy() : this(new DefaultLoggerFactory())
- {
- }
+ /// <summary>
+ /// Default constructor
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Initializes a new instance of the <see cref="Hierarchy" /> class.
+ /// </para>
+ /// </remarks>
+ public Hierarchy() : this(new DefaultLoggerFactory())
+ {
+ }
- /// <summary>
- /// Construct with properties
- /// </summary>
- /// <param name="properties">The properties to pass to this repository.</param>
- /// <remarks>
- /// <para>
- /// Initializes a new instance of the <see cref="Hierarchy" /> class.
- /// </para>
- /// </remarks>
- public Hierarchy(PropertiesDictionary properties) : this(properties, new DefaultLoggerFactory())
- {
- }
+ /// <summary>
+ /// Construct with properties
+ /// </summary>
+ /// <param name="properties">The properties to pass to this repository.</param>
+ /// <remarks>
+ /// <para>
+ /// Initializes a new instance of the <see cref="Hierarchy" /> class.
+ /// </para>
+ /// </remarks>
+ public Hierarchy(PropertiesDictionary properties) : this(properties, new DefaultLoggerFactory())
+ {
+ }
- /// <summary>
- /// Construct with a logger factory
- /// </summary>
- /// <param name="loggerFactory">The factory to use to create new logger instances.</param>
- /// <remarks>
- /// <para>
- /// Initializes a new instance of the <see cref="Hierarchy" /> class with
- /// the specified <see cref="ILoggerFactory" />.
- /// </para>
- /// </remarks>
- public Hierarchy(ILoggerFactory loggerFactory) : this(new PropertiesDictionary(), loggerFactory)
- {
- }
+ /// <summary>
+ /// Construct with a logger factory
+ /// </summary>
+ /// <param name="loggerFactory">The factory to use to create new logger instances.</param>
+ /// <remarks>
+ /// <para>
+ /// Initializes a new instance of the <see cref="Hierarchy" /> class with
+ /// the specified <see cref="ILoggerFactory" />.
+ /// </para>
+ /// </remarks>
+ public Hierarchy(ILoggerFactory loggerFactory) : this(new PropertiesDictionary(), loggerFactory)
+ {
+ }
- /// <summary>
- /// Construct with properties and a logger factory
- /// </summary>
- /// <param name="properties">The properties to pass to this repository.</param>
- /// <param name="loggerFactory">The factory to use to create new logger instances.</param>
- /// <remarks>
- /// <para>
- /// Initializes a new instance of the <see cref="Hierarchy" /> class with
- /// the specified <see cref="ILoggerFactory" />.
- /// </para>
- /// </remarks>
- public Hierarchy(PropertiesDictionary properties, ILoggerFactory loggerFactory) : base(properties)
- {
- if (loggerFactory == null)
- {
- throw new ArgumentNullException("loggerFactory");
- }
+ /// <summary>
+ /// Construct with properties and a logger factory
+ /// </summary>
+ /// <param name="properties">The properties to pass to this repository.</param>
+ /// <param name="loggerFactory">The factory to use to create new logger instances.</param>
+ /// <remarks>
+ /// <para>
+ /// Initializes a new instance of the <see cref="Hierarchy" /> class with
+ /// the specified <see cref="ILoggerFactory" />.
+ /// </para>
+ /// </remarks>
+ public Hierarchy(PropertiesDictionary properties, ILoggerFactory loggerFactory) : base(properties)
+ {
+ if (loggerFactory == null)
+ {
+ throw new ArgumentNullException("loggerFactory");
+ }
- m_defaultFactory = loggerFactory;
+ m_defaultFactory = loggerFactory;
- m_ht = System.Collections.Hashtable.Synchronized(new System.Collections.Hashtable());
- }
+ m_ht = System.Collections.Hashtable.Synchronized(new System.Collections.Hashtable());
+ }
- #endregion Public Instance Constructors
+ #endregion Public Instance Constructors
- #region Public Instance Properties
+ #region Public Instance Properties
- /// <summary>
- /// Has no appender warning been emitted
- /// </summary>
- /// <remarks>
- /// <para>
- /// Flag to indicate if we have already issued a warning
- /// about not having an appender warning.
- /// </para>
- /// </remarks>
- public bool EmittedNoAppenderWarning
- {
- get { return m_emittedNoAppenderWarning; }
- set { m_emittedNoAppenderWarning = value; }
- }
+ /// <summary>
+ /// Has no appender warning been emitted
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Flag to indicate if we have already issued a warning
+ /// about not having an appender warning.
+ /// </para>
+ /// </remarks>
+ public bool EmittedNoAppenderWarning
+ {
+ get { return m_emittedNoAppenderWarning; }
+ set { m_emittedNoAppenderWarning = value; }
+ }
- /// <summary>
- /// Get the root of this hierarchy
- /// </summary>
- /// <remarks>
- /// <para>
- /// Get the root of this hierarchy.
- /// </para>
- /// </remarks>
- public Logger Root
- {
- get
- {
- if (m_root == null)
- {
- lock(this)
- {
- if (m_root == null)
- {
- // Create the root logger
- Logger root = m_defaultFactory.CreateLogger(this, null);
- root.Hierarchy = this;
+ /// <summary>
+ /// Get the root of this hierarchy
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Get the root of this hierarchy.
+ /// </para>
+ /// </remarks>
+ public Logger Root
+ {
+ get
+ {
+ if (m_root == null)
+ {
+ lock(this)
+ {
+ if (m_root == null)
+ {
+ // Create the root logger
+ Logger root = m_defaultFactory.CreateLogger(this, null);
+ root.Hierarchy = this;
- // Store root
- m_root = root;
- }
- }
- }
- return m_root;
- }
- }
+ // Store root
+ m_root = root;
+ }
+ }
+ }
+ return m_root;
+ }
+ }
- /// <summary>
- /// Gets or sets the default <see cref="ILoggerFactory" /> instance.
- /// </summary>
- /// <value>The default <see cref="ILoggerFactory" /></value>
- /// <remarks>
- /// <para>
- /// The logger factory is used to create logger instances.
- /// </para>
- /// </remarks>
- public ILoggerFactory LoggerFactory
- {
- get { return m_defaultFactory; }
- set
- {
- if (value == null)
- {
- throw new ArgumentNullException("value");
- }
- m_defaultFactory = value;
- }
- }
+ /// <summary>
+ /// Gets or sets the default <see cref="ILoggerFactory" /> instance.
+ /// </summary>
+ /// <value>The default <see cref="ILoggerFactory" /></value>
+ /// <remarks>
+ /// <para>
+ /// The logger factory is used to create logger instances.
+ /// </para>
+ /// </remarks>
+ public ILoggerFactory LoggerFactory
+ {
+ get { return m_defaultFactory; }
+ set
+ {
+ if (value == null)
+ {
+ throw new ArgumentNullException("value");
+ }
+ m_defaultFactory = value;
+ }
+ }
- #endregion Public Instance Properties
+ #endregion Public Instance Properties
- #region Override Implementation of LoggerRepositorySkeleton
+ #region Override Implementation of LoggerRepositorySkeleton
- /// <summary>
- /// Test if a logger exists
- /// </summary>
- /// <param name="name">The name of the logger to lookup</param>
- /// <returns>The Logger object with the name specified</returns>
- /// <remarks>
- /// <para>
- /// Check if the named logger exists in the hierarchy. If so return
- /// its reference, otherwise returns <c>null</c>.
- /// </para>
- /// </remarks>
- public override ILogger Exists(string name)
- {
- if (name == null)
- {
- throw new ArgumentNullException("name");
- }
+ /// <summary>
+ /// Test if a logger exists
+ /// </summary>
+ /// <param name="name">The name of the logger to lookup</param>
+ /// <returns>The Logger object with the name specified</returns>
+ /// <remarks>
+ /// <para>
+ /// Check if the named logger exists in the hierarchy. If so return
+ /// its reference, otherwise returns <c>null</c>.
+ /// </para>
+ /// </remarks>
+ public override ILogger Exists(string name)
+ {
+ if (name == null)
+ {
+ throw new ArgumentNullException("name");
+ }
- lock(m_ht)
- {
- return m_ht[new LoggerKey(name)] as Logger;
- }
- }
+ lock(m_ht)
+ {
+ return m_ht[new LoggerKey(name)] as Logger;
+ }
+ }
- /// <summary>
- /// Returns all the currently defined loggers in the hierarchy as an Array
- /// </summary>
- /// <returns>All the defined loggers</returns>
- /// <remarks>
- /// <para>
- /// Returns all the currently defined loggers in the hierarchy as an Array.
- /// The root logger is <b>not</b> included in the returned
- /// enumeration.
- /// </para>
- /// </remarks>
- public override ILogger[] GetCurrentLoggers()
- {
- // The accumulation in loggers is necessary because not all elements in
- // ht are Logger objects as there might be some ProvisionNodes
- // as well.
- lock(m_ht)
- {
- System.Collections.ArrayList loggers = new System.Collections.ArrayList(m_ht.Count);
-
- // Iterate through m_ht values
- foreach(object node in m_ht.Values)
- {
- if (node is Logger)
- {
- loggers.Add(node);
- }
- }
- return (Logger[])loggers.ToArray(typeof(Logger));
- }
- }
+ /// <summary>
+ /// Returns all the currently defined loggers in the hierarchy as an Array
+ /// </summary>
+ /// <returns>All the defined loggers</returns>
+ /// <remarks>
+ /// <para>
+ /// Returns all the currently defined loggers in the hierarchy as an Array.
+ /// The root logger is <b>not</b> included in the returned
+ /// enumeration.
+ /// </para>
+ /// </remarks>
+ public override ILogger[] GetCurrentLoggers()
+ {
+ // The accumulation in loggers is necessary because not all elements in
+ // ht are Logger objects as there might be some ProvisionNodes
+ // as well.
+ lock(m_ht)
+ {
+ System.Collections.ArrayList loggers = new System.Collections.ArrayList(m_ht.Count);
+
+ // Iterate through m_ht values
+ foreach(object node in m_ht.Values)
+ {
+ if (node is Logger)
+ {
+ loggers.Add(node);
+ }
+ }
+ return (Logger[])loggers.ToArray(typeof(Logger));
+ }
+ }
- /// <summary>
- /// Return a new logger instance named as the first parameter using
- /// the default factory.
- /// </summary>
- /// <remarks>
- /// <para>
- /// Return a new logger instance named as the first parameter using
- /// the default factory.
- /// </para>
- /// <para>
- /// If a logger of that name already exists, then it will be
- /// returned. Otherwise, a new logger will be instantiated and
- /// then linked with its existing ancestors as well as children.
- /// </para>
- /// </remarks>
- /// <param name="name">The name of the logger to retrieve</param>
- /// <returns>The logger object with the name specified</returns>
- public override ILogger GetLogger(string name)
- {
- if (name == null)
- {
- throw new ArgumentNullException("name");
- }
+ /// <summary>
+ /// Return a new logger instance named as the first parameter using
+ /// the default factory.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Return a new logger instance named as the first parameter using
+ /// the default factory.
+ /// </para>
+ /// <para>
+ /// If a logger of that name already exists, then it will be
+ /// returned. Otherwise, a new logger will be instantiated and
+ /// then linked with its existing ancestors as well as children.
+ /// </para>
+ /// </remarks>
+ /// <param name="name">The name of the logger to retrieve</param>
+ /// <returns>The logger object with the name specified</returns>
+ public override ILogger GetLogger(string name)
+ {
+ if (name == null)
+ {
+ throw new ArgumentNullException("name");
+ }
- return GetLogger(name, m_defaultFactory);
- }
+ return GetLogger(name, m_defaultFactory);
+ }
- /// <summary>
- /// Shutting down a hierarchy will <i>safely</i> close and remove
- /// all appenders in all loggers including the root logger.
- /// </summary>
- /// <remarks>
- /// <para>
- /// Shutting down a hierarchy will <i>safely</i> close and remove
- /// all appenders in all loggers including the root logger.
- /// </para>
- /// <para>
- /// Some appenders need to be closed before the
- /// application exists. Otherwise, pending logging events might be
- /// lost.
- /// </para>
- /// <para>
- /// The <c>Shutdown</c> method is careful to close nested
- /// appenders before closing regular appenders. This is allows
- /// configurations where a regular appender is attached to a logger
- /// and again to a nested appender.
- /// </para>
- /// </remarks>
- public override void Shutdown()
- {
- LogLog.Debug(declaringType, "Shutdown called on Hierarchy ["+this.Name+"]");
+ /// <summary>
+ /// Shutting down a hierarchy will <i>safely</i> close and remove
+ /// all appenders in all loggers including the root logger.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Shutting down a hierarchy will <i>safely</i> close and remove
+ /// all appenders in all loggers including the root logger.
+ /// </para>
+ /// <para>
+ /// Some appenders need to be closed before the
+ /// application exists. Otherwise, pending logging events might be
+ /// lost.
+ /// </para>
+ /// <para>
+ /// The <c>Shutdown</c> method is careful to close nested
+ /// appenders before closing regular appenders. This is allows
+ /// configurations where a regular appender is attached to a logger
+ /// and again to a nested appender.
+ /// </para>
+ /// </remarks>
+ public override void Shutdown()
+ {
+ LogLog.Debug(declaringType, "Shutdown called on Hierarchy ["+this.Name+"]");
- // begin by closing nested appenders
- Root.CloseNestedAppenders();
+ // begin by closing nested appenders
+ Root.CloseNestedAppenders();
- lock(m_ht)
- {
- ILogger[] currentLoggers = this.GetCurrentLoggers();
+ lock(m_ht)
+ {
+ ILogger[] currentLoggers = this.GetCurrentLoggers();
- foreach(Logger logger in currentLoggers)
- {
- logger.CloseNestedAppenders();
- }
+ foreach(Logger logger in currentLoggers)
+ {
+ logger.CloseNestedAppenders();
+ }
- // then, remove all appenders
- Root.RemoveAllAppenders();
+ // then, remove all appenders
+ Root.RemoveAllAppenders();
- foreach(Logger logger in currentLoggers)
- {
- logger.RemoveAllAppenders();
- }
- }
+ foreach(Logger logger in currentLoggers)
+ {
+ logger.RemoveAllAppenders();
+ }
+ }
- base.Shutdown();
- }
+ base.Shutdown();
+ }
- /// <summary>
- /// Reset all values contained in this hierarchy instance to their default.
- /// </summary>
- /// <remarks>
- /// <para>
- /// Reset all values contained in this hierarchy instance to their
- /// default. This removes all appenders from all loggers, sets
- /// the level of all non-root loggers to <c>null</c>,
- /// sets their additivity flag to <c>true</c> and sets the level
- /// of the root logger to <see cref="Level.Debug"/>. Moreover,
- /// message disabling is set its default "off" value.
- /// </para>
- /// <para>
- /// Existing loggers are not removed. They are just reset.
- /// </para>
- /// <para>
- /// This method should be used sparingly and with care as it will
- /// block all logging until it is completed.
- /// </para>
- /// </remarks>
- public override void ResetConfiguration()
- {
- Root.Level = LevelMap.LookupWithDefault(Level.Debug);
- Threshold = LevelMap.LookupWithDefault(Level.All);
-
- // the synchronization is needed to prevent hashtable surprises
- lock(m_ht)
- {
- Shutdown(); // nested locks are OK
-
- foreach(Logger l in this.GetCurrentLoggers())
- {
- l.Level = null;
- l.Additivity = true;
- }
- }
+ /// <summary>
+ /// Reset all values contained in this hierarchy instance to their default.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Reset all values contained in this hierarchy instance to their
+ /// default. This removes all appenders from all loggers, sets
+ /// the level of all non-root loggers to <c>null</c>,
+ /// sets their additivity flag to <c>true</c> and sets the level
+ /// of the root logger to <see cref="Level.Debug"/>. Moreover,
+ /// message disabling is set its default "off" value.
+ /// </para>
+ /// <para>
+ /// Existing loggers are not removed. They are just reset.
+ /// </para>
+ /// <para>
+ /// This method should be used sparingly and with care as it will
+ /// block all logging until it is completed.
+ /// </para>
+ /// </remarks>
+ public override void ResetConfiguration()
+ {
+ Root.Level = LevelMap.LookupWithDefault(Level.Debug);
+ Threshold = LevelMap.LookupWithDefault(Level.All);
+
+ // the synchronization is needed to prevent hashtable surprises
+ lock(m_ht)
+ {
+ Shutdown(); // nested locks are OK
+
+ foreach(Logger l in this.GetCurrentLoggers())
+ {
+ l.Level = null;
+ l.Additivity = true;
+ }
+ }
- base.ResetConfiguration();
+ base.ResetConfiguration();
- // Notify listeners
- OnConfigurationChanged(null);
- }
+ // Notify listeners
+ OnConfigurationChanged(null);
+ }
- /// <summary>
- /// Log the logEvent through this hierarchy.
- /// </summary>
- /// <param name="logEvent">the event to log</param>
- /// <remarks>
- /// <para>
- /// This method should not normally be used to log.
- /// The <see cref="ILog"/> interface should be used
- /// for routine logging. This interface can be obtained
- /// using the <see cref="M:log4net.LogManager.GetLogger(string)"/> method.
- /// </para>
- /// <para>
- /// The <c>logEvent</c> is delivered to the appropriate logger and
- /// that logger is then responsible for logging the event.
- /// </para>
- /// </remarks>
- public override void Log(LoggingEvent logEvent)
- {
- if (logEvent == null)
- {
- throw new ArgumentNullException("logEvent");
- }
+ /// <summary>
+ /// Log the logEvent through this hierarchy.
+ /// </summary>
+ /// <param name="logEvent">the event to log</param>
+ /// <remarks>
+ /// <para>
+ /// This method should not normally be used to log.
+ /// The <see cref="ILog"/> interface should be used
+ /// for routine logging. This interface can be obtained
+ /// using the <see cref="M:log4net.LogManager.GetLogger(string)"/> method.
+ /// </para>
+ /// <para>
+ /// The <c>logEvent</c> is delivered to the appropriate logger and
+ /// that logger is then responsible for logging the event.
+ /// </para>
+ /// </remarks>
+ public override void Log(LoggingEvent logEvent)
+ {
+ if (logEvent == null)
+ {
+ throw new ArgumentNullException("logEvent");
+ }
- this.GetLogger(logEvent.LoggerName, m_defaultFactory).Log(logEvent);
- }
+ this.GetLogger(logEvent.LoggerName, m_defaultFactory).Log(logEvent);
+ }
- /// <summary>
- /// Returns all the Appenders that are currently configured
- /// </summary>
- /// <returns>An array containing all the currently configured appenders</returns>
- /// <remarks>
- /// <para>
- /// Returns all the <see cref="log4net.Appender.IAppender"/> instances that are currently configured.
- /// All the loggers are searched for appenders. The appenders may also be containers
- /// for appenders and these are also searched for additional loggers.
- /// </para>
- /// <para>
- /// The list returned is unordered but does not contain duplicates.
- /// </para>
- /// </remarks>
- public override Appender.IAppender[] GetAppenders()
- {
- System.Collections.ArrayList appenderList = new System.Collections.ArrayList();
+ /// <summary>
+ /// Returns all the Appenders that are currently configured
+ /// </summary>
+ /// <returns>An array containing all the currently configured appenders</returns>
+ /// <remarks>
+ /// <para>
+ /// Returns all the <see cref="log4net.Appender.IAppender"/> instances that are currently configured.
+ /// All the loggers are searched for appenders. The appenders may also be containers
+ /// for appenders and these are also searched for additional loggers.
+ /// </para>
+ /// <para>
+ /// The list returned is unordered but does not contain duplicates.
+ /// </para>
+ /// </remarks>
+ public override Appender.IAppender[] GetAppenders()
+ {
+ System.Collections.ArrayList appenderList = new System.Collections.ArrayList();
- CollectAppenders(appenderList, Root);
+ CollectAppenders(appenderList, Root);
- foreach(Logger logger in GetCurrentLoggers())
- {
- CollectAppenders(appenderList, logger);
- }
+ foreach(Logger logger in GetCurrentLoggers())
+ {
+ CollectAppenders(appenderList, logger);
+ }
- return (Appender.IAppender[])appenderList.ToArray(typeof(Appender.IAppender));
- }
+ return (Appender.IAppender[])appenderList.ToArray(typeof(Appender.IAppender));
+ }
- #endregion Override Implementation of LoggerRepositorySkeleton
+ #endregion Override Implementation of LoggerRepositorySkeleton
#region Private Static Methods
/// <summary>
- /// Collect the appenders from an <see cref="IAppenderAttachable"/>.
- /// The appender may also be a container.
- /// </summary>
- /// <param name="appenderList"></param>
- /// <param name="appender"></param>
- private static void CollectAppender(System.Collections.ArrayList appenderList, Appender.IAppender appender)
- {
- if (!appenderList.Contains(appender))
- {
- appenderList.Add(appender);
+ /// Collect the appenders from an <see cref="IAppenderAttachable"/>.
+ /// The appender may also be a container.
+ /// </summary>
+ /// <param name="appenderList"></param>
+ /// <param name="appender"></param>
+ private static void CollectAppender(System.Collections.ArrayList appenderList, Appender.IAppender appender)
+ {
+ if (!appenderList.Contains(appender))
+ {
+ appenderList.Add(appender);
- IAppenderAttachable container = appender as IAppenderAttachable;
- if (container != null)
- {
- CollectAppenders(appenderList, container);
- }
- }
- }
+ IAppenderAttachable container = appender as IAppenderAttachable;
+ if (container != null)
+ {
+ CollectAppenders(appenderList, container);
+ }
+ }
+ }
- /// <summary>
- /// Collect the appenders from an <see cref="IAppenderAttachable"/> container
- /// </summary>
- /// <param name="appenderList"></param>
- /// <param name="container"></param>
- private static void CollectAppenders(System.Collections.ArrayList appenderList, IAppenderAttachable container)
- {
- foreach(Appender.IAppender appender in container.Appenders)
- {
- CollectAppender(appenderList, appender);
- }
+ /// <summary>
+ /// Collect the appenders from an <see cref="IAppenderAttachable"/> container
+ /// </summary>
+ /// <param name="appenderList"></param>
+ /// <param name="container"></param>
+ private static void CollectAppenders(System.Collections.ArrayList appenderList, IAppenderAttachable container)
+ {
+ foreach(Appender.IAppender appender in container.Appenders)
+ {
+ CollectAppender(appenderList, appender);
+ }
}
#endregion
@@ -550,13 +550,13 @@
#region Implementation of IBasicRepositoryConfigurator
/// <summary>
- /// Initialize the log4net system using the specified appender
- /// </summary>
- /// <param name="appender">the appender to use to log all logging events</param>
- void IBasicRepositoryConfigurator.Configure(IAppender appender)
- {
- BasicRepositoryConfigure(appender);
- }
+ /// Initialize the log4net system using the specified appender
+ /// </summary>
+ /// <param name="appender">the appender to use to log all logging events</param>
+ void IBasicRepositoryConfigurator.Configure(IAppender appender)
+ {
+ BasicRepositoryConfigure(appender);
+ }
/// <summary>
/// Initialize the log4net system using the specified appenders
@@ -567,19 +567,19 @@
BasicRepositoryConfigure(appenders);
}
- /// <summary>
- /// Initialize the log4net system using the specified appenders
- /// </summary>
- /// <param name="appenders">the appenders to use to log all logging events</param>
- /// <remarks>
- /// <para>
- /// This method provides the same functionality as the
- /// <see cref="M:IBasicRepositoryConfigurator.Configure(IAppender)"/> method implemented
- /// on this object, but it is protected and therefore can be called by subclasses.
- /// </para>
- /// </remarks>
- protected void BasicRepositoryConfigure(params IAppender[] appenders)
- {
+ /// <summary>
+ /// Initialize the log4net system using the specified appenders
+ /// </summary>
+ /// <param name="appenders">the appenders to use to log all logging events</param>
+ /// <remarks>
+ /// <para>
+ /// This method provides the same functionality as the
+ /// <see cref="M:IBasicRepositoryConfigurator.Configure(IAppender)"/> method implemented
+ /// on this object, but it is protected and therefore can be called by subclasses.
+ /// </para>
+ /// </remarks>
+ protected void BasicRepositoryConfigure(params IAppender[] appenders)
+ {
ArrayList configurationMessages = new ArrayList();
using (new LogLog.LogReceivedAdapter(configurationMessages))
@@ -590,497 +590,497 @@
}
}
- Configured = true;
+ Configured = true;
ConfigurationMessages = configurationMessages;
- // Notify listeners
+ // Notify listeners
OnConfigurationChanged(new ConfigurationChangedEventArgs(configurationMessages));
- }
+ }
- #endregion Implementation of IBasicRepositoryConfigurator
+ #endregion Implementation of IBasicRepositoryConfigurator
- #region Implementation of IXmlRepositoryConfigurator
+ #region Implementation of IXmlRepositoryConfigurator
- /// <summary>
- /// Initialize the log4net system using the specified config
- /// </summary>
- /// <param name="element">the element containing the root of the config</param>
- void IXmlRepositoryConfigurator.Configure(System.Xml.XmlElement element)
- {
- XmlRepositoryConfigure(element);
- }
+ /// <summary>
+ /// Initialize the log4net system using the specified config
+ /// </summary>
+ /// <param name="element">the element containing the root of the config</param>
+ void IXmlRepositoryConfigurator.Configure(System.Xml.XmlElement element)
+ {
+ XmlRepositoryConfigure(element);
+ }
- /// <summary>
- /// Initialize the log4net system using the specified config
- /// </summary>
- /// <param name="element">the element containing the root of the config</param>
- /// <remarks>
- /// <para>
- /// This method provides the same functionality as the
- /// <see cref="M:IBasicRepositoryConfigurator.Configure(IAppender)"/> method implemented
- /// on this object, but it is protected and therefore can be called by subclasses.
- /// </para>
- /// </remarks>
- protected void XmlRepositoryConfigure(System.Xml.XmlElement element)
- {
+ /// <summary>
+ /// Initialize the log4net system using the specified config
+ /// </summary>
+ /// <param name="element">the element containing the root of the config</param>
+ /// <remarks>
+ /// <para>
+ /// This method provides the same functionality as the
+ /// <see cref="M:IBasicRepositoryConfigurator.Configure(IAppender)"/> method implemented
+ /// on this object, but it is protected and therefore can be called by subclasses.
+ /// </para>
+ /// </remarks>
+ protected void XmlRepositoryConfigure(System.Xml.XmlElement element)
+ {
ArrayList configurationMessages = new ArrayList();
using (new LogLog.LogReceivedAdapter(configurationMessages))
- {
- XmlHierarchyConfigurator config = new XmlHierarchyConfigurator(this);
+ {
+ XmlHierarchyConfigurator config = new XmlHierarchyConfigurator(this);
config.Configure(element);
- }
+ }
- Configured = true;
+ Configured = true;
ConfigurationMessages = configurationMessages;
- // Notify listeners
+ // Notify listeners
OnConfigurationChanged(new ConfigurationChangedEventArgs(configurationMessages));
- }
+ }
- #endregion Implementation of IXmlRepositoryConfigurator
+ #endregion Implementation of IXmlRepositoryConfigurator
- #region Public Instance Methods
+ #region Public Instance Methods
- /// <summary>
- /// Test if this hierarchy is disabled for the specified <see cref="Level"/>.
- /// </summary>
- /// <param name="level">The level to check against.</param>
- /// <returns>
- /// <c>true</c> if the repository is disabled for the level argument, <c>false</c> otherwise.
- /// </returns>
- /// <remarks>
- /// <para>
- /// If this hierarchy has not been configured then this method will
- /// always return <c>true</c>.
- /// </para>
- /// <para>
- /// This method will return <c>true</c> if this repository is
- /// disabled for <c>level</c> object passed as parameter and
- /// <c>false</c> otherwise.
- /// </para>
- /// <para>
- /// See also the <see cref="ILoggerRepository.Threshold"/> property.
- /// </para>
- /// </remarks>
- public bool IsDisabled(Level level)
- {
- // Cast level to object for performance
- if ((object)level == null)
- {
- throw new ArgumentNullException("level");
- }
+ /// <summary>
+ /// Test if this hierarchy is disabled for the specified <see cref="Level"/>.
+ /// </summary>
+ /// <param name="level">The level to check against.</param>
+ /// <returns>
+ /// <c>true</c> if the repository is disabled for the level argument, <c>false</c> otherwise.
+ /// </returns>
+ /// <remarks>
+ /// <para>
+ /// If this hierarchy has not been configured then this method will
+ /// always return <c>true</c>.
+ /// </para>
+ /// <para>
+ /// This method will return <c>true</c> if this repository is
+ /// disabled for <c>level</c> object passed as parameter and
+ /// <c>false</c> otherwise.
+ /// </para>
+ /// <para>
+ /// See also the <see cref="ILoggerRepository.Threshold"/> property.
+ /// </para>
+ /// </remarks>
+ public bool IsDisabled(Level level)
+ {
+ // Cast level to object for performance
+ if ((object)level == null)
+ {
+ throw new ArgumentNullException("level");
+ }
- if (Configured)
- {
- return Threshold > level;
- }
- else
- {
- // If not configured the hierarchy is effectively disabled
- return true;
- }
- }
+ if (Configured)
+ {
+ return Threshold > level;
+ }
+ else
+ {
+ // If not configured the hierarchy is effectively disabled
+ return true;
+ }
+ }
- /// <summary>
- /// Clear all logger definitions from the internal hashtable
- /// </summary>
- /// <remarks>
- /// <para>
- /// This call will clear all logger definitions from the internal
- /// hashtable. Invoking this method will irrevocably mess up the
- /// logger hierarchy.
- /// </para>
- /// <para>
- /// You should <b>really</b> know what you are doing before
- /// invoking this method.
- /// </para>
- /// </remarks>
- public void Clear()
- {
- lock(m_ht)
- {
- m_ht.Clear();
- }
- }
+ /// <summary>
+ /// Clear all logger definitions from the internal hashtable
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// This call will clear all logger definitions from the internal
+ /// hashtable. Invoking this method will irrevocably mess up the
+ /// logger hierarchy.
+ /// </para>
+ /// <para>
+ /// You should <b>really</b> know what you are doing before
+ /// invoking this method.
+ /// </para>
+ /// </remarks>
+ public void Clear()
+ {
+ lock(m_ht)
+ {
+ m_ht.Clear();
+ }
+ }
- /// <summary>
- /// Return a new logger instance named as the first parameter using
- /// <paramref name="factory"/>.
- /// </summary>
- /// <param name="name">The name of the logger to retrieve</param>
- /// <param name="factory">The factory that will make the new logger instance</param>
- /// <returns>The logger object with the name specified</returns>
- /// <remarks>
- /// <para>
- /// If a logger of that name already exists, then it will be
- /// returned. Otherwise, a new logger will be instantiated by the
- /// <paramref name="factory"/> parameter and linked with its existing
- /// ancestors as well as children.
- /// </para>
- /// </remarks>
- public Logger GetLogger(string name, ILoggerFactory factory)
- {
- if (name == null)
- {
- throw new ArgumentNullException("name");
- }
- if (factory == null)
- {
- throw new ArgumentNullException("factory");
- }
+ /// <summary>
+ /// Return a new logger instance named as the first parameter using
+ /// <paramref name="factory"/>.
+ /// </summary>
+ /// <param name="name">The name of the logger to retrieve</param>
+ /// <param name="factory">The factory that will make the new logger instance</param>
+ /// <returns>The logger object with the name specified</returns>
+ /// <remarks>
+ /// <para>
+ /// If a logger of that name already exists, then it will be
+ /// returned. Otherwise, a new logger will be instantiated by the
+ /// <paramref name="factory"/> parameter and linked with its existing
+ /// ancestors as well as children.
+ /// </para>
+ /// </remarks>
+ public Logger GetLogger(string name, ILoggerFactory factory)
+ {
+ if (name == null)
+ {
+ throw new ArgumentNullException("name");
+ }
+ if (factory == null)
+ {
+ throw new ArgumentNullException("factory");
+ }
- LoggerKey key = new LoggerKey(name);
+ LoggerKey key = new LoggerKey(name);
- // Synchronize to prevent write conflicts. Read conflicts (in
- // GetEffectiveLevel() method) are possible only if variable
- // assignments are non-atomic.
+ // Synchronize to prevent write conflicts. Read conflicts (in
+ // GetEffectiveLevel() method) are possible only if variable
+ // assignments are non-atomic.
- lock(m_ht)
- {
- Logger logger = null;
+ lock(m_ht)
+ {
+ Logger logger = null;
- Object node = m_ht[key];
- if (node == null)
- {
- logger = factory.CreateLogger(this, name);
- logger.Hierarchy = this;
- m_ht[key] = logger;
- UpdateParents(logger);
- OnLoggerCreationEvent(logger);
- return logger;
- }
-
- Logger nodeLogger = node as Logger;
- if (nodeLogger != null)
- {
- return nodeLogger;
- }
-
- ProvisionNode nodeProvisionNode = node as ProvisionNode;
- if (nodeProvisionNode != null)
- {
- logger = factory.CreateLogger(this, name);
- logger.Hierarchy = this;
- m_ht[key] = logger;
- UpdateChildren(nodeProvisionNode, logger);
- UpdateParents(logger);
- OnLoggerCreationEvent(logger);
- return logger;
- }
+ Object node = m_ht[key];
+ if (node == null)
+ {
+ logger = factory.CreateLogger(this, name);
+ logger.Hierarchy = this;
+ m_ht[key] = logger;
+ UpdateParents(logger);
+ OnLoggerCreationEvent(logger);
+ return logger;
+ }
+
+ Logger nodeLogger = node as Logger;
+ if (nodeLogger != null)
+ {
+ return nodeLogger;
+ }
+
+ ProvisionNode nodeProvisionNode = node as ProvisionNode;
+ if (nodeProvisionNode != null)
+ {
+ logger = factory.CreateLogger(this, name);
+ logger.Hierarchy = this;
+ m_ht[key] = logger;
+ UpdateChildren(nodeProvisionNode, logger);
+ UpdateParents(logger);
+ OnLoggerCreationEvent(logger);
+ return logger;
+ }
- // It should be impossible to arrive here but let's keep the compiler happy.
- return null;
- }
- }
+ // It should be impossible to arrive here but let's keep the compiler happy.
+ return null;
+ }
+ }
- #endregion Public Instance Methods
+ #endregion Public Instance Methods
- #region Protected Instance Methods
+ #region Protected Instance Methods
- /// <summary>
- /// Sends a logger creation event to all registered listeners
- /// </summary>
- /// <param name="logger">The newly created logger</param>
- /// <remarks>
- /// Raises the logger creation event.
- /// </remarks>
- protected virtual void OnLoggerCreationEvent(Logger logger)
- {
- LoggerCreationEventHandler handler = m_loggerCreatedEvent;
- if (handler != null)
- {
- handler(this, new LoggerCreationEventArgs(logger));
- }
- }
+ /// <summary>
+ /// Sends a logger creation event to all registered listeners
+ /// </summary>
+ /// <param name="logger">The newly created logger</param>
+ /// <remarks>
+ /// Raises the logger creation event.
+ /// </remarks>
+ protected virtual void OnLoggerCreationEvent(Logger logger)
+ {
+ LoggerCreationEventHandler handler = m_loggerCreatedEvent;
+ if (handler != null)
+ {
+ handler(this, new LoggerCreationEventArgs(logger));
+ }
+ }
- #endregion Protected Instance Methods
+ #endregion Protected Instance Methods
- #region Private Instance Methods
+ #region Private Instance Methods
- /// <summary>
- /// Updates all the parents of the specified logger
- /// </summary>
- /// <param name="log">The logger to update the parents for</param>
- /// <remarks>
- /// <para>
- /// This method loops through all the <i>potential</i> parents of
- /// <paramref name="log"/>. There 3 possible cases:
- /// </para>
- /// <list type="number">
- /// <item>
- /// <term>No entry for the potential parent of <paramref name="log"/> exists</term>
- /// <description>
- /// We create a ProvisionNode for this potential
- /// parent and insert <paramref name="log"/> in that provision node.
- /// </description>
- /// </item>
- /// <item>
- /// <term>The entry is of type Logger for the potential parent.</term>
- /// <description>
- /// The entry is <paramref name="log"/>'s nearest existing parent. We
- /// update <paramref name="log"/>'s parent field with this entry. We also break from
- /// he loop because updating our parent's parent is our parent's
- /// responsibility.
- /// </description>
- /// </item>
- /// <item>
- /// <term>The entry is of type ProvisionNode for this potential parent.</term>
- /// <description>
- /// We add <paramref name="log"/> to the list of children for this
- /// potential parent.
- /// </description>
- /// </item>
- /// </list>
- /// </remarks>
- private void UpdateParents(Logger log)
- {
- string name = log.Name;
- int length = name.Length;
- bool parentFound = false;
-
- // if name = "w.x.y.z", loop through "w.x.y", "w.x" and "w", but not "w.x.y.z"
- for(int i = name.LastIndexOf('.', length-1); i >= 0; i = name.LastIndexOf('.', i-1))
- {
- string substr = name.Substring(0, i);
-
- LoggerKey key = new LoggerKey(substr); // simple constructor
- Object node = m_ht[key];
- // Create a provision node for a future parent.
- if (node == null)
- {
- ProvisionNode pn = new ProvisionNode(log);
- m_ht[key] = pn;
- }
- else
- {
- Logger nodeLogger = node as Logger;
- if (nodeLogger != null)
- {
- parentFound = true;
- log.Parent = nodeLogger;
- break; // no need to update the ancestors of the closest ancestor
- }
- else
- {
- ProvisionNode nodeProvisionNode = node as ProvisionNode;
- if (nodeProvisionNode != null)
- {
- nodeProvisionNode.Add(log);
- }
- else
- {
- LogLog.Error(declaringType, "Unexpected object type ["+node.GetType()+"] in ht.", new LogException());
- }
- }
- }
- if (i == 0) {
- // logger name starts with a dot
- // and we've hit the start
- break;
- }
- }
-
- // If we could not find any existing parents, then link with root.
- if (!parentFound)
- {
- log.Parent = this.Root;
- }
- }
-
- /// <summary>
- /// Replace a <see cref="ProvisionNode"/> with a <see cref="Logger"/> in the hierarchy.
- /// </summary>
- /// <param name="pn"></param>
- /// <param name="log"></param>
- /// <remarks>
- /// <para>
- /// We update the links for all the children that placed themselves
- /// in the provision node 'pn'. The second argument 'log' is a
- /// reference for the newly created Logger, parent of all the
- /// children in 'pn'.
- /// </para>
- /// <para>
- /// We loop on all the children 'c' in 'pn'.
- /// </para>
- /// <para>
- /// If the child 'c' has been already linked to a child of
- /// 'log' then there is no need to update 'c'.
- /// </para>
- /// <para>
- /// Otherwise, we set log's parent field to c's parent and set
- /// c's parent field to log.
- /// </para>
- /// </remarks>
- private static void UpdateChildren(ProvisionNode pn, Logger log)
- {
- for(int i = 0; i < pn.Count; i++)
- {
- Logger childLogger = (Logger)pn[i];
-
- // Unless this child already points to a correct (lower) parent,
- // make log.Parent point to childLogger.Parent and childLogger.Parent to log.
- if (!childLogger.Parent.Name.StartsWith(log.Name))
- {
- log.Parent = childLogger.Parent;
- childLogger.Parent = log;
- }
- }
- }
-
- /// <summary>
- /// Define or redefine a Level using the values in the <see cref="LevelEntry"/> argument
- /// </summary>
- /// <param name="levelEntry">the level values</param>
- /// <remarks>
- /// <para>
- /// Define or redefine a Level using the values in the <see cref="LevelEntry"/> argument
- /// </para>
- /// <para>
- /// Supports setting levels via the configuration file.
- /// </para>
- /// </remarks>
- internal void AddLevel(LevelEntry levelEntry)
- {
- if (levelEntry == null) throw new ArgumentNullException("levelEntry");
- if (levelEntry.Name == null) throw new ArgumentNullException("levelEntry.Name");
-
- // Lookup replacement value
- if (levelEntry.Value == -1)
- {
- Level previousLevel = LevelMap[levelEntry.Name];
- if (previousLevel == null)
- {
- throw new InvalidOperationException("Cannot redefine level ["+levelEntry.Name+"] because it is not defined in the LevelMap. To define the level supply the level value.");
- }
-
- levelEntry.Value = previousLevel.Value;
- }
-
- LevelMap.Add(levelEntry.Name, levelEntry.Value, levelEntry.DisplayName);
- }
-
- /// <summary>
- /// A class to hold the value, name and display name for a level
- /// </summary>
- /// <remarks>
- /// <para>
- /// A class to hold the value, name and display name for a level
- /// </para>
- /// </remarks>
- internal class LevelEntry
- {
- private int m_levelValue = -1;
- private string m_levelName = null;
- private string m_levelDisplayName = null;
-
- /// <summary>
- /// Value of the level
- /// </summary>
- /// <remarks>
- /// <para>
- /// If the value is not set (defaults to -1) the value will be looked
- /// up for the current level with the same name.
- /// </para>
- /// </remarks>
- public int Value
- {
- get { return m_levelValue; }
- set { m_levelValue = value; }
- }
-
- /// <summary>
- /// Name of the level
- /// </summary>
- /// <value>
- /// The name of the level
- /// </value>
- /// <remarks>
- /// <para>
- /// The name of the level.
- /// </para>
- /// </remarks>
- public string Name
- {
- get { return m_levelName; }
- set { m_levelName = value; }
- }
-
- /// <summary>
- /// Display name for the level
- /// </summary>
- /// <value>
- /// The display name of the level
- /// </value>
- /// <remarks>
- /// <para>
- /// The display name of the level.
- /// </para>
- /// </remarks>
- public string DisplayName
- {
- get { return m_levelDisplayName; }
- set { m_levelDisplayName = value; }
- }
-
- /// <summary>
- /// Override <c>Object.ToString</c> to return sensible debug info
- /// </summary>
- /// <returns>string info about this object</returns>
- public override string ToString()
- {
- return "LevelEntry(Value="+m_levelValue+", Name="+m_levelName+", DisplayName="+m_levelDisplayName+")";
- }
- }
-
- /// <summary>
- /// Set a Property using the values in the <see cref="LevelEntry"/> argument
- /// </summary>
- /// <param name="propertyEntry">the property value</param>
- /// <remarks>
- /// <para>
- /// Set a Property using the values in the <see cref="LevelEntry"/> argument.
- /// </para>
- /// <para>
- /// Supports setting property values via the configuration file.
- /// </para>
- /// </remarks>
- internal void AddProperty(PropertyEntry propertyEntry)
- {
- if (propertyEntry == null) throw new ArgumentNullException("propertyEntry");
- if (propertyEntry.Key == null) throw new ArgumentNullException("propertyEntry.Key");
-
- Properties[propertyEntry.Key] = propertyEntry.Value;
- }
-
- #endregion Private Instance Methods
-
- #region Private Instance Fields
-
- private ILoggerFactory m_defaultFactory;
-
- private System.Collections.Hashtable m_ht;
- private Logger m_root;
+ /// <summary>
+ /// Updates all the parents of the specified logger
+ /// </summary>
+ /// <param name="log">The logger to update the parents for</param>
+ /// <remarks>
+ /// <para>
+ /// This method loops through all the <i>potential</i> parents of
+ /// <paramref name="log"/>. There 3 possible cases:
+ /// </para>
+ /// <list type="number">
+ /// <item>
+ /// <term>No entry for the potential parent of <paramref name="log"/> exists</term>
+ /// <description>
+ /// We create a ProvisionNode for this potential
+ /// parent and insert <paramref name="log"/> in that provision node.
+ /// </description>
+ /// </item>
+ /// <item>
+ /// <term>The entry is of type Logger for the potential parent.</term>
+ /// <description>
+ /// The entry is <paramref name="log"/>'s nearest existing parent. We
+ /// update <paramref name="log"/>'s parent field with this entry. We also break from
+ /// he loop because updating our parent's parent is our parent's
+ /// responsibility.
+ /// </description>
+ /// </item>
+ /// <item>
+ /// <term>The entry is of type ProvisionNode for this potential parent.</term>
+ /// <description>
+ /// We add <paramref name="log"/> to the list of children for this
+ /// potential parent.
+ /// </description>
+ /// </item>
+ /// </list>
+ /// </remarks>
+ private void UpdateParents(Logger log)
+ {
+ string name = log.Name;
+ int length = name.Length;
+ bool parentFound = false;
- private bool m_emittedNoAppenderWarning = false;
+ // if name = "w.x.y.z", loop through "w.x.y", "w.x" and "w", but not "w.x.y.z"
+ for(int i = name.LastIndexOf('.', length-1); i >= 0; i = name.LastIndexOf('.', i-1))
+ {
+ string substr = name.Substring(0, i);
- private event LoggerCreationEventHandler m_loggerCreatedEvent;
+ LoggerKey key = new LoggerKey(substr); // simple constructor
+ Object node = m_ht[key];
+ // Create a provision node for a future parent.
+ if (node == null)
+ {
+ ProvisionNode pn = new ProvisionNode(log);
+ m_ht[key] = pn;
+ }
+ else
+ {
+ Logger nodeLogger = node as Logger;
+ if (nodeLogger != null)
+ {
+ parentFound = true;
+ log.Parent = nodeLogger;
+ break; // no need to update the ancestors of the closest ancestor
+ }
+ else
+ {
+ ProvisionNode nodeProvisionNode = node as ProvisionNode;
+ if (nodeProvisionNode != null)
+ {
+ nodeProvisionNode.Add(log);
+ }
+ else
+ {
+ LogLog.Error(declaringType, "Unexpected object type ["+node.GetType()+"] in ht.", new LogException());
+ }
+ }
+ }
+ if (i == 0) {
+ // logger name starts with a dot
+ // and we've hit the start
+ break;
+ }
+ }
- #endregion Private Instance Fields
+ // If we could not find any existing parents, then link with root.
+ if (!parentFound)
+ {
+ log.Parent = this.Root;
+ }
+ }
- #region Private Static Fields
+ /// <summary>
+ /// Replace a <see cref="ProvisionNode"/> with a <see cref="Logger"/> in the hierarchy.
+ /// </summary>
+ /// <param name="pn"></param>
+ /// <param name="log"></param>
+ /// <remarks>
+ /// <para>
+ /// We update the links for all the children that placed themselves
+ /// in the provision node 'pn'. The second argument 'log' is a
+ /// reference for the newly created Logger, parent of all the
+ /// children in 'pn'.
+ /// </para>
+ /// <para>
+ /// We loop on all the children 'c' in 'pn'.
+ /// </para>
+ /// <para>
+ /// If the child 'c' has been already linked to a child of
+ /// 'log' then there is no need to update 'c'.
+ /// </para>
+ /// <para>
+ /// Otherwise, we set log's parent field to c's parent and set
+ /// c's parent field to log.
+ /// </para>
+ /// </remarks>
+ private static void UpdateChildren(ProvisionNode pn, Logger log)
+ {
+ for(int i = 0; i < pn.Count; i++)
+ {
+ Logger childLogger = (Logger)pn[i];
- /// <summary>
- /// The fully qualified type of the Hierarchy class.
- /// </summary>
- /// <remarks>
- /// Used by the internal logger to record the Type of the
- /// log message.
- /// </remarks>
- private static readonly Type declaringType = typeof(Hierarchy);
+ // Unless this child already points to a correct (lower) parent,
+ // make log.Parent point to childLogger.Parent and childLogger.Parent to log.
+ if (!childLogger.Parent.Name.StartsWith(log.Name))
+ {
+ log.Parent = childLogger.Parent;
+ childLogger.Parent = log;
+ }
+ }
+ }
- #endregion Private Static Fields
- }
+ /// <summary>
+ /// Define or redefine a Level using the values in the <see cref="LevelEntry"/> argument
+ /// </summary>
+ /// <param name="levelEntry">the level values</param>
+ /// <remarks>
+ /// <para>
+ /// Define or redefine a Level using the values in the <see cref="LevelEntry"/> argument
+ /// </para>
+ /// <para>
+ /// Supports setting levels via the configuration file.
+ /// </para>
+ /// </remarks>
+ internal void AddLevel(LevelEntry levelEntry)
+ {
+ if (levelEntry == null) throw new ArgumentNullException("levelEntry");
+ if (levelEntry.Name == null) throw new ArgumentNullException("levelEntry.Name");
+
+ // Lookup replacement value
+ if (levelEntry.Value == -1)
+ {
+ Level previousLevel = LevelMap[levelEntry.Name];
+ if (previousLevel == null)
+ {
+ throw new InvalidOperationException("Cannot redefine level ["+levelEntry.Name+"] because it is not defined in the LevelMap. To define the level supply the level value.");
+ }
+
+ levelEntry.Value = previousLevel.Value;
+ }
+
+ LevelMap.Add(levelEntry.Name, levelEntry.Value, levelEntry.DisplayName);
+ }
+
+ /// <summary>
+ /// A class to hold the value, name and display name for a level
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// A class to hold the value, name and display name for a level
+ /// </para>
+ /// </remarks>
+ internal class LevelEntry
+ {
+ private int m_levelValue = -1;
+ private string m_levelName = null;
+ private string m_levelDisplayName = null;
+
+ /// <summary>
+ /// Value of the level
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// If the value is not set (defaults to -1) the value will be looked
+ /// up for the current level with the same name.
+ /// </para>
+ /// </remarks>
+ public int Value
+ {
+ get { return m_levelValue; }
+ set { m_levelValue = value; }
+ }
+
+ /// <summary>
+ /// Name of the level
+ /// </summary>
+ /// <value>
+ /// The name of the level
+ /// </value>
+ /// <remarks>
+ /// <para>
+ /// The name of the level.
+ /// </para>
+ /// </remarks>
+ public string Name
+ {
+ get { return m_levelName; }
+ set { m_levelName = value; }
+ }
+
+ /// <summary>
+ /// Display name for the level
+ /// </summary>
+ /// <value>
+ /// The display name of the level
+ /// </value>
+ /// <remarks>
+ /// <para>
+ /// The display name of the level.
+ /// </para>
+ /// </remarks>
+ public string DisplayName
+ {
+ get { return m_levelDisplayName; }
+ set { m_levelDisplayName = value; }
+ }
+
+ /// <summary>
+ /// Override <c>Object.ToString</c> to return sensible debug info
+ /// </summary>
+ /// <returns>string info about this object</returns>
+ public override string ToString()
+ {
+ return "LevelEntry(Value="+m_levelValue+", Name="+m_levelName+", DisplayName="+m_levelDisplayName+")";
+ }
+ }
+
+ /// <summary>
+ /// Set a Property using the values in the <see cref="LevelEntry"/> argument
+ /// </summary>
+ /// <param name="propertyEntry">the property value</param>
+ /// <remarks>
+ /// <para>
+ /// Set a Property using the values in the <see cref="LevelEntry"/> argument.
+ /// </para>
+ /// <para>
+ /// Supports setting property values via the configuration file.
+ /// </para>
+ /// </remarks>
+ internal void AddProperty(PropertyEntry propertyEntry)
+ {
+ if (propertyEntry == null) throw new ArgumentNullException("propertyEntry");
+ if (propertyEntry.Key == null) throw new ArgumentNullException("propertyEntry.Key");
+
+ Properties[propertyEntry.Key] = propertyEntry.Value;
+ }
+
+ #endregion Private Instance Methods
+
+ #region Private Instance Fields
+
+ private ILoggerFactory m_defaultFactory;
+
+ private System.Collections.Hashtable m_ht;
+ private Logger m_root;
+
+ private bool m_emittedNoAppenderWarning = false;
+
+ private event LoggerCreationEventHandler m_loggerCreatedEvent;
+
+ #endregion Private Instance Fields
+
+ #region Private Static Fields
+
+ /// <summary>
+ /// The fully qualified type of the Hierarchy class.
+ /// </summary>
+ /// <remarks>
+ /// Used by the internal logger to record the Type of the
+ /// log message.
+ /// </remarks>
+ private static readonly Type declaringType = typeof(Hierarchy);
+
+ #endregion Private Static Fields
+ }
}
diff --git a/src/log4net/Repository/Hierarchy/ILoggerFactory.cs b/src/log4net/Repository/Hierarchy/ILoggerFactory.cs
index 52966f4..9826a97 100644
--- a/src/log4net/Repository/Hierarchy/ILoggerFactory.cs
+++ b/src/log4net/Repository/Hierarchy/ILoggerFactory.cs
@@ -19,46 +19,46 @@
namespace log4net.Repository.Hierarchy
{
- /// <summary>
- /// Interface abstracts creation of <see cref="Logger"/> instances
- /// </summary>
- /// <remarks>
- /// <para>
- /// This interface is used by the <see cref="Hierarchy"/> to
- /// create new <see cref="Logger"/> objects.
- /// </para>
- /// <para>
- /// The <see cref="CreateLogger"/> method is called
- /// to create a named <see cref="Logger" />.
- /// </para>
- /// <para>
- /// Implement this interface to create new subclasses of <see cref="Logger" />.
- /// </para>
- /// </remarks>
- /// <author>Nicko Cadell</author>
- /// <author>Gert Driesen</author>
- public interface ILoggerFactory
- {
- /// <summary>
- /// Create a new <see cref="Logger" /> instance
- /// </summary>
- /// <param name="repository">The <see cref="ILoggerRepository" /> that will own the <see cref="Logger" />.</param>
- /// <param name="name">The name of the <see cref="Logger" />.</param>
- /// <returns>The <see cref="Logger" /> instance for the specified name.</returns>
- /// <remarks>
- /// <para>
- /// Create a new <see cref="Logger" /> instance with the
- /// specified name.
- /// </para>
- /// <para>
- /// Called by the <see cref="Hierarchy"/> to create
- /// new named <see cref="Logger"/> instances.
- /// </para>
- /// <para>
- /// If the <paramref name="name"/> is <c>null</c> then the root logger
- /// must be returned.
- /// </para>
- /// </remarks>
- Logger CreateLogger(ILoggerRepository repository, string name);
- }
+ /// <summary>
+ /// Interface abstracts creation of <see cref="Logger"/> instances
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// This interface is used by the <see cref="Hierarchy"/> to
+ /// create new <see cref="Logger"/> objects.
+ /// </para>
+ /// <para>
+ /// The <see cref="CreateLogger"/> method is called
+ /// to create a named <see cref="Logger" />.
+ /// </para>
+ /// <para>
+ /// Implement this interface to create new subclasses of <see cref="Logger" />.
+ /// </para>
+ /// </remarks>
+ /// <author>Nicko Cadell</author>
+ /// <author>Gert Driesen</author>
+ public interface ILoggerFactory
+ {
+ /// <summary>
+ /// Create a new <see cref="Logger" /> instance
+ /// </summary>
+ /// <param name="repository">The <see cref="ILoggerRepository" /> that will own the <see cref="Logger" />.</param>
+ /// <param name="name">The name of the <see cref="Logger" />.</param>
+ /// <returns>The <see cref="Logger" /> instance for the specified name.</returns>
+ /// <remarks>
+ /// <para>
+ /// Create a new <see cref="Logger" /> instance with the
+ /// specified name.
+ /// </para>
+ /// <para>
+ /// Called by the <see cref="Hierarchy"/> to create
+ /// new named <see cref="Logger"/> instances.
+ /// </para>
+ /// <para>
+ /// If the <paramref name="name"/> is <c>null</c> then the root logger
+ /// must be returned.
+ /// </para>
+ /// </remarks>
+ Logger CreateLogger(ILoggerRepository repository, string name);
+ }
}
diff --git a/src/log4net/Repository/Hierarchy/Logger.cs b/src/log4net/Repository/Hierarchy/Logger.cs
index 839e688..dbeab32 100644
--- a/src/log4net/Repository/Hierarchy/Logger.cs
+++ b/src/log4net/Repository/Hierarchy/Logger.cs
@@ -25,764 +25,764 @@
namespace log4net.Repository.Hierarchy
{
- /// <summary>
- /// Implementation of <see cref="ILogger"/> used by <see cref="Hierarchy"/>
- /// </summary>
- /// <remarks>
- /// <para>
- /// Internal class used to provide implementation of <see cref="ILogger"/>
- /// interface. Applications should use <see cref="LogManager"/> to get
- /// logger instances.
- /// </para>
- /// <para>
- /// This is one of the central classes in the log4net implementation. One of the
- /// distinctive features of log4net are hierarchical loggers and their
- /// evaluation. The <see cref="Hierarchy"/> organizes the <see cref="Logger"/>
- /// instances into a rooted tree hierarchy.
- /// </para>
- /// <para>
- /// The <see cref="Logger"/> class is abstract. Only concrete subclasses of
- /// <see cref="Logger"/> can be created. The <see cref="ILoggerFactory"/>
- /// is used to create instances of this type for the <see cref="Hierarchy"/>.
- /// </para>
- /// </remarks>
- /// <author>Nicko Cadell</author>
- /// <author>Gert Driesen</author>
- /// <author>Aspi Havewala</author>
- /// <author>Douglas de la Torre</author>
- public abstract class Logger : IAppenderAttachable, ILogger
- {
- #region Protected Instance Constructors
+ /// <summary>
+ /// Implementation of <see cref="ILogger"/> used by <see cref="Hierarchy"/>
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Internal class used to provide implementation of <see cref="ILogger"/>
+ /// interface. Applications should use <see cref="LogManager"/> to get
+ /// logger instances.
+ /// </para>
+ /// <para>
+ /// This is one of the central classes in the log4net implementation. One of the
+ /// distinctive features of log4net are hierarchical loggers and their
+ /// evaluation. The <see cref="Hierarchy"/> organizes the <see cref="Logger"/>
+ /// instances into a rooted tree hierarchy.
+ /// </para>
+ /// <para>
+ /// The <see cref="Logger"/> class is abstract. Only concrete subclasses of
+ /// <see cref="Logger"/> can be created. The <see cref="ILoggerFactory"/>
+ /// is used to create instances of this type for the <see cref="Hierarchy"/>.
+ /// </para>
+ /// </remarks>
+ /// <author>Nicko Cadell</author>
+ /// <author>Gert Driesen</author>
+ /// <author>Aspi Havewala</author>
+ /// <author>Douglas de la Torre</author>
+ public abstract class Logger : IAppenderAttachable, ILogger
+ {
+ #region Protected Instance Constructors
- /// <summary>
- /// This constructor created a new <see cref="Logger" /> instance and
- /// sets its name.
- /// </summary>
- /// <param name="name">The name of the <see cref="Logger" />.</param>
- /// <remarks>
- /// <para>
- /// This constructor is protected and designed to be used by
- /// a subclass that is not abstract.
- /// </para>
- /// <para>
- /// Loggers are constructed by <see cref="ILoggerFactory"/>
- /// objects. See <see cref="DefaultLoggerFactory"/> for the default
- /// logger creator.
- /// </para>
- /// </remarks>
- protected Logger(string name)
- {
+ /// <summary>
+ /// This constructor created a new <see cref="Logger" /> instance and
+ /// sets its name.
+ /// </summary>
+ /// <param name="name">The name of the <see cref="Logger" />.</param>
+ /// <remarks>
+ /// <para>
+ /// This constructor is protected and designed to be used by
+ /// a subclass that is not abstract.
+ /// </para>
+ /// <para>
+ /// Loggers are constructed by <see cref="ILoggerFactory"/>
+ /// objects. See <see cref="DefaultLoggerFactory"/> for the default
+ /// logger creator.
+ /// </para>
+ /// </remarks>
+ protected Logger(string name)
+ {
#if NETCF || NETSTANDARD1_3
- // NETCF: String.Intern causes Native Exception
- m_name = name;
+ // NETCF: String.Intern causes Native Exception
+ m_name = name;
#else
- m_name = string.Intern(name);
+ m_name = string.Intern(name);
#endif
- }
+ }
- #endregion Protected Instance Constructors
+ #endregion Protected Instance Constructors
- #region Public Instance Properties
+ #region Public Instance Properties
- /// <summary>
- /// Gets or sets the parent logger in the hierarchy.
- /// </summary>
- /// <value>
- /// The parent logger in the hierarchy.
- /// </value>
- /// <remarks>
- /// <para>
- /// Part of the Composite pattern that makes the hierarchy.
- /// The hierarchy is parent linked rather than child linked.
- /// </para>
- /// </remarks>
- public virtual Logger Parent
- {
- get { return m_parent; }
- set { m_parent = value; }
- }
+ /// <summary>
+ /// Gets or sets the parent logger in the hierarchy.
+ /// </summary>
+ /// <value>
+ /// The parent logger in the hierarchy.
+ /// </value>
+ /// <remarks>
+ /// <para>
+ /// Part of the Composite pattern that makes the hierarchy.
+ /// The hierarchy is parent linked rather than child linked.
+ /// </para>
+ /// </remarks>
+ public virtual Logger Parent
+ {
+ get { return m_parent; }
+ set { m_parent = value; }
+ }
- /// <summary>
- /// Gets or sets a value indicating if child loggers inherit their parent's appenders.
- /// </summary>
- /// <value>
- /// <c>true</c> if child loggers inherit their parent's appenders.
- /// </value>
- /// <remarks>
- /// <para>
- /// Additivity is set to <c>true</c> by default, that is children inherit
- /// the appenders of their ancestors by default. If this variable is
- /// set to <c>false</c> then the appenders found in the
- /// ancestors of this logger are not used. However, the children
- /// of this logger will inherit its appenders, unless the children
- /// have their additivity flag set to <c>false</c> too. See
- /// the user manual for more details.
- /// </para>
- /// </remarks>
- public virtual bool Additivity
- {
- get { return m_additive; }
- set { m_additive = value; }
- }
+ /// <summary>
+ /// Gets or sets a value indicating if child loggers inherit their parent's appenders.
+ /// </summary>
+ /// <value>
+ /// <c>true</c> if child loggers inherit their parent's appenders.
+ /// </value>
+ /// <remarks>
+ /// <para>
+ /// Additivity is set to <c>true</c> by default, that is children inherit
+ /// the appenders of their ancestors by default. If this variable is
+ /// set to <c>false</c> then the appenders found in the
+ /// ancestors of this logger are not used. However, the children
+ /// of this logger will inherit its appenders, unless the children
+ /// have their additivity flag set to <c>false</c> too. See
+ /// the user manual for more details.
+ /// </para>
+ /// </remarks>
+ public virtual bool Additivity
+ {
+ get { return m_additive; }
+ set { m_additive = value; }
+ }
- /// <summary>
- /// Gets the effective level for this logger.
- /// </summary>
- /// <returns>The nearest level in the logger hierarchy.</returns>
- /// <remarks>
- /// <para>
- /// Starting from this logger, searches the logger hierarchy for a
- /// non-null level and returns it. Otherwise, returns the level of the
- /// root logger.
- /// </para>
- /// <para>The Logger class is designed so that this method executes as
- /// quickly as possible.</para>
- /// </remarks>
- public virtual Level EffectiveLevel
- {
- get
- {
- for(Logger c = this; c != null; c = c.m_parent)
- {
- Level level = c.m_level;
+ /// <summary>
+ /// Gets the effective level for this logger.
+ /// </summary>
+ /// <returns>The nearest level in the logger hierarchy.</returns>
+ /// <remarks>
+ /// <para>
+ /// Starting from this logger, searches the logger hierarchy for a
+ /// non-null level and returns it. Otherwise, returns the level of the
+ /// root logger.
+ /// </para>
+ /// <para>The Logger class is designed so that this method executes as
+ /// quickly as possible.</para>
+ /// </remarks>
+ public virtual Level EffectiveLevel
+ {
+ get
+ {
+ for(Logger c = this; c != null; c = c.m_parent)
+ {
+ Level level = c.m_level;
- // Casting level to Object for performance, otherwise the overloaded operator is called
- if ((object)level != null)
- {
- return level;
- }
- }
- return null; // If reached will cause an NullPointerException.
- }
- }
+ // Casting level to Object for performance, otherwise the overloaded operator is called
+ if ((object)level != null)
+ {
+ return level;
+ }
+ }
+ return null; // If reached will cause an NullPointerException.
+ }
+ }
- /// <summary>
- /// Gets or sets the <see cref="Hierarchy"/> where this
- /// <c>Logger</c> instance is attached to.
- /// </summary>
- /// <value>The hierarchy that this logger belongs to.</value>
- /// <remarks>
- /// <para>
- /// This logger must be attached to a single <see cref="Hierarchy"/>.
- /// </para>
- /// </remarks>
- public virtual Hierarchy Hierarchy
- {
- get { return m_hierarchy; }
- set { m_hierarchy = value; }
- }
+ /// <summary>
+ /// Gets or sets the <see cref="Hierarchy"/> where this
+ /// <c>Logger</c> instance is attached to.
+ /// </summary>
+ /// <value>The hierarchy that this logger belongs to.</value>
+ /// <remarks>
+ /// <para>
+ /// This logger must be attached to a single <see cref="Hierarchy"/>.
+ /// </para>
+ /// </remarks>
+ public virtual Hierarchy Hierarchy
+ {
+ get { return m_hierarchy; }
+ set { m_hierarchy = value; }
+ }
- /// <summary>
- /// Gets or sets the assigned <see cref="Level"/>, if any, for this Logger.
- /// </summary>
- /// <value>
- /// The <see cref="Level"/> of this logger.
- /// </value>
- /// <remarks>
- /// <para>
- /// The assigned <see cref="Level"/> can be <c>null</c>.
- /// </para>
- /// </remarks>
- public virtual Level Level
- {
- get { return m_level; }
- set { m_level = value; }
- }
+ /// <summary>
+ /// Gets or sets the assigned <see cref="Level"/>, if any, for this Logger.
+ /// </summary>
+ /// <value>
+ /// The <see cref="Level"/> of this logger.
+ /// </value>
+ /// <remarks>
+ /// <para>
+ /// The assigned <see cref="Level"/> can be <c>null</c>.
+ /// </para>
+ /// </remarks>
+ public virtual Level Level
+ {
+ get { return m_level; }
+ set { m_level = value; }
+ }
- #endregion Public Instance Properties
+ #endregion Public Instance Properties
- #region Implementation of IAppenderAttachable
+ #region Implementation of IAppenderAttachable
- /// <summary>
- /// Add <paramref name="newAppender"/> to the list of appenders of this
- /// Logger instance.
- /// </summary>
- /// <param name="newAppender">An appender to add to this logger</param>
- /// <remarks>
- /// <para>
- /// Add <paramref name="newAppender"/> to the list of appenders of this
- /// Logger instance.
- /// </para>
- /// <para>
- /// If <paramref name="newAppender"/> is already in the list of
- /// appenders, then it won't be added again.
- /// </para>
- /// </remarks>
- public virtual void AddAppender(IAppender newAppender)
- {
- if (newAppender == null)
- {
- throw new ArgumentNullException("newAppender");
- }
+ /// <summary>
+ /// Add <paramref name="newAppender"/> to the list of appenders of this
+ /// Logger instance.
+ /// </summary>
+ /// <param name="newAppender">An appender to add to this logger</param>
+ /// <remarks>
+ /// <para>
+ /// Add <paramref name="newAppender"/> to the list of appenders of this
+ /// Logger instance.
+ /// </para>
+ /// <para>
+ /// If <paramref name="newAppender"/> is already in the list of
+ /// appenders, then it won't be added again.
+ /// </para>
+ /// </remarks>
+ public virtual void AddAppender(IAppender newAppender)
+ {
+ if (newAppender == null)
+ {
+ throw new ArgumentNullException("newAppender");
+ }
- m_appenderLock.AcquireWriterLock();
- try
- {
- if (m_appenderAttachedImpl == null)
- {
- m_appenderAttachedImpl = new log4net.Util.AppenderAttachedImpl();
- }
- m_appenderAttachedImpl.AddAppender(newAppender);
- }
- finally
- {
- m_appenderLock.ReleaseWriterLock();
- }
- }
+ m_appenderLock.AcquireWriterLock();
+ try
+ {
+ if (m_appenderAttachedImpl == null)
+ {
+ m_appenderAttachedImpl = new log4net.Util.AppenderAttachedImpl();
+ }
+ m_appenderAttachedImpl.AddAppender(newAppender);
+ }
+ finally
+ {
+ m_appenderLock.ReleaseWriterLock();
+ }
+ }
- /// <summary>
- /// Get the appenders contained in this logger as an
- /// <see cref="System.Collections.ICollection"/>.
- /// </summary>
- /// <returns>A collection of the appenders in this logger</returns>
- /// <remarks>
- /// <para>
- /// Get the appenders contained in this logger as an
- /// <see cref="System.Collections.ICollection"/>. If no appenders
- /// can be found, then a <see cref="EmptyCollection"/> is returned.
- /// </para>
- /// </remarks>
- public virtual AppenderCollection Appenders
- {
- get
- {
- m_appenderLock.AcquireReaderLock();
- try
- {
- if (m_appenderAttachedImpl == null)
- {
- return AppenderCollection.EmptyCollection;
- }
- else
- {
- return m_appenderAttachedImpl.Appenders;
- }
- }
- finally
- {
- m_appenderLock.ReleaseReaderLock();
- }
- }
- }
+ /// <summary>
+ /// Get the appenders contained in this logger as an
+ /// <see cref="System.Collections.ICollection"/>.
+ /// </summary>
+ /// <returns>A collection of the appenders in this logger</returns>
+ /// <remarks>
+ /// <para>
+ /// Get the appenders contained in this logger as an
+ /// <see cref="System.Collections.ICollection"/>. If no appenders
+ /// can be found, then a <see cref="EmptyCollection"/> is returned.
+ /// </para>
+ /// </remarks>
+ public virtual AppenderCollection Appenders
+ {
+ get
+ {
+ m_appenderLock.AcquireReaderLock();
+ try
+ {
+ if (m_appenderAttachedImpl == null)
+ {
+ return AppenderCollection.EmptyCollection;
+ }
+ else
+ {
+ return m_appenderAttachedImpl.Appenders;
+ }
+ }
+ finally
+ {
+ m_appenderLock.ReleaseReaderLock();
+ }
+ }
+ }
- /// <summary>
- /// Look for the appender named as <c>name</c>
- /// </summary>
- /// <param name="name">The name of the appender to lookup</param>
- /// <returns>The appender with the name specified, or <c>null</c>.</returns>
- /// <remarks>
- /// <para>
- /// Returns the named appender, or null if the appender is not found.
- /// </para>
- /// </remarks>
- public virtual IAppender GetAppender(string name)
- {
- m_appenderLock.AcquireReaderLock();
- try
- {
- if (m_appenderAttachedImpl == null || name == null)
- {
- return null;
- }
+ /// <summary>
+ /// Look for the appender named as <c>name</c>
+ /// </summary>
+ /// <param name="name">The name of the appender to lookup</param>
+ /// <returns>The appender with the name specified, or <c>null</c>.</returns>
+ /// <remarks>
+ /// <para>
+ /// Returns the named appender, or null if the appender is not found.
+ /// </para>
+ /// </remarks>
+ public virtual IAppender GetAppender(string name)
+ {
+ m_appenderLock.AcquireReaderLock();
+ try
+ {
+ if (m_appenderAttachedImpl == null || name == null)
+ {
+ return null;
+ }
- return m_appenderAttachedImpl.GetAppender(name);
- }
- finally
- {
- m_appenderLock.ReleaseReaderLock();
- }
- }
+ return m_appenderAttachedImpl.GetAppender(name);
+ }
+ finally
+ {
+ m_appenderLock.ReleaseReaderLock();
+ }
+ }
- /// <summary>
- /// Remove all previously added appenders from this Logger instance.
- /// </summary>
- /// <remarks>
- /// <para>
- /// Remove all previously added appenders from this Logger instance.
- /// </para>
- /// <para>
- /// This is useful when re-reading configuration information.
- /// </para>
- /// </remarks>
- public virtual void RemoveAllAppenders()
- {
- m_appenderLock.AcquireWriterLock();
- try
- {
- if (m_appenderAttachedImpl != null)
- {
- m_appenderAttachedImpl.RemoveAllAppenders();
- m_appenderAttachedImpl = null;
- }
- }
- finally
- {
- m_appenderLock.ReleaseWriterLock();
- }
- }
+ /// <summary>
+ /// Remove all previously added appenders from this Logger instance.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Remove all previously added appenders from this Logger instance.
+ /// </para>
+ /// <para>
+ /// This is useful when re-reading configuration information.
+ /// </para>
+ /// </remarks>
+ public virtual void RemoveAllAppenders()
+ {
+ m_appenderLock.AcquireWriterLock();
+ try
+ {
+ if (m_appenderAttachedImpl != null)
+ {
+ m_appenderAttachedImpl.RemoveAllAppenders();
+ m_appenderAttachedImpl = null;
+ }
+ }
+ finally
+ {
+ m_appenderLock.ReleaseWriterLock();
+ }
+ }
- /// <summary>
- /// Remove the appender passed as parameter form the list of appenders.
- /// </summary>
- /// <param name="appender">The appender to remove</param>
- /// <returns>The appender removed from the list</returns>
- /// <remarks>
- /// <para>
- /// Remove the appender passed as parameter form the list of appenders.
- /// The appender removed is not closed.
- /// If you are discarding the appender you must call
- /// <see cref="IAppender.Close"/> on the appender removed.
- /// </para>
- /// </remarks>
- public virtual IAppender RemoveAppender(IAppender appender)
- {
- m_appenderLock.AcquireWriterLock();
- try
- {
- if (appender != null && m_appenderAttachedImpl != null)
- {
- return m_appenderAttachedImpl.RemoveAppender(appender);
- }
- }
- finally
- {
- m_appenderLock.ReleaseWriterLock();
- }
- return null;
- }
+ /// <summary>
+ /// Remove the appender passed as parameter form the list of appenders.
+ /// </summary>
+ /// <param name="appender">The appender to remove</param>
+ /// <returns>The appender removed from the list</returns>
+ /// <remarks>
+ /// <para>
+ /// Remove the appender passed as parameter form the list of appenders.
+ /// The appender removed is not closed.
+ /// If you are discarding the appender you must call
+ /// <see cref="IAppender.Close"/> on the appender removed.
+ /// </para>
+ /// </remarks>
+ public virtual IAppender RemoveAppender(IAppender appender)
+ {
+ m_appenderLock.AcquireWriterLock();
+ try
+ {
+ if (appender != null && m_appenderAttachedImpl != null)
+ {
+ return m_appenderAttachedImpl.RemoveAppender(appender);
+ }
+ }
+ finally
+ {
+ m_appenderLock.ReleaseWriterLock();
+ }
+ return null;
+ }
- /// <summary>
- /// Remove the appender passed as parameter form the list of appenders.
- /// </summary>
- /// <param name="name">The name of the appender to remove</param>
- /// <returns>The appender removed from the list</returns>
- /// <remarks>
- /// <para>
- /// Remove the named appender passed as parameter form the list of appenders.
- /// The appender removed is not closed.
- /// If you are discarding the appender you must call
- /// <see cref="IAppender.Close"/> on the appender removed.
- /// </para>
- /// </remarks>
- public virtual IAppender RemoveAppender(string name)
- {
- m_appenderLock.AcquireWriterLock();
- try
- {
- if (name != null && m_appenderAttachedImpl != null)
- {
- return m_appenderAttachedImpl.RemoveAppender(name);
- }
- }
- finally
- {
- m_appenderLock.ReleaseWriterLock();
- }
- return null;
- }
+ /// <summary>
+ /// Remove the appender passed as parameter form the list of appenders.
+ /// </summary>
+ /// <param name="name">The name of the appender to remove</param>
+ /// <returns>The appender removed from the list</returns>
+ /// <remarks>
+ /// <para>
+ /// Remove the named appender passed as parameter form the list of appenders.
+ /// The appender removed is not closed.
+ /// If you are discarding the appender you must call
+ /// <see cref="IAppender.Close"/> on the appender removed.
+ /// </para>
+ /// </remarks>
+ public virtual IAppender RemoveAppender(string name)
+ {
+ m_appenderLock.AcquireWriterLock();
+ try
+ {
+ if (name != null && m_appenderAttachedImpl != null)
+ {
+ return m_appenderAttachedImpl.RemoveAppender(name);
+ }
+ }
+ finally
+ {
+ m_appenderLock.ReleaseWriterLock();
+ }
+ return null;
+ }
- #endregion
+ #endregion
- #region Implementation of ILogger
+ #region Implementation of ILogger
- /// <summary>
- /// Gets the logger name.
- /// </summary>
- /// <value>
- /// The name of the logger.
- /// </value>
- /// <remarks>
- /// <para>
- /// The name of this logger
- /// </para>
- /// </remarks>
- public virtual string Name
- {
- get { return m_name; }
- }
+ /// <summary>
+ /// Gets the logger name.
+ /// </summary>
+ /// <value>
+ /// The name of the logger.
+ /// </value>
+ /// <remarks>
+ /// <para>
+ /// The name of this logger
+ /// </para>
+ /// </remarks>
+ public virtual string Name
+ {
+ get { return m_name; }
+ }
- /// <summary>
- /// This generic form is intended to be used by wrappers.
- /// </summary>
- /// <param name="callerStackBoundaryDeclaringType">The declaring type of the method that is
- /// the stack boundary into the logging system for this call.</param>
- /// <param name="level">The level of the message to be logged.</param>
- /// <param name="message">The message object to log.</param>
- /// <param name="exception">The exception to log, including its stack trace.</param>
- /// <remarks>
- /// <para>
- /// Generate a logging event for the specified <paramref name="level"/> using
- /// the <paramref name="message"/> and <paramref name="exception"/>.
- /// </para>
- /// <para>
- /// This method must not throw any exception to the caller.
- /// </para>
- /// </remarks>
- public virtual void Log(Type callerStackBoundaryDeclaringType, Level level, object message, Exception exception)
- {
- try
- {
- if (IsEnabledFor(level))
- {
+ /// <summary>
+ /// This generic form is intended to be used by wrappers.
+ /// </summary>
+ /// <param name="callerStackBoundaryDeclaringType">The declaring type of the method that is
+ /// the stack boundary into the logging system for this call.</param>
+ /// <param name="level">The level of the message to be logged.</param>
+ /// <param name="message">The message object to log.</param>
+ /// <param name="exception">The exception to log, including its stack trace.</param>
+ /// <remarks>
+ /// <para>
+ /// Generate a logging event for the specified <paramref name="level"/> using
+ /// the <paramref name="message"/> and <paramref name="exception"/>.
+ /// </para>
+ /// <para>
+ /// This method must not throw any exception to the caller.
+ /// </para>
+ /// </remarks>
+ public virtual void Log(Type callerStackBoundaryDeclaringType, Level level, object message, Exception exception)
+ {
+ try
+ {
+ if (IsEnabledFor(level))
+ {
ForcedLog((callerStackBoundaryDeclaringType != null) ? callerStackBoundaryDeclaringType : declaringType, level, message, exception);
- }
- }
- catch (Exception ex)
- {
- log4net.Util.LogLog.Error(declaringType, "Exception while logging", ex);
- }
+ }
+ }
+ catch (Exception ex)
+ {
+ log4net.Util.LogLog.Error(declaringType, "Exception while logging", ex);
+ }
#if !NET_2_0 && !MONO_2_0 && !MONO_3_5 && !MONO_4_0 && !NETSTANDARD
- catch
- {
- log4net.Util.LogLog.Error(declaringType, "Exception while logging");
- }
+ catch
+ {
+ log4net.Util.LogLog.Error(declaringType, "Exception while logging");
+ }
#endif
- }
+ }
- /// <summary>
- /// This is the most generic printing method that is intended to be used
- /// by wrappers.
- /// </summary>
- /// <param name="logEvent">The event being logged.</param>
- /// <remarks>
- /// <para>
- /// Logs the specified logging event through this logger.
- /// </para>
- /// <para>
- /// This method must not throw any exception to the caller.
- /// </para>
- /// </remarks>
- public virtual void Log(LoggingEvent logEvent)
- {
- try
- {
- if (logEvent != null)
- {
- if (IsEnabledFor(logEvent.Level))
- {
- ForcedLog(logEvent);
- }
- }
- }
- catch (Exception ex)
- {
- log4net.Util.LogLog.Error(declaringType, "Exception while logging", ex);
- }
+ /// <summary>
+ /// This is the most generic printing method that is intended to be used
+ /// by wrappers.
+ /// </summary>
+ /// <param name="logEvent">The event being logged.</param>
+ /// <remarks>
+ /// <para>
+ /// Logs the specified logging event through this logger.
+ /// </para>
+ /// <para>
+ /// This method must not throw any exception to the caller.
+ /// </para>
+ /// </remarks>
+ public virtual void Log(LoggingEvent logEvent)
+ {
+ try
+ {
+ if (logEvent != null)
+ {
+ if (IsEnabledFor(logEvent.Level))
+ {
+ ForcedLog(logEvent);
+ }
+ }
+ }
+ catch (Exception ex)
+ {
+ log4net.Util.LogLog.Error(declaringType, "Exception while logging", ex);
+ }
#if !NET_2_0 && !MONO_2_0 && !MONO_3_5 && !MONO_4_0 && !NETSTANDARD
- catch
- {
- log4net.Util.LogLog.Error(declaringType, "Exception while logging");
- }
+ catch
+ {
+ log4net.Util.LogLog.Error(declaringType, "Exception while logging");
+ }
#endif
- }
+ }
- /// <summary>
- /// Checks if this logger is enabled for a given <see cref="Level"/> passed as parameter.
- /// </summary>
- /// <param name="level">The level to check.</param>
- /// <returns>
- /// <c>true</c> if this logger is enabled for <c>level</c>, otherwise <c>false</c>.
- /// </returns>
- /// <remarks>
- /// <para>
- /// Test if this logger is going to log events of the specified <paramref name="level"/>.
- /// </para>
- /// <para>
- /// This method must not throw any exception to the caller.
- /// </para>
- /// </remarks>
- public virtual bool IsEnabledFor(Level level)
- {
- try
- {
- if (level != null)
- {
- if (m_hierarchy.IsDisabled(level))
- {
- return false;
- }
- return level >= this.EffectiveLevel;
- }
- }
- catch (Exception ex)
- {
- log4net.Util.LogLog.Error(declaringType, "Exception while logging", ex);
- }
+ /// <summary>
+ /// Checks if this logger is enabled for a given <see cref="Level"/> passed as parameter.
+ /// </summary>
+ /// <param name="level">The level to check.</param>
+ /// <returns>
+ /// <c>true</c> if this logger is enabled for <c>level</c>, otherwise <c>false</c>.
+ /// </returns>
+ /// <remarks>
+ /// <para>
+ /// Test if this logger is going to log events of the specified <paramref name="level"/>.
+ /// </para>
+ /// <para>
+ /// This method must not throw any exception to the caller.
+ /// </para>
+ /// </remarks>
+ public virtual bool IsEnabledFor(Level level)
+ {
+ try
+ {
+ if (level != null)
+ {
+ if (m_hierarchy.IsDisabled(level))
+ {
+ return false;
+ }
+ return level >= this.EffectiveLevel;
+ }
+ }
+ catch (Exception ex)
+ {
+ log4net.Util.LogLog.Error(declaringType, "Exception while logging", ex);
+ }
#if !NET_2_0 && !MONO_2_0 && !MONO_3_5 && !MONO_4_0 && !NETSTANDARD
- catch
- {
- log4net.Util.LogLog.Error(declaringType, "Exception while logging");
- }
+ catch
+ {
+ log4net.Util.LogLog.Error(declaringType, "Exception while logging");
+ }
#endif
- return false;
- }
+ return false;
+ }
- /// <summary>
- /// Gets the <see cref="ILoggerRepository"/> where this
- /// <c>Logger</c> instance is attached to.
- /// </summary>
- /// <value>
- /// The <see cref="ILoggerRepository" /> that this logger belongs to.
- /// </value>
- /// <remarks>
- /// <para>
- /// Gets the <see cref="ILoggerRepository"/> where this
- /// <c>Logger</c> instance is attached to.
- /// </para>
- /// </remarks>
- public ILoggerRepository Repository
- {
- get { return m_hierarchy; }
- }
+ /// <summary>
+ /// Gets the <see cref="ILoggerRepository"/> where this
+ /// <c>Logger</c> instance is attached to.
+ /// </summary>
+ /// <value>
+ /// The <see cref="ILoggerRepository" /> that this logger belongs to.
+ /// </value>
+ /// <remarks>
+ /// <para>
+ /// Gets the <see cref="ILoggerRepository"/> where this
+ /// <c>Logger</c> instance is attached to.
+ /// </para>
+ /// </remarks>
+ public ILoggerRepository Repository
+ {
+ get { return m_hierarchy; }
+ }
- #endregion Implementation of ILogger
+ #endregion Implementation of ILogger
- /// <summary>
- /// Deliver the <see cref="LoggingEvent"/> to the attached appenders.
- /// </summary>
- /// <param name="loggingEvent">The event to log.</param>
- /// <remarks>
- /// <para>
- /// Call the appenders in the hierarchy starting at
- /// <c>this</c>. If no appenders could be found, emit a
- /// warning.
- /// </para>
- /// <para>
- /// This method calls all the appenders inherited from the
- /// hierarchy circumventing any evaluation of whether to log or not
- /// to log the particular log request.
- /// </para>
- /// </remarks>
- protected virtual void CallAppenders(LoggingEvent loggingEvent)
- {
- if (loggingEvent == null)
- {
- throw new ArgumentNullException("loggingEvent");
- }
+ /// <summary>
+ /// Deliver the <see cref="LoggingEvent"/> to the attached appenders.
+ /// </summary>
+ /// <param name="loggingEvent">The event to log.</param>
+ /// <remarks>
+ /// <para>
+ /// Call the appenders in the hierarchy starting at
+ /// <c>this</c>. If no appenders could be found, emit a
+ /// warning.
+ /// </para>
+ /// <para>
+ /// This method calls all the appenders inherited from the
+ /// hierarchy circumventing any evaluation of whether to log or not
+ /// to log the particular log request.
+ /// </para>
+ /// </remarks>
+ protected virtual void CallAppenders(LoggingEvent loggingEvent)
+ {
+ if (loggingEvent == null)
+ {
+ throw new ArgumentNullException("loggingEvent");
+ }
- int writes = 0;
+ int writes = 0;
- for(Logger c=this; c != null; c=c.m_parent)
- {
- if (c.m_appenderAttachedImpl != null)
- {
- // Protected against simultaneous call to addAppender, removeAppender,...
- c.m_appenderLock.AcquireReaderLock();
- try
- {
- if (c.m_appenderAttachedImpl != null)
- {
- writes += c.m_appenderAttachedImpl.AppendLoopOnAppenders(loggingEvent);
- }
- }
- finally
- {
- c.m_appenderLock.ReleaseReaderLock();
- }
- }
+ for(Logger c=this; c != null; c=c.m_parent)
+ {
+ if (c.m_appenderAttachedImpl != null)
+ {
+ // Protected against simultaneous call to addAppender, removeAppender,...
+ c.m_appenderLock.AcquireReaderLock();
+ try
+ {
+ if (c.m_appenderAttachedImpl != null)
+ {
+ writes += c.m_appenderAttachedImpl.AppendLoopOnAppenders(loggingEvent);
+ }
+ }
+ finally
+ {
+ c.m_appenderLock.ReleaseReaderLock();
+ }
+ }
- if (!c.m_additive)
- {
- break;
- }
- }
-
- // No appenders in hierarchy, warn user only once.
- //
- // Note that by including the AppDomain values for the currently running
- // thread, it becomes much easier to see which application the warning
- // is from, which is especially helpful in a multi-AppDomain environment
- // (like IIS with multiple VDIRS). Without this, it can be difficult
- // or impossible to determine which .config file is missing appender
- // definitions.
- //
- if (!m_hierarchy.EmittedNoAppenderWarning && writes == 0)
- {
- m_hierarchy.EmittedNoAppenderWarning = true;
- LogLog.Debug(declaringType, "No appenders could be found for logger [" + Name + "] repository [" + Repository.Name + "]");
- LogLog.Debug(declaringType, "Please initialize the log4net system properly.");
- try
- {
- LogLog.Debug(declaringType, " Current AppDomain context information: ");
- LogLog.Debug(declaringType, " BaseDirectory : " + SystemInfo.ApplicationBaseDirectory);
+ if (!c.m_additive)
+ {
+ break;
+ }
+ }
+
+ // No appenders in hierarchy, warn user only once.
+ //
+ // Note that by including the AppDomain values for the currently running
+ // thread, it becomes much easier to see which application the warning
+ // is from, which is especially helpful in a multi-AppDomain environment
+ // (like IIS with multiple VDIRS). Without this, it can be difficult
+ // or impossible to determine which .config file is missing appender
+ // definitions.
+ //
+ if (!m_hierarchy.EmittedNoAppenderWarning && writes == 0)
+ {
+ m_hierarchy.EmittedNoAppenderWarning = true;
+ LogLog.Debug(declaringType, "No appenders could be found for logger [" + Name + "] repository [" + Repository.Name + "]");
+ LogLog.Debug(declaringType, "Please initialize the log4net system properly.");
+ try
+ {
+ LogLog.Debug(declaringType, " Current AppDomain context information: ");
+ LogLog.Debug(declaringType, " BaseDirectory : " + SystemInfo.ApplicationBaseDirectory);
#if !NETCF && !NETSTANDARD1_3
- LogLog.Debug(declaringType, " FriendlyName : " + AppDomain.CurrentDomain.FriendlyName);
- LogLog.Debug(declaringType, " DynamicDirectory: " + AppDomain.CurrentDomain.DynamicDirectory);
+ LogLog.Debug(declaringType, " FriendlyName : " + AppDomain.CurrentDomain.FriendlyName);
+ LogLog.Debug(declaringType, " DynamicDirectory: " + AppDomain.CurrentDomain.DynamicDirectory);
#endif
- }
- catch(System.Security.SecurityException)
- {
- // Insufficient permissions to display info from the AppDomain
- }
- }
- }
+ }
+ catch(System.Security.SecurityException)
+ {
+ // Insufficient permissions to display info from the AppDomain
+ }
+ }
+ }
- /// <summary>
- /// Closes all attached appenders implementing the <see cref="IAppenderAttachable"/> interface.
- /// </summary>
- /// <remarks>
- /// <para>
- /// Used to ensure that the appenders are correctly shutdown.
- /// </para>
- /// </remarks>
- public virtual void CloseNestedAppenders()
- {
- m_appenderLock.AcquireWriterLock();
- try
- {
- if (m_appenderAttachedImpl != null)
- {
- AppenderCollection appenders = m_appenderAttachedImpl.Appenders;
- foreach(IAppender appender in appenders)
- {
- if (appender is IAppenderAttachable)
- {
- appender.Close();
- }
- }
- }
- }
- finally
- {
- m_appenderLock.ReleaseWriterLock();
- }
- }
+ /// <summary>
+ /// Closes all attached appenders implementing the <see cref="IAppenderAttachable"/> interface.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Used to ensure that the appenders are correctly shutdown.
+ /// </para>
+ /// </remarks>
+ public virtual void CloseNestedAppenders()
+ {
+ m_appenderLock.AcquireWriterLock();
+ try
+ {
+ if (m_appenderAttachedImpl != null)
+ {
+ AppenderCollection appenders = m_appenderAttachedImpl.Appenders;
+ foreach(IAppender appender in appenders)
+ {
+ if (appender is IAppenderAttachable)
+ {
+ appender.Close();
+ }
+ }
+ }
+ }
+ finally
+ {
+ m_appenderLock.ReleaseWriterLock();
+ }
+ }
- /// <summary>
- /// This is the most generic printing method. This generic form is intended to be used by wrappers
- /// </summary>
- /// <param name="level">The level of the message to be logged.</param>
- /// <param name="message">The message object to log.</param>
- /// <param name="exception">The exception to log, including its stack trace.</param>
- /// <remarks>
- /// <para>
- /// Generate a logging event for the specified <paramref name="level"/> using
- /// the <paramref name="message"/>.
- /// </para>
- /// </remarks>
- public virtual void Log(Level level, object message, Exception exception)
- {
- if (IsEnabledFor(level))
- {
+ /// <summary>
+ /// This is the most generic printing method. This generic form is intended to be used by wrappers
+ /// </summary>
+ /// <param name="level">The level of the message to be logged.</param>
+ /// <param name="message">The message object to log.</param>
+ /// <param name="exception">The exception to log, including its stack trace.</param>
+ /// <remarks>
+ /// <para>
+ /// Generate a logging event for the specified <paramref name="level"/> using
+ /// the <paramref name="message"/>.
+ /// </para>
+ /// </remarks>
+ public virtual void Log(Level level, object message, Exception exception)
+ {
+ if (IsEnabledFor(level))
+ {
ForcedLog(declaringType, level, message, exception);
- }
- }
+ }
+ }
- /// <summary>
- /// Creates a new logging event and logs the event without further checks.
- /// </summary>
- /// <param name="callerStackBoundaryDeclaringType">The declaring type of the method that is
- /// the stack boundary into the logging system for this call.</param>
- /// <param name="level">The level of the message to be logged.</param>
- /// <param name="message">The message object to log.</param>
- /// <param name="exception">The exception to log, including its stack trace.</param>
- /// <remarks>
- /// <para>
- /// Generates a logging event and delivers it to the attached
- /// appenders.
- /// </para>
- /// </remarks>
- protected virtual void ForcedLog(Type callerStackBoundaryDeclaringType, Level level, object message, Exception exception)
- {
- CallAppenders(new LoggingEvent(callerStackBoundaryDeclaringType, this.Hierarchy, this.Name, level, message, exception));
- }
+ /// <summary>
+ /// Creates a new logging event and logs the event without further checks.
+ /// </summary>
+ /// <param name="callerStackBoundaryDeclaringType">The declaring type of the method that is
+ /// the stack boundary into the logging system for this call.</param>
+ /// <param name="level">The level of the message to be logged.</param>
+ /// <param name="message">The message object to log.</param>
+ /// <param name="exception">The exception to log, including its stack trace.</param>
+ /// <remarks>
+ /// <para>
+ /// Generates a logging event and delivers it to the attached
+ /// appenders.
+ /// </para>
+ /// </remarks>
+ protected virtual void ForcedLog(Type callerStackBoundaryDeclaringType, Level level, object message, Exception exception)
+ {
+ CallAppenders(new LoggingEvent(callerStackBoundaryDeclaringType, this.Hierarchy, this.Name, level, message, exception));
+ }
- /// <summary>
- /// Creates a new logging event and logs the event without further checks.
- /// </summary>
- /// <param name="logEvent">The event being logged.</param>
- /// <remarks>
- /// <para>
- /// Delivers the logging event to the attached appenders.
- /// </para>
- /// </remarks>
- protected virtual void ForcedLog(LoggingEvent logEvent)
- {
- // The logging event may not have been created by this logger
- // the Repository may not be correctly set on the event. This
- // is required for the appenders to correctly lookup renderers etc...
- logEvent.EnsureRepository(this.Hierarchy);
+ /// <summary>
+ /// Creates a new logging event and logs the event without further checks.
+ /// </summary>
+ /// <param name="logEvent">The event being logged.</param>
+ /// <remarks>
+ /// <para>
+ /// Delivers the logging event to the attached appenders.
+ /// </para>
+ /// </remarks>
+ protected virtual void ForcedLog(LoggingEvent logEvent)
+ {
+ // The logging event may not have been created by this logger
+ // the Repository may not be correctly set on the event. This
+ // is required for the appenders to correctly lookup renderers etc...
+ logEvent.EnsureRepository(this.Hierarchy);
- CallAppenders(logEvent);
- }
+ CallAppenders(logEvent);
+ }
- #region Private Static Fields
+ #region Private Static Fields
/// <summary>
/// The fully qualified type of the Logger class.
/// </summary>
private static readonly Type declaringType = typeof(Logger);
- #endregion Private Static Fields
+ #endregion Private Static Fields
- #region Private Instance Fields
+ #region Private Instance Fields
- /// <summary>
- /// The name of this logger.
- /// </summary>
- private readonly string m_name;
+ /// <summary>
+ /// The name of this logger.
+ /// </summary>
+ private readonly string m_name;
- /// <summary>
- /// The assigned level of this logger.
- /// </summary>
- /// <remarks>
- /// <para>
- /// The <c>level</c> variable need not be
- /// assigned a value in which case it is inherited
- /// form the hierarchy.
- /// </para>
- /// </remarks>
- private Level m_level;
+ /// <summary>
+ /// The assigned level of this logger.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// The <c>level</c> variable need not be
+ /// assigned a value in which case it is inherited
+ /// form the hierarchy.
+ /// </para>
+ /// </remarks>
+ private Level m_level;
- /// <summary>
- /// The parent of this logger.
- /// </summary>
- /// <remarks>
- /// <para>
- /// The parent of this logger.
- /// All loggers have at least one ancestor which is the root logger.
- /// </para>
- /// </remarks>
- private Logger m_parent;
+ /// <summary>
+ /// The parent of this logger.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// The parent of this logger.
+ /// All loggers have at least one ancestor which is the root logger.
+ /// </para>
+ /// </remarks>
+ private Logger m_parent;
- /// <summary>
- /// Loggers need to know what Hierarchy they are in.
- /// </summary>
- /// <remarks>
- /// <para>
- /// Loggers need to know what Hierarchy they are in.
- /// The hierarchy that this logger is a member of is stored
- /// here.
- /// </para>
- /// </remarks>
- private Hierarchy m_hierarchy;
+ /// <summary>
+ /// Loggers need to know what Hierarchy they are in.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Loggers need to know what Hierarchy they are in.
+ /// The hierarchy that this logger is a member of is stored
+ /// here.
+ /// </para>
+ /// </remarks>
+ private Hierarchy m_hierarchy;
- /// <summary>
- /// Helper implementation of the <see cref="IAppenderAttachable"/> interface
- /// </summary>
- private log4net.Util.AppenderAttachedImpl m_appenderAttachedImpl;
+ /// <summary>
+ /// Helper implementation of the <see cref="IAppenderAttachable"/> interface
+ /// </summary>
+ private log4net.Util.AppenderAttachedImpl m_appenderAttachedImpl;
- /// <summary>
- /// Flag indicating if child loggers inherit their parents appenders
- /// </summary>
- /// <remarks>
- /// <para>
- /// Additivity is set to true by default, that is children inherit
- /// the appenders of their ancestors by default. If this variable is
- /// set to <c>false</c> then the appenders found in the
- /// ancestors of this logger are not used. However, the children
- /// of this logger will inherit its appenders, unless the children
- /// have their additivity flag set to <c>false</c> too. See
- /// the user manual for more details.
- /// </para>
- /// </remarks>
- private bool m_additive = true;
+ /// <summary>
+ /// Flag indicating if child loggers inherit their parents appenders
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Additivity is set to true by default, that is children inherit
+ /// the appenders of their ancestors by default. If this variable is
+ /// set to <c>false</c> then the appenders found in the
+ /// ancestors of this logger are not used. However, the children
+ /// of this logger will inherit its appenders, unless the children
+ /// have their additivity flag set to <c>false</c> too. See
+ /// the user manual for more details.
+ /// </para>
+ /// </remarks>
+ private bool m_additive = true;
- /// <summary>
- /// Lock to protect AppenderAttachedImpl variable m_appenderAttachedImpl
- /// </summary>
- private readonly ReaderWriterLock m_appenderLock = new ReaderWriterLock();
+ /// <summary>
+ /// Lock to protect AppenderAttachedImpl variable m_appenderAttachedImpl
+ /// </summary>
+ private readonly ReaderWriterLock m_appenderLock = new ReaderWriterLock();
- #endregion
- }
+ #endregion
+ }
}
diff --git a/src/log4net/Repository/Hierarchy/LoggerKey.cs b/src/log4net/Repository/Hierarchy/LoggerKey.cs
index 1485417..0067152 100644
--- a/src/log4net/Repository/Hierarchy/LoggerKey.cs
+++ b/src/log4net/Repository/Hierarchy/LoggerKey.cs
@@ -21,118 +21,118 @@
namespace log4net.Repository.Hierarchy
{
- /// <summary>
- /// Used internally to accelerate hash table searches.
- /// </summary>
- /// <remarks>
- /// <para>
- /// Internal class used to improve performance of
- /// string keyed hashtables.
- /// </para>
- /// <para>
- /// The hashcode of the string is cached for reuse.
- /// The string is stored as an interned value.
- /// When comparing two <see cref="LoggerKey"/> objects for equality
- /// the reference equality of the interned strings is compared.
- /// </para>
- /// </remarks>
- /// <author>Nicko Cadell</author>
- /// <author>Gert Driesen</author>
- internal sealed class LoggerKey
- {
- #region Internal Instance Constructors
+ /// <summary>
+ /// Used internally to accelerate hash table searches.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Internal class used to improve performance of
+ /// string keyed hashtables.
+ /// </para>
+ /// <para>
+ /// The hashcode of the string is cached for reuse.
+ /// The string is stored as an interned value.
+ /// When comparing two <see cref="LoggerKey"/> objects for equality
+ /// the reference equality of the interned strings is compared.
+ /// </para>
+ /// </remarks>
+ /// <author>Nicko Cadell</author>
+ /// <author>Gert Driesen</author>
+ internal sealed class LoggerKey
+ {
+ #region Internal Instance Constructors
- /// <summary>
- /// Construct key with string name
- /// </summary>
- /// <remarks>
- /// <para>
- /// Initializes a new instance of the <see cref="LoggerKey" /> class
- /// with the specified name.
- /// </para>
- /// <para>
- /// Stores the hashcode of the string and interns
- /// the string key to optimize comparisons.
- /// </para>
- /// <note>
- /// The Compact Framework 1.0 the <see cref="String.Intern"/>
- /// method does not work. On the Compact Framework
- /// the string keys are not interned nor are they
- /// compared by reference.
- /// </note>
- /// </remarks>
- /// <param name="name">The name of the logger.</param>
- internal LoggerKey(string name)
- {
+ /// <summary>
+ /// Construct key with string name
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Initializes a new instance of the <see cref="LoggerKey" /> class
+ /// with the specified name.
+ /// </para>
+ /// <para>
+ /// Stores the hashcode of the string and interns
+ /// the string key to optimize comparisons.
+ /// </para>
+ /// <note>
+ /// The Compact Framework 1.0 the <see cref="String.Intern"/>
+ /// method does not work. On the Compact Framework
+ /// the string keys are not interned nor are they
+ /// compared by reference.
+ /// </note>
+ /// </remarks>
+ /// <param name="name">The name of the logger.</param>
+ internal LoggerKey(string name)
+ {
#if NETCF || NETSTANDARD1_3
- // NETCF: String.Intern causes Native Exception
- m_name = name;
+ // NETCF: String.Intern causes Native Exception
+ m_name = name;
#else
- m_name = string.Intern(name);
+ m_name = string.Intern(name);
#endif
- m_hashCache = name.GetHashCode();
- }
+ m_hashCache = name.GetHashCode();
+ }
- #endregion Internal Instance Constructors
+ #endregion Internal Instance Constructors
- #region Override implementation of Object
+ #region Override implementation of Object
- /// <summary>
- /// Returns a hash code for the current instance.
- /// </summary>
- /// <returns>A hash code for the current instance.</returns>
- /// <remarks>
- /// <para>
- /// Returns the cached hashcode.
- /// </para>
- /// </remarks>
- public override int GetHashCode()
- {
- return m_hashCache;
- }
+ /// <summary>
+ /// Returns a hash code for the current instance.
+ /// </summary>
+ /// <returns>A hash code for the current instance.</returns>
+ /// <remarks>
+ /// <para>
+ /// Returns the cached hashcode.
+ /// </para>
+ /// </remarks>
+ public override int GetHashCode()
+ {
+ return m_hashCache;
+ }
- /// <summary>
- /// Determines whether two <see cref="LoggerKey" /> instances
- /// are equal.
- /// </summary>
- /// <param name="obj">The <see cref="object" /> to compare with the current <see cref="LoggerKey" />.</param>
- /// <returns>
- /// <c>true</c> if the specified <see cref="object" /> is equal to the current <see cref="LoggerKey" />; otherwise, <c>false</c>.
- /// </returns>
- /// <remarks>
- /// <para>
- /// Compares the references of the interned strings.
- /// </para>
- /// </remarks>
- public override bool Equals(object obj)
- {
- // Compare reference type of this against argument
- if (((object)this) == obj)
- {
- return true;
- }
-
- LoggerKey objKey = obj as LoggerKey;
- if (objKey != null)
- {
+ /// <summary>
+ /// Determines whether two <see cref="LoggerKey" /> instances
+ /// are equal.
+ /// </summary>
+ /// <param name="obj">The <see cref="object" /> to compare with the current <see cref="LoggerKey" />.</param>
+ /// <returns>
+ /// <c>true</c> if the specified <see cref="object" /> is equal to the current <see cref="LoggerKey" />; otherwise, <c>false</c>.
+ /// </returns>
+ /// <remarks>
+ /// <para>
+ /// Compares the references of the interned strings.
+ /// </para>
+ /// </remarks>
+ public override bool Equals(object obj)
+ {
+ // Compare reference type of this against argument
+ if (((object)this) == obj)
+ {
+ return true;
+ }
+
+ LoggerKey objKey = obj as LoggerKey;
+ if (objKey != null)
+ {
#if NETCF || NETSTANDARD1_3
- return ( m_name == objKey.m_name );
+ return ( m_name == objKey.m_name );
#else
- // Compare reference types rather than string's overloaded ==
- return ( ((object)m_name) == ((object)objKey.m_name) );
+ // Compare reference types rather than string's overloaded ==
+ return ( ((object)m_name) == ((object)objKey.m_name) );
#endif
- }
- return false;
- }
+ }
+ return false;
+ }
- #endregion
+ #endregion
- #region Private Instance Fields
+ #region Private Instance Fields
- private readonly string m_name;
- private readonly int m_hashCache;
+ private readonly string m_name;
+ private readonly int m_hashCache;
- #endregion Private Instance Fields
- }
+ #endregion Private Instance Fields
+ }
}
diff --git a/src/log4net/Repository/Hierarchy/ProvisionNode.cs b/src/log4net/Repository/Hierarchy/ProvisionNode.cs
index 50f4e16..9262a47 100644
--- a/src/log4net/Repository/Hierarchy/ProvisionNode.cs
+++ b/src/log4net/Repository/Hierarchy/ProvisionNode.cs
@@ -22,37 +22,37 @@
namespace log4net.Repository.Hierarchy
{
- /// <summary>
- /// Provision nodes are used where no logger instance has been specified
- /// </summary>
- /// <remarks>
- /// <para>
- /// <see cref="ProvisionNode"/> instances are used in the
- /// <see cref="Hierarchy" /> when there is no specified
- /// <see cref="Logger" /> for that node.
- /// </para>
- /// <para>
- /// A provision node holds a list of child loggers on behalf of
- /// a logger that does not exist.
- /// </para>
- /// </remarks>
- /// <author>Nicko Cadell</author>
- /// <author>Gert Driesen</author>
- internal sealed class ProvisionNode : ArrayList
- {
- /// <summary>
- /// Create a new provision node with child node
- /// </summary>
- /// <param name="log">A child logger to add to this node.</param>
- /// <remarks>
- /// <para>
- /// Initializes a new instance of the <see cref="ProvisionNode" /> class
- /// with the specified child logger.
- /// </para>
- /// </remarks>
- internal ProvisionNode(Logger log) : base()
- {
- this.Add(log);
- }
- }
+ /// <summary>
+ /// Provision nodes are used where no logger instance has been specified
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// <see cref="ProvisionNode"/> instances are used in the
+ /// <see cref="Hierarchy" /> when there is no specified
+ /// <see cref="Logger" /> for that node.
+ /// </para>
+ /// <para>
+ /// A provision node holds a list of child loggers on behalf of
+ /// a logger that does not exist.
+ /// </para>
+ /// </remarks>
+ /// <author>Nicko Cadell</author>
+ /// <author>Gert Driesen</author>
+ internal sealed class ProvisionNode : ArrayList
+ {
+ /// <summary>
+ /// Create a new provision node with child node
+ /// </summary>
+ /// <param name="log">A child logger to add to this node.</param>
+ /// <remarks>
+ /// <para>
+ /// Initializes a new instance of the <see cref="ProvisionNode" /> class
+ /// with the specified child logger.
+ /// </para>
+ /// </remarks>
+ internal ProvisionNode(Logger log) : base()
+ {
+ this.Add(log);
+ }
+ }
}
diff --git a/src/log4net/Repository/Hierarchy/RootLogger.cs b/src/log4net/Repository/Hierarchy/RootLogger.cs
index 8184e3f..dae8aa9 100644
--- a/src/log4net/Repository/Hierarchy/RootLogger.cs
+++ b/src/log4net/Repository/Hierarchy/RootLogger.cs
@@ -24,110 +24,110 @@
namespace log4net.Repository.Hierarchy
{
- /// <summary>
- /// The <see cref="RootLogger" /> sits at the root of the logger hierarchy tree.
- /// </summary>
- /// <remarks>
- /// <para>
- /// The <see cref="RootLogger" /> is a regular <see cref="Logger" /> except
- /// that it provides several guarantees.
- /// </para>
- /// <para>
- /// First, it cannot be assigned a <c>null</c>
- /// level. Second, since the root logger cannot have a parent, the
- /// <see cref="EffectiveLevel"/> property always returns the value of the
- /// level field without walking the hierarchy.
- /// </para>
- /// </remarks>
- /// <author>Nicko Cadell</author>
- /// <author>Gert Driesen</author>
- public class RootLogger : Logger
- {
- #region Public Instance Constructors
+ /// <summary>
+ /// The <see cref="RootLogger" /> sits at the root of the logger hierarchy tree.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// The <see cref="RootLogger" /> is a regular <see cref="Logger" /> except
+ /// that it provides several guarantees.
+ /// </para>
+ /// <para>
+ /// First, it cannot be assigned a <c>null</c>
+ /// level. Second, since the root logger cannot have a parent, the
+ /// <see cref="EffectiveLevel"/> property always returns the value of the
+ /// level field without walking the hierarchy.
+ /// </para>
+ /// </remarks>
+ /// <author>Nicko Cadell</author>
+ /// <author>Gert Driesen</author>
+ public class RootLogger : Logger
+ {
+ #region Public Instance Constructors
- /// <summary>
- /// Construct a <see cref="RootLogger"/>
- /// </summary>
- /// <param name="level">The level to assign to the root logger.</param>
- /// <remarks>
- /// <para>
- /// Initializes a new instance of the <see cref="RootLogger" /> class with
- /// the specified logging level.
- /// </para>
- /// <para>
- /// The root logger names itself as "root". However, the root
- /// logger cannot be retrieved by name.
- /// </para>
- /// </remarks>
- public RootLogger(Level level) : base("root")
- {
- this.Level = level;
- }
+ /// <summary>
+ /// Construct a <see cref="RootLogger"/>
+ /// </summary>
+ /// <param name="level">The level to assign to the root logger.</param>
+ /// <remarks>
+ /// <para>
+ /// Initializes a new instance of the <see cref="RootLogger" /> class with
+ /// the specified logging level.
+ /// </para>
+ /// <para>
+ /// The root logger names itself as "root". However, the root
+ /// logger cannot be retrieved by name.
+ /// </para>
+ /// </remarks>
+ public RootLogger(Level level) : base("root")
+ {
+ this.Level = level;
+ }
- #endregion Public Instance Constructors
+ #endregion Public Instance Constructors
- #region Override implementation of Logger
+ #region Override implementation of Logger
- /// <summary>
- /// Gets the assigned level value without walking the logger hierarchy.
- /// </summary>
- /// <value>The assigned level value without walking the logger hierarchy.</value>
- /// <remarks>
- /// <para>
- /// Because the root logger cannot have a parent and its level
- /// must not be <c>null</c> this property just returns the
- /// value of <see cref="Logger.Level"/>.
- /// </para>
- /// </remarks>
- public override Level EffectiveLevel
- {
- get
- {
- return base.Level;
- }
- }
+ /// <summary>
+ /// Gets the assigned level value without walking the logger hierarchy.
+ /// </summary>
+ /// <value>The assigned level value without walking the logger hierarchy.</value>
+ /// <remarks>
+ /// <para>
+ /// Because the root logger cannot have a parent and its level
+ /// must not be <c>null</c> this property just returns the
+ /// value of <see cref="Logger.Level"/>.
+ /// </para>
+ /// </remarks>
+ public override Level EffectiveLevel
+ {
+ get
+ {
+ return base.Level;
+ }
+ }
- /// <summary>
- /// Gets or sets the assigned <see cref="Level"/> for the root logger.
- /// </summary>
- /// <value>
- /// The <see cref="Level"/> of the root logger.
- /// </value>
- /// <remarks>
- /// <para>
- /// Setting the level of the root logger to a <c>null</c> reference
- /// may have catastrophic results. We prevent this here.
- /// </para>
- /// </remarks>
- public override Level Level
- {
- get { return base.Level; }
- set
- {
- if (value == null)
- {
- LogLog.Error(declaringType, "You have tried to set a null level to root.", new LogException());
- }
- else
- {
- base.Level = value;
- }
- }
- }
+ /// <summary>
+ /// Gets or sets the assigned <see cref="Level"/> for the root logger.
+ /// </summary>
+ /// <value>
+ /// The <see cref="Level"/> of the root logger.
+ /// </value>
+ /// <remarks>
+ /// <para>
+ /// Setting the level of the root logger to a <c>null</c> reference
+ /// may have catastrophic results. We prevent this here.
+ /// </para>
+ /// </remarks>
+ public override Level Level
+ {
+ get { return base.Level; }
+ set
+ {
+ if (value == null)
+ {
+ LogLog.Error(declaringType, "You have tried to set a null level to root.", new LogException());
+ }
+ else
+ {
+ base.Level = value;
+ }
+ }
+ }
- #endregion Override implementation of Logger
+ #endregion Override implementation of Logger
- #region Private Static Fields
+ #region Private Static Fields
- /// <summary>
- /// The fully qualified type of the RootLogger class.
- /// </summary>
- /// <remarks>
- /// Used by the internal logger to record the Type of the
- /// log message.
- /// </remarks>
- private static readonly Type declaringType = typeof(RootLogger);
+ /// <summary>
+ /// The fully qualified type of the RootLogger class.
+ /// </summary>
+ /// <remarks>
+ /// Used by the internal logger to record the Type of the
+ /// log message.
+ /// </remarks>
+ private static readonly Type declaringType = typeof(RootLogger);
- #endregion Private Static Fields
- }
+ #endregion Private Static Fields
+ }
}
diff --git a/src/log4net/Repository/Hierarchy/XmlHierarchyConfigurator.cs b/src/log4net/Repository/Hierarchy/XmlHierarchyConfigurator.cs
index bc2561d..b7bb605 100644
--- a/src/log4net/Repository/Hierarchy/XmlHierarchyConfigurator.cs
+++ b/src/log4net/Repository/Hierarchy/XmlHierarchyConfigurator.cs
@@ -30,69 +30,69 @@
namespace log4net.Repository.Hierarchy
{
- /// <summary>
- /// Initializes the log4net environment using an XML DOM.
- /// </summary>
- /// <remarks>
- /// <para>
- /// Configures a <see cref="Hierarchy"/> using an XML DOM.
- /// </para>
- /// </remarks>
- /// <author>Nicko Cadell</author>
- /// <author>Gert Driesen</author>
- public class XmlHierarchyConfigurator
- {
- private enum ConfigUpdateMode
- {
- Merge,
- Overwrite
- }
+ /// <summary>
+ /// Initializes the log4net environment using an XML DOM.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Configures a <see cref="Hierarchy"/> using an XML DOM.
+ /// </para>
+ /// </remarks>
+ /// <author>Nicko Cadell</author>
+ /// <author>Gert Driesen</author>
+ public class XmlHierarchyConfigurator
+ {
+ private enum ConfigUpdateMode
+ {
+ Merge,
+ Overwrite
+ }
- #region Public Instance Constructors
+ #region Public Instance Constructors
- /// <summary>
- /// Construct the configurator for a hierarchy
- /// </summary>
- /// <param name="hierarchy">The hierarchy to build.</param>
- /// <remarks>
- /// <para>
- /// Initializes a new instance of the <see cref="XmlHierarchyConfigurator" /> class
- /// with the specified <see cref="Hierarchy" />.
- /// </para>
- /// </remarks>
- public XmlHierarchyConfigurator(Hierarchy hierarchy)
- {
- m_hierarchy = hierarchy;
- m_appenderBag = new Hashtable();
- }
+ /// <summary>
+ /// Construct the configurator for a hierarchy
+ /// </summary>
+ /// <param name="hierarchy">The hierarchy to build.</param>
+ /// <remarks>
+ /// <para>
+ /// Initializes a new instance of the <see cref="XmlHierarchyConfigurator" /> class
+ /// with the specified <see cref="Hierarchy" />.
+ /// </para>
+ /// </remarks>
+ public XmlHierarchyConfigurator(Hierarchy hierarchy)
+ {
+ m_hierarchy = hierarchy;
+ m_appenderBag = new Hashtable();
+ }
- #endregion Public Instance Constructors
+ #endregion Public Instance Constructors
- #region Public Instance Methods
+ #region Public Instance Methods
- /// <summary>
- /// Configure the hierarchy by parsing a DOM tree of XML elements.
- /// </summary>
- /// <param name="element">The root element to parse.</param>
- /// <remarks>
- /// <para>
- /// Configure the hierarchy by parsing a DOM tree of XML elements.
- /// </para>
- /// </remarks>
- public void Configure(XmlElement element)
- {
- if (element == null || m_hierarchy == null)
- {
+ /// <summary>
+ /// Configure the hierarchy by parsing a DOM tree of XML elements.
+ /// </summary>
+ /// <param name="element">The root element to parse.</param>
+ /// <remarks>
+ /// <para>
+ /// Configure the hierarchy by parsing a DOM tree of XML elements.
+ /// </para>
+ /// </remarks>
+ public void Configure(XmlElement element)
+ {
+ if (element == null || m_hierarchy == null)
+ {
return;
- }
+ }
- string rootElementName = element.LocalName;
+ string rootElementName = element.LocalName;
- if (rootElementName != CONFIGURATION_TAG)
- {
- LogLog.Error(declaringType, "Xml element is - not a <" + CONFIGURATION_TAG + "> element.");
+ if (rootElementName != CONFIGURATION_TAG)
+ {
+ LogLog.Error(declaringType, "Xml element is - not a <" + CONFIGURATION_TAG + "> element.");
return;
- }
+ }
if (!LogLog.EmitInternalMessages)
{
@@ -110,1054 +110,1054 @@
}
}
- if (!LogLog.InternalDebugging)
- {
- // Look for a debug attribute to enable internal debug
- string debugAttribute = element.GetAttribute(INTERNAL_DEBUG_ATTR);
- LogLog.Debug(declaringType, INTERNAL_DEBUG_ATTR+" attribute [" + debugAttribute + "].");
+ if (!LogLog.InternalDebugging)
+ {
+ // Look for a debug attribute to enable internal debug
+ string debugAttribute = element.GetAttribute(INTERNAL_DEBUG_ATTR);
+ LogLog.Debug(declaringType, INTERNAL_DEBUG_ATTR+" attribute [" + debugAttribute + "].");
- if (debugAttribute.Length>0 && debugAttribute != "null")
- {
- LogLog.InternalDebugging = OptionConverter.ToBoolean(debugAttribute, true);
- }
- else
- {
- LogLog.Debug(declaringType, "Ignoring " + INTERNAL_DEBUG_ATTR + " attribute.");
- }
+ if (debugAttribute.Length>0 && debugAttribute != "null")
+ {
+ LogLog.InternalDebugging = OptionConverter.ToBoolean(debugAttribute, true);
+ }
+ else
+ {
+ LogLog.Debug(declaringType, "Ignoring " + INTERNAL_DEBUG_ATTR + " attribute.");
+ }
- string confDebug = element.GetAttribute(CONFIG_DEBUG_ATTR);
- if (confDebug.Length>0 && confDebug != "null")
- {
- LogLog.Warn(declaringType, "The \"" + CONFIG_DEBUG_ATTR + "\" attribute is deprecated.");
- LogLog.Warn(declaringType, "Use the \"" + INTERNAL_DEBUG_ATTR + "\" attribute instead.");
- LogLog.InternalDebugging = OptionConverter.ToBoolean(confDebug, true);
- }
- }
+ string confDebug = element.GetAttribute(CONFIG_DEBUG_ATTR);
+ if (confDebug.Length>0 && confDebug != "null")
+ {
+ LogLog.Warn(declaringType, "The \"" + CONFIG_DEBUG_ATTR + "\" attribute is deprecated.");
+ LogLog.Warn(declaringType, "Use the \"" + INTERNAL_DEBUG_ATTR + "\" attribute instead.");
+ LogLog.InternalDebugging = OptionConverter.ToBoolean(confDebug, true);
+ }
+ }
- // Default mode is merge
- ConfigUpdateMode configUpdateMode = ConfigUpdateMode.Merge;
+ // Default mode is merge
+ ConfigUpdateMode configUpdateMode = ConfigUpdateMode.Merge;
- // Look for the config update attribute
- string configUpdateModeAttribute = element.GetAttribute(CONFIG_UPDATE_MODE_ATTR);
- if (configUpdateModeAttribute != null && configUpdateModeAttribute.Length > 0)
- {
- // Parse the attribute
- try
- {
- configUpdateMode = (ConfigUpdateMode)OptionConverter.ConvertStringTo(typeof(ConfigUpdateMode), configUpdateModeAttribute);
- }
- catch
- {
- LogLog.Error(declaringType, "Invalid " + CONFIG_UPDATE_MODE_ATTR + " attribute value [" + configUpdateModeAttribute + "]");
- }
- }
+ // Look for the config update attribute
+ string configUpdateModeAttribute = element.GetAttribute(CONFIG_UPDATE_MODE_ATTR);
+ if (configUpdateModeAttribute != null && configUpdateModeAttribute.Length > 0)
+ {
+ // Parse the attribute
+ try
+ {
+ configUpdateMode = (ConfigUpdateMode)OptionConverter.ConvertStringTo(typeof(ConfigUpdateMode), configUpdateModeAttribute);
+ }
+ catch
+ {
+ LogLog.Error(declaringType, "Invalid " + CONFIG_UPDATE_MODE_ATTR + " attribute value [" + configUpdateModeAttribute + "]");
+ }
+ }
- // IMPL: The IFormatProvider argument to Enum.ToString() is deprecated in .NET 2.0
- LogLog.Debug(declaringType, "Configuration update mode [" + configUpdateMode.ToString() + "].");
+ // IMPL: The IFormatProvider argument to Enum.ToString() is deprecated in .NET 2.0
+ LogLog.Debug(declaringType, "Configuration update mode [" + configUpdateMode.ToString() + "].");
- // Only reset configuration if overwrite flag specified
- if (configUpdateMode == ConfigUpdateMode.Overwrite)
- {
- // Reset to original unset configuration
- m_hierarchy.ResetConfiguration();
- LogLog.Debug(declaringType, "Configuration reset before reading config.");
- }
+ // Only reset configuration if overwrite flag specified
+ if (configUpdateMode == ConfigUpdateMode.Overwrite)
+ {
+ // Reset to original unset configuration
+ m_hierarchy.ResetConfiguration();
+ LogLog.Debug(declaringType, "Configuration reset before reading config.");
+ }
- /* Building Appender objects, placing them in a local namespace
- for future reference */
+ /* Building Appender objects, placing them in a local namespace
+ for future reference */
- /* Process all the top level elements */
+ /* Process all the top level elements */
- foreach (XmlNode currentNode in element.ChildNodes)
- {
- if (currentNode.NodeType == XmlNodeType.Element)
- {
- XmlElement currentElement = (XmlElement)currentNode;
+ foreach (XmlNode currentNode in element.ChildNodes)
+ {
+ if (currentNode.NodeType == XmlNodeType.Element)
+ {
+ XmlElement currentElement = (XmlElement)currentNode;
- if (currentElement.LocalName == LOGGER_TAG)
- {
- ParseLogger(currentElement);
- }
- else if (currentElement.LocalName == CATEGORY_TAG)
- {
- // TODO: deprecated use of category
- ParseLogger(currentElement);
- }
- else if (currentElement.LocalName == ROOT_TAG)
- {
- ParseRoot(currentElement);
- }
- else if (currentElement.LocalName == RENDERER_TAG)
- {
- ParseRenderer(currentElement);
- }
- else if (currentElement.LocalName == APPENDER_TAG)
- {
- // We ignore appenders in this pass. They will
- // be found and loaded if they are referenced.
- }
- else
- {
- // Read the param tags and set properties on the hierarchy
- SetParameter(currentElement, m_hierarchy);
- }
- }
- }
+ if (currentElement.LocalName == LOGGER_TAG)
+ {
+ ParseLogger(currentElement);
+ }
+ else if (currentElement.LocalName == CATEGORY_TAG)
+ {
+ // TODO: deprecated use of category
+ ParseLogger(currentElement);
+ }
+ else if (currentElement.LocalName == ROOT_TAG)
+ {
+ ParseRoot(currentElement);
+ }
+ else if (currentElement.LocalName == RENDERER_TAG)
+ {
+ ParseRenderer(currentElement);
+ }
+ else if (currentElement.LocalName == APPENDER_TAG)
+ {
+ // We ignore appenders in this pass. They will
+ // be found and loaded if they are referenced.
+ }
+ else
+ {
+ // Read the param tags and set properties on the hierarchy
+ SetParameter(currentElement, m_hierarchy);
+ }
+ }
+ }
- // Lastly set the hierarchy threshold
- string thresholdStr = element.GetAttribute(THRESHOLD_ATTR);
- LogLog.Debug(declaringType, "Hierarchy Threshold [" + thresholdStr + "]");
- if (thresholdStr.Length > 0 && thresholdStr != "null")
- {
- Level thresholdLevel = (Level) ConvertStringTo(typeof(Level), thresholdStr);
- if (thresholdLevel != null)
- {
- m_hierarchy.Threshold = thresholdLevel;
- }
- else
- {
- LogLog.Warn(declaringType, "Unable to set hierarchy threshold using value [" + thresholdStr + "] (with acceptable conversion types)");
- }
- }
+ // Lastly set the hierarchy threshold
+ string thresholdStr = element.GetAttribute(THRESHOLD_ATTR);
+ LogLog.Debug(declaringType, "Hierarchy Threshold [" + thresholdStr + "]");
+ if (thresholdStr.Length > 0 && thresholdStr != "null")
+ {
+ Level thresholdLevel = (Level) ConvertStringTo(typeof(Level), thresholdStr);
+ if (thresholdLevel != null)
+ {
+ m_hierarchy.Threshold = thresholdLevel;
+ }
+ else
+ {
+ LogLog.Warn(declaringType, "Unable to set hierarchy threshold using value [" + thresholdStr + "] (with acceptable conversion types)");
+ }
+ }
- // Done reading config
- }
+ // Done reading config
+ }
- #endregion Public Instance Methods
+ #endregion Public Instance Methods
- #region Protected Instance Methods
+ #region Protected Instance Methods
- /// <summary>
- /// Parse appenders by IDREF.
- /// </summary>
- /// <param name="appenderRef">The appender ref element.</param>
- /// <returns>The instance of the appender that the ref refers to.</returns>
- /// <remarks>
- /// <para>
- /// Parse an XML element that represents an appender and return
- /// the appender.
- /// </para>
- /// </remarks>
- protected IAppender FindAppenderByReference(XmlElement appenderRef)
- {
- string appenderName = appenderRef.GetAttribute(REF_ATTR);
+ /// <summary>
+ /// Parse appenders by IDREF.
+ /// </summary>
+ /// <param name="appenderRef">The appender ref element.</param>
+ /// <returns>The instance of the appender that the ref refers to.</returns>
+ /// <remarks>
+ /// <para>
+ /// Parse an XML element that represents an appender and return
+ /// the appender.
+ /// </para>
+ /// </remarks>
+ protected IAppender FindAppenderByReference(XmlElement appenderRef)
+ {
+ string appenderName = appenderRef.GetAttribute(REF_ATTR);
- IAppender appender = (IAppender)m_appenderBag[appenderName];
- if (appender != null)
- {
- return appender;
- }
- else
- {
- // Find the element with that id
- XmlElement element = null;
+ IAppender appender = (IAppender)m_appenderBag[appenderName];
+ if (appender != null)
+ {
+ return appender;
+ }
+ else
+ {
+ // Find the element with that id
+ XmlElement element = null;
- if (appenderName != null && appenderName.Length > 0)
- {
- foreach (XmlElement curAppenderElement in appenderRef.OwnerDocument.GetElementsByTagName(APPENDER_TAG))
- {
- if (curAppenderElement.GetAttribute("name") == appenderName)
- {
- element = curAppenderElement;
- break;
- }
- }
- }
+ if (appenderName != null && appenderName.Length > 0)
+ {
+ foreach (XmlElement curAppenderElement in appenderRef.OwnerDocument.GetElementsByTagName(APPENDER_TAG))
+ {
+ if (curAppenderElement.GetAttribute("name") == appenderName)
+ {
+ element = curAppenderElement;
+ break;
+ }
+ }
+ }
- if (element == null)
- {
- LogLog.Error(declaringType, "XmlHierarchyConfigurator: No appender named [" + appenderName + "] could be found.");
- return null;
- }
- else
- {
- appender = ParseAppender(element);
- if (appender != null)
- {
- m_appenderBag[appenderName] = appender;
- }
- return appender;
- }
- }
- }
+ if (element == null)
+ {
+ LogLog.Error(declaringType, "XmlHierarchyConfigurator: No appender named [" + appenderName + "] could be found.");
+ return null;
+ }
+ else
+ {
+ appender = ParseAppender(element);
+ if (appender != null)
+ {
+ m_appenderBag[appenderName] = appender;
+ }
+ return appender;
+ }
+ }
+ }
- /// <summary>
- /// Parses an appender element.
- /// </summary>
- /// <param name="appenderElement">The appender element.</param>
- /// <returns>The appender instance or <c>null</c> when parsing failed.</returns>
- /// <remarks>
- /// <para>
- /// Parse an XML element that represents an appender and return
- /// the appender instance.
- /// </para>
- /// </remarks>
- protected IAppender ParseAppender(XmlElement appenderElement)
- {
- string appenderName = appenderElement.GetAttribute(NAME_ATTR);
- string typeName = appenderElement.GetAttribute(TYPE_ATTR);
+ /// <summary>
+ /// Parses an appender element.
+ /// </summary>
+ /// <param name="appenderElement">The appender element.</param>
+ /// <returns>The appender instance or <c>null</c> when parsing failed.</returns>
+ /// <remarks>
+ /// <para>
+ /// Parse an XML element that represents an appender and return
+ /// the appender instance.
+ /// </para>
+ /// </remarks>
+ protected IAppender ParseAppender(XmlElement appenderElement)
+ {
+ string appenderName = appenderElement.GetAttribute(NAME_ATTR);
+ string typeName = appenderElement.GetAttribute(TYPE_ATTR);
- LogLog.Debug(declaringType, "Loading Appender [" + appenderName + "] type: [" + typeName + "]");
- try
- {
+ LogLog.Debug(declaringType, "Loading Appender [" + appenderName + "] type: [" + typeName + "]");
+ try
+ {
#if NETSTANDARD1_3
- IAppender appender = (IAppender)Activator.CreateInstance(SystemInfo.GetTypeFromString(this.GetType().GetTypeInfo().Assembly, typeName, true, true));
+ IAppender appender = (IAppender)Activator.CreateInstance(SystemInfo.GetTypeFromString(this.GetType().GetTypeInfo().Assembly, typeName, true, true));
#else
- IAppender appender = (IAppender)Activator.CreateInstance(SystemInfo.GetTypeFromString(typeName, true, true));
+ IAppender appender = (IAppender)Activator.CreateInstance(SystemInfo.GetTypeFromString(typeName, true, true));
#endif
- appender.Name = appenderName;
+ appender.Name = appenderName;
- foreach (XmlNode currentNode in appenderElement.ChildNodes)
- {
- /* We're only interested in Elements */
- if (currentNode.NodeType == XmlNodeType.Element)
- {
- XmlElement currentElement = (XmlElement)currentNode;
+ foreach (XmlNode currentNode in appenderElement.ChildNodes)
+ {
+ /* We're only interested in Elements */
+ if (currentNode.NodeType == XmlNodeType.Element)
+ {
+ XmlElement currentElement = (XmlElement)currentNode;
- // Look for the appender ref tag
- if (currentElement.LocalName == APPENDER_REF_TAG)
- {
- string refName = currentElement.GetAttribute(REF_ATTR);
+ // Look for the appender ref tag
+ if (currentElement.LocalName == APPENDER_REF_TAG)
+ {
+ string refName = currentElement.GetAttribute(REF_ATTR);
- IAppenderAttachable appenderContainer = appender as IAppenderAttachable;
- if (appenderContainer != null)
- {
- LogLog.Debug(declaringType, "Attaching appender named [" + refName + "] to appender named [" + appender.Name + "].");
+ IAppenderAttachable appenderContainer = appender as IAppenderAttachable;
+ if (appenderContainer != null)
+ {
+ LogLog.Debug(declaringType, "Attaching appender named [" + refName + "] to appender named [" + appender.Name + "].");
- IAppender referencedAppender = FindAppenderByReference(currentElement);
- if (referencedAppender != null)
- {
- appenderContainer.AddAppender(referencedAppender);
- }
- }
- else
- {
- LogLog.Error(declaringType, "Requesting attachment of appender named ["+refName+ "] to appender named [" + appender.Name + "] which does not implement log4net.Core.IAppenderAttachable.");
- }
- }
- else
- {
- // For all other tags we use standard set param method
- SetParameter(currentElement, appender);
- }
- }
- }
+ IAppender referencedAppender = FindAppenderByReference(currentElement);
+ if (referencedAppender != null)
+ {
+ appenderContainer.AddAppender(referencedAppender);
+ }
+ }
+ else
+ {
+ LogLog.Error(declaringType, "Requesting attachment of appender named ["+refName+ "] to appender named [" + appender.Name + "] which does not implement log4net.Core.IAppenderAttachable.");
+ }
+ }
+ else
+ {
+ // For all other tags we use standard set param method
+ SetParameter(currentElement, appender);
+ }
+ }
+ }
- IOptionHandler optionHandler = appender as IOptionHandler;
- if (optionHandler != null)
- {
- optionHandler.ActivateOptions();
- }
+ IOptionHandler optionHandler = appender as IOptionHandler;
+ if (optionHandler != null)
+ {
+ optionHandler.ActivateOptions();
+ }
- LogLog.Debug(declaringType, "Created Appender [" + appenderName + "]");
- return appender;
- }
- catch (Exception ex)
- {
- // Yes, it's ugly. But all exceptions point to the same problem: we can't create an Appender
+ LogLog.Debug(declaringType, "Created Appender [" + appenderName + "]");
+ return appender;
+ }
+ catch (Exception ex)
+ {
+ // Yes, it's ugly. But all exceptions point to the same problem: we can't create an Appender
- LogLog.Error(declaringType, "Could not create Appender [" + appenderName + "] of type [" + typeName + "]. Reported error follows.", ex);
- return null;
- }
- }
+ LogLog.Error(declaringType, "Could not create Appender [" + appenderName + "] of type [" + typeName + "]. Reported error follows.", ex);
+ return null;
+ }
+ }
- /// <summary>
- /// Parses a logger element.
- /// </summary>
- /// <param name="loggerElement">The logger element.</param>
- /// <remarks>
- /// <para>
- /// Parse an XML element that represents a logger.
- /// </para>
- /// </remarks>
- protected void ParseLogger(XmlElement loggerElement)
- {
- // Create a new log4net.Logger object from the <logger> element.
- string loggerName = loggerElement.GetAttribute(NAME_ATTR);
+ /// <summary>
+ /// Parses a logger element.
+ /// </summary>
+ /// <param name="loggerElement">The logger element.</param>
+ /// <remarks>
+ /// <para>
+ /// Parse an XML element that represents a logger.
+ /// </para>
+ /// </remarks>
+ protected void ParseLogger(XmlElement loggerElement)
+ {
+ // Create a new log4net.Logger object from the <logger> element.
+ string loggerName = loggerElement.GetAttribute(NAME_ATTR);
- LogLog.Debug(declaringType, "Retrieving an instance of log4net.Repository.Logger for logger [" + loggerName + "].");
- Logger log = m_hierarchy.GetLogger(loggerName) as Logger;
+ LogLog.Debug(declaringType, "Retrieving an instance of log4net.Repository.Logger for logger [" + loggerName + "].");
+ Logger log = m_hierarchy.GetLogger(loggerName) as Logger;
- // Setting up a logger needs to be an atomic operation, in order
- // to protect potential log operations while logger
- // configuration is in progress.
- lock(log)
- {
- bool additivity = OptionConverter.ToBoolean(loggerElement.GetAttribute(ADDITIVITY_ATTR), true);
-
- LogLog.Debug(declaringType, "Setting [" + log.Name + "] additivity to [" + additivity + "].");
- log.Additivity = additivity;
- ParseChildrenOfLoggerElement(loggerElement, log, false);
- }
- }
+ // Setting up a logger needs to be an atomic operation, in order
+ // to protect potential log operations while logger
+ // configuration is in progress.
+ lock(log)
+ {
+ bool additivity = OptionConverter.ToBoolean(loggerElement.GetAttribute(ADDITIVITY_ATTR), true);
+
+ LogLog.Debug(declaringType, "Setting [" + log.Name + "] additivity to [" + additivity + "].");
+ log.Additivity = additivity;
+ ParseChildrenOfLoggerElement(loggerElement, log, false);
+ }
+ }
- /// <summary>
- /// Parses the root logger element.
- /// </summary>
- /// <param name="rootElement">The root element.</param>
- /// <remarks>
- /// <para>
- /// Parse an XML element that represents the root logger.
- /// </para>
- /// </remarks>
- protected void ParseRoot(XmlElement rootElement)
- {
- Logger root = m_hierarchy.Root;
- // logger configuration needs to be atomic
- lock(root)
- {
- ParseChildrenOfLoggerElement(rootElement, root, true);
- }
- }
+ /// <summary>
+ /// Parses the root logger element.
+ /// </summary>
+ /// <param name="rootElement">The root element.</param>
+ /// <remarks>
+ /// <para>
+ /// Parse an XML element that represents the root logger.
+ /// </para>
+ /// </remarks>
+ protected void ParseRoot(XmlElement rootElement)
+ {
+ Logger root = m_hierarchy.Root;
+ // logger configuration needs to be atomic
+ lock(root)
+ {
+ ParseChildrenOfLoggerElement(rootElement, root, true);
+ }
+ }
- /// <summary>
- /// Parses the children of a logger element.
- /// </summary>
- /// <param name="catElement">The category element.</param>
- /// <param name="log">The logger instance.</param>
- /// <param name="isRoot">Flag to indicate if the logger is the root logger.</param>
- /// <remarks>
- /// <para>
- /// Parse the child elements of a <logger> element.
- /// </para>
- /// </remarks>
- protected void ParseChildrenOfLoggerElement(XmlElement catElement, Logger log, bool isRoot)
- {
- // Remove all existing appenders from log. They will be
- // reconstructed if need be.
- log.RemoveAllAppenders();
+ /// <summary>
+ /// Parses the children of a logger element.
+ /// </summary>
+ /// <param name="catElement">The category element.</param>
+ /// <param name="log">The logger instance.</param>
+ /// <param name="isRoot">Flag to indicate if the logger is the root logger.</param>
+ /// <remarks>
+ /// <para>
+ /// Parse the child elements of a <logger> element.
+ /// </para>
+ /// </remarks>
+ protected void ParseChildrenOfLoggerElement(XmlElement catElement, Logger log, bool isRoot)
+ {
+ // Remove all existing appenders from log. They will be
+ // reconstructed if need be.
+ log.RemoveAllAppenders();
- foreach (XmlNode currentNode in catElement.ChildNodes)
- {
- if (currentNode.NodeType == XmlNodeType.Element)
- {
- XmlElement currentElement = (XmlElement) currentNode;
-
- if (currentElement.LocalName == APPENDER_REF_TAG)
- {
- IAppender appender = FindAppenderByReference(currentElement);
- string refName = currentElement.GetAttribute(REF_ATTR);
- if (appender != null)
- {
- LogLog.Debug(declaringType, "Adding appender named [" + refName + "] to logger [" + log.Name + "].");
- log.AddAppender(appender);
- }
- else
- {
- LogLog.Error(declaringType, "Appender named [" + refName + "] not found.");
- }
- }
- else if (currentElement.LocalName == LEVEL_TAG || currentElement.LocalName == PRIORITY_TAG)
- {
- ParseLevel(currentElement, log, isRoot);
- }
- else
- {
- SetParameter(currentElement, log);
- }
- }
- }
+ foreach (XmlNode currentNode in catElement.ChildNodes)
+ {
+ if (currentNode.NodeType == XmlNodeType.Element)
+ {
+ XmlElement currentElement = (XmlElement) currentNode;
+
+ if (currentElement.LocalName == APPENDER_REF_TAG)
+ {
+ IAppender appender = FindAppenderByReference(currentElement);
+ string refName = currentElement.GetAttribute(REF_ATTR);
+ if (appender != null)
+ {
+ LogLog.Debug(declaringType, "Adding appender named [" + refName + "] to logger [" + log.Name + "].");
+ log.AddAppender(appender);
+ }
+ else
+ {
+ LogLog.Error(declaringType, "Appender named [" + refName + "] not found.");
+ }
+ }
+ else if (currentElement.LocalName == LEVEL_TAG || currentElement.LocalName == PRIORITY_TAG)
+ {
+ ParseLevel(currentElement, log, isRoot);
+ }
+ else
+ {
+ SetParameter(currentElement, log);
+ }
+ }
+ }
- IOptionHandler optionHandler = log as IOptionHandler;
- if (optionHandler != null)
- {
- optionHandler.ActivateOptions();
- }
- }
+ IOptionHandler optionHandler = log as IOptionHandler;
+ if (optionHandler != null)
+ {
+ optionHandler.ActivateOptions();
+ }
+ }
- /// <summary>
- /// Parses an object renderer.
- /// </summary>
- /// <param name="element">The renderer element.</param>
- /// <remarks>
- /// <para>
- /// Parse an XML element that represents a renderer.
- /// </para>
- /// </remarks>
- protected void ParseRenderer(XmlElement element)
- {
- string renderingClassName = element.GetAttribute(RENDERING_TYPE_ATTR);
- string renderedClassName = element.GetAttribute(RENDERED_TYPE_ATTR);
+ /// <summary>
+ /// Parses an object renderer.
+ /// </summary>
+ /// <param name="element">The renderer element.</param>
+ /// <remarks>
+ /// <para>
+ /// Parse an XML element that represents a renderer.
+ /// </para>
+ /// </remarks>
+ protected void ParseRenderer(XmlElement element)
+ {
+ string renderingClassName = element.GetAttribute(RENDERING_TYPE_ATTR);
+ string renderedClassName = element.GetAttribute(RENDERED_TYPE_ATTR);
- LogLog.Debug(declaringType, "Rendering class [" + renderingClassName + "], Rendered class [" + renderedClassName + "].");
- IObjectRenderer renderer = (IObjectRenderer)OptionConverter.InstantiateByClassName(renderingClassName, typeof(IObjectRenderer), null);
- if (renderer == null)
- {
- LogLog.Error(declaringType, "Could not instantiate renderer [" + renderingClassName + "].");
- return;
- }
- else
- {
- try
- {
+ LogLog.Debug(declaringType, "Rendering class [" + renderingClassName + "], Rendered class [" + renderedClassName + "].");
+ IObjectRenderer renderer = (IObjectRenderer)OptionConverter.InstantiateByClassName(renderingClassName, typeof(IObjectRenderer), null);
+ if (renderer == null)
+ {
+ LogLog.Error(declaringType, "Could not instantiate renderer [" + renderingClassName + "].");
+ return;
+ }
+ else
+ {
+ try
+ {
#if NETSTANDARD1_3
- m_hierarchy.RendererMap.Put(SystemInfo.GetTypeFromString(this.GetType().GetTypeInfo().Assembly, renderedClassName, true, true), renderer);
+ m_hierarchy.RendererMap.Put(SystemInfo.GetTypeFromString(this.GetType().GetTypeInfo().Assembly, renderedClassName, true, true), renderer);
#else
- m_hierarchy.RendererMap.Put(SystemInfo.GetTypeFromString(renderedClassName, true, true), renderer);
+ m_hierarchy.RendererMap.Put(SystemInfo.GetTypeFromString(renderedClassName, true, true), renderer);
#endif
- }
- catch(Exception e)
- {
- LogLog.Error(declaringType, "Could not find class [" + renderedClassName + "].", e);
- }
- }
- }
+ }
+ catch(Exception e)
+ {
+ LogLog.Error(declaringType, "Could not find class [" + renderedClassName + "].", e);
+ }
+ }
+ }
- /// <summary>
- /// Parses a level element.
- /// </summary>
- /// <param name="element">The level element.</param>
- /// <param name="log">The logger object to set the level on.</param>
- /// <param name="isRoot">Flag to indicate if the logger is the root logger.</param>
- /// <remarks>
- /// <para>
- /// Parse an XML element that represents a level.
- /// </para>
- /// </remarks>
- protected void ParseLevel(XmlElement element, Logger log, bool isRoot)
- {
- string loggerName = log.Name;
- if (isRoot)
- {
- loggerName = "root";
- }
+ /// <summary>
+ /// Parses a level element.
+ /// </summary>
+ /// <param name="element">The level element.</param>
+ /// <param name="log">The logger object to set the level on.</param>
+ /// <param name="isRoot">Flag to indicate if the logger is the root logger.</param>
+ /// <remarks>
+ /// <para>
+ /// Parse an XML element that represents a level.
+ /// </para>
+ /// </remarks>
+ protected void ParseLevel(XmlElement element, Logger log, bool isRoot)
+ {
+ string loggerName = log.Name;
+ if (isRoot)
+ {
+ loggerName = "root";
+ }
- string levelStr = element.GetAttribute(VALUE_ATTR);
- LogLog.Debug(declaringType, "Logger [" + loggerName + "] Level string is [" + levelStr + "].");
-
- if (INHERITED == levelStr)
- {
- if (isRoot)
- {
- LogLog.Error(declaringType, "Root level cannot be inherited. Ignoring directive.");
- }
- else
- {
- LogLog.Debug(declaringType, "Logger [" + loggerName + "] level set to inherit from parent.");
- log.Level = null;
- }
- }
- else
- {
- log.Level = log.Hierarchy.LevelMap[levelStr];
- if (log.Level == null)
- {
- LogLog.Error(declaringType, "Undefined level [" + levelStr + "] on Logger [" + loggerName + "].");
- }
- else
- {
- LogLog.Debug(declaringType, "Logger [" + loggerName + "] level set to [name=\"" + log.Level.Name + "\",value=" + log.Level.Value + "].");
- }
- }
- }
+ string levelStr = element.GetAttribute(VALUE_ATTR);
+ LogLog.Debug(declaringType, "Logger [" + loggerName + "] Level string is [" + levelStr + "].");
+
+ if (INHERITED == levelStr)
+ {
+ if (isRoot)
+ {
+ LogLog.Error(declaringType, "Root level cannot be inherited. Ignoring directive.");
+ }
+ else
+ {
+ LogLog.Debug(declaringType, "Logger [" + loggerName + "] level set to inherit from parent.");
+ log.Level = null;
+ }
+ }
+ else
+ {
+ log.Level = log.Hierarchy.LevelMap[levelStr];
+ if (log.Level == null)
+ {
+ LogLog.Error(declaringType, "Undefined level [" + levelStr + "] on Logger [" + loggerName + "].");
+ }
+ else
+ {
+ LogLog.Debug(declaringType, "Logger [" + loggerName + "] level set to [name=\"" + log.Level.Name + "\",value=" + log.Level.Value + "].");
+ }
+ }
+ }
- /// <summary>
- /// Sets a parameter on an object.
- /// </summary>
- /// <param name="element">The parameter element.</param>
- /// <param name="target">The object to set the parameter on.</param>
- /// <remarks>
- /// The parameter name must correspond to a writable property
- /// on the object. The value of the parameter is a string,
- /// therefore this function will attempt to set a string
- /// property first. If unable to set a string property it
- /// will inspect the property and its argument type. It will
- /// attempt to call a static method called <c>Parse</c> on the
- /// type of the property. This method will take a single
- /// string argument and return a value that can be used to
- /// set the property.
- /// </remarks>
- protected void SetParameter(XmlElement element, object target)
- {
- // Get the property name
- string name = element.GetAttribute(NAME_ATTR);
+ /// <summary>
+ /// Sets a parameter on an object.
+ /// </summary>
+ /// <param name="element">The parameter element.</param>
+ /// <param name="target">The object to set the parameter on.</param>
+ /// <remarks>
+ /// The parameter name must correspond to a writable property
+ /// on the object. The value of the parameter is a string,
+ /// therefore this function will attempt to set a string
+ /// property first. If unable to set a string property it
+ /// will inspect the property and its argument type. It will
+ /// attempt to call a static method called <c>Parse</c> on the
+ /// type of the property. This method will take a single
+ /// string argument and return a value that can be used to
+ /// set the property.
+ /// </remarks>
+ protected void SetParameter(XmlElement element, object target)
+ {
+ // Get the property name
+ string name = element.GetAttribute(NAME_ATTR);
- // If the name attribute does not exist then use the name of the element
- if (element.LocalName != PARAM_TAG || name == null || name.Length == 0)
- {
- name = element.LocalName;
- }
+ // If the name attribute does not exist then use the name of the element
+ if (element.LocalName != PARAM_TAG || name == null || name.Length == 0)
+ {
+ name = element.LocalName;
+ }
- // Look for the property on the target object
- Type targetType = target.GetType();
- Type propertyType = null;
+ // Look for the property on the target object
+ Type targetType = target.GetType();
+ Type propertyType = null;
- PropertyInfo propInfo = null;
- MethodInfo methInfo = null;
+ PropertyInfo propInfo = null;
+ MethodInfo methInfo = null;
- // Try to find a writable property
- propInfo = targetType.GetProperty(name, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.IgnoreCase);
- if (propInfo != null && propInfo.CanWrite)
- {
- // found a property
- propertyType = propInfo.PropertyType;
- }
- else
- {
- propInfo = null;
+ // Try to find a writable property
+ propInfo = targetType.GetProperty(name, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.IgnoreCase);
+ if (propInfo != null && propInfo.CanWrite)
+ {
+ // found a property
+ propertyType = propInfo.PropertyType;
+ }
+ else
+ {
+ propInfo = null;
- // look for a method with the signature Add<property>(type)
- methInfo = FindMethodInfo(targetType, name);
+ // look for a method with the signature Add<property>(type)
+ methInfo = FindMethodInfo(targetType, name);
- if (methInfo != null)
- {
- propertyType = methInfo.GetParameters()[0].ParameterType;
- }
- }
+ if (methInfo != null)
+ {
+ propertyType = methInfo.GetParameters()[0].ParameterType;
+ }
+ }
- if (propertyType == null)
- {
- LogLog.Error(declaringType, "XmlHierarchyConfigurator: Cannot find Property [" + name + "] to set object on [" + target.ToString() + "]");
- }
- else
- {
- string propertyValue = null;
+ if (propertyType == null)
+ {
+ LogLog.Error(declaringType, "XmlHierarchyConfigurator: Cannot find Property [" + name + "] to set object on [" + target.ToString() + "]");
+ }
+ else
+ {
+ string propertyValue = null;
- if (element.GetAttributeNode(VALUE_ATTR) != null)
- {
- propertyValue = element.GetAttribute(VALUE_ATTR);
- }
- else if (element.HasChildNodes)
- {
- // Concatenate the CDATA and Text nodes together
- foreach(XmlNode childNode in element.ChildNodes)
- {
- if (childNode.NodeType == XmlNodeType.CDATA || childNode.NodeType == XmlNodeType.Text)
- {
- if (propertyValue == null)
- {
- propertyValue = childNode.InnerText;
- }
- else
- {
- propertyValue += childNode.InnerText;
- }
- }
- }
- }
+ if (element.GetAttributeNode(VALUE_ATTR) != null)
+ {
+ propertyValue = element.GetAttribute(VALUE_ATTR);
+ }
+ else if (element.HasChildNodes)
+ {
+ // Concatenate the CDATA and Text nodes together
+ foreach(XmlNode childNode in element.ChildNodes)
+ {
+ if (childNode.NodeType == XmlNodeType.CDATA || childNode.NodeType == XmlNodeType.Text)
+ {
+ if (propertyValue == null)
+ {
+ propertyValue = childNode.InnerText;
+ }
+ else
+ {
+ propertyValue += childNode.InnerText;
+ }
+ }
+ }
+ }
- if(propertyValue != null)
- {
+ if(propertyValue != null)
+ {
#if !NETCF && !NETSTANDARD1_3 // NETSTANDARD1_3: System.Runtime.InteropServices.RuntimeInformation not available on desktop 4.6
- try
- {
- // Expand environment variables in the string.
- IDictionary environmentVariables = Environment.GetEnvironmentVariables();
- if (HasCaseInsensitiveEnvironment) {
- environmentVariables = CreateCaseInsensitiveWrapper(environmentVariables);
- }
- propertyValue = OptionConverter.SubstituteVariables(propertyValue, environmentVariables);
- }
- catch(System.Security.SecurityException)
- {
- // This security exception will occur if the caller does not have
- // unrestricted environment permission. If this occurs the expansion
- // will be skipped with the following warning message.
- LogLog.Debug(declaringType, "Security exception while trying to expand environment variables. Error Ignored. No Expansion.");
- }
+ try
+ {
+ // Expand environment variables in the string.
+ IDictionary environmentVariables = Environment.GetEnvironmentVariables();
+ if (HasCaseInsensitiveEnvironment) {
+ environmentVariables = CreateCaseInsensitiveWrapper(environmentVariables);
+ }
+ propertyValue = OptionConverter.SubstituteVariables(propertyValue, environmentVariables);
+ }
+ catch(System.Security.SecurityException)
+ {
+ // This security exception will occur if the caller does not have
+ // unrestricted environment permission. If this occurs the expansion
+ // will be skipped with the following warning message.
+ LogLog.Debug(declaringType, "Security exception while trying to expand environment variables. Error Ignored. No Expansion.");
+ }
#endif
- Type parsedObjectConversionTargetType = null;
+ Type parsedObjectConversionTargetType = null;
- // Check if a specific subtype is specified on the element using the 'type' attribute
- string subTypeString = element.GetAttribute(TYPE_ATTR);
- if (subTypeString != null && subTypeString.Length > 0)
- {
- // Read the explicit subtype
- try
- {
+ // Check if a specific subtype is specified on the element using the 'type' attribute
+ string subTypeString = element.GetAttribute(TYPE_ATTR);
+ if (subTypeString != null && subTypeString.Length > 0)
+ {
+ // Read the explicit subtype
+ try
+ {
#if NETSTANDARD1_3
- Type subType = SystemInfo.GetTypeFromString(this.GetType().GetTypeInfo().Assembly, subTypeString, true, true);
+ Type subType = SystemInfo.GetTypeFromString(this.GetType().GetTypeInfo().Assembly, subTypeString, true, true);
#else
- Type subType = SystemInfo.GetTypeFromString(subTypeString, true, true);
+ Type subType = SystemInfo.GetTypeFromString(subTypeString, true, true);
#endif
- LogLog.Debug(declaringType, "Parameter ["+name+"] specified subtype ["+subType.FullName+"]");
+ LogLog.Debug(declaringType, "Parameter ["+name+"] specified subtype ["+subType.FullName+"]");
- if (!propertyType.IsAssignableFrom(subType))
- {
- // Check if there is an appropriate type converter
- if (OptionConverter.CanConvertTypeTo(subType, propertyType))
- {
- // Must re-convert to the real property type
- parsedObjectConversionTargetType = propertyType;
+ if (!propertyType.IsAssignableFrom(subType))
+ {
+ // Check if there is an appropriate type converter
+ if (OptionConverter.CanConvertTypeTo(subType, propertyType))
+ {
+ // Must re-convert to the real property type
+ parsedObjectConversionTargetType = propertyType;
- // Use sub type as intermediary type
- propertyType = subType;
- }
- else
- {
- LogLog.Error(declaringType, "subtype ["+subType.FullName+"] set on ["+name+"] is not a subclass of property type ["+propertyType.FullName+"] and there are no acceptable type conversions.");
- }
- }
- else
- {
- // The subtype specified is found and is actually a subtype of the property
- // type, therefore we can switch to using this type.
- propertyType = subType;
- }
- }
- catch(Exception ex)
- {
- LogLog.Error(declaringType, "Failed to find type ["+subTypeString+"] set on ["+name+"]", ex);
- }
- }
+ // Use sub type as intermediary type
+ propertyType = subType;
+ }
+ else
+ {
+ LogLog.Error(declaringType, "subtype ["+subType.FullName+"] set on ["+name+"] is not a subclass of property type ["+propertyType.FullName+"] and there are no acceptable type conversions.");
+ }
+ }
+ else
+ {
+ // The subtype specified is found and is actually a subtype of the property
+ // type, therefore we can switch to using this type.
+ propertyType = subType;
+ }
+ }
+ catch(Exception ex)
+ {
+ LogLog.Error(declaringType, "Failed to find type ["+subTypeString+"] set on ["+name+"]", ex);
+ }
+ }
- // Now try to convert the string value to an acceptable type
- // to pass to this property.
+ // Now try to convert the string value to an acceptable type
+ // to pass to this property.
- object convertedValue = ConvertStringTo(propertyType, propertyValue);
-
- // Check if we need to do an additional conversion
- if (convertedValue != null && parsedObjectConversionTargetType != null)
- {
- LogLog.Debug(declaringType, "Performing additional conversion of value from [" + convertedValue.GetType().Name + "] to [" + parsedObjectConversionTargetType.Name + "]");
- convertedValue = OptionConverter.ConvertTypeTo(convertedValue, parsedObjectConversionTargetType);
- }
+ object convertedValue = ConvertStringTo(propertyType, propertyValue);
+
+ // Check if we need to do an additional conversion
+ if (convertedValue != null && parsedObjectConversionTargetType != null)
+ {
+ LogLog.Debug(declaringType, "Performing additional conversion of value from [" + convertedValue.GetType().Name + "] to [" + parsedObjectConversionTargetType.Name + "]");
+ convertedValue = OptionConverter.ConvertTypeTo(convertedValue, parsedObjectConversionTargetType);
+ }
- if (convertedValue != null)
- {
- if (propInfo != null)
- {
- // Got a converted result
- LogLog.Debug(declaringType, "Setting Property [" + propInfo.Name + "] to " + convertedValue.GetType().Name + " value [" + convertedValue.ToString() + "]");
+ if (convertedValue != null)
+ {
+ if (propInfo != null)
+ {
+ // Got a converted result
+ LogLog.Debug(declaringType, "Setting Property [" + propInfo.Name + "] to " + convertedValue.GetType().Name + " value [" + convertedValue.ToString() + "]");
- try
- {
- // Pass to the property
+ try
+ {
+ // Pass to the property
#if NETSTANDARD1_3 // TODO BindingFlags is available for netstandard1.5
- propInfo.SetValue(target, convertedValue, null);
+ propInfo.SetValue(target, convertedValue, null);
#else
- propInfo.SetValue(target, convertedValue, BindingFlags.SetProperty, null, null, CultureInfo.InvariantCulture);
+ propInfo.SetValue(target, convertedValue, BindingFlags.SetProperty, null, null, CultureInfo.InvariantCulture);
#endif
- }
- catch(TargetInvocationException targetInvocationEx)
- {
- LogLog.Error(declaringType, "Failed to set parameter [" + propInfo.Name + "] on object [" + target + "] using value [" + convertedValue + "]", targetInvocationEx.InnerException);
- }
- }
- else if (methInfo != null)
- {
- // Got a converted result
- LogLog.Debug(declaringType, "Setting Collection Property [" + methInfo.Name + "] to " + convertedValue.GetType().Name + " value [" + convertedValue.ToString() + "]");
+ }
+ catch(TargetInvocationException targetInvocationEx)
+ {
+ LogLog.Error(declaringType, "Failed to set parameter [" + propInfo.Name + "] on object [" + target + "] using value [" + convertedValue + "]", targetInvocationEx.InnerException);
+ }
+ }
+ else if (methInfo != null)
+ {
+ // Got a converted result
+ LogLog.Debug(declaringType, "Setting Collection Property [" + methInfo.Name + "] to " + convertedValue.GetType().Name + " value [" + convertedValue.ToString() + "]");
- try
- {
- // Pass to the property
+ try
+ {
+ // Pass to the property
#if NETSTANDARD1_3 // TODO BindingFlags is available for netstandard1.5
- methInfo.Invoke(target, new[] { convertedValue });
+ methInfo.Invoke(target, new[] { convertedValue });
#else
- methInfo.Invoke(target, BindingFlags.InvokeMethod, null, new object[] {convertedValue}, CultureInfo.InvariantCulture);
+ methInfo.Invoke(target, BindingFlags.InvokeMethod, null, new object[] {convertedValue}, CultureInfo.InvariantCulture);
#endif
- }
- catch(TargetInvocationException targetInvocationEx)
- {
- LogLog.Error(declaringType, "Failed to set parameter [" + name + "] on object [" + target + "] using value [" + convertedValue + "]", targetInvocationEx.InnerException);
- }
- }
- }
- else
- {
- LogLog.Warn(declaringType, "Unable to set property [" + name + "] on object [" + target + "] using value [" + propertyValue + "] (with acceptable conversion types)");
- }
- }
- else
- {
- object createdObject = null;
+ }
+ catch(TargetInvocationException targetInvocationEx)
+ {
+ LogLog.Error(declaringType, "Failed to set parameter [" + name + "] on object [" + target + "] using value [" + convertedValue + "]", targetInvocationEx.InnerException);
+ }
+ }
+ }
+ else
+ {
+ LogLog.Warn(declaringType, "Unable to set property [" + name + "] on object [" + target + "] using value [" + propertyValue + "] (with acceptable conversion types)");
+ }
+ }
+ else
+ {
+ object createdObject = null;
- if (propertyType == typeof(string) && !HasAttributesOrElements(element))
- {
- // If the property is a string and the element is empty (no attributes
- // or child elements) then we special case the object value to an empty string.
- // This is necessary because while the String is a class it does not have
- // a default constructor that creates an empty string, which is the behavior
- // we are trying to simulate and would be expected from CreateObjectFromXml
- createdObject = "";
- }
- else
- {
- // No value specified
- Type defaultObjectType = null;
- if (IsTypeConstructible(propertyType))
- {
- defaultObjectType = propertyType;
- }
+ if (propertyType == typeof(string) && !HasAttributesOrElements(element))
+ {
+ // If the property is a string and the element is empty (no attributes
+ // or child elements) then we special case the object value to an empty string.
+ // This is necessary because while the String is a class it does not have
+ // a default constructor that creates an empty string, which is the behavior
+ // we are trying to simulate and would be expected from CreateObjectFromXml
+ createdObject = "";
+ }
+ else
+ {
+ // No value specified
+ Type defaultObjectType = null;
+ if (IsTypeConstructible(propertyType))
+ {
+ defaultObjectType = propertyType;
+ }
- createdObject = CreateObjectFromXml(element, defaultObjectType, propertyType);
- }
+ createdObject = CreateObjectFromXml(element, defaultObjectType, propertyType);
+ }
- if (createdObject == null)
- {
- LogLog.Error(declaringType, "Failed to create object to set param: "+name);
- }
- else
- {
- if (propInfo != null)
- {
- // Got a converted result
- LogLog.Debug(declaringType, "Setting Property ["+ propInfo.Name +"] to object ["+ createdObject +"]");
+ if (createdObject == null)
+ {
+ LogLog.Error(declaringType, "Failed to create object to set param: "+name);
+ }
+ else
+ {
+ if (propInfo != null)
+ {
+ // Got a converted result
+ LogLog.Debug(declaringType, "Setting Property ["+ propInfo.Name +"] to object ["+ createdObject +"]");
- try
- {
- // Pass to the property
+ try
+ {
+ // Pass to the property
#if NETSTANDARD1_3 // TODO BindingFlags is available for netstandard1.5
- propInfo.SetValue(target, createdObject, null);
+ propInfo.SetValue(target, createdObject, null);
#else
- propInfo.SetValue(target, createdObject, BindingFlags.SetProperty, null, null, CultureInfo.InvariantCulture);
+ propInfo.SetValue(target, createdObject, BindingFlags.SetProperty, null, null, CultureInfo.InvariantCulture);
#endif
- }
- catch(TargetInvocationException targetInvocationEx)
- {
- LogLog.Error(declaringType, "Failed to set parameter [" + propInfo.Name + "] on object [" + target + "] using value [" + createdObject + "]", targetInvocationEx.InnerException);
- }
- }
- else if (methInfo != null)
- {
- // Got a converted result
- LogLog.Debug(declaringType, "Setting Collection Property ["+ methInfo.Name +"] to object ["+ createdObject +"]");
+ }
+ catch(TargetInvocationException targetInvocationEx)
+ {
+ LogLog.Error(declaringType, "Failed to set parameter [" + propInfo.Name + "] on object [" + target + "] using value [" + createdObject + "]", targetInvocationEx.InnerException);
+ }
+ }
+ else if (methInfo != null)
+ {
+ // Got a converted result
+ LogLog.Debug(declaringType, "Setting Collection Property ["+ methInfo.Name +"] to object ["+ createdObject +"]");
- try
- {
- // Pass to the property
+ try
+ {
+ // Pass to the property
#if NETSTANDARD1_3 // TODO BindingFlags is available for netstandard1.5
- methInfo.Invoke(target, new[] { createdObject });
+ methInfo.Invoke(target, new[] { createdObject });
#else
- methInfo.Invoke(target, BindingFlags.InvokeMethod, null, new object[] {createdObject}, CultureInfo.InvariantCulture);
+ methInfo.Invoke(target, BindingFlags.InvokeMethod, null, new object[] {createdObject}, CultureInfo.InvariantCulture);
#endif
- }
- catch(TargetInvocationException targetInvocationEx)
- {
- LogLog.Error(declaringType, "Failed to set parameter [" + methInfo.Name + "] on object [" + target + "] using value [" + createdObject + "]", targetInvocationEx.InnerException);
- }
- }
- }
- }
- }
- }
+ }
+ catch(TargetInvocationException targetInvocationEx)
+ {
+ LogLog.Error(declaringType, "Failed to set parameter [" + methInfo.Name + "] on object [" + target + "] using value [" + createdObject + "]", targetInvocationEx.InnerException);
+ }
+ }
+ }
+ }
+ }
+ }
- /// <summary>
- /// Test if an element has no attributes or child elements
- /// </summary>
- /// <param name="element">the element to inspect</param>
- /// <returns><c>true</c> if the element has any attributes or child elements, <c>false</c> otherwise</returns>
- private bool HasAttributesOrElements(XmlElement element)
- {
- foreach(XmlNode node in element.ChildNodes)
- {
- if (node.NodeType == XmlNodeType.Attribute || node.NodeType == XmlNodeType.Element)
- {
- return true;
- }
- }
- return false;
- }
+ /// <summary>
+ /// Test if an element has no attributes or child elements
+ /// </summary>
+ /// <param name="element">the element to inspect</param>
+ /// <returns><c>true</c> if the element has any attributes or child elements, <c>false</c> otherwise</returns>
+ private bool HasAttributesOrElements(XmlElement element)
+ {
+ foreach(XmlNode node in element.ChildNodes)
+ {
+ if (node.NodeType == XmlNodeType.Attribute || node.NodeType == XmlNodeType.Element)
+ {
+ return true;
+ }
+ }
+ return false;
+ }
- /// <summary>
- /// Test if a <see cref="Type"/> is constructible with <c>Activator.CreateInstance</c>.
- /// </summary>
- /// <param name="type">the type to inspect</param>
- /// <returns><c>true</c> if the type is creatable using a default constructor, <c>false</c> otherwise</returns>
- private static bool IsTypeConstructible(Type type)
- {
+ /// <summary>
+ /// Test if a <see cref="Type"/> is constructible with <c>Activator.CreateInstance</c>.
+ /// </summary>
+ /// <param name="type">the type to inspect</param>
+ /// <returns><c>true</c> if the type is creatable using a default constructor, <c>false</c> otherwise</returns>
+ private static bool IsTypeConstructible(Type type)
+ {
#if NETSTANDARD1_3
- TypeInfo typeInfo = type.GetTypeInfo();
- if (typeInfo.IsClass && !typeInfo.IsAbstract)
+ TypeInfo typeInfo = type.GetTypeInfo();
+ if (typeInfo.IsClass && !typeInfo.IsAbstract)
#else
- if (type.IsClass && !type.IsAbstract)
+ if (type.IsClass && !type.IsAbstract)
#endif
- {
- ConstructorInfo defaultConstructor = type.GetConstructor(new Type[0]);
- if (defaultConstructor != null && !defaultConstructor.IsAbstract && !defaultConstructor.IsPrivate)
- {
- return true;
- }
- }
- return false;
- }
+ {
+ ConstructorInfo defaultConstructor = type.GetConstructor(new Type[0]);
+ if (defaultConstructor != null && !defaultConstructor.IsAbstract && !defaultConstructor.IsPrivate)
+ {
+ return true;
+ }
+ }
+ return false;
+ }
- /// <summary>
- /// Look for a method on the <paramref name="targetType"/> that matches the <paramref name="name"/> supplied
- /// </summary>
- /// <param name="targetType">the type that has the method</param>
- /// <param name="name">the name of the method</param>
- /// <returns>the method info found</returns>
- /// <remarks>
- /// <para>
- /// The method must be a public instance method on the <paramref name="targetType"/>.
- /// The method must be named <paramref name="name"/> or "Add" followed by <paramref name="name"/>.
- /// The method must take a single parameter.
- /// </para>
- /// </remarks>
- private MethodInfo FindMethodInfo(Type targetType, string name)
- {
- string requiredMethodNameA = name;
- string requiredMethodNameB = "Add" + name;
+ /// <summary>
+ /// Look for a method on the <paramref name="targetType"/> that matches the <paramref name="name"/> supplied
+ /// </summary>
+ /// <param name="targetType">the type that has the method</param>
+ /// <param name="name">the name of the method</param>
+ /// <returns>the method info found</returns>
+ /// <remarks>
+ /// <para>
+ /// The method must be a public instance method on the <paramref name="targetType"/>.
+ /// The method must be named <paramref name="name"/> or "Add" followed by <paramref name="name"/>.
+ /// The method must take a single parameter.
+ /// </para>
+ /// </remarks>
+ private MethodInfo FindMethodInfo(Type targetType, string name)
+ {
+ string requiredMethodNameA = name;
+ string requiredMethodNameB = "Add" + name;
- MethodInfo[] methods = targetType.GetMethods(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
+ MethodInfo[] methods = targetType.GetMethods(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
- foreach(MethodInfo methInfo in methods)
- {
- if (!methInfo.IsStatic)
- {
- string methodInfoName = methInfo.Name;
+ foreach(MethodInfo methInfo in methods)
+ {
+ if (!methInfo.IsStatic)
+ {
+ string methodInfoName = methInfo.Name;
- if (SystemInfo.EqualsIgnoringCase(methodInfoName, requiredMethodNameA) ||
- SystemInfo.EqualsIgnoringCase(methodInfoName, requiredMethodNameB))
- {
- // Found matching method name
+ if (SystemInfo.EqualsIgnoringCase(methodInfoName, requiredMethodNameA) ||
+ SystemInfo.EqualsIgnoringCase(methodInfoName, requiredMethodNameB))
+ {
+ // Found matching method name
- // Look for version with one arg only
- System.Reflection.ParameterInfo[] methParams = methInfo.GetParameters();
- if (methParams.Length == 1)
- {
- return methInfo;
- }
- }
- }
- }
- return null;
- }
+ // Look for version with one arg only
+ System.Reflection.ParameterInfo[] methParams = methInfo.GetParameters();
+ if (methParams.Length == 1)
+ {
+ return methInfo;
+ }
+ }
+ }
+ }
+ return null;
+ }
- /// <summary>
- /// Converts a string value to a target type.
- /// </summary>
- /// <param name="type">The type of object to convert the string to.</param>
- /// <param name="value">The string value to use as the value of the object.</param>
- /// <returns>
- /// <para>
- /// An object of type <paramref name="type"/> with value <paramref name="value"/> or
- /// <c>null</c> when the conversion could not be performed.
- /// </para>
- /// </returns>
- protected object ConvertStringTo(Type type, string value)
- {
- // Hack to allow use of Level in property
- if (typeof(Level) == type)
- {
- // Property wants a level
- Level levelValue = m_hierarchy.LevelMap[value];
+ /// <summary>
+ /// Converts a string value to a target type.
+ /// </summary>
+ /// <param name="type">The type of object to convert the string to.</param>
+ /// <param name="value">The string value to use as the value of the object.</param>
+ /// <returns>
+ /// <para>
+ /// An object of type <paramref name="type"/> with value <paramref name="value"/> or
+ /// <c>null</c> when the conversion could not be performed.
+ /// </para>
+ /// </returns>
+ protected object ConvertStringTo(Type type, string value)
+ {
+ // Hack to allow use of Level in property
+ if (typeof(Level) == type)
+ {
+ // Property wants a level
+ Level levelValue = m_hierarchy.LevelMap[value];
- if (levelValue == null)
- {
- LogLog.Error(declaringType, "XmlHierarchyConfigurator: Unknown Level Specified ["+ value +"]");
- }
+ if (levelValue == null)
+ {
+ LogLog.Error(declaringType, "XmlHierarchyConfigurator: Unknown Level Specified ["+ value +"]");
+ }
- return levelValue;
- }
- return OptionConverter.ConvertStringTo(type, value);
- }
+ return levelValue;
+ }
+ return OptionConverter.ConvertStringTo(type, value);
+ }
- /// <summary>
- /// Creates an object as specified in XML.
- /// </summary>
- /// <param name="element">The XML element that contains the definition of the object.</param>
- /// <param name="defaultTargetType">The object type to use if not explicitly specified.</param>
- /// <param name="typeConstraint">The type that the returned object must be or must inherit from.</param>
- /// <returns>The object or <c>null</c></returns>
- /// <remarks>
- /// <para>
- /// Parse an XML element and create an object instance based on the configuration
- /// data.
- /// </para>
- /// <para>
- /// The type of the instance may be specified in the XML. If not
- /// specified then the <paramref name="defaultTargetType"/> is used
- /// as the type. However the type is specified it must support the
- /// <paramref name="typeConstraint"/> type.
- /// </para>
- /// </remarks>
- protected object CreateObjectFromXml(XmlElement element, Type defaultTargetType, Type typeConstraint)
- {
- Type objectType = null;
+ /// <summary>
+ /// Creates an object as specified in XML.
+ /// </summary>
+ /// <param name="element">The XML element that contains the definition of the object.</param>
+ /// <param name="defaultTargetType">The object type to use if not explicitly specified.</param>
+ /// <param name="typeConstraint">The type that the returned object must be or must inherit from.</param>
+ /// <returns>The object or <c>null</c></returns>
+ /// <remarks>
+ /// <para>
+ /// Parse an XML element and create an object instance based on the configuration
+ /// data.
+ /// </para>
+ /// <para>
+ /// The type of the instance may be specified in the XML. If not
+ /// specified then the <paramref name="defaultTargetType"/> is used
+ /// as the type. However the type is specified it must support the
+ /// <paramref name="typeConstraint"/> type.
+ /// </para>
+ /// </remarks>
+ protected object CreateObjectFromXml(XmlElement element, Type defaultTargetType, Type typeConstraint)
+ {
+ Type objectType = null;
- // Get the object type
- string objectTypeString = element.GetAttribute(TYPE_ATTR);
- if (objectTypeString == null || objectTypeString.Length == 0)
- {
- if (defaultTargetType == null)
- {
- LogLog.Error(declaringType, "Object type not specified. Cannot create object of type ["+typeConstraint.FullName+"]. Missing Value or Type.");
- return null;
- }
- else
- {
- // Use the default object type
- objectType = defaultTargetType;
- }
- }
- else
- {
- // Read the explicit object type
- try
- {
+ // Get the object type
+ string objectTypeString = element.GetAttribute(TYPE_ATTR);
+ if (objectTypeString == null || objectTypeString.Length == 0)
+ {
+ if (defaultTargetType == null)
+ {
+ LogLog.Error(declaringType, "Object type not specified. Cannot create object of type ["+typeConstraint.FullName+"]. Missing Value or Type.");
+ return null;
+ }
+ else
+ {
+ // Use the default object type
+ objectType = defaultTargetType;
+ }
+ }
+ else
+ {
+ // Read the explicit object type
+ try
+ {
#if NETSTANDARD1_3
- objectType = SystemInfo.GetTypeFromString(this.GetType().GetTypeInfo().Assembly, objectTypeString, true, true);
+ objectType = SystemInfo.GetTypeFromString(this.GetType().GetTypeInfo().Assembly, objectTypeString, true, true);
#else
- objectType = SystemInfo.GetTypeFromString(objectTypeString, true, true);
+ objectType = SystemInfo.GetTypeFromString(objectTypeString, true, true);
#endif
- }
- catch(Exception ex)
- {
- LogLog.Error(declaringType, "Failed to find type ["+objectTypeString+"]", ex);
- return null;
- }
- }
+ }
+ catch(Exception ex)
+ {
+ LogLog.Error(declaringType, "Failed to find type ["+objectTypeString+"]", ex);
+ return null;
+ }
+ }
- bool requiresConversion = false;
+ bool requiresConversion = false;
- // Got the object type. Check that it meets the typeConstraint
- if (typeConstraint != null)
- {
- if (!typeConstraint.IsAssignableFrom(objectType))
- {
- // Check if there is an appropriate type converter
- if (OptionConverter.CanConvertTypeTo(objectType, typeConstraint))
- {
- requiresConversion = true;
- }
- else
- {
- LogLog.Error(declaringType, "Object type ["+objectType.FullName+"] is not assignable to type ["+typeConstraint.FullName+"]. There are no acceptable type conversions.");
- return null;
- }
- }
- }
+ // Got the object type. Check that it meets the typeConstraint
+ if (typeConstraint != null)
+ {
+ if (!typeConstraint.IsAssignableFrom(objectType))
+ {
+ // Check if there is an appropriate type converter
+ if (OptionConverter.CanConvertTypeTo(objectType, typeConstraint))
+ {
+ requiresConversion = true;
+ }
+ else
+ {
+ LogLog.Error(declaringType, "Object type ["+objectType.FullName+"] is not assignable to type ["+typeConstraint.FullName+"]. There are no acceptable type conversions.");
+ return null;
+ }
+ }
+ }
- // Create using the default constructor
- object createdObject = null;
- try
- {
- createdObject = Activator.CreateInstance(objectType);
- }
- catch(Exception createInstanceEx)
- {
- LogLog.Error(declaringType, "XmlHierarchyConfigurator: Failed to construct object of type [" + objectType.FullName + "] Exception: "+createInstanceEx.ToString());
- }
+ // Create using the default constructor
+ object createdObject = null;
+ try
+ {
+ createdObject = Activator.CreateInstance(objectType);
+ }
+ catch(Exception createInstanceEx)
+ {
+ LogLog.Error(declaringType, "XmlHierarchyConfigurator: Failed to construct object of type [" + objectType.FullName + "] Exception: "+createInstanceEx.ToString());
+ }
- // Set any params on object
- foreach (XmlNode currentNode in element.ChildNodes)
- {
- if (currentNode.NodeType == XmlNodeType.Element)
- {
- SetParameter((XmlElement)currentNode, createdObject);
- }
- }
+ // Set any params on object
+ foreach (XmlNode currentNode in element.ChildNodes)
+ {
+ if (currentNode.NodeType == XmlNodeType.Element)
+ {
+ SetParameter((XmlElement)currentNode, createdObject);
+ }
+ }
- // Check if we need to call ActivateOptions
- IOptionHandler optionHandler = createdObject as IOptionHandler;
- if (optionHandler != null)
- {
- optionHandler.ActivateOptions();
- }
+ // Check if we need to call ActivateOptions
+ IOptionHandler optionHandler = createdObject as IOptionHandler;
+ if (optionHandler != null)
+ {
+ optionHandler.ActivateOptions();
+ }
- // Ok object should be initialized
+ // Ok object should be initialized
- if (requiresConversion)
- {
- // Convert the object type
- return OptionConverter.ConvertTypeTo(createdObject, typeConstraint);
- }
- else
- {
- // The object is of the correct type
- return createdObject;
- }
- }
+ if (requiresConversion)
+ {
+ // Convert the object type
+ return OptionConverter.ConvertTypeTo(createdObject, typeConstraint);
+ }
+ else
+ {
+ // The object is of the correct type
+ return createdObject;
+ }
+ }
- #endregion Protected Instance Methods
+ #endregion Protected Instance Methods
#if !NETCF && !NETSTANDARD1_3 // NETSTANDARD1_3: System.Runtime.InteropServices.RuntimeInformation not available on desktop 4.6
- private bool HasCaseInsensitiveEnvironment
- {
- get
- {
+ private bool HasCaseInsensitiveEnvironment
+ {
+ get
+ {
#if NET_1_0 || NET_1_1 || CLI_1_0
- // actually there is no guarantee, but we don't know better
- return true;
+ // actually there is no guarantee, but we don't know better
+ return true;
#elif MONO_1_0
- // see above
- return false;
+ // see above
+ return false;
#else
- PlatformID platform = Environment.OSVersion.Platform;
- return platform != PlatformID.Unix && platform != PlatformID.MacOSX;
+ PlatformID platform = Environment.OSVersion.Platform;
+ return platform != PlatformID.Unix && platform != PlatformID.MacOSX;
#endif
- }
- }
+ }
+ }
- private IDictionary CreateCaseInsensitiveWrapper(IDictionary dict)
- {
- if (dict == null)
- {
- return dict;
- }
- Hashtable hash = SystemInfo.CreateCaseInsensitiveHashtable();
- foreach (DictionaryEntry entry in dict) {
- hash[entry.Key] = entry.Value;
- }
- return hash;
- }
+ private IDictionary CreateCaseInsensitiveWrapper(IDictionary dict)
+ {
+ if (dict == null)
+ {
+ return dict;
+ }
+ Hashtable hash = SystemInfo.CreateCaseInsensitiveHashtable();
+ foreach (DictionaryEntry entry in dict) {
+ hash[entry.Key] = entry.Value;
+ }
+ return hash;
+ }
#endif
- #region Private Constants
+ #region Private Constants
- // String constants used while parsing the XML data
- private const string CONFIGURATION_TAG = "log4net";
- private const string RENDERER_TAG = "renderer";
- private const string APPENDER_TAG = "appender";
- private const string APPENDER_REF_TAG = "appender-ref";
- private const string PARAM_TAG = "param";
+ // String constants used while parsing the XML data
+ private const string CONFIGURATION_TAG = "log4net";
+ private const string RENDERER_TAG = "renderer";
+ private const string APPENDER_TAG = "appender";
+ private const string APPENDER_REF_TAG = "appender-ref";
+ private const string PARAM_TAG = "param";
- // TODO: Deprecate use of category tags
- private const string CATEGORY_TAG = "category";
- // TODO: Deprecate use of priority tag
- private const string PRIORITY_TAG = "priority";
+ // TODO: Deprecate use of category tags
+ private const string CATEGORY_TAG = "category";
+ // TODO: Deprecate use of priority tag
+ private const string PRIORITY_TAG = "priority";
- private const string LOGGER_TAG = "logger";
- private const string NAME_ATTR = "name";
- private const string TYPE_ATTR = "type";
- private const string VALUE_ATTR = "value";
- private const string ROOT_TAG = "root";
- private const string LEVEL_TAG = "level";
- private const string REF_ATTR = "ref";
- private const string ADDITIVITY_ATTR = "additivity";
- private const string THRESHOLD_ATTR = "threshold";
- private const string CONFIG_DEBUG_ATTR = "configDebug";
- private const string INTERNAL_DEBUG_ATTR = "debug";
- private const string EMIT_INTERNAL_DEBUG_ATTR = "emitDebug";
- private const string CONFIG_UPDATE_MODE_ATTR = "update";
- private const string RENDERING_TYPE_ATTR = "renderingClass";
- private const string RENDERED_TYPE_ATTR = "renderedClass";
+ private const string LOGGER_TAG = "logger";
+ private const string NAME_ATTR = "name";
+ private const string TYPE_ATTR = "type";
+ private const string VALUE_ATTR = "value";
+ private const string ROOT_TAG = "root";
+ private const string LEVEL_TAG = "level";
+ private const string REF_ATTR = "ref";
+ private const string ADDITIVITY_ATTR = "additivity";
+ private const string THRESHOLD_ATTR = "threshold";
+ private const string CONFIG_DEBUG_ATTR = "configDebug";
+ private const string INTERNAL_DEBUG_ATTR = "debug";
+ private const string EMIT_INTERNAL_DEBUG_ATTR = "emitDebug";
+ private const string CONFIG_UPDATE_MODE_ATTR = "update";
+ private const string RENDERING_TYPE_ATTR = "renderingClass";
+ private const string RENDERED_TYPE_ATTR = "renderedClass";
- // flag used on the level element
- private const string INHERITED = "inherited";
+ // flag used on the level element
+ private const string INHERITED = "inherited";
- #endregion Private Constants
+ #endregion Private Constants
- #region Private Instance Fields
+ #region Private Instance Fields
- /// <summary>
- /// key: appenderName, value: appender.
- /// </summary>
- private Hashtable m_appenderBag;
+ /// <summary>
+ /// key: appenderName, value: appender.
+ /// </summary>
+ private Hashtable m_appenderBag;
- /// <summary>
- /// The Hierarchy being configured.
- /// </summary>
- private readonly Hierarchy m_hierarchy;
+ /// <summary>
+ /// The Hierarchy being configured.
+ /// </summary>
+ private readonly Hierarchy m_hierarchy;
- #endregion Private Instance Fields
+ #endregion Private Instance Fields
- #region Private Static Fields
+ #region Private Static Fields
- /// <summary>
- /// The fully qualified type of the XmlHierarchyConfigurator class.
- /// </summary>
- /// <remarks>
- /// Used by the internal logger to record the Type of the
- /// log message.
- /// </remarks>
- private static readonly Type declaringType = typeof(XmlHierarchyConfigurator);
+ /// <summary>
+ /// The fully qualified type of the XmlHierarchyConfigurator class.
+ /// </summary>
+ /// <remarks>
+ /// Used by the internal logger to record the Type of the
+ /// log message.
+ /// </remarks>
+ private static readonly Type declaringType = typeof(XmlHierarchyConfigurator);
- #endregion Private Static Fields
- }
+ #endregion Private Static Fields
+ }
}
diff --git a/src/log4net/Repository/IBasicRepositoryConfigurator.cs b/src/log4net/Repository/IBasicRepositoryConfigurator.cs
index 7fdbb70..b6196f7 100644
--- a/src/log4net/Repository/IBasicRepositoryConfigurator.cs
+++ b/src/log4net/Repository/IBasicRepositoryConfigurator.cs
@@ -19,33 +19,33 @@
namespace log4net.Repository
{
- /// <summary>
- /// Basic Configurator interface for repositories
- /// </summary>
- /// <remarks>
- /// <para>
- /// Interface used by basic configurator to configure a <see cref="ILoggerRepository"/>
- /// with a default <see cref="log4net.Appender.IAppender"/>.
- /// </para>
- /// <para>
- /// A <see cref="ILoggerRepository"/> should implement this interface to support
- /// configuration by the <see cref="log4net.Config.BasicConfigurator"/>.
- /// </para>
- /// </remarks>
- /// <author>Nicko Cadell</author>
- /// <author>Gert Driesen</author>
- public interface IBasicRepositoryConfigurator
- {
- /// <summary>
- /// Initialize the repository using the specified appender
- /// </summary>
- /// <param name="appender">the appender to use to log all logging events</param>
- /// <remarks>
- /// <para>
- /// Configure the repository to route all logging events to the
- /// specified appender.
- /// </para>
- /// </remarks>
+ /// <summary>
+ /// Basic Configurator interface for repositories
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Interface used by basic configurator to configure a <see cref="ILoggerRepository"/>
+ /// with a default <see cref="log4net.Appender.IAppender"/>.
+ /// </para>
+ /// <para>
+ /// A <see cref="ILoggerRepository"/> should implement this interface to support
+ /// configuration by the <see cref="log4net.Config.BasicConfigurator"/>.
+ /// </para>
+ /// </remarks>
+ /// <author>Nicko Cadell</author>
+ /// <author>Gert Driesen</author>
+ public interface IBasicRepositoryConfigurator
+ {
+ /// <summary>
+ /// Initialize the repository using the specified appender
+ /// </summary>
+ /// <param name="appender">the appender to use to log all logging events</param>
+ /// <remarks>
+ /// <para>
+ /// Configure the repository to route all logging events to the
+ /// specified appender.
+ /// </para>
+ /// </remarks>
void Configure(Appender.IAppender appender);
/// <summary>
@@ -59,5 +59,5 @@
/// </para>
/// </remarks>
void Configure(params Appender.IAppender[] appenders);
- }
+ }
}
diff --git a/src/log4net/Repository/ILoggerRepository.cs b/src/log4net/Repository/ILoggerRepository.cs
index 30ef5b3..9ea0fd4 100644
--- a/src/log4net/Repository/ILoggerRepository.cs
+++ b/src/log4net/Repository/ILoggerRepository.cs
@@ -28,253 +28,253 @@
namespace log4net.Repository
{
- #region LoggerRepositoryShutdownEvent
+ #region LoggerRepositoryShutdownEvent
- /// <summary>
- /// Delegate used to handle logger repository shutdown event notifications
- /// </summary>
- /// <param name="sender">The <see cref="ILoggerRepository"/> that is shutting down.</param>
- /// <param name="e">Empty event args</param>
- /// <remarks>
- /// <para>
- /// Delegate used to handle logger repository shutdown event notifications.
- /// </para>
- /// </remarks>
- public delegate void LoggerRepositoryShutdownEventHandler(object sender, EventArgs e);
+ /// <summary>
+ /// Delegate used to handle logger repository shutdown event notifications
+ /// </summary>
+ /// <param name="sender">The <see cref="ILoggerRepository"/> that is shutting down.</param>
+ /// <param name="e">Empty event args</param>
+ /// <remarks>
+ /// <para>
+ /// Delegate used to handle logger repository shutdown event notifications.
+ /// </para>
+ /// </remarks>
+ public delegate void LoggerRepositoryShutdownEventHandler(object sender, EventArgs e);
- #endregion
+ #endregion
- #region LoggerRepositoryConfigurationResetEventHandler
+ #region LoggerRepositoryConfigurationResetEventHandler
- /// <summary>
- /// Delegate used to handle logger repository configuration reset event notifications
- /// </summary>
- /// <param name="sender">The <see cref="ILoggerRepository"/> that has had its configuration reset.</param>
- /// <param name="e">Empty event args</param>
- /// <remarks>
- /// <para>
- /// Delegate used to handle logger repository configuration reset event notifications.
- /// </para>
- /// </remarks>
- public delegate void LoggerRepositoryConfigurationResetEventHandler(object sender, EventArgs e);
+ /// <summary>
+ /// Delegate used to handle logger repository configuration reset event notifications
+ /// </summary>
+ /// <param name="sender">The <see cref="ILoggerRepository"/> that has had its configuration reset.</param>
+ /// <param name="e">Empty event args</param>
+ /// <remarks>
+ /// <para>
+ /// Delegate used to handle logger repository configuration reset event notifications.
+ /// </para>
+ /// </remarks>
+ public delegate void LoggerRepositoryConfigurationResetEventHandler(object sender, EventArgs e);
- #endregion
+ #endregion
- #region LoggerRepositoryConfigurationChangedEventHandler
+ #region LoggerRepositoryConfigurationChangedEventHandler
- /// <summary>
- /// Delegate used to handle event notifications for logger repository configuration changes.
- /// </summary>
- /// <param name="sender">The <see cref="ILoggerRepository"/> that has had its configuration changed.</param>
- /// <param name="e">Empty event arguments.</param>
- /// <remarks>
- /// <para>
- /// Delegate used to handle event notifications for logger repository configuration changes.
- /// </para>
- /// </remarks>
- public delegate void LoggerRepositoryConfigurationChangedEventHandler(object sender, EventArgs e);
+ /// <summary>
+ /// Delegate used to handle event notifications for logger repository configuration changes.
+ /// </summary>
+ /// <param name="sender">The <see cref="ILoggerRepository"/> that has had its configuration changed.</param>
+ /// <param name="e">Empty event arguments.</param>
+ /// <remarks>
+ /// <para>
+ /// Delegate used to handle event notifications for logger repository configuration changes.
+ /// </para>
+ /// </remarks>
+ public delegate void LoggerRepositoryConfigurationChangedEventHandler(object sender, EventArgs e);
#endregion
-
- /// <summary>
- /// Interface implemented by logger repositories.
- /// </summary>
- /// <remarks>
- /// <para>
- /// This interface is implemented by logger repositories. e.g.
- /// <see cref="Hierarchy"/>.
- /// </para>
- /// <para>
- /// This interface is used by the <see cref="LogManager"/>
- /// to obtain <see cref="ILog"/> interfaces.
- /// </para>
- /// </remarks>
- /// <author>Nicko Cadell</author>
- /// <author>Gert Driesen</author>
- public interface ILoggerRepository
- {
- /// <summary>
- /// The name of the repository
- /// </summary>
- /// <value>
- /// The name of the repository
- /// </value>
- /// <remarks>
- /// <para>
- /// The name of the repository.
- /// </para>
- /// </remarks>
- string Name { get; set; }
+
+ /// <summary>
+ /// Interface implemented by logger repositories.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// This interface is implemented by logger repositories. e.g.
+ /// <see cref="Hierarchy"/>.
+ /// </para>
+ /// <para>
+ /// This interface is used by the <see cref="LogManager"/>
+ /// to obtain <see cref="ILog"/> interfaces.
+ /// </para>
+ /// </remarks>
+ /// <author>Nicko Cadell</author>
+ /// <author>Gert Driesen</author>
+ public interface ILoggerRepository
+ {
+ /// <summary>
+ /// The name of the repository
+ /// </summary>
+ /// <value>
+ /// The name of the repository
+ /// </value>
+ /// <remarks>
+ /// <para>
+ /// The name of the repository.
+ /// </para>
+ /// </remarks>
+ string Name { get; set; }
- /// <summary>
- /// RendererMap accesses the object renderer map for this repository.
- /// </summary>
- /// <value>
- /// RendererMap accesses the object renderer map for this repository.
- /// </value>
- /// <remarks>
- /// <para>
- /// RendererMap accesses the object renderer map for this repository.
- /// </para>
- /// <para>
- /// The RendererMap holds a mapping between types and
- /// <see cref="IObjectRenderer"/> objects.
- /// </para>
- /// </remarks>
- RendererMap RendererMap { get; }
+ /// <summary>
+ /// RendererMap accesses the object renderer map for this repository.
+ /// </summary>
+ /// <value>
+ /// RendererMap accesses the object renderer map for this repository.
+ /// </value>
+ /// <remarks>
+ /// <para>
+ /// RendererMap accesses the object renderer map for this repository.
+ /// </para>
+ /// <para>
+ /// The RendererMap holds a mapping between types and
+ /// <see cref="IObjectRenderer"/> objects.
+ /// </para>
+ /// </remarks>
+ RendererMap RendererMap { get; }
- /// <summary>
- /// The plugin map for this repository.
- /// </summary>
- /// <value>
- /// The plugin map for this repository.
- /// </value>
- /// <remarks>
- /// <para>
- /// The plugin map holds the <see cref="IPlugin"/> instances
- /// that have been attached to this repository.
- /// </para>
- /// </remarks>
- PluginMap PluginMap { get; }
+ /// <summary>
+ /// The plugin map for this repository.
+ /// </summary>
+ /// <value>
+ /// The plugin map for this repository.
+ /// </value>
+ /// <remarks>
+ /// <para>
+ /// The plugin map holds the <see cref="IPlugin"/> instances
+ /// that have been attached to this repository.
+ /// </para>
+ /// </remarks>
+ PluginMap PluginMap { get; }
- /// <summary>
- /// Get the level map for the Repository.
- /// </summary>
- /// <remarks>
- /// <para>
- /// Get the level map for the Repository.
- /// </para>
- /// <para>
- /// The level map defines the mappings between
- /// level names and <see cref="Level"/> objects in
- /// this repository.
- /// </para>
- /// </remarks>
- LevelMap LevelMap { get; }
+ /// <summary>
+ /// Get the level map for the Repository.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Get the level map for the Repository.
+ /// </para>
+ /// <para>
+ /// The level map defines the mappings between
+ /// level names and <see cref="Level"/> objects in
+ /// this repository.
+ /// </para>
+ /// </remarks>
+ LevelMap LevelMap { get; }
- /// <summary>
- /// The threshold for all events in this repository
- /// </summary>
- /// <value>
- /// The threshold for all events in this repository
- /// </value>
- /// <remarks>
- /// <para>
- /// The threshold for all events in this repository.
- /// </para>
- /// </remarks>
- Level Threshold { get; set; }
+ /// <summary>
+ /// The threshold for all events in this repository
+ /// </summary>
+ /// <value>
+ /// The threshold for all events in this repository
+ /// </value>
+ /// <remarks>
+ /// <para>
+ /// The threshold for all events in this repository.
+ /// </para>
+ /// </remarks>
+ Level Threshold { get; set; }
- /// <summary>
- /// Check if the named logger exists in the repository. If so return
- /// its reference, otherwise returns <c>null</c>.
- /// </summary>
- /// <param name="name">The name of the logger to lookup</param>
- /// <returns>The Logger object with the name specified</returns>
- /// <remarks>
- /// <para>
- /// If the names logger exists it is returned, otherwise
- /// <c>null</c> is returned.
- /// </para>
- /// </remarks>
- ILogger Exists(string name);
+ /// <summary>
+ /// Check if the named logger exists in the repository. If so return
+ /// its reference, otherwise returns <c>null</c>.
+ /// </summary>
+ /// <param name="name">The name of the logger to lookup</param>
+ /// <returns>The Logger object with the name specified</returns>
+ /// <remarks>
+ /// <para>
+ /// If the names logger exists it is returned, otherwise
+ /// <c>null</c> is returned.
+ /// </para>
+ /// </remarks>
+ ILogger Exists(string name);
- /// <summary>
- /// Returns all the currently defined loggers as an Array.
- /// </summary>
- /// <returns>All the defined loggers</returns>
- /// <remarks>
- /// <para>
- /// Returns all the currently defined loggers as an Array.
- /// </para>
- /// </remarks>
- ILogger[] GetCurrentLoggers();
+ /// <summary>
+ /// Returns all the currently defined loggers as an Array.
+ /// </summary>
+ /// <returns>All the defined loggers</returns>
+ /// <remarks>
+ /// <para>
+ /// Returns all the currently defined loggers as an Array.
+ /// </para>
+ /// </remarks>
+ ILogger[] GetCurrentLoggers();
- /// <summary>
- /// Returns a named logger instance
- /// </summary>
- /// <param name="name">The name of the logger to retrieve</param>
- /// <returns>The logger object with the name specified</returns>
- /// <remarks>
- /// <para>
- /// Returns a named logger instance.
- /// </para>
- /// <para>
- /// If a logger of that name already exists, then it will be
- /// returned. Otherwise, a new logger will be instantiated and
- /// then linked with its existing ancestors as well as children.
- /// </para>
- /// </remarks>
- ILogger GetLogger(string name);
+ /// <summary>
+ /// Returns a named logger instance
+ /// </summary>
+ /// <param name="name">The name of the logger to retrieve</param>
+ /// <returns>The logger object with the name specified</returns>
+ /// <remarks>
+ /// <para>
+ /// Returns a named logger instance.
+ /// </para>
+ /// <para>
+ /// If a logger of that name already exists, then it will be
+ /// returned. Otherwise, a new logger will be instantiated and
+ /// then linked with its existing ancestors as well as children.
+ /// </para>
+ /// </remarks>
+ ILogger GetLogger(string name);
- /// <summary>Shutdown the repository</summary>
- /// <remarks>
- /// <para>
- /// Shutting down a repository will <i>safely</i> close and remove
- /// all appenders in all loggers including the root logger.
- /// </para>
- /// <para>
- /// Some appenders need to be closed before the
- /// application exists. Otherwise, pending logging events might be
- /// lost.
- /// </para>
- /// <para>
- /// The <see cref="M:Shutdown()"/> method is careful to close nested
- /// appenders before closing regular appenders. This is allows
- /// configurations where a regular appender is attached to a logger
- /// and again to a nested appender.
- /// </para>
- /// </remarks>
- void Shutdown();
+ /// <summary>Shutdown the repository</summary>
+ /// <remarks>
+ /// <para>
+ /// Shutting down a repository will <i>safely</i> close and remove
+ /// all appenders in all loggers including the root logger.
+ /// </para>
+ /// <para>
+ /// Some appenders need to be closed before the
+ /// application exists. Otherwise, pending logging events might be
+ /// lost.
+ /// </para>
+ /// <para>
+ /// The <see cref="M:Shutdown()"/> method is careful to close nested
+ /// appenders before closing regular appenders. This is allows
+ /// configurations where a regular appender is attached to a logger
+ /// and again to a nested appender.
+ /// </para>
+ /// </remarks>
+ void Shutdown();
- /// <summary>
- /// Reset the repositories configuration to a default state
- /// </summary>
- /// <remarks>
- /// <para>
- /// Reset all values contained in this instance to their
- /// default state.
- /// </para>
- /// <para>
- /// Existing loggers are not removed. They are just reset.
- /// </para>
- /// <para>
- /// This method should be used sparingly and with care as it will
- /// block all logging until it is completed.
- /// </para>
- /// </remarks>
- void ResetConfiguration();
+ /// <summary>
+ /// Reset the repositories configuration to a default state
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Reset all values contained in this instance to their
+ /// default state.
+ /// </para>
+ /// <para>
+ /// Existing loggers are not removed. They are just reset.
+ /// </para>
+ /// <para>
+ /// This method should be used sparingly and with care as it will
+ /// block all logging until it is completed.
+ /// </para>
+ /// </remarks>
+ void ResetConfiguration();
- /// <summary>
- /// Log the <see cref="LoggingEvent"/> through this repository.
- /// </summary>
- /// <param name="logEvent">the event to log</param>
- /// <remarks>
- /// <para>
- /// This method should not normally be used to log.
- /// The <see cref="ILog"/> interface should be used
- /// for routine logging. This interface can be obtained
- /// using the <see cref="M:log4net.LogManager.GetLogger(string)"/> method.
- /// </para>
- /// <para>
- /// The <c>logEvent</c> is delivered to the appropriate logger and
- /// that logger is then responsible for logging the event.
- /// </para>
- /// </remarks>
- void Log(LoggingEvent logEvent);
+ /// <summary>
+ /// Log the <see cref="LoggingEvent"/> through this repository.
+ /// </summary>
+ /// <param name="logEvent">the event to log</param>
+ /// <remarks>
+ /// <para>
+ /// This method should not normally be used to log.
+ /// The <see cref="ILog"/> interface should be used
+ /// for routine logging. This interface can be obtained
+ /// using the <see cref="M:log4net.LogManager.GetLogger(string)"/> method.
+ /// </para>
+ /// <para>
+ /// The <c>logEvent</c> is delivered to the appropriate logger and
+ /// that logger is then responsible for logging the event.
+ /// </para>
+ /// </remarks>
+ void Log(LoggingEvent logEvent);
- /// <summary>
- /// Flag indicates if this repository has been configured.
- /// </summary>
- /// <value>
- /// Flag indicates if this repository has been configured.
- /// </value>
- /// <remarks>
- /// <para>
- /// Flag indicates if this repository has been configured.
- /// </para>
- /// </remarks>
- bool Configured { get; set; }
+ /// <summary>
+ /// Flag indicates if this repository has been configured.
+ /// </summary>
+ /// <value>
+ /// Flag indicates if this repository has been configured.
+ /// </value>
+ /// <remarks>
+ /// <para>
+ /// Flag indicates if this repository has been configured.
+ /// </para>
+ /// </remarks>
+ bool Configured { get; set; }
/// <summary>
/// Collection of internal messages captured during the most
@@ -282,68 +282,68 @@
/// </summary>
ICollection ConfigurationMessages { get; set; }
- /// <summary>
- /// Event to notify that the repository has been shutdown.
- /// </summary>
- /// <value>
- /// Event to notify that the repository has been shutdown.
- /// </value>
- /// <remarks>
- /// <para>
- /// Event raised when the repository has been shutdown.
- /// </para>
- /// </remarks>
- event LoggerRepositoryShutdownEventHandler ShutdownEvent;
+ /// <summary>
+ /// Event to notify that the repository has been shutdown.
+ /// </summary>
+ /// <value>
+ /// Event to notify that the repository has been shutdown.
+ /// </value>
+ /// <remarks>
+ /// <para>
+ /// Event raised when the repository has been shutdown.
+ /// </para>
+ /// </remarks>
+ event LoggerRepositoryShutdownEventHandler ShutdownEvent;
- /// <summary>
- /// Event to notify that the repository has had its configuration reset.
- /// </summary>
- /// <value>
- /// Event to notify that the repository has had its configuration reset.
- /// </value>
- /// <remarks>
- /// <para>
- /// Event raised when the repository's configuration has been
- /// reset to default.
- /// </para>
- /// </remarks>
- event LoggerRepositoryConfigurationResetEventHandler ConfigurationReset;
+ /// <summary>
+ /// Event to notify that the repository has had its configuration reset.
+ /// </summary>
+ /// <value>
+ /// Event to notify that the repository has had its configuration reset.
+ /// </value>
+ /// <remarks>
+ /// <para>
+ /// Event raised when the repository's configuration has been
+ /// reset to default.
+ /// </para>
+ /// </remarks>
+ event LoggerRepositoryConfigurationResetEventHandler ConfigurationReset;
- /// <summary>
- /// Event to notify that the repository has had its configuration changed.
- /// </summary>
- /// <value>
- /// Event to notify that the repository has had its configuration changed.
- /// </value>
- /// <remarks>
- /// <para>
- /// Event raised when the repository's configuration has been changed.
- /// </para>
- /// </remarks>
- event LoggerRepositoryConfigurationChangedEventHandler ConfigurationChanged;
+ /// <summary>
+ /// Event to notify that the repository has had its configuration changed.
+ /// </summary>
+ /// <value>
+ /// Event to notify that the repository has had its configuration changed.
+ /// </value>
+ /// <remarks>
+ /// <para>
+ /// Event raised when the repository's configuration has been changed.
+ /// </para>
+ /// </remarks>
+ event LoggerRepositoryConfigurationChangedEventHandler ConfigurationChanged;
- /// <summary>
- /// Repository specific properties
- /// </summary>
- /// <value>
- /// Repository specific properties
- /// </value>
- /// <remarks>
- /// <para>
- /// These properties can be specified on a repository specific basis.
- /// </para>
- /// </remarks>
- PropertiesDictionary Properties { get; }
+ /// <summary>
+ /// Repository specific properties
+ /// </summary>
+ /// <value>
+ /// Repository specific properties
+ /// </value>
+ /// <remarks>
+ /// <para>
+ /// These properties can be specified on a repository specific basis.
+ /// </para>
+ /// </remarks>
+ PropertiesDictionary Properties { get; }
- /// <summary>
- /// Returns all the Appenders that are configured as an Array.
- /// </summary>
- /// <returns>All the Appenders</returns>
- /// <remarks>
- /// <para>
- /// Returns all the Appenders that are configured as an Array.
- /// </para>
- /// </remarks>
- log4net.Appender.IAppender[] GetAppenders();
- }
+ /// <summary>
+ /// Returns all the Appenders that are configured as an Array.
+ /// </summary>
+ /// <returns>All the Appenders</returns>
+ /// <remarks>
+ /// <para>
+ /// Returns all the Appenders that are configured as an Array.
+ /// </para>
+ /// </remarks>
+ log4net.Appender.IAppender[] GetAppenders();
+ }
}
diff --git a/src/log4net/Repository/IXmlRepositoryConfigurator.cs b/src/log4net/Repository/IXmlRepositoryConfigurator.cs
index 6fd657c..ad16471 100644
--- a/src/log4net/Repository/IXmlRepositoryConfigurator.cs
+++ b/src/log4net/Repository/IXmlRepositoryConfigurator.cs
@@ -23,32 +23,32 @@
namespace log4net.Repository
{
- /// <summary>
- /// Configure repository using XML
- /// </summary>
- /// <remarks>
- /// <para>
- /// Interface used by Xml configurator to configure a <see cref="ILoggerRepository"/>.
- /// </para>
- /// <para>
- /// A <see cref="ILoggerRepository"/> should implement this interface to support
- /// configuration by the <see cref="log4net.Config.XmlConfigurator"/>.
- /// </para>
- /// </remarks>
- /// <author>Nicko Cadell</author>
- /// <author>Gert Driesen</author>
- public interface IXmlRepositoryConfigurator
- {
- /// <summary>
- /// Initialize the repository using the specified config
- /// </summary>
- /// <param name="element">the element containing the root of the config</param>
- /// <remarks>
- /// <para>
- /// The schema for the XML configuration data is defined by
- /// the implementation.
- /// </para>
- /// </remarks>
- void Configure(System.Xml.XmlElement element);
- }
+ /// <summary>
+ /// Configure repository using XML
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Interface used by Xml configurator to configure a <see cref="ILoggerRepository"/>.
+ /// </para>
+ /// <para>
+ /// A <see cref="ILoggerRepository"/> should implement this interface to support
+ /// configuration by the <see cref="log4net.Config.XmlConfigurator"/>.
+ /// </para>
+ /// </remarks>
+ /// <author>Nicko Cadell</author>
+ /// <author>Gert Driesen</author>
+ public interface IXmlRepositoryConfigurator
+ {
+ /// <summary>
+ /// Initialize the repository using the specified config
+ /// </summary>
+ /// <param name="element">the element containing the root of the config</param>
+ /// <remarks>
+ /// <para>
+ /// The schema for the XML configuration data is defined by
+ /// the implementation.
+ /// </para>
+ /// </remarks>
+ void Configure(System.Xml.XmlElement element);
+ }
}
diff --git a/src/log4net/Repository/LoggerRepositorySkeleton.cs b/src/log4net/Repository/LoggerRepositorySkeleton.cs
index 9a2a69c..7a69a24 100644
--- a/src/log4net/Repository/LoggerRepositorySkeleton.cs
+++ b/src/log4net/Repository/LoggerRepositorySkeleton.cs
@@ -27,553 +27,553 @@
namespace log4net.Repository
{
- /// <summary>
- /// Base implementation of <see cref="ILoggerRepository"/>
- /// </summary>
- /// <remarks>
- /// <para>
- /// Default abstract implementation of the <see cref="ILoggerRepository"/> interface.
- /// </para>
- /// <para>
- /// Skeleton implementation of the <see cref="ILoggerRepository"/> interface.
- /// All <see cref="ILoggerRepository"/> types can extend this type.
- /// </para>
- /// </remarks>
- /// <author>Nicko Cadell</author>
- /// <author>Gert Driesen</author>
- public abstract class LoggerRepositorySkeleton : ILoggerRepository, Appender.IFlushable
- {
- #region Member Variables
+ /// <summary>
+ /// Base implementation of <see cref="ILoggerRepository"/>
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Default abstract implementation of the <see cref="ILoggerRepository"/> interface.
+ /// </para>
+ /// <para>
+ /// Skeleton implementation of the <see cref="ILoggerRepository"/> interface.
+ /// All <see cref="ILoggerRepository"/> types can extend this type.
+ /// </para>
+ /// </remarks>
+ /// <author>Nicko Cadell</author>
+ /// <author>Gert Driesen</author>
+ public abstract class LoggerRepositorySkeleton : ILoggerRepository, Appender.IFlushable
+ {
+ #region Member Variables
- private string m_name;
- private RendererMap m_rendererMap;
- private PluginMap m_pluginMap;
- private LevelMap m_levelMap;
- private Level m_threshold;
- private bool m_configured;
+ private string m_name;
+ private RendererMap m_rendererMap;
+ private PluginMap m_pluginMap;
+ private LevelMap m_levelMap;
+ private Level m_threshold;
+ private bool m_configured;
private ICollection m_configurationMessages;
- private event LoggerRepositoryShutdownEventHandler m_shutdownEvent;
- private event LoggerRepositoryConfigurationResetEventHandler m_configurationResetEvent;
- private event LoggerRepositoryConfigurationChangedEventHandler m_configurationChangedEvent;
- private PropertiesDictionary m_properties;
+ private event LoggerRepositoryShutdownEventHandler m_shutdownEvent;
+ private event LoggerRepositoryConfigurationResetEventHandler m_configurationResetEvent;
+ private event LoggerRepositoryConfigurationChangedEventHandler m_configurationChangedEvent;
+ private PropertiesDictionary m_properties;
- #endregion
+ #endregion
- #region Constructors
+ #region Constructors
- /// <summary>
- /// Default Constructor
- /// </summary>
- /// <remarks>
- /// <para>
- /// Initializes the repository with default (empty) properties.
- /// </para>
- /// </remarks>
- protected LoggerRepositorySkeleton() : this(new PropertiesDictionary())
- {
- }
+ /// <summary>
+ /// Default Constructor
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Initializes the repository with default (empty) properties.
+ /// </para>
+ /// </remarks>
+ protected LoggerRepositorySkeleton() : this(new PropertiesDictionary())
+ {
+ }
- /// <summary>
- /// Construct the repository using specific properties
- /// </summary>
- /// <param name="properties">the properties to set for this repository</param>
- /// <remarks>
- /// <para>
- /// Initializes the repository with specified properties.
- /// </para>
- /// </remarks>
- protected LoggerRepositorySkeleton(PropertiesDictionary properties)
- {
- m_properties = properties;
- m_rendererMap = new RendererMap();
- m_pluginMap = new PluginMap(this);
- m_levelMap = new LevelMap();
+ /// <summary>
+ /// Construct the repository using specific properties
+ /// </summary>
+ /// <param name="properties">the properties to set for this repository</param>
+ /// <remarks>
+ /// <para>
+ /// Initializes the repository with specified properties.
+ /// </para>
+ /// </remarks>
+ protected LoggerRepositorySkeleton(PropertiesDictionary properties)
+ {
+ m_properties = properties;
+ m_rendererMap = new RendererMap();
+ m_pluginMap = new PluginMap(this);
+ m_levelMap = new LevelMap();
m_configurationMessages = EmptyCollection.Instance;
- m_configured = false;
+ m_configured = false;
- AddBuiltinLevels();
+ AddBuiltinLevels();
- // Don't disable any levels by default.
- m_threshold = Level.All;
- }
+ // Don't disable any levels by default.
+ m_threshold = Level.All;
+ }
- #endregion
+ #endregion
- #region Implementation of ILoggerRepository
+ #region Implementation of ILoggerRepository
- /// <summary>
- /// The name of the repository
- /// </summary>
- /// <value>
- /// The string name of the repository
- /// </value>
- /// <remarks>
- /// <para>
- /// The name of this repository. The name is
- /// used to store and lookup the repositories
- /// stored by the <see cref="IRepositorySelector"/>.
- /// </para>
- /// </remarks>
- public virtual string Name
- {
- get { return m_name; }
- set { m_name = value; }
- }
+ /// <summary>
+ /// The name of the repository
+ /// </summary>
+ /// <value>
+ /// The string name of the repository
+ /// </value>
+ /// <remarks>
+ /// <para>
+ /// The name of this repository. The name is
+ /// used to store and lookup the repositories
+ /// stored by the <see cref="IRepositorySelector"/>.
+ /// </para>
+ /// </remarks>
+ public virtual string Name
+ {
+ get { return m_name; }
+ set { m_name = value; }
+ }
- /// <summary>
- /// The threshold for all events in this repository
- /// </summary>
- /// <value>
- /// The threshold for all events in this repository
- /// </value>
- /// <remarks>
- /// <para>
- /// The threshold for all events in this repository
- /// </para>
- /// </remarks>
- public virtual Level Threshold
- {
- get { return m_threshold; }
- set
- {
- if (value != null)
- {
- m_threshold = value;
- }
- else
- {
- // Must not set threshold to null
- LogLog.Warn(declaringType, "LoggerRepositorySkeleton: Threshold cannot be set to null. Setting to ALL");
- m_threshold = Level.All;
- }
- }
- }
+ /// <summary>
+ /// The threshold for all events in this repository
+ /// </summary>
+ /// <value>
+ /// The threshold for all events in this repository
+ /// </value>
+ /// <remarks>
+ /// <para>
+ /// The threshold for all events in this repository
+ /// </para>
+ /// </remarks>
+ public virtual Level Threshold
+ {
+ get { return m_threshold; }
+ set
+ {
+ if (value != null)
+ {
+ m_threshold = value;
+ }
+ else
+ {
+ // Must not set threshold to null
+ LogLog.Warn(declaringType, "LoggerRepositorySkeleton: Threshold cannot be set to null. Setting to ALL");
+ m_threshold = Level.All;
+ }
+ }
+ }
- /// <summary>
- /// RendererMap accesses the object renderer map for this repository.
- /// </summary>
- /// <value>
- /// RendererMap accesses the object renderer map for this repository.
- /// </value>
- /// <remarks>
- /// <para>
- /// RendererMap accesses the object renderer map for this repository.
- /// </para>
- /// <para>
- /// The RendererMap holds a mapping between types and
- /// <see cref="IObjectRenderer"/> objects.
- /// </para>
- /// </remarks>
- public virtual RendererMap RendererMap
- {
- get { return m_rendererMap; }
- }
+ /// <summary>
+ /// RendererMap accesses the object renderer map for this repository.
+ /// </summary>
+ /// <value>
+ /// RendererMap accesses the object renderer map for this repository.
+ /// </value>
+ /// <remarks>
+ /// <para>
+ /// RendererMap accesses the object renderer map for this repository.
+ /// </para>
+ /// <para>
+ /// The RendererMap holds a mapping between types and
+ /// <see cref="IObjectRenderer"/> objects.
+ /// </para>
+ /// </remarks>
+ public virtual RendererMap RendererMap
+ {
+ get { return m_rendererMap; }
+ }
- /// <summary>
- /// The plugin map for this repository.
- /// </summary>
- /// <value>
- /// The plugin map for this repository.
- /// </value>
- /// <remarks>
- /// <para>
- /// The plugin map holds the <see cref="IPlugin"/> instances
- /// that have been attached to this repository.
- /// </para>
- /// </remarks>
- public virtual PluginMap PluginMap
- {
- get { return m_pluginMap; }
- }
+ /// <summary>
+ /// The plugin map for this repository.
+ /// </summary>
+ /// <value>
+ /// The plugin map for this repository.
+ /// </value>
+ /// <remarks>
+ /// <para>
+ /// The plugin map holds the <see cref="IPlugin"/> instances
+ /// that have been attached to this repository.
+ /// </para>
+ /// </remarks>
+ public virtual PluginMap PluginMap
+ {
+ get { return m_pluginMap; }
+ }
- /// <summary>
- /// Get the level map for the Repository.
- /// </summary>
- /// <remarks>
- /// <para>
- /// Get the level map for the Repository.
- /// </para>
- /// <para>
- /// The level map defines the mappings between
- /// level names and <see cref="Level"/> objects in
- /// this repository.
- /// </para>
- /// </remarks>
- public virtual LevelMap LevelMap
- {
- get { return m_levelMap; }
- }
+ /// <summary>
+ /// Get the level map for the Repository.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Get the level map for the Repository.
+ /// </para>
+ /// <para>
+ /// The level map defines the mappings between
+ /// level names and <see cref="Level"/> objects in
+ /// this repository.
+ /// </para>
+ /// </remarks>
+ public virtual LevelMap LevelMap
+ {
+ get { return m_levelMap; }
+ }
- /// <summary>
- /// Test if logger exists
- /// </summary>
- /// <param name="name">The name of the logger to lookup</param>
- /// <returns>The Logger object with the name specified</returns>
- /// <remarks>
- /// <para>
- /// Check if the named logger exists in the repository. If so return
- /// its reference, otherwise returns <c>null</c>.
- /// </para>
- /// </remarks>
- public abstract ILogger Exists(string name);
+ /// <summary>
+ /// Test if logger exists
+ /// </summary>
+ /// <param name="name">The name of the logger to lookup</param>
+ /// <returns>The Logger object with the name specified</returns>
+ /// <remarks>
+ /// <para>
+ /// Check if the named logger exists in the repository. If so return
+ /// its reference, otherwise returns <c>null</c>.
+ /// </para>
+ /// </remarks>
+ public abstract ILogger Exists(string name);
- /// <summary>
- /// Returns all the currently defined loggers in the repository
- /// </summary>
- /// <returns>All the defined loggers</returns>
- /// <remarks>
- /// <para>
- /// Returns all the currently defined loggers in the repository as an Array.
- /// </para>
- /// </remarks>
- public abstract ILogger[] GetCurrentLoggers();
+ /// <summary>
+ /// Returns all the currently defined loggers in the repository
+ /// </summary>
+ /// <returns>All the defined loggers</returns>
+ /// <remarks>
+ /// <para>
+ /// Returns all the currently defined loggers in the repository as an Array.
+ /// </para>
+ /// </remarks>
+ public abstract ILogger[] GetCurrentLoggers();
- /// <summary>
- /// Return a new logger instance
- /// </summary>
- /// <param name="name">The name of the logger to retrieve</param>
- /// <returns>The logger object with the name specified</returns>
- /// <remarks>
- /// <para>
- /// Return a new logger instance.
- /// </para>
- /// <para>
- /// If a logger of that name already exists, then it will be
- /// returned. Otherwise, a new logger will be instantiated and
- /// then linked with its existing ancestors as well as children.
- /// </para>
- /// </remarks>
- public abstract ILogger GetLogger(string name);
+ /// <summary>
+ /// Return a new logger instance
+ /// </summary>
+ /// <param name="name">The name of the logger to retrieve</param>
+ /// <returns>The logger object with the name specified</returns>
+ /// <remarks>
+ /// <para>
+ /// Return a new logger instance.
+ /// </para>
+ /// <para>
+ /// If a logger of that name already exists, then it will be
+ /// returned. Otherwise, a new logger will be instantiated and
+ /// then linked with its existing ancestors as well as children.
+ /// </para>
+ /// </remarks>
+ public abstract ILogger GetLogger(string name);
- /// <summary>
- /// Shutdown the repository
- /// </summary>
- /// <remarks>
- /// <para>
- /// Shutdown the repository. Can be overridden in a subclass.
- /// This base class implementation notifies the <see cref="ShutdownEvent"/>
- /// listeners and all attached plugins of the shutdown event.
- /// </para>
- /// </remarks>
- public virtual void Shutdown()
- {
- // Shutdown attached plugins
- foreach(IPlugin plugin in PluginMap.AllPlugins)
- {
- plugin.Shutdown();
- }
+ /// <summary>
+ /// Shutdown the repository
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Shutdown the repository. Can be overridden in a subclass.
+ /// This base class implementation notifies the <see cref="ShutdownEvent"/>
+ /// listeners and all attached plugins of the shutdown event.
+ /// </para>
+ /// </remarks>
+ public virtual void Shutdown()
+ {
+ // Shutdown attached plugins
+ foreach(IPlugin plugin in PluginMap.AllPlugins)
+ {
+ plugin.Shutdown();
+ }
- // Notify listeners
- OnShutdown(null);
- }
+ // Notify listeners
+ OnShutdown(null);
+ }
- /// <summary>
- /// Reset the repositories configuration to a default state
- /// </summary>
- /// <remarks>
- /// <para>
- /// Reset all values contained in this instance to their
- /// default state.
- /// </para>
- /// <para>
- /// Existing loggers are not removed. They are just reset.
- /// </para>
- /// <para>
- /// This method should be used sparingly and with care as it will
- /// block all logging until it is completed.
- /// </para>
- /// </remarks>
- public virtual void ResetConfiguration()
- {
- // Clear internal data structures
- m_rendererMap.Clear();
- m_levelMap.Clear();
+ /// <summary>
+ /// Reset the repositories configuration to a default state
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Reset all values contained in this instance to their
+ /// default state.
+ /// </para>
+ /// <para>
+ /// Existing loggers are not removed. They are just reset.
+ /// </para>
+ /// <para>
+ /// This method should be used sparingly and with care as it will
+ /// block all logging until it is completed.
+ /// </para>
+ /// </remarks>
+ public virtual void ResetConfiguration()
+ {
+ // Clear internal data structures
+ m_rendererMap.Clear();
+ m_levelMap.Clear();
m_configurationMessages = EmptyCollection.Instance;
- // Add the predefined levels to the map
- AddBuiltinLevels();
+ // Add the predefined levels to the map
+ AddBuiltinLevels();
- Configured = false;
+ Configured = false;
- // Notify listeners
- OnConfigurationReset(null);
- }
+ // Notify listeners
+ OnConfigurationReset(null);
+ }
- /// <summary>
- /// Log the logEvent through this repository.
- /// </summary>
- /// <param name="logEvent">the event to log</param>
- /// <remarks>
- /// <para>
- /// This method should not normally be used to log.
- /// The <see cref="ILog"/> interface should be used
- /// for routine logging. This interface can be obtained
- /// using the <see cref="M:log4net.LogManager.GetLogger(string)"/> method.
- /// </para>
- /// <para>
- /// The <c>logEvent</c> is delivered to the appropriate logger and
- /// that logger is then responsible for logging the event.
- /// </para>
- /// </remarks>
- public abstract void Log(LoggingEvent logEvent);
+ /// <summary>
+ /// Log the logEvent through this repository.
+ /// </summary>
+ /// <param name="logEvent">the event to log</param>
+ /// <remarks>
+ /// <para>
+ /// This method should not normally be used to log.
+ /// The <see cref="ILog"/> interface should be used
+ /// for routine logging. This interface can be obtained
+ /// using the <see cref="M:log4net.LogManager.GetLogger(string)"/> method.
+ /// </para>
+ /// <para>
+ /// The <c>logEvent</c> is delivered to the appropriate logger and
+ /// that logger is then responsible for logging the event.
+ /// </para>
+ /// </remarks>
+ public abstract void Log(LoggingEvent logEvent);
- /// <summary>
- /// Flag indicates if this repository has been configured.
- /// </summary>
- /// <value>
- /// Flag indicates if this repository has been configured.
- /// </value>
- /// <remarks>
- /// <para>
- /// Flag indicates if this repository has been configured.
- /// </para>
- /// </remarks>
- public virtual bool Configured
- {
- get { return m_configured; }
- set { m_configured = value; }
- }
+ /// <summary>
+ /// Flag indicates if this repository has been configured.
+ /// </summary>
+ /// <value>
+ /// Flag indicates if this repository has been configured.
+ /// </value>
+ /// <remarks>
+ /// <para>
+ /// Flag indicates if this repository has been configured.
+ /// </para>
+ /// </remarks>
+ public virtual bool Configured
+ {
+ get { return m_configured; }
+ set { m_configured = value; }
+ }
/// <summary>
/// Contains a list of internal messages captures during the
/// last configuration.
/// </summary>
- public virtual ICollection ConfigurationMessages
- {
+ public virtual ICollection ConfigurationMessages
+ {
get { return m_configurationMessages; }
set { m_configurationMessages = value; }
- }
+ }
- /// <summary>
- /// Event to notify that the repository has been shutdown.
- /// </summary>
- /// <value>
- /// Event to notify that the repository has been shutdown.
- /// </value>
- /// <remarks>
- /// <para>
- /// Event raised when the repository has been shutdown.
- /// </para>
- /// </remarks>
- public event LoggerRepositoryShutdownEventHandler ShutdownEvent
- {
- add { m_shutdownEvent += value; }
- remove { m_shutdownEvent -= value; }
- }
+ /// <summary>
+ /// Event to notify that the repository has been shutdown.
+ /// </summary>
+ /// <value>
+ /// Event to notify that the repository has been shutdown.
+ /// </value>
+ /// <remarks>
+ /// <para>
+ /// Event raised when the repository has been shutdown.
+ /// </para>
+ /// </remarks>
+ public event LoggerRepositoryShutdownEventHandler ShutdownEvent
+ {
+ add { m_shutdownEvent += value; }
+ remove { m_shutdownEvent -= value; }
+ }
- /// <summary>
- /// Event to notify that the repository has had its configuration reset.
- /// </summary>
- /// <value>
- /// Event to notify that the repository has had its configuration reset.
- /// </value>
- /// <remarks>
- /// <para>
- /// Event raised when the repository's configuration has been
- /// reset to default.
- /// </para>
- /// </remarks>
- public event LoggerRepositoryConfigurationResetEventHandler ConfigurationReset
- {
- add { m_configurationResetEvent += value; }
- remove { m_configurationResetEvent -= value; }
- }
+ /// <summary>
+ /// Event to notify that the repository has had its configuration reset.
+ /// </summary>
+ /// <value>
+ /// Event to notify that the repository has had its configuration reset.
+ /// </value>
+ /// <remarks>
+ /// <para>
+ /// Event raised when the repository's configuration has been
+ /// reset to default.
+ /// </para>
+ /// </remarks>
+ public event LoggerRepositoryConfigurationResetEventHandler ConfigurationReset
+ {
+ add { m_configurationResetEvent += value; }
+ remove { m_configurationResetEvent -= value; }
+ }
- /// <summary>
- /// Event to notify that the repository has had its configuration changed.
- /// </summary>
- /// <value>
- /// Event to notify that the repository has had its configuration changed.
- /// </value>
- /// <remarks>
- /// <para>
- /// Event raised when the repository's configuration has been changed.
- /// </para>
- /// </remarks>
- public event LoggerRepositoryConfigurationChangedEventHandler ConfigurationChanged
- {
- add { m_configurationChangedEvent += value; }
- remove { m_configurationChangedEvent -= value; }
- }
+ /// <summary>
+ /// Event to notify that the repository has had its configuration changed.
+ /// </summary>
+ /// <value>
+ /// Event to notify that the repository has had its configuration changed.
+ /// </value>
+ /// <remarks>
+ /// <para>
+ /// Event raised when the repository's configuration has been changed.
+ /// </para>
+ /// </remarks>
+ public event LoggerRepositoryConfigurationChangedEventHandler ConfigurationChanged
+ {
+ add { m_configurationChangedEvent += value; }
+ remove { m_configurationChangedEvent -= value; }
+ }
- /// <summary>
- /// Repository specific properties
- /// </summary>
- /// <value>
- /// Repository specific properties
- /// </value>
- /// <remarks>
- /// These properties can be specified on a repository specific basis
- /// </remarks>
- public PropertiesDictionary Properties
- {
- get { return m_properties; }
- }
+ /// <summary>
+ /// Repository specific properties
+ /// </summary>
+ /// <value>
+ /// Repository specific properties
+ /// </value>
+ /// <remarks>
+ /// These properties can be specified on a repository specific basis
+ /// </remarks>
+ public PropertiesDictionary Properties
+ {
+ get { return m_properties; }
+ }
- /// <summary>
- /// Returns all the Appenders that are configured as an Array.
- /// </summary>
- /// <returns>All the Appenders</returns>
- /// <remarks>
- /// <para>
- /// Returns all the Appenders that are configured as an Array.
- /// </para>
- /// </remarks>
- public abstract log4net.Appender.IAppender[] GetAppenders();
+ /// <summary>
+ /// Returns all the Appenders that are configured as an Array.
+ /// </summary>
+ /// <returns>All the Appenders</returns>
+ /// <remarks>
+ /// <para>
+ /// Returns all the Appenders that are configured as an Array.
+ /// </para>
+ /// </remarks>
+ public abstract log4net.Appender.IAppender[] GetAppenders();
- #endregion
+ #endregion
- #region Private Static Fields
+ #region Private Static Fields
- /// <summary>
- /// The fully qualified type of the LoggerRepositorySkeleton class.
- /// </summary>
- /// <remarks>
- /// Used by the internal logger to record the Type of the
- /// log message.
- /// </remarks>
- private static readonly Type declaringType = typeof(LoggerRepositorySkeleton);
+ /// <summary>
+ /// The fully qualified type of the LoggerRepositorySkeleton class.
+ /// </summary>
+ /// <remarks>
+ /// Used by the internal logger to record the Type of the
+ /// log message.
+ /// </remarks>
+ private static readonly Type declaringType = typeof(LoggerRepositorySkeleton);
- #endregion Private Static Fields
+ #endregion Private Static Fields
- private void AddBuiltinLevels()
- {
- // Add the predefined levels to the map
- m_levelMap.Add(Level.Off);
+ private void AddBuiltinLevels()
+ {
+ // Add the predefined levels to the map
+ m_levelMap.Add(Level.Off);
- // Unrecoverable errors
- m_levelMap.Add(Level.Emergency);
- m_levelMap.Add(Level.Fatal);
- m_levelMap.Add(Level.Alert);
+ // Unrecoverable errors
+ m_levelMap.Add(Level.Emergency);
+ m_levelMap.Add(Level.Fatal);
+ m_levelMap.Add(Level.Alert);
- // Recoverable errors
- m_levelMap.Add(Level.Critical);
- m_levelMap.Add(Level.Severe);
- m_levelMap.Add(Level.Error);
- m_levelMap.Add(Level.Warn);
+ // Recoverable errors
+ m_levelMap.Add(Level.Critical);
+ m_levelMap.Add(Level.Severe);
+ m_levelMap.Add(Level.Error);
+ m_levelMap.Add(Level.Warn);
- // Information
- m_levelMap.Add(Level.Notice);
- m_levelMap.Add(Level.Info);
+ // Information
+ m_levelMap.Add(Level.Notice);
+ m_levelMap.Add(Level.Info);
- // Debug
- m_levelMap.Add(Level.Debug);
- m_levelMap.Add(Level.Fine);
- m_levelMap.Add(Level.Trace);
- m_levelMap.Add(Level.Finer);
- m_levelMap.Add(Level.Verbose);
- m_levelMap.Add(Level.Finest);
+ // Debug
+ m_levelMap.Add(Level.Debug);
+ m_levelMap.Add(Level.Fine);
+ m_levelMap.Add(Level.Trace);
+ m_levelMap.Add(Level.Finer);
+ m_levelMap.Add(Level.Verbose);
+ m_levelMap.Add(Level.Finest);
- m_levelMap.Add(Level.All);
- }
+ m_levelMap.Add(Level.All);
+ }
- /// <summary>
- /// Adds an object renderer for a specific class.
- /// </summary>
- /// <param name="typeToRender">The type that will be rendered by the renderer supplied.</param>
- /// <param name="rendererInstance">The object renderer used to render the object.</param>
- /// <remarks>
- /// <para>
- /// Adds an object renderer for a specific class.
- /// </para>
- /// </remarks>
- public virtual void AddRenderer(Type typeToRender, IObjectRenderer rendererInstance)
- {
- if (typeToRender == null)
- {
- throw new ArgumentNullException("typeToRender");
- }
- if (rendererInstance == null)
- {
- throw new ArgumentNullException("rendererInstance");
- }
+ /// <summary>
+ /// Adds an object renderer for a specific class.
+ /// </summary>
+ /// <param name="typeToRender">The type that will be rendered by the renderer supplied.</param>
+ /// <param name="rendererInstance">The object renderer used to render the object.</param>
+ /// <remarks>
+ /// <para>
+ /// Adds an object renderer for a specific class.
+ /// </para>
+ /// </remarks>
+ public virtual void AddRenderer(Type typeToRender, IObjectRenderer rendererInstance)
+ {
+ if (typeToRender == null)
+ {
+ throw new ArgumentNullException("typeToRender");
+ }
+ if (rendererInstance == null)
+ {
+ throw new ArgumentNullException("rendererInstance");
+ }
- m_rendererMap.Put(typeToRender, rendererInstance);
- }
+ m_rendererMap.Put(typeToRender, rendererInstance);
+ }
- /// <summary>
- /// Notify the registered listeners that the repository is shutting down
- /// </summary>
- /// <param name="e">Empty EventArgs</param>
- /// <remarks>
- /// <para>
- /// Notify any listeners that this repository is shutting down.
- /// </para>
- /// </remarks>
- protected virtual void OnShutdown(EventArgs e)
- {
- if (e == null)
- {
- e = EventArgs.Empty;
- }
+ /// <summary>
+ /// Notify the registered listeners that the repository is shutting down
+ /// </summary>
+ /// <param name="e">Empty EventArgs</param>
+ /// <remarks>
+ /// <para>
+ /// Notify any listeners that this repository is shutting down.
+ /// </para>
+ /// </remarks>
+ protected virtual void OnShutdown(EventArgs e)
+ {
+ if (e == null)
+ {
+ e = EventArgs.Empty;
+ }
- LoggerRepositoryShutdownEventHandler handler = m_shutdownEvent;
- if (handler != null)
- {
- handler(this, e);
- }
- }
+ LoggerRepositoryShutdownEventHandler handler = m_shutdownEvent;
+ if (handler != null)
+ {
+ handler(this, e);
+ }
+ }
- /// <summary>
- /// Notify the registered listeners that the repository has had its configuration reset
- /// </summary>
- /// <param name="e">Empty EventArgs</param>
- /// <remarks>
- /// <para>
- /// Notify any listeners that this repository's configuration has been reset.
- /// </para>
- /// </remarks>
- protected virtual void OnConfigurationReset(EventArgs e)
- {
- if (e == null)
- {
- e = EventArgs.Empty;
- }
+ /// <summary>
+ /// Notify the registered listeners that the repository has had its configuration reset
+ /// </summary>
+ /// <param name="e">Empty EventArgs</param>
+ /// <remarks>
+ /// <para>
+ /// Notify any listeners that this repository's configuration has been reset.
+ /// </para>
+ /// </remarks>
+ protected virtual void OnConfigurationReset(EventArgs e)
+ {
+ if (e == null)
+ {
+ e = EventArgs.Empty;
+ }
- LoggerRepositoryConfigurationResetEventHandler handler = m_configurationResetEvent;
- if (handler != null)
- {
- handler(this, e);
- }
- }
+ LoggerRepositoryConfigurationResetEventHandler handler = m_configurationResetEvent;
+ if (handler != null)
+ {
+ handler(this, e);
+ }
+ }
- /// <summary>
- /// Notify the registered listeners that the repository has had its configuration changed
- /// </summary>
- /// <param name="e">Empty EventArgs</param>
- /// <remarks>
- /// <para>
- /// Notify any listeners that this repository's configuration has changed.
- /// </para>
- /// </remarks>
- protected virtual void OnConfigurationChanged(EventArgs e)
- {
- if (e == null)
- {
- e = EventArgs.Empty;
- }
+ /// <summary>
+ /// Notify the registered listeners that the repository has had its configuration changed
+ /// </summary>
+ /// <param name="e">Empty EventArgs</param>
+ /// <remarks>
+ /// <para>
+ /// Notify any listeners that this repository's configuration has changed.
+ /// </para>
+ /// </remarks>
+ protected virtual void OnConfigurationChanged(EventArgs e)
+ {
+ if (e == null)
+ {
+ e = EventArgs.Empty;
+ }
- LoggerRepositoryConfigurationChangedEventHandler handler = m_configurationChangedEvent;
- if (handler != null)
- {
- handler(this, e);
- }
- }
+ LoggerRepositoryConfigurationChangedEventHandler handler = m_configurationChangedEvent;
+ if (handler != null)
+ {
+ handler(this, e);
+ }
+ }
- /// <summary>
- /// Raise a configuration changed event on this repository
- /// </summary>
- /// <param name="e">EventArgs.Empty</param>
- /// <remarks>
- /// <para>
- /// Applications that programmatically change the configuration of the repository should
- /// raise this event notification to notify listeners.
- /// </para>
- /// </remarks>
- public void RaiseConfigurationChanged(EventArgs e)
- {
- OnConfigurationChanged(e);
- }
+ /// <summary>
+ /// Raise a configuration changed event on this repository
+ /// </summary>
+ /// <param name="e">EventArgs.Empty</param>
+ /// <remarks>
+ /// <para>
+ /// Applications that programmatically change the configuration of the repository should
+ /// raise this event notification to notify listeners.
+ /// </para>
+ /// </remarks>
+ public void RaiseConfigurationChanged(EventArgs e)
+ {
+ OnConfigurationChanged(e);
+ }
private static int GetWaitTime(DateTime startTimeUtc, int millisecondsTimeout)
{
@@ -628,5 +628,5 @@
return result;
}
- }
+ }
}
diff --git a/src/log4net/ThreadContext.cs b/src/log4net/ThreadContext.cs
index 4da972c..e84dba5 100644
--- a/src/log4net/ThreadContext.cs
+++ b/src/log4net/ThreadContext.cs
@@ -24,116 +24,116 @@
namespace log4net
{
- /// <summary>
- /// The log4net Thread Context.
- /// </summary>
- /// <remarks>
- /// <para>
- /// The <c>ThreadContext</c> provides a location for thread specific debugging
- /// information to be stored.
- /// The <c>ThreadContext</c> properties override any <see cref="GlobalContext"/>
- /// properties with the same name.
- /// </para>
- /// <para>
- /// The thread context has a properties map and a stack.
- /// The properties and stack can
- /// be included in the output of log messages. The <see cref="log4net.Layout.PatternLayout"/>
- /// supports selecting and outputting these properties.
- /// </para>
- /// <para>
- /// The Thread Context provides a diagnostic context for the current thread.
- /// This is an instrument for distinguishing interleaved log
- /// output from different sources. Log output is typically interleaved
- /// when a server handles multiple clients near-simultaneously.
- /// </para>
- /// <para>
- /// The Thread Context is managed on a per thread basis.
- /// </para>
- /// </remarks>
- /// <example>Example of using the thread context properties to store a username.
- /// <code lang="C#">
- /// ThreadContext.Properties["user"] = userName;
- /// log.Info("This log message has a ThreadContext Property called 'user'");
- /// </code>
- /// </example>
- /// <example>Example of how to push a message into the context stack
- /// <code lang="C#">
- /// using(ThreadContext.Stacks["NDC"].Push("my context message"))
- /// {
- /// log.Info("This log message has a ThreadContext Stack message that includes 'my context message'");
- ///
- /// } // at the end of the using block the message is automatically popped
- /// </code>
- /// </example>
- /// <threadsafety static="true" instance="true" />
- /// <author>Nicko Cadell</author>
- public sealed class ThreadContext
- {
- #region Private Instance Constructors
+ /// <summary>
+ /// The log4net Thread Context.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// The <c>ThreadContext</c> provides a location for thread specific debugging
+ /// information to be stored.
+ /// The <c>ThreadContext</c> properties override any <see cref="GlobalContext"/>
+ /// properties with the same name.
+ /// </para>
+ /// <para>
+ /// The thread context has a properties map and a stack.
+ /// The properties and stack can
+ /// be included in the output of log messages. The <see cref="log4net.Layout.PatternLayout"/>
+ /// supports selecting and outputting these properties.
+ /// </para>
+ /// <para>
+ /// The Thread Context provides a diagnostic context for the current thread.
+ /// This is an instrument for distinguishing interleaved log
+ /// output from different sources. Log output is typically interleaved
+ /// when a server handles multiple clients near-simultaneously.
+ /// </para>
+ /// <para>
+ /// The Thread Context is managed on a per thread basis.
+ /// </para>
+ /// </remarks>
+ /// <example>Example of using the thread context properties to store a username.
+ /// <code lang="C#">
+ /// ThreadContext.Properties["user"] = userName;
+ /// log.Info("This log message has a ThreadContext Property called 'user'");
+ /// </code>
+ /// </example>
+ /// <example>Example of how to push a message into the context stack
+ /// <code lang="C#">
+ /// using(ThreadContext.Stacks["NDC"].Push("my context message"))
+ /// {
+ /// log.Info("This log message has a ThreadContext Stack message that includes 'my context message'");
+ ///
+ /// } // at the end of the using block the message is automatically popped
+ /// </code>
+ /// </example>
+ /// <threadsafety static="true" instance="true" />
+ /// <author>Nicko Cadell</author>
+ public sealed class ThreadContext
+ {
+ #region Private Instance Constructors
- /// <summary>
- /// Private Constructor.
- /// </summary>
- /// <remarks>
- /// <para>
- /// Uses a private access modifier to prevent instantiation of this class.
- /// </para>
- /// </remarks>
- private ThreadContext()
- {
- }
+ /// <summary>
+ /// Private Constructor.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Uses a private access modifier to prevent instantiation of this class.
+ /// </para>
+ /// </remarks>
+ private ThreadContext()
+ {
+ }
- #endregion Private Instance Constructors
+ #endregion Private Instance Constructors
- #region Public Static Properties
+ #region Public Static Properties
- /// <summary>
- /// The thread properties map
- /// </summary>
- /// <value>
- /// The thread properties map
- /// </value>
- /// <remarks>
- /// <para>
- /// The <c>ThreadContext</c> properties override any <see cref="GlobalContext"/>
- /// properties with the same name.
- /// </para>
- /// </remarks>
- public static ThreadContextProperties Properties
- {
- get { return s_properties; }
- }
+ /// <summary>
+ /// The thread properties map
+ /// </summary>
+ /// <value>
+ /// The thread properties map
+ /// </value>
+ /// <remarks>
+ /// <para>
+ /// The <c>ThreadContext</c> properties override any <see cref="GlobalContext"/>
+ /// properties with the same name.
+ /// </para>
+ /// </remarks>
+ public static ThreadContextProperties Properties
+ {
+ get { return s_properties; }
+ }
- /// <summary>
- /// The thread stacks
- /// </summary>
- /// <value>
- /// stack map
- /// </value>
- /// <remarks>
- /// <para>
- /// The thread local stacks.
- /// </para>
- /// </remarks>
- public static ThreadContextStacks Stacks
- {
- get { return s_stacks; }
- }
+ /// <summary>
+ /// The thread stacks
+ /// </summary>
+ /// <value>
+ /// stack map
+ /// </value>
+ /// <remarks>
+ /// <para>
+ /// The thread local stacks.
+ /// </para>
+ /// </remarks>
+ public static ThreadContextStacks Stacks
+ {
+ get { return s_stacks; }
+ }
- #endregion Public Static Properties
+ #endregion Public Static Properties
- #region Private Static Fields
+ #region Private Static Fields
- /// <summary>
- /// The thread context properties instance
- /// </summary>
- private static readonly ThreadContextProperties s_properties = new ThreadContextProperties();
+ /// <summary>
+ /// The thread context properties instance
+ /// </summary>
+ private static readonly ThreadContextProperties s_properties = new ThreadContextProperties();
- /// <summary>
- /// The thread context stacks instance
- /// </summary>
- private static readonly ThreadContextStacks s_stacks = new ThreadContextStacks(s_properties);
+ /// <summary>
+ /// The thread context stacks instance
+ /// </summary>
+ private static readonly ThreadContextStacks s_stacks = new ThreadContextStacks(s_properties);
- #endregion Private Static Fields
- }
+ #endregion Private Static Fields
+ }
}
diff --git a/src/log4net/Util/AppenderAttachedImpl.cs b/src/log4net/Util/AppenderAttachedImpl.cs
index 3508048..b6fc0fd 100644
--- a/src/log4net/Util/AppenderAttachedImpl.cs
+++ b/src/log4net/Util/AppenderAttachedImpl.cs
@@ -24,165 +24,165 @@
namespace log4net.Util
{
- /// <summary>
- /// A straightforward implementation of the <see cref="IAppenderAttachable"/> interface.
- /// </summary>
- /// <remarks>
- /// <para>
- /// This is the default implementation of the <see cref="IAppenderAttachable"/>
- /// interface. Implementors of the <see cref="IAppenderAttachable"/> interface
- /// should aggregate an instance of this type.
- /// </para>
- /// </remarks>
- /// <author>Nicko Cadell</author>
- /// <author>Gert Driesen</author>
- public class AppenderAttachedImpl : IAppenderAttachable
- {
- #region Public Instance Constructors
+ /// <summary>
+ /// A straightforward implementation of the <see cref="IAppenderAttachable"/> interface.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// This is the default implementation of the <see cref="IAppenderAttachable"/>
+ /// interface. Implementors of the <see cref="IAppenderAttachable"/> interface
+ /// should aggregate an instance of this type.
+ /// </para>
+ /// </remarks>
+ /// <author>Nicko Cadell</author>
+ /// <author>Gert Driesen</author>
+ public class AppenderAttachedImpl : IAppenderAttachable
+ {
+ #region Public Instance Constructors
- /// <summary>
- /// Constructor
- /// </summary>
- /// <remarks>
- /// <para>
- /// Initializes a new instance of the <see cref="AppenderAttachedImpl"/> class.
- /// </para>
- /// </remarks>
- public AppenderAttachedImpl()
- {
- }
+ /// <summary>
+ /// Constructor
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Initializes a new instance of the <see cref="AppenderAttachedImpl"/> class.
+ /// </para>
+ /// </remarks>
+ public AppenderAttachedImpl()
+ {
+ }
- #endregion Public Instance Constructors
+ #endregion Public Instance Constructors
- #region Public Instance Methods
+ #region Public Instance Methods
- /// <summary>
- /// Append on on all attached appenders.
- /// </summary>
- /// <param name="loggingEvent">The event being logged.</param>
- /// <returns>The number of appenders called.</returns>
- /// <remarks>
- /// <para>
- /// Calls the <see cref="IAppender.DoAppend" /> method on all
- /// attached appenders.
- /// </para>
- /// </remarks>
- public int AppendLoopOnAppenders(LoggingEvent loggingEvent)
- {
- if (loggingEvent == null)
- {
- throw new ArgumentNullException("loggingEvent");
- }
+ /// <summary>
+ /// Append on on all attached appenders.
+ /// </summary>
+ /// <param name="loggingEvent">The event being logged.</param>
+ /// <returns>The number of appenders called.</returns>
+ /// <remarks>
+ /// <para>
+ /// Calls the <see cref="IAppender.DoAppend" /> method on all
+ /// attached appenders.
+ /// </para>
+ /// </remarks>
+ public int AppendLoopOnAppenders(LoggingEvent loggingEvent)
+ {
+ if (loggingEvent == null)
+ {
+ throw new ArgumentNullException("loggingEvent");
+ }
- // m_appenderList is null when empty
- if (m_appenderList == null)
- {
- return 0;
- }
+ // m_appenderList is null when empty
+ if (m_appenderList == null)
+ {
+ return 0;
+ }
- if (m_appenderArray == null)
- {
- m_appenderArray = m_appenderList.ToArray();
- }
+ if (m_appenderArray == null)
+ {
+ m_appenderArray = m_appenderList.ToArray();
+ }
- foreach(IAppender appender in m_appenderArray)
- {
- try
- {
- appender.DoAppend(loggingEvent);
- }
- catch(Exception ex)
- {
- LogLog.Error(declaringType, "Failed to append to appender [" + appender.Name + "]", ex);
- }
- }
- return m_appenderList.Count;
- }
+ foreach(IAppender appender in m_appenderArray)
+ {
+ try
+ {
+ appender.DoAppend(loggingEvent);
+ }
+ catch(Exception ex)
+ {
+ LogLog.Error(declaringType, "Failed to append to appender [" + appender.Name + "]", ex);
+ }
+ }
+ return m_appenderList.Count;
+ }
- /// <summary>
- /// Append on on all attached appenders.
- /// </summary>
- /// <param name="loggingEvents">The array of events being logged.</param>
- /// <returns>The number of appenders called.</returns>
- /// <remarks>
- /// <para>
- /// Calls the <see cref="IAppender.DoAppend" /> method on all
- /// attached appenders.
- /// </para>
- /// </remarks>
- public int AppendLoopOnAppenders(LoggingEvent[] loggingEvents)
- {
- if (loggingEvents == null)
- {
- throw new ArgumentNullException("loggingEvents");
- }
- if (loggingEvents.Length == 0)
- {
- throw new ArgumentException("loggingEvents array must not be empty", "loggingEvents");
- }
- if (loggingEvents.Length == 1)
- {
- // Fall back to single event path
- return AppendLoopOnAppenders(loggingEvents[0]);
- }
+ /// <summary>
+ /// Append on on all attached appenders.
+ /// </summary>
+ /// <param name="loggingEvents">The array of events being logged.</param>
+ /// <returns>The number of appenders called.</returns>
+ /// <remarks>
+ /// <para>
+ /// Calls the <see cref="IAppender.DoAppend" /> method on all
+ /// attached appenders.
+ /// </para>
+ /// </remarks>
+ public int AppendLoopOnAppenders(LoggingEvent[] loggingEvents)
+ {
+ if (loggingEvents == null)
+ {
+ throw new ArgumentNullException("loggingEvents");
+ }
+ if (loggingEvents.Length == 0)
+ {
+ throw new ArgumentException("loggingEvents array must not be empty", "loggingEvents");
+ }
+ if (loggingEvents.Length == 1)
+ {
+ // Fall back to single event path
+ return AppendLoopOnAppenders(loggingEvents[0]);
+ }
- // m_appenderList is null when empty
- if (m_appenderList == null)
- {
- return 0;
- }
+ // m_appenderList is null when empty
+ if (m_appenderList == null)
+ {
+ return 0;
+ }
- if (m_appenderArray == null)
- {
- m_appenderArray = m_appenderList.ToArray();
- }
+ if (m_appenderArray == null)
+ {
+ m_appenderArray = m_appenderList.ToArray();
+ }
- foreach(IAppender appender in m_appenderArray)
- {
- try
- {
- CallAppend(appender, loggingEvents);
- }
- catch(Exception ex)
- {
- LogLog.Error(declaringType, "Failed to append to appender [" + appender.Name + "]", ex);
- }
- }
- return m_appenderList.Count;
- }
+ foreach(IAppender appender in m_appenderArray)
+ {
+ try
+ {
+ CallAppend(appender, loggingEvents);
+ }
+ catch(Exception ex)
+ {
+ LogLog.Error(declaringType, "Failed to append to appender [" + appender.Name + "]", ex);
+ }
+ }
+ return m_appenderList.Count;
+ }
- #endregion Public Instance Methods
+ #endregion Public Instance Methods
#region Private Static Methods
/// <summary>
- /// Calls the DoAppende method on the <see cref="IAppender"/> with
- /// the <see cref="LoggingEvent"/> objects supplied.
- /// </summary>
- /// <param name="appender">The appender</param>
- /// <param name="loggingEvents">The events</param>
- /// <remarks>
- /// <para>
- /// If the <paramref name="appender" /> supports the <see cref="IBulkAppender"/>
- /// interface then the <paramref name="loggingEvents" /> will be passed
- /// through using that interface. Otherwise the <see cref="LoggingEvent"/>
- /// objects in the array will be passed one at a time.
- /// </para>
- /// </remarks>
- private static void CallAppend(IAppender appender, LoggingEvent[] loggingEvents)
- {
- IBulkAppender bulkAppender = appender as IBulkAppender;
- if (bulkAppender != null)
- {
- bulkAppender.DoAppend(loggingEvents);
- }
- else
- {
- foreach(LoggingEvent loggingEvent in loggingEvents)
- {
- appender.DoAppend(loggingEvent);
- }
- }
+ /// Calls the DoAppende method on the <see cref="IAppender"/> with
+ /// the <see cref="LoggingEvent"/> objects supplied.
+ /// </summary>
+ /// <param name="appender">The appender</param>
+ /// <param name="loggingEvents">The events</param>
+ /// <remarks>
+ /// <para>
+ /// If the <paramref name="appender" /> supports the <see cref="IBulkAppender"/>
+ /// interface then the <paramref name="loggingEvents" /> will be passed
+ /// through using that interface. Otherwise the <see cref="LoggingEvent"/>
+ /// objects in the array will be passed one at a time.
+ /// </para>
+ /// </remarks>
+ private static void CallAppend(IAppender appender, LoggingEvent[] loggingEvents)
+ {
+ IBulkAppender bulkAppender = appender as IBulkAppender;
+ if (bulkAppender != null)
+ {
+ bulkAppender.DoAppend(loggingEvents);
+ }
+ else
+ {
+ foreach(LoggingEvent loggingEvent in loggingEvents)
+ {
+ appender.DoAppend(loggingEvent);
+ }
+ }
}
#endregion
@@ -190,187 +190,187 @@
#region Implementation of IAppenderAttachable
/// <summary>
- /// Attaches an appender.
- /// </summary>
- /// <param name="newAppender">The appender to add.</param>
- /// <remarks>
- /// <para>
- /// If the appender is already in the list it won't be added again.
- /// </para>
- /// </remarks>
- public void AddAppender(IAppender newAppender)
- {
- // Null values for newAppender parameter are strictly forbidden.
- if (newAppender == null)
- {
- throw new ArgumentNullException("newAppender");
- }
-
- m_appenderArray = null;
- if (m_appenderList == null)
- {
- m_appenderList = new AppenderCollection(1);
- }
- if (!m_appenderList.Contains(newAppender))
- {
- m_appenderList.Add(newAppender);
- }
- }
+ /// Attaches an appender.
+ /// </summary>
+ /// <param name="newAppender">The appender to add.</param>
+ /// <remarks>
+ /// <para>
+ /// If the appender is already in the list it won't be added again.
+ /// </para>
+ /// </remarks>
+ public void AddAppender(IAppender newAppender)
+ {
+ // Null values for newAppender parameter are strictly forbidden.
+ if (newAppender == null)
+ {
+ throw new ArgumentNullException("newAppender");
+ }
+
+ m_appenderArray = null;
+ if (m_appenderList == null)
+ {
+ m_appenderList = new AppenderCollection(1);
+ }
+ if (!m_appenderList.Contains(newAppender))
+ {
+ m_appenderList.Add(newAppender);
+ }
+ }
- /// <summary>
- /// Gets all attached appenders.
- /// </summary>
- /// <returns>
- /// A collection of attached appenders, or <c>null</c> if there
- /// are no attached appenders.
- /// </returns>
- /// <remarks>
- /// <para>
- /// The read only collection of all currently attached appenders.
- /// </para>
- /// </remarks>
- public AppenderCollection Appenders
- {
- get
- {
- if (m_appenderList == null)
- {
- // We must always return a valid collection
- return AppenderCollection.EmptyCollection;
- }
- else
- {
- return AppenderCollection.ReadOnly(m_appenderList);
- }
- }
- }
+ /// <summary>
+ /// Gets all attached appenders.
+ /// </summary>
+ /// <returns>
+ /// A collection of attached appenders, or <c>null</c> if there
+ /// are no attached appenders.
+ /// </returns>
+ /// <remarks>
+ /// <para>
+ /// The read only collection of all currently attached appenders.
+ /// </para>
+ /// </remarks>
+ public AppenderCollection Appenders
+ {
+ get
+ {
+ if (m_appenderList == null)
+ {
+ // We must always return a valid collection
+ return AppenderCollection.EmptyCollection;
+ }
+ else
+ {
+ return AppenderCollection.ReadOnly(m_appenderList);
+ }
+ }
+ }
- /// <summary>
- /// Gets an attached appender with the specified name.
- /// </summary>
- /// <param name="name">The name of the appender to get.</param>
- /// <returns>
- /// The appender with the name specified, or <c>null</c> if no appender with the
- /// specified name is found.
- /// </returns>
- /// <remarks>
- /// <para>
- /// Lookup an attached appender by name.
- /// </para>
- /// </remarks>
- public IAppender GetAppender(string name)
- {
- if (m_appenderList != null && name != null)
- {
- foreach(IAppender appender in m_appenderList)
- {
- if (name == appender.Name)
- {
- return appender;
- }
- }
- }
- return null;
- }
+ /// <summary>
+ /// Gets an attached appender with the specified name.
+ /// </summary>
+ /// <param name="name">The name of the appender to get.</param>
+ /// <returns>
+ /// The appender with the name specified, or <c>null</c> if no appender with the
+ /// specified name is found.
+ /// </returns>
+ /// <remarks>
+ /// <para>
+ /// Lookup an attached appender by name.
+ /// </para>
+ /// </remarks>
+ public IAppender GetAppender(string name)
+ {
+ if (m_appenderList != null && name != null)
+ {
+ foreach(IAppender appender in m_appenderList)
+ {
+ if (name == appender.Name)
+ {
+ return appender;
+ }
+ }
+ }
+ return null;
+ }
- /// <summary>
- /// Removes all attached appenders.
- /// </summary>
- /// <remarks>
- /// <para>
- /// Removes and closes all attached appenders
- /// </para>
- /// </remarks>
- public void RemoveAllAppenders()
- {
- if (m_appenderList != null)
- {
- foreach(IAppender appender in m_appenderList)
- {
- try
- {
- appender.Close();
- }
- catch(Exception ex)
- {
- LogLog.Error(declaringType, "Failed to Close appender ["+appender.Name+"]", ex);
- }
- }
- m_appenderList = null;
- m_appenderArray = null;
- }
- }
+ /// <summary>
+ /// Removes all attached appenders.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Removes and closes all attached appenders
+ /// </para>
+ /// </remarks>
+ public void RemoveAllAppenders()
+ {
+ if (m_appenderList != null)
+ {
+ foreach(IAppender appender in m_appenderList)
+ {
+ try
+ {
+ appender.Close();
+ }
+ catch(Exception ex)
+ {
+ LogLog.Error(declaringType, "Failed to Close appender ["+appender.Name+"]", ex);
+ }
+ }
+ m_appenderList = null;
+ m_appenderArray = null;
+ }
+ }
- /// <summary>
- /// Removes the specified appender from the list of attached appenders.
- /// </summary>
- /// <param name="appender">The appender to remove.</param>
- /// <returns>The appender removed from the list</returns>
- /// <remarks>
- /// <para>
- /// The appender removed is not closed.
- /// If you are discarding the appender you must call
- /// <see cref="IAppender.Close"/> on the appender removed.
- /// </para>
- /// </remarks>
- public IAppender RemoveAppender(IAppender appender)
- {
- if (appender != null && m_appenderList != null)
- {
- m_appenderList.Remove(appender);
- if (m_appenderList.Count == 0)
- {
- m_appenderList = null;
- }
- m_appenderArray = null;
- }
- return appender;
- }
+ /// <summary>
+ /// Removes the specified appender from the list of attached appenders.
+ /// </summary>
+ /// <param name="appender">The appender to remove.</param>
+ /// <returns>The appender removed from the list</returns>
+ /// <remarks>
+ /// <para>
+ /// The appender removed is not closed.
+ /// If you are discarding the appender you must call
+ /// <see cref="IAppender.Close"/> on the appender removed.
+ /// </para>
+ /// </remarks>
+ public IAppender RemoveAppender(IAppender appender)
+ {
+ if (appender != null && m_appenderList != null)
+ {
+ m_appenderList.Remove(appender);
+ if (m_appenderList.Count == 0)
+ {
+ m_appenderList = null;
+ }
+ m_appenderArray = null;
+ }
+ return appender;
+ }
- /// <summary>
- /// Removes the appender with the specified name from the list of appenders.
- /// </summary>
- /// <param name="name">The name of the appender to remove.</param>
- /// <returns>The appender removed from the list</returns>
- /// <remarks>
- /// <para>
- /// The appender removed is not closed.
- /// If you are discarding the appender you must call
- /// <see cref="IAppender.Close"/> on the appender removed.
- /// </para>
- /// </remarks>
- public IAppender RemoveAppender(string name)
- {
- return RemoveAppender(GetAppender(name));
- }
+ /// <summary>
+ /// Removes the appender with the specified name from the list of appenders.
+ /// </summary>
+ /// <param name="name">The name of the appender to remove.</param>
+ /// <returns>The appender removed from the list</returns>
+ /// <remarks>
+ /// <para>
+ /// The appender removed is not closed.
+ /// If you are discarding the appender you must call
+ /// <see cref="IAppender.Close"/> on the appender removed.
+ /// </para>
+ /// </remarks>
+ public IAppender RemoveAppender(string name)
+ {
+ return RemoveAppender(GetAppender(name));
+ }
- #endregion
+ #endregion
- #region Private Instance Fields
+ #region Private Instance Fields
- /// <summary>
- /// List of appenders
- /// </summary>
- private AppenderCollection m_appenderList;
+ /// <summary>
+ /// List of appenders
+ /// </summary>
+ private AppenderCollection m_appenderList;
- /// <summary>
- /// Array of appenders, used to cache the m_appenderList
- /// </summary>
- private IAppender[] m_appenderArray;
+ /// <summary>
+ /// Array of appenders, used to cache the m_appenderList
+ /// </summary>
+ private IAppender[] m_appenderArray;
- #endregion Private Instance Fields
+ #endregion Private Instance Fields
- #region Private Static Fields
+ #region Private Static Fields
- /// <summary>
- /// The fully qualified type of the AppenderAttachedImpl class.
- /// </summary>
- /// <remarks>
- /// Used by the internal logger to record the Type of the
- /// log message.
- /// </remarks>
- private static readonly Type declaringType = typeof(AppenderAttachedImpl);
+ /// <summary>
+ /// The fully qualified type of the AppenderAttachedImpl class.
+ /// </summary>
+ /// <remarks>
+ /// Used by the internal logger to record the Type of the
+ /// log message.
+ /// </remarks>
+ private static readonly Type declaringType = typeof(AppenderAttachedImpl);
- #endregion Private Static Fields
- }
+ #endregion Private Static Fields
+ }
}
diff --git a/src/log4net/Util/CompositeProperties.cs b/src/log4net/Util/CompositeProperties.cs
index b491197..987661c 100644
--- a/src/log4net/Util/CompositeProperties.cs
+++ b/src/log4net/Util/CompositeProperties.cs
@@ -22,134 +22,134 @@
namespace log4net.Util
{
- /// <summary>
- /// This class aggregates several PropertiesDictionary collections together.
- /// </summary>
- /// <remarks>
- /// <para>
- /// Provides a dictionary style lookup over an ordered list of
- /// <see cref="PropertiesDictionary"/> collections.
- /// </para>
- /// </remarks>
- /// <author>Nicko Cadell</author>
- public sealed class CompositeProperties
- {
- #region Private Instance Fields
+ /// <summary>
+ /// This class aggregates several PropertiesDictionary collections together.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Provides a dictionary style lookup over an ordered list of
+ /// <see cref="PropertiesDictionary"/> collections.
+ /// </para>
+ /// </remarks>
+ /// <author>Nicko Cadell</author>
+ public sealed class CompositeProperties
+ {
+ #region Private Instance Fields
- private PropertiesDictionary m_flattened = null;
- private ArrayList m_nestedProperties = new ArrayList();
+ private PropertiesDictionary m_flattened = null;
+ private ArrayList m_nestedProperties = new ArrayList();
- #endregion Private Instance Fields
+ #endregion Private Instance Fields
- #region Public Instance Constructors
+ #region Public Instance Constructors
- /// <summary>
- /// Constructor
- /// </summary>
- /// <remarks>
- /// <para>
- /// Initializes a new instance of the <see cref="CompositeProperties" /> class.
- /// </para>
- /// </remarks>
- internal CompositeProperties()
- {
- }
+ /// <summary>
+ /// Constructor
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Initializes a new instance of the <see cref="CompositeProperties" /> class.
+ /// </para>
+ /// </remarks>
+ internal CompositeProperties()
+ {
+ }
- #endregion Public Instance Constructors
+ #endregion Public Instance Constructors
- #region Public Instance Properties
+ #region Public Instance Properties
- /// <summary>
- /// Gets the value of a property
- /// </summary>
- /// <value>
- /// The value for the property with the specified key
- /// </value>
- /// <remarks>
- /// <para>
- /// Looks up the value for the <paramref name="key" /> specified.
- /// The <see cref="PropertiesDictionary"/> collections are searched
- /// in the order in which they were added to this collection. The value
- /// returned is the value held by the first collection that contains
- /// the specified key.
- /// </para>
- /// <para>
- /// If none of the collections contain the specified key then
- /// <c>null</c> is returned.
- /// </para>
- /// </remarks>
- public object this[string key]
- {
- get
- {
- // Look in the flattened properties first
- if (m_flattened != null)
- {
- return m_flattened[key];
- }
+ /// <summary>
+ /// Gets the value of a property
+ /// </summary>
+ /// <value>
+ /// The value for the property with the specified key
+ /// </value>
+ /// <remarks>
+ /// <para>
+ /// Looks up the value for the <paramref name="key" /> specified.
+ /// The <see cref="PropertiesDictionary"/> collections are searched
+ /// in the order in which they were added to this collection. The value
+ /// returned is the value held by the first collection that contains
+ /// the specified key.
+ /// </para>
+ /// <para>
+ /// If none of the collections contain the specified key then
+ /// <c>null</c> is returned.
+ /// </para>
+ /// </remarks>
+ public object this[string key]
+ {
+ get
+ {
+ // Look in the flattened properties first
+ if (m_flattened != null)
+ {
+ return m_flattened[key];
+ }
- // Look for the key in all the nested properties
- foreach(ReadOnlyPropertiesDictionary cur in m_nestedProperties)
- {
- if (cur.Contains(key))
- {
- return cur[key];
- }
- }
- return null;
- }
- }
+ // Look for the key in all the nested properties
+ foreach(ReadOnlyPropertiesDictionary cur in m_nestedProperties)
+ {
+ if (cur.Contains(key))
+ {
+ return cur[key];
+ }
+ }
+ return null;
+ }
+ }
- #endregion Public Instance Properties
+ #endregion Public Instance Properties
- #region Public Instance Methods
+ #region Public Instance Methods
- /// <summary>
- /// Add a Properties Dictionary to this composite collection
- /// </summary>
- /// <param name="properties">the properties to add</param>
- /// <remarks>
- /// <para>
- /// Properties dictionaries added first take precedence over dictionaries added
- /// later.
- /// </para>
- /// </remarks>
- public void Add(ReadOnlyPropertiesDictionary properties)
- {
- m_flattened = null;
- m_nestedProperties.Add(properties);
- }
+ /// <summary>
+ /// Add a Properties Dictionary to this composite collection
+ /// </summary>
+ /// <param name="properties">the properties to add</param>
+ /// <remarks>
+ /// <para>
+ /// Properties dictionaries added first take precedence over dictionaries added
+ /// later.
+ /// </para>
+ /// </remarks>
+ public void Add(ReadOnlyPropertiesDictionary properties)
+ {
+ m_flattened = null;
+ m_nestedProperties.Add(properties);
+ }
- /// <summary>
- /// Flatten this composite collection into a single properties dictionary
- /// </summary>
- /// <returns>the flattened dictionary</returns>
- /// <remarks>
- /// <para>
- /// Reduces the collection of ordered dictionaries to a single dictionary
- /// containing the resultant values for the keys.
- /// </para>
- /// </remarks>
- public PropertiesDictionary Flatten()
- {
- if (m_flattened == null)
- {
- m_flattened = new PropertiesDictionary();
+ /// <summary>
+ /// Flatten this composite collection into a single properties dictionary
+ /// </summary>
+ /// <returns>the flattened dictionary</returns>
+ /// <remarks>
+ /// <para>
+ /// Reduces the collection of ordered dictionaries to a single dictionary
+ /// containing the resultant values for the keys.
+ /// </para>
+ /// </remarks>
+ public PropertiesDictionary Flatten()
+ {
+ if (m_flattened == null)
+ {
+ m_flattened = new PropertiesDictionary();
- for(int i=m_nestedProperties.Count; --i>=0; )
- {
- ReadOnlyPropertiesDictionary cur = (ReadOnlyPropertiesDictionary)m_nestedProperties[i];
+ for(int i=m_nestedProperties.Count; --i>=0; )
+ {
+ ReadOnlyPropertiesDictionary cur = (ReadOnlyPropertiesDictionary)m_nestedProperties[i];
- foreach(DictionaryEntry entry in cur)
- {
- m_flattened[(string)entry.Key] = entry.Value;
- }
- }
- }
- return m_flattened;
- }
+ foreach(DictionaryEntry entry in cur)
+ {
+ m_flattened[(string)entry.Key] = entry.Value;
+ }
+ }
+ }
+ return m_flattened;
+ }
- #endregion Public Instance Methods
- }
+ #endregion Public Instance Methods
+ }
}
diff --git a/src/log4net/Util/ContextPropertiesBase.cs b/src/log4net/Util/ContextPropertiesBase.cs
index 9d79fee..4727461 100644
--- a/src/log4net/Util/ContextPropertiesBase.cs
+++ b/src/log4net/Util/ContextPropertiesBase.cs
@@ -22,29 +22,29 @@
namespace log4net.Util
{
- /// <summary>
- /// Base class for Context Properties implementations
- /// </summary>
- /// <remarks>
- /// <para>
- /// This class defines a basic property get set accessor
- /// </para>
- /// </remarks>
- /// <author>Nicko Cadell</author>
- public abstract class ContextPropertiesBase
- {
- /// <summary>
- /// Gets or sets the value of a property
- /// </summary>
- /// <value>
- /// The value for the property with the specified key
- /// </value>
- /// <remarks>
- /// <para>
- /// Gets or sets the value of a property
- /// </para>
- /// </remarks>
- public abstract object this[string key] { get; set; }
- }
+ /// <summary>
+ /// Base class for Context Properties implementations
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// This class defines a basic property get set accessor
+ /// </para>
+ /// </remarks>
+ /// <author>Nicko Cadell</author>
+ public abstract class ContextPropertiesBase
+ {
+ /// <summary>
+ /// Gets or sets the value of a property
+ /// </summary>
+ /// <value>
+ /// The value for the property with the specified key
+ /// </value>
+ /// <remarks>
+ /// <para>
+ /// Gets or sets the value of a property
+ /// </para>
+ /// </remarks>
+ public abstract object this[string key] { get; set; }
+ }
}
diff --git a/src/log4net/Util/CountingQuietTextWriter.cs b/src/log4net/Util/CountingQuietTextWriter.cs
index e0c2925..505163a 100644
--- a/src/log4net/Util/CountingQuietTextWriter.cs
+++ b/src/log4net/Util/CountingQuietTextWriter.cs
@@ -24,157 +24,157 @@
namespace log4net.Util
{
- /// <summary>
- /// Subclass of <see cref="QuietTextWriter"/> that maintains a count of
- /// the number of bytes written.
- /// </summary>
- /// <remarks>
- /// <para>
- /// This writer counts the number of bytes written.
- /// </para>
- /// </remarks>
- /// <author>Nicko Cadell</author>
- /// <author>Gert Driesen</author>
- public class CountingQuietTextWriter : QuietTextWriter
- {
- #region Public Instance Constructors
+ /// <summary>
+ /// Subclass of <see cref="QuietTextWriter"/> that maintains a count of
+ /// the number of bytes written.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// This writer counts the number of bytes written.
+ /// </para>
+ /// </remarks>
+ /// <author>Nicko Cadell</author>
+ /// <author>Gert Driesen</author>
+ public class CountingQuietTextWriter : QuietTextWriter
+ {
+ #region Public Instance Constructors
- /// <summary>
- /// Constructor
- /// </summary>
- /// <param name="writer">The <see cref="TextWriter" /> to actually write to.</param>
- /// <param name="errorHandler">The <see cref="IErrorHandler" /> to report errors to.</param>
- /// <remarks>
- /// <para>
- /// Creates a new instance of the <see cref="CountingQuietTextWriter" /> class
- /// with the specified <see cref="TextWriter" /> and <see cref="IErrorHandler" />.
- /// </para>
- /// </remarks>
- public CountingQuietTextWriter(TextWriter writer, IErrorHandler errorHandler) : base(writer, errorHandler)
- {
- m_countBytes = 0;
- }
+ /// <summary>
+ /// Constructor
+ /// </summary>
+ /// <param name="writer">The <see cref="TextWriter" /> to actually write to.</param>
+ /// <param name="errorHandler">The <see cref="IErrorHandler" /> to report errors to.</param>
+ /// <remarks>
+ /// <para>
+ /// Creates a new instance of the <see cref="CountingQuietTextWriter" /> class
+ /// with the specified <see cref="TextWriter" /> and <see cref="IErrorHandler" />.
+ /// </para>
+ /// </remarks>
+ public CountingQuietTextWriter(TextWriter writer, IErrorHandler errorHandler) : base(writer, errorHandler)
+ {
+ m_countBytes = 0;
+ }
- #endregion Public Instance Constructors
+ #endregion Public Instance Constructors
- #region Override implementation of QuietTextWriter
+ #region Override implementation of QuietTextWriter
- /// <summary>
- /// Writes a character to the underlying writer and counts the number of bytes written.
- /// </summary>
- /// <param name="value">the char to write</param>
- /// <remarks>
- /// <para>
- /// Overrides implementation of <see cref="QuietTextWriter"/>. Counts
- /// the number of bytes written.
- /// </para>
- /// </remarks>
- public override void Write(char value)
- {
- try
- {
- base.Write(value);
+ /// <summary>
+ /// Writes a character to the underlying writer and counts the number of bytes written.
+ /// </summary>
+ /// <param name="value">the char to write</param>
+ /// <remarks>
+ /// <para>
+ /// Overrides implementation of <see cref="QuietTextWriter"/>. Counts
+ /// the number of bytes written.
+ /// </para>
+ /// </remarks>
+ public override void Write(char value)
+ {
+ try
+ {
+ base.Write(value);
- // get the number of bytes needed to represent the
- // char using the supplied encoding.
- m_countBytes += this.Encoding.GetByteCount(new char[] { value });
- }
- catch(Exception e)
- {
- this.ErrorHandler.Error("Failed to write [" + value + "].", e, ErrorCode.WriteFailure);
- }
- }
+ // get the number of bytes needed to represent the
+ // char using the supplied encoding.
+ m_countBytes += this.Encoding.GetByteCount(new char[] { value });
+ }
+ catch(Exception e)
+ {
+ this.ErrorHandler.Error("Failed to write [" + value + "].", e, ErrorCode.WriteFailure);
+ }
+ }
- /// <summary>
- /// Writes a buffer to the underlying writer and counts the number of bytes written.
- /// </summary>
- /// <param name="buffer">the buffer to write</param>
- /// <param name="index">the start index to write from</param>
- /// <param name="count">the number of characters to write</param>
- /// <remarks>
- /// <para>
- /// Overrides implementation of <see cref="QuietTextWriter"/>. Counts
- /// the number of bytes written.
- /// </para>
- /// </remarks>
- public override void Write(char[] buffer, int index, int count)
- {
- if (count > 0)
- {
- try
- {
- base.Write(buffer, index, count);
+ /// <summary>
+ /// Writes a buffer to the underlying writer and counts the number of bytes written.
+ /// </summary>
+ /// <param name="buffer">the buffer to write</param>
+ /// <param name="index">the start index to write from</param>
+ /// <param name="count">the number of characters to write</param>
+ /// <remarks>
+ /// <para>
+ /// Overrides implementation of <see cref="QuietTextWriter"/>. Counts
+ /// the number of bytes written.
+ /// </para>
+ /// </remarks>
+ public override void Write(char[] buffer, int index, int count)
+ {
+ if (count > 0)
+ {
+ try
+ {
+ base.Write(buffer, index, count);
- // get the number of bytes needed to represent the
- // char array using the supplied encoding.
- m_countBytes += this.Encoding.GetByteCount(buffer, index, count);
- }
- catch(Exception e)
- {
- this.ErrorHandler.Error("Failed to write buffer.", e, ErrorCode.WriteFailure);
- }
- }
- }
+ // get the number of bytes needed to represent the
+ // char array using the supplied encoding.
+ m_countBytes += this.Encoding.GetByteCount(buffer, index, count);
+ }
+ catch(Exception e)
+ {
+ this.ErrorHandler.Error("Failed to write buffer.", e, ErrorCode.WriteFailure);
+ }
+ }
+ }
- /// <summary>
- /// Writes a string to the output and counts the number of bytes written.
- /// </summary>
- /// <param name="str">The string data to write to the output.</param>
- /// <remarks>
- /// <para>
- /// Overrides implementation of <see cref="QuietTextWriter"/>. Counts
- /// the number of bytes written.
- /// </para>
- /// </remarks>
- public override void Write(string str)
- {
- if (str != null && str.Length > 0)
- {
- try
- {
- base.Write(str);
+ /// <summary>
+ /// Writes a string to the output and counts the number of bytes written.
+ /// </summary>
+ /// <param name="str">The string data to write to the output.</param>
+ /// <remarks>
+ /// <para>
+ /// Overrides implementation of <see cref="QuietTextWriter"/>. Counts
+ /// the number of bytes written.
+ /// </para>
+ /// </remarks>
+ public override void Write(string str)
+ {
+ if (str != null && str.Length > 0)
+ {
+ try
+ {
+ base.Write(str);
- // get the number of bytes needed to represent the
- // string using the supplied encoding.
- m_countBytes += this.Encoding.GetByteCount(str);
- }
- catch(Exception e)
- {
- this.ErrorHandler.Error("Failed to write [" + str + "].", e, ErrorCode.WriteFailure);
- }
- }
- }
-
- #endregion Override implementation of QuietTextWriter
+ // get the number of bytes needed to represent the
+ // string using the supplied encoding.
+ m_countBytes += this.Encoding.GetByteCount(str);
+ }
+ catch(Exception e)
+ {
+ this.ErrorHandler.Error("Failed to write [" + str + "].", e, ErrorCode.WriteFailure);
+ }
+ }
+ }
+
+ #endregion Override implementation of QuietTextWriter
- #region Public Instance Properties
+ #region Public Instance Properties
- /// <summary>
- /// Gets or sets the total number of bytes written.
- /// </summary>
- /// <value>
- /// The total number of bytes written.
- /// </value>
- /// <remarks>
- /// <para>
- /// Gets or sets the total number of bytes written.
- /// </para>
- /// </remarks>
- public long Count
- {
- get { return m_countBytes; }
- set { m_countBytes = value; }
- }
+ /// <summary>
+ /// Gets or sets the total number of bytes written.
+ /// </summary>
+ /// <value>
+ /// The total number of bytes written.
+ /// </value>
+ /// <remarks>
+ /// <para>
+ /// Gets or sets the total number of bytes written.
+ /// </para>
+ /// </remarks>
+ public long Count
+ {
+ get { return m_countBytes; }
+ set { m_countBytes = value; }
+ }
- #endregion Public Instance Properties
+ #endregion Public Instance Properties
- #region Private Instance Fields
+ #region Private Instance Fields
- /// <summary>
- /// Total number of bytes written.
- /// </summary>
- private long m_countBytes;
+ /// <summary>
+ /// Total number of bytes written.
+ /// </summary>
+ private long m_countBytes;
- #endregion Private Instance Fields
- }
+ #endregion Private Instance Fields
+ }
}
diff --git a/src/log4net/Util/CyclicBuffer.cs b/src/log4net/Util/CyclicBuffer.cs
index bc8c902..ca5ca70 100644
--- a/src/log4net/Util/CyclicBuffer.cs
+++ b/src/log4net/Util/CyclicBuffer.cs
@@ -23,333 +23,333 @@
namespace log4net.Util
{
- /// <summary>
- /// A fixed size rolling buffer of logging events.
- /// </summary>
- /// <remarks>
- /// <para>
- /// An array backed fixed size leaky bucket.
- /// </para>
- /// </remarks>
- /// <author>Nicko Cadell</author>
- /// <author>Gert Driesen</author>
- public class CyclicBuffer
- {
- #region Public Instance Constructors
+ /// <summary>
+ /// A fixed size rolling buffer of logging events.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// An array backed fixed size leaky bucket.
+ /// </para>
+ /// </remarks>
+ /// <author>Nicko Cadell</author>
+ /// <author>Gert Driesen</author>
+ public class CyclicBuffer
+ {
+ #region Public Instance Constructors
- /// <summary>
- /// Constructor
- /// </summary>
- /// <param name="maxSize">The maximum number of logging events in the buffer.</param>
- /// <remarks>
- /// <para>
- /// Initializes a new instance of the <see cref="CyclicBuffer" /> class with
- /// the specified maximum number of buffered logging events.
- /// </para>
- /// </remarks>
- /// <exception cref="ArgumentOutOfRangeException">The <paramref name="maxSize"/> argument is not a positive integer.</exception>
- public CyclicBuffer(int maxSize)
- {
- if (maxSize < 1)
- {
- throw SystemInfo.CreateArgumentOutOfRangeException("maxSize", (object)maxSize, "Parameter: maxSize, Value: [" + maxSize + "] out of range. Non zero positive integer required");
- }
+ /// <summary>
+ /// Constructor
+ /// </summary>
+ /// <param name="maxSize">The maximum number of logging events in the buffer.</param>
+ /// <remarks>
+ /// <para>
+ /// Initializes a new instance of the <see cref="CyclicBuffer" /> class with
+ /// the specified maximum number of buffered logging events.
+ /// </para>
+ /// </remarks>
+ /// <exception cref="ArgumentOutOfRangeException">The <paramref name="maxSize"/> argument is not a positive integer.</exception>
+ public CyclicBuffer(int maxSize)
+ {
+ if (maxSize < 1)
+ {
+ throw SystemInfo.CreateArgumentOutOfRangeException("maxSize", (object)maxSize, "Parameter: maxSize, Value: [" + maxSize + "] out of range. Non zero positive integer required");
+ }
- m_maxSize = maxSize;
- m_events = new LoggingEvent[maxSize];
- m_first = 0;
- m_last = 0;
- m_numElems = 0;
- }
+ m_maxSize = maxSize;
+ m_events = new LoggingEvent[maxSize];
+ m_first = 0;
+ m_last = 0;
+ m_numElems = 0;
+ }
- #endregion Public Instance Constructors
+ #endregion Public Instance Constructors
- #region Public Instance Methods
-
- /// <summary>
- /// Appends a <paramref name="loggingEvent"/> to the buffer.
- /// </summary>
- /// <param name="loggingEvent">The event to append to the buffer.</param>
- /// <returns>The event discarded from the buffer, if the buffer is full, otherwise <c>null</c>.</returns>
- /// <remarks>
- /// <para>
- /// Append an event to the buffer. If the buffer still contains free space then
- /// <c>null</c> is returned. If the buffer is full then an event will be dropped
- /// to make space for the new event, the event dropped is returned.
- /// </para>
- /// </remarks>
- public LoggingEvent Append(LoggingEvent loggingEvent)
- {
- if (loggingEvent == null)
- {
- throw new ArgumentNullException("loggingEvent");
- }
+ #region Public Instance Methods
+
+ /// <summary>
+ /// Appends a <paramref name="loggingEvent"/> to the buffer.
+ /// </summary>
+ /// <param name="loggingEvent">The event to append to the buffer.</param>
+ /// <returns>The event discarded from the buffer, if the buffer is full, otherwise <c>null</c>.</returns>
+ /// <remarks>
+ /// <para>
+ /// Append an event to the buffer. If the buffer still contains free space then
+ /// <c>null</c> is returned. If the buffer is full then an event will be dropped
+ /// to make space for the new event, the event dropped is returned.
+ /// </para>
+ /// </remarks>
+ public LoggingEvent Append(LoggingEvent loggingEvent)
+ {
+ if (loggingEvent == null)
+ {
+ throw new ArgumentNullException("loggingEvent");
+ }
- lock(this)
- {
- // save the discarded event
- LoggingEvent discardedLoggingEvent = m_events[m_last];
+ lock(this)
+ {
+ // save the discarded event
+ LoggingEvent discardedLoggingEvent = m_events[m_last];
- // overwrite the last event position
- m_events[m_last] = loggingEvent;
- if (++m_last == m_maxSize)
- {
- m_last = 0;
- }
+ // overwrite the last event position
+ m_events[m_last] = loggingEvent;
+ if (++m_last == m_maxSize)
+ {
+ m_last = 0;
+ }
- if (m_numElems < m_maxSize)
- {
- m_numElems++;
- }
- else if (++m_first == m_maxSize)
- {
- m_first = 0;
- }
+ if (m_numElems < m_maxSize)
+ {
+ m_numElems++;
+ }
+ else if (++m_first == m_maxSize)
+ {
+ m_first = 0;
+ }
- if (m_numElems < m_maxSize)
- {
- // Space remaining
- return null;
- }
- else
- {
- // Buffer is full and discarding an event
- return discardedLoggingEvent;
- }
- }
- }
+ if (m_numElems < m_maxSize)
+ {
+ // Space remaining
+ return null;
+ }
+ else
+ {
+ // Buffer is full and discarding an event
+ return discardedLoggingEvent;
+ }
+ }
+ }
- /// <summary>
- /// Get and remove the oldest event in the buffer.
- /// </summary>
- /// <returns>The oldest logging event in the buffer</returns>
- /// <remarks>
- /// <para>
- /// Gets the oldest (first) logging event in the buffer and removes it
- /// from the buffer.
- /// </para>
- /// </remarks>
- public LoggingEvent PopOldest()
- {
- lock(this)
- {
- LoggingEvent ret = null;
- if (m_numElems > 0)
- {
- m_numElems--;
- ret = m_events[m_first];
- m_events[m_first] = null;
- if (++m_first == m_maxSize)
- {
- m_first = 0;
- }
- }
- return ret;
- }
- }
+ /// <summary>
+ /// Get and remove the oldest event in the buffer.
+ /// </summary>
+ /// <returns>The oldest logging event in the buffer</returns>
+ /// <remarks>
+ /// <para>
+ /// Gets the oldest (first) logging event in the buffer and removes it
+ /// from the buffer.
+ /// </para>
+ /// </remarks>
+ public LoggingEvent PopOldest()
+ {
+ lock(this)
+ {
+ LoggingEvent ret = null;
+ if (m_numElems > 0)
+ {
+ m_numElems--;
+ ret = m_events[m_first];
+ m_events[m_first] = null;
+ if (++m_first == m_maxSize)
+ {
+ m_first = 0;
+ }
+ }
+ return ret;
+ }
+ }
- /// <summary>
- /// Pops all the logging events from the buffer into an array.
- /// </summary>
- /// <returns>An array of all the logging events in the buffer.</returns>
- /// <remarks>
- /// <para>
- /// Get all the events in the buffer and clear the buffer.
- /// </para>
- /// </remarks>
- public LoggingEvent[] PopAll()
- {
- lock(this)
- {
- LoggingEvent[] ret = new LoggingEvent[m_numElems];
+ /// <summary>
+ /// Pops all the logging events from the buffer into an array.
+ /// </summary>
+ /// <returns>An array of all the logging events in the buffer.</returns>
+ /// <remarks>
+ /// <para>
+ /// Get all the events in the buffer and clear the buffer.
+ /// </para>
+ /// </remarks>
+ public LoggingEvent[] PopAll()
+ {
+ lock(this)
+ {
+ LoggingEvent[] ret = new LoggingEvent[m_numElems];
- if (m_numElems > 0)
- {
- if (m_first < m_last)
- {
- Array.Copy(m_events, m_first, ret, 0, m_numElems);
- }
- else
- {
- Array.Copy(m_events, m_first, ret, 0, m_maxSize - m_first);
- Array.Copy(m_events, 0, ret, m_maxSize - m_first, m_last);
- }
- }
+ if (m_numElems > 0)
+ {
+ if (m_first < m_last)
+ {
+ Array.Copy(m_events, m_first, ret, 0, m_numElems);
+ }
+ else
+ {
+ Array.Copy(m_events, m_first, ret, 0, m_maxSize - m_first);
+ Array.Copy(m_events, 0, ret, m_maxSize - m_first, m_last);
+ }
+ }
- Clear();
+ Clear();
- return ret;
- }
- }
+ return ret;
+ }
+ }
- /// <summary>
- /// Clear the buffer
- /// </summary>
- /// <remarks>
- /// <para>
- /// Clear the buffer of all events. The events in the buffer are lost.
- /// </para>
- /// </remarks>
- public void Clear()
- {
- lock(this)
- {
- // Set all the elements to null
- Array.Clear(m_events, 0, m_events.Length);
+ /// <summary>
+ /// Clear the buffer
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Clear the buffer of all events. The events in the buffer are lost.
+ /// </para>
+ /// </remarks>
+ public void Clear()
+ {
+ lock(this)
+ {
+ // Set all the elements to null
+ Array.Clear(m_events, 0, m_events.Length);
- m_first = 0;
- m_last = 0;
- m_numElems = 0;
- }
- }
+ m_first = 0;
+ m_last = 0;
+ m_numElems = 0;
+ }
+ }
#if RESIZABLE_CYCLIC_BUFFER
- /// <summary>
- /// Resizes the cyclic buffer to <paramref name="newSize"/>.
- /// </summary>
- /// <param name="newSize">The new size of the buffer.</param>
- /// <remarks>
- /// <para>
- /// Resize the cyclic buffer. Events in the buffer are copied into
- /// the newly sized buffer. If the buffer is shrunk and there are
- /// more events currently in the buffer than the new size of the
- /// buffer then the newest events will be dropped from the buffer.
- /// </para>
- /// </remarks>
- /// <exception cref="ArgumentOutOfRangeException">The <paramref name="newSize"/> argument is not a positive integer.</exception>
- public void Resize(int newSize)
- {
- lock(this)
- {
- if (newSize < 0)
- {
- throw log4net.Util.SystemInfo.CreateArgumentOutOfRangeException("newSize", (object)newSize, "Parameter: newSize, Value: [" + newSize + "] out of range. Non zero positive integer required");
- }
- if (newSize == m_numElems)
- {
- return; // nothing to do
- }
-
- LoggingEvent[] temp = new LoggingEvent[newSize];
+ /// <summary>
+ /// Resizes the cyclic buffer to <paramref name="newSize"/>.
+ /// </summary>
+ /// <param name="newSize">The new size of the buffer.</param>
+ /// <remarks>
+ /// <para>
+ /// Resize the cyclic buffer. Events in the buffer are copied into
+ /// the newly sized buffer. If the buffer is shrunk and there are
+ /// more events currently in the buffer than the new size of the
+ /// buffer then the newest events will be dropped from the buffer.
+ /// </para>
+ /// </remarks>
+ /// <exception cref="ArgumentOutOfRangeException">The <paramref name="newSize"/> argument is not a positive integer.</exception>
+ public void Resize(int newSize)
+ {
+ lock(this)
+ {
+ if (newSize < 0)
+ {
+ throw log4net.Util.SystemInfo.CreateArgumentOutOfRangeException("newSize", (object)newSize, "Parameter: newSize, Value: [" + newSize + "] out of range. Non zero positive integer required");
+ }
+ if (newSize == m_numElems)
+ {
+ return; // nothing to do
+ }
+
+ LoggingEvent[] temp = new LoggingEvent[newSize];
- int loopLen = (newSize < m_numElems) ? newSize : m_numElems;
-
- for(int i = 0; i < loopLen; i++)
- {
- temp[i] = m_events[m_first];
- m_events[m_first] = null;
+ int loopLen = (newSize < m_numElems) ? newSize : m_numElems;
+
+ for(int i = 0; i < loopLen; i++)
+ {
+ temp[i] = m_events[m_first];
+ m_events[m_first] = null;
- if (++m_first == m_numElems)
- {
- m_first = 0;
- }
- }
+ if (++m_first == m_numElems)
+ {
+ m_first = 0;
+ }
+ }
- m_events = temp;
- m_first = 0;
- m_numElems = loopLen;
- m_maxSize = newSize;
+ m_events = temp;
+ m_first = 0;
+ m_numElems = loopLen;
+ m_maxSize = newSize;
- if (loopLen == newSize)
- {
- m_last = 0;
- }
- else
- {
- m_last = loopLen;
- }
- }
- }
+ if (loopLen == newSize)
+ {
+ m_last = 0;
+ }
+ else
+ {
+ m_last = loopLen;
+ }
+ }
+ }
#endif
- #endregion Public Instance Methods
+ #endregion Public Instance Methods
- #region Public Instance Properties
+ #region Public Instance Properties
- /// <summary>
- /// Gets the <paramref name="i"/>th oldest event currently in the buffer.
- /// </summary>
- /// <value>The <paramref name="i"/>th oldest event currently in the buffer.</value>
- /// <remarks>
- /// <para>
- /// If <paramref name="i"/> is outside the range 0 to the number of events
- /// currently in the buffer, then <c>null</c> is returned.
- /// </para>
- /// </remarks>
- public LoggingEvent this[int i]
- {
- get
- {
- lock(this)
- {
- if (i < 0 || i >= m_numElems)
- {
- return null;
- }
+ /// <summary>
+ /// Gets the <paramref name="i"/>th oldest event currently in the buffer.
+ /// </summary>
+ /// <value>The <paramref name="i"/>th oldest event currently in the buffer.</value>
+ /// <remarks>
+ /// <para>
+ /// If <paramref name="i"/> is outside the range 0 to the number of events
+ /// currently in the buffer, then <c>null</c> is returned.
+ /// </para>
+ /// </remarks>
+ public LoggingEvent this[int i]
+ {
+ get
+ {
+ lock(this)
+ {
+ if (i < 0 || i >= m_numElems)
+ {
+ return null;
+ }
- return m_events[(m_first + i) % m_maxSize];
- }
- }
- }
+ return m_events[(m_first + i) % m_maxSize];
+ }
+ }
+ }
- /// <summary>
- /// Gets the maximum size of the buffer.
- /// </summary>
- /// <value>The maximum size of the buffer.</value>
- /// <remarks>
- /// <para>
- /// Gets the maximum size of the buffer
- /// </para>
- /// </remarks>
- public int MaxSize
- {
- get
- {
- lock(this)
- {
- return m_maxSize;
- }
- }
+ /// <summary>
+ /// Gets the maximum size of the buffer.
+ /// </summary>
+ /// <value>The maximum size of the buffer.</value>
+ /// <remarks>
+ /// <para>
+ /// Gets the maximum size of the buffer
+ /// </para>
+ /// </remarks>
+ public int MaxSize
+ {
+ get
+ {
+ lock(this)
+ {
+ return m_maxSize;
+ }
+ }
#if RESIZABLE_CYCLIC_BUFFER
- set
- {
- /// Setting the MaxSize will cause the buffer to resize.
- Resize(value);
- }
+ set
+ {
+ /// Setting the MaxSize will cause the buffer to resize.
+ Resize(value);
+ }
#endif
- }
+ }
- /// <summary>
- /// Gets the number of logging events in the buffer.
- /// </summary>
- /// <value>The number of logging events in the buffer.</value>
- /// <remarks>
- /// <para>
- /// This number is guaranteed to be in the range 0 to <see cref="MaxSize"/>
- /// (inclusive).
- /// </para>
- /// </remarks>
- public int Length
- {
- get
- {
- lock(this)
- {
- return m_numElems;
- }
- }
- }
+ /// <summary>
+ /// Gets the number of logging events in the buffer.
+ /// </summary>
+ /// <value>The number of logging events in the buffer.</value>
+ /// <remarks>
+ /// <para>
+ /// This number is guaranteed to be in the range 0 to <see cref="MaxSize"/>
+ /// (inclusive).
+ /// </para>
+ /// </remarks>
+ public int Length
+ {
+ get
+ {
+ lock(this)
+ {
+ return m_numElems;
+ }
+ }
+ }
- #endregion Public Instance Properties
+ #endregion Public Instance Properties
- #region Private Instance Fields
+ #region Private Instance Fields
- private LoggingEvent[] m_events;
- private int m_first;
- private int m_last;
- private int m_numElems;
- private int m_maxSize;
+ private LoggingEvent[] m_events;
+ private int m_first;
+ private int m_last;
+ private int m_numElems;
+ private int m_maxSize;
- #endregion Private Instance Fields
- }
+ #endregion Private Instance Fields
+ }
}
diff --git a/src/log4net/Util/EmptyCollection.cs b/src/log4net/Util/EmptyCollection.cs
index 1222587..2f019dd 100644
--- a/src/log4net/Util/EmptyCollection.cs
+++ b/src/log4net/Util/EmptyCollection.cs
@@ -22,157 +22,157 @@
namespace log4net.Util
{
- /// <summary>
- /// An always empty <see cref="ICollection"/>.
- /// </summary>
- /// <remarks>
- /// <para>
- /// A singleton implementation of the <see cref="ICollection"/>
- /// interface that always represents an empty collection.
- /// </para>
- /// </remarks>
- /// <author>Nicko Cadell</author>
- /// <author>Gert Driesen</author>
+ /// <summary>
+ /// An always empty <see cref="ICollection"/>.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// A singleton implementation of the <see cref="ICollection"/>
+ /// interface that always represents an empty collection.
+ /// </para>
+ /// </remarks>
+ /// <author>Nicko Cadell</author>
+ /// <author>Gert Driesen</author>
#if !NETCF
- [Serializable]
+ [Serializable]
#endif
- public sealed class EmptyCollection : ICollection
- {
- #region Private Instance Constructors
+ public sealed class EmptyCollection : ICollection
+ {
+ #region Private Instance Constructors
- /// <summary>
- /// Initializes a new instance of the <see cref="EmptyCollection" /> class.
- /// </summary>
- /// <remarks>
- /// <para>
- /// Uses a private access modifier to enforce the singleton pattern.
- /// </para>
- /// </remarks>
- private EmptyCollection()
- {
- }
+ /// <summary>
+ /// Initializes a new instance of the <see cref="EmptyCollection" /> class.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Uses a private access modifier to enforce the singleton pattern.
+ /// </para>
+ /// </remarks>
+ private EmptyCollection()
+ {
+ }
- #endregion Private Instance Constructors
+ #endregion Private Instance Constructors
- #region Public Static Properties
+ #region Public Static Properties
- /// <summary>
- /// Gets the singleton instance of the empty collection.
- /// </summary>
- /// <returns>The singleton instance of the empty collection.</returns>
- /// <remarks>
- /// <para>
- /// Gets the singleton instance of the empty collection.
- /// </para>
- /// </remarks>
- public static EmptyCollection Instance
- {
- get { return s_instance; }
- }
+ /// <summary>
+ /// Gets the singleton instance of the empty collection.
+ /// </summary>
+ /// <returns>The singleton instance of the empty collection.</returns>
+ /// <remarks>
+ /// <para>
+ /// Gets the singleton instance of the empty collection.
+ /// </para>
+ /// </remarks>
+ public static EmptyCollection Instance
+ {
+ get { return s_instance; }
+ }
- #endregion Public Static Properties
+ #endregion Public Static Properties
- #region Implementation of ICollection
+ #region Implementation of ICollection
- /// <summary>
- /// Copies the elements of the <see cref="ICollection"/> to an
- /// <see cref="Array"/>, starting at a particular Array index.
- /// </summary>
- /// <param name="array">The one-dimensional <see cref="Array"/>
- /// that is the destination of the elements copied from
- /// <see cref="ICollection"/>. The Array must have zero-based
- /// indexing.</param>
- /// <param name="index">The zero-based index in array at which
- /// copying begins.</param>
- /// <remarks>
- /// <para>
- /// As the collection is empty no values are copied into the array.
- /// </para>
- /// </remarks>
- public void CopyTo(System.Array array, int index)
- {
- // copy nothing
- }
+ /// <summary>
+ /// Copies the elements of the <see cref="ICollection"/> to an
+ /// <see cref="Array"/>, starting at a particular Array index.
+ /// </summary>
+ /// <param name="array">The one-dimensional <see cref="Array"/>
+ /// that is the destination of the elements copied from
+ /// <see cref="ICollection"/>. The Array must have zero-based
+ /// indexing.</param>
+ /// <param name="index">The zero-based index in array at which
+ /// copying begins.</param>
+ /// <remarks>
+ /// <para>
+ /// As the collection is empty no values are copied into the array.
+ /// </para>
+ /// </remarks>
+ public void CopyTo(System.Array array, int index)
+ {
+ // copy nothing
+ }
- /// <summary>
- /// Gets a value indicating if access to the <see cref="ICollection"/> is synchronized (thread-safe).
- /// </summary>
- /// <value>
- /// <b>true</b> if access to the <see cref="ICollection"/> is synchronized (thread-safe); otherwise, <b>false</b>.
- /// </value>
- /// <remarks>
- /// <para>
- /// For the <see cref="EmptyCollection"/> this property is always <c>true</c>.
- /// </para>
- /// </remarks>
- public bool IsSynchronized
- {
- get { return true; }
- }
+ /// <summary>
+ /// Gets a value indicating if access to the <see cref="ICollection"/> is synchronized (thread-safe).
+ /// </summary>
+ /// <value>
+ /// <b>true</b> if access to the <see cref="ICollection"/> is synchronized (thread-safe); otherwise, <b>false</b>.
+ /// </value>
+ /// <remarks>
+ /// <para>
+ /// For the <see cref="EmptyCollection"/> this property is always <c>true</c>.
+ /// </para>
+ /// </remarks>
+ public bool IsSynchronized
+ {
+ get { return true; }
+ }
- /// <summary>
- /// Gets the number of elements contained in the <see cref="ICollection"/>.
- /// </summary>
- /// <value>
- /// The number of elements contained in the <see cref="ICollection"/>.
- /// </value>
- /// <remarks>
- /// <para>
- /// As the collection is empty the <see cref="Count"/> is always <c>0</c>.
- /// </para>
- /// </remarks>
- public int Count
- {
- get { return 0; }
- }
+ /// <summary>
+ /// Gets the number of elements contained in the <see cref="ICollection"/>.
+ /// </summary>
+ /// <value>
+ /// The number of elements contained in the <see cref="ICollection"/>.
+ /// </value>
+ /// <remarks>
+ /// <para>
+ /// As the collection is empty the <see cref="Count"/> is always <c>0</c>.
+ /// </para>
+ /// </remarks>
+ public int Count
+ {
+ get { return 0; }
+ }
- /// <summary>
- /// Gets an object that can be used to synchronize access to the <see cref="ICollection"/>.
- /// </summary>
- /// <value>
- /// An object that can be used to synchronize access to the <see cref="ICollection"/>.
- /// </value>
- /// <remarks>
- /// <para>
- /// As the collection is empty and thread safe and synchronized this instance is also
- /// the <see cref="SyncRoot"/> object.
- /// </para>
- /// </remarks>
- public object SyncRoot
- {
- get { return this; }
- }
+ /// <summary>
+ /// Gets an object that can be used to synchronize access to the <see cref="ICollection"/>.
+ /// </summary>
+ /// <value>
+ /// An object that can be used to synchronize access to the <see cref="ICollection"/>.
+ /// </value>
+ /// <remarks>
+ /// <para>
+ /// As the collection is empty and thread safe and synchronized this instance is also
+ /// the <see cref="SyncRoot"/> object.
+ /// </para>
+ /// </remarks>
+ public object SyncRoot
+ {
+ get { return this; }
+ }
- #endregion Implementation of ICollection
+ #endregion Implementation of ICollection
- #region Implementation of IEnumerable
+ #region Implementation of IEnumerable
- /// <summary>
- /// Returns an enumerator that can iterate through a collection.
- /// </summary>
- /// <returns>
- /// An <see cref="IEnumerator"/> that can be used to
- /// iterate through the collection.
- /// </returns>
- /// <remarks>
- /// <para>
- /// As the collection is empty a <see cref="NullEnumerator"/> is returned.
- /// </para>
- /// </remarks>
- public IEnumerator GetEnumerator()
- {
- return NullEnumerator.Instance;
- }
+ /// <summary>
+ /// Returns an enumerator that can iterate through a collection.
+ /// </summary>
+ /// <returns>
+ /// An <see cref="IEnumerator"/> that can be used to
+ /// iterate through the collection.
+ /// </returns>
+ /// <remarks>
+ /// <para>
+ /// As the collection is empty a <see cref="NullEnumerator"/> is returned.
+ /// </para>
+ /// </remarks>
+ public IEnumerator GetEnumerator()
+ {
+ return NullEnumerator.Instance;
+ }
- #endregion Implementation of IEnumerable
+ #endregion Implementation of IEnumerable
- #region Private Static Fields
+ #region Private Static Fields
- /// <summary>
- /// The singleton instance of the empty collection.
- /// </summary>
- private static readonly EmptyCollection s_instance = new EmptyCollection();
+ /// <summary>
+ /// The singleton instance of the empty collection.
+ /// </summary>
+ private static readonly EmptyCollection s_instance = new EmptyCollection();
- #endregion Private Static Fields
- }
+ #endregion Private Static Fields
+ }
}
diff --git a/src/log4net/Util/EmptyDictionary.cs b/src/log4net/Util/EmptyDictionary.cs
index 792a781..1ccb67e 100644
--- a/src/log4net/Util/EmptyDictionary.cs
+++ b/src/log4net/Util/EmptyDictionary.cs
@@ -22,318 +22,318 @@
namespace log4net.Util
{
- /// <summary>
- /// An always empty <see cref="IDictionary"/>.
- /// </summary>
- /// <remarks>
- /// <para>
- /// A singleton implementation of the <see cref="IDictionary"/>
- /// interface that always represents an empty collection.
- /// </para>
- /// </remarks>
- /// <author>Nicko Cadell</author>
- /// <author>Gert Driesen</author>
+ /// <summary>
+ /// An always empty <see cref="IDictionary"/>.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// A singleton implementation of the <see cref="IDictionary"/>
+ /// interface that always represents an empty collection.
+ /// </para>
+ /// </remarks>
+ /// <author>Nicko Cadell</author>
+ /// <author>Gert Driesen</author>
#if !NETCF
- [Serializable]
+ [Serializable]
#endif
- public sealed class EmptyDictionary : IDictionary
- {
- #region Private Instance Constructors
+ public sealed class EmptyDictionary : IDictionary
+ {
+ #region Private Instance Constructors
- /// <summary>
- /// Initializes a new instance of the <see cref="EmptyDictionary" /> class.
- /// </summary>
- /// <remarks>
- /// <para>
- /// Uses a private access modifier to enforce the singleton pattern.
- /// </para>
- /// </remarks>
- private EmptyDictionary()
- {
- }
+ /// <summary>
+ /// Initializes a new instance of the <see cref="EmptyDictionary" /> class.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Uses a private access modifier to enforce the singleton pattern.
+ /// </para>
+ /// </remarks>
+ private EmptyDictionary()
+ {
+ }
- #endregion Private Instance Constructors
+ #endregion Private Instance Constructors
- #region Public Static Properties
+ #region Public Static Properties
- /// <summary>
- /// Gets the singleton instance of the <see cref="EmptyDictionary" />.
- /// </summary>
- /// <returns>The singleton instance of the <see cref="EmptyDictionary" />.</returns>
- /// <remarks>
- /// <para>
- /// Gets the singleton instance of the <see cref="EmptyDictionary" />.
- /// </para>
- /// </remarks>
- public static EmptyDictionary Instance
- {
- get { return s_instance; }
- }
+ /// <summary>
+ /// Gets the singleton instance of the <see cref="EmptyDictionary" />.
+ /// </summary>
+ /// <returns>The singleton instance of the <see cref="EmptyDictionary" />.</returns>
+ /// <remarks>
+ /// <para>
+ /// Gets the singleton instance of the <see cref="EmptyDictionary" />.
+ /// </para>
+ /// </remarks>
+ public static EmptyDictionary Instance
+ {
+ get { return s_instance; }
+ }
- #endregion Public Static Properties
+ #endregion Public Static Properties
- #region Implementation of ICollection
+ #region Implementation of ICollection
- /// <summary>
- /// Copies the elements of the <see cref="ICollection"/> to an
- /// <see cref="Array"/>, starting at a particular Array index.
- /// </summary>
- /// <param name="array">The one-dimensional <see cref="Array"/>
- /// that is the destination of the elements copied from
- /// <see cref="ICollection"/>. The Array must have zero-based
- /// indexing.</param>
- /// <param name="index">The zero-based index in array at which
- /// copying begins.</param>
- /// <remarks>
- /// <para>
- /// As the collection is empty no values are copied into the array.
- /// </para>
- /// </remarks>
- public void CopyTo(System.Array array, int index)
- {
- // copy nothing
- }
+ /// <summary>
+ /// Copies the elements of the <see cref="ICollection"/> to an
+ /// <see cref="Array"/>, starting at a particular Array index.
+ /// </summary>
+ /// <param name="array">The one-dimensional <see cref="Array"/>
+ /// that is the destination of the elements copied from
+ /// <see cref="ICollection"/>. The Array must have zero-based
+ /// indexing.</param>
+ /// <param name="index">The zero-based index in array at which
+ /// copying begins.</param>
+ /// <remarks>
+ /// <para>
+ /// As the collection is empty no values are copied into the array.
+ /// </para>
+ /// </remarks>
+ public void CopyTo(System.Array array, int index)
+ {
+ // copy nothing
+ }
- /// <summary>
- /// Gets a value indicating if access to the <see cref="ICollection"/> is synchronized (thread-safe).
- /// </summary>
- /// <value>
- /// <b>true</b> if access to the <see cref="ICollection"/> is synchronized (thread-safe); otherwise, <b>false</b>.
- /// </value>
- /// <remarks>
- /// <para>
- /// For the <see cref="EmptyCollection"/> this property is always <b>true</b>.
- /// </para>
- /// </remarks>
- public bool IsSynchronized
- {
- get { return true; }
- }
+ /// <summary>
+ /// Gets a value indicating if access to the <see cref="ICollection"/> is synchronized (thread-safe).
+ /// </summary>
+ /// <value>
+ /// <b>true</b> if access to the <see cref="ICollection"/> is synchronized (thread-safe); otherwise, <b>false</b>.
+ /// </value>
+ /// <remarks>
+ /// <para>
+ /// For the <see cref="EmptyCollection"/> this property is always <b>true</b>.
+ /// </para>
+ /// </remarks>
+ public bool IsSynchronized
+ {
+ get { return true; }
+ }
- /// <summary>
- /// Gets the number of elements contained in the <see cref="ICollection"/>
- /// </summary>
- /// <value>
- /// The number of elements contained in the <see cref="ICollection"/>.
- /// </value>
- /// <remarks>
- /// <para>
- /// As the collection is empty the <see cref="Count"/> is always <c>0</c>.
- /// </para>
- /// </remarks>
- public int Count
- {
- get { return 0; }
- }
+ /// <summary>
+ /// Gets the number of elements contained in the <see cref="ICollection"/>
+ /// </summary>
+ /// <value>
+ /// The number of elements contained in the <see cref="ICollection"/>.
+ /// </value>
+ /// <remarks>
+ /// <para>
+ /// As the collection is empty the <see cref="Count"/> is always <c>0</c>.
+ /// </para>
+ /// </remarks>
+ public int Count
+ {
+ get { return 0; }
+ }
- /// <summary>
- /// Gets an object that can be used to synchronize access to the <see cref="ICollection"/>.
- /// </summary>
- /// <value>
- /// An object that can be used to synchronize access to the <see cref="ICollection"/>.
- /// </value>
- /// <remarks>
- /// <para>
- /// As the collection is empty and thread safe and synchronized this instance is also
- /// the <see cref="SyncRoot"/> object.
- /// </para>
- /// </remarks>
- public object SyncRoot
- {
- get { return this; }
- }
+ /// <summary>
+ /// Gets an object that can be used to synchronize access to the <see cref="ICollection"/>.
+ /// </summary>
+ /// <value>
+ /// An object that can be used to synchronize access to the <see cref="ICollection"/>.
+ /// </value>
+ /// <remarks>
+ /// <para>
+ /// As the collection is empty and thread safe and synchronized this instance is also
+ /// the <see cref="SyncRoot"/> object.
+ /// </para>
+ /// </remarks>
+ public object SyncRoot
+ {
+ get { return this; }
+ }
- #endregion Implementation of ICollection
+ #endregion Implementation of ICollection
- #region Implementation of IEnumerable
+ #region Implementation of IEnumerable
- /// <summary>
- /// Returns an enumerator that can iterate through a collection.
- /// </summary>
- /// <returns>
- /// An <see cref="IEnumerator"/> that can be used to
- /// iterate through the collection.
- /// </returns>
- /// <remarks>
- /// <para>
- /// As the collection is empty a <see cref="NullEnumerator"/> is returned.
- /// </para>
- /// </remarks>
- IEnumerator IEnumerable.GetEnumerator()
- {
- return NullEnumerator.Instance;
- }
+ /// <summary>
+ /// Returns an enumerator that can iterate through a collection.
+ /// </summary>
+ /// <returns>
+ /// An <see cref="IEnumerator"/> that can be used to
+ /// iterate through the collection.
+ /// </returns>
+ /// <remarks>
+ /// <para>
+ /// As the collection is empty a <see cref="NullEnumerator"/> is returned.
+ /// </para>
+ /// </remarks>
+ IEnumerator IEnumerable.GetEnumerator()
+ {
+ return NullEnumerator.Instance;
+ }
- #endregion Implementation of IEnumerable
+ #endregion Implementation of IEnumerable
- #region Implementation of IDictionary
+ #region Implementation of IDictionary
- /// <summary>
- /// Adds an element with the provided key and value to the
- /// <see cref="EmptyDictionary" />.
- /// </summary>
- /// <param name="key">The <see cref="object" /> to use as the key of the element to add.</param>
- /// <param name="value">The <see cref="object" /> to use as the value of the element to add.</param>
- /// <remarks>
- /// <para>
- /// As the collection is empty no new values can be added. A <see cref="InvalidOperationException"/>
- /// is thrown if this method is called.
- /// </para>
- /// </remarks>
- /// <exception cref="InvalidOperationException">This dictionary is always empty and cannot be modified.</exception>
- public void Add(object key, object value)
- {
- throw new InvalidOperationException();
- }
+ /// <summary>
+ /// Adds an element with the provided key and value to the
+ /// <see cref="EmptyDictionary" />.
+ /// </summary>
+ /// <param name="key">The <see cref="object" /> to use as the key of the element to add.</param>
+ /// <param name="value">The <see cref="object" /> to use as the value of the element to add.</param>
+ /// <remarks>
+ /// <para>
+ /// As the collection is empty no new values can be added. A <see cref="InvalidOperationException"/>
+ /// is thrown if this method is called.
+ /// </para>
+ /// </remarks>
+ /// <exception cref="InvalidOperationException">This dictionary is always empty and cannot be modified.</exception>
+ public void Add(object key, object value)
+ {
+ throw new InvalidOperationException();
+ }
- /// <summary>
- /// Removes all elements from the <see cref="EmptyDictionary" />.
- /// </summary>
- /// <remarks>
- /// <para>
- /// As the collection is empty no values can be removed. A <see cref="InvalidOperationException"/>
- /// is thrown if this method is called.
- /// </para>
- /// </remarks>
- /// <exception cref="InvalidOperationException">This dictionary is always empty and cannot be modified.</exception>
- public void Clear()
- {
- throw new InvalidOperationException();
- }
+ /// <summary>
+ /// Removes all elements from the <see cref="EmptyDictionary" />.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// As the collection is empty no values can be removed. A <see cref="InvalidOperationException"/>
+ /// is thrown if this method is called.
+ /// </para>
+ /// </remarks>
+ /// <exception cref="InvalidOperationException">This dictionary is always empty and cannot be modified.</exception>
+ public void Clear()
+ {
+ throw new InvalidOperationException();
+ }
- /// <summary>
- /// Determines whether the <see cref="EmptyDictionary" /> contains an element
- /// with the specified key.
- /// </summary>
- /// <param name="key">The key to locate in the <see cref="EmptyDictionary" />.</param>
- /// <returns><c>false</c></returns>
- /// <remarks>
- /// <para>
- /// As the collection is empty the <see cref="Contains"/> method always returns <c>false</c>.
- /// </para>
- /// </remarks>
- public bool Contains(object key)
- {
- return false;
- }
+ /// <summary>
+ /// Determines whether the <see cref="EmptyDictionary" /> contains an element
+ /// with the specified key.
+ /// </summary>
+ /// <param name="key">The key to locate in the <see cref="EmptyDictionary" />.</param>
+ /// <returns><c>false</c></returns>
+ /// <remarks>
+ /// <para>
+ /// As the collection is empty the <see cref="Contains"/> method always returns <c>false</c>.
+ /// </para>
+ /// </remarks>
+ public bool Contains(object key)
+ {
+ return false;
+ }
- /// <summary>
- /// Returns an enumerator that can iterate through a collection.
- /// </summary>
- /// <returns>
- /// An <see cref="IEnumerator"/> that can be used to
- /// iterate through the collection.
- /// </returns>
- /// <remarks>
- /// <para>
- /// As the collection is empty a <see cref="NullEnumerator"/> is returned.
- /// </para>
- /// </remarks>
- public IDictionaryEnumerator GetEnumerator()
- {
- return NullDictionaryEnumerator.Instance;
- }
+ /// <summary>
+ /// Returns an enumerator that can iterate through a collection.
+ /// </summary>
+ /// <returns>
+ /// An <see cref="IEnumerator"/> that can be used to
+ /// iterate through the collection.
+ /// </returns>
+ /// <remarks>
+ /// <para>
+ /// As the collection is empty a <see cref="NullEnumerator"/> is returned.
+ /// </para>
+ /// </remarks>
+ public IDictionaryEnumerator GetEnumerator()
+ {
+ return NullDictionaryEnumerator.Instance;
+ }
- /// <summary>
- /// Removes the element with the specified key from the <see cref="EmptyDictionary" />.
- /// </summary>
- /// <param name="key">The key of the element to remove.</param>
- /// <remarks>
- /// <para>
- /// As the collection is empty no values can be removed. A <see cref="InvalidOperationException"/>
- /// is thrown if this method is called.
- /// </para>
- /// </remarks>
- /// <exception cref="InvalidOperationException">This dictionary is always empty and cannot be modified.</exception>
- public void Remove(object key)
- {
- throw new InvalidOperationException();
- }
+ /// <summary>
+ /// Removes the element with the specified key from the <see cref="EmptyDictionary" />.
+ /// </summary>
+ /// <param name="key">The key of the element to remove.</param>
+ /// <remarks>
+ /// <para>
+ /// As the collection is empty no values can be removed. A <see cref="InvalidOperationException"/>
+ /// is thrown if this method is called.
+ /// </para>
+ /// </remarks>
+ /// <exception cref="InvalidOperationException">This dictionary is always empty and cannot be modified.</exception>
+ public void Remove(object key)
+ {
+ throw new InvalidOperationException();
+ }
- /// <summary>
- /// Gets a value indicating whether the <see cref="EmptyDictionary" /> has a fixed size.
- /// </summary>
- /// <value><c>true</c></value>
- /// <remarks>
- /// <para>
- /// As the collection is empty <see cref="IsFixedSize"/> always returns <c>true</c>.
- /// </para>
- /// </remarks>
- public bool IsFixedSize
- {
- get { return true; }
- }
+ /// <summary>
+ /// Gets a value indicating whether the <see cref="EmptyDictionary" /> has a fixed size.
+ /// </summary>
+ /// <value><c>true</c></value>
+ /// <remarks>
+ /// <para>
+ /// As the collection is empty <see cref="IsFixedSize"/> always returns <c>true</c>.
+ /// </para>
+ /// </remarks>
+ public bool IsFixedSize
+ {
+ get { return true; }
+ }
- /// <summary>
- /// Gets a value indicating whether the <see cref="EmptyDictionary" /> is read-only.
- /// </summary>
- /// <value><c>true</c></value>
- /// <remarks>
- /// <para>
- /// As the collection is empty <see cref="IsReadOnly"/> always returns <c>true</c>.
- /// </para>
- /// </remarks>
- public bool IsReadOnly
- {
- get { return true; }
- }
+ /// <summary>
+ /// Gets a value indicating whether the <see cref="EmptyDictionary" /> is read-only.
+ /// </summary>
+ /// <value><c>true</c></value>
+ /// <remarks>
+ /// <para>
+ /// As the collection is empty <see cref="IsReadOnly"/> always returns <c>true</c>.
+ /// </para>
+ /// </remarks>
+ public bool IsReadOnly
+ {
+ get { return true; }
+ }
- /// <summary>
- /// Gets an <see cref="ICollection" /> containing the keys of the <see cref="EmptyDictionary" />.
- /// </summary>
- /// <value>An <see cref="ICollection" /> containing the keys of the <see cref="EmptyDictionary" />.</value>
- /// <remarks>
- /// <para>
- /// As the collection is empty a <see cref="EmptyCollection"/> is returned.
- /// </para>
- /// </remarks>
- public System.Collections.ICollection Keys
- {
- get { return EmptyCollection.Instance; }
- }
+ /// <summary>
+ /// Gets an <see cref="ICollection" /> containing the keys of the <see cref="EmptyDictionary" />.
+ /// </summary>
+ /// <value>An <see cref="ICollection" /> containing the keys of the <see cref="EmptyDictionary" />.</value>
+ /// <remarks>
+ /// <para>
+ /// As the collection is empty a <see cref="EmptyCollection"/> is returned.
+ /// </para>
+ /// </remarks>
+ public System.Collections.ICollection Keys
+ {
+ get { return EmptyCollection.Instance; }
+ }
- /// <summary>
- /// Gets an <see cref="ICollection" /> containing the values of the <see cref="EmptyDictionary" />.
- /// </summary>
- /// <value>An <see cref="ICollection" /> containing the values of the <see cref="EmptyDictionary" />.</value>
- /// <remarks>
- /// <para>
- /// As the collection is empty a <see cref="EmptyCollection"/> is returned.
- /// </para>
- /// </remarks>
- public System.Collections.ICollection Values
- {
- get { return EmptyCollection.Instance; }
- }
+ /// <summary>
+ /// Gets an <see cref="ICollection" /> containing the values of the <see cref="EmptyDictionary" />.
+ /// </summary>
+ /// <value>An <see cref="ICollection" /> containing the values of the <see cref="EmptyDictionary" />.</value>
+ /// <remarks>
+ /// <para>
+ /// As the collection is empty a <see cref="EmptyCollection"/> is returned.
+ /// </para>
+ /// </remarks>
+ public System.Collections.ICollection Values
+ {
+ get { return EmptyCollection.Instance; }
+ }
- /// <summary>
- /// Gets or sets the element with the specified key.
- /// </summary>
- /// <param name="key">The key of the element to get or set.</param>
- /// <value><c>null</c></value>
- /// <remarks>
- /// <para>
- /// As the collection is empty no values can be looked up or stored.
- /// If the index getter is called then <c>null</c> is returned.
- /// A <see cref="InvalidOperationException"/> is thrown if the setter is called.
- /// </para>
- /// </remarks>
- /// <exception cref="InvalidOperationException">This dictionary is always empty and cannot be modified.</exception>
- public object this[object key]
- {
- get { return null; }
- set { throw new InvalidOperationException(); }
- }
+ /// <summary>
+ /// Gets or sets the element with the specified key.
+ /// </summary>
+ /// <param name="key">The key of the element to get or set.</param>
+ /// <value><c>null</c></value>
+ /// <remarks>
+ /// <para>
+ /// As the collection is empty no values can be looked up or stored.
+ /// If the index getter is called then <c>null</c> is returned.
+ /// A <see cref="InvalidOperationException"/> is thrown if the setter is called.
+ /// </para>
+ /// </remarks>
+ /// <exception cref="InvalidOperationException">This dictionary is always empty and cannot be modified.</exception>
+ public object this[object key]
+ {
+ get { return null; }
+ set { throw new InvalidOperationException(); }
+ }
- #endregion Implementation of IDictionary
+ #endregion Implementation of IDictionary
- #region Private Static Fields
+ #region Private Static Fields
- /// <summary>
- /// The singleton instance of the empty dictionary.
- /// </summary>
- private static readonly EmptyDictionary s_instance = new EmptyDictionary();
+ /// <summary>
+ /// The singleton instance of the empty dictionary.
+ /// </summary>
+ private static readonly EmptyDictionary s_instance = new EmptyDictionary();
- #endregion Private Static Fields
- }
+ #endregion Private Static Fields
+ }
}
diff --git a/src/log4net/Util/FormattingInfo.cs b/src/log4net/Util/FormattingInfo.cs
index 4a6c9bb..6e8ed63 100644
--- a/src/log4net/Util/FormattingInfo.cs
+++ b/src/log4net/Util/FormattingInfo.cs
@@ -22,115 +22,115 @@
namespace log4net.Util
{
- /// <summary>
- /// Contain the information obtained when parsing formatting modifiers
- /// in conversion modifiers.
- /// </summary>
- /// <remarks>
- /// <para>
- /// Holds the formatting information extracted from the format string by
- /// the <see cref="PatternParser"/>. This is used by the <see cref="PatternConverter"/>
- /// objects when rendering the output.
- /// </para>
- /// </remarks>
- /// <author>Nicko Cadell</author>
- /// <author>Gert Driesen</author>
- public class FormattingInfo
- {
- #region Public Instance Constructors
+ /// <summary>
+ /// Contain the information obtained when parsing formatting modifiers
+ /// in conversion modifiers.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Holds the formatting information extracted from the format string by
+ /// the <see cref="PatternParser"/>. This is used by the <see cref="PatternConverter"/>
+ /// objects when rendering the output.
+ /// </para>
+ /// </remarks>
+ /// <author>Nicko Cadell</author>
+ /// <author>Gert Driesen</author>
+ public class FormattingInfo
+ {
+ #region Public Instance Constructors
- /// <summary>
- /// Defaut Constructor
- /// </summary>
- /// <remarks>
- /// <para>
- /// Initializes a new instance of the <see cref="FormattingInfo" /> class.
- /// </para>
- /// </remarks>
- public FormattingInfo()
- {
- }
+ /// <summary>
+ /// Defaut Constructor
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Initializes a new instance of the <see cref="FormattingInfo" /> class.
+ /// </para>
+ /// </remarks>
+ public FormattingInfo()
+ {
+ }
- /// <summary>
- /// Constructor
- /// </summary>
- /// <remarks>
- /// <para>
- /// Initializes a new instance of the <see cref="FormattingInfo" /> class
- /// with the specified parameters.
- /// </para>
- /// </remarks>
- public FormattingInfo(int min, int max, bool leftAlign)
- {
- m_min = min;
- m_max = max;
- m_leftAlign = leftAlign;
- }
+ /// <summary>
+ /// Constructor
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Initializes a new instance of the <see cref="FormattingInfo" /> class
+ /// with the specified parameters.
+ /// </para>
+ /// </remarks>
+ public FormattingInfo(int min, int max, bool leftAlign)
+ {
+ m_min = min;
+ m_max = max;
+ m_leftAlign = leftAlign;
+ }
- #endregion Public Instance Constructors
+ #endregion Public Instance Constructors
- #region Public Instance Properties
+ #region Public Instance Properties
- /// <summary>
- /// Gets or sets the minimum value.
- /// </summary>
- /// <value>
- /// The minimum value.
- /// </value>
- /// <remarks>
- /// <para>
- /// Gets or sets the minimum value.
- /// </para>
- /// </remarks>
- public int Min
- {
- get { return m_min; }
- set { m_min = value; }
- }
+ /// <summary>
+ /// Gets or sets the minimum value.
+ /// </summary>
+ /// <value>
+ /// The minimum value.
+ /// </value>
+ /// <remarks>
+ /// <para>
+ /// Gets or sets the minimum value.
+ /// </para>
+ /// </remarks>
+ public int Min
+ {
+ get { return m_min; }
+ set { m_min = value; }
+ }
- /// <summary>
- /// Gets or sets the maximum value.
- /// </summary>
- /// <value>
- /// The maximum value.
- /// </value>
- /// <remarks>
- /// <para>
- /// Gets or sets the maximum value.
- /// </para>
- /// </remarks>
- public int Max
- {
- get { return m_max; }
- set { m_max = value; }
- }
+ /// <summary>
+ /// Gets or sets the maximum value.
+ /// </summary>
+ /// <value>
+ /// The maximum value.
+ /// </value>
+ /// <remarks>
+ /// <para>
+ /// Gets or sets the maximum value.
+ /// </para>
+ /// </remarks>
+ public int Max
+ {
+ get { return m_max; }
+ set { m_max = value; }
+ }
- /// <summary>
- /// Gets or sets a flag indicating whether left align is enabled
- /// or not.
- /// </summary>
- /// <value>
- /// A flag indicating whether left align is enabled or not.
- /// </value>
- /// <remarks>
- /// <para>
- /// Gets or sets a flag indicating whether left align is enabled or not.
- /// </para>
- /// </remarks>
- public bool LeftAlign
- {
- get { return m_leftAlign; }
- set { m_leftAlign = value; }
- }
+ /// <summary>
+ /// Gets or sets a flag indicating whether left align is enabled
+ /// or not.
+ /// </summary>
+ /// <value>
+ /// A flag indicating whether left align is enabled or not.
+ /// </value>
+ /// <remarks>
+ /// <para>
+ /// Gets or sets a flag indicating whether left align is enabled or not.
+ /// </para>
+ /// </remarks>
+ public bool LeftAlign
+ {
+ get { return m_leftAlign; }
+ set { m_leftAlign = value; }
+ }
- #endregion Public Instance Properties
+ #endregion Public Instance Properties
- #region Private Instance Fields
+ #region Private Instance Fields
- private int m_min = -1;
- private int m_max = int.MaxValue;
- private bool m_leftAlign = false;
+ private int m_min = -1;
+ private int m_max = int.MaxValue;
+ private bool m_leftAlign = false;
- #endregion Private Instance Fields
- }
+ #endregion Private Instance Fields
+ }
}
diff --git a/src/log4net/Util/GlobalContextProperties.cs b/src/log4net/Util/GlobalContextProperties.cs
index 0c19995..c7c504f 100644
--- a/src/log4net/Util/GlobalContextProperties.cs
+++ b/src/log4net/Util/GlobalContextProperties.cs
@@ -22,156 +22,156 @@
namespace log4net.Util
{
- /// <summary>
- /// Implementation of Properties collection for the <see cref="log4net.GlobalContext"/>
- /// </summary>
- /// <remarks>
- /// <para>
- /// This class implements a properties collection that is thread safe and supports both
- /// storing properties and capturing a read only copy of the current propertied.
- /// </para>
- /// <para>
- /// This class is optimized to the scenario where the properties are read frequently
- /// and are modified infrequently.
- /// </para>
- /// </remarks>
- /// <author>Nicko Cadell</author>
- public sealed class GlobalContextProperties : ContextPropertiesBase
- {
- #region Private Instance Fields
+ /// <summary>
+ /// Implementation of Properties collection for the <see cref="log4net.GlobalContext"/>
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// This class implements a properties collection that is thread safe and supports both
+ /// storing properties and capturing a read only copy of the current propertied.
+ /// </para>
+ /// <para>
+ /// This class is optimized to the scenario where the properties are read frequently
+ /// and are modified infrequently.
+ /// </para>
+ /// </remarks>
+ /// <author>Nicko Cadell</author>
+ public sealed class GlobalContextProperties : ContextPropertiesBase
+ {
+ #region Private Instance Fields
- /// <summary>
- /// The read only copy of the properties.
- /// </summary>
- /// <remarks>
- /// <para>
- /// This variable is declared <c>volatile</c> to prevent the compiler and JIT from
- /// reordering reads and writes of this thread performed on different threads.
- /// </para>
- /// </remarks>
+ /// <summary>
+ /// The read only copy of the properties.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// This variable is declared <c>volatile</c> to prevent the compiler and JIT from
+ /// reordering reads and writes of this thread performed on different threads.
+ /// </para>
+ /// </remarks>
#if NETCF
- private ReadOnlyPropertiesDictionary m_readOnlyProperties = new ReadOnlyPropertiesDictionary();
+ private ReadOnlyPropertiesDictionary m_readOnlyProperties = new ReadOnlyPropertiesDictionary();
#else
- private volatile ReadOnlyPropertiesDictionary m_readOnlyProperties = new ReadOnlyPropertiesDictionary();
+ private volatile ReadOnlyPropertiesDictionary m_readOnlyProperties = new ReadOnlyPropertiesDictionary();
#endif
- /// <summary>
- /// Lock object used to synchronize updates within this instance
- /// </summary>
- private readonly object m_syncRoot = new object();
+ /// <summary>
+ /// Lock object used to synchronize updates within this instance
+ /// </summary>
+ private readonly object m_syncRoot = new object();
- #endregion Private Instance Fields
+ #endregion Private Instance Fields
- #region Public Instance Constructors
+ #region Public Instance Constructors
- /// <summary>
- /// Constructor
- /// </summary>
- /// <remarks>
- /// <para>
- /// Initializes a new instance of the <see cref="GlobalContextProperties" /> class.
- /// </para>
- /// </remarks>
- internal GlobalContextProperties()
- {
- }
+ /// <summary>
+ /// Constructor
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Initializes a new instance of the <see cref="GlobalContextProperties" /> class.
+ /// </para>
+ /// </remarks>
+ internal GlobalContextProperties()
+ {
+ }
- #endregion Public Instance Constructors
+ #endregion Public Instance Constructors
- #region Public Instance Properties
+ #region Public Instance Properties
- /// <summary>
- /// Gets or sets the value of a property
- /// </summary>
- /// <value>
- /// The value for the property with the specified key
- /// </value>
- /// <remarks>
- /// <para>
- /// Reading the value for a key is faster than setting the value.
- /// When the value is written a new read only copy of
- /// the properties is created.
- /// </para>
- /// </remarks>
- public override object this[string key]
- {
- get
- {
- return m_readOnlyProperties[key];
- }
- set
- {
- lock(m_syncRoot)
- {
- PropertiesDictionary mutableProps = new PropertiesDictionary(m_readOnlyProperties);
+ /// <summary>
+ /// Gets or sets the value of a property
+ /// </summary>
+ /// <value>
+ /// The value for the property with the specified key
+ /// </value>
+ /// <remarks>
+ /// <para>
+ /// Reading the value for a key is faster than setting the value.
+ /// When the value is written a new read only copy of
+ /// the properties is created.
+ /// </para>
+ /// </remarks>
+ public override object this[string key]
+ {
+ get
+ {
+ return m_readOnlyProperties[key];
+ }
+ set
+ {
+ lock(m_syncRoot)
+ {
+ PropertiesDictionary mutableProps = new PropertiesDictionary(m_readOnlyProperties);
- mutableProps[key] = value;
+ mutableProps[key] = value;
- m_readOnlyProperties = new ReadOnlyPropertiesDictionary(mutableProps);
- }
- }
- }
+ m_readOnlyProperties = new ReadOnlyPropertiesDictionary(mutableProps);
+ }
+ }
+ }
- #endregion Public Instance Properties
+ #endregion Public Instance Properties
- #region Public Instance Methods
+ #region Public Instance Methods
- /// <summary>
- /// Remove a property from the global context
- /// </summary>
- /// <param name="key">the key for the entry to remove</param>
- /// <remarks>
- /// <para>
- /// Removing an entry from the global context properties is relatively expensive compared
- /// with reading a value.
- /// </para>
- /// </remarks>
- public void Remove(string key)
- {
- lock(m_syncRoot)
- {
- if (m_readOnlyProperties.Contains(key))
- {
- PropertiesDictionary mutableProps = new PropertiesDictionary(m_readOnlyProperties);
+ /// <summary>
+ /// Remove a property from the global context
+ /// </summary>
+ /// <param name="key">the key for the entry to remove</param>
+ /// <remarks>
+ /// <para>
+ /// Removing an entry from the global context properties is relatively expensive compared
+ /// with reading a value.
+ /// </para>
+ /// </remarks>
+ public void Remove(string key)
+ {
+ lock(m_syncRoot)
+ {
+ if (m_readOnlyProperties.Contains(key))
+ {
+ PropertiesDictionary mutableProps = new PropertiesDictionary(m_readOnlyProperties);
- mutableProps.Remove(key);
+ mutableProps.Remove(key);
- m_readOnlyProperties = new ReadOnlyPropertiesDictionary(mutableProps);
- }
- }
- }
+ m_readOnlyProperties = new ReadOnlyPropertiesDictionary(mutableProps);
+ }
+ }
+ }
- /// <summary>
- /// Clear the global context properties
- /// </summary>
- public void Clear()
- {
- lock(m_syncRoot)
- {
- m_readOnlyProperties = new ReadOnlyPropertiesDictionary();
- }
- }
+ /// <summary>
+ /// Clear the global context properties
+ /// </summary>
+ public void Clear()
+ {
+ lock(m_syncRoot)
+ {
+ m_readOnlyProperties = new ReadOnlyPropertiesDictionary();
+ }
+ }
- #endregion Public Instance Methods
+ #endregion Public Instance Methods
- #region Internal Instance Methods
+ #region Internal Instance Methods
- /// <summary>
- /// Get a readonly immutable copy of the properties
- /// </summary>
- /// <returns>the current global context properties</returns>
- /// <remarks>
- /// <para>
- /// This implementation is fast because the GlobalContextProperties class
- /// stores a readonly copy of the properties.
- /// </para>
- /// </remarks>
- internal ReadOnlyPropertiesDictionary GetReadOnlyProperties()
- {
- return m_readOnlyProperties;
- }
+ /// <summary>
+ /// Get a readonly immutable copy of the properties
+ /// </summary>
+ /// <returns>the current global context properties</returns>
+ /// <remarks>
+ /// <para>
+ /// This implementation is fast because the GlobalContextProperties class
+ /// stores a readonly copy of the properties.
+ /// </para>
+ /// </remarks>
+ internal ReadOnlyPropertiesDictionary GetReadOnlyProperties()
+ {
+ return m_readOnlyProperties;
+ }
- #endregion Internal Instance Methods
- }
+ #endregion Internal Instance Methods
+ }
}
diff --git a/src/log4net/Util/ILogExtensions.cs b/src/log4net/Util/ILogExtensions.cs
index fa52c28..0d13e04 100644
--- a/src/log4net/Util/ILogExtensions.cs
+++ b/src/log4net/Util/ILogExtensions.cs
@@ -25,1717 +25,1717 @@
namespace log4net.Util
{
- /// <summary>
- /// The static class ILogExtensions contains a set of widely used
- /// methods that ease the interaction with the ILog interface implementations.
- /// </summary>
- /// <remarks>
- /// <para>
- /// This class contains methods for logging at different levels and checks the
- /// properties for determining if those logging levels are enabled in the current
- /// configuration.
- /// </para>
- /// </remarks>
- /// <example>Simple example of logging messages
- /// <code lang="C#">
- /// using log4net.Util;
- ///
- /// ILog log = LogManager.GetLogger("application-log");
- ///
- /// log.InfoExt("Application Start");
- /// log.DebugExt("This is a debug message");
- /// </code>
- /// </example>
- public static class ILogExtensions
- {
- #region Private Static Fields
+ /// <summary>
+ /// The static class ILogExtensions contains a set of widely used
+ /// methods that ease the interaction with the ILog interface implementations.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// This class contains methods for logging at different levels and checks the
+ /// properties for determining if those logging levels are enabled in the current
+ /// configuration.
+ /// </para>
+ /// </remarks>
+ /// <example>Simple example of logging messages
+ /// <code lang="C#">
+ /// using log4net.Util;
+ ///
+ /// ILog log = LogManager.GetLogger("application-log");
+ ///
+ /// log.InfoExt("Application Start");
+ /// log.DebugExt("This is a debug message");
+ /// </code>
+ /// </example>
+ public static class ILogExtensions
+ {
+ #region Private Static Fields
- /// <summary>
- /// The fully qualified type of the Logger class.
- /// </summary>
- private static readonly Type declaringType = typeof(ILogExtensions);
+ /// <summary>
+ /// The fully qualified type of the Logger class.
+ /// </summary>
+ private static readonly Type declaringType = typeof(ILogExtensions);
- #endregion //Private Static Fields
+ #endregion //Private Static Fields
- #region debug extensions
+ #region debug extensions
- #region debug extensions that uses log message lambda expression
+ #region debug extensions that uses log message lambda expression
- /// <summary>
- /// Log a message object with the <see cref="Level.Debug"/> level.
- /// </summary>
- /// <param name="logger">The logger on which the message is logged.</param>
- /// <param name="callback">The lambda expression that gets the object to log.</param>
- /// <remarks>
- /// <para>
- /// This method first checks if this logger is <c>INFO</c>
- /// enabled by reading the value <seealso cref="ILog.IsDebugEnabled"/> property.
- /// This check happens always and does not depend on the <seealso cref="ILog"/>
- /// implementation. If this logger is <c>INFO</c> enabled, then it converts
- /// the message object (retrieved by invocation of the provided callback) to a
- /// string by invoking the appropriate <see cref="log4net.ObjectRenderer.IObjectRenderer"/>.
- /// It then proceeds to call all the registered appenders in this logger
- /// and also higher in the hierarchy depending on the value of
- /// the additivity flag.
- /// </para>
- /// <para><b>WARNING</b> Note that passing an <see cref="Exception"/>
- /// to this method will print the name of the <see cref="Exception"/>
- /// but no stack trace. To print a stack trace use the
- /// <see cref="DebugExt(ILog,Func{object},Exception)"/> form instead.
- /// </para>
- /// </remarks>
- /// <seealso cref="ILog.Debug(object)"/>
- /// <seealso cref="ILog.IsDebugEnabled"/>
- public static void DebugExt(this ILog logger, Func<object> callback)
- {
- try
- {
- if (!logger.IsDebugEnabled)
- return;
+ /// <summary>
+ /// Log a message object with the <see cref="Level.Debug"/> level.
+ /// </summary>
+ /// <param name="logger">The logger on which the message is logged.</param>
+ /// <param name="callback">The lambda expression that gets the object to log.</param>
+ /// <remarks>
+ /// <para>
+ /// This method first checks if this logger is <c>INFO</c>
+ /// enabled by reading the value <seealso cref="ILog.IsDebugEnabled"/> property.
+ /// This check happens always and does not depend on the <seealso cref="ILog"/>
+ /// implementation. If this logger is <c>INFO</c> enabled, then it converts
+ /// the message object (retrieved by invocation of the provided callback) to a
+ /// string by invoking the appropriate <see cref="log4net.ObjectRenderer.IObjectRenderer"/>.
+ /// It then proceeds to call all the registered appenders in this logger
+ /// and also higher in the hierarchy depending on the value of
+ /// the additivity flag.
+ /// </para>
+ /// <para><b>WARNING</b> Note that passing an <see cref="Exception"/>
+ /// to this method will print the name of the <see cref="Exception"/>
+ /// but no stack trace. To print a stack trace use the
+ /// <see cref="DebugExt(ILog,Func{object},Exception)"/> form instead.
+ /// </para>
+ /// </remarks>
+ /// <seealso cref="ILog.Debug(object)"/>
+ /// <seealso cref="ILog.IsDebugEnabled"/>
+ public static void DebugExt(this ILog logger, Func<object> callback)
+ {
+ try
+ {
+ if (!logger.IsDebugEnabled)
+ return;
- logger.Debug(callback());
- }
- catch (Exception ex)
- {
- log4net.Util.LogLog.Error(declaringType, "Exception while logging", ex);
- }
- }
+ logger.Debug(callback());
+ }
+ catch (Exception ex)
+ {
+ log4net.Util.LogLog.Error(declaringType, "Exception while logging", ex);
+ }
+ }
- /// <summary>
- /// Log a message object with the <see cref="Level.Debug"/> level including
- /// the stack trace of the <see cref="Exception"/> passed
- /// as a parameter.
- /// </summary>
- /// <param name="logger">The logger on which the message is logged.</param>
- /// <param name="callback">The lambda expression that gets the object to log.</param>
- /// <param name="exception">The exception to log, including its stack trace.</param>
- /// <remarks>
- /// <para>
- /// See the <see cref="DebugExt(ILog, object)"/> form for more detailed information.
- /// </para>
- /// </remarks>
- /// <seealso cref="ILog.Debug(object)"/>
- /// <seealso cref="ILog.IsDebugEnabled"/>
- public static void DebugExt(this ILog logger, Func<object> callback, Exception exception)
- {
- try
- {
- if (!logger.IsDebugEnabled)
- return;
+ /// <summary>
+ /// Log a message object with the <see cref="Level.Debug"/> level including
+ /// the stack trace of the <see cref="Exception"/> passed
+ /// as a parameter.
+ /// </summary>
+ /// <param name="logger">The logger on which the message is logged.</param>
+ /// <param name="callback">The lambda expression that gets the object to log.</param>
+ /// <param name="exception">The exception to log, including its stack trace.</param>
+ /// <remarks>
+ /// <para>
+ /// See the <see cref="DebugExt(ILog, object)"/> form for more detailed information.
+ /// </para>
+ /// </remarks>
+ /// <seealso cref="ILog.Debug(object)"/>
+ /// <seealso cref="ILog.IsDebugEnabled"/>
+ public static void DebugExt(this ILog logger, Func<object> callback, Exception exception)
+ {
+ try
+ {
+ if (!logger.IsDebugEnabled)
+ return;
- logger.Debug(callback(), exception);
- }
- catch (Exception ex)
- {
- log4net.Util.LogLog.Error(declaringType, "Exception while logging", ex);
- }
- }
+ logger.Debug(callback(), exception);
+ }
+ catch (Exception ex)
+ {
+ log4net.Util.LogLog.Error(declaringType, "Exception while logging", ex);
+ }
+ }
- #endregion
+ #endregion
- #region debug extension that use the formatter
+ #region debug extension that use the formatter
- /// <overloads>Log a message object with the <see cref="Level.Debug"/> level.</overloads> //TODO
- /// <summary>
- /// Log a message object with the <see cref="Level.Debug"/> level.
- /// </summary>
- /// <param name="logger">The logger on which the message is logged.</param>
- /// <param name="message">The message object to log.</param>
- /// <remarks>
- /// <para>
- /// This method first checks if this logger is <c>INFO</c>
- /// enabled by reading the value <seealso cref="ILog.IsDebugEnabled"/> property.
- /// This check happens always and does not depend on the <seealso cref="ILog"/>
- /// implementation. If this logger is <c>INFO</c> enabled, then it converts
- /// the message object (passed as parameter) to a string by invoking the appropriate
- /// <see cref="log4net.ObjectRenderer.IObjectRenderer"/>. It then
- /// proceeds to call all the registered appenders in this logger
- /// and also higher in the hierarchy depending on the value of
- /// the additivity flag.
- /// </para>
- /// <para><b>WARNING</b> Note that passing an <see cref="Exception"/>
- /// to this method will print the name of the <see cref="Exception"/>
- /// but no stack trace. To print a stack trace use the
- /// <see cref="DebugExt(ILog,object,Exception)"/> form instead.
- /// </para>
- /// </remarks>
- /// <seealso cref="ILog.Debug(object)"/>
- /// <seealso cref="ILog.IsDebugEnabled"/>
- public static void DebugExt(this ILog logger, object message)
- {
- try
- {
- if (!logger.IsDebugEnabled)
- return;
+ /// <overloads>Log a message object with the <see cref="Level.Debug"/> level.</overloads> //TODO
+ /// <summary>
+ /// Log a message object with the <see cref="Level.Debug"/> level.
+ /// </summary>
+ /// <param name="logger">The logger on which the message is logged.</param>
+ /// <param name="message">The message object to log.</param>
+ /// <remarks>
+ /// <para>
+ /// This method first checks if this logger is <c>INFO</c>
+ /// enabled by reading the value <seealso cref="ILog.IsDebugEnabled"/> property.
+ /// This check happens always and does not depend on the <seealso cref="ILog"/>
+ /// implementation. If this logger is <c>INFO</c> enabled, then it converts
+ /// the message object (passed as parameter) to a string by invoking the appropriate
+ /// <see cref="log4net.ObjectRenderer.IObjectRenderer"/>. It then
+ /// proceeds to call all the registered appenders in this logger
+ /// and also higher in the hierarchy depending on the value of
+ /// the additivity flag.
+ /// </para>
+ /// <para><b>WARNING</b> Note that passing an <see cref="Exception"/>
+ /// to this method will print the name of the <see cref="Exception"/>
+ /// but no stack trace. To print a stack trace use the
+ /// <see cref="DebugExt(ILog,object,Exception)"/> form instead.
+ /// </para>
+ /// </remarks>
+ /// <seealso cref="ILog.Debug(object)"/>
+ /// <seealso cref="ILog.IsDebugEnabled"/>
+ public static void DebugExt(this ILog logger, object message)
+ {
+ try
+ {
+ if (!logger.IsDebugEnabled)
+ return;
- logger.Debug(message);
- }
- catch (Exception ex)
- {
- log4net.Util.LogLog.Error(declaringType, "Exception while logging", ex);
- }
- }
+ logger.Debug(message);
+ }
+ catch (Exception ex)
+ {
+ log4net.Util.LogLog.Error(declaringType, "Exception while logging", ex);
+ }
+ }
- /// <summary>
- /// Log a message object with the <see cref="Level.Debug"/> level including
- /// the stack trace of the <see cref="Exception"/> passed
- /// as a parameter.
- /// </summary>
- /// <param name="logger">The logger on which the message is logged.</param>
- /// <param name="message">The message object to log.</param>
- /// <param name="exception">The exception to log, including its stack trace.</param>
- /// <remarks>
- /// <para>
- /// See the <see cref="DebugExt(ILog, object)"/> form for more detailed information.
- /// </para>
- /// </remarks>
- /// <seealso cref="ILog.Debug(object)"/>
- /// <seealso cref="ILog.IsDebugEnabled"/>
- public static void DebugExt(this ILog logger, object message, Exception exception)
- {
- try
- {
- if (!logger.IsDebugEnabled)
- return;
+ /// <summary>
+ /// Log a message object with the <see cref="Level.Debug"/> level including
+ /// the stack trace of the <see cref="Exception"/> passed
+ /// as a parameter.
+ /// </summary>
+ /// <param name="logger">The logger on which the message is logged.</param>
+ /// <param name="message">The message object to log.</param>
+ /// <param name="exception">The exception to log, including its stack trace.</param>
+ /// <remarks>
+ /// <para>
+ /// See the <see cref="DebugExt(ILog, object)"/> form for more detailed information.
+ /// </para>
+ /// </remarks>
+ /// <seealso cref="ILog.Debug(object)"/>
+ /// <seealso cref="ILog.IsDebugEnabled"/>
+ public static void DebugExt(this ILog logger, object message, Exception exception)
+ {
+ try
+ {
+ if (!logger.IsDebugEnabled)
+ return;
- logger.Debug(message, exception);
- }
- catch (Exception ex)
- {
- log4net.Util.LogLog.Error(declaringType, "Exception while logging", ex);
- }
- }
+ logger.Debug(message, exception);
+ }
+ catch (Exception ex)
+ {
+ log4net.Util.LogLog.Error(declaringType, "Exception while logging", ex);
+ }
+ }
- #endregion
+ #endregion
- #region debug extension that use string format
+ #region debug extension that use string format
- /// <summary>
- /// Logs a formatted message string with the <see cref="Level.Debug"/> level.
- /// </summary>
- /// <param name="logger">The logger on which the message is logged.</param>
- /// <param name="format">A String containing zero or more format items</param>
- /// <param name="arg0">An Object to format</param>
- /// <remarks>
- /// <para>
- /// The message is formatted using the <c>String.Format</c> method. See
- /// <see cref="String.Format(string, object[])"/> for details of the syntax of the format string and the behavior
- /// of the formatting.
- /// </para>
- /// <para>
- /// This method does not take an <see cref="Exception"/> object to include in the
- /// log event. To pass an <see cref="Exception"/> use one of the <see cref="DebugExt(ILog,object,Exception)"/>
- /// methods instead.
- /// </para>
- /// </remarks>
- /// <seealso cref="ILog.Debug(object)"/>
- /// <seealso cref="ILog.IsDebugEnabled"/>
- public static void DebugFormatExt(this ILog logger, string format, object arg0)
- {
- try
- {
- if (!logger.IsDebugEnabled)
- return;
+ /// <summary>
+ /// Logs a formatted message string with the <see cref="Level.Debug"/> level.
+ /// </summary>
+ /// <param name="logger">The logger on which the message is logged.</param>
+ /// <param name="format">A String containing zero or more format items</param>
+ /// <param name="arg0">An Object to format</param>
+ /// <remarks>
+ /// <para>
+ /// The message is formatted using the <c>String.Format</c> method. See
+ /// <see cref="String.Format(string, object[])"/> for details of the syntax of the format string and the behavior
+ /// of the formatting.
+ /// </para>
+ /// <para>
+ /// This method does not take an <see cref="Exception"/> object to include in the
+ /// log event. To pass an <see cref="Exception"/> use one of the <see cref="DebugExt(ILog,object,Exception)"/>
+ /// methods instead.
+ /// </para>
+ /// </remarks>
+ /// <seealso cref="ILog.Debug(object)"/>
+ /// <seealso cref="ILog.IsDebugEnabled"/>
+ public static void DebugFormatExt(this ILog logger, string format, object arg0)
+ {
+ try
+ {
+ if (!logger.IsDebugEnabled)
+ return;
- logger.DebugFormat(format, arg0);
- }
- catch (Exception ex)
- {
- log4net.Util.LogLog.Error(declaringType, "Exception while logging", ex);
- }
- }
+ logger.DebugFormat(format, arg0);
+ }
+ catch (Exception ex)
+ {
+ log4net.Util.LogLog.Error(declaringType, "Exception while logging", ex);
+ }
+ }
- /// <summary>
- /// Logs a formatted message string with the <see cref="Level.Debug"/> level.
- /// </summary>
- /// <param name="logger">The logger on which the message is logged.</param>
- /// <param name="format">A String containing zero or more format items</param>
- /// <param name="args">An Object array containing zero or more objects to format</param>
- /// <remarks>
- /// <para>
- /// The message is formatted using the <c>String.Format</c> method. See
- /// <see cref="String.Format(string, object[])"/> for details of the syntax of the format string and the behavior
- /// of the formatting.
- /// </para>
- /// <para>
- /// This method does not take an <see cref="Exception"/> object to include in the
- /// log event. To pass an <see cref="Exception"/> use one of the <see cref="DebugExt(ILog,object,Exception)"/>
- /// methods instead.
- /// </para>
- /// </remarks>
- /// <seealso cref="ILog.Debug(object)"/>
- /// <seealso cref="ILog.IsDebugEnabled"/>
- public static void DebugFormatExt(this ILog logger, string format, params object[] args)
- {
- try
- {
- if (!logger.IsDebugEnabled)
- return;
+ /// <summary>
+ /// Logs a formatted message string with the <see cref="Level.Debug"/> level.
+ /// </summary>
+ /// <param name="logger">The logger on which the message is logged.</param>
+ /// <param name="format">A String containing zero or more format items</param>
+ /// <param name="args">An Object array containing zero or more objects to format</param>
+ /// <remarks>
+ /// <para>
+ /// The message is formatted using the <c>String.Format</c> method. See
+ /// <see cref="String.Format(string, object[])"/> for details of the syntax of the format string and the behavior
+ /// of the formatting.
+ /// </para>
+ /// <para>
+ /// This method does not take an <see cref="Exception"/> object to include in the
+ /// log event. To pass an <see cref="Exception"/> use one of the <see cref="DebugExt(ILog,object,Exception)"/>
+ /// methods instead.
+ /// </para>
+ /// </remarks>
+ /// <seealso cref="ILog.Debug(object)"/>
+ /// <seealso cref="ILog.IsDebugEnabled"/>
+ public static void DebugFormatExt(this ILog logger, string format, params object[] args)
+ {
+ try
+ {
+ if (!logger.IsDebugEnabled)
+ return;
- logger.DebugFormat(format, args);
- }
- catch (Exception ex)
- {
- log4net.Util.LogLog.Error(declaringType, "Exception while logging", ex);
- }
- }
+ logger.DebugFormat(format, args);
+ }
+ catch (Exception ex)
+ {
+ log4net.Util.LogLog.Error(declaringType, "Exception while logging", ex);
+ }
+ }
- /// <summary>
- /// Logs a formatted message string with the <see cref="Level.Debug"/> level.
- /// </summary>
- /// <param name="provider">An <see cref="IFormatProvider"/> that supplies culture-specific formatting information</param>
- /// <param name="logger">The logger on which the message is logged.</param>
- /// <param name="format">A String containing zero or more format items</param>
- /// <param name="args">An Object array containing zero or more objects to format</param>
- /// <remarks>
- /// <para>
- /// The message is formatted using the <c>String.Format</c> method. See
- /// <see cref="String.Format(string, object[])"/> for details of the syntax of the format string and the behavior
- /// of the formatting.
- /// </para>
- /// <para>
- /// This method does not take an <see cref="Exception"/> object to include in the
- /// log event. To pass an <see cref="Exception"/> use one of the <see cref="DebugExt(ILog,object,Exception)"/>
- /// methods instead.
- /// </para>
- /// </remarks>
- /// <seealso cref="ILog.Debug(object)"/>
- /// <seealso cref="ILog.IsDebugEnabled"/>
- public static void DebugFormatExt(this ILog logger, IFormatProvider provider, string format, params object[] args)
- {
- try
- {
- if (!logger.IsDebugEnabled)
- return;
+ /// <summary>
+ /// Logs a formatted message string with the <see cref="Level.Debug"/> level.
+ /// </summary>
+ /// <param name="provider">An <see cref="IFormatProvider"/> that supplies culture-specific formatting information</param>
+ /// <param name="logger">The logger on which the message is logged.</param>
+ /// <param name="format">A String containing zero or more format items</param>
+ /// <param name="args">An Object array containing zero or more objects to format</param>
+ /// <remarks>
+ /// <para>
+ /// The message is formatted using the <c>String.Format</c> method. See
+ /// <see cref="String.Format(string, object[])"/> for details of the syntax of the format string and the behavior
+ /// of the formatting.
+ /// </para>
+ /// <para>
+ /// This method does not take an <see cref="Exception"/> object to include in the
+ /// log event. To pass an <see cref="Exception"/> use one of the <see cref="DebugExt(ILog,object,Exception)"/>
+ /// methods instead.
+ /// </para>
+ /// </remarks>
+ /// <seealso cref="ILog.Debug(object)"/>
+ /// <seealso cref="ILog.IsDebugEnabled"/>
+ public static void DebugFormatExt(this ILog logger, IFormatProvider provider, string format, params object[] args)
+ {
+ try
+ {
+ if (!logger.IsDebugEnabled)
+ return;
- logger.DebugFormat(provider, format, args);
- }
- catch (Exception ex)
- {
- log4net.Util.LogLog.Error(declaringType, "Exception while logging", ex);
- }
- }
+ logger.DebugFormat(provider, format, args);
+ }
+ catch (Exception ex)
+ {
+ log4net.Util.LogLog.Error(declaringType, "Exception while logging", ex);
+ }
+ }
- /// <summary>
- /// Logs a formatted message string with the <see cref="Level.Debug"/> level.
- /// </summary>
- /// <param name="logger">The logger on which the message is logged.</param>
- /// <param name="format">A String containing zero or more format items</param>
- /// <param name="arg0">An Object to format</param>
- /// <param name="arg1">An Object to format</param>
- /// <remarks>
- /// <para>
- /// The message is formatted using the <c>String.Format</c> method. See
- /// <see cref="String.Format(string, object[])"/> for details of the syntax of the format string and the behavior
- /// of the formatting.
- /// </para>
- /// <para>
- /// This method does not take an <see cref="Exception"/> object to include in the
- /// log event. To pass an <see cref="Exception"/> use one of the <see cref="DebugExt(ILog,object,Exception)"/>
- /// methods instead.
- /// </para>
- /// </remarks>
- /// <seealso cref="ILog.Debug(object)"/>
- /// <seealso cref="ILog.IsDebugEnabled"/>
- public static void DebugFormatExt(this ILog logger, string format, object arg0, object arg1)
- {
- try
- {
- if (!logger.IsDebugEnabled)
- return;
+ /// <summary>
+ /// Logs a formatted message string with the <see cref="Level.Debug"/> level.
+ /// </summary>
+ /// <param name="logger">The logger on which the message is logged.</param>
+ /// <param name="format">A String containing zero or more format items</param>
+ /// <param name="arg0">An Object to format</param>
+ /// <param name="arg1">An Object to format</param>
+ /// <remarks>
+ /// <para>
+ /// The message is formatted using the <c>String.Format</c> method. See
+ /// <see cref="String.Format(string, object[])"/> for details of the syntax of the format string and the behavior
+ /// of the formatting.
+ /// </para>
+ /// <para>
+ /// This method does not take an <see cref="Exception"/> object to include in the
+ /// log event. To pass an <see cref="Exception"/> use one of the <see cref="DebugExt(ILog,object,Exception)"/>
+ /// methods instead.
+ /// </para>
+ /// </remarks>
+ /// <seealso cref="ILog.Debug(object)"/>
+ /// <seealso cref="ILog.IsDebugEnabled"/>
+ public static void DebugFormatExt(this ILog logger, string format, object arg0, object arg1)
+ {
+ try
+ {
+ if (!logger.IsDebugEnabled)
+ return;
- logger.DebugFormat(format, arg0, arg1);
- }
- catch (Exception ex)
- {
- log4net.Util.LogLog.Error(declaringType, "Exception while logging", ex);
- }
- }
+ logger.DebugFormat(format, arg0, arg1);
+ }
+ catch (Exception ex)
+ {
+ log4net.Util.LogLog.Error(declaringType, "Exception while logging", ex);
+ }
+ }
- /// <summary>
- /// Logs a formatted message string with the <see cref="Level.Debug"/> level.
- /// </summary>
- /// <param name="logger">The logger on which the message is logged.</param>
- /// <param name="format">A String containing zero or more format items</param>
- /// <param name="arg0">An Object to format</param>
- /// <param name="arg1">An Object to format</param>
- /// <param name="arg2">An Object to format</param>
- /// <remarks>
- /// <para>
- /// The message is formatted using the <c>String.Format</c> method. See
- /// <see cref="String.Format(string, object[])"/> for details of the syntax of the format string and the behavior
- /// of the formatting.
- /// </para>
- /// <para>
- /// This method does not take an <see cref="Exception"/> object to include in the
- /// log event. To pass an <see cref="Exception"/> use one of the <see cref="DebugExt(ILog,object,Exception)"/>
- /// methods instead.
- /// </para>
- /// </remarks>
- /// <seealso cref="ILog.Debug(object)"/>
- /// <seealso cref="ILog.IsDebugEnabled"/>
- public static void DebugFormatExt(this ILog logger, string format, object arg0, object arg1, object arg2)
- {
- try
- {
- if (!logger.IsDebugEnabled)
- return;
+ /// <summary>
+ /// Logs a formatted message string with the <see cref="Level.Debug"/> level.
+ /// </summary>
+ /// <param name="logger">The logger on which the message is logged.</param>
+ /// <param name="format">A String containing zero or more format items</param>
+ /// <param name="arg0">An Object to format</param>
+ /// <param name="arg1">An Object to format</param>
+ /// <param name="arg2">An Object to format</param>
+ /// <remarks>
+ /// <para>
+ /// The message is formatted using the <c>String.Format</c> method. See
+ /// <see cref="String.Format(string, object[])"/> for details of the syntax of the format string and the behavior
+ /// of the formatting.
+ /// </para>
+ /// <para>
+ /// This method does not take an <see cref="Exception"/> object to include in the
+ /// log event. To pass an <see cref="Exception"/> use one of the <see cref="DebugExt(ILog,object,Exception)"/>
+ /// methods instead.
+ /// </para>
+ /// </remarks>
+ /// <seealso cref="ILog.Debug(object)"/>
+ /// <seealso cref="ILog.IsDebugEnabled"/>
+ public static void DebugFormatExt(this ILog logger, string format, object arg0, object arg1, object arg2)
+ {
+ try
+ {
+ if (!logger.IsDebugEnabled)
+ return;
- logger.DebugFormat(format, arg0, arg1, arg2);
- }
- catch (Exception ex)
- {
- log4net.Util.LogLog.Error(declaringType, "Exception while logging", ex);
- }
- }
+ logger.DebugFormat(format, arg0, arg1, arg2);
+ }
+ catch (Exception ex)
+ {
+ log4net.Util.LogLog.Error(declaringType, "Exception while logging", ex);
+ }
+ }
- #endregion
+ #endregion
- #endregion
+ #endregion
- #region info extensions
+ #region info extensions
- #region info extensions that uses log message lambda expression
+ #region info extensions that uses log message lambda expression
- /// <summary>
- /// Log a message object with the <see cref="Level.Info"/> level.
- /// </summary>
- /// <param name="logger">The logger on which the message is logged.</param>
- /// <param name="callback">The lambda expression that gets the object to log.</param>
- /// <remarks>
- /// <para>
- /// This method first checks if this logger is <c>INFO</c>
- /// enabled by reading the value <seealso cref="ILog.IsInfoEnabled"/> property.
- /// This check happens always and does not depend on the <seealso cref="ILog"/>
- /// implementation. If this logger is <c>INFO</c> enabled, then it converts
- /// the message object (retrieved by invocation of the provided callback) to a
- /// string by invoking the appropriate <see cref="log4net.ObjectRenderer.IObjectRenderer"/>.
- /// It then proceeds to call all the registered appenders in this logger
- /// and also higher in the hierarchy depending on the value of
- /// the additivity flag.
- /// </para>
- /// <para><b>WARNING</b> Note that passing an <see cref="Exception"/>
- /// to this method will print the name of the <see cref="Exception"/>
- /// but no stack trace. To print a stack trace use the
- /// <see cref="InfoExt(ILog,Func{object},Exception)"/> form instead.
- /// </para>
- /// </remarks>
- /// <seealso cref="ILog.Info(object)"/>
- /// <seealso cref="ILog.IsInfoEnabled"/>
- public static void InfoExt(this ILog logger, Func<object> callback)
- {
- try
- {
- if (!logger.IsInfoEnabled)
- return;
+ /// <summary>
+ /// Log a message object with the <see cref="Level.Info"/> level.
+ /// </summary>
+ /// <param name="logger">The logger on which the message is logged.</param>
+ /// <param name="callback">The lambda expression that gets the object to log.</param>
+ /// <remarks>
+ /// <para>
+ /// This method first checks if this logger is <c>INFO</c>
+ /// enabled by reading the value <seealso cref="ILog.IsInfoEnabled"/> property.
+ /// This check happens always and does not depend on the <seealso cref="ILog"/>
+ /// implementation. If this logger is <c>INFO</c> enabled, then it converts
+ /// the message object (retrieved by invocation of the provided callback) to a
+ /// string by invoking the appropriate <see cref="log4net.ObjectRenderer.IObjectRenderer"/>.
+ /// It then proceeds to call all the registered appenders in this logger
+ /// and also higher in the hierarchy depending on the value of
+ /// the additivity flag.
+ /// </para>
+ /// <para><b>WARNING</b> Note that passing an <see cref="Exception"/>
+ /// to this method will print the name of the <see cref="Exception"/>
+ /// but no stack trace. To print a stack trace use the
+ /// <see cref="InfoExt(ILog,Func{object},Exception)"/> form instead.
+ /// </para>
+ /// </remarks>
+ /// <seealso cref="ILog.Info(object)"/>
+ /// <seealso cref="ILog.IsInfoEnabled"/>
+ public static void InfoExt(this ILog logger, Func<object> callback)
+ {
+ try
+ {
+ if (!logger.IsInfoEnabled)
+ return;
- logger.Info(callback());
- }
- catch (Exception ex)
- {
- log4net.Util.LogLog.Error(declaringType, "Exception while logging", ex);
- }
- }
+ logger.Info(callback());
+ }
+ catch (Exception ex)
+ {
+ log4net.Util.LogLog.Error(declaringType, "Exception while logging", ex);
+ }
+ }
- /// <summary>
- /// Log a message object with the <see cref="Level.Info"/> level including
- /// the stack trace of the <see cref="Exception"/> passed
- /// as a parameter.
- /// </summary>
- /// <param name="logger">The logger on which the message is logged.</param>
- /// <param name="callback">The lambda expression that gets the object to log.</param>
- /// <param name="exception">The exception to log, including its stack trace.</param>
- /// <remarks>
- /// <para>
- /// See the <see cref="InfoExt(ILog, object)"/> form for more detailed information.
- /// </para>
- /// </remarks>
- /// <seealso cref="ILog.Info(object)"/>
- /// <seealso cref="ILog.IsInfoEnabled"/>
- public static void InfoExt(this ILog logger, Func<object> callback, Exception exception)
- {
- try
- {
- if (!logger.IsInfoEnabled)
- return;
+ /// <summary>
+ /// Log a message object with the <see cref="Level.Info"/> level including
+ /// the stack trace of the <see cref="Exception"/> passed
+ /// as a parameter.
+ /// </summary>
+ /// <param name="logger">The logger on which the message is logged.</param>
+ /// <param name="callback">The lambda expression that gets the object to log.</param>
+ /// <param name="exception">The exception to log, including its stack trace.</param>
+ /// <remarks>
+ /// <para>
+ /// See the <see cref="InfoExt(ILog, object)"/> form for more detailed information.
+ /// </para>
+ /// </remarks>
+ /// <seealso cref="ILog.Info(object)"/>
+ /// <seealso cref="ILog.IsInfoEnabled"/>
+ public static void InfoExt(this ILog logger, Func<object> callback, Exception exception)
+ {
+ try
+ {
+ if (!logger.IsInfoEnabled)
+ return;
- logger.Info(callback(), exception);
- }
- catch (Exception ex)
- {
- log4net.Util.LogLog.Error(declaringType, "Exception while logging", ex);
- }
- }
+ logger.Info(callback(), exception);
+ }
+ catch (Exception ex)
+ {
+ log4net.Util.LogLog.Error(declaringType, "Exception while logging", ex);
+ }
+ }
- #endregion
+ #endregion
- #region info extension that use the formatter
+ #region info extension that use the formatter
- /// <overloads>Log a message object with the <see cref="Level.Info"/> level.</overloads> //TODO
- /// <summary>
- /// Log a message object with the <see cref="Level.Info"/> level.
- /// </summary>
- /// <param name="logger">The logger on which the message is logged.</param>
- /// <param name="message">The message object to log.</param>
- /// <remarks>
- /// <para>
- /// This method first checks if this logger is <c>INFO</c>
- /// enabled by reading the value <seealso cref="ILog.IsInfoEnabled"/> property.
- /// This check happens always and does not depend on the <seealso cref="ILog"/>
- /// implementation. If this logger is <c>INFO</c> enabled, then it converts
- /// the message object (passed as parameter) to a string by invoking the appropriate
- /// <see cref="log4net.ObjectRenderer.IObjectRenderer"/>. It then
- /// proceeds to call all the registered appenders in this logger
- /// and also higher in the hierarchy depending on the value of
- /// the additivity flag.
- /// </para>
- /// <para><b>WARNING</b> Note that passing an <see cref="Exception"/>
- /// to this method will print the name of the <see cref="Exception"/>
- /// but no stack trace. To print a stack trace use the
- /// <see cref="InfoExt(ILog,object,Exception)"/> form instead.
- /// </para>
- /// </remarks>
- /// <seealso cref="ILog.Info(object)"/>
- /// <seealso cref="ILog.IsInfoEnabled"/>
- public static void InfoExt(this ILog logger, object message)
- {
- try
- {
- if (!logger.IsInfoEnabled)
- return;
+ /// <overloads>Log a message object with the <see cref="Level.Info"/> level.</overloads> //TODO
+ /// <summary>
+ /// Log a message object with the <see cref="Level.Info"/> level.
+ /// </summary>
+ /// <param name="logger">The logger on which the message is logged.</param>
+ /// <param name="message">The message object to log.</param>
+ /// <remarks>
+ /// <para>
+ /// This method first checks if this logger is <c>INFO</c>
+ /// enabled by reading the value <seealso cref="ILog.IsInfoEnabled"/> property.
+ /// This check happens always and does not depend on the <seealso cref="ILog"/>
+ /// implementation. If this logger is <c>INFO</c> enabled, then it converts
+ /// the message object (passed as parameter) to a string by invoking the appropriate
+ /// <see cref="log4net.ObjectRenderer.IObjectRenderer"/>. It then
+ /// proceeds to call all the registered appenders in this logger
+ /// and also higher in the hierarchy depending on the value of
+ /// the additivity flag.
+ /// </para>
+ /// <para><b>WARNING</b> Note that passing an <see cref="Exception"/>
+ /// to this method will print the name of the <see cref="Exception"/>
+ /// but no stack trace. To print a stack trace use the
+ /// <see cref="InfoExt(ILog,object,Exception)"/> form instead.
+ /// </para>
+ /// </remarks>
+ /// <seealso cref="ILog.Info(object)"/>
+ /// <seealso cref="ILog.IsInfoEnabled"/>
+ public static void InfoExt(this ILog logger, object message)
+ {
+ try
+ {
+ if (!logger.IsInfoEnabled)
+ return;
- logger.Info(message);
- }
- catch (Exception ex)
- {
- log4net.Util.LogLog.Error(declaringType, "Exception while logging", ex);
- }
- }
+ logger.Info(message);
+ }
+ catch (Exception ex)
+ {
+ log4net.Util.LogLog.Error(declaringType, "Exception while logging", ex);
+ }
+ }
- /// <summary>
- /// Log a message object with the <see cref="Level.Info"/> level including
- /// the stack trace of the <see cref="Exception"/> passed
- /// as a parameter.
- /// </summary>
- /// <param name="logger">The logger on which the message is logged.</param>
- /// <param name="message">The message object to log.</param>
- /// <param name="exception">The exception to log, including its stack trace.</param>
- /// <remarks>
- /// <para>
- /// See the <see cref="InfoExt(ILog, object)"/> form for more detailed information.
- /// </para>
- /// </remarks>
- /// <seealso cref="ILog.Info(object)"/>
- /// <seealso cref="ILog.IsInfoEnabled"/>
- public static void InfoExt(this ILog logger, object message, Exception exception)
- {
- try
- {
- if (!logger.IsInfoEnabled)
- return;
+ /// <summary>
+ /// Log a message object with the <see cref="Level.Info"/> level including
+ /// the stack trace of the <see cref="Exception"/> passed
+ /// as a parameter.
+ /// </summary>
+ /// <param name="logger">The logger on which the message is logged.</param>
+ /// <param name="message">The message object to log.</param>
+ /// <param name="exception">The exception to log, including its stack trace.</param>
+ /// <remarks>
+ /// <para>
+ /// See the <see cref="InfoExt(ILog, object)"/> form for more detailed information.
+ /// </para>
+ /// </remarks>
+ /// <seealso cref="ILog.Info(object)"/>
+ /// <seealso cref="ILog.IsInfoEnabled"/>
+ public static void InfoExt(this ILog logger, object message, Exception exception)
+ {
+ try
+ {
+ if (!logger.IsInfoEnabled)
+ return;
- logger.Info(message, exception);
- }
- catch (Exception ex)
- {
- log4net.Util.LogLog.Error(declaringType, "Exception while logging", ex);
- }
- }
+ logger.Info(message, exception);
+ }
+ catch (Exception ex)
+ {
+ log4net.Util.LogLog.Error(declaringType, "Exception while logging", ex);
+ }
+ }
- #endregion
+ #endregion
- #region info extension that use string format
+ #region info extension that use string format
- /// <summary>
- /// Logs a formatted message string with the <see cref="Level.Info"/> level.
- /// </summary>
- /// <param name="logger">The logger on which the message is logged.</param>
- /// <param name="format">A String containing zero or more format items</param>
- /// <param name="arg0">An Object to format</param>
- /// <remarks>
- /// <para>
- /// The message is formatted using the <c>String.Format</c> method. See
- /// <see cref="String.Format(string, object[])"/> for details of the syntax of the format string and the behavior
- /// of the formatting.
- /// </para>
- /// <para>
- /// This method does not take an <see cref="Exception"/> object to include in the
- /// log event. To pass an <see cref="Exception"/> use one of the <see cref="InfoExt(ILog,object,Exception)"/>
- /// methods instead.
- /// </para>
- /// </remarks>
- /// <seealso cref="ILog.Info(object)"/>
- /// <seealso cref="ILog.IsInfoEnabled"/>
- public static void InfoFormatExt(this ILog logger, string format, object arg0)
- {
- try
- {
- if (!logger.IsInfoEnabled)
- return;
+ /// <summary>
+ /// Logs a formatted message string with the <see cref="Level.Info"/> level.
+ /// </summary>
+ /// <param name="logger">The logger on which the message is logged.</param>
+ /// <param name="format">A String containing zero or more format items</param>
+ /// <param name="arg0">An Object to format</param>
+ /// <remarks>
+ /// <para>
+ /// The message is formatted using the <c>String.Format</c> method. See
+ /// <see cref="String.Format(string, object[])"/> for details of the syntax of the format string and the behavior
+ /// of the formatting.
+ /// </para>
+ /// <para>
+ /// This method does not take an <see cref="Exception"/> object to include in the
+ /// log event. To pass an <see cref="Exception"/> use one of the <see cref="InfoExt(ILog,object,Exception)"/>
+ /// methods instead.
+ /// </para>
+ /// </remarks>
+ /// <seealso cref="ILog.Info(object)"/>
+ /// <seealso cref="ILog.IsInfoEnabled"/>
+ public static void InfoFormatExt(this ILog logger, string format, object arg0)
+ {
+ try
+ {
+ if (!logger.IsInfoEnabled)
+ return;
- logger.InfoFormat(format, arg0);
- }
- catch (Exception ex)
- {
- log4net.Util.LogLog.Error(declaringType, "Exception while logging", ex);
- }
- }
+ logger.InfoFormat(format, arg0);
+ }
+ catch (Exception ex)
+ {
+ log4net.Util.LogLog.Error(declaringType, "Exception while logging", ex);
+ }
+ }
- /// <summary>
- /// Logs a formatted message string with the <see cref="Level.Info"/> level.
- /// </summary>
- /// <param name="logger">The logger on which the message is logged.</param>
- /// <param name="format">A String containing zero or more format items</param>
- /// <param name="args">An Object array containing zero or more objects to format</param>
- /// <remarks>
- /// <para>
- /// The message is formatted using the <c>String.Format</c> method. See
- /// <see cref="String.Format(string, object[])"/> for details of the syntax of the format string and the behavior
- /// of the formatting.
- /// </para>
- /// <para>
- /// This method does not take an <see cref="Exception"/> object to include in the
- /// log event. To pass an <see cref="Exception"/> use one of the <see cref="InfoExt(ILog,object,Exception)"/>
- /// methods instead.
- /// </para>
- /// </remarks>
- /// <seealso cref="ILog.Info(object)"/>
- /// <seealso cref="ILog.IsInfoEnabled"/>
- public static void InfoFormatExt(this ILog logger, string format, params object[] args)
- {
- try
- {
- if (!logger.IsInfoEnabled)
- return;
+ /// <summary>
+ /// Logs a formatted message string with the <see cref="Level.Info"/> level.
+ /// </summary>
+ /// <param name="logger">The logger on which the message is logged.</param>
+ /// <param name="format">A String containing zero or more format items</param>
+ /// <param name="args">An Object array containing zero or more objects to format</param>
+ /// <remarks>
+ /// <para>
+ /// The message is formatted using the <c>String.Format</c> method. See
+ /// <see cref="String.Format(string, object[])"/> for details of the syntax of the format string and the behavior
+ /// of the formatting.
+ /// </para>
+ /// <para>
+ /// This method does not take an <see cref="Exception"/> object to include in the
+ /// log event. To pass an <see cref="Exception"/> use one of the <see cref="InfoExt(ILog,object,Exception)"/>
+ /// methods instead.
+ /// </para>
+ /// </remarks>
+ /// <seealso cref="ILog.Info(object)"/>
+ /// <seealso cref="ILog.IsInfoEnabled"/>
+ public static void InfoFormatExt(this ILog logger, string format, params object[] args)
+ {
+ try
+ {
+ if (!logger.IsInfoEnabled)
+ return;
- logger.InfoFormat(format, args);
- }
- catch (Exception ex)
- {
- log4net.Util.LogLog.Error(declaringType, "Exception while logging", ex);
- }
- }
+ logger.InfoFormat(format, args);
+ }
+ catch (Exception ex)
+ {
+ log4net.Util.LogLog.Error(declaringType, "Exception while logging", ex);
+ }
+ }
- /// <summary>
- /// Logs a formatted message string with the <see cref="Level.Info"/> level.
- /// </summary>
- /// <param name="provider">An <see cref="IFormatProvider"/> that supplies culture-specific formatting information</param>
- /// <param name="logger">The logger on which the message is logged.</param>
- /// <param name="format">A String containing zero or more format items</param>
- /// <param name="args">An Object array containing zero or more objects to format</param>
- /// <remarks>
- /// <para>
- /// The message is formatted using the <c>String.Format</c> method. See
- /// <see cref="String.Format(string, object[])"/> for details of the syntax of the format string and the behavior
- /// of the formatting.
- /// </para>
- /// <para>
- /// This method does not take an <see cref="Exception"/> object to include in the
- /// log event. To pass an <see cref="Exception"/> use one of the <see cref="InfoExt(ILog,object,Exception)"/>
- /// methods instead.
- /// </para>
- /// </remarks>
- /// <seealso cref="ILog.Info(object)"/>
- /// <seealso cref="ILog.IsInfoEnabled"/>
- public static void InfoFormatExt(this ILog logger, IFormatProvider provider, string format, params object[] args)
- {
- try
- {
- if (!logger.IsInfoEnabled)
- return;
+ /// <summary>
+ /// Logs a formatted message string with the <see cref="Level.Info"/> level.
+ /// </summary>
+ /// <param name="provider">An <see cref="IFormatProvider"/> that supplies culture-specific formatting information</param>
+ /// <param name="logger">The logger on which the message is logged.</param>
+ /// <param name="format">A String containing zero or more format items</param>
+ /// <param name="args">An Object array containing zero or more objects to format</param>
+ /// <remarks>
+ /// <para>
+ /// The message is formatted using the <c>String.Format</c> method. See
+ /// <see cref="String.Format(string, object[])"/> for details of the syntax of the format string and the behavior
+ /// of the formatting.
+ /// </para>
+ /// <para>
+ /// This method does not take an <see cref="Exception"/> object to include in the
+ /// log event. To pass an <see cref="Exception"/> use one of the <see cref="InfoExt(ILog,object,Exception)"/>
+ /// methods instead.
+ /// </para>
+ /// </remarks>
+ /// <seealso cref="ILog.Info(object)"/>
+ /// <seealso cref="ILog.IsInfoEnabled"/>
+ public static void InfoFormatExt(this ILog logger, IFormatProvider provider, string format, params object[] args)
+ {
+ try
+ {
+ if (!logger.IsInfoEnabled)
+ return;
- logger.InfoFormat(provider, format, args);
- }
- catch (Exception ex)
- {
- log4net.Util.LogLog.Error(declaringType, "Exception while logging", ex);
- }
- }
+ logger.InfoFormat(provider, format, args);
+ }
+ catch (Exception ex)
+ {
+ log4net.Util.LogLog.Error(declaringType, "Exception while logging", ex);
+ }
+ }
- /// <summary>
- /// Logs a formatted message string with the <see cref="Level.Info"/> level.
- /// </summary>
- /// <param name="logger">The logger on which the message is logged.</param>
- /// <param name="format">A String containing zero or more format items</param>
- /// <param name="arg0">An Object to format</param>
- /// <param name="arg1">An Object to format</param>
- /// <remarks>
- /// <para>
- /// The message is formatted using the <c>String.Format</c> method. See
- /// <see cref="String.Format(string, object[])"/> for details of the syntax of the format string and the behavior
- /// of the formatting.
- /// </para>
- /// <para>
- /// This method does not take an <see cref="Exception"/> object to include in the
- /// log event. To pass an <see cref="Exception"/> use one of the <see cref="InfoExt(ILog,object,Exception)"/>
- /// methods instead.
- /// </para>
- /// </remarks>
- /// <seealso cref="ILog.Info(object)"/>
- /// <seealso cref="ILog.IsInfoEnabled"/>
- public static void InfoFormatExt(this ILog logger, string format, object arg0, object arg1)
- {
- try
- {
- if (!logger.IsInfoEnabled)
- return;
+ /// <summary>
+ /// Logs a formatted message string with the <see cref="Level.Info"/> level.
+ /// </summary>
+ /// <param name="logger">The logger on which the message is logged.</param>
+ /// <param name="format">A String containing zero or more format items</param>
+ /// <param name="arg0">An Object to format</param>
+ /// <param name="arg1">An Object to format</param>
+ /// <remarks>
+ /// <para>
+ /// The message is formatted using the <c>String.Format</c> method. See
+ /// <see cref="String.Format(string, object[])"/> for details of the syntax of the format string and the behavior
+ /// of the formatting.
+ /// </para>
+ /// <para>
+ /// This method does not take an <see cref="Exception"/> object to include in the
+ /// log event. To pass an <see cref="Exception"/> use one of the <see cref="InfoExt(ILog,object,Exception)"/>
+ /// methods instead.
+ /// </para>
+ /// </remarks>
+ /// <seealso cref="ILog.Info(object)"/>
+ /// <seealso cref="ILog.IsInfoEnabled"/>
+ public static void InfoFormatExt(this ILog logger, string format, object arg0, object arg1)
+ {
+ try
+ {
+ if (!logger.IsInfoEnabled)
+ return;
- logger.InfoFormat(format, arg0, arg1);
- }
- catch (Exception ex)
- {
- log4net.Util.LogLog.Error(declaringType, "Exception while logging", ex);
- }
- }
+ logger.InfoFormat(format, arg0, arg1);
+ }
+ catch (Exception ex)
+ {
+ log4net.Util.LogLog.Error(declaringType, "Exception while logging", ex);
+ }
+ }
- /// <summary>
- /// Logs a formatted message string with the <see cref="Level.Info"/> level.
- /// </summary>
- /// <param name="logger">The logger on which the message is logged.</param>
- /// <param name="format">A String containing zero or more format items</param>
- /// <param name="arg0">An Object to format</param>
- /// <param name="arg1">An Object to format</param>
- /// <param name="arg2">An Object to format</param>
- /// <remarks>
- /// <para>
- /// The message is formatted using the <c>String.Format</c> method. See
- /// <see cref="String.Format(string, object[])"/> for details of the syntax of the format string and the behavior
- /// of the formatting.
- /// </para>
- /// <para>
- /// This method does not take an <see cref="Exception"/> object to include in the
- /// log event. To pass an <see cref="Exception"/> use one of the <see cref="InfoExt(ILog,object,Exception)"/>
- /// methods instead.
- /// </para>
- /// </remarks>
- /// <seealso cref="ILog.Info(object)"/>
- /// <seealso cref="ILog.IsInfoEnabled"/>
- public static void InfoFormatExt(this ILog logger, string format, object arg0, object arg1, object arg2)
- {
- try
- {
- if (!logger.IsInfoEnabled)
- return;
+ /// <summary>
+ /// Logs a formatted message string with the <see cref="Level.Info"/> level.
+ /// </summary>
+ /// <param name="logger">The logger on which the message is logged.</param>
+ /// <param name="format">A String containing zero or more format items</param>
+ /// <param name="arg0">An Object to format</param>
+ /// <param name="arg1">An Object to format</param>
+ /// <param name="arg2">An Object to format</param>
+ /// <remarks>
+ /// <para>
+ /// The message is formatted using the <c>String.Format</c> method. See
+ /// <see cref="String.Format(string, object[])"/> for details of the syntax of the format string and the behavior
+ /// of the formatting.
+ /// </para>
+ /// <para>
+ /// This method does not take an <see cref="Exception"/> object to include in the
+ /// log event. To pass an <see cref="Exception"/> use one of the <see cref="InfoExt(ILog,object,Exception)"/>
+ /// methods instead.
+ /// </para>
+ /// </remarks>
+ /// <seealso cref="ILog.Info(object)"/>
+ /// <seealso cref="ILog.IsInfoEnabled"/>
+ public static void InfoFormatExt(this ILog logger, string format, object arg0, object arg1, object arg2)
+ {
+ try
+ {
+ if (!logger.IsInfoEnabled)
+ return;
- logger.InfoFormat(format, arg0, arg1, arg2);
- }
- catch (Exception ex)
- {
- log4net.Util.LogLog.Error(declaringType, "Exception while logging", ex);
- }
- }
+ logger.InfoFormat(format, arg0, arg1, arg2);
+ }
+ catch (Exception ex)
+ {
+ log4net.Util.LogLog.Error(declaringType, "Exception while logging", ex);
+ }
+ }
- #endregion
+ #endregion
- #endregion
+ #endregion
- #region warn extensions
+ #region warn extensions
- #region warn extensions that uses log message lambda expression
+ #region warn extensions that uses log message lambda expression
- /// <summary>
- /// Log a message object with the <see cref="Level.Warn"/> level.
- /// </summary>
- /// <param name="logger">The logger on which the message is logged.</param>
- /// <param name="callback">The lambda expression that gets the object to log.</param>
- /// <remarks>
- /// <para>
- /// This method first checks if this logger is <c>WARN</c>
- /// enabled by reading the value <seealso cref="ILog.IsWarnEnabled"/> property.
- /// This check happens always and does not depend on the <seealso cref="ILog"/>
- /// implementation. If this logger is <c>WARN</c> enabled, then it converts
- /// the message object (retrieved by invocation of the provided callback) to a
- /// string by invoking the appropriate <see cref="log4net.ObjectRenderer.IObjectRenderer"/>.
- /// It then proceeds to call all the registered appenders in this logger
- /// and also higher in the hierarchy depending on the value of
- /// the additivity flag.
- /// </para>
- /// <para><b>WARNING</b> Note that passing an <see cref="Exception"/>
- /// to this method will print the name of the <see cref="Exception"/>
- /// but no stack trace. To print a stack trace use the
- /// <see cref="WarnExt(ILog,Func{object},Exception)"/> form instead.
- /// </para>
- /// </remarks>
- /// <seealso cref="ILog.Warn(object)"/>
- /// <seealso cref="ILog.IsWarnEnabled"/>
- public static void WarnExt(this ILog logger, Func<object> callback)
- {
- try
- {
- if (!logger.IsWarnEnabled)
- return;
+ /// <summary>
+ /// Log a message object with the <see cref="Level.Warn"/> level.
+ /// </summary>
+ /// <param name="logger">The logger on which the message is logged.</param>
+ /// <param name="callback">The lambda expression that gets the object to log.</param>
+ /// <remarks>
+ /// <para>
+ /// This method first checks if this logger is <c>WARN</c>
+ /// enabled by reading the value <seealso cref="ILog.IsWarnEnabled"/> property.
+ /// This check happens always and does not depend on the <seealso cref="ILog"/>
+ /// implementation. If this logger is <c>WARN</c> enabled, then it converts
+ /// the message object (retrieved by invocation of the provided callback) to a
+ /// string by invoking the appropriate <see cref="log4net.ObjectRenderer.IObjectRenderer"/>.
+ /// It then proceeds to call all the registered appenders in this logger
+ /// and also higher in the hierarchy depending on the value of
+ /// the additivity flag.
+ /// </para>
+ /// <para><b>WARNING</b> Note that passing an <see cref="Exception"/>
+ /// to this method will print the name of the <see cref="Exception"/>
+ /// but no stack trace. To print a stack trace use the
+ /// <see cref="WarnExt(ILog,Func{object},Exception)"/> form instead.
+ /// </para>
+ /// </remarks>
+ /// <seealso cref="ILog.Warn(object)"/>
+ /// <seealso cref="ILog.IsWarnEnabled"/>
+ public static void WarnExt(this ILog logger, Func<object> callback)
+ {
+ try
+ {
+ if (!logger.IsWarnEnabled)
+ return;
- logger.Warn(callback());
- }
- catch (Exception ex)
- {
- log4net.Util.LogLog.Error(declaringType, "Exception while logging", ex);
- }
- }
+ logger.Warn(callback());
+ }
+ catch (Exception ex)
+ {
+ log4net.Util.LogLog.Error(declaringType, "Exception while logging", ex);
+ }
+ }
- /// <summary>
- /// Log a message object with the <see cref="Level.Warn"/> level including
- /// the stack trace of the <see cref="Exception"/> passed
- /// as a parameter.
- /// </summary>
- /// <param name="logger">The logger on which the message is logged.</param>
- /// <param name="callback">The lambda expression that gets the object to log.</param>
- /// <param name="exception">The exception to log, including its stack trace.</param>
- /// <remarks>
- /// <para>
- /// See the <see cref="WarnExt(ILog, object)"/> form for more detailed information.
- /// </para>
- /// </remarks>
- /// <seealso cref="ILog.Warn(object)"/>
- /// <seealso cref="ILog.IsWarnEnabled"/>
- public static void WarnExt(this ILog logger, Func<object> callback, Exception exception)
- {
- try
- {
- if (!logger.IsWarnEnabled)
- return;
+ /// <summary>
+ /// Log a message object with the <see cref="Level.Warn"/> level including
+ /// the stack trace of the <see cref="Exception"/> passed
+ /// as a parameter.
+ /// </summary>
+ /// <param name="logger">The logger on which the message is logged.</param>
+ /// <param name="callback">The lambda expression that gets the object to log.</param>
+ /// <param name="exception">The exception to log, including its stack trace.</param>
+ /// <remarks>
+ /// <para>
+ /// See the <see cref="WarnExt(ILog, object)"/> form for more detailed information.
+ /// </para>
+ /// </remarks>
+ /// <seealso cref="ILog.Warn(object)"/>
+ /// <seealso cref="ILog.IsWarnEnabled"/>
+ public static void WarnExt(this ILog logger, Func<object> callback, Exception exception)
+ {
+ try
+ {
+ if (!logger.IsWarnEnabled)
+ return;
- logger.Warn(callback(), exception);
- }
- catch (Exception ex)
- {
- log4net.Util.LogLog.Error(declaringType, "Exception while logging", ex);
- }
- }
+ logger.Warn(callback(), exception);
+ }
+ catch (Exception ex)
+ {
+ log4net.Util.LogLog.Error(declaringType, "Exception while logging", ex);
+ }
+ }
- #endregion
+ #endregion
- #region warn extension that use the formatter
+ #region warn extension that use the formatter
- /// <overloads>Log a message object with the <see cref="Level.Warn"/> level.</overloads> //TODO
- /// <summary>
- /// Log a message object with the <see cref="Level.Warn"/> level.
- /// </summary>
- /// <param name="logger">The logger on which the message is logged.</param>
- /// <param name="message">The message object to log.</param>
- /// <remarks>
- /// <para>
- /// This method first checks if this logger is <c>WARN</c>
- /// enabled by reading the value <seealso cref="ILog.IsWarnEnabled"/> property.
- /// This check happens always and does not depend on the <seealso cref="ILog"/>
- /// implementation. If this logger is <c>WARN</c> enabled, then it converts
- /// the message object (passed as parameter) to a string by invoking the appropriate
- /// <see cref="log4net.ObjectRenderer.IObjectRenderer"/>. It then
- /// proceeds to call all the registered appenders in this logger
- /// and also higher in the hierarchy depending on the value of
- /// the additivity flag.
- /// </para>
- /// <para><b>WARNING</b> Note that passing an <see cref="Exception"/>
- /// to this method will print the name of the <see cref="Exception"/>
- /// but no stack trace. To print a stack trace use the
- /// <see cref="WarnExt(ILog,object,Exception)"/> form instead.
- /// </para>
- /// </remarks>
- /// <seealso cref="ILog.Warn(object)"/>
- /// <seealso cref="ILog.IsWarnEnabled"/>
- public static void WarnExt(this ILog logger, object message)
- {
- try
- {
- if (!logger.IsWarnEnabled)
- return;
+ /// <overloads>Log a message object with the <see cref="Level.Warn"/> level.</overloads> //TODO
+ /// <summary>
+ /// Log a message object with the <see cref="Level.Warn"/> level.
+ /// </summary>
+ /// <param name="logger">The logger on which the message is logged.</param>
+ /// <param name="message">The message object to log.</param>
+ /// <remarks>
+ /// <para>
+ /// This method first checks if this logger is <c>WARN</c>
+ /// enabled by reading the value <seealso cref="ILog.IsWarnEnabled"/> property.
+ /// This check happens always and does not depend on the <seealso cref="ILog"/>
+ /// implementation. If this logger is <c>WARN</c> enabled, then it converts
+ /// the message object (passed as parameter) to a string by invoking the appropriate
+ /// <see cref="log4net.ObjectRenderer.IObjectRenderer"/>. It then
+ /// proceeds to call all the registered appenders in this logger
+ /// and also higher in the hierarchy depending on the value of
+ /// the additivity flag.
+ /// </para>
+ /// <para><b>WARNING</b> Note that passing an <see cref="Exception"/>
+ /// to this method will print the name of the <see cref="Exception"/>
+ /// but no stack trace. To print a stack trace use the
+ /// <see cref="WarnExt(ILog,object,Exception)"/> form instead.
+ /// </para>
+ /// </remarks>
+ /// <seealso cref="ILog.Warn(object)"/>
+ /// <seealso cref="ILog.IsWarnEnabled"/>
+ public static void WarnExt(this ILog logger, object message)
+ {
+ try
+ {
+ if (!logger.IsWarnEnabled)
+ return;
- logger.Warn(message);
- }
- catch (Exception ex)
- {
- log4net.Util.LogLog.Error(declaringType, "Exception while logging", ex);
- }
- }
+ logger.Warn(message);
+ }
+ catch (Exception ex)
+ {
+ log4net.Util.LogLog.Error(declaringType, "Exception while logging", ex);
+ }
+ }
- /// <summary>
- /// Log a message object with the <see cref="Level.Warn"/> level including
- /// the stack trace of the <see cref="Exception"/> passed
- /// as a parameter.
- /// </summary>
- /// <param name="logger">The logger on which the message is logged.</param>
- /// <param name="message">The message object to log.</param>
- /// <param name="exception">The exception to log, including its stack trace.</param>
- /// <remarks>
- /// <para>
- /// See the <see cref="WarnExt(ILog, object)"/> form for more detailed information.
- /// </para>
- /// </remarks>
- /// <seealso cref="ILog.Warn(object)"/>
- /// <seealso cref="ILog.IsWarnEnabled"/>
- public static void WarnExt(this ILog logger, object message, Exception exception)
- {
- try
- {
- if (!logger.IsWarnEnabled)
- return;
+ /// <summary>
+ /// Log a message object with the <see cref="Level.Warn"/> level including
+ /// the stack trace of the <see cref="Exception"/> passed
+ /// as a parameter.
+ /// </summary>
+ /// <param name="logger">The logger on which the message is logged.</param>
+ /// <param name="message">The message object to log.</param>
+ /// <param name="exception">The exception to log, including its stack trace.</param>
+ /// <remarks>
+ /// <para>
+ /// See the <see cref="WarnExt(ILog, object)"/> form for more detailed information.
+ /// </para>
+ /// </remarks>
+ /// <seealso cref="ILog.Warn(object)"/>
+ /// <seealso cref="ILog.IsWarnEnabled"/>
+ public static void WarnExt(this ILog logger, object message, Exception exception)
+ {
+ try
+ {
+ if (!logger.IsWarnEnabled)
+ return;
- logger.Warn(message, exception);
- }
- catch (Exception ex)
- {
- log4net.Util.LogLog.Error(declaringType, "Exception while logging", ex);
- }
- }
+ logger.Warn(message, exception);
+ }
+ catch (Exception ex)
+ {
+ log4net.Util.LogLog.Error(declaringType, "Exception while logging", ex);
+ }
+ }
- #endregion
+ #endregion
- #region warn extension that use string format
+ #region warn extension that use string format
- /// <summary>
- /// Logs a formatted message string with the <see cref="Level.Warn"/> level.
- /// </summary>
- /// <param name="logger">The logger on which the message is logged.</param>
- /// <param name="format">A String containing zero or more format items</param>
- /// <param name="arg0">An Object to format</param>
- /// <remarks>
- /// <para>
- /// The message is formatted using the <c>String.Format</c> method. See
- /// <see cref="String.Format(string, object[])"/> for details of the syntax of the format string and the behavior
- /// of the formatting.
- /// </para>
- /// <para>
- /// This method does not take an <see cref="Exception"/> object to include in the
- /// log event. To pass an <see cref="Exception"/> use one of the <see cref="WarnExt(ILog,object,Exception)"/>
- /// methods instead.
- /// </para>
- /// </remarks>
- /// <seealso cref="ILog.Warn(object)"/>
- /// <seealso cref="ILog.IsWarnEnabled"/>
- public static void WarnFormatExt(this ILog logger, string format, object arg0)
- {
- try
- {
- if (!logger.IsWarnEnabled)
- return;
+ /// <summary>
+ /// Logs a formatted message string with the <see cref="Level.Warn"/> level.
+ /// </summary>
+ /// <param name="logger">The logger on which the message is logged.</param>
+ /// <param name="format">A String containing zero or more format items</param>
+ /// <param name="arg0">An Object to format</param>
+ /// <remarks>
+ /// <para>
+ /// The message is formatted using the <c>String.Format</c> method. See
+ /// <see cref="String.Format(string, object[])"/> for details of the syntax of the format string and the behavior
+ /// of the formatting.
+ /// </para>
+ /// <para>
+ /// This method does not take an <see cref="Exception"/> object to include in the
+ /// log event. To pass an <see cref="Exception"/> use one of the <see cref="WarnExt(ILog,object,Exception)"/>
+ /// methods instead.
+ /// </para>
+ /// </remarks>
+ /// <seealso cref="ILog.Warn(object)"/>
+ /// <seealso cref="ILog.IsWarnEnabled"/>
+ public static void WarnFormatExt(this ILog logger, string format, object arg0)
+ {
+ try
+ {
+ if (!logger.IsWarnEnabled)
+ return;
- logger.WarnFormat(format, arg0);
- }
- catch (Exception ex)
- {
- log4net.Util.LogLog.Error(declaringType, "Exception while logging", ex);
- }
- }
+ logger.WarnFormat(format, arg0);
+ }
+ catch (Exception ex)
+ {
+ log4net.Util.LogLog.Error(declaringType, "Exception while logging", ex);
+ }
+ }
- /// <summary>
- /// Logs a formatted message string with the <see cref="Level.Warn"/> level.
- /// </summary>
- /// <param name="logger">The logger on which the message is logged.</param>
- /// <param name="format">A String containing zero or more format items</param>
- /// <param name="args">An Object array containing zero or more objects to format</param>
- /// <remarks>
- /// <para>
- /// The message is formatted using the <c>String.Format</c> method. See
- /// <see cref="String.Format(string, object[])"/> for details of the syntax of the format string and the behavior
- /// of the formatting.
- /// </para>
- /// <para>
- /// This method does not take an <see cref="Exception"/> object to include in the
- /// log event. To pass an <see cref="Exception"/> use one of the <see cref="WarnExt(ILog,object,Exception)"/>
- /// methods instead.
- /// </para>
- /// </remarks>
- /// <seealso cref="ILog.Warn(object)"/>
- /// <seealso cref="ILog.IsWarnEnabled"/>
- public static void WarnFormatExt(this ILog logger, string format, params object[] args)
- {
- try
- {
- if (!logger.IsWarnEnabled)
- return;
+ /// <summary>
+ /// Logs a formatted message string with the <see cref="Level.Warn"/> level.
+ /// </summary>
+ /// <param name="logger">The logger on which the message is logged.</param>
+ /// <param name="format">A String containing zero or more format items</param>
+ /// <param name="args">An Object array containing zero or more objects to format</param>
+ /// <remarks>
+ /// <para>
+ /// The message is formatted using the <c>String.Format</c> method. See
+ /// <see cref="String.Format(string, object[])"/> for details of the syntax of the format string and the behavior
+ /// of the formatting.
+ /// </para>
+ /// <para>
+ /// This method does not take an <see cref="Exception"/> object to include in the
+ /// log event. To pass an <see cref="Exception"/> use one of the <see cref="WarnExt(ILog,object,Exception)"/>
+ /// methods instead.
+ /// </para>
+ /// </remarks>
+ /// <seealso cref="ILog.Warn(object)"/>
+ /// <seealso cref="ILog.IsWarnEnabled"/>
+ public static void WarnFormatExt(this ILog logger, string format, params object[] args)
+ {
+ try
+ {
+ if (!logger.IsWarnEnabled)
+ return;
- logger.WarnFormat(format, args);
- }
- catch (Exception ex)
- {
- log4net.Util.LogLog.Error(declaringType, "Exception while logging", ex);
- }
- }
+ logger.WarnFormat(format, args);
+ }
+ catch (Exception ex)
+ {
+ log4net.Util.LogLog.Error(declaringType, "Exception while logging", ex);
+ }
+ }
- /// <summary>
- /// Logs a formatted message string with the <see cref="Level.Warn"/> level.
- /// </summary>
- /// <param name="provider">An <see cref="IFormatProvider"/> that supplies culture-specific formatting information</param>
- /// <param name="logger">The logger on which the message is logged.</param>
- /// <param name="format">A String containing zero or more format items</param>
- /// <param name="args">An Object array containing zero or more objects to format</param>
- /// <remarks>
- /// <para>
- /// The message is formatted using the <c>String.Format</c> method. See
- /// <see cref="String.Format(string, object[])"/> for details of the syntax of the format string and the behavior
- /// of the formatting.
- /// </para>
- /// <para>
- /// This method does not take an <see cref="Exception"/> object to include in the
- /// log event. To pass an <see cref="Exception"/> use one of the <see cref="WarnExt(ILog,object,Exception)"/>
- /// methods instead.
- /// </para>
- /// </remarks>
- /// <seealso cref="ILog.Warn(object)"/>
- /// <seealso cref="ILog.IsWarnEnabled"/>
- public static void WarnFormatExt(this ILog logger, IFormatProvider provider, string format, params object[] args)
- {
- try
- {
- if (!logger.IsWarnEnabled)
- return;
+ /// <summary>
+ /// Logs a formatted message string with the <see cref="Level.Warn"/> level.
+ /// </summary>
+ /// <param name="provider">An <see cref="IFormatProvider"/> that supplies culture-specific formatting information</param>
+ /// <param name="logger">The logger on which the message is logged.</param>
+ /// <param name="format">A String containing zero or more format items</param>
+ /// <param name="args">An Object array containing zero or more objects to format</param>
+ /// <remarks>
+ /// <para>
+ /// The message is formatted using the <c>String.Format</c> method. See
+ /// <see cref="String.Format(string, object[])"/> for details of the syntax of the format string and the behavior
+ /// of the formatting.
+ /// </para>
+ /// <para>
+ /// This method does not take an <see cref="Exception"/> object to include in the
+ /// log event. To pass an <see cref="Exception"/> use one of the <see cref="WarnExt(ILog,object,Exception)"/>
+ /// methods instead.
+ /// </para>
+ /// </remarks>
+ /// <seealso cref="ILog.Warn(object)"/>
+ /// <seealso cref="ILog.IsWarnEnabled"/>
+ public static void WarnFormatExt(this ILog logger, IFormatProvider provider, string format, params object[] args)
+ {
+ try
+ {
+ if (!logger.IsWarnEnabled)
+ return;
- logger.WarnFormat(provider, format, args);
- }
- catch (Exception ex)
- {
- log4net.Util.LogLog.Error(declaringType, "Exception while logging", ex);
- }
- }
+ logger.WarnFormat(provider, format, args);
+ }
+ catch (Exception ex)
+ {
+ log4net.Util.LogLog.Error(declaringType, "Exception while logging", ex);
+ }
+ }
- /// <summary>
- /// Logs a formatted message string with the <see cref="Level.Warn"/> level.
- /// </summary>
- /// <param name="logger">The logger on which the message is logged.</param>
- /// <param name="format">A String containing zero or more format items</param>
- /// <param name="arg0">An Object to format</param>
- /// <param name="arg1">An Object to format</param>
- /// <remarks>
- /// <para>
- /// The message is formatted using the <c>String.Format</c> method. See
- /// <see cref="String.Format(string, object[])"/> for details of the syntax of the format string and the behavior
- /// of the formatting.
- /// </para>
- /// <para>
- /// This method does not take an <see cref="Exception"/> object to include in the
- /// log event. To pass an <see cref="Exception"/> use one of the <see cref="WarnExt(ILog,object,Exception)"/>
- /// methods instead.
- /// </para>
- /// </remarks>
- /// <seealso cref="ILog.Warn(object)"/>
- /// <seealso cref="ILog.IsWarnEnabled"/>
- public static void WarnFormatExt(this ILog logger, string format, object arg0, object arg1)
- {
- try
- {
- if (!logger.IsWarnEnabled)
- return;
+ /// <summary>
+ /// Logs a formatted message string with the <see cref="Level.Warn"/> level.
+ /// </summary>
+ /// <param name="logger">The logger on which the message is logged.</param>
+ /// <param name="format">A String containing zero or more format items</param>
+ /// <param name="arg0">An Object to format</param>
+ /// <param name="arg1">An Object to format</param>
+ /// <remarks>
+ /// <para>
+ /// The message is formatted using the <c>String.Format</c> method. See
+ /// <see cref="String.Format(string, object[])"/> for details of the syntax of the format string and the behavior
+ /// of the formatting.
+ /// </para>
+ /// <para>
+ /// This method does not take an <see cref="Exception"/> object to include in the
+ /// log event. To pass an <see cref="Exception"/> use one of the <see cref="WarnExt(ILog,object,Exception)"/>
+ /// methods instead.
+ /// </para>
+ /// </remarks>
+ /// <seealso cref="ILog.Warn(object)"/>
+ /// <seealso cref="ILog.IsWarnEnabled"/>
+ public static void WarnFormatExt(this ILog logger, string format, object arg0, object arg1)
+ {
+ try
+ {
+ if (!logger.IsWarnEnabled)
+ return;
- logger.WarnFormat(format, arg0, arg1);
- }
- catch (Exception ex)
- {
- log4net.Util.LogLog.Error(declaringType, "Exception while logging", ex);
- }
- }
+ logger.WarnFormat(format, arg0, arg1);
+ }
+ catch (Exception ex)
+ {
+ log4net.Util.LogLog.Error(declaringType, "Exception while logging", ex);
+ }
+ }
- /// <summary>
- /// Logs a formatted message string with the <see cref="Level.Warn"/> level.
- /// </summary>
- /// <param name="logger">The logger on which the message is logged.</param>
- /// <param name="format">A String containing zero or more format items</param>
- /// <param name="arg0">An Object to format</param>
- /// <param name="arg1">An Object to format</param>
- /// <param name="arg2">An Object to format</param>
- /// <remarks>
- /// <para>
- /// The message is formatted using the <c>String.Format</c> method. See
- /// <see cref="String.Format(string, object[])"/> for details of the syntax of the format string and the behavior
- /// of the formatting.
- /// </para>
- /// <para>
- /// This method does not take an <see cref="Exception"/> object to include in the
- /// log event. To pass an <see cref="Exception"/> use one of the <see cref="WarnExt(ILog,object,Exception)"/>
- /// methods instead.
- /// </para>
- /// </remarks>
- /// <seealso cref="ILog.Warn(object)"/>
- /// <seealso cref="ILog.IsWarnEnabled"/>
- public static void WarnFormatExt(this ILog logger, string format, object arg0, object arg1, object arg2)
- {
- try
- {
- if (!logger.IsWarnEnabled)
- return;
+ /// <summary>
+ /// Logs a formatted message string with the <see cref="Level.Warn"/> level.
+ /// </summary>
+ /// <param name="logger">The logger on which the message is logged.</param>
+ /// <param name="format">A String containing zero or more format items</param>
+ /// <param name="arg0">An Object to format</param>
+ /// <param name="arg1">An Object to format</param>
+ /// <param name="arg2">An Object to format</param>
+ /// <remarks>
+ /// <para>
+ /// The message is formatted using the <c>String.Format</c> method. See
+ /// <see cref="String.Format(string, object[])"/> for details of the syntax of the format string and the behavior
+ /// of the formatting.
+ /// </para>
+ /// <para>
+ /// This method does not take an <see cref="Exception"/> object to include in the
+ /// log event. To pass an <see cref="Exception"/> use one of the <see cref="WarnExt(ILog,object,Exception)"/>
+ /// methods instead.
+ /// </para>
+ /// </remarks>
+ /// <seealso cref="ILog.Warn(object)"/>
+ /// <seealso cref="ILog.IsWarnEnabled"/>
+ public static void WarnFormatExt(this ILog logger, string format, object arg0, object arg1, object arg2)
+ {
+ try
+ {
+ if (!logger.IsWarnEnabled)
+ return;
- logger.WarnFormat(format, arg0, arg1, arg2);
- }
- catch (Exception ex)
- {
- log4net.Util.LogLog.Error(declaringType, "Exception while logging", ex);
- }
- }
+ logger.WarnFormat(format, arg0, arg1, arg2);
+ }
+ catch (Exception ex)
+ {
+ log4net.Util.LogLog.Error(declaringType, "Exception while logging", ex);
+ }
+ }
- #endregion
+ #endregion
- #endregion
+ #endregion
- #region error extensions
+ #region error extensions
- #region error extensions that uses log message lambda expression
+ #region error extensions that uses log message lambda expression
- /// <summary>
- /// Log a message object with the <see cref="Level.Error"/> level.
- /// </summary>
- /// <param name="logger">The logger on which the message is logged.</param>
- /// <param name="callback">The lambda expression that gets the object to log.</param>
- /// <remarks>
- /// <para>
- /// This method first checks if this logger is <c>ERROR</c>
- /// enabled by reading the value <seealso cref="ILog.IsErrorEnabled"/> property.
- /// This check happens always and does not depend on the <seealso cref="ILog"/>
- /// implementation. If this logger is <c>ERROR</c> enabled, then it converts
- /// the message object (retrieved by invocation of the provided callback) to a
- /// string by invoking the appropriate <see cref="log4net.ObjectRenderer.IObjectRenderer"/>.
- /// It then proceeds to call all the registered appenders in this logger
- /// and also higher in the hierarchy depending on the value of
- /// the additivity flag.
- /// </para>
- /// <para><b>WARNING</b> Note that passing an <see cref="Exception"/>
- /// to this method will print the name of the <see cref="Exception"/>
- /// but no stack trace. To print a stack trace use the
- /// <see cref="ErrorExt(ILog,Func{object},Exception)"/> form instead.
- /// </para>
- /// </remarks>
- /// <seealso cref="ILog.Error(object)"/>
- /// <seealso cref="ILog.IsErrorEnabled"/>
- public static void ErrorExt(this ILog logger, Func<object> callback)
- {
- try
- {
- if (!logger.IsErrorEnabled)
- return;
+ /// <summary>
+ /// Log a message object with the <see cref="Level.Error"/> level.
+ /// </summary>
+ /// <param name="logger">The logger on which the message is logged.</param>
+ /// <param name="callback">The lambda expression that gets the object to log.</param>
+ /// <remarks>
+ /// <para>
+ /// This method first checks if this logger is <c>ERROR</c>
+ /// enabled by reading the value <seealso cref="ILog.IsErrorEnabled"/> property.
+ /// This check happens always and does not depend on the <seealso cref="ILog"/>
+ /// implementation. If this logger is <c>ERROR</c> enabled, then it converts
+ /// the message object (retrieved by invocation of the provided callback) to a
+ /// string by invoking the appropriate <see cref="log4net.ObjectRenderer.IObjectRenderer"/>.
+ /// It then proceeds to call all the registered appenders in this logger
+ /// and also higher in the hierarchy depending on the value of
+ /// the additivity flag.
+ /// </para>
+ /// <para><b>WARNING</b> Note that passing an <see cref="Exception"/>
+ /// to this method will print the name of the <see cref="Exception"/>
+ /// but no stack trace. To print a stack trace use the
+ /// <see cref="ErrorExt(ILog,Func{object},Exception)"/> form instead.
+ /// </para>
+ /// </remarks>
+ /// <seealso cref="ILog.Error(object)"/>
+ /// <seealso cref="ILog.IsErrorEnabled"/>
+ public static void ErrorExt(this ILog logger, Func<object> callback)
+ {
+ try
+ {
+ if (!logger.IsErrorEnabled)
+ return;
- logger.Error(callback());
- }
- catch (Exception ex)
- {
- log4net.Util.LogLog.Error(declaringType, "Exception while logging", ex);
- }
- }
+ logger.Error(callback());
+ }
+ catch (Exception ex)
+ {
+ log4net.Util.LogLog.Error(declaringType, "Exception while logging", ex);
+ }
+ }
- /// <summary>
- /// Log a message object with the <see cref="Level.Error"/> level including
- /// the stack trace of the <see cref="Exception"/> passed
- /// as a parameter.
- /// </summary>
- /// <param name="logger">The logger on which the message is logged.</param>
- /// <param name="callback">The lambda expression that gets the object to log.</param>
- /// <param name="exception">The exception to log, including its stack trace.</param>
- /// <remarks>
- /// <para>
- /// See the <see cref="ErrorExt(ILog, object)"/> form for more detailed information.
- /// </para>
- /// </remarks>
- /// <seealso cref="ILog.Error(object)"/>
- /// <seealso cref="ILog.IsErrorEnabled"/>
- public static void ErrorExt(this ILog logger, Func<object> callback, Exception exception)
- {
- try
- {
- if (!logger.IsErrorEnabled)
- return;
+ /// <summary>
+ /// Log a message object with the <see cref="Level.Error"/> level including
+ /// the stack trace of the <see cref="Exception"/> passed
+ /// as a parameter.
+ /// </summary>
+ /// <param name="logger">The logger on which the message is logged.</param>
+ /// <param name="callback">The lambda expression that gets the object to log.</param>
+ /// <param name="exception">The exception to log, including its stack trace.</param>
+ /// <remarks>
+ /// <para>
+ /// See the <see cref="ErrorExt(ILog, object)"/> form for more detailed information.
+ /// </para>
+ /// </remarks>
+ /// <seealso cref="ILog.Error(object)"/>
+ /// <seealso cref="ILog.IsErrorEnabled"/>
+ public static void ErrorExt(this ILog logger, Func<object> callback, Exception exception)
+ {
+ try
+ {
+ if (!logger.IsErrorEnabled)
+ return;
- logger.Error(callback(), exception);
- }
- catch (Exception ex)
- {
- log4net.Util.LogLog.Error(declaringType, "Exception while logging", ex);
- }
- }
+ logger.Error(callback(), exception);
+ }
+ catch (Exception ex)
+ {
+ log4net.Util.LogLog.Error(declaringType, "Exception while logging", ex);
+ }
+ }
- #endregion
+ #endregion
- #region error extension that use the formatter
+ #region error extension that use the formatter
- /// <overloads>Log a message object with the <see cref="Level.Error"/> level.</overloads> //TODO
- /// <summary>
- /// Log a message object with the <see cref="Level.Error"/> level.
- /// </summary>
- /// <param name="logger">The logger on which the message is logged.</param>
- /// <param name="message">The message object to log.</param>
- /// <remarks>
- /// <para>
- /// This method first checks if this logger is <c>ERROR</c>
- /// enabled by reading the value <seealso cref="ILog.IsErrorEnabled"/> property.
- /// This check happens always and does not depend on the <seealso cref="ILog"/>
- /// implementation. If this logger is <c>ERROR</c> enabled, then it converts
- /// the message object (passed as parameter) to a string by invoking the appropriate
- /// <see cref="log4net.ObjectRenderer.IObjectRenderer"/>. It then
- /// proceeds to call all the registered appenders in this logger
- /// and also higher in the hierarchy depending on the value of
- /// the additivity flag.
- /// </para>
- /// <para><b>WARNING</b> Note that passing an <see cref="Exception"/>
- /// to this method will print the name of the <see cref="Exception"/>
- /// but no stack trace. To print a stack trace use the
- /// <see cref="ErrorExt(ILog,object,Exception)"/> form instead.
- /// </para>
- /// </remarks>
- /// <seealso cref="ILog.Error(object)"/>
- /// <seealso cref="ILog.IsErrorEnabled"/>
- public static void ErrorExt(this ILog logger, object message)
- {
- try
- {
- if (!logger.IsErrorEnabled)
- return;
+ /// <overloads>Log a message object with the <see cref="Level.Error"/> level.</overloads> //TODO
+ /// <summary>
+ /// Log a message object with the <see cref="Level.Error"/> level.
+ /// </summary>
+ /// <param name="logger">The logger on which the message is logged.</param>
+ /// <param name="message">The message object to log.</param>
+ /// <remarks>
+ /// <para>
+ /// This method first checks if this logger is <c>ERROR</c>
+ /// enabled by reading the value <seealso cref="ILog.IsErrorEnabled"/> property.
+ /// This check happens always and does not depend on the <seealso cref="ILog"/>
+ /// implementation. If this logger is <c>ERROR</c> enabled, then it converts
+ /// the message object (passed as parameter) to a string by invoking the appropriate
+ /// <see cref="log4net.ObjectRenderer.IObjectRenderer"/>. It then
+ /// proceeds to call all the registered appenders in this logger
+ /// and also higher in the hierarchy depending on the value of
+ /// the additivity flag.
+ /// </para>
+ /// <para><b>WARNING</b> Note that passing an <see cref="Exception"/>
+ /// to this method will print the name of the <see cref="Exception"/>
+ /// but no stack trace. To print a stack trace use the
+ /// <see cref="ErrorExt(ILog,object,Exception)"/> form instead.
+ /// </para>
+ /// </remarks>
+ /// <seealso cref="ILog.Error(object)"/>
+ /// <seealso cref="ILog.IsErrorEnabled"/>
+ public static void ErrorExt(this ILog logger, object message)
+ {
+ try
+ {
+ if (!logger.IsErrorEnabled)
+ return;
- logger.Error(message);
- }
- catch (Exception ex)
- {
- log4net.Util.LogLog.Error(declaringType, "Exception while logging", ex);
- }
- }
+ logger.Error(message);
+ }
+ catch (Exception ex)
+ {
+ log4net.Util.LogLog.Error(declaringType, "Exception while logging", ex);
+ }
+ }
- /// <summary>
- /// Log a message object with the <see cref="Level.Error"/> level including
- /// the stack trace of the <see cref="Exception"/> passed
- /// as a parameter.
- /// </summary>
- /// <param name="logger">The logger on which the message is logged.</param>
- /// <param name="message">The message object to log.</param>
- /// <param name="exception">The exception to log, including its stack trace.</param>
- /// <remarks>
- /// <para>
- /// See the <see cref="ErrorExt(ILog, object)"/> form for more detailed information.
- /// </para>
- /// </remarks>
- /// <seealso cref="ILog.Error(object)"/>
- /// <seealso cref="ILog.IsErrorEnabled"/>
- public static void ErrorExt(this ILog logger, object message, Exception exception)
- {
- try
- {
- if (!logger.IsErrorEnabled)
- return;
+ /// <summary>
+ /// Log a message object with the <see cref="Level.Error"/> level including
+ /// the stack trace of the <see cref="Exception"/> passed
+ /// as a parameter.
+ /// </summary>
+ /// <param name="logger">The logger on which the message is logged.</param>
+ /// <param name="message">The message object to log.</param>
+ /// <param name="exception">The exception to log, including its stack trace.</param>
+ /// <remarks>
+ /// <para>
+ /// See the <see cref="ErrorExt(ILog, object)"/> form for more detailed information.
+ /// </para>
+ /// </remarks>
+ /// <seealso cref="ILog.Error(object)"/>
+ /// <seealso cref="ILog.IsErrorEnabled"/>
+ public static void ErrorExt(this ILog logger, object message, Exception exception)
+ {
+ try
+ {
+ if (!logger.IsErrorEnabled)
+ return;
- logger.Error(message, exception);
- }
- catch (Exception ex)
- {
- log4net.Util.LogLog.Error(declaringType, "Exception while logging", ex);
- }
- }
+ logger.Error(message, exception);
+ }
+ catch (Exception ex)
+ {
+ log4net.Util.LogLog.Error(declaringType, "Exception while logging", ex);
+ }
+ }
- #endregion
+ #endregion
- #region error extension that use string format
+ #region error extension that use string format
- /// <summary>
- /// Logs a formatted message string with the <see cref="Level.Error"/> level.
- /// </summary>
- /// <param name="logger">The logger on which the message is logged.</param>
- /// <param name="format">A String containing zero or more format items</param>
- /// <param name="arg0">An Object to format</param>
- /// <remarks>
- /// <para>
- /// The message is formatted using the <c>String.Format</c> method. See
- /// <see cref="String.Format(string, object[])"/> for details of the syntax of the format string and the behavior
- /// of the formatting.
- /// </para>
- /// <para>
- /// This method does not take an <see cref="Exception"/> object to include in the
- /// log event. To pass an <see cref="Exception"/> use one of the <see cref="ErrorExt(ILog,object,Exception)"/>
- /// methods instead.
- /// </para>
- /// </remarks>
- /// <seealso cref="ILog.Error(object)"/>
- /// <seealso cref="ILog.IsErrorEnabled"/>
- public static void ErrorFormatExt(this ILog logger, string format, object arg0)
- {
- try
- {
- if (!logger.IsErrorEnabled)
- return;
+ /// <summary>
+ /// Logs a formatted message string with the <see cref="Level.Error"/> level.
+ /// </summary>
+ /// <param name="logger">The logger on which the message is logged.</param>
+ /// <param name="format">A String containing zero or more format items</param>
+ /// <param name="arg0">An Object to format</param>
+ /// <remarks>
+ /// <para>
+ /// The message is formatted using the <c>String.Format</c> method. See
+ /// <see cref="String.Format(string, object[])"/> for details of the syntax of the format string and the behavior
+ /// of the formatting.
+ /// </para>
+ /// <para>
+ /// This method does not take an <see cref="Exception"/> object to include in the
+ /// log event. To pass an <see cref="Exception"/> use one of the <see cref="ErrorExt(ILog,object,Exception)"/>
+ /// methods instead.
+ /// </para>
+ /// </remarks>
+ /// <seealso cref="ILog.Error(object)"/>
+ /// <seealso cref="ILog.IsErrorEnabled"/>
+ public static void ErrorFormatExt(this ILog logger, string format, object arg0)
+ {
+ try
+ {
+ if (!logger.IsErrorEnabled)
+ return;
- logger.ErrorFormat(format, arg0);
- }
- catch (Exception ex)
- {
- log4net.Util.LogLog.Error(declaringType, "Exception while logging", ex);
- }
- }
+ logger.ErrorFormat(format, arg0);
+ }
+ catch (Exception ex)
+ {
+ log4net.Util.LogLog.Error(declaringType, "Exception while logging", ex);
+ }
+ }
- /// <summary>
- /// Logs a formatted message string with the <see cref="Level.Error"/> level.
- /// </summary>
- /// <param name="logger">The logger on which the message is logged.</param>
- /// <param name="format">A String containing zero or more format items</param>
- /// <param name="args">An Object array containing zero or more objects to format</param>
- /// <remarks>
- /// <para>
- /// The message is formatted using the <c>String.Format</c> method. See
- /// <see cref="String.Format(string, object[])"/> for details of the syntax of the format string and the behavior
- /// of the formatting.
- /// </para>
- /// <para>
- /// This method does not take an <see cref="Exception"/> object to include in the
- /// log event. To pass an <see cref="Exception"/> use one of the <see cref="ErrorExt(ILog,object,Exception)"/>
- /// methods instead.
- /// </para>
- /// </remarks>
- /// <seealso cref="ILog.Error(object)"/>
- /// <seealso cref="ILog.IsErrorEnabled"/>
- public static void ErrorFormatExt(this ILog logger, string format, params object[] args)
- {
- try
- {
- if (!logger.IsErrorEnabled)
- return;
+ /// <summary>
+ /// Logs a formatted message string with the <see cref="Level.Error"/> level.
+ /// </summary>
+ /// <param name="logger">The logger on which the message is logged.</param>
+ /// <param name="format">A String containing zero or more format items</param>
+ /// <param name="args">An Object array containing zero or more objects to format</param>
+ /// <remarks>
+ /// <para>
+ /// The message is formatted using the <c>String.Format</c> method. See
+ /// <see cref="String.Format(string, object[])"/> for details of the syntax of the format string and the behavior
+ /// of the formatting.
+ /// </para>
+ /// <para>
+ /// This method does not take an <see cref="Exception"/> object to include in the
+ /// log event. To pass an <see cref="Exception"/> use one of the <see cref="ErrorExt(ILog,object,Exception)"/>
+ /// methods instead.
+ /// </para>
+ /// </remarks>
+ /// <seealso cref="ILog.Error(object)"/>
+ /// <seealso cref="ILog.IsErrorEnabled"/>
+ public static void ErrorFormatExt(this ILog logger, string format, params object[] args)
+ {
+ try
+ {
+ if (!logger.IsErrorEnabled)
+ return;
- logger.ErrorFormat(format, args);
- }
- catch (Exception ex)
- {
- log4net.Util.LogLog.Error(declaringType, "Exception while logging", ex);
- }
- }
+ logger.ErrorFormat(format, args);
+ }
+ catch (Exception ex)
+ {
+ log4net.Util.LogLog.Error(declaringType, "Exception while logging", ex);
+ }
+ }
- /// <summary>
- /// Logs a formatted message string with the <see cref="Level.Error"/> level.
- /// </summary>
- /// <param name="provider">An <see cref="IFormatProvider"/> that supplies culture-specific formatting information</param>
- /// <param name="logger">The logger on which the message is logged.</param>
- /// <param name="format">A String containing zero or more format items</param>
- /// <param name="args">An Object array containing zero or more objects to format</param>
- /// <remarks>
- /// <para>
- /// The message is formatted using the <c>String.Format</c> method. See
- /// <see cref="String.Format(string, object[])"/> for details of the syntax of the format string and the behavior
- /// of the formatting.
- /// </para>
- /// <para>
- /// This method does not take an <see cref="Exception"/> object to include in the
- /// log event. To pass an <see cref="Exception"/> use one of the <see cref="ErrorExt(ILog,object,Exception)"/>
- /// methods instead.
- /// </para>
- /// </remarks>
- /// <seealso cref="ILog.Error(object)"/>
- /// <seealso cref="ILog.IsErrorEnabled"/>
- public static void ErrorFormatExt(this ILog logger, IFormatProvider provider, string format, params object[] args)
- {
- try
- {
- if (!logger.IsErrorEnabled)
- return;
+ /// <summary>
+ /// Logs a formatted message string with the <see cref="Level.Error"/> level.
+ /// </summary>
+ /// <param name="provider">An <see cref="IFormatProvider"/> that supplies culture-specific formatting information</param>
+ /// <param name="logger">The logger on which the message is logged.</param>
+ /// <param name="format">A String containing zero or more format items</param>
+ /// <param name="args">An Object array containing zero or more objects to format</param>
+ /// <remarks>
+ /// <para>
+ /// The message is formatted using the <c>String.Format</c> method. See
+ /// <see cref="String.Format(string, object[])"/> for details of the syntax of the format string and the behavior
+ /// of the formatting.
+ /// </para>
+ /// <para>
+ /// This method does not take an <see cref="Exception"/> object to include in the
+ /// log event. To pass an <see cref="Exception"/> use one of the <see cref="ErrorExt(ILog,object,Exception)"/>
+ /// methods instead.
+ /// </para>
+ /// </remarks>
+ /// <seealso cref="ILog.Error(object)"/>
+ /// <seealso cref="ILog.IsErrorEnabled"/>
+ public static void ErrorFormatExt(this ILog logger, IFormatProvider provider, string format, params object[] args)
+ {
+ try
+ {
+ if (!logger.IsErrorEnabled)
+ return;
- logger.ErrorFormat(provider, format, args);
- }
- catch (Exception ex)
- {
- log4net.Util.LogLog.Error(declaringType, "Exception while logging", ex);
- }
- }
+ logger.ErrorFormat(provider, format, args);
+ }
+ catch (Exception ex)
+ {
+ log4net.Util.LogLog.Error(declaringType, "Exception while logging", ex);
+ }
+ }
- /// <summary>
- /// Logs a formatted message string with the <see cref="Level.Error"/> level.
- /// </summary>
- /// <param name="logger">The logger on which the message is logged.</param>
- /// <param name="format">A String containing zero or more format items</param>
- /// <param name="arg0">An Object to format</param>
- /// <param name="arg1">An Object to format</param>
- /// <remarks>
- /// <para>
- /// The message is formatted using the <c>String.Format</c> method. See
- /// <see cref="String.Format(string, object[])"/> for details of the syntax of the format string and the behavior
- /// of the formatting.
- /// </para>
- /// <para>
- /// This method does not take an <see cref="Exception"/> object to include in the
- /// log event. To pass an <see cref="Exception"/> use one of the <see cref="ErrorExt(ILog,object,Exception)"/>
- /// methods instead.
- /// </para>
- /// </remarks>
- /// <seealso cref="ILog.Error(object)"/>
- /// <seealso cref="ILog.IsErrorEnabled"/>
- public static void ErrorFormatExt(this ILog logger, string format, object arg0, object arg1)
- {
- try
- {
- if (!logger.IsErrorEnabled)
- return;
+ /// <summary>
+ /// Logs a formatted message string with the <see cref="Level.Error"/> level.
+ /// </summary>
+ /// <param name="logger">The logger on which the message is logged.</param>
+ /// <param name="format">A String containing zero or more format items</param>
+ /// <param name="arg0">An Object to format</param>
+ /// <param name="arg1">An Object to format</param>
+ /// <remarks>
+ /// <para>
+ /// The message is formatted using the <c>String.Format</c> method. See
+ /// <see cref="String.Format(string, object[])"/> for details of the syntax of the format string and the behavior
+ /// of the formatting.
+ /// </para>
+ /// <para>
+ /// This method does not take an <see cref="Exception"/> object to include in the
+ /// log event. To pass an <see cref="Exception"/> use one of the <see cref="ErrorExt(ILog,object,Exception)"/>
+ /// methods instead.
+ /// </para>
+ /// </remarks>
+ /// <seealso cref="ILog.Error(object)"/>
+ /// <seealso cref="ILog.IsErrorEnabled"/>
+ public static void ErrorFormatExt(this ILog logger, string format, object arg0, object arg1)
+ {
+ try
+ {
+ if (!logger.IsErrorEnabled)
+ return;
- logger.ErrorFormat(format, arg0, arg1);
- }
- catch (Exception ex)
- {
- log4net.Util.LogLog.Error(declaringType, "Exception while logging", ex);
- }
- }
+ logger.ErrorFormat(format, arg0, arg1);
+ }
+ catch (Exception ex)
+ {
+ log4net.Util.LogLog.Error(declaringType, "Exception while logging", ex);
+ }
+ }
- /// <summary>
- /// Logs a formatted message string with the <see cref="Level.Error"/> level.
- /// </summary>
- /// <param name="logger">The logger on which the message is logged.</param>
- /// <param name="format">A String containing zero or more format items</param>
- /// <param name="arg0">An Object to format</param>
- /// <param name="arg1">An Object to format</param>
- /// <param name="arg2">An Object to format</param>
- /// <remarks>
- /// <para>
- /// The message is formatted using the <c>String.Format</c> method. See
- /// <see cref="String.Format(string, object[])"/> for details of the syntax of the format string and the behavior
- /// of the formatting.
- /// </para>
- /// <para>
- /// This method does not take an <see cref="Exception"/> object to include in the
- /// log event. To pass an <see cref="Exception"/> use one of the <see cref="ErrorExt(ILog,object,Exception)"/>
- /// methods instead.
- /// </para>
- /// </remarks>
- /// <seealso cref="ILog.Error(object)"/>
- /// <seealso cref="ILog.IsErrorEnabled"/>
- public static void ErrorFormatExt(this ILog logger, string format, object arg0, object arg1, object arg2)
- {
- try
- {
- if (!logger.IsErrorEnabled)
- return;
+ /// <summary>
+ /// Logs a formatted message string with the <see cref="Level.Error"/> level.
+ /// </summary>
+ /// <param name="logger">The logger on which the message is logged.</param>
+ /// <param name="format">A String containing zero or more format items</param>
+ /// <param name="arg0">An Object to format</param>
+ /// <param name="arg1">An Object to format</param>
+ /// <param name="arg2">An Object to format</param>
+ /// <remarks>
+ /// <para>
+ /// The message is formatted using the <c>String.Format</c> method. See
+ /// <see cref="String.Format(string, object[])"/> for details of the syntax of the format string and the behavior
+ /// of the formatting.
+ /// </para>
+ /// <para>
+ /// This method does not take an <see cref="Exception"/> object to include in the
+ /// log event. To pass an <see cref="Exception"/> use one of the <see cref="ErrorExt(ILog,object,Exception)"/>
+ /// methods instead.
+ /// </para>
+ /// </remarks>
+ /// <seealso cref="ILog.Error(object)"/>
+ /// <seealso cref="ILog.IsErrorEnabled"/>
+ public static void ErrorFormatExt(this ILog logger, string format, object arg0, object arg1, object arg2)
+ {
+ try
+ {
+ if (!logger.IsErrorEnabled)
+ return;
- logger.ErrorFormat(format, arg0, arg1, arg2);
- }
- catch (Exception ex)
- {
- log4net.Util.LogLog.Error(declaringType, "Exception while logging", ex);
- }
- }
+ logger.ErrorFormat(format, arg0, arg1, arg2);
+ }
+ catch (Exception ex)
+ {
+ log4net.Util.LogLog.Error(declaringType, "Exception while logging", ex);
+ }
+ }
- #endregion
+ #endregion
- #endregion
+ #endregion
- #region fatal extensions
+ #region fatal extensions
- #region fatal extensions that uses log message lambda expression
+ #region fatal extensions that uses log message lambda expression
- /// <summary>
- /// Log a message object with the <see cref="Level.Fatal"/> level.
- /// </summary>
- /// <param name="logger">The logger on which the message is logged.</param>
- /// <param name="callback">The lambda expression that gets the object to log.</param>
- /// <remarks>
- /// <para>
- /// This method first checks if this logger is <c>FATAL</c>
- /// enabled by reading the value <seealso cref="ILog.IsFatalEnabled"/> property.
- /// This check happens always and does not depend on the <seealso cref="ILog"/>
- /// implementation. If this logger is <c>FATAL</c> enabled, then it converts
- /// the message object (retrieved by invocation of the provided callback) to a
- /// string by invoking the appropriate <see cref="log4net.ObjectRenderer.IObjectRenderer"/>.
- /// It then proceeds to call all the registered appenders in this logger
- /// and also higher in the hierarchy depending on the value of
- /// the additivity flag.
- /// </para>
- /// <para><b>WARNING</b> Note that passing an <see cref="Exception"/>
- /// to this method will print the name of the <see cref="Exception"/>
- /// but no stack trace. To print a stack trace use the
- /// <see cref="FatalExt(ILog,Func{object},Exception)"/> form instead.
- /// </para>
- /// </remarks>
- /// <seealso cref="ILog.Fatal(object)"/>
- /// <seealso cref="ILog.IsFatalEnabled"/>
- public static void FatalExt(this ILog logger, Func<object> callback)
- {
- try
- {
- if (!logger.IsFatalEnabled)
- return;
+ /// <summary>
+ /// Log a message object with the <see cref="Level.Fatal"/> level.
+ /// </summary>
+ /// <param name="logger">The logger on which the message is logged.</param>
+ /// <param name="callback">The lambda expression that gets the object to log.</param>
+ /// <remarks>
+ /// <para>
+ /// This method first checks if this logger is <c>FATAL</c>
+ /// enabled by reading the value <seealso cref="ILog.IsFatalEnabled"/> property.
+ /// This check happens always and does not depend on the <seealso cref="ILog"/>
+ /// implementation. If this logger is <c>FATAL</c> enabled, then it converts
+ /// the message object (retrieved by invocation of the provided callback) to a
+ /// string by invoking the appropriate <see cref="log4net.ObjectRenderer.IObjectRenderer"/>.
+ /// It then proceeds to call all the registered appenders in this logger
+ /// and also higher in the hierarchy depending on the value of
+ /// the additivity flag.
+ /// </para>
+ /// <para><b>WARNING</b> Note that passing an <see cref="Exception"/>
+ /// to this method will print the name of the <see cref="Exception"/>
+ /// but no stack trace. To print a stack trace use the
+ /// <see cref="FatalExt(ILog,Func{object},Exception)"/> form instead.
+ /// </para>
+ /// </remarks>
+ /// <seealso cref="ILog.Fatal(object)"/>
+ /// <seealso cref="ILog.IsFatalEnabled"/>
+ public static void FatalExt(this ILog logger, Func<object> callback)
+ {
+ try
+ {
+ if (!logger.IsFatalEnabled)
+ return;
- logger.Fatal(callback());
- }
- catch (Exception ex)
- {
- log4net.Util.LogLog.Error(declaringType, "Exception while logging", ex);
- }
- }
+ logger.Fatal(callback());
+ }
+ catch (Exception ex)
+ {
+ log4net.Util.LogLog.Error(declaringType, "Exception while logging", ex);
+ }
+ }
- /// <summary>
- /// Log a message object with the <see cref="Level.Fatal"/> level including
- /// the stack trace of the <see cref="Exception"/> passed
- /// as a parameter.
- /// </summary>
- /// <param name="logger">The logger on which the message is logged.</param>
- /// <param name="callback">The lambda expression that gets the object to log.</param>
- /// <param name="exception">The exception to log, including its stack trace.</param>
- /// <remarks>
- /// <para>
- /// See the <see cref="FatalExt(ILog, object)"/> form for more detailed information.
- /// </para>
- /// </remarks>
- /// <seealso cref="ILog.Fatal(object)"/>
- /// <seealso cref="ILog.IsFatalEnabled"/>
- public static void FatalExt(this ILog logger, Func<object> callback, Exception exception)
- {
- try
- {
- if (!logger.IsFatalEnabled)
- return;
+ /// <summary>
+ /// Log a message object with the <see cref="Level.Fatal"/> level including
+ /// the stack trace of the <see cref="Exception"/> passed
+ /// as a parameter.
+ /// </summary>
+ /// <param name="logger">The logger on which the message is logged.</param>
+ /// <param name="callback">The lambda expression that gets the object to log.</param>
+ /// <param name="exception">The exception to log, including its stack trace.</param>
+ /// <remarks>
+ /// <para>
+ /// See the <see cref="FatalExt(ILog, object)"/> form for more detailed information.
+ /// </para>
+ /// </remarks>
+ /// <seealso cref="ILog.Fatal(object)"/>
+ /// <seealso cref="ILog.IsFatalEnabled"/>
+ public static void FatalExt(this ILog logger, Func<object> callback, Exception exception)
+ {
+ try
+ {
+ if (!logger.IsFatalEnabled)
+ return;
- logger.Fatal(callback(), exception);
- }
- catch (Exception ex)
- {
- log4net.Util.LogLog.Error(declaringType, "Exception while logging", ex);
- }
- }
+ logger.Fatal(callback(), exception);
+ }
+ catch (Exception ex)
+ {
+ log4net.Util.LogLog.Error(declaringType, "Exception while logging", ex);
+ }
+ }
- #endregion
+ #endregion
- #region fatal extension that use the formatter
+ #region fatal extension that use the formatter
- /// <overloads>Log a message object with the <see cref="Level.Fatal"/> level.</overloads> //TODO
- /// <summary>
- /// Log a message object with the <see cref="Level.Fatal"/> level.
- /// </summary>
- /// <param name="logger">The logger on which the message is logged.</param>
- /// <param name="message">The message object to log.</param>
- /// <remarks>
- /// <para>
- /// This method first checks if this logger is <c>FATAL</c>
- /// enabled by reading the value <seealso cref="ILog.IsFatalEnabled"/> property.
- /// This check happens always and does not depend on the <seealso cref="ILog"/>
- /// implementation. If this logger is <c>FATAL</c> enabled, then it converts
- /// the message object (passed as parameter) to a string by invoking the appropriate
- /// <see cref="log4net.ObjectRenderer.IObjectRenderer"/>. It then
- /// proceeds to call all the registered appenders in this logger
- /// and also higher in the hierarchy depending on the value of
- /// the additivity flag.
- /// </para>
- /// <para><b>WARNING</b> Note that passing an <see cref="Exception"/>
- /// to this method will print the name of the <see cref="Exception"/>
- /// but no stack trace. To print a stack trace use the
- /// <see cref="FatalExt(ILog,object,Exception)"/> form instead.
- /// </para>
- /// </remarks>
- /// <seealso cref="ILog.Fatal(object)"/>
- /// <seealso cref="ILog.IsFatalEnabled"/>
- public static void FatalExt(this ILog logger, object message)
- {
- try
- {
- if (!logger.IsFatalEnabled)
- return;
+ /// <overloads>Log a message object with the <see cref="Level.Fatal"/> level.</overloads> //TODO
+ /// <summary>
+ /// Log a message object with the <see cref="Level.Fatal"/> level.
+ /// </summary>
+ /// <param name="logger">The logger on which the message is logged.</param>
+ /// <param name="message">The message object to log.</param>
+ /// <remarks>
+ /// <para>
+ /// This method first checks if this logger is <c>FATAL</c>
+ /// enabled by reading the value <seealso cref="ILog.IsFatalEnabled"/> property.
+ /// This check happens always and does not depend on the <seealso cref="ILog"/>
+ /// implementation. If this logger is <c>FATAL</c> enabled, then it converts
+ /// the message object (passed as parameter) to a string by invoking the appropriate
+ /// <see cref="log4net.ObjectRenderer.IObjectRenderer"/>. It then
+ /// proceeds to call all the registered appenders in this logger
+ /// and also higher in the hierarchy depending on the value of
+ /// the additivity flag.
+ /// </para>
+ /// <para><b>WARNING</b> Note that passing an <see cref="Exception"/>
+ /// to this method will print the name of the <see cref="Exception"/>
+ /// but no stack trace. To print a stack trace use the
+ /// <see cref="FatalExt(ILog,object,Exception)"/> form instead.
+ /// </para>
+ /// </remarks>
+ /// <seealso cref="ILog.Fatal(object)"/>
+ /// <seealso cref="ILog.IsFatalEnabled"/>
+ public static void FatalExt(this ILog logger, object message)
+ {
+ try
+ {
+ if (!logger.IsFatalEnabled)
+ return;
- logger.Fatal(message);
- }
- catch (Exception ex)
- {
- log4net.Util.LogLog.Error(declaringType, "Exception while logging", ex);
- }
- }
+ logger.Fatal(message);
+ }
+ catch (Exception ex)
+ {
+ log4net.Util.LogLog.Error(declaringType, "Exception while logging", ex);
+ }
+ }
- /// <summary>
- /// Log a message object with the <see cref="Level.Fatal"/> level including
- /// the stack trace of the <see cref="Exception"/> passed
- /// as a parameter.
- /// </summary>
- /// <param name="logger">The logger on which the message is logged.</param>
- /// <param name="message">The message object to log.</param>
- /// <param name="exception">The exception to log, including its stack trace.</param>
- /// <remarks>
- /// <para>
- /// See the <see cref="FatalExt(ILog, object)"/> form for more detailed information.
- /// </para>
- /// </remarks>
- /// <seealso cref="ILog.Fatal(object)"/>
- /// <seealso cref="ILog.IsFatalEnabled"/>
- public static void FatalExt(this ILog logger, object message, Exception exception)
- {
- try
- {
- if (!logger.IsFatalEnabled)
- return;
+ /// <summary>
+ /// Log a message object with the <see cref="Level.Fatal"/> level including
+ /// the stack trace of the <see cref="Exception"/> passed
+ /// as a parameter.
+ /// </summary>
+ /// <param name="logger">The logger on which the message is logged.</param>
+ /// <param name="message">The message object to log.</param>
+ /// <param name="exception">The exception to log, including its stack trace.</param>
+ /// <remarks>
+ /// <para>
+ /// See the <see cref="FatalExt(ILog, object)"/> form for more detailed information.
+ /// </para>
+ /// </remarks>
+ /// <seealso cref="ILog.Fatal(object)"/>
+ /// <seealso cref="ILog.IsFatalEnabled"/>
+ public static void FatalExt(this ILog logger, object message, Exception exception)
+ {
+ try
+ {
+ if (!logger.IsFatalEnabled)
+ return;
- logger.Fatal(message, exception);
- }
- catch (Exception ex)
- {
- log4net.Util.LogLog.Error(declaringType, "Exception while logging", ex);
- }
- }
+ logger.Fatal(message, exception);
+ }
+ catch (Exception ex)
+ {
+ log4net.Util.LogLog.Error(declaringType, "Exception while logging", ex);
+ }
+ }
- #endregion
+ #endregion
- #region fatal extension that use string format
+ #region fatal extension that use string format
- /// <summary>
- /// Logs a formatted message string with the <see cref="Level.Fatal"/> level.
- /// </summary>
- /// <param name="logger">The logger on which the message is logged.</param>
- /// <param name="format">A String containing zero or more format items</param>
- /// <param name="arg0">An Object to format</param>
- /// <remarks>
- /// <para>
- /// The message is formatted using the <c>String.Format</c> method. See
- /// <see cref="String.Format(string, object[])"/> for details of the syntax of the format string and the behavior
- /// of the formatting.
- /// </para>
- /// <para>
- /// This method does not take an <see cref="Exception"/> object to include in the
- /// log event. To pass an <see cref="Exception"/> use one of the <see cref="FatalExt(ILog,object,Exception)"/>
- /// methods instead.
- /// </para>
- /// </remarks>
- /// <seealso cref="ILog.Fatal(object)"/>
- /// <seealso cref="ILog.IsFatalEnabled"/>
- public static void FatalFormatExt(this ILog logger, string format, object arg0)
- {
- try
- {
- if (!logger.IsFatalEnabled)
- return;
+ /// <summary>
+ /// Logs a formatted message string with the <see cref="Level.Fatal"/> level.
+ /// </summary>
+ /// <param name="logger">The logger on which the message is logged.</param>
+ /// <param name="format">A String containing zero or more format items</param>
+ /// <param name="arg0">An Object to format</param>
+ /// <remarks>
+ /// <para>
+ /// The message is formatted using the <c>String.Format</c> method. See
+ /// <see cref="String.Format(string, object[])"/> for details of the syntax of the format string and the behavior
+ /// of the formatting.
+ /// </para>
+ /// <para>
+ /// This method does not take an <see cref="Exception"/> object to include in the
+ /// log event. To pass an <see cref="Exception"/> use one of the <see cref="FatalExt(ILog,object,Exception)"/>
+ /// methods instead.
+ /// </para>
+ /// </remarks>
+ /// <seealso cref="ILog.Fatal(object)"/>
+ /// <seealso cref="ILog.IsFatalEnabled"/>
+ public static void FatalFormatExt(this ILog logger, string format, object arg0)
+ {
+ try
+ {
+ if (!logger.IsFatalEnabled)
+ return;
- logger.FatalFormat(format, arg0);
- }
- catch (Exception ex)
- {
- log4net.Util.LogLog.Error(declaringType, "Exception while logging", ex);
- }
- }
+ logger.FatalFormat(format, arg0);
+ }
+ catch (Exception ex)
+ {
+ log4net.Util.LogLog.Error(declaringType, "Exception while logging", ex);
+ }
+ }
- /// <summary>
- /// Logs a formatted message string with the <see cref="Level.Fatal"/> level.
- /// </summary>
- /// <param name="logger">The logger on which the message is logged.</param>
- /// <param name="format">A String containing zero or more format items</param>
- /// <param name="args">An Object array containing zero or more objects to format</param>
- /// <remarks>
- /// <para>
- /// The message is formatted using the <c>String.Format</c> method. See
- /// <see cref="String.Format(string, object[])"/> for details of the syntax of the format string and the behavior
- /// of the formatting.
- /// </para>
- /// <para>
- /// This method does not take an <see cref="Exception"/> object to include in the
- /// log event. To pass an <see cref="Exception"/> use one of the <see cref="FatalExt(ILog,object,Exception)"/>
- /// methods instead.
- /// </para>
- /// </remarks>
- /// <seealso cref="ILog.Fatal(object)"/>
- /// <seealso cref="ILog.IsFatalEnabled"/>
- public static void FatalFormatExt(this ILog logger, string format, params object[] args)
- {
- try
- {
- if (!logger.IsFatalEnabled)
- return;
+ /// <summary>
+ /// Logs a formatted message string with the <see cref="Level.Fatal"/> level.
+ /// </summary>
+ /// <param name="logger">The logger on which the message is logged.</param>
+ /// <param name="format">A String containing zero or more format items</param>
+ /// <param name="args">An Object array containing zero or more objects to format</param>
+ /// <remarks>
+ /// <para>
+ /// The message is formatted using the <c>String.Format</c> method. See
+ /// <see cref="String.Format(string, object[])"/> for details of the syntax of the format string and the behavior
+ /// of the formatting.
+ /// </para>
+ /// <para>
+ /// This method does not take an <see cref="Exception"/> object to include in the
+ /// log event. To pass an <see cref="Exception"/> use one of the <see cref="FatalExt(ILog,object,Exception)"/>
+ /// methods instead.
+ /// </para>
+ /// </remarks>
+ /// <seealso cref="ILog.Fatal(object)"/>
+ /// <seealso cref="ILog.IsFatalEnabled"/>
+ public static void FatalFormatExt(this ILog logger, string format, params object[] args)
+ {
+ try
+ {
+ if (!logger.IsFatalEnabled)
+ return;
- logger.FatalFormat(format, args);
- }
- catch (Exception ex)
- {
- log4net.Util.LogLog.Error(declaringType, "Exception while logging", ex);
- }
- }
+ logger.FatalFormat(format, args);
+ }
+ catch (Exception ex)
+ {
+ log4net.Util.LogLog.Error(declaringType, "Exception while logging", ex);
+ }
+ }
- /// <summary>
- /// Logs a formatted message string with the <see cref="Level.Fatal"/> level.
- /// </summary>
- /// <param name="provider">An <see cref="IFormatProvider"/> that supplies culture-specific formatting information</param>
- /// <param name="logger">The logger on which the message is logged.</param>
- /// <param name="format">A String containing zero or more format items</param>
- /// <param name="args">An Object array containing zero or more objects to format</param>
- /// <remarks>
- /// <para>
- /// The message is formatted using the <c>String.Format</c> method. See
- /// <see cref="String.Format(string, object[])"/> for details of the syntax of the format string and the behavior
- /// of the formatting.
- /// </para>
- /// <para>
- /// This method does not take an <see cref="Exception"/> object to include in the
- /// log event. To pass an <see cref="Exception"/> use one of the <see cref="FatalExt(ILog,object,Exception)"/>
- /// methods instead.
- /// </para>
- /// </remarks>
- /// <seealso cref="ILog.Fatal(object)"/>
- /// <seealso cref="ILog.IsFatalEnabled"/>
- public static void FatalFormatExt(this ILog logger, IFormatProvider provider, string format, params object[] args)
- {
- try
- {
- if (!logger.IsFatalEnabled)
- return;
+ /// <summary>
+ /// Logs a formatted message string with the <see cref="Level.Fatal"/> level.
+ /// </summary>
+ /// <param name="provider">An <see cref="IFormatProvider"/> that supplies culture-specific formatting information</param>
+ /// <param name="logger">The logger on which the message is logged.</param>
+ /// <param name="format">A String containing zero or more format items</param>
+ /// <param name="args">An Object array containing zero or more objects to format</param>
+ /// <remarks>
+ /// <para>
+ /// The message is formatted using the <c>String.Format</c> method. See
+ /// <see cref="String.Format(string, object[])"/> for details of the syntax of the format string and the behavior
+ /// of the formatting.
+ /// </para>
+ /// <para>
+ /// This method does not take an <see cref="Exception"/> object to include in the
+ /// log event. To pass an <see cref="Exception"/> use one of the <see cref="FatalExt(ILog,object,Exception)"/>
+ /// methods instead.
+ /// </para>
+ /// </remarks>
+ /// <seealso cref="ILog.Fatal(object)"/>
+ /// <seealso cref="ILog.IsFatalEnabled"/>
+ public static void FatalFormatExt(this ILog logger, IFormatProvider provider, string format, params object[] args)
+ {
+ try
+ {
+ if (!logger.IsFatalEnabled)
+ return;
- logger.FatalFormat(provider, format, args);
- }
- catch (Exception ex)
- {
- log4net.Util.LogLog.Error(declaringType, "Exception while logging", ex);
- }
- }
+ logger.FatalFormat(provider, format, args);
+ }
+ catch (Exception ex)
+ {
+ log4net.Util.LogLog.Error(declaringType, "Exception while logging", ex);
+ }
+ }
- /// <summary>
- /// Logs a formatted message string with the <see cref="Level.Fatal"/> level.
- /// </summary>
- /// <param name="logger">The logger on which the message is logged.</param>
- /// <param name="format">A String containing zero or more format items</param>
- /// <param name="arg0">An Object to format</param>
- /// <param name="arg1">An Object to format</param>
- /// <remarks>
- /// <para>
- /// The message is formatted using the <c>String.Format</c> method. See
- /// <see cref="String.Format(string, object[])"/> for details of the syntax of the format string and the behavior
- /// of the formatting.
- /// </para>
- /// <para>
- /// This method does not take an <see cref="Exception"/> object to include in the
- /// log event. To pass an <see cref="Exception"/> use one of the <see cref="FatalExt(ILog,object,Exception)"/>
- /// methods instead.
- /// </para>
- /// </remarks>
- /// <seealso cref="ILog.Fatal(object)"/>
- /// <seealso cref="ILog.IsFatalEnabled"/>
- public static void FatalFormatExt(this ILog logger, string format, object arg0, object arg1)
- {
- try
- {
- if (!logger.IsFatalEnabled)
- return;
+ /// <summary>
+ /// Logs a formatted message string with the <see cref="Level.Fatal"/> level.
+ /// </summary>
+ /// <param name="logger">The logger on which the message is logged.</param>
+ /// <param name="format">A String containing zero or more format items</param>
+ /// <param name="arg0">An Object to format</param>
+ /// <param name="arg1">An Object to format</param>
+ /// <remarks>
+ /// <para>
+ /// The message is formatted using the <c>String.Format</c> method. See
+ /// <see cref="String.Format(string, object[])"/> for details of the syntax of the format string and the behavior
+ /// of the formatting.
+ /// </para>
+ /// <para>
+ /// This method does not take an <see cref="Exception"/> object to include in the
+ /// log event. To pass an <see cref="Exception"/> use one of the <see cref="FatalExt(ILog,object,Exception)"/>
+ /// methods instead.
+ /// </para>
+ /// </remarks>
+ /// <seealso cref="ILog.Fatal(object)"/>
+ /// <seealso cref="ILog.IsFatalEnabled"/>
+ public static void FatalFormatExt(this ILog logger, string format, object arg0, object arg1)
+ {
+ try
+ {
+ if (!logger.IsFatalEnabled)
+ return;
- logger.FatalFormat(format, arg0, arg1);
- }
- catch (Exception ex)
- {
- log4net.Util.LogLog.Error(declaringType, "Exception while logging", ex);
- }
- }
+ logger.FatalFormat(format, arg0, arg1);
+ }
+ catch (Exception ex)
+ {
+ log4net.Util.LogLog.Error(declaringType, "Exception while logging", ex);
+ }
+ }
- /// <summary>
- /// Logs a formatted message string with the <see cref="Level.Fatal"/> level.
- /// </summary>
- /// <param name="logger">The logger on which the message is logged.</param>
- /// <param name="format">A String containing zero or more format items</param>
- /// <param name="arg0">An Object to format</param>
- /// <param name="arg1">An Object to format</param>
- /// <param name="arg2">An Object to format</param>
- /// <remarks>
- /// <para>
- /// The message is formatted using the <c>String.Format</c> method. See
- /// <see cref="String.Format(string, object[])"/> for details of the syntax of the format string and the behavior
- /// of the formatting.
- /// </para>
- /// <para>
- /// This method does not take an <see cref="Exception"/> object to include in the
- /// log event. To pass an <see cref="Exception"/> use one of the <see cref="FatalExt(ILog,object,Exception)"/>
- /// methods instead.
- /// </para>
- /// </remarks>
- /// <seealso cref="ILog.Fatal(object)"/>
- /// <seealso cref="ILog.IsFatalEnabled"/>
- public static void FatalFormatExt(this ILog logger, string format, object arg0, object arg1, object arg2)
- {
- try
- {
- if (!logger.IsFatalEnabled)
- return;
+ /// <summary>
+ /// Logs a formatted message string with the <see cref="Level.Fatal"/> level.
+ /// </summary>
+ /// <param name="logger">The logger on which the message is logged.</param>
+ /// <param name="format">A String containing zero or more format items</param>
+ /// <param name="arg0">An Object to format</param>
+ /// <param name="arg1">An Object to format</param>
+ /// <param name="arg2">An Object to format</param>
+ /// <remarks>
+ /// <para>
+ /// The message is formatted using the <c>String.Format</c> method. See
+ /// <see cref="String.Format(string, object[])"/> for details of the syntax of the format string and the behavior
+ /// of the formatting.
+ /// </para>
+ /// <para>
+ /// This method does not take an <see cref="Exception"/> object to include in the
+ /// log event. To pass an <see cref="Exception"/> use one of the <see cref="FatalExt(ILog,object,Exception)"/>
+ /// methods instead.
+ /// </para>
+ /// </remarks>
+ /// <seealso cref="ILog.Fatal(object)"/>
+ /// <seealso cref="ILog.IsFatalEnabled"/>
+ public static void FatalFormatExt(this ILog logger, string format, object arg0, object arg1, object arg2)
+ {
+ try
+ {
+ if (!logger.IsFatalEnabled)
+ return;
- logger.FatalFormat(format, arg0, arg1, arg2);
- }
- catch (Exception ex)
- {
- log4net.Util.LogLog.Error(declaringType, "Exception while logging", ex);
- }
- }
+ logger.FatalFormat(format, arg0, arg1, arg2);
+ }
+ catch (Exception ex)
+ {
+ log4net.Util.LogLog.Error(declaringType, "Exception while logging", ex);
+ }
+ }
- #endregion
+ #endregion
- #endregion
- }
+ #endregion
+ }
}
#endif
diff --git a/src/log4net/Util/LevelMapping.cs b/src/log4net/Util/LevelMapping.cs
index a2d4aff..aee83b2 100644
--- a/src/log4net/Util/LevelMapping.cs
+++ b/src/log4net/Util/LevelMapping.cs
@@ -24,127 +24,127 @@
namespace log4net.Util
{
- /// <summary>
- /// Manages a mapping from levels to <see cref="LevelMappingEntry"/>
- /// </summary>
- /// <remarks>
- /// <para>
- /// Manages an ordered mapping from <see cref="Level"/> instances
- /// to <see cref="LevelMappingEntry"/> subclasses.
- /// </para>
- /// </remarks>
- /// <author>Nicko Cadell</author>
- public sealed class LevelMapping : IOptionHandler
- {
- #region Public Instance Constructors
+ /// <summary>
+ /// Manages a mapping from levels to <see cref="LevelMappingEntry"/>
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Manages an ordered mapping from <see cref="Level"/> instances
+ /// to <see cref="LevelMappingEntry"/> subclasses.
+ /// </para>
+ /// </remarks>
+ /// <author>Nicko Cadell</author>
+ public sealed class LevelMapping : IOptionHandler
+ {
+ #region Public Instance Constructors
- /// <summary>
- /// Default constructor
- /// </summary>
- /// <remarks>
- /// <para>
- /// Initialise a new instance of <see cref="LevelMapping"/>.
- /// </para>
- /// </remarks>
- public LevelMapping()
- {
- }
+ /// <summary>
+ /// Default constructor
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Initialise a new instance of <see cref="LevelMapping"/>.
+ /// </para>
+ /// </remarks>
+ public LevelMapping()
+ {
+ }
- #endregion // Public Instance Constructors
+ #endregion // Public Instance Constructors
- #region Public Instance Methods
-
- /// <summary>
- /// Add a <see cref="LevelMappingEntry"/> to this mapping
- /// </summary>
- /// <param name="entry">the entry to add</param>
- /// <remarks>
- /// <para>
- /// If a <see cref="LevelMappingEntry"/> has previously been added
- /// for the same <see cref="Level"/> then that entry will be
- /// overwritten.
- /// </para>
- /// </remarks>
- public void Add(LevelMappingEntry entry)
- {
- if (m_entriesMap.ContainsKey(entry.Level))
- {
- m_entriesMap.Remove(entry.Level);
- }
- m_entriesMap.Add(entry.Level, entry);
- }
+ #region Public Instance Methods
+
+ /// <summary>
+ /// Add a <see cref="LevelMappingEntry"/> to this mapping
+ /// </summary>
+ /// <param name="entry">the entry to add</param>
+ /// <remarks>
+ /// <para>
+ /// If a <see cref="LevelMappingEntry"/> has previously been added
+ /// for the same <see cref="Level"/> then that entry will be
+ /// overwritten.
+ /// </para>
+ /// </remarks>
+ public void Add(LevelMappingEntry entry)
+ {
+ if (m_entriesMap.ContainsKey(entry.Level))
+ {
+ m_entriesMap.Remove(entry.Level);
+ }
+ m_entriesMap.Add(entry.Level, entry);
+ }
- /// <summary>
- /// Lookup the mapping for the specified level
- /// </summary>
- /// <param name="level">the level to lookup</param>
- /// <returns>the <see cref="LevelMappingEntry"/> for the level or <c>null</c> if no mapping found</returns>
- /// <remarks>
- /// <para>
- /// Lookup the value for the specified level. Finds the nearest
- /// mapping value for the level that is equal to or less than the
- /// <paramref name="level"/> specified.
- /// </para>
- /// <para>
- /// If no mapping could be found then <c>null</c> is returned.
- /// </para>
- /// </remarks>
- public LevelMappingEntry Lookup(Level level)
- {
- if (m_entries != null)
- {
- foreach(LevelMappingEntry entry in m_entries)
- {
- if (level >= entry.Level)
- {
- return entry;
- }
- }
- }
- return null;
- }
+ /// <summary>
+ /// Lookup the mapping for the specified level
+ /// </summary>
+ /// <param name="level">the level to lookup</param>
+ /// <returns>the <see cref="LevelMappingEntry"/> for the level or <c>null</c> if no mapping found</returns>
+ /// <remarks>
+ /// <para>
+ /// Lookup the value for the specified level. Finds the nearest
+ /// mapping value for the level that is equal to or less than the
+ /// <paramref name="level"/> specified.
+ /// </para>
+ /// <para>
+ /// If no mapping could be found then <c>null</c> is returned.
+ /// </para>
+ /// </remarks>
+ public LevelMappingEntry Lookup(Level level)
+ {
+ if (m_entries != null)
+ {
+ foreach(LevelMappingEntry entry in m_entries)
+ {
+ if (level >= entry.Level)
+ {
+ return entry;
+ }
+ }
+ }
+ return null;
+ }
- #endregion // Public Instance Methods
+ #endregion // Public Instance Methods
- #region IOptionHandler Members
+ #region IOptionHandler Members
- /// <summary>
- /// Initialize options
- /// </summary>
- /// <remarks>
- /// <para>
- /// Caches the sorted list of <see cref="LevelMappingEntry"/> in an array
- /// </para>
- /// </remarks>
- public void ActivateOptions()
- {
- Level[] sortKeys = new Level[m_entriesMap.Count];
- LevelMappingEntry[] sortValues = new LevelMappingEntry[m_entriesMap.Count];
+ /// <summary>
+ /// Initialize options
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Caches the sorted list of <see cref="LevelMappingEntry"/> in an array
+ /// </para>
+ /// </remarks>
+ public void ActivateOptions()
+ {
+ Level[] sortKeys = new Level[m_entriesMap.Count];
+ LevelMappingEntry[] sortValues = new LevelMappingEntry[m_entriesMap.Count];
- m_entriesMap.Keys.CopyTo(sortKeys, 0);
- m_entriesMap.Values.CopyTo(sortValues, 0);
+ m_entriesMap.Keys.CopyTo(sortKeys, 0);
+ m_entriesMap.Values.CopyTo(sortValues, 0);
- // Sort in level order
- Array.Sort(sortKeys, sortValues, 0, sortKeys.Length, null);
+ // Sort in level order
+ Array.Sort(sortKeys, sortValues, 0, sortKeys.Length, null);
- // Reverse list so that highest level is first
- Array.Reverse(sortValues, 0, sortValues.Length);
+ // Reverse list so that highest level is first
+ Array.Reverse(sortValues, 0, sortValues.Length);
- foreach(LevelMappingEntry entry in sortValues)
- {
- entry.ActivateOptions();
- }
+ foreach(LevelMappingEntry entry in sortValues)
+ {
+ entry.ActivateOptions();
+ }
- m_entries = sortValues;
- }
+ m_entries = sortValues;
+ }
- #endregion // IOptionHandler Members
+ #endregion // IOptionHandler Members
- #region Private Instance Fields
+ #region Private Instance Fields
- private Hashtable m_entriesMap = new Hashtable();
- private LevelMappingEntry[] m_entries = null;
+ private Hashtable m_entriesMap = new Hashtable();
+ private LevelMappingEntry[] m_entries = null;
- #endregion // Private Instance Fields
- }
+ #endregion // Private Instance Fields
+ }
}
diff --git a/src/log4net/Util/LevelMappingEntry.cs b/src/log4net/Util/LevelMappingEntry.cs
index 1a3975b..4bbe004 100644
--- a/src/log4net/Util/LevelMappingEntry.cs
+++ b/src/log4net/Util/LevelMappingEntry.cs
@@ -24,77 +24,77 @@
namespace log4net.Util
{
- /// <summary>
- /// An entry in the <see cref="LevelMapping"/>
- /// </summary>
- /// <remarks>
- /// <para>
- /// This is an abstract base class for types that are stored in the
- /// <see cref="LevelMapping"/> object.
- /// </para>
- /// </remarks>
- /// <author>Nicko Cadell</author>
- public abstract class LevelMappingEntry : IOptionHandler
- {
- #region Public Instance Constructors
+ /// <summary>
+ /// An entry in the <see cref="LevelMapping"/>
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// This is an abstract base class for types that are stored in the
+ /// <see cref="LevelMapping"/> object.
+ /// </para>
+ /// </remarks>
+ /// <author>Nicko Cadell</author>
+ public abstract class LevelMappingEntry : IOptionHandler
+ {
+ #region Public Instance Constructors
- /// <summary>
- /// Default protected constructor
- /// </summary>
- /// <remarks>
- /// <para>
- /// Default protected constructor
- /// </para>
- /// </remarks>
- protected LevelMappingEntry()
- {
- }
+ /// <summary>
+ /// Default protected constructor
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Default protected constructor
+ /// </para>
+ /// </remarks>
+ protected LevelMappingEntry()
+ {
+ }
- #endregion // Public Instance Constructors
+ #endregion // Public Instance Constructors
- #region Public Instance Properties
+ #region Public Instance Properties
- /// <summary>
- /// The level that is the key for this mapping
- /// </summary>
- /// <value>
- /// The <see cref="Level"/> that is the key for this mapping
- /// </value>
- /// <remarks>
- /// <para>
- /// Get or set the <see cref="Level"/> that is the key for this
- /// mapping subclass.
- /// </para>
- /// </remarks>
- public Level Level
- {
- get { return m_level; }
- set { m_level = value; }
- }
+ /// <summary>
+ /// The level that is the key for this mapping
+ /// </summary>
+ /// <value>
+ /// The <see cref="Level"/> that is the key for this mapping
+ /// </value>
+ /// <remarks>
+ /// <para>
+ /// Get or set the <see cref="Level"/> that is the key for this
+ /// mapping subclass.
+ /// </para>
+ /// </remarks>
+ public Level Level
+ {
+ get { return m_level; }
+ set { m_level = value; }
+ }
- #endregion // Public Instance Properties
+ #endregion // Public Instance Properties
- #region IOptionHandler Members
+ #region IOptionHandler Members
- /// <summary>
- /// Initialize any options defined on this entry
- /// </summary>
- /// <remarks>
- /// <para>
- /// Should be overridden by any classes that need to initialise based on their options
- /// </para>
- /// </remarks>
- public virtual void ActivateOptions()
- {
- // default implementation is to do nothing
- }
+ /// <summary>
+ /// Initialize any options defined on this entry
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Should be overridden by any classes that need to initialise based on their options
+ /// </para>
+ /// </remarks>
+ public virtual void ActivateOptions()
+ {
+ // default implementation is to do nothing
+ }
- #endregion // IOptionHandler Members
+ #endregion // IOptionHandler Members
- #region Private Instance Fields
+ #region Private Instance Fields
- private Level m_level;
+ private Level m_level;
- #endregion // Private Instance Fields
- }
+ #endregion // Private Instance Fields
+ }
}
diff --git a/src/log4net/Util/LogLog.cs b/src/log4net/Util/LogLog.cs
index 84f640e..8c0f0a7 100644
--- a/src/log4net/Util/LogLog.cs
+++ b/src/log4net/Util/LogLog.cs
@@ -30,25 +30,25 @@
/// <param name="e"></param>
public delegate void LogReceivedEventHandler(object source, LogReceivedEventArgs e);
- /// <summary>
- /// Outputs log statements from within the log4net assembly.
- /// </summary>
- /// <remarks>
- /// <para>
- /// Log4net components cannot make log4net logging calls. However, it is
- /// sometimes useful for the user to learn about what log4net is
- /// doing.
- /// </para>
- /// <para>
- /// All log4net internal debug calls go to the standard output stream
- /// whereas internal error messages are sent to the standard error output
- /// stream.
- /// </para>
- /// </remarks>
- /// <author>Nicko Cadell</author>
- /// <author>Gert Driesen</author>
- public sealed class LogLog
- {
+ /// <summary>
+ /// Outputs log statements from within the log4net assembly.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Log4net components cannot make log4net logging calls. However, it is
+ /// sometimes useful for the user to learn about what log4net is
+ /// doing.
+ /// </para>
+ /// <para>
+ /// All log4net internal debug calls go to the standard output stream
+ /// whereas internal error messages are sent to the standard error output
+ /// stream.
+ /// </para>
+ /// </remarks>
+ /// <author>Nicko Cadell</author>
+ /// <author>Gert Driesen</author>
+ public sealed class LogLog
+ {
/// <summary>
/// The event raised when an internal message has been received.
/// </summary>
@@ -63,18 +63,18 @@
/// <summary>
/// The Type that generated the internal message.
/// </summary>
- public Type Source
- {
- get { return source; }
- }
+ public Type Source
+ {
+ get { return source; }
+ }
/// <summary>
/// The DateTime stamp of when the internal message was received.
/// </summary>
- public DateTime TimeStamp
- {
+ public DateTime TimeStamp
+ {
get { return timeStampUtc.ToLocalTime(); }
- }
+ }
/// <summary>
/// The UTC DateTime stamp of when the internal message was received.
@@ -82,7 +82,7 @@
public DateTime TimeStampUtc
{
get { return timeStampUtc; }
- }
+ }
/// <summary>
/// A string indicating the severity of the internal message.
@@ -92,18 +92,18 @@
/// "log4net:ERROR ",
/// "log4net:WARN "
/// </remarks>
- public string Prefix
- {
- get { return prefix; }
- }
+ public string Prefix
+ {
+ get { return prefix; }
+ }
/// <summary>
/// The internal log message.
/// </summary>
- public string Message
- {
- get { return message; }
- }
+ public string Message
+ {
+ get { return message; }
+ }
/// <summary>
/// The Exception related to the message.
@@ -111,22 +111,22 @@
/// <remarks>
/// Optional. Will be null if no Exception was passed.
/// </remarks>
- public Exception Exception
- {
- get { return exception; }
- }
+ public Exception Exception
+ {
+ get { return exception; }
+ }
/// <summary>
/// Formats Prefix, Source, and Message in the same format as the value
/// sent to Console.Out and Trace.Write.
/// </summary>
/// <returns></returns>
- public override string ToString()
- {
+ public override string ToString()
+ {
return Prefix + Source.Name + ": " + Message;
- }
+ }
- #region Private Instance Constructors
+ #region Private Instance Constructors
/// <summary>
/// Initializes a new instance of the <see cref="LogLog" /> class.
@@ -135,142 +135,142 @@
/// <param name="prefix"></param>
/// <param name="message"></param>
/// <param name="exception"></param>
- public LogLog(Type source, string prefix, string message, Exception exception)
- {
+ public LogLog(Type source, string prefix, string message, Exception exception)
+ {
timeStampUtc = DateTime.UtcNow;
-
+
this.source = source;
- this.prefix = prefix;
- this.message = message;
- this.exception = exception;
- }
+ this.prefix = prefix;
+ this.message = message;
+ this.exception = exception;
+ }
- #endregion Private Instance Constructors
+ #endregion Private Instance Constructors
- #region Static Constructor
+ #region Static Constructor
- /// <summary>
- /// Static constructor that initializes logging by reading
- /// settings from the application configuration file.
- /// </summary>
- /// <remarks>
- /// <para>
- /// The <c>log4net.Internal.Debug</c> application setting
- /// controls internal debugging. This setting should be set
- /// to <c>true</c> to enable debugging.
- /// </para>
- /// <para>
- /// The <c>log4net.Internal.Quiet</c> application setting
- /// suppresses all internal logging including error messages.
- /// This setting should be set to <c>true</c> to enable message
- /// suppression.
- /// </para>
- /// </remarks>
- static LogLog()
- {
+ /// <summary>
+ /// Static constructor that initializes logging by reading
+ /// settings from the application configuration file.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// The <c>log4net.Internal.Debug</c> application setting
+ /// controls internal debugging. This setting should be set
+ /// to <c>true</c> to enable debugging.
+ /// </para>
+ /// <para>
+ /// The <c>log4net.Internal.Quiet</c> application setting
+ /// suppresses all internal logging including error messages.
+ /// This setting should be set to <c>true</c> to enable message
+ /// suppression.
+ /// </para>
+ /// </remarks>
+ static LogLog()
+ {
#if !NETCF
- try
- {
- InternalDebugging = OptionConverter.ToBoolean(SystemInfo.GetAppSetting("log4net.Internal.Debug"), false);
- QuietMode = OptionConverter.ToBoolean(SystemInfo.GetAppSetting("log4net.Internal.Quiet"), false);
- EmitInternalMessages = OptionConverter.ToBoolean(SystemInfo.GetAppSetting("log4net.Internal.Emit"), true);
- }
- catch(Exception ex)
- {
- // If an exception is thrown here then it looks like the config file does not
- // parse correctly.
- //
- // We will leave debug OFF and print an Error message
- Error(typeof(LogLog), "Exception while reading ConfigurationSettings. Check your .config file is well formed XML.", ex);
- }
+ try
+ {
+ InternalDebugging = OptionConverter.ToBoolean(SystemInfo.GetAppSetting("log4net.Internal.Debug"), false);
+ QuietMode = OptionConverter.ToBoolean(SystemInfo.GetAppSetting("log4net.Internal.Quiet"), false);
+ EmitInternalMessages = OptionConverter.ToBoolean(SystemInfo.GetAppSetting("log4net.Internal.Emit"), true);
+ }
+ catch(Exception ex)
+ {
+ // If an exception is thrown here then it looks like the config file does not
+ // parse correctly.
+ //
+ // We will leave debug OFF and print an Error message
+ Error(typeof(LogLog), "Exception while reading ConfigurationSettings. Check your .config file is well formed XML.", ex);
+ }
#endif
- }
+ }
- #endregion Static Constructor
+ #endregion Static Constructor
- #region Public Static Properties
+ #region Public Static Properties
- /// <summary>
- /// Gets or sets a value indicating whether log4net internal logging
- /// is enabled or disabled.
- /// </summary>
- /// <value>
- /// <c>true</c> if log4net internal logging is enabled, otherwise
- /// <c>false</c>.
- /// </value>
- /// <remarks>
- /// <para>
- /// When set to <c>true</c>, internal debug level logging will be
- /// displayed.
- /// </para>
- /// <para>
- /// This value can be set by setting the application setting
- /// <c>log4net.Internal.Debug</c> in the application configuration
- /// file.
- /// </para>
- /// <para>
- /// The default value is <c>false</c>, i.e. debugging is
- /// disabled.
- /// </para>
- /// </remarks>
- /// <example>
- /// <para>
- /// The following example enables internal debugging using the
- /// application configuration file :
- /// </para>
- /// <code lang="XML" escaped="true">
- /// <configuration>
- /// <appSettings>
- /// <add key="log4net.Internal.Debug" value="true" />
- /// </appSettings>
- /// </configuration>
- /// </code>
- /// </example>
- public static bool InternalDebugging
- {
- get { return s_debugEnabled; }
- set { s_debugEnabled = value; }
- }
+ /// <summary>
+ /// Gets or sets a value indicating whether log4net internal logging
+ /// is enabled or disabled.
+ /// </summary>
+ /// <value>
+ /// <c>true</c> if log4net internal logging is enabled, otherwise
+ /// <c>false</c>.
+ /// </value>
+ /// <remarks>
+ /// <para>
+ /// When set to <c>true</c>, internal debug level logging will be
+ /// displayed.
+ /// </para>
+ /// <para>
+ /// This value can be set by setting the application setting
+ /// <c>log4net.Internal.Debug</c> in the application configuration
+ /// file.
+ /// </para>
+ /// <para>
+ /// The default value is <c>false</c>, i.e. debugging is
+ /// disabled.
+ /// </para>
+ /// </remarks>
+ /// <example>
+ /// <para>
+ /// The following example enables internal debugging using the
+ /// application configuration file :
+ /// </para>
+ /// <code lang="XML" escaped="true">
+ /// <configuration>
+ /// <appSettings>
+ /// <add key="log4net.Internal.Debug" value="true" />
+ /// </appSettings>
+ /// </configuration>
+ /// </code>
+ /// </example>
+ public static bool InternalDebugging
+ {
+ get { return s_debugEnabled; }
+ set { s_debugEnabled = value; }
+ }
- /// <summary>
- /// Gets or sets a value indicating whether log4net should generate no output
- /// from internal logging, not even for errors.
- /// </summary>
- /// <value>
- /// <c>true</c> if log4net should generate no output at all from internal
- /// logging, otherwise <c>false</c>.
- /// </value>
- /// <remarks>
- /// <para>
- /// When set to <c>true</c> will cause internal logging at all levels to be
- /// suppressed. This means that no warning or error reports will be logged.
- /// This option overrides the <see cref="InternalDebugging"/> setting and
- /// disables all debug also.
- /// </para>
- /// <para>This value can be set by setting the application setting
- /// <c>log4net.Internal.Quiet</c> in the application configuration file.
- /// </para>
- /// <para>
- /// The default value is <c>false</c>, i.e. internal logging is not
- /// disabled.
- /// </para>
- /// </remarks>
- /// <example>
- /// The following example disables internal logging using the
- /// application configuration file :
- /// <code lang="XML" escaped="true">
- /// <configuration>
- /// <appSettings>
- /// <add key="log4net.Internal.Quiet" value="true" />
- /// </appSettings>
- /// </configuration>
- /// </code>
- /// </example>
- public static bool QuietMode
- {
- get { return s_quietMode; }
- set { s_quietMode = value; }
- }
+ /// <summary>
+ /// Gets or sets a value indicating whether log4net should generate no output
+ /// from internal logging, not even for errors.
+ /// </summary>
+ /// <value>
+ /// <c>true</c> if log4net should generate no output at all from internal
+ /// logging, otherwise <c>false</c>.
+ /// </value>
+ /// <remarks>
+ /// <para>
+ /// When set to <c>true</c> will cause internal logging at all levels to be
+ /// suppressed. This means that no warning or error reports will be logged.
+ /// This option overrides the <see cref="InternalDebugging"/> setting and
+ /// disables all debug also.
+ /// </para>
+ /// <para>This value can be set by setting the application setting
+ /// <c>log4net.Internal.Quiet</c> in the application configuration file.
+ /// </para>
+ /// <para>
+ /// The default value is <c>false</c>, i.e. internal logging is not
+ /// disabled.
+ /// </para>
+ /// </remarks>
+ /// <example>
+ /// The following example disables internal logging using the
+ /// application configuration file :
+ /// <code lang="XML" escaped="true">
+ /// <configuration>
+ /// <appSettings>
+ /// <add key="log4net.Internal.Quiet" value="true" />
+ /// </appSettings>
+ /// </configuration>
+ /// </code>
+ /// </example>
+ public static bool QuietMode
+ {
+ get { return s_quietMode; }
+ set { s_quietMode = value; }
+ }
/// <summary>
///
@@ -281,9 +281,9 @@
set { s_emitInternalMessages = value; }
}
- #endregion Public Static Properties
+ #endregion Public Static Properties
- #region Public Static Methods
+ #region Public Static Methods
/// <summary>
/// Raises the LogReceived event when an internal messages is received.
@@ -300,64 +300,64 @@
}
}
- /// <summary>
- /// Test if LogLog.Debug is enabled for output.
- /// </summary>
- /// <value>
- /// <c>true</c> if Debug is enabled
- /// </value>
- /// <remarks>
- /// <para>
- /// Test if LogLog.Debug is enabled for output.
- /// </para>
- /// </remarks>
- public static bool IsDebugEnabled
- {
- get { return s_debugEnabled && !s_quietMode; }
- }
+ /// <summary>
+ /// Test if LogLog.Debug is enabled for output.
+ /// </summary>
+ /// <value>
+ /// <c>true</c> if Debug is enabled
+ /// </value>
+ /// <remarks>
+ /// <para>
+ /// Test if LogLog.Debug is enabled for output.
+ /// </para>
+ /// </remarks>
+ public static bool IsDebugEnabled
+ {
+ get { return s_debugEnabled && !s_quietMode; }
+ }
- /// <summary>
- /// Writes log4net internal debug messages to the
- /// standard output stream.
- /// </summary>
+ /// <summary>
+ /// Writes log4net internal debug messages to the
+ /// standard output stream.
+ /// </summary>
/// <param name="source"></param>
- /// <param name="message">The message to log.</param>
- /// <remarks>
- /// <para>
- /// All internal debug messages are prepended with
- /// the string "log4net: ".
- /// </para>
- /// </remarks>
- public static void Debug(Type source, string message)
- {
- if (IsDebugEnabled)
- {
+ /// <param name="message">The message to log.</param>
+ /// <remarks>
+ /// <para>
+ /// All internal debug messages are prepended with
+ /// the string "log4net: ".
+ /// </para>
+ /// </remarks>
+ public static void Debug(Type source, string message)
+ {
+ if (IsDebugEnabled)
+ {
if (EmitInternalMessages)
{
EmitOutLine(PREFIX + message);
}
OnLogReceived(source, PREFIX, message, null);
- }
- }
+ }
+ }
- /// <summary>
- /// Writes log4net internal debug messages to the
- /// standard output stream.
- /// </summary>
+ /// <summary>
+ /// Writes log4net internal debug messages to the
+ /// standard output stream.
+ /// </summary>
/// <param name="source">The Type that generated this message.</param>
- /// <param name="message">The message to log.</param>
- /// <param name="exception">An exception to log.</param>
- /// <remarks>
- /// <para>
- /// All internal debug messages are prepended with
- /// the string "log4net: ".
- /// </para>
- /// </remarks>
- public static void Debug(Type source, string message, Exception exception)
- {
- if (IsDebugEnabled)
- {
+ /// <param name="message">The message to log.</param>
+ /// <param name="exception">An exception to log.</param>
+ /// <remarks>
+ /// <para>
+ /// All internal debug messages are prepended with
+ /// the string "log4net: ".
+ /// </para>
+ /// </remarks>
+ public static void Debug(Type source, string message, Exception exception)
+ {
+ if (IsDebugEnabled)
+ {
if (EmitInternalMessages)
{
EmitOutLine(PREFIX + message);
@@ -368,67 +368,67 @@
}
OnLogReceived(source, PREFIX, message, exception);
- }
- }
+ }
+ }
- /// <summary>
- /// Test if LogLog.Warn is enabled for output.
- /// </summary>
- /// <value>
- /// <c>true</c> if Warn is enabled
- /// </value>
- /// <remarks>
- /// <para>
- /// Test if LogLog.Warn is enabled for output.
- /// </para>
- /// </remarks>
- public static bool IsWarnEnabled
- {
- get { return !s_quietMode; }
- }
+ /// <summary>
+ /// Test if LogLog.Warn is enabled for output.
+ /// </summary>
+ /// <value>
+ /// <c>true</c> if Warn is enabled
+ /// </value>
+ /// <remarks>
+ /// <para>
+ /// Test if LogLog.Warn is enabled for output.
+ /// </para>
+ /// </remarks>
+ public static bool IsWarnEnabled
+ {
+ get { return !s_quietMode; }
+ }
- /// <summary>
- /// Writes log4net internal warning messages to the
- /// standard error stream.
- /// </summary>
+ /// <summary>
+ /// Writes log4net internal warning messages to the
+ /// standard error stream.
+ /// </summary>
/// <param name="source">The Type that generated this message.</param>
- /// <param name="message">The message to log.</param>
- /// <remarks>
- /// <para>
- /// All internal warning messages are prepended with
- /// the string "log4net:WARN ".
- /// </para>
- /// </remarks>
- public static void Warn(Type source, string message)
- {
- if (IsWarnEnabled)
- {
+ /// <param name="message">The message to log.</param>
+ /// <remarks>
+ /// <para>
+ /// All internal warning messages are prepended with
+ /// the string "log4net:WARN ".
+ /// </para>
+ /// </remarks>
+ public static void Warn(Type source, string message)
+ {
+ if (IsWarnEnabled)
+ {
if (EmitInternalMessages)
{
EmitErrorLine(WARN_PREFIX + message);
}
OnLogReceived(source, WARN_PREFIX, message, null);
- }
- }
+ }
+ }
- /// <summary>
- /// Writes log4net internal warning messages to the
- /// standard error stream.
- /// </summary>
+ /// <summary>
+ /// Writes log4net internal warning messages to the
+ /// standard error stream.
+ /// </summary>
/// <param name="source">The Type that generated this message.</param>
- /// <param name="message">The message to log.</param>
- /// <param name="exception">An exception to log.</param>
- /// <remarks>
- /// <para>
- /// All internal warning messages are prepended with
- /// the string "log4net:WARN ".
- /// </para>
- /// </remarks>
- public static void Warn(Type source, string message, Exception exception)
- {
- if (IsWarnEnabled)
- {
+ /// <param name="message">The message to log.</param>
+ /// <param name="exception">An exception to log.</param>
+ /// <remarks>
+ /// <para>
+ /// All internal warning messages are prepended with
+ /// the string "log4net:WARN ".
+ /// </para>
+ /// </remarks>
+ public static void Warn(Type source, string message, Exception exception)
+ {
+ if (IsWarnEnabled)
+ {
if (EmitInternalMessages)
{
EmitErrorLine(WARN_PREFIX + message);
@@ -439,67 +439,67 @@
}
OnLogReceived(source, WARN_PREFIX, message, exception);
- }
- }
+ }
+ }
- /// <summary>
- /// Test if LogLog.Error is enabled for output.
- /// </summary>
- /// <value>
- /// <c>true</c> if Error is enabled
- /// </value>
- /// <remarks>
- /// <para>
- /// Test if LogLog.Error is enabled for output.
- /// </para>
- /// </remarks>
- public static bool IsErrorEnabled
- {
- get { return !s_quietMode; }
- }
+ /// <summary>
+ /// Test if LogLog.Error is enabled for output.
+ /// </summary>
+ /// <value>
+ /// <c>true</c> if Error is enabled
+ /// </value>
+ /// <remarks>
+ /// <para>
+ /// Test if LogLog.Error is enabled for output.
+ /// </para>
+ /// </remarks>
+ public static bool IsErrorEnabled
+ {
+ get { return !s_quietMode; }
+ }
- /// <summary>
- /// Writes log4net internal error messages to the
- /// standard error stream.
- /// </summary>
+ /// <summary>
+ /// Writes log4net internal error messages to the
+ /// standard error stream.
+ /// </summary>
/// <param name="source">The Type that generated this message.</param>
- /// <param name="message">The message to log.</param>
- /// <remarks>
- /// <para>
- /// All internal error messages are prepended with
- /// the string "log4net:ERROR ".
- /// </para>
- /// </remarks>
- public static void Error(Type source, string message)
- {
- if (IsErrorEnabled)
- {
+ /// <param name="message">The message to log.</param>
+ /// <remarks>
+ /// <para>
+ /// All internal error messages are prepended with
+ /// the string "log4net:ERROR ".
+ /// </para>
+ /// </remarks>
+ public static void Error(Type source, string message)
+ {
+ if (IsErrorEnabled)
+ {
if (EmitInternalMessages)
{
EmitErrorLine(ERR_PREFIX + message);
}
OnLogReceived(source, ERR_PREFIX, message, null);
- }
- }
+ }
+ }
- /// <summary>
- /// Writes log4net internal error messages to the
- /// standard error stream.
- /// </summary>
+ /// <summary>
+ /// Writes log4net internal error messages to the
+ /// standard error stream.
+ /// </summary>
/// <param name="source">The Type that generated this message.</param>
- /// <param name="message">The message to log.</param>
- /// <param name="exception">An exception to log.</param>
- /// <remarks>
- /// <para>
- /// All internal debug messages are prepended with
- /// the string "log4net:ERROR ".
- /// </para>
- /// </remarks>
- public static void Error(Type source, string message, Exception exception)
- {
- if (IsErrorEnabled)
- {
+ /// <param name="message">The message to log.</param>
+ /// <param name="exception">An exception to log.</param>
+ /// <remarks>
+ /// <para>
+ /// All internal debug messages are prepended with
+ /// the string "log4net:ERROR ".
+ /// </para>
+ /// </remarks>
+ public static void Error(Type source, string message, Exception exception)
+ {
+ if (IsErrorEnabled)
+ {
if (EmitInternalMessages)
{
EmitErrorLine(ERR_PREFIX + message);
@@ -510,98 +510,98 @@
}
OnLogReceived(source, ERR_PREFIX, message, exception);
- }
- }
+ }
+ }
- #endregion Public Static Methods
+ #endregion Public Static Methods
- /// <summary>
- /// Writes output to the standard output stream.
- /// </summary>
- /// <param name="message">The message to log.</param>
- /// <remarks>
- /// <para>
- /// Writes to both Console.Out and System.Diagnostics.Trace.
- /// Note that the System.Diagnostics.Trace is not supported
- /// on the Compact Framework.
- /// </para>
- /// <para>
- /// If the AppDomain is not configured with a config file then
- /// the call to System.Diagnostics.Trace may fail. This is only
- /// an issue if you are programmatically creating your own AppDomains.
- /// </para>
- /// </remarks>
- private static void EmitOutLine(string message)
- {
- try
- {
+ /// <summary>
+ /// Writes output to the standard output stream.
+ /// </summary>
+ /// <param name="message">The message to log.</param>
+ /// <remarks>
+ /// <para>
+ /// Writes to both Console.Out and System.Diagnostics.Trace.
+ /// Note that the System.Diagnostics.Trace is not supported
+ /// on the Compact Framework.
+ /// </para>
+ /// <para>
+ /// If the AppDomain is not configured with a config file then
+ /// the call to System.Diagnostics.Trace may fail. This is only
+ /// an issue if you are programmatically creating your own AppDomains.
+ /// </para>
+ /// </remarks>
+ private static void EmitOutLine(string message)
+ {
+ try
+ {
#if NETCF
- Console.WriteLine(message);
- //System.Diagnostics.Debug.WriteLine(message);
+ Console.WriteLine(message);
+ //System.Diagnostics.Debug.WriteLine(message);
#else
- Console.Out.WriteLine(message);
- Trace.WriteLine(message);
+ Console.Out.WriteLine(message);
+ Trace.WriteLine(message);
#endif
- }
- catch
- {
- // Ignore exception, what else can we do? Not really a good idea to propagate back to the caller
- }
- }
+ }
+ catch
+ {
+ // Ignore exception, what else can we do? Not really a good idea to propagate back to the caller
+ }
+ }
- /// <summary>
- /// Writes output to the standard error stream.
- /// </summary>
- /// <param name="message">The message to log.</param>
- /// <remarks>
- /// <para>
- /// Writes to both Console.Error and System.Diagnostics.Trace.
- /// Note that the System.Diagnostics.Trace is not supported
- /// on the Compact Framework.
- /// </para>
- /// <para>
- /// If the AppDomain is not configured with a config file then
- /// the call to System.Diagnostics.Trace may fail. This is only
- /// an issue if you are programmatically creating your own AppDomains.
- /// </para>
- /// </remarks>
- private static void EmitErrorLine(string message)
- {
- try
- {
+ /// <summary>
+ /// Writes output to the standard error stream.
+ /// </summary>
+ /// <param name="message">The message to log.</param>
+ /// <remarks>
+ /// <para>
+ /// Writes to both Console.Error and System.Diagnostics.Trace.
+ /// Note that the System.Diagnostics.Trace is not supported
+ /// on the Compact Framework.
+ /// </para>
+ /// <para>
+ /// If the AppDomain is not configured with a config file then
+ /// the call to System.Diagnostics.Trace may fail. This is only
+ /// an issue if you are programmatically creating your own AppDomains.
+ /// </para>
+ /// </remarks>
+ private static void EmitErrorLine(string message)
+ {
+ try
+ {
#if NETCF
- Console.WriteLine(message);
- //System.Diagnostics.Debug.WriteLine(message);
+ Console.WriteLine(message);
+ //System.Diagnostics.Debug.WriteLine(message);
#else
- Console.Error.WriteLine(message);
- Trace.WriteLine(message);
+ Console.Error.WriteLine(message);
+ Trace.WriteLine(message);
#endif
- }
- catch
- {
- // Ignore exception, what else can we do? Not really a good idea to propagate back to the caller
- }
- }
+ }
+ catch
+ {
+ // Ignore exception, what else can we do? Not really a good idea to propagate back to the caller
+ }
+ }
- #region Private Static Fields
+ #region Private Static Fields
- /// <summary>
- /// Default debug level
- /// </summary>
- private static bool s_debugEnabled = false;
+ /// <summary>
+ /// Default debug level
+ /// </summary>
+ private static bool s_debugEnabled = false;
- /// <summary>
- /// In quietMode not even errors generate any output.
- /// </summary>
- private static bool s_quietMode = false;
+ /// <summary>
+ /// In quietMode not even errors generate any output.
+ /// </summary>
+ private static bool s_quietMode = false;
private static bool s_emitInternalMessages = true;
- private const string PREFIX = "log4net: ";
- private const string ERR_PREFIX = "log4net:ERROR ";
- private const string WARN_PREFIX = "log4net:WARN ";
+ private const string PREFIX = "log4net: ";
+ private const string ERR_PREFIX = "log4net:ERROR ";
+ private const string WARN_PREFIX = "log4net:WARN ";
- #endregion Private Static Fields
+ #endregion Private Static Fields
/// <summary>
/// Subscribes to the LogLog.LogReceived event and stores messages
@@ -646,7 +646,7 @@
LogReceived -= handler;
}
}
- }
+ }
/// <summary>
///
diff --git a/src/log4net/Util/LogicalThreadContextProperties.cs b/src/log4net/Util/LogicalThreadContextProperties.cs
index 179c22b..8a93894 100644
--- a/src/log4net/Util/LogicalThreadContextProperties.cs
+++ b/src/log4net/Util/LogicalThreadContextProperties.cs
@@ -31,251 +31,251 @@
namespace log4net.Util
{
- /// <summary>
- /// Implementation of Properties collection for the <see cref="log4net.LogicalThreadContext"/>
- /// </summary>
- /// <remarks>
- /// <para>
- /// Class implements a collection of properties that is specific to each thread.
- /// The class is not synchronized as each thread has its own <see cref="PropertiesDictionary"/>.
- /// </para>
- /// <para>
- /// This class stores its properties in a slot on the <see cref="CallContext"/> named
- /// <c>log4net.Util.LogicalThreadContextProperties</c>.
- /// </para>
- /// <para>
- /// For .NET Standard 1.3 this class uses
- /// System.Threading.AsyncLocal rather than <see
- /// cref="System.Runtime.Remoting.Messaging.CallContext"/>.
- /// </para>
- /// <para>
- /// The <see cref="CallContext"/> requires a link time
- /// <see cref="System.Security.Permissions.SecurityPermission"/> for the
- /// <see cref="System.Security.Permissions.SecurityPermissionFlag.Infrastructure"/>.
- /// If the calling code does not have this permission then this context will be disabled.
- /// It will not store any property values set on it.
- /// </para>
- /// </remarks>
- /// <author>Nicko Cadell</author>
- public sealed class LogicalThreadContextProperties : ContextPropertiesBase
- {
+ /// <summary>
+ /// Implementation of Properties collection for the <see cref="log4net.LogicalThreadContext"/>
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Class implements a collection of properties that is specific to each thread.
+ /// The class is not synchronized as each thread has its own <see cref="PropertiesDictionary"/>.
+ /// </para>
+ /// <para>
+ /// This class stores its properties in a slot on the <see cref="CallContext"/> named
+ /// <c>log4net.Util.LogicalThreadContextProperties</c>.
+ /// </para>
+ /// <para>
+ /// For .NET Standard 1.3 this class uses
+ /// System.Threading.AsyncLocal rather than <see
+ /// cref="System.Runtime.Remoting.Messaging.CallContext"/>.
+ /// </para>
+ /// <para>
+ /// The <see cref="CallContext"/> requires a link time
+ /// <see cref="System.Security.Permissions.SecurityPermission"/> for the
+ /// <see cref="System.Security.Permissions.SecurityPermissionFlag.Infrastructure"/>.
+ /// If the calling code does not have this permission then this context will be disabled.
+ /// It will not store any property values set on it.
+ /// </para>
+ /// </remarks>
+ /// <author>Nicko Cadell</author>
+ public sealed class LogicalThreadContextProperties : ContextPropertiesBase
+ {
#if NETSTANDARD
- private static readonly AsyncLocal<PropertiesDictionary> AsyncLocalDictionary = new AsyncLocal<PropertiesDictionary>();
+ private static readonly AsyncLocal<PropertiesDictionary> AsyncLocalDictionary = new AsyncLocal<PropertiesDictionary>();
#else
- private const string c_SlotName = "log4net.Util.LogicalThreadContextProperties";
+ private const string c_SlotName = "log4net.Util.LogicalThreadContextProperties";
#endif
-
- /// <summary>
- /// Flag used to disable this context if we don't have permission to access the CallContext.
- /// </summary>
- private bool m_disabled = false;
-
- #region Public Instance Constructors
+
+ /// <summary>
+ /// Flag used to disable this context if we don't have permission to access the CallContext.
+ /// </summary>
+ private bool m_disabled = false;
+
+ #region Public Instance Constructors
- /// <summary>
- /// Constructor
- /// </summary>
- /// <remarks>
- /// <para>
- /// Initializes a new instance of the <see cref="LogicalThreadContextProperties" /> class.
- /// </para>
- /// </remarks>
- internal LogicalThreadContextProperties()
- {
- }
+ /// <summary>
+ /// Constructor
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Initializes a new instance of the <see cref="LogicalThreadContextProperties" /> class.
+ /// </para>
+ /// </remarks>
+ internal LogicalThreadContextProperties()
+ {
+ }
- #endregion Public Instance Constructors
+ #endregion Public Instance Constructors
- #region Public Instance Properties
+ #region Public Instance Properties
- /// <summary>
- /// Gets or sets the value of a property
- /// </summary>
- /// <value>
- /// The value for the property with the specified key
- /// </value>
- /// <remarks>
- /// <para>
- /// Get or set the property value for the <paramref name="key"/> specified.
- /// </para>
- /// </remarks>
- public override object this[string key]
- {
- get
- {
- // Don't create the dictionary if it does not already exist
- PropertiesDictionary dictionary = GetProperties(false);
- if (dictionary != null)
- {
- return dictionary[key];
- }
- return null;
- }
- set
- {
- // Force the dictionary to be created
- PropertiesDictionary props = GetProperties(true);
- // Reason for cloning the dictionary below: object instances set on the CallContext
- // need to be immutable to correctly flow through async/await
- PropertiesDictionary immutableProps = new PropertiesDictionary(props);
- immutableProps[key] = value;
- SetLogicalProperties(immutableProps);
- }
- }
+ /// <summary>
+ /// Gets or sets the value of a property
+ /// </summary>
+ /// <value>
+ /// The value for the property with the specified key
+ /// </value>
+ /// <remarks>
+ /// <para>
+ /// Get or set the property value for the <paramref name="key"/> specified.
+ /// </para>
+ /// </remarks>
+ public override object this[string key]
+ {
+ get
+ {
+ // Don't create the dictionary if it does not already exist
+ PropertiesDictionary dictionary = GetProperties(false);
+ if (dictionary != null)
+ {
+ return dictionary[key];
+ }
+ return null;
+ }
+ set
+ {
+ // Force the dictionary to be created
+ PropertiesDictionary props = GetProperties(true);
+ // Reason for cloning the dictionary below: object instances set on the CallContext
+ // need to be immutable to correctly flow through async/await
+ PropertiesDictionary immutableProps = new PropertiesDictionary(props);
+ immutableProps[key] = value;
+ SetLogicalProperties(immutableProps);
+ }
+ }
- #endregion Public Instance Properties
+ #endregion Public Instance Properties
- #region Public Instance Methods
+ #region Public Instance Methods
- /// <summary>
- /// Remove a property
- /// </summary>
- /// <param name="key">the key for the entry to remove</param>
- /// <remarks>
- /// <para>
- /// Remove the value for the specified <paramref name="key"/> from the context.
- /// </para>
- /// </remarks>
- public void Remove(string key)
- {
- PropertiesDictionary dictionary = GetProperties(false);
- if (dictionary != null)
- {
- PropertiesDictionary immutableProps = new PropertiesDictionary(dictionary);
- immutableProps.Remove(key);
- SetLogicalProperties(immutableProps);
- }
- }
+ /// <summary>
+ /// Remove a property
+ /// </summary>
+ /// <param name="key">the key for the entry to remove</param>
+ /// <remarks>
+ /// <para>
+ /// Remove the value for the specified <paramref name="key"/> from the context.
+ /// </para>
+ /// </remarks>
+ public void Remove(string key)
+ {
+ PropertiesDictionary dictionary = GetProperties(false);
+ if (dictionary != null)
+ {
+ PropertiesDictionary immutableProps = new PropertiesDictionary(dictionary);
+ immutableProps.Remove(key);
+ SetLogicalProperties(immutableProps);
+ }
+ }
- /// <summary>
- /// Clear all the context properties
- /// </summary>
- /// <remarks>
- /// <para>
- /// Clear all the context properties
- /// </para>
- /// </remarks>
- public void Clear()
- {
- PropertiesDictionary dictionary = GetProperties(false);
- if (dictionary != null)
- {
- PropertiesDictionary immutableProps = new PropertiesDictionary();
- SetLogicalProperties(immutableProps);
- }
- }
+ /// <summary>
+ /// Clear all the context properties
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Clear all the context properties
+ /// </para>
+ /// </remarks>
+ public void Clear()
+ {
+ PropertiesDictionary dictionary = GetProperties(false);
+ if (dictionary != null)
+ {
+ PropertiesDictionary immutableProps = new PropertiesDictionary();
+ SetLogicalProperties(immutableProps);
+ }
+ }
- #endregion Public Instance Methods
+ #endregion Public Instance Methods
- #region Internal Instance Methods
+ #region Internal Instance Methods
- /// <summary>
- /// Get the PropertiesDictionary stored in the LocalDataStoreSlot for this thread.
- /// </summary>
- /// <param name="create">create the dictionary if it does not exist, otherwise return null if is does not exist</param>
- /// <returns>the properties for this thread</returns>
- /// <remarks>
- /// <para>
- /// The collection returned is only to be used on the calling thread. If the
- /// caller needs to share the collection between different threads then the
- /// caller must clone the collection before doings so.
- /// </para>
- /// </remarks>
- internal PropertiesDictionary GetProperties(bool create)
- {
- if (!m_disabled)
- {
- try
- {
- PropertiesDictionary properties = GetLogicalProperties();
- if (properties == null && create)
- {
- properties = new PropertiesDictionary();
- SetLogicalProperties(properties);
- }
- return properties;
- }
- catch (SecurityException secEx)
- {
- m_disabled = true;
-
- // Thrown if we don't have permission to read or write the CallContext
- LogLog.Warn(declaringType, "SecurityException while accessing CallContext. Disabling LogicalThreadContextProperties", secEx);
- }
- }
-
- // Only get here is we are disabled because of a security exception
- if (create)
- {
- return new PropertiesDictionary();
- }
- return null;
- }
+ /// <summary>
+ /// Get the PropertiesDictionary stored in the LocalDataStoreSlot for this thread.
+ /// </summary>
+ /// <param name="create">create the dictionary if it does not exist, otherwise return null if is does not exist</param>
+ /// <returns>the properties for this thread</returns>
+ /// <remarks>
+ /// <para>
+ /// The collection returned is only to be used on the calling thread. If the
+ /// caller needs to share the collection between different threads then the
+ /// caller must clone the collection before doings so.
+ /// </para>
+ /// </remarks>
+ internal PropertiesDictionary GetProperties(bool create)
+ {
+ if (!m_disabled)
+ {
+ try
+ {
+ PropertiesDictionary properties = GetLogicalProperties();
+ if (properties == null && create)
+ {
+ properties = new PropertiesDictionary();
+ SetLogicalProperties(properties);
+ }
+ return properties;
+ }
+ catch (SecurityException secEx)
+ {
+ m_disabled = true;
+
+ // Thrown if we don't have permission to read or write the CallContext
+ LogLog.Warn(declaringType, "SecurityException while accessing CallContext. Disabling LogicalThreadContextProperties", secEx);
+ }
+ }
+
+ // Only get here is we are disabled because of a security exception
+ if (create)
+ {
+ return new PropertiesDictionary();
+ }
+ return null;
+ }
- #endregion Internal Instance Methods
+ #endregion Internal Instance Methods
#region Private Static Methods
/// <summary>
- /// Gets the call context get data.
- /// </summary>
- /// <returns>The peroperties dictionary stored in the call context</returns>
- /// <remarks>
- /// The <see cref="CallContext"/> method <see cref="CallContext.GetData"/> has a
- /// security link demand, therfore we must put the method call in a seperate method
- /// that we can wrap in an exception handler.
- /// </remarks>
+ /// Gets the call context get data.
+ /// </summary>
+ /// <returns>The peroperties dictionary stored in the call context</returns>
+ /// <remarks>
+ /// The <see cref="CallContext"/> method <see cref="CallContext.GetData"/> has a
+ /// security link demand, therfore we must put the method call in a seperate method
+ /// that we can wrap in an exception handler.
+ /// </remarks>
#if NET_4_0 || MONO_4_0 || NETSTANDARD
[System.Security.SecuritySafeCritical]
#endif
private static PropertiesDictionary GetLogicalProperties()
- {
+ {
#if NETSTANDARD
return AsyncLocalDictionary.Value;
#elif NET_2_0 || MONO_2_0 || MONO_3_5 || MONO_4_0
return CallContext.LogicalGetData(c_SlotName) as PropertiesDictionary;
#else
- return CallContext.GetData(c_SlotName) as PropertiesDictionary;
+ return CallContext.GetData(c_SlotName) as PropertiesDictionary;
#endif
- }
+ }
- /// <summary>
- /// Sets the call context data.
- /// </summary>
- /// <param name="properties">The properties.</param>
- /// <remarks>
- /// The <see cref="CallContext"/> method <see cref="CallContext.SetData"/> has a
- /// security link demand, therfore we must put the method call in a seperate method
- /// that we can wrap in an exception handler.
- /// </remarks>
+ /// <summary>
+ /// Sets the call context data.
+ /// </summary>
+ /// <param name="properties">The properties.</param>
+ /// <remarks>
+ /// The <see cref="CallContext"/> method <see cref="CallContext.SetData"/> has a
+ /// security link demand, therfore we must put the method call in a seperate method
+ /// that we can wrap in an exception handler.
+ /// </remarks>
#if NET_4_0 || MONO_4_0 || NETSTANDARD
[System.Security.SecuritySafeCritical]
#endif
private static void SetLogicalProperties(PropertiesDictionary properties)
- {
+ {
#if NETSTANDARD
- AsyncLocalDictionary.Value = properties;
+ AsyncLocalDictionary.Value = properties;
#elif NET_2_0 || MONO_2_0 || MONO_3_5 || MONO_4_0
- CallContext.LogicalSetData(c_SlotName, properties);
+ CallContext.LogicalSetData(c_SlotName, properties);
#else
- CallContext.SetData(c_SlotName, properties);
+ CallContext.SetData(c_SlotName, properties);
#endif
}
#endregion
- #region Private Static Fields
+ #region Private Static Fields
- /// <summary>
- /// The fully qualified type of the LogicalThreadContextProperties class.
- /// </summary>
- /// <remarks>
- /// Used by the internal logger to record the Type of the
- /// log message.
- /// </remarks>
- private static readonly Type declaringType = typeof(LogicalThreadContextProperties);
+ /// <summary>
+ /// The fully qualified type of the LogicalThreadContextProperties class.
+ /// </summary>
+ /// <remarks>
+ /// Used by the internal logger to record the Type of the
+ /// log message.
+ /// </remarks>
+ private static readonly Type declaringType = typeof(LogicalThreadContextProperties);
- #endregion Private Static Fields
+ #endregion Private Static Fields
}
}
diff --git a/src/log4net/Util/LogicalThreadContextStack.cs b/src/log4net/Util/LogicalThreadContextStack.cs
index dbad39a..45993eb 100644
--- a/src/log4net/Util/LogicalThreadContextStack.cs
+++ b/src/log4net/Util/LogicalThreadContextStack.cs
@@ -26,424 +26,424 @@
namespace log4net.Util
{
- /// <summary>
- /// Delegate type used for LogicalThreadContextStack's callbacks.
- /// </summary>
- #if NET_2_0 || MONO_2_0 || NETSTANDARD
- public delegate void TwoArgAction<T1, T2>(T1 t1, T2 t2);
- #else
- public delegate void TwoArgAction(string t1, LogicalThreadContextStack t2);
- #endif
+ /// <summary>
+ /// Delegate type used for LogicalThreadContextStack's callbacks.
+ /// </summary>
+ #if NET_2_0 || MONO_2_0 || NETSTANDARD
+ public delegate void TwoArgAction<T1, T2>(T1 t1, T2 t2);
+ #else
+ public delegate void TwoArgAction(string t1, LogicalThreadContextStack t2);
+ #endif
- /// <summary>
- /// Implementation of Stack for the <see cref="log4net.LogicalThreadContext"/>
- /// </summary>
- /// <remarks>
- /// <para>
- /// Implementation of Stack for the <see cref="log4net.LogicalThreadContext"/>
- /// </para>
- /// </remarks>
- /// <author>Nicko Cadell</author>
- public sealed class LogicalThreadContextStack : IFixingRequired
- {
- #region Private Instance Fields
+ /// <summary>
+ /// Implementation of Stack for the <see cref="log4net.LogicalThreadContext"/>
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Implementation of Stack for the <see cref="log4net.LogicalThreadContext"/>
+ /// </para>
+ /// </remarks>
+ /// <author>Nicko Cadell</author>
+ public sealed class LogicalThreadContextStack : IFixingRequired
+ {
+ #region Private Instance Fields
- /// <summary>
- /// The stack store.
- /// </summary>
- private Stack m_stack = new Stack();
+ /// <summary>
+ /// The stack store.
+ /// </summary>
+ private Stack m_stack = new Stack();
- /// <summary>
- /// The name of this <see cref="log4net.Util.LogicalThreadContextStack"/> within the
- /// <see cref="log4net.Util.LogicalThreadContextProperties"/>.
- /// </summary>
- private string m_propertyKey;
+ /// <summary>
+ /// The name of this <see cref="log4net.Util.LogicalThreadContextStack"/> within the
+ /// <see cref="log4net.Util.LogicalThreadContextProperties"/>.
+ /// </summary>
+ private string m_propertyKey;
- /// <summary>
- /// The callback used to let the <see cref="log4net.Util.LogicalThreadContextStacks"/> register a
- /// new instance of a <see cref="log4net.Util.LogicalThreadContextStack"/>.
- /// </summary>
- #if NET_2_0 || MONO_2_0 || NETSTANDARD
- private TwoArgAction<string, LogicalThreadContextStack> m_registerNew;
- #else
- private TwoArgAction m_registerNew;
- #endif
+ /// <summary>
+ /// The callback used to let the <see cref="log4net.Util.LogicalThreadContextStacks"/> register a
+ /// new instance of a <see cref="log4net.Util.LogicalThreadContextStack"/>.
+ /// </summary>
+ #if NET_2_0 || MONO_2_0 || NETSTANDARD
+ private TwoArgAction<string, LogicalThreadContextStack> m_registerNew;
+ #else
+ private TwoArgAction m_registerNew;
+ #endif
- #endregion Private Instance Fields
+ #endregion Private Instance Fields
- #region Public Instance Constructors
+ #region Public Instance Constructors
- /// <summary>
- /// Internal constructor
- /// </summary>
- /// <remarks>
- /// <para>
- /// Initializes a new instance of the <see cref="LogicalThreadContextStack" /> class.
- /// </para>
- /// </remarks>
- #if NET_2_0 || MONO_2_0 || NETSTANDARD
- internal LogicalThreadContextStack(string propertyKey, TwoArgAction<string, LogicalThreadContextStack> registerNew)
- #else
- internal LogicalThreadContextStack(string propertyKey, TwoArgAction registerNew)
- #endif
- {
- m_propertyKey = propertyKey;
- m_registerNew = registerNew;
- }
+ /// <summary>
+ /// Internal constructor
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Initializes a new instance of the <see cref="LogicalThreadContextStack" /> class.
+ /// </para>
+ /// </remarks>
+ #if NET_2_0 || MONO_2_0 || NETSTANDARD
+ internal LogicalThreadContextStack(string propertyKey, TwoArgAction<string, LogicalThreadContextStack> registerNew)
+ #else
+ internal LogicalThreadContextStack(string propertyKey, TwoArgAction registerNew)
+ #endif
+ {
+ m_propertyKey = propertyKey;
+ m_registerNew = registerNew;
+ }
- #endregion Public Instance Constructors
+ #endregion Public Instance Constructors
- #region Public Properties
+ #region Public Properties
- /// <summary>
- /// The number of messages in the stack
- /// </summary>
- /// <value>
- /// The current number of messages in the stack
- /// </value>
- /// <remarks>
- /// <para>
- /// The current number of messages in the stack. That is
- /// the number of times <see cref="Push"/> has been called
- /// minus the number of times <see cref="Pop"/> has been called.
- /// </para>
- /// </remarks>
- public int Count
- {
- get { return m_stack.Count; }
- }
+ /// <summary>
+ /// The number of messages in the stack
+ /// </summary>
+ /// <value>
+ /// The current number of messages in the stack
+ /// </value>
+ /// <remarks>
+ /// <para>
+ /// The current number of messages in the stack. That is
+ /// the number of times <see cref="Push"/> has been called
+ /// minus the number of times <see cref="Pop"/> has been called.
+ /// </para>
+ /// </remarks>
+ public int Count
+ {
+ get { return m_stack.Count; }
+ }
- #endregion // Public Properties
+ #endregion // Public Properties
- #region Public Methods
+ #region Public Methods
- /// <summary>
- /// Clears all the contextual information held in this stack.
- /// </summary>
- /// <remarks>
- /// <para>
- /// Clears all the contextual information held in this stack.
- /// Only call this if you think that this thread is being reused after
- /// a previous call execution which may not have completed correctly.
- /// You do not need to use this method if you always guarantee to call
- /// the <see cref="IDisposable.Dispose"/> method of the <see cref="IDisposable"/>
- /// returned from <see cref="Push"/> even in exceptional circumstances,
- /// for example by using the <c>using(log4net.LogicalThreadContext.Stacks["NDC"].Push("Stack_Message"))</c>
- /// syntax.
- /// </para>
- /// </remarks>
- public void Clear()
- {
- m_registerNew(m_propertyKey, new LogicalThreadContextStack(m_propertyKey, m_registerNew));
- }
+ /// <summary>
+ /// Clears all the contextual information held in this stack.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Clears all the contextual information held in this stack.
+ /// Only call this if you think that this thread is being reused after
+ /// a previous call execution which may not have completed correctly.
+ /// You do not need to use this method if you always guarantee to call
+ /// the <see cref="IDisposable.Dispose"/> method of the <see cref="IDisposable"/>
+ /// returned from <see cref="Push"/> even in exceptional circumstances,
+ /// for example by using the <c>using(log4net.LogicalThreadContext.Stacks["NDC"].Push("Stack_Message"))</c>
+ /// syntax.
+ /// </para>
+ /// </remarks>
+ public void Clear()
+ {
+ m_registerNew(m_propertyKey, new LogicalThreadContextStack(m_propertyKey, m_registerNew));
+ }
- /// <summary>
- /// Removes the top context from this stack.
- /// </summary>
- /// <returns>The message in the context that was removed from the top of this stack.</returns>
- /// <remarks>
- /// <para>
- /// Remove the top context from this stack, and return
- /// it to the caller. If this stack is empty then an
- /// empty string (not <see langword="null"/>) is returned.
- /// </para>
- /// </remarks>
- public string Pop()
- {
- // copy current stack
- Stack stack = new Stack(new Stack(m_stack));
- string result = "";
- if (stack.Count > 0)
- {
- result = ((StackFrame)(stack.Pop())).Message;
- }
- LogicalThreadContextStack ltcs = new LogicalThreadContextStack(m_propertyKey, m_registerNew);
- ltcs.m_stack = stack;
- m_registerNew(m_propertyKey, ltcs);
- return result;
- }
+ /// <summary>
+ /// Removes the top context from this stack.
+ /// </summary>
+ /// <returns>The message in the context that was removed from the top of this stack.</returns>
+ /// <remarks>
+ /// <para>
+ /// Remove the top context from this stack, and return
+ /// it to the caller. If this stack is empty then an
+ /// empty string (not <see langword="null"/>) is returned.
+ /// </para>
+ /// </remarks>
+ public string Pop()
+ {
+ // copy current stack
+ Stack stack = new Stack(new Stack(m_stack));
+ string result = "";
+ if (stack.Count > 0)
+ {
+ result = ((StackFrame)(stack.Pop())).Message;
+ }
+ LogicalThreadContextStack ltcs = new LogicalThreadContextStack(m_propertyKey, m_registerNew);
+ ltcs.m_stack = stack;
+ m_registerNew(m_propertyKey, ltcs);
+ return result;
+ }
- /// <summary>
- /// Pushes a new context message into this stack.
- /// </summary>
- /// <param name="message">The new context message.</param>
- /// <returns>
- /// An <see cref="IDisposable"/> that can be used to clean up the context stack.
- /// </returns>
- /// <remarks>
- /// <para>
- /// Pushes a new context onto this stack. An <see cref="IDisposable"/>
- /// is returned that can be used to clean up this stack. This
- /// can be easily combined with the <c>using</c> keyword to scope the
- /// context.
- /// </para>
- /// </remarks>
- /// <example>Simple example of using the <c>Push</c> method with the <c>using</c> keyword.
- /// <code lang="C#">
- /// using(log4net.LogicalThreadContext.Stacks["NDC"].Push("Stack_Message"))
- /// {
- /// log.Warn("This should have an ThreadContext Stack message");
- /// }
- /// </code>
- /// </example>
- public IDisposable Push(string message)
- {
- // do modifications on a copy
- Stack stack = new Stack(new Stack(m_stack));
- stack.Push(new StackFrame(message, (stack.Count > 0) ? (StackFrame)stack.Peek() : null));
+ /// <summary>
+ /// Pushes a new context message into this stack.
+ /// </summary>
+ /// <param name="message">The new context message.</param>
+ /// <returns>
+ /// An <see cref="IDisposable"/> that can be used to clean up the context stack.
+ /// </returns>
+ /// <remarks>
+ /// <para>
+ /// Pushes a new context onto this stack. An <see cref="IDisposable"/>
+ /// is returned that can be used to clean up this stack. This
+ /// can be easily combined with the <c>using</c> keyword to scope the
+ /// context.
+ /// </para>
+ /// </remarks>
+ /// <example>Simple example of using the <c>Push</c> method with the <c>using</c> keyword.
+ /// <code lang="C#">
+ /// using(log4net.LogicalThreadContext.Stacks["NDC"].Push("Stack_Message"))
+ /// {
+ /// log.Warn("This should have an ThreadContext Stack message");
+ /// }
+ /// </code>
+ /// </example>
+ public IDisposable Push(string message)
+ {
+ // do modifications on a copy
+ Stack stack = new Stack(new Stack(m_stack));
+ stack.Push(new StackFrame(message, (stack.Count > 0) ? (StackFrame)stack.Peek() : null));
- LogicalThreadContextStack contextStack = new LogicalThreadContextStack(m_propertyKey, m_registerNew);
- contextStack.m_stack = stack;
- m_registerNew(m_propertyKey, contextStack);
- return new AutoPopStackFrame(contextStack, stack.Count - 1);
- }
+ LogicalThreadContextStack contextStack = new LogicalThreadContextStack(m_propertyKey, m_registerNew);
+ contextStack.m_stack = stack;
+ m_registerNew(m_propertyKey, contextStack);
+ return new AutoPopStackFrame(contextStack, stack.Count - 1);
+ }
- /// <summary>
- /// Returns the top context from this stack.
- /// </summary>
- /// <returns>The message in the context from the top of this stack.</returns>
- /// <remarks>
- /// <para>
- /// Returns the top context from this stack. If this stack is empty then an
- /// empty string (not <see langword="null"/>) is returned.
- /// </para>
- /// </remarks>
- public string Peek()
- {
- Stack stack = m_stack;
- if (stack.Count > 0)
- {
- return ((StackFrame)stack.Peek()).Message;
- }
- return "";
- }
+ /// <summary>
+ /// Returns the top context from this stack.
+ /// </summary>
+ /// <returns>The message in the context from the top of this stack.</returns>
+ /// <remarks>
+ /// <para>
+ /// Returns the top context from this stack. If this stack is empty then an
+ /// empty string (not <see langword="null"/>) is returned.
+ /// </para>
+ /// </remarks>
+ public string Peek()
+ {
+ Stack stack = m_stack;
+ if (stack.Count > 0)
+ {
+ return ((StackFrame)stack.Peek()).Message;
+ }
+ return "";
+ }
- #endregion Public Methods
+ #endregion Public Methods
- #region Internal Methods
+ #region Internal Methods
- /// <summary>
- /// Gets the current context information for this stack.
- /// </summary>
- /// <returns>The current context information.</returns>
- internal string GetFullMessage()
- {
- Stack stack = m_stack;
- if (stack.Count > 0)
- {
- return ((StackFrame)(stack.Peek())).FullMessage;
- }
- return null;
- }
+ /// <summary>
+ /// Gets the current context information for this stack.
+ /// </summary>
+ /// <returns>The current context information.</returns>
+ internal string GetFullMessage()
+ {
+ Stack stack = m_stack;
+ if (stack.Count > 0)
+ {
+ return ((StackFrame)(stack.Peek())).FullMessage;
+ }
+ return null;
+ }
- /// <summary>
- /// Gets and sets the internal stack used by this <see cref="LogicalThreadContextStack"/>
- /// </summary>
- /// <value>The internal storage stack</value>
- /// <remarks>
- /// <para>
- /// This property is provided only to support backward compatability
- /// of the <see cref="NDC"/>. Tytpically the internal stack should not
- /// be modified.
- /// </para>
- /// </remarks>
- internal Stack InternalStack
- {
- get { return m_stack; }
- set { m_stack = value; }
- }
+ /// <summary>
+ /// Gets and sets the internal stack used by this <see cref="LogicalThreadContextStack"/>
+ /// </summary>
+ /// <value>The internal storage stack</value>
+ /// <remarks>
+ /// <para>
+ /// This property is provided only to support backward compatability
+ /// of the <see cref="NDC"/>. Tytpically the internal stack should not
+ /// be modified.
+ /// </para>
+ /// </remarks>
+ internal Stack InternalStack
+ {
+ get { return m_stack; }
+ set { m_stack = value; }
+ }
- #endregion Internal Methods
+ #endregion Internal Methods
- /// <summary>
- /// Gets the current context information for this stack.
- /// </summary>
- /// <returns>Gets the current context information</returns>
- /// <remarks>
- /// <para>
- /// Gets the current context information for this stack.
- /// </para>
- /// </remarks>
- public override string ToString()
- {
- return GetFullMessage();
- }
+ /// <summary>
+ /// Gets the current context information for this stack.
+ /// </summary>
+ /// <returns>Gets the current context information</returns>
+ /// <remarks>
+ /// <para>
+ /// Gets the current context information for this stack.
+ /// </para>
+ /// </remarks>
+ public override string ToString()
+ {
+ return GetFullMessage();
+ }
- /// <summary>
- /// Get a portable version of this object
- /// </summary>
- /// <returns>the portable instance of this object</returns>
- /// <remarks>
- /// <para>
- /// Get a cross thread portable version of this object
- /// </para>
- /// </remarks>
- object IFixingRequired.GetFixedObject()
- {
- return GetFullMessage();
- }
+ /// <summary>
+ /// Get a portable version of this object
+ /// </summary>
+ /// <returns>the portable instance of this object</returns>
+ /// <remarks>
+ /// <para>
+ /// Get a cross thread portable version of this object
+ /// </para>
+ /// </remarks>
+ object IFixingRequired.GetFixedObject()
+ {
+ return GetFullMessage();
+ }
- /// <summary>
- /// Inner class used to represent a single context frame in the stack.
- /// </summary>
- /// <remarks>
- /// <para>
- /// Inner class used to represent a single context frame in the stack.
- /// </para>
- /// </remarks>
- private sealed class StackFrame
- {
- #region Private Instance Fields
+ /// <summary>
+ /// Inner class used to represent a single context frame in the stack.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Inner class used to represent a single context frame in the stack.
+ /// </para>
+ /// </remarks>
+ private sealed class StackFrame
+ {
+ #region Private Instance Fields
- private readonly string m_message;
- private readonly StackFrame m_parent;
- private string m_fullMessage = null;
+ private readonly string m_message;
+ private readonly StackFrame m_parent;
+ private string m_fullMessage = null;
- #endregion
+ #endregion
- #region Internal Instance Constructors
+ #region Internal Instance Constructors
- /// <summary>
- /// Constructor
- /// </summary>
- /// <param name="message">The message for this context.</param>
- /// <param name="parent">The parent context in the chain.</param>
- /// <remarks>
- /// <para>
- /// Initializes a new instance of the <see cref="StackFrame" /> class
- /// with the specified message and parent context.
- /// </para>
- /// </remarks>
- internal StackFrame(string message, StackFrame parent)
- {
- m_message = message;
- m_parent = parent;
+ /// <summary>
+ /// Constructor
+ /// </summary>
+ /// <param name="message">The message for this context.</param>
+ /// <param name="parent">The parent context in the chain.</param>
+ /// <remarks>
+ /// <para>
+ /// Initializes a new instance of the <see cref="StackFrame" /> class
+ /// with the specified message and parent context.
+ /// </para>
+ /// </remarks>
+ internal StackFrame(string message, StackFrame parent)
+ {
+ m_message = message;
+ m_parent = parent;
- if (parent == null)
- {
- m_fullMessage = message;
- }
- }
+ if (parent == null)
+ {
+ m_fullMessage = message;
+ }
+ }
- #endregion Internal Instance Constructors
+ #endregion Internal Instance Constructors
- #region Internal Instance Properties
+ #region Internal Instance Properties
- /// <summary>
- /// Get the message.
- /// </summary>
- /// <value>The message.</value>
- /// <remarks>
- /// <para>
- /// Get the message.
- /// </para>
- /// </remarks>
- internal string Message
- {
- get { return m_message; }
- }
+ /// <summary>
+ /// Get the message.
+ /// </summary>
+ /// <value>The message.</value>
+ /// <remarks>
+ /// <para>
+ /// Get the message.
+ /// </para>
+ /// </remarks>
+ internal string Message
+ {
+ get { return m_message; }
+ }
- /// <summary>
- /// Gets the full text of the context down to the root level.
- /// </summary>
- /// <value>
- /// The full text of the context down to the root level.
- /// </value>
- /// <remarks>
- /// <para>
- /// Gets the full text of the context down to the root level.
- /// </para>
- /// </remarks>
- internal string FullMessage
- {
- get
- {
- if (m_fullMessage == null && m_parent != null)
- {
- m_fullMessage = string.Concat(m_parent.FullMessage, " ", m_message);
- }
- return m_fullMessage;
- }
- }
+ /// <summary>
+ /// Gets the full text of the context down to the root level.
+ /// </summary>
+ /// <value>
+ /// The full text of the context down to the root level.
+ /// </value>
+ /// <remarks>
+ /// <para>
+ /// Gets the full text of the context down to the root level.
+ /// </para>
+ /// </remarks>
+ internal string FullMessage
+ {
+ get
+ {
+ if (m_fullMessage == null && m_parent != null)
+ {
+ m_fullMessage = string.Concat(m_parent.FullMessage, " ", m_message);
+ }
+ return m_fullMessage;
+ }
+ }
- #endregion Internal Instance Properties
- }
+ #endregion Internal Instance Properties
+ }
- /// <summary>
- /// Struct returned from the <see cref="LogicalThreadContextStack.Push"/> method.
- /// </summary>
- /// <remarks>
- /// <para>
- /// This struct implements the <see cref="IDisposable"/> and is designed to be used
- /// with the <see langword="using"/> pattern to remove the stack frame at the end of the scope.
- /// </para>
- /// </remarks>
- private struct AutoPopStackFrame : IDisposable
- {
- #region Private Instance Fields
+ /// <summary>
+ /// Struct returned from the <see cref="LogicalThreadContextStack.Push"/> method.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// This struct implements the <see cref="IDisposable"/> and is designed to be used
+ /// with the <see langword="using"/> pattern to remove the stack frame at the end of the scope.
+ /// </para>
+ /// </remarks>
+ private struct AutoPopStackFrame : IDisposable
+ {
+ #region Private Instance Fields
- /// <summary>
- /// The depth to trim the stack to when this instance is disposed
- /// </summary>
- private int m_frameDepth;
+ /// <summary>
+ /// The depth to trim the stack to when this instance is disposed
+ /// </summary>
+ private int m_frameDepth;
- /// <summary>
- /// The outer LogicalThreadContextStack.
- /// </summary>
- private LogicalThreadContextStack m_logicalThreadContextStack;
+ /// <summary>
+ /// The outer LogicalThreadContextStack.
+ /// </summary>
+ private LogicalThreadContextStack m_logicalThreadContextStack;
- #endregion Private Instance Fields
+ #endregion Private Instance Fields
- #region Internal Instance Constructors
+ #region Internal Instance Constructors
- /// <summary>
- /// Constructor
- /// </summary>
- /// <param name="logicalThreadContextStack">The internal stack used by the ThreadContextStack.</param>
- /// <param name="frameDepth">The depth to return the stack to when this object is disposed.</param>
- /// <remarks>
- /// <para>
- /// Initializes a new instance of the <see cref="AutoPopStackFrame" /> class with
- /// the specified stack and return depth.
- /// </para>
- /// </remarks>
- internal AutoPopStackFrame(LogicalThreadContextStack logicalThreadContextStack, int frameDepth)
- {
- m_frameDepth = frameDepth;
- m_logicalThreadContextStack = logicalThreadContextStack;
- }
+ /// <summary>
+ /// Constructor
+ /// </summary>
+ /// <param name="logicalThreadContextStack">The internal stack used by the ThreadContextStack.</param>
+ /// <param name="frameDepth">The depth to return the stack to when this object is disposed.</param>
+ /// <remarks>
+ /// <para>
+ /// Initializes a new instance of the <see cref="AutoPopStackFrame" /> class with
+ /// the specified stack and return depth.
+ /// </para>
+ /// </remarks>
+ internal AutoPopStackFrame(LogicalThreadContextStack logicalThreadContextStack, int frameDepth)
+ {
+ m_frameDepth = frameDepth;
+ m_logicalThreadContextStack = logicalThreadContextStack;
+ }
- #endregion Internal Instance Constructors
+ #endregion Internal Instance Constructors
- #region Implementation of IDisposable
+ #region Implementation of IDisposable
- /// <summary>
- /// Returns the stack to the correct depth.
- /// </summary>
- /// <remarks>
- /// <para>
- /// Returns the stack to the correct depth.
- /// </para>
- /// </remarks>
- public void Dispose()
- {
- if (m_frameDepth >= 0 && m_logicalThreadContextStack.m_stack != null)
- {
- Stack stack = new Stack(new Stack(m_logicalThreadContextStack.m_stack));
- while (stack.Count > m_frameDepth)
- {
- stack.Pop();
- }
- LogicalThreadContextStack ltcs = new LogicalThreadContextStack(m_logicalThreadContextStack.m_propertyKey, m_logicalThreadContextStack.m_registerNew);
- ltcs.m_stack = stack;
- m_logicalThreadContextStack.m_registerNew(m_logicalThreadContextStack.m_propertyKey,
- ltcs);
- }
- }
+ /// <summary>
+ /// Returns the stack to the correct depth.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Returns the stack to the correct depth.
+ /// </para>
+ /// </remarks>
+ public void Dispose()
+ {
+ if (m_frameDepth >= 0 && m_logicalThreadContextStack.m_stack != null)
+ {
+ Stack stack = new Stack(new Stack(m_logicalThreadContextStack.m_stack));
+ while (stack.Count > m_frameDepth)
+ {
+ stack.Pop();
+ }
+ LogicalThreadContextStack ltcs = new LogicalThreadContextStack(m_logicalThreadContextStack.m_propertyKey, m_logicalThreadContextStack.m_registerNew);
+ ltcs.m_stack = stack;
+ m_logicalThreadContextStack.m_registerNew(m_logicalThreadContextStack.m_propertyKey,
+ ltcs);
+ }
+ }
- #endregion Implementation of IDisposable
- }
+ #endregion Implementation of IDisposable
+ }
- }
+ }
}
#endif
\ No newline at end of file
diff --git a/src/log4net/Util/LogicalThreadContextStacks.cs b/src/log4net/Util/LogicalThreadContextStacks.cs
index 7d4a225..6ea5901 100644
--- a/src/log4net/Util/LogicalThreadContextStacks.cs
+++ b/src/log4net/Util/LogicalThreadContextStacks.cs
@@ -22,121 +22,121 @@
namespace log4net.Util
{
- /// <summary>
- /// Implementation of Stacks collection for the <see cref="log4net.LogicalThreadContext"/>
- /// </summary>
- /// <remarks>
- /// <para>
- /// Implementation of Stacks collection for the <see cref="log4net.LogicalThreadContext"/>
- /// </para>
- /// </remarks>
- /// <author>Nicko Cadell</author>
- public sealed class LogicalThreadContextStacks
- {
- private readonly LogicalThreadContextProperties m_properties;
+ /// <summary>
+ /// Implementation of Stacks collection for the <see cref="log4net.LogicalThreadContext"/>
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Implementation of Stacks collection for the <see cref="log4net.LogicalThreadContext"/>
+ /// </para>
+ /// </remarks>
+ /// <author>Nicko Cadell</author>
+ public sealed class LogicalThreadContextStacks
+ {
+ private readonly LogicalThreadContextProperties m_properties;
- #region Public Instance Constructors
+ #region Public Instance Constructors
- /// <summary>
- /// Internal constructor
- /// </summary>
- /// <remarks>
- /// <para>
- /// Initializes a new instance of the <see cref="ThreadContextStacks" /> class.
- /// </para>
- /// </remarks>
- internal LogicalThreadContextStacks(LogicalThreadContextProperties properties)
- {
- m_properties = properties;
- }
+ /// <summary>
+ /// Internal constructor
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Initializes a new instance of the <see cref="ThreadContextStacks" /> class.
+ /// </para>
+ /// </remarks>
+ internal LogicalThreadContextStacks(LogicalThreadContextProperties properties)
+ {
+ m_properties = properties;
+ }
- #endregion Public Instance Constructors
+ #endregion Public Instance Constructors
- #region Public Instance Properties
+ #region Public Instance Properties
- /// <summary>
- /// Gets the named thread context stack
- /// </summary>
- /// <value>
- /// The named stack
- /// </value>
- /// <remarks>
- /// <para>
- /// Gets the named thread context stack
- /// </para>
- /// </remarks>
- public LogicalThreadContextStack this[string key]
- {
- get
- {
- LogicalThreadContextStack stack = null;
+ /// <summary>
+ /// Gets the named thread context stack
+ /// </summary>
+ /// <value>
+ /// The named stack
+ /// </value>
+ /// <remarks>
+ /// <para>
+ /// Gets the named thread context stack
+ /// </para>
+ /// </remarks>
+ public LogicalThreadContextStack this[string key]
+ {
+ get
+ {
+ LogicalThreadContextStack stack = null;
- object propertyValue = m_properties[key];
- if (propertyValue == null)
- {
- // Stack does not exist, create
+ object propertyValue = m_properties[key];
+ if (propertyValue == null)
+ {
+ // Stack does not exist, create
#if NET_2_0 || MONO_2_0 || NETSTANDARD
- stack = new LogicalThreadContextStack(key, registerNew);
+ stack = new LogicalThreadContextStack(key, registerNew);
#else
- stack = new LogicalThreadContextStack(key, new TwoArgAction(registerNew));
+ stack = new LogicalThreadContextStack(key, new TwoArgAction(registerNew));
#endif
- m_properties[key] = stack;
- }
- else
- {
- // Look for existing stack
- stack = propertyValue as LogicalThreadContextStack;
- if (stack == null)
- {
- // Property is not set to a stack!
- string propertyValueString = SystemInfo.NullText;
+ m_properties[key] = stack;
+ }
+ else
+ {
+ // Look for existing stack
+ stack = propertyValue as LogicalThreadContextStack;
+ if (stack == null)
+ {
+ // Property is not set to a stack!
+ string propertyValueString = SystemInfo.NullText;
- try
- {
- propertyValueString = propertyValue.ToString();
- }
- catch
- {
- }
+ try
+ {
+ propertyValueString = propertyValue.ToString();
+ }
+ catch
+ {
+ }
- LogLog.Error(declaringType, "ThreadContextStacks: Request for stack named [" + key + "] failed because a property with the same name exists which is a [" + propertyValue.GetType().Name + "] with value [" + propertyValueString + "]");
+ LogLog.Error(declaringType, "ThreadContextStacks: Request for stack named [" + key + "] failed because a property with the same name exists which is a [" + propertyValue.GetType().Name + "] with value [" + propertyValueString + "]");
#if NET_2_0 || MONO_2_0 || NETSTANDARD
- stack = new LogicalThreadContextStack(key, registerNew);
+ stack = new LogicalThreadContextStack(key, registerNew);
#else
- stack = new LogicalThreadContextStack(key, new TwoArgAction(registerNew));
+ stack = new LogicalThreadContextStack(key, new TwoArgAction(registerNew));
#endif
- }
- }
+ }
+ }
- return stack;
- }
- }
+ return stack;
+ }
+ }
- #endregion Public Instance Properties
+ #endregion Public Instance Properties
- #region Private Instance Fields
+ #region Private Instance Fields
- private void registerNew(string stackName, LogicalThreadContextStack stack)
- {
- m_properties[stackName] = stack;
- }
+ private void registerNew(string stackName, LogicalThreadContextStack stack)
+ {
+ m_properties[stackName] = stack;
+ }
- #endregion Private Instance Fields
+ #endregion Private Instance Fields
- #region Private Static Fields
+ #region Private Static Fields
- /// <summary>
- /// The fully qualified type of the ThreadContextStacks class.
- /// </summary>
- /// <remarks>
- /// Used by the internal logger to record the Type of the
- /// log message.
- /// </remarks>
- private static readonly Type declaringType = typeof(LogicalThreadContextStacks);
+ /// <summary>
+ /// The fully qualified type of the ThreadContextStacks class.
+ /// </summary>
+ /// <remarks>
+ /// Used by the internal logger to record the Type of the
+ /// log message.
+ /// </remarks>
+ private static readonly Type declaringType = typeof(LogicalThreadContextStacks);
- #endregion Private Static Fields
- }
+ #endregion Private Static Fields
+ }
}
#endif
diff --git a/src/log4net/Util/NativeError.cs b/src/log4net/Util/NativeError.cs
index b527c53..a17a40c 100644
--- a/src/log4net/Util/NativeError.cs
+++ b/src/log4net/Util/NativeError.cs
@@ -30,90 +30,90 @@
namespace log4net.Util
{
- /// <summary>
- /// Represents a native error code and message.
- /// </summary>
- /// <remarks>
- /// <para>
- /// Represents a Win32 platform native error.
- /// </para>
- /// </remarks>
- /// <author>Nicko Cadell</author>
- /// <author>Gert Driesen</author>
- public sealed class NativeError
- {
- #region Protected Instance Constructors
+ /// <summary>
+ /// Represents a native error code and message.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Represents a Win32 platform native error.
+ /// </para>
+ /// </remarks>
+ /// <author>Nicko Cadell</author>
+ /// <author>Gert Driesen</author>
+ public sealed class NativeError
+ {
+ #region Protected Instance Constructors
- /// <summary>
- /// Create an instance of the <see cref="NativeError" /> class with the specified
- /// error number and message.
- /// </summary>
- /// <param name="number">The number of the native error.</param>
- /// <param name="message">The message of the native error.</param>
- /// <remarks>
- /// <para>
- /// Create an instance of the <see cref="NativeError" /> class with the specified
- /// error number and message.
- /// </para>
- /// </remarks>
- private NativeError(int number, string message)
- {
- m_number = number;
- m_message = message;
- }
+ /// <summary>
+ /// Create an instance of the <see cref="NativeError" /> class with the specified
+ /// error number and message.
+ /// </summary>
+ /// <param name="number">The number of the native error.</param>
+ /// <param name="message">The message of the native error.</param>
+ /// <remarks>
+ /// <para>
+ /// Create an instance of the <see cref="NativeError" /> class with the specified
+ /// error number and message.
+ /// </para>
+ /// </remarks>
+ private NativeError(int number, string message)
+ {
+ m_number = number;
+ m_message = message;
+ }
- #endregion // Protected Instance Constructors
+ #endregion // Protected Instance Constructors
- #region Public Instance Properties
+ #region Public Instance Properties
- /// <summary>
- /// Gets the number of the native error.
- /// </summary>
- /// <value>
- /// The number of the native error.
- /// </value>
- /// <remarks>
- /// <para>
- /// Gets the number of the native error.
- /// </para>
- /// </remarks>
- public int Number
- {
- get { return m_number; }
- }
+ /// <summary>
+ /// Gets the number of the native error.
+ /// </summary>
+ /// <value>
+ /// The number of the native error.
+ /// </value>
+ /// <remarks>
+ /// <para>
+ /// Gets the number of the native error.
+ /// </para>
+ /// </remarks>
+ public int Number
+ {
+ get { return m_number; }
+ }
- /// <summary>
- /// Gets the message of the native error.
- /// </summary>
- /// <value>
- /// The message of the native error.
- /// </value>
- /// <remarks>
- /// <para>
- /// </para>
- /// Gets the message of the native error.
- /// </remarks>
- public string Message
- {
- get { return m_message; }
- }
+ /// <summary>
+ /// Gets the message of the native error.
+ /// </summary>
+ /// <value>
+ /// The message of the native error.
+ /// </value>
+ /// <remarks>
+ /// <para>
+ /// </para>
+ /// Gets the message of the native error.
+ /// </remarks>
+ public string Message
+ {
+ get { return m_message; }
+ }
- #endregion // Public Instance Properties
+ #endregion // Public Instance Properties
- #region Public Static Methods
+ #region Public Static Methods
- /// <summary>
- /// Create a new instance of the <see cref="NativeError" /> class for the last Windows error.
- /// </summary>
- /// <returns>
- /// An instance of the <see cref="NativeError" /> class for the last windows error.
- /// </returns>
- /// <remarks>
- /// <para>
- /// The message for the <see cref="Marshal.GetLastWin32Error"/> error number is lookup up using the
- /// native Win32 <c>FormatMessage</c> function.
- /// </para>
- /// </remarks>
+ /// <summary>
+ /// Create a new instance of the <see cref="NativeError" /> class for the last Windows error.
+ /// </summary>
+ /// <returns>
+ /// An instance of the <see cref="NativeError" /> class for the last windows error.
+ /// </returns>
+ /// <remarks>
+ /// <para>
+ /// The message for the <see cref="Marshal.GetLastWin32Error"/> error number is lookup up using the
+ /// native Win32 <c>FormatMessage</c> function.
+ /// </para>
+ /// </remarks>
#if NET_4_0 || MONO_4_0 || NETSTANDARD
[System.Security.SecuritySafeCritical]
#endif
@@ -121,43 +121,43 @@
[System.Security.Permissions.SecurityPermission(System.Security.Permissions.SecurityAction.Demand, UnmanagedCode = true)]
#endif
public static NativeError GetLastError()
- {
- int number = Marshal.GetLastWin32Error();
- return new NativeError(number, NativeError.GetErrorMessage(number));
- }
+ {
+ int number = Marshal.GetLastWin32Error();
+ return new NativeError(number, NativeError.GetErrorMessage(number));
+ }
- /// <summary>
- /// Create a new instance of the <see cref="NativeError" /> class.
- /// </summary>
- /// <param name="number">the error number for the native error</param>
- /// <returns>
- /// An instance of the <see cref="NativeError" /> class for the specified
- /// error number.
- /// </returns>
- /// <remarks>
- /// <para>
- /// The message for the specified error number is lookup up using the
- /// native Win32 <c>FormatMessage</c> function.
- /// </para>
- /// </remarks>
- public static NativeError GetError(int number)
- {
- return new NativeError(number, NativeError.GetErrorMessage(number));
- }
+ /// <summary>
+ /// Create a new instance of the <see cref="NativeError" /> class.
+ /// </summary>
+ /// <param name="number">the error number for the native error</param>
+ /// <returns>
+ /// An instance of the <see cref="NativeError" /> class for the specified
+ /// error number.
+ /// </returns>
+ /// <remarks>
+ /// <para>
+ /// The message for the specified error number is lookup up using the
+ /// native Win32 <c>FormatMessage</c> function.
+ /// </para>
+ /// </remarks>
+ public static NativeError GetError(int number)
+ {
+ return new NativeError(number, NativeError.GetErrorMessage(number));
+ }
- /// <summary>
- /// Retrieves the message corresponding with a Win32 message identifier.
- /// </summary>
- /// <param name="messageId">Message identifier for the requested message.</param>
- /// <returns>
- /// The message corresponding with the specified message identifier.
- /// </returns>
- /// <remarks>
- /// <para>
- /// The message will be searched for in system message-table resource(s)
- /// using the native <c>FormatMessage</c> function.
- /// </para>
- /// </remarks>
+ /// <summary>
+ /// Retrieves the message corresponding with a Win32 message identifier.
+ /// </summary>
+ /// <param name="messageId">Message identifier for the requested message.</param>
+ /// <returns>
+ /// The message corresponding with the specified message identifier.
+ /// </returns>
+ /// <remarks>
+ /// <para>
+ /// The message will be searched for in system message-table resource(s)
+ /// using the native <c>FormatMessage</c> function.
+ /// </para>
+ /// </remarks>
#if NET_4_0 || MONO_4_0 || NETSTANDARD
[System.Security.SecuritySafeCritical]
#endif
@@ -165,126 +165,126 @@
[System.Security.Permissions.SecurityPermission(System.Security.Permissions.SecurityAction.Demand, UnmanagedCode = true)]
#endif
public static string GetErrorMessage(int messageId)
- {
- // Win32 constants
- int FORMAT_MESSAGE_ALLOCATE_BUFFER = 0x00000100; // The function should allocates a buffer large enough to hold the formatted message
- int FORMAT_MESSAGE_IGNORE_INSERTS = 0x00000200; // Insert sequences in the message definition are to be ignored
- int FORMAT_MESSAGE_FROM_SYSTEM = 0x00001000; // The function should search the system message-table resource(s) for the requested message
+ {
+ // Win32 constants
+ int FORMAT_MESSAGE_ALLOCATE_BUFFER = 0x00000100; // The function should allocates a buffer large enough to hold the formatted message
+ int FORMAT_MESSAGE_IGNORE_INSERTS = 0x00000200; // Insert sequences in the message definition are to be ignored
+ int FORMAT_MESSAGE_FROM_SYSTEM = 0x00001000; // The function should search the system message-table resource(s) for the requested message
- string msgBuf = ""; // buffer that will receive the message
- IntPtr sourcePtr = new IntPtr(); // Location of the message definition, will be ignored
- IntPtr argumentsPtr = new IntPtr(); // Pointer to array of values to insert, not supported as it requires unsafe code
+ string msgBuf = ""; // buffer that will receive the message
+ IntPtr sourcePtr = new IntPtr(); // Location of the message definition, will be ignored
+ IntPtr argumentsPtr = new IntPtr(); // Pointer to array of values to insert, not supported as it requires unsafe code
- if (messageId != 0)
- {
- // If the function succeeds, the return value is the number of TCHARs stored in the output buffer, excluding the terminating null character
- int messageSize = FormatMessage(
- FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
- ref sourcePtr,
- messageId,
- 0,
- ref msgBuf,
- 255,
- argumentsPtr);
+ if (messageId != 0)
+ {
+ // If the function succeeds, the return value is the number of TCHARs stored in the output buffer, excluding the terminating null character
+ int messageSize = FormatMessage(
+ FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
+ ref sourcePtr,
+ messageId,
+ 0,
+ ref msgBuf,
+ 255,
+ argumentsPtr);
- if (messageSize > 0)
- {
- // Remove trailing null-terminating characters (\r\n) from the message
- msgBuf = msgBuf.TrimEnd(new char[] {'\r', '\n'});
- }
- else
- {
- // A message could not be located.
- msgBuf = null;
- }
- }
- else
- {
- msgBuf = null;
- }
+ if (messageSize > 0)
+ {
+ // Remove trailing null-terminating characters (\r\n) from the message
+ msgBuf = msgBuf.TrimEnd(new char[] {'\r', '\n'});
+ }
+ else
+ {
+ // A message could not be located.
+ msgBuf = null;
+ }
+ }
+ else
+ {
+ msgBuf = null;
+ }
- return msgBuf;
- }
+ return msgBuf;
+ }
- #endregion // Public Static Methods
+ #endregion // Public Static Methods
- #region Override Object Implementation
+ #region Override Object Implementation
- /// <summary>
- /// Return error information string
- /// </summary>
- /// <returns>error information string</returns>
- /// <remarks>
- /// <para>
- /// Return error information string
- /// </para>
- /// </remarks>
- public override string ToString()
- {
- return string.Format(CultureInfo.InvariantCulture, "0x{0:x8}", this.Number) + (this.Message != null ? ": " + this.Message : "");
- }
+ /// <summary>
+ /// Return error information string
+ /// </summary>
+ /// <returns>error information string</returns>
+ /// <remarks>
+ /// <para>
+ /// Return error information string
+ /// </para>
+ /// </remarks>
+ public override string ToString()
+ {
+ return string.Format(CultureInfo.InvariantCulture, "0x{0:x8}", this.Number) + (this.Message != null ? ": " + this.Message : "");
+ }
- #endregion // Override Object Implementation
+ #endregion // Override Object Implementation
- #region Stubs For Native Function Calls
+ #region Stubs For Native Function Calls
- /// <summary>
- /// Formats a message string.
- /// </summary>
- /// <param name="dwFlags">Formatting options, and how to interpret the <paramref name="lpSource" /> parameter.</param>
- /// <param name="lpSource">Location of the message definition.</param>
- /// <param name="dwMessageId">Message identifier for the requested message.</param>
- /// <param name="dwLanguageId">Language identifier for the requested message.</param>
- /// <param name="lpBuffer">If <paramref name="dwFlags" /> includes FORMAT_MESSAGE_ALLOCATE_BUFFER, the function allocates a buffer using the <c>LocalAlloc</c> function, and places the pointer to the buffer at the address specified in <paramref name="lpBuffer" />.</param>
- /// <param name="nSize">If the FORMAT_MESSAGE_ALLOCATE_BUFFER flag is not set, this parameter specifies the maximum number of TCHARs that can be stored in the output buffer. If FORMAT_MESSAGE_ALLOCATE_BUFFER is set, this parameter specifies the minimum number of TCHARs to allocate for an output buffer.</param>
- /// <param name="Arguments">Pointer to an array of values that are used as insert values in the formatted message.</param>
- /// <remarks>
- /// <para>
- /// The function requires a message definition as input. The message definition can come from a
- /// buffer passed into the function. It can come from a message table resource in an
- /// already-loaded module. Or the caller can ask the function to search the system's message
- /// table resource(s) for the message definition. The function finds the message definition
- /// in a message table resource based on a message identifier and a language identifier.
- /// The function copies the formatted message text to an output buffer, processing any embedded
- /// insert sequences if requested.
- /// </para>
- /// <para>
- /// To prevent the usage of unsafe code, this stub does not support inserting values in the formatted message.
- /// </para>
- /// </remarks>
- /// <returns>
- /// <para>
- /// If the function succeeds, the return value is the number of TCHARs stored in the output
- /// buffer, excluding the terminating null character.
- /// </para>
- /// <para>
- /// If the function fails, the return value is zero. To get extended error information,
- /// call <see cref="M:Marshal.GetLastWin32Error()" />.
- /// </para>
- /// </returns>
+ /// <summary>
+ /// Formats a message string.
+ /// </summary>
+ /// <param name="dwFlags">Formatting options, and how to interpret the <paramref name="lpSource" /> parameter.</param>
+ /// <param name="lpSource">Location of the message definition.</param>
+ /// <param name="dwMessageId">Message identifier for the requested message.</param>
+ /// <param name="dwLanguageId">Language identifier for the requested message.</param>
+ /// <param name="lpBuffer">If <paramref name="dwFlags" /> includes FORMAT_MESSAGE_ALLOCATE_BUFFER, the function allocates a buffer using the <c>LocalAlloc</c> function, and places the pointer to the buffer at the address specified in <paramref name="lpBuffer" />.</param>
+ /// <param name="nSize">If the FORMAT_MESSAGE_ALLOCATE_BUFFER flag is not set, this parameter specifies the maximum number of TCHARs that can be stored in the output buffer. If FORMAT_MESSAGE_ALLOCATE_BUFFER is set, this parameter specifies the minimum number of TCHARs to allocate for an output buffer.</param>
+ /// <param name="Arguments">Pointer to an array of values that are used as insert values in the formatted message.</param>
+ /// <remarks>
+ /// <para>
+ /// The function requires a message definition as input. The message definition can come from a
+ /// buffer passed into the function. It can come from a message table resource in an
+ /// already-loaded module. Or the caller can ask the function to search the system's message
+ /// table resource(s) for the message definition. The function finds the message definition
+ /// in a message table resource based on a message identifier and a language identifier.
+ /// The function copies the formatted message text to an output buffer, processing any embedded
+ /// insert sequences if requested.
+ /// </para>
+ /// <para>
+ /// To prevent the usage of unsafe code, this stub does not support inserting values in the formatted message.
+ /// </para>
+ /// </remarks>
+ /// <returns>
+ /// <para>
+ /// If the function succeeds, the return value is the number of TCHARs stored in the output
+ /// buffer, excluding the terminating null character.
+ /// </para>
+ /// <para>
+ /// If the function fails, the return value is zero. To get extended error information,
+ /// call <see cref="M:Marshal.GetLastWin32Error()" />.
+ /// </para>
+ /// </returns>
#if NETCF || NETSTANDARD
- [DllImport("CoreDll.dll", SetLastError=true, CharSet=CharSet.Unicode)]
+ [DllImport("CoreDll.dll", SetLastError=true, CharSet=CharSet.Unicode)]
#else
- [DllImport("Kernel32.dll", SetLastError=true, CharSet=CharSet.Auto)]
+ [DllImport("Kernel32.dll", SetLastError=true, CharSet=CharSet.Auto)]
#endif
- private static extern int FormatMessage(
- int dwFlags,
- ref IntPtr lpSource,
- int dwMessageId,
- int dwLanguageId,
- ref String lpBuffer,
- int nSize,
- IntPtr Arguments);
+ private static extern int FormatMessage(
+ int dwFlags,
+ ref IntPtr lpSource,
+ int dwMessageId,
+ int dwLanguageId,
+ ref String lpBuffer,
+ int nSize,
+ IntPtr Arguments);
- #endregion // Stubs For Native Function Calls
+ #endregion // Stubs For Native Function Calls
- #region Private Instance Fields
+ #region Private Instance Fields
- private int m_number;
- private string m_message;
+ private int m_number;
+ private string m_message;
- #endregion
- }
+ #endregion
+ }
}
#endif // !CLI_1_0
diff --git a/src/log4net/Util/NullDictionaryEnumerator.cs b/src/log4net/Util/NullDictionaryEnumerator.cs
index 48af424..53d1526 100644
--- a/src/log4net/Util/NullDictionaryEnumerator.cs
+++ b/src/log4net/Util/NullDictionaryEnumerator.cs
@@ -22,181 +22,181 @@
namespace log4net.Util
{
- /// <summary>
- /// An always empty <see cref="IDictionaryEnumerator"/>.
- /// </summary>
- /// <remarks>
- /// <para>
- /// A singleton implementation of the <see cref="IDictionaryEnumerator"/> over a collection
- /// that is empty and not modifiable.
- /// </para>
- /// </remarks>
- /// <author>Nicko Cadell</author>
- /// <author>Gert Driesen</author>
- public sealed class NullDictionaryEnumerator : IDictionaryEnumerator
- {
- #region Private Instance Constructors
+ /// <summary>
+ /// An always empty <see cref="IDictionaryEnumerator"/>.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// A singleton implementation of the <see cref="IDictionaryEnumerator"/> over a collection
+ /// that is empty and not modifiable.
+ /// </para>
+ /// </remarks>
+ /// <author>Nicko Cadell</author>
+ /// <author>Gert Driesen</author>
+ public sealed class NullDictionaryEnumerator : IDictionaryEnumerator
+ {
+ #region Private Instance Constructors
- /// <summary>
- /// Initializes a new instance of the <see cref="NullDictionaryEnumerator" /> class.
- /// </summary>
- /// <remarks>
- /// <para>
- /// Uses a private access modifier to enforce the singleton pattern.
- /// </para>
- /// </remarks>
- private NullDictionaryEnumerator()
- {
- }
+ /// <summary>
+ /// Initializes a new instance of the <see cref="NullDictionaryEnumerator" /> class.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Uses a private access modifier to enforce the singleton pattern.
+ /// </para>
+ /// </remarks>
+ private NullDictionaryEnumerator()
+ {
+ }
- #endregion Private Instance Constructors
+ #endregion Private Instance Constructors
- #region Public Static Properties
+ #region Public Static Properties
- /// <summary>
- /// Gets the singleton instance of the <see cref="NullDictionaryEnumerator" />.
- /// </summary>
- /// <returns>The singleton instance of the <see cref="NullDictionaryEnumerator" />.</returns>
- /// <remarks>
- /// <para>
- /// Gets the singleton instance of the <see cref="NullDictionaryEnumerator" />.
- /// </para>
- /// </remarks>
- public static NullDictionaryEnumerator Instance
- {
- get { return s_instance; }
- }
+ /// <summary>
+ /// Gets the singleton instance of the <see cref="NullDictionaryEnumerator" />.
+ /// </summary>
+ /// <returns>The singleton instance of the <see cref="NullDictionaryEnumerator" />.</returns>
+ /// <remarks>
+ /// <para>
+ /// Gets the singleton instance of the <see cref="NullDictionaryEnumerator" />.
+ /// </para>
+ /// </remarks>
+ public static NullDictionaryEnumerator Instance
+ {
+ get { return s_instance; }
+ }
- #endregion Public Static Properties
+ #endregion Public Static Properties
- #region Implementation of IEnumerator
+ #region Implementation of IEnumerator
- /// <summary>
- /// Gets the current object from the enumerator.
- /// </summary>
- /// <remarks>
- /// Throws an <see cref="InvalidOperationException" /> because the
- /// <see cref="NullDictionaryEnumerator" /> never has a current value.
- /// </remarks>
- /// <remarks>
- /// <para>
- /// As the enumerator is over an empty collection its <see cref="Current"/>
- /// value cannot be moved over a valid position, therefore <see cref="Current"/>
- /// will throw an <see cref="InvalidOperationException"/>.
- /// </para>
- /// </remarks>
- /// <exception cref="InvalidOperationException">The collection is empty and <see cref="Current"/>
- /// cannot be positioned over a valid location.</exception>
- public object Current
- {
- get { throw new InvalidOperationException(); }
- }
+ /// <summary>
+ /// Gets the current object from the enumerator.
+ /// </summary>
+ /// <remarks>
+ /// Throws an <see cref="InvalidOperationException" /> because the
+ /// <see cref="NullDictionaryEnumerator" /> never has a current value.
+ /// </remarks>
+ /// <remarks>
+ /// <para>
+ /// As the enumerator is over an empty collection its <see cref="Current"/>
+ /// value cannot be moved over a valid position, therefore <see cref="Current"/>
+ /// will throw an <see cref="InvalidOperationException"/>.
+ /// </para>
+ /// </remarks>
+ /// <exception cref="InvalidOperationException">The collection is empty and <see cref="Current"/>
+ /// cannot be positioned over a valid location.</exception>
+ public object Current
+ {
+ get { throw new InvalidOperationException(); }
+ }
- /// <summary>
- /// Test if the enumerator can advance, if so advance.
- /// </summary>
- /// <returns><c>false</c> as the <see cref="NullDictionaryEnumerator" /> cannot advance.</returns>
- /// <remarks>
- /// <para>
- /// As the enumerator is over an empty collection its <see cref="Current"/>
- /// value cannot be moved over a valid position, therefore <see cref="MoveNext"/>
- /// will always return <c>false</c>.
- /// </para>
- /// </remarks>
- public bool MoveNext()
- {
- return false;
- }
+ /// <summary>
+ /// Test if the enumerator can advance, if so advance.
+ /// </summary>
+ /// <returns><c>false</c> as the <see cref="NullDictionaryEnumerator" /> cannot advance.</returns>
+ /// <remarks>
+ /// <para>
+ /// As the enumerator is over an empty collection its <see cref="Current"/>
+ /// value cannot be moved over a valid position, therefore <see cref="MoveNext"/>
+ /// will always return <c>false</c>.
+ /// </para>
+ /// </remarks>
+ public bool MoveNext()
+ {
+ return false;
+ }
- /// <summary>
- /// Resets the enumerator back to the start.
- /// </summary>
- /// <remarks>
- /// <para>
- /// As the enumerator is over an empty collection <see cref="Reset"/> does nothing.
- /// </para>
- /// </remarks>
- public void Reset()
- {
- }
+ /// <summary>
+ /// Resets the enumerator back to the start.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// As the enumerator is over an empty collection <see cref="Reset"/> does nothing.
+ /// </para>
+ /// </remarks>
+ public void Reset()
+ {
+ }
- #endregion Implementation of IEnumerator
+ #endregion Implementation of IEnumerator
- #region Implementation of IDictionaryEnumerator
+ #region Implementation of IDictionaryEnumerator
- /// <summary>
- /// Gets the current key from the enumerator.
- /// </summary>
- /// <remarks>
- /// Throws an exception because the <see cref="NullDictionaryEnumerator" />
- /// never has a current value.
- /// </remarks>
- /// <remarks>
- /// <para>
- /// As the enumerator is over an empty collection its <see cref="Current"/>
- /// value cannot be moved over a valid position, therefore <see cref="Key"/>
- /// will throw an <see cref="InvalidOperationException"/>.
- /// </para>
- /// </remarks>
- /// <exception cref="InvalidOperationException">The collection is empty and <see cref="Current"/>
- /// cannot be positioned over a valid location.</exception>
- public object Key
- {
- get { throw new InvalidOperationException(); }
- }
+ /// <summary>
+ /// Gets the current key from the enumerator.
+ /// </summary>
+ /// <remarks>
+ /// Throws an exception because the <see cref="NullDictionaryEnumerator" />
+ /// never has a current value.
+ /// </remarks>
+ /// <remarks>
+ /// <para>
+ /// As the enumerator is over an empty collection its <see cref="Current"/>
+ /// value cannot be moved over a valid position, therefore <see cref="Key"/>
+ /// will throw an <see cref="InvalidOperationException"/>.
+ /// </para>
+ /// </remarks>
+ /// <exception cref="InvalidOperationException">The collection is empty and <see cref="Current"/>
+ /// cannot be positioned over a valid location.</exception>
+ public object Key
+ {
+ get { throw new InvalidOperationException(); }
+ }
- /// <summary>
- /// Gets the current value from the enumerator.
- /// </summary>
- /// <value>The current value from the enumerator.</value>
- /// <remarks>
- /// Throws an <see cref="InvalidOperationException" /> because the
- /// <see cref="NullDictionaryEnumerator" /> never has a current value.
- /// </remarks>
- /// <remarks>
- /// <para>
- /// As the enumerator is over an empty collection its <see cref="Current"/>
- /// value cannot be moved over a valid position, therefore <see cref="Value"/>
- /// will throw an <see cref="InvalidOperationException"/>.
- /// </para>
- /// </remarks>
- /// <exception cref="InvalidOperationException">The collection is empty and <see cref="Current"/>
- /// cannot be positioned over a valid location.</exception>
- public object Value
- {
- get { throw new InvalidOperationException(); }
- }
+ /// <summary>
+ /// Gets the current value from the enumerator.
+ /// </summary>
+ /// <value>The current value from the enumerator.</value>
+ /// <remarks>
+ /// Throws an <see cref="InvalidOperationException" /> because the
+ /// <see cref="NullDictionaryEnumerator" /> never has a current value.
+ /// </remarks>
+ /// <remarks>
+ /// <para>
+ /// As the enumerator is over an empty collection its <see cref="Current"/>
+ /// value cannot be moved over a valid position, therefore <see cref="Value"/>
+ /// will throw an <see cref="InvalidOperationException"/>.
+ /// </para>
+ /// </remarks>
+ /// <exception cref="InvalidOperationException">The collection is empty and <see cref="Current"/>
+ /// cannot be positioned over a valid location.</exception>
+ public object Value
+ {
+ get { throw new InvalidOperationException(); }
+ }
- /// <summary>
- /// Gets the current entry from the enumerator.
- /// </summary>
- /// <remarks>
- /// Throws an <see cref="InvalidOperationException" /> because the
- /// <see cref="NullDictionaryEnumerator" /> never has a current entry.
- /// </remarks>
- /// <remarks>
- /// <para>
- /// As the enumerator is over an empty collection its <see cref="Current"/>
- /// value cannot be moved over a valid position, therefore <see cref="Entry"/>
- /// will throw an <see cref="InvalidOperationException"/>.
- /// </para>
- /// </remarks>
- /// <exception cref="InvalidOperationException">The collection is empty and <see cref="Current"/>
- /// cannot be positioned over a valid location.</exception>
- public DictionaryEntry Entry
- {
- get { throw new InvalidOperationException(); }
- }
+ /// <summary>
+ /// Gets the current entry from the enumerator.
+ /// </summary>
+ /// <remarks>
+ /// Throws an <see cref="InvalidOperationException" /> because the
+ /// <see cref="NullDictionaryEnumerator" /> never has a current entry.
+ /// </remarks>
+ /// <remarks>
+ /// <para>
+ /// As the enumerator is over an empty collection its <see cref="Current"/>
+ /// value cannot be moved over a valid position, therefore <see cref="Entry"/>
+ /// will throw an <see cref="InvalidOperationException"/>.
+ /// </para>
+ /// </remarks>
+ /// <exception cref="InvalidOperationException">The collection is empty and <see cref="Current"/>
+ /// cannot be positioned over a valid location.</exception>
+ public DictionaryEntry Entry
+ {
+ get { throw new InvalidOperationException(); }
+ }
- #endregion Implementation of IDictionaryEnumerator
+ #endregion Implementation of IDictionaryEnumerator
- #region Private Static Fields
+ #region Private Static Fields
- /// <summary>
- /// The singleton instance of the <see cref="NullDictionaryEnumerator" />.
- /// </summary>
- private static readonly NullDictionaryEnumerator s_instance = new NullDictionaryEnumerator();
+ /// <summary>
+ /// The singleton instance of the <see cref="NullDictionaryEnumerator" />.
+ /// </summary>
+ private static readonly NullDictionaryEnumerator s_instance = new NullDictionaryEnumerator();
- #endregion Private Static Fields
- }
+ #endregion Private Static Fields
+ }
}
diff --git a/src/log4net/Util/NullEnumerator.cs b/src/log4net/Util/NullEnumerator.cs
index 4cb7806..05351f2 100644
--- a/src/log4net/Util/NullEnumerator.cs
+++ b/src/log4net/Util/NullEnumerator.cs
@@ -22,113 +22,113 @@
namespace log4net.Util
{
- /// <summary>
- /// An always empty <see cref="IEnumerator"/>.
- /// </summary>
- /// <remarks>
- /// <para>
- /// A singleton implementation of the <see cref="IEnumerator"/> over a collection
- /// that is empty and not modifiable.
- /// </para>
- /// </remarks>
- /// <author>Nicko Cadell</author>
- /// <author>Gert Driesen</author>
- public sealed class NullEnumerator : IEnumerator
- {
- #region Private Instance Constructors
+ /// <summary>
+ /// An always empty <see cref="IEnumerator"/>.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// A singleton implementation of the <see cref="IEnumerator"/> over a collection
+ /// that is empty and not modifiable.
+ /// </para>
+ /// </remarks>
+ /// <author>Nicko Cadell</author>
+ /// <author>Gert Driesen</author>
+ public sealed class NullEnumerator : IEnumerator
+ {
+ #region Private Instance Constructors
- /// <summary>
- /// Initializes a new instance of the <see cref="NullEnumerator" /> class.
- /// </summary>
- /// <remarks>
- /// <para>
- /// Uses a private access modifier to enforce the singleton pattern.
- /// </para>
- /// </remarks>
- private NullEnumerator()
- {
- }
+ /// <summary>
+ /// Initializes a new instance of the <see cref="NullEnumerator" /> class.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Uses a private access modifier to enforce the singleton pattern.
+ /// </para>
+ /// </remarks>
+ private NullEnumerator()
+ {
+ }
- #endregion Private Instance Constructors
+ #endregion Private Instance Constructors
- #region Public Static Properties
+ #region Public Static Properties
- /// <summary>
- /// Get the singleton instance of the <see cref="NullEnumerator" />.
- /// </summary>
- /// <returns>The singleton instance of the <see cref="NullEnumerator" />.</returns>
- /// <remarks>
- /// <para>
- /// Gets the singleton instance of the <see cref="NullEnumerator" />.
- /// </para>
- /// </remarks>
- public static NullEnumerator Instance
- {
- get { return s_instance; }
- }
+ /// <summary>
+ /// Get the singleton instance of the <see cref="NullEnumerator" />.
+ /// </summary>
+ /// <returns>The singleton instance of the <see cref="NullEnumerator" />.</returns>
+ /// <remarks>
+ /// <para>
+ /// Gets the singleton instance of the <see cref="NullEnumerator" />.
+ /// </para>
+ /// </remarks>
+ public static NullEnumerator Instance
+ {
+ get { return s_instance; }
+ }
- #endregion Public Static Properties
+ #endregion Public Static Properties
- #region Implementation of IEnumerator
+ #region Implementation of IEnumerator
- /// <summary>
- /// Gets the current object from the enumerator.
- /// </summary>
- /// <remarks>
- /// Throws an <see cref="InvalidOperationException" /> because the
- /// <see cref="NullDictionaryEnumerator" /> never has a current value.
- /// </remarks>
- /// <remarks>
- /// <para>
- /// As the enumerator is over an empty collection its <see cref="Current"/>
- /// value cannot be moved over a valid position, therefore <see cref="Current"/>
- /// will throw an <see cref="InvalidOperationException"/>.
- /// </para>
- /// </remarks>
- /// <exception cref="InvalidOperationException">The collection is empty and <see cref="Current"/>
- /// cannot be positioned over a valid location.</exception>
- public object Current
- {
- get { throw new InvalidOperationException(); }
- }
+ /// <summary>
+ /// Gets the current object from the enumerator.
+ /// </summary>
+ /// <remarks>
+ /// Throws an <see cref="InvalidOperationException" /> because the
+ /// <see cref="NullDictionaryEnumerator" /> never has a current value.
+ /// </remarks>
+ /// <remarks>
+ /// <para>
+ /// As the enumerator is over an empty collection its <see cref="Current"/>
+ /// value cannot be moved over a valid position, therefore <see cref="Current"/>
+ /// will throw an <see cref="InvalidOperationException"/>.
+ /// </para>
+ /// </remarks>
+ /// <exception cref="InvalidOperationException">The collection is empty and <see cref="Current"/>
+ /// cannot be positioned over a valid location.</exception>
+ public object Current
+ {
+ get { throw new InvalidOperationException(); }
+ }
- /// <summary>
- /// Test if the enumerator can advance, if so advance
- /// </summary>
- /// <returns><c>false</c> as the <see cref="NullEnumerator" /> cannot advance.</returns>
- /// <remarks>
- /// <para>
- /// As the enumerator is over an empty collection its <see cref="Current"/>
- /// value cannot be moved over a valid position, therefore <see cref="MoveNext"/>
- /// will always return <c>false</c>.
- /// </para>
- /// </remarks>
- public bool MoveNext()
- {
- return false;
- }
+ /// <summary>
+ /// Test if the enumerator can advance, if so advance
+ /// </summary>
+ /// <returns><c>false</c> as the <see cref="NullEnumerator" /> cannot advance.</returns>
+ /// <remarks>
+ /// <para>
+ /// As the enumerator is over an empty collection its <see cref="Current"/>
+ /// value cannot be moved over a valid position, therefore <see cref="MoveNext"/>
+ /// will always return <c>false</c>.
+ /// </para>
+ /// </remarks>
+ public bool MoveNext()
+ {
+ return false;
+ }
- /// <summary>
- /// Resets the enumerator back to the start.
- /// </summary>
- /// <remarks>
- /// <para>
- /// As the enumerator is over an empty collection <see cref="Reset"/> does nothing.
- /// </para>
- /// </remarks>
- public void Reset()
- {
- }
+ /// <summary>
+ /// Resets the enumerator back to the start.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// As the enumerator is over an empty collection <see cref="Reset"/> does nothing.
+ /// </para>
+ /// </remarks>
+ public void Reset()
+ {
+ }
- #endregion Implementation of IEnumerator
+ #endregion Implementation of IEnumerator
- #region Private Static Fields
+ #region Private Static Fields
- /// <summary>
- /// The singleton instance of the <see cref="NullEnumerator" />.
- /// </summary>
- private static readonly NullEnumerator s_instance = new NullEnumerator();
+ /// <summary>
+ /// The singleton instance of the <see cref="NullEnumerator" />.
+ /// </summary>
+ private static readonly NullEnumerator s_instance = new NullEnumerator();
- #endregion Private Static Fields
- }
+ #endregion Private Static Fields
+ }
}
diff --git a/src/log4net/Util/NullSecurityContext.cs b/src/log4net/Util/NullSecurityContext.cs
index 3196d1d..d01d7d3 100644
--- a/src/log4net/Util/NullSecurityContext.cs
+++ b/src/log4net/Util/NullSecurityContext.cs
@@ -23,54 +23,54 @@
namespace log4net.Util
{
- /// <summary>
- /// A SecurityContext used when a SecurityContext is not required
- /// </summary>
- /// <remarks>
- /// <para>
- /// The <see cref="NullSecurityContext"/> is a no-op implementation of the
- /// <see cref="SecurityContext"/> base class. It is used where a <see cref="SecurityContext"/>
- /// is required but one has not been provided.
- /// </para>
- /// </remarks>
- /// <author>Nicko Cadell</author>
- public sealed class NullSecurityContext : SecurityContext
- {
- /// <summary>
- /// Singleton instance of <see cref="NullSecurityContext"/>
- /// </summary>
- /// <remarks>
- /// <para>
- /// Singleton instance of <see cref="NullSecurityContext"/>
- /// </para>
- /// </remarks>
- public static readonly NullSecurityContext Instance = new NullSecurityContext();
+ /// <summary>
+ /// A SecurityContext used when a SecurityContext is not required
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// The <see cref="NullSecurityContext"/> is a no-op implementation of the
+ /// <see cref="SecurityContext"/> base class. It is used where a <see cref="SecurityContext"/>
+ /// is required but one has not been provided.
+ /// </para>
+ /// </remarks>
+ /// <author>Nicko Cadell</author>
+ public sealed class NullSecurityContext : SecurityContext
+ {
+ /// <summary>
+ /// Singleton instance of <see cref="NullSecurityContext"/>
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Singleton instance of <see cref="NullSecurityContext"/>
+ /// </para>
+ /// </remarks>
+ public static readonly NullSecurityContext Instance = new NullSecurityContext();
- /// <summary>
- /// Private constructor
- /// </summary>
- /// <remarks>
- /// <para>
- /// Private constructor for singleton pattern.
- /// </para>
- /// </remarks>
- private NullSecurityContext()
- {
- }
+ /// <summary>
+ /// Private constructor
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Private constructor for singleton pattern.
+ /// </para>
+ /// </remarks>
+ private NullSecurityContext()
+ {
+ }
- /// <summary>
- /// Impersonate this SecurityContext
- /// </summary>
- /// <param name="state">State supplied by the caller</param>
- /// <returns><c>null</c></returns>
- /// <remarks>
- /// <para>
- /// No impersonation is done and <c>null</c> is always returned.
- /// </para>
- /// </remarks>
- public override IDisposable Impersonate(object state)
- {
- return null;
- }
- }
+ /// <summary>
+ /// Impersonate this SecurityContext
+ /// </summary>
+ /// <param name="state">State supplied by the caller</param>
+ /// <returns><c>null</c></returns>
+ /// <remarks>
+ /// <para>
+ /// No impersonation is done and <c>null</c> is always returned.
+ /// </para>
+ /// </remarks>
+ public override IDisposable Impersonate(object state)
+ {
+ return null;
+ }
+ }
}
diff --git a/src/log4net/Util/OnlyOnceErrorHandler.cs b/src/log4net/Util/OnlyOnceErrorHandler.cs
index 5f03d92..ba4f0d1 100644
--- a/src/log4net/Util/OnlyOnceErrorHandler.cs
+++ b/src/log4net/Util/OnlyOnceErrorHandler.cs
@@ -23,91 +23,91 @@
namespace log4net.Util
{
- /// <summary>
- /// Implements log4net's default error handling policy which consists
- /// of emitting a message for the first error in an appender and
- /// ignoring all subsequent errors.
- /// </summary>
- /// <remarks>
- /// <para>
- /// The error message is processed using the LogLog sub-system by default.
- /// </para>
- /// <para>
- /// This policy aims at protecting an otherwise working application
- /// from being flooded with error messages when logging fails.
- /// </para>
- /// </remarks>
- /// <author>Nicko Cadell</author>
- /// <author>Gert Driesen</author>
- /// <author>Ron Grabowski</author>
- public class OnlyOnceErrorHandler : IErrorHandler
- {
- #region Public Instance Constructors
+ /// <summary>
+ /// Implements log4net's default error handling policy which consists
+ /// of emitting a message for the first error in an appender and
+ /// ignoring all subsequent errors.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// The error message is processed using the LogLog sub-system by default.
+ /// </para>
+ /// <para>
+ /// This policy aims at protecting an otherwise working application
+ /// from being flooded with error messages when logging fails.
+ /// </para>
+ /// </remarks>
+ /// <author>Nicko Cadell</author>
+ /// <author>Gert Driesen</author>
+ /// <author>Ron Grabowski</author>
+ public class OnlyOnceErrorHandler : IErrorHandler
+ {
+ #region Public Instance Constructors
- /// <summary>
- /// Default Constructor
- /// </summary>
- /// <remarks>
- /// <para>
- /// Initializes a new instance of the <see cref="OnlyOnceErrorHandler" /> class.
- /// </para>
- /// </remarks>
- public OnlyOnceErrorHandler()
- {
- m_prefix = "";
- }
+ /// <summary>
+ /// Default Constructor
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Initializes a new instance of the <see cref="OnlyOnceErrorHandler" /> class.
+ /// </para>
+ /// </remarks>
+ public OnlyOnceErrorHandler()
+ {
+ m_prefix = "";
+ }
- /// <summary>
- /// Constructor
- /// </summary>
- /// <param name="prefix">The prefix to use for each message.</param>
- /// <remarks>
- /// <para>
- /// Initializes a new instance of the <see cref="OnlyOnceErrorHandler" /> class
- /// with the specified prefix.
- /// </para>
- /// </remarks>
- public OnlyOnceErrorHandler(string prefix)
- {
- m_prefix = prefix;
- }
+ /// <summary>
+ /// Constructor
+ /// </summary>
+ /// <param name="prefix">The prefix to use for each message.</param>
+ /// <remarks>
+ /// <para>
+ /// Initializes a new instance of the <see cref="OnlyOnceErrorHandler" /> class
+ /// with the specified prefix.
+ /// </para>
+ /// </remarks>
+ public OnlyOnceErrorHandler(string prefix)
+ {
+ m_prefix = prefix;
+ }
- #endregion Public Instance Constructors
+ #endregion Public Instance Constructors
- #region Public Instance Methods
+ #region Public Instance Methods
- /// <summary>
- /// Reset the error handler back to its initial disabled state.
- /// </summary>
- public void Reset()
- {
- m_enabledDateUtc = DateTime.MinValue;
- m_errorCode = ErrorCode.GenericFailure;
- m_exception = null;
- m_message = null;
- m_firstTime = true;
- }
+ /// <summary>
+ /// Reset the error handler back to its initial disabled state.
+ /// </summary>
+ public void Reset()
+ {
+ m_enabledDateUtc = DateTime.MinValue;
+ m_errorCode = ErrorCode.GenericFailure;
+ m_exception = null;
+ m_message = null;
+ m_firstTime = true;
+ }
- #region Implementation of IErrorHandler
+ #region Implementation of IErrorHandler
- /// <summary>
- /// Log an Error
- /// </summary>
- /// <param name="message">The error message.</param>
- /// <param name="e">The exception.</param>
- /// <param name="errorCode">The internal error code.</param>
- /// <remarks>
- /// <para>
- /// Invokes <see cref="FirstError"/> if and only if this is the first error or the first error after <see cref="Reset"/> has been called.
- /// </para>
- /// </remarks>
- public void Error(string message, Exception e, ErrorCode errorCode)
- {
- if (m_firstTime)
- {
+ /// <summary>
+ /// Log an Error
+ /// </summary>
+ /// <param name="message">The error message.</param>
+ /// <param name="e">The exception.</param>
+ /// <param name="errorCode">The internal error code.</param>
+ /// <remarks>
+ /// <para>
+ /// Invokes <see cref="FirstError"/> if and only if this is the first error or the first error after <see cref="Reset"/> has been called.
+ /// </para>
+ /// </remarks>
+ public void Error(string message, Exception e, ErrorCode errorCode)
+ {
+ if (m_firstTime)
+ {
FirstError(message, e, errorCode);
- }
- }
+ }
+ }
/// <summary>
/// Log the very first error
@@ -133,65 +133,65 @@
}
/// <summary>
- /// Log an Error
- /// </summary>
- /// <param name="message">The error message.</param>
- /// <param name="e">The exception.</param>
- /// <remarks>
+ /// Log an Error
+ /// </summary>
+ /// <param name="message">The error message.</param>
+ /// <param name="e">The exception.</param>
+ /// <remarks>
/// <para>
/// Invokes <see cref="FirstError"/> if and only if this is the first error or the first error after <see cref="Reset"/> has been called.
/// </para>
/// </remarks>
- public void Error(string message, Exception e)
- {
- Error(message, e, ErrorCode.GenericFailure);
- }
+ public void Error(string message, Exception e)
+ {
+ Error(message, e, ErrorCode.GenericFailure);
+ }
- /// <summary>
- /// Log an error
- /// </summary>
- /// <param name="message">The error message.</param>
- /// <remarks>
+ /// <summary>
+ /// Log an error
+ /// </summary>
+ /// <param name="message">The error message.</param>
+ /// <remarks>
/// <para>
/// Invokes <see cref="FirstError"/> if and only if this is the first error or the first error after <see cref="Reset"/> has been called.
/// </para>
/// </remarks>
- public void Error(string message)
- {
- Error(message, null, ErrorCode.GenericFailure);
- }
+ public void Error(string message)
+ {
+ Error(message, null, ErrorCode.GenericFailure);
+ }
- #endregion Implementation of IErrorHandler
+ #endregion Implementation of IErrorHandler
- #endregion
+ #endregion
- #region Public Instance Properties
+ #region Public Instance Properties
- /// <summary>
- /// Is error logging enabled
- /// </summary>
- /// <remarks>
- /// <para>
- /// Is error logging enabled. Logging is only enabled for the
- /// first error delivered to the <see cref="OnlyOnceErrorHandler"/>.
- /// </para>
- /// </remarks>
- public bool IsEnabled
- {
- get { return m_firstTime; }
- }
+ /// <summary>
+ /// Is error logging enabled
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Is error logging enabled. Logging is only enabled for the
+ /// first error delivered to the <see cref="OnlyOnceErrorHandler"/>.
+ /// </para>
+ /// </remarks>
+ public bool IsEnabled
+ {
+ get { return m_firstTime; }
+ }
- /// <summary>
- /// The date the first error that trigged this error handler occurred, or <see cref="DateTime.MinValue"/> if it has not been triggered.
- /// </summary>
- public DateTime EnabledDate
- {
- get
+ /// <summary>
+ /// The date the first error that trigged this error handler occurred, or <see cref="DateTime.MinValue"/> if it has not been triggered.
+ /// </summary>
+ public DateTime EnabledDate
+ {
+ get
{
if (m_enabledDateUtc == DateTime.MinValue) return DateTime.MinValue;
return m_enabledDateUtc.ToLocalTime();
}
- }
+ }
/// <summary>
/// The UTC date the first error that trigged this error handler occured, or <see cref="DateTime.MinValue"/> if it has not been triggered.
@@ -201,83 +201,83 @@
get { return m_enabledDateUtc; }
}
- /// <summary>
- /// The message from the first error that trigged this error handler.
- /// </summary>
- public string ErrorMessage
- {
- get { return m_message; }
- }
+ /// <summary>
+ /// The message from the first error that trigged this error handler.
+ /// </summary>
+ public string ErrorMessage
+ {
+ get { return m_message; }
+ }
- /// <summary>
- /// The exception from the first error that trigged this error handler.
- /// </summary>
- /// <remarks>
- /// May be <see langword="null" />.
- /// </remarks>
- public Exception Exception
- {
- get { return m_exception; }
- }
+ /// <summary>
+ /// The exception from the first error that trigged this error handler.
+ /// </summary>
+ /// <remarks>
+ /// May be <see langword="null" />.
+ /// </remarks>
+ public Exception Exception
+ {
+ get { return m_exception; }
+ }
- /// <summary>
- /// The error code from the first error that trigged this error handler.
- /// </summary>
- /// <remarks>
- /// Defaults to <see cref="log4net.Core.ErrorCode.GenericFailure"/>
- /// </remarks>
- public ErrorCode ErrorCode
- {
- get { return m_errorCode; }
- }
+ /// <summary>
+ /// The error code from the first error that trigged this error handler.
+ /// </summary>
+ /// <remarks>
+ /// Defaults to <see cref="log4net.Core.ErrorCode.GenericFailure"/>
+ /// </remarks>
+ public ErrorCode ErrorCode
+ {
+ get { return m_errorCode; }
+ }
- #endregion
+ #endregion
- #region Private Instance Fields
+ #region Private Instance Fields
- /// <summary>
- /// The UTC date the error was recorded.
- /// </summary>
- private DateTime m_enabledDateUtc;
+ /// <summary>
+ /// The UTC date the error was recorded.
+ /// </summary>
+ private DateTime m_enabledDateUtc;
- /// <summary>
- /// Flag to indicate if it is the first error
- /// </summary>
- private bool m_firstTime = true;
+ /// <summary>
+ /// Flag to indicate if it is the first error
+ /// </summary>
+ private bool m_firstTime = true;
- /// <summary>
- /// The message recorded during the first error.
- /// </summary>
- private string m_message = null;
+ /// <summary>
+ /// The message recorded during the first error.
+ /// </summary>
+ private string m_message = null;
- /// <summary>
- /// The exception recorded during the first error.
- /// </summary>
- private Exception m_exception = null;
+ /// <summary>
+ /// The exception recorded during the first error.
+ /// </summary>
+ private Exception m_exception = null;
- /// <summary>
- /// The error code recorded during the first error.
- /// </summary>
- private ErrorCode m_errorCode = ErrorCode.GenericFailure;
+ /// <summary>
+ /// The error code recorded during the first error.
+ /// </summary>
+ private ErrorCode m_errorCode = ErrorCode.GenericFailure;
- /// <summary>
- /// String to prefix each message with
- /// </summary>
- private readonly string m_prefix;
+ /// <summary>
+ /// String to prefix each message with
+ /// </summary>
+ private readonly string m_prefix;
- #endregion Private Instance Fields
+ #endregion Private Instance Fields
- #region Private Static Fields
+ #region Private Static Fields
- /// <summary>
- /// The fully qualified type of the OnlyOnceErrorHandler class.
- /// </summary>
- /// <remarks>
- /// Used by the internal logger to record the Type of the
- /// log message.
- /// </remarks>
- private static readonly Type declaringType = typeof(OnlyOnceErrorHandler);
+ /// <summary>
+ /// The fully qualified type of the OnlyOnceErrorHandler class.
+ /// </summary>
+ /// <remarks>
+ /// Used by the internal logger to record the Type of the
+ /// log message.
+ /// </remarks>
+ private static readonly Type declaringType = typeof(OnlyOnceErrorHandler);
- #endregion
- }
+ #endregion
+ }
}
diff --git a/src/log4net/Util/OptionConverter.cs b/src/log4net/Util/OptionConverter.cs
index 21eabfe..77075b7 100644
--- a/src/log4net/Util/OptionConverter.cs
+++ b/src/log4net/Util/OptionConverter.cs
@@ -27,527 +27,527 @@
namespace log4net.Util
{
- /// <summary>
- /// A convenience class to convert property values to specific types.
- /// </summary>
- /// <remarks>
- /// <para>
- /// Utility functions for converting types and parsing values.
- /// </para>
- /// </remarks>
- /// <author>Nicko Cadell</author>
- /// <author>Gert Driesen</author>
- public sealed class OptionConverter
- {
- #region Private Instance Constructors
+ /// <summary>
+ /// A convenience class to convert property values to specific types.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Utility functions for converting types and parsing values.
+ /// </para>
+ /// </remarks>
+ /// <author>Nicko Cadell</author>
+ /// <author>Gert Driesen</author>
+ public sealed class OptionConverter
+ {
+ #region Private Instance Constructors
- /// <summary>
- /// Initializes a new instance of the <see cref="OptionConverter" /> class.
- /// </summary>
- /// <remarks>
- /// <para>
- /// Uses a private access modifier to prevent instantiation of this class.
- /// </para>
- /// </remarks>
- private OptionConverter()
- {
- }
+ /// <summary>
+ /// Initializes a new instance of the <see cref="OptionConverter" /> class.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Uses a private access modifier to prevent instantiation of this class.
+ /// </para>
+ /// </remarks>
+ private OptionConverter()
+ {
+ }
- #endregion Private Instance Constructors
+ #endregion Private Instance Constructors
- #region Public Static Methods
+ #region Public Static Methods
- /// <summary>
- /// Converts a string to a <see cref="bool" /> value.
- /// </summary>
- /// <param name="argValue">String to convert.</param>
- /// <param name="defaultValue">The default value.</param>
- /// <returns>The <see cref="bool" /> value of <paramref name="argValue" />.</returns>
- /// <remarks>
- /// <para>
- /// If <paramref name="argValue"/> is "true", then <c>true</c> is returned.
- /// If <paramref name="argValue"/> is "false", then <c>false</c> is returned.
- /// Otherwise, <paramref name="defaultValue"/> is returned.
- /// </para>
- /// </remarks>
- public static bool ToBoolean(string argValue, bool defaultValue)
- {
- if (argValue != null && argValue.Length > 0)
- {
- try
- {
- return bool.Parse(argValue);
- }
- catch(Exception e)
- {
- LogLog.Error(declaringType, "[" + argValue + "] is not in proper bool form.", e);
- }
- }
- return defaultValue;
- }
+ /// <summary>
+ /// Converts a string to a <see cref="bool" /> value.
+ /// </summary>
+ /// <param name="argValue">String to convert.</param>
+ /// <param name="defaultValue">The default value.</param>
+ /// <returns>The <see cref="bool" /> value of <paramref name="argValue" />.</returns>
+ /// <remarks>
+ /// <para>
+ /// If <paramref name="argValue"/> is "true", then <c>true</c> is returned.
+ /// If <paramref name="argValue"/> is "false", then <c>false</c> is returned.
+ /// Otherwise, <paramref name="defaultValue"/> is returned.
+ /// </para>
+ /// </remarks>
+ public static bool ToBoolean(string argValue, bool defaultValue)
+ {
+ if (argValue != null && argValue.Length > 0)
+ {
+ try
+ {
+ return bool.Parse(argValue);
+ }
+ catch(Exception e)
+ {
+ LogLog.Error(declaringType, "[" + argValue + "] is not in proper bool form.", e);
+ }
+ }
+ return defaultValue;
+ }
- /// <summary>
- /// Parses a file size into a number.
- /// </summary>
- /// <param name="argValue">String to parse.</param>
- /// <param name="defaultValue">The default value.</param>
- /// <returns>The <see cref="long" /> value of <paramref name="argValue" />.</returns>
- /// <remarks>
- /// <para>
- /// Parses a file size of the form: number[KB|MB|GB] into a
- /// long value. It is scaled with the appropriate multiplier.
- /// </para>
- /// <para>
- /// <paramref name="defaultValue"/> is returned when <paramref name="argValue"/>
- /// cannot be converted to a <see cref="long" /> value.
- /// </para>
- /// </remarks>
- public static long ToFileSize(string argValue, long defaultValue)
- {
- if (argValue == null)
- {
- return defaultValue;
- }
-
- string s = argValue.Trim().ToUpperInvariant();
- long multiplier = 1;
- int index;
-
- if ((index = s.IndexOf("KB")) != -1)
- {
- multiplier = 1024;
- s = s.Substring(0, index);
- }
- else if ((index = s.IndexOf("MB")) != -1)
- {
- multiplier = 1024 * 1024;
- s = s.Substring(0, index);
- }
- else if ((index = s.IndexOf("GB")) != -1)
- {
- multiplier = 1024 * 1024 * 1024;
- s = s.Substring(0, index);
- }
- if (s != null)
- {
- // Try again to remove whitespace between the number and the size specifier
- s = s.Trim();
-
- long longVal;
- if (SystemInfo.TryParse(s, out longVal))
- {
- return longVal * multiplier;
- }
- else
- {
- LogLog.Error(declaringType, "OptionConverter: ["+ s +"] is not in the correct file size syntax.");
- }
- }
- return defaultValue;
- }
+ /// <summary>
+ /// Parses a file size into a number.
+ /// </summary>
+ /// <param name="argValue">String to parse.</param>
+ /// <param name="defaultValue">The default value.</param>
+ /// <returns>The <see cref="long" /> value of <paramref name="argValue" />.</returns>
+ /// <remarks>
+ /// <para>
+ /// Parses a file size of the form: number[KB|MB|GB] into a
+ /// long value. It is scaled with the appropriate multiplier.
+ /// </para>
+ /// <para>
+ /// <paramref name="defaultValue"/> is returned when <paramref name="argValue"/>
+ /// cannot be converted to a <see cref="long" /> value.
+ /// </para>
+ /// </remarks>
+ public static long ToFileSize(string argValue, long defaultValue)
+ {
+ if (argValue == null)
+ {
+ return defaultValue;
+ }
+
+ string s = argValue.Trim().ToUpperInvariant();
+ long multiplier = 1;
+ int index;
+
+ if ((index = s.IndexOf("KB")) != -1)
+ {
+ multiplier = 1024;
+ s = s.Substring(0, index);
+ }
+ else if ((index = s.IndexOf("MB")) != -1)
+ {
+ multiplier = 1024 * 1024;
+ s = s.Substring(0, index);
+ }
+ else if ((index = s.IndexOf("GB")) != -1)
+ {
+ multiplier = 1024 * 1024 * 1024;
+ s = s.Substring(0, index);
+ }
+ if (s != null)
+ {
+ // Try again to remove whitespace between the number and the size specifier
+ s = s.Trim();
+
+ long longVal;
+ if (SystemInfo.TryParse(s, out longVal))
+ {
+ return longVal * multiplier;
+ }
+ else
+ {
+ LogLog.Error(declaringType, "OptionConverter: ["+ s +"] is not in the correct file size syntax.");
+ }
+ }
+ return defaultValue;
+ }
- /// <summary>
- /// Converts a string to an object.
- /// </summary>
- /// <param name="target">The target type to convert to.</param>
- /// <param name="txt">The string to convert to an object.</param>
- /// <returns>
- /// The object converted from a string or <c>null</c> when the
- /// conversion failed.
- /// </returns>
- /// <remarks>
- /// <para>
- /// Converts a string to an object. Uses the converter registry to try
- /// to convert the string value into the specified target type.
- /// </para>
- /// </remarks>
- public static object ConvertStringTo(Type target, string txt)
- {
- if (target == null)
- {
- throw new ArgumentNullException("target");
- }
+ /// <summary>
+ /// Converts a string to an object.
+ /// </summary>
+ /// <param name="target">The target type to convert to.</param>
+ /// <param name="txt">The string to convert to an object.</param>
+ /// <returns>
+ /// The object converted from a string or <c>null</c> when the
+ /// conversion failed.
+ /// </returns>
+ /// <remarks>
+ /// <para>
+ /// Converts a string to an object. Uses the converter registry to try
+ /// to convert the string value into the specified target type.
+ /// </para>
+ /// </remarks>
+ public static object ConvertStringTo(Type target, string txt)
+ {
+ if (target == null)
+ {
+ throw new ArgumentNullException("target");
+ }
- // If we want a string we already have the correct type
- if (typeof(string) == target || typeof(object) == target)
- {
- return txt;
- }
+ // If we want a string we already have the correct type
+ if (typeof(string) == target || typeof(object) == target)
+ {
+ return txt;
+ }
- // First lets try to find a type converter
- IConvertFrom typeConverter = ConverterRegistry.GetConvertFrom(target);
- if (typeConverter != null && typeConverter.CanConvertFrom(typeof(string)))
- {
- // Found appropriate converter
- return typeConverter.ConvertFrom(txt);
- }
- else
- {
+ // First lets try to find a type converter
+ IConvertFrom typeConverter = ConverterRegistry.GetConvertFrom(target);
+ if (typeConverter != null && typeConverter.CanConvertFrom(typeof(string)))
+ {
+ // Found appropriate converter
+ return typeConverter.ConvertFrom(txt);
+ }
+ else
+ {
#if NETSTANDARD1_3
- if (target.GetTypeInfo().IsEnum)
+ if (target.GetTypeInfo().IsEnum)
#else
- if (target.IsEnum)
+ if (target.IsEnum)
#endif
- {
- // Target type is an enum.
+ {
+ // Target type is an enum.
- // Use the Enum.Parse(EnumType, string) method to get the enum value
- return ParseEnum(target, txt, true);
- }
- else
- {
- // We essentially make a guess that to convert from a string
- // to an arbitrary type T there will be a static method defined on type T called Parse
- // that will take an argument of type string. i.e. T.Parse(string)->T we call this
- // method to convert the string to the type required by the property.
- System.Reflection.MethodInfo meth = target.GetMethod("Parse", new Type[] {typeof(string)});
- if (meth != null)
- {
- // Call the Parse method
+ // Use the Enum.Parse(EnumType, string) method to get the enum value
+ return ParseEnum(target, txt, true);
+ }
+ else
+ {
+ // We essentially make a guess that to convert from a string
+ // to an arbitrary type T there will be a static method defined on type T called Parse
+ // that will take an argument of type string. i.e. T.Parse(string)->T we call this
+ // method to convert the string to the type required by the property.
+ System.Reflection.MethodInfo meth = target.GetMethod("Parse", new Type[] {typeof(string)});
+ if (meth != null)
+ {
+ // Call the Parse method
#if NETSTANDARD1_3
- return meth.Invoke(target, new[] { txt });
+ return meth.Invoke(target, new[] { txt });
#else
- return meth.Invoke(null, BindingFlags.InvokeMethod, null, new object[] {txt}, CultureInfo.InvariantCulture);
+ return meth.Invoke(null, BindingFlags.InvokeMethod, null, new object[] {txt}, CultureInfo.InvariantCulture);
#endif
- }
- else
- {
- // No Parse() method found.
- }
- }
- }
- return null;
- }
+ }
+ else
+ {
+ // No Parse() method found.
+ }
+ }
+ }
+ return null;
+ }
-// /// <summary>
-// /// Looks up the <see cref="IConvertFrom"/> for the target type.
-// /// </summary>
-// /// <param name="target">The type to lookup the converter for.</param>
-// /// <returns>The converter for the specified type.</returns>
-// public static IConvertFrom GetTypeConverter(Type target)
-// {
-// IConvertFrom converter = ConverterRegistry.GetConverter(target);
-// if (converter == null)
-// {
-// throw new InvalidOperationException("No type converter defined for [" + target + "]");
-// }
-// return converter;
-// }
+// /// <summary>
+// /// Looks up the <see cref="IConvertFrom"/> for the target type.
+// /// </summary>
+// /// <param name="target">The type to lookup the converter for.</param>
+// /// <returns>The converter for the specified type.</returns>
+// public static IConvertFrom GetTypeConverter(Type target)
+// {
+// IConvertFrom converter = ConverterRegistry.GetConverter(target);
+// if (converter == null)
+// {
+// throw new InvalidOperationException("No type converter defined for [" + target + "]");
+// }
+// return converter;
+// }
- /// <summary>
- /// Checks if there is an appropriate type conversion from the source type to the target type.
- /// </summary>
- /// <param name="sourceType">The type to convert from.</param>
- /// <param name="targetType">The type to convert to.</param>
- /// <returns><c>true</c> if there is a conversion from the source type to the target type.</returns>
- /// <remarks>
- /// Checks if there is an appropriate type conversion from the source type to the target type.
- /// <para>
- /// </para>
- /// </remarks>
- public static bool CanConvertTypeTo(Type sourceType, Type targetType)
- {
- if (sourceType == null || targetType == null)
- {
- return false;
- }
+ /// <summary>
+ /// Checks if there is an appropriate type conversion from the source type to the target type.
+ /// </summary>
+ /// <param name="sourceType">The type to convert from.</param>
+ /// <param name="targetType">The type to convert to.</param>
+ /// <returns><c>true</c> if there is a conversion from the source type to the target type.</returns>
+ /// <remarks>
+ /// Checks if there is an appropriate type conversion from the source type to the target type.
+ /// <para>
+ /// </para>
+ /// </remarks>
+ public static bool CanConvertTypeTo(Type sourceType, Type targetType)
+ {
+ if (sourceType == null || targetType == null)
+ {
+ return false;
+ }
- // Check if we can assign directly from the source type to the target type
- if (targetType.IsAssignableFrom(sourceType))
- {
- return true;
- }
+ // Check if we can assign directly from the source type to the target type
+ if (targetType.IsAssignableFrom(sourceType))
+ {
+ return true;
+ }
- // Look for a To converter
- IConvertTo tcSource = ConverterRegistry.GetConvertTo(sourceType, targetType);
- if (tcSource != null)
- {
- if (tcSource.CanConvertTo(targetType))
- {
- return true;
- }
- }
+ // Look for a To converter
+ IConvertTo tcSource = ConverterRegistry.GetConvertTo(sourceType, targetType);
+ if (tcSource != null)
+ {
+ if (tcSource.CanConvertTo(targetType))
+ {
+ return true;
+ }
+ }
- // Look for a From converter
- IConvertFrom tcTarget = ConverterRegistry.GetConvertFrom(targetType);
- if (tcTarget != null)
- {
- if (tcTarget.CanConvertFrom(sourceType))
- {
- return true;
- }
- }
+ // Look for a From converter
+ IConvertFrom tcTarget = ConverterRegistry.GetConvertFrom(targetType);
+ if (tcTarget != null)
+ {
+ if (tcTarget.CanConvertFrom(sourceType))
+ {
+ return true;
+ }
+ }
- return false;
- }
+ return false;
+ }
- /// <summary>
- /// Converts an object to the target type.
- /// </summary>
- /// <param name="sourceInstance">The object to convert to the target type.</param>
- /// <param name="targetType">The type to convert to.</param>
- /// <returns>The converted object.</returns>
- /// <remarks>
- /// <para>
- /// Converts an object to the target type.
- /// </para>
- /// </remarks>
- public static object ConvertTypeTo(object sourceInstance, Type targetType)
- {
- Type sourceType = sourceInstance.GetType();
+ /// <summary>
+ /// Converts an object to the target type.
+ /// </summary>
+ /// <param name="sourceInstance">The object to convert to the target type.</param>
+ /// <param name="targetType">The type to convert to.</param>
+ /// <returns>The converted object.</returns>
+ /// <remarks>
+ /// <para>
+ /// Converts an object to the target type.
+ /// </para>
+ /// </remarks>
+ public static object ConvertTypeTo(object sourceInstance, Type targetType)
+ {
+ Type sourceType = sourceInstance.GetType();
- // Check if we can assign directly from the source type to the target type
- if (targetType.IsAssignableFrom(sourceType))
- {
- return sourceInstance;
- }
+ // Check if we can assign directly from the source type to the target type
+ if (targetType.IsAssignableFrom(sourceType))
+ {
+ return sourceInstance;
+ }
- // Look for a TO converter
- IConvertTo tcSource = ConverterRegistry.GetConvertTo(sourceType, targetType);
- if (tcSource != null)
- {
- if (tcSource.CanConvertTo(targetType))
- {
- return tcSource.ConvertTo(sourceInstance, targetType);
- }
- }
+ // Look for a TO converter
+ IConvertTo tcSource = ConverterRegistry.GetConvertTo(sourceType, targetType);
+ if (tcSource != null)
+ {
+ if (tcSource.CanConvertTo(targetType))
+ {
+ return tcSource.ConvertTo(sourceInstance, targetType);
+ }
+ }
- // Look for a FROM converter
- IConvertFrom tcTarget = ConverterRegistry.GetConvertFrom(targetType);
- if (tcTarget != null)
- {
- if (tcTarget.CanConvertFrom(sourceType))
- {
- return tcTarget.ConvertFrom(sourceInstance);
- }
- }
+ // Look for a FROM converter
+ IConvertFrom tcTarget = ConverterRegistry.GetConvertFrom(targetType);
+ if (tcTarget != null)
+ {
+ if (tcTarget.CanConvertFrom(sourceType))
+ {
+ return tcTarget.ConvertFrom(sourceInstance);
+ }
+ }
- throw new ArgumentException("Cannot convert source object [" + sourceInstance.ToString() + "] to target type [" + targetType.Name + "]", "sourceInstance");
- }
+ throw new ArgumentException("Cannot convert source object [" + sourceInstance.ToString() + "] to target type [" + targetType.Name + "]", "sourceInstance");
+ }
-// /// <summary>
-// /// Finds the value corresponding to <paramref name="key"/> in
-// /// <paramref name="props"/> and then perform variable substitution
-// /// on the found value.
-// /// </summary>
-// /// <param name="key">The key to lookup.</param>
-// /// <param name="props">The association to use for lookups.</param>
-// /// <returns>The substituted result.</returns>
-// public static string FindAndSubst(string key, System.Collections.IDictionary props)
-// {
-// if (props == null)
-// {
-// throw new ArgumentNullException("props");
-// }
+// /// <summary>
+// /// Finds the value corresponding to <paramref name="key"/> in
+// /// <paramref name="props"/> and then perform variable substitution
+// /// on the found value.
+// /// </summary>
+// /// <param name="key">The key to lookup.</param>
+// /// <param name="props">The association to use for lookups.</param>
+// /// <returns>The substituted result.</returns>
+// public static string FindAndSubst(string key, System.Collections.IDictionary props)
+// {
+// if (props == null)
+// {
+// throw new ArgumentNullException("props");
+// }
//
-// string v = props[key] as string;
-// if (v == null)
-// {
-// return null;
-// }
-//
-// try
-// {
-// return SubstituteVariables(v, props);
-// }
-// catch(Exception e)
-// {
-// LogLog.Error(declaringType, "OptionConverter: Bad option value [" + v + "].", e);
-// return v;
-// }
-// }
+// string v = props[key] as string;
+// if (v == null)
+// {
+// return null;
+// }
+//
+// try
+// {
+// return SubstituteVariables(v, props);
+// }
+// catch(Exception e)
+// {
+// LogLog.Error(declaringType, "OptionConverter: Bad option value [" + v + "].", e);
+// return v;
+// }
+// }
- /// <summary>
- /// Instantiates an object given a class name.
- /// </summary>
- /// <param name="className">The fully qualified class name of the object to instantiate.</param>
- /// <param name="superClass">The class to which the new object should belong.</param>
- /// <param name="defaultValue">The object to return in case of non-fulfillment.</param>
- /// <returns>
- /// An instance of the <paramref name="className"/> or <paramref name="defaultValue"/>
- /// if the object could not be instantiated.
- /// </returns>
- /// <remarks>
- /// <para>
- /// Checks that the <paramref name="className"/> is a subclass of
- /// <paramref name="superClass"/>. If that test fails or the object could
- /// not be instantiated, then <paramref name="defaultValue"/> is returned.
- /// </para>
- /// </remarks>
- public static object InstantiateByClassName(string className, Type superClass, object defaultValue)
- {
- if (className != null)
- {
- try
- {
+ /// <summary>
+ /// Instantiates an object given a class name.
+ /// </summary>
+ /// <param name="className">The fully qualified class name of the object to instantiate.</param>
+ /// <param name="superClass">The class to which the new object should belong.</param>
+ /// <param name="defaultValue">The object to return in case of non-fulfillment.</param>
+ /// <returns>
+ /// An instance of the <paramref name="className"/> or <paramref name="defaultValue"/>
+ /// if the object could not be instantiated.
+ /// </returns>
+ /// <remarks>
+ /// <para>
+ /// Checks that the <paramref name="className"/> is a subclass of
+ /// <paramref name="superClass"/>. If that test fails or the object could
+ /// not be instantiated, then <paramref name="defaultValue"/> is returned.
+ /// </para>
+ /// </remarks>
+ public static object InstantiateByClassName(string className, Type superClass, object defaultValue)
+ {
+ if (className != null)
+ {
+ try
+ {
#if NETSTANDARD1_3
- Type classObj = SystemInfo.GetTypeFromString(superClass.GetTypeInfo().Assembly, className, true, true);
+ Type classObj = SystemInfo.GetTypeFromString(superClass.GetTypeInfo().Assembly, className, true, true);
#else
- Type classObj = SystemInfo.GetTypeFromString(className, true, true);
+ Type classObj = SystemInfo.GetTypeFromString(className, true, true);
#endif
- if (!superClass.IsAssignableFrom(classObj))
- {
- LogLog.Error(declaringType, "OptionConverter: A [" + className + "] object is not assignable to a [" + superClass.FullName + "] variable.");
- return defaultValue;
- }
- return Activator.CreateInstance(classObj);
- }
- catch (Exception e)
- {
- LogLog.Error(declaringType, "Could not instantiate class [" + className + "].", e);
- }
- }
- return defaultValue;
- }
+ if (!superClass.IsAssignableFrom(classObj))
+ {
+ LogLog.Error(declaringType, "OptionConverter: A [" + className + "] object is not assignable to a [" + superClass.FullName + "] variable.");
+ return defaultValue;
+ }
+ return Activator.CreateInstance(classObj);
+ }
+ catch (Exception e)
+ {
+ LogLog.Error(declaringType, "Could not instantiate class [" + className + "].", e);
+ }
+ }
+ return defaultValue;
+ }
- /// <summary>
- /// Performs variable substitution in string <paramref name="value"/> from the
- /// values of keys found in <paramref name="props"/>.
- /// </summary>
- /// <param name="value">The string on which variable substitution is performed.</param>
- /// <param name="props">The dictionary to use to lookup variables.</param>
- /// <returns>The result of the substitutions.</returns>
- /// <remarks>
- /// <para>
- /// The variable substitution delimiters are <b>${</b> and <b>}</b>.
- /// </para>
- /// <para>
- /// For example, if props contains <c>key=value</c>, then the call
- /// </para>
- /// <para>
- /// <code lang="C#">
- /// string s = OptionConverter.SubstituteVariables("Value of key is ${key}.");
- /// </code>
- /// </para>
- /// <para>
- /// will set the variable <c>s</c> to "Value of key is value.".
- /// </para>
- /// <para>
- /// If no value could be found for the specified key, then substitution
- /// defaults to an empty string.
- /// </para>
- /// <para>
- /// For example, if system properties contains no value for the key
- /// "nonExistentKey", then the call
- /// </para>
- /// <para>
- /// <code lang="C#">
- /// string s = OptionConverter.SubstituteVariables("Value of nonExistentKey is [${nonExistentKey}]");
- /// </code>
- /// </para>
- /// <para>
- /// will set <s>s</s> to "Value of nonExistentKey is []".
- /// </para>
- /// <para>
- /// An Exception is thrown if <paramref name="value"/> contains a start
- /// delimiter "${" which is not balanced by a stop delimiter "}".
- /// </para>
- /// </remarks>
- public static string SubstituteVariables(string value, System.Collections.IDictionary props)
- {
- StringBuilder buf = new StringBuilder();
+ /// <summary>
+ /// Performs variable substitution in string <paramref name="value"/> from the
+ /// values of keys found in <paramref name="props"/>.
+ /// </summary>
+ /// <param name="value">The string on which variable substitution is performed.</param>
+ /// <param name="props">The dictionary to use to lookup variables.</param>
+ /// <returns>The result of the substitutions.</returns>
+ /// <remarks>
+ /// <para>
+ /// The variable substitution delimiters are <b>${</b> and <b>}</b>.
+ /// </para>
+ /// <para>
+ /// For example, if props contains <c>key=value</c>, then the call
+ /// </para>
+ /// <para>
+ /// <code lang="C#">
+ /// string s = OptionConverter.SubstituteVariables("Value of key is ${key}.");
+ /// </code>
+ /// </para>
+ /// <para>
+ /// will set the variable <c>s</c> to "Value of key is value.".
+ /// </para>
+ /// <para>
+ /// If no value could be found for the specified key, then substitution
+ /// defaults to an empty string.
+ /// </para>
+ /// <para>
+ /// For example, if system properties contains no value for the key
+ /// "nonExistentKey", then the call
+ /// </para>
+ /// <para>
+ /// <code lang="C#">
+ /// string s = OptionConverter.SubstituteVariables("Value of nonExistentKey is [${nonExistentKey}]");
+ /// </code>
+ /// </para>
+ /// <para>
+ /// will set <s>s</s> to "Value of nonExistentKey is []".
+ /// </para>
+ /// <para>
+ /// An Exception is thrown if <paramref name="value"/> contains a start
+ /// delimiter "${" which is not balanced by a stop delimiter "}".
+ /// </para>
+ /// </remarks>
+ public static string SubstituteVariables(string value, System.Collections.IDictionary props)
+ {
+ StringBuilder buf = new StringBuilder();
- int i = 0;
- int j, k;
-
- while(true)
- {
- j = value.IndexOf(DELIM_START, i);
- if (j == -1)
- {
- if (i == 0)
- {
- return value;
- }
- else
- {
- buf.Append(value.Substring(i, value.Length - i));
- return buf.ToString();
- }
- }
- else
- {
- buf.Append(value.Substring(i, j - i));
- k = value.IndexOf(DELIM_STOP, j);
- if (k == -1)
- {
- throw new LogException("[" + value + "] has no closing brace. Opening brace at position [" + j + "]");
- }
- else
- {
- j += DELIM_START_LEN;
- string key = value.Substring(j, k - j);
+ int i = 0;
+ int j, k;
+
+ while(true)
+ {
+ j = value.IndexOf(DELIM_START, i);
+ if (j == -1)
+ {
+ if (i == 0)
+ {
+ return value;
+ }
+ else
+ {
+ buf.Append(value.Substring(i, value.Length - i));
+ return buf.ToString();
+ }
+ }
+ else
+ {
+ buf.Append(value.Substring(i, j - i));
+ k = value.IndexOf(DELIM_STOP, j);
+ if (k == -1)
+ {
+ throw new LogException("[" + value + "] has no closing brace. Opening brace at position [" + j + "]");
+ }
+ else
+ {
+ j += DELIM_START_LEN;
+ string key = value.Substring(j, k - j);
- string replacement = props[key] as string;
+ string replacement = props[key] as string;
- if (replacement != null)
- {
- buf.Append(replacement);
- }
- i = k + DELIM_STOP_LEN;
- }
- }
- }
- }
+ if (replacement != null)
+ {
+ buf.Append(replacement);
+ }
+ i = k + DELIM_STOP_LEN;
+ }
+ }
+ }
+ }
- #endregion Public Static Methods
+ #endregion Public Static Methods
- #region Private Static Methods
+ #region Private Static Methods
- /// <summary>
- /// Converts the string representation of the name or numeric value of one or
- /// more enumerated constants to an equivalent enumerated object.
- /// </summary>
- /// <param name="enumType">The type to convert to.</param>
- /// <param name="value">The enum string value.</param>
- /// <param name="ignoreCase">If <c>true</c>, ignore case; otherwise, regard case.</param>
- /// <returns>An object of type <paramref name="enumType" /> whose value is represented by <paramref name="value" />.</returns>
- private static object ParseEnum(System.Type enumType, string value, bool ignoreCase)
- {
+ /// <summary>
+ /// Converts the string representation of the name or numeric value of one or
+ /// more enumerated constants to an equivalent enumerated object.
+ /// </summary>
+ /// <param name="enumType">The type to convert to.</param>
+ /// <param name="value">The enum string value.</param>
+ /// <param name="ignoreCase">If <c>true</c>, ignore case; otherwise, regard case.</param>
+ /// <returns>An object of type <paramref name="enumType" /> whose value is represented by <paramref name="value" />.</returns>
+ private static object ParseEnum(System.Type enumType, string value, bool ignoreCase)
+ {
#if !NETCF
- return Enum.Parse(enumType, value, ignoreCase);
+ return Enum.Parse(enumType, value, ignoreCase);
#else
- FieldInfo[] fields = enumType.GetFields(BindingFlags.Public | BindingFlags.Static);
+ FieldInfo[] fields = enumType.GetFields(BindingFlags.Public | BindingFlags.Static);
- string[] names = value.Split(new char[] {','});
- for (int i = 0; i < names.Length; ++i)
- {
- names[i] = names [i].Trim();
- }
+ string[] names = value.Split(new char[] {','});
+ for (int i = 0; i < names.Length; ++i)
+ {
+ names[i] = names [i].Trim();
+ }
- long retVal = 0;
+ long retVal = 0;
- try
- {
- // Attempt to convert to numeric type
- return Enum.ToObject(enumType, Convert.ChangeType(value, typeof(long), CultureInfo.InvariantCulture));
- }
- catch {}
+ try
+ {
+ // Attempt to convert to numeric type
+ return Enum.ToObject(enumType, Convert.ChangeType(value, typeof(long), CultureInfo.InvariantCulture));
+ }
+ catch {}
- foreach (string name in names)
- {
- bool found = false;
- foreach(FieldInfo field in fields)
- {
- if (String.Compare(name, field.Name, ignoreCase) == 0)
- {
- retVal |= ((IConvertible) field.GetValue(null)).ToInt64(CultureInfo.InvariantCulture);
- found = true;
- break;
- }
- }
- if (!found)
- {
- throw new ArgumentException("Failed to lookup member [" + name + "] from Enum type [" + enumType.Name + "]");
- }
- }
- return Enum.ToObject(enumType, retVal);
+ foreach (string name in names)
+ {
+ bool found = false;
+ foreach(FieldInfo field in fields)
+ {
+ if (String.Compare(name, field.Name, ignoreCase) == 0)
+ {
+ retVal |= ((IConvertible) field.GetValue(null)).ToInt64(CultureInfo.InvariantCulture);
+ found = true;
+ break;
+ }
+ }
+ if (!found)
+ {
+ throw new ArgumentException("Failed to lookup member [" + name + "] from Enum type [" + enumType.Name + "]");
+ }
+ }
+ return Enum.ToObject(enumType, retVal);
#endif
- }
+ }
- #endregion Private Static Methods
+ #endregion Private Static Methods
- #region Private Static Fields
+ #region Private Static Fields
/// <summary>
/// The fully qualified type of the OptionConverter class.
@@ -558,11 +558,11 @@
/// </remarks>
private static readonly Type declaringType = typeof(OptionConverter);
- private const string DELIM_START = "${";
- private const char DELIM_STOP = '}';
- private const int DELIM_START_LEN = 2;
- private const int DELIM_STOP_LEN = 1;
+ private const string DELIM_START = "${";
+ private const char DELIM_STOP = '}';
+ private const int DELIM_START_LEN = 2;
+ private const int DELIM_STOP_LEN = 1;
- #endregion Private Static Fields
- }
+ #endregion Private Static Fields
+ }
}
diff --git a/src/log4net/Util/PatternConverter.cs b/src/log4net/Util/PatternConverter.cs
index 9f9067b..295a749 100644
--- a/src/log4net/Util/PatternConverter.cs
+++ b/src/log4net/Util/PatternConverter.cs
@@ -26,154 +26,154 @@
namespace log4net.Util
{
- /// <summary>
- /// Abstract class that provides the formatting functionality that
- /// derived classes need.
- /// </summary>
- /// <remarks>
- /// <para>
- /// Conversion specifiers in a conversion patterns are parsed to
- /// individual PatternConverters. Each of which is responsible for
- /// converting a logging event in a converter specific manner.
- /// </para>
- /// </remarks>
- /// <author>Nicko Cadell</author>
- /// <author>Gert Driesen</author>
- public abstract class PatternConverter
- {
- #region Protected Instance Constructors
+ /// <summary>
+ /// Abstract class that provides the formatting functionality that
+ /// derived classes need.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Conversion specifiers in a conversion patterns are parsed to
+ /// individual PatternConverters. Each of which is responsible for
+ /// converting a logging event in a converter specific manner.
+ /// </para>
+ /// </remarks>
+ /// <author>Nicko Cadell</author>
+ /// <author>Gert Driesen</author>
+ public abstract class PatternConverter
+ {
+ #region Protected Instance Constructors
- /// <summary>
- /// Protected constructor
- /// </summary>
- /// <remarks>
- /// <para>
- /// Initializes a new instance of the <see cref="PatternConverter" /> class.
- /// </para>
- /// </remarks>
- protected PatternConverter()
- {
- }
+ /// <summary>
+ /// Protected constructor
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Initializes a new instance of the <see cref="PatternConverter" /> class.
+ /// </para>
+ /// </remarks>
+ protected PatternConverter()
+ {
+ }
- #endregion Protected Instance Constructors
+ #endregion Protected Instance Constructors
- #region Public Instance Properties
+ #region Public Instance Properties
- /// <summary>
- /// Get the next pattern converter in the chain
- /// </summary>
- /// <value>
- /// the next pattern converter in the chain
- /// </value>
- /// <remarks>
- /// <para>
- /// Get the next pattern converter in the chain
- /// </para>
- /// </remarks>
- public virtual PatternConverter Next
- {
- get { return m_next; }
- }
+ /// <summary>
+ /// Get the next pattern converter in the chain
+ /// </summary>
+ /// <value>
+ /// the next pattern converter in the chain
+ /// </value>
+ /// <remarks>
+ /// <para>
+ /// Get the next pattern converter in the chain
+ /// </para>
+ /// </remarks>
+ public virtual PatternConverter Next
+ {
+ get { return m_next; }
+ }
- /// <summary>
- /// Gets or sets the formatting info for this converter
- /// </summary>
- /// <value>
- /// The formatting info for this converter
- /// </value>
- /// <remarks>
- /// <para>
- /// Gets or sets the formatting info for this converter
- /// </para>
- /// </remarks>
- public virtual FormattingInfo FormattingInfo
- {
- get { return new FormattingInfo(m_min, m_max, m_leftAlign); }
- set
- {
- m_min = value.Min;
- m_max = value.Max;
- m_leftAlign = value.LeftAlign;
- }
- }
+ /// <summary>
+ /// Gets or sets the formatting info for this converter
+ /// </summary>
+ /// <value>
+ /// The formatting info for this converter
+ /// </value>
+ /// <remarks>
+ /// <para>
+ /// Gets or sets the formatting info for this converter
+ /// </para>
+ /// </remarks>
+ public virtual FormattingInfo FormattingInfo
+ {
+ get { return new FormattingInfo(m_min, m_max, m_leftAlign); }
+ set
+ {
+ m_min = value.Min;
+ m_max = value.Max;
+ m_leftAlign = value.LeftAlign;
+ }
+ }
- /// <summary>
- /// Gets or sets the option value for this converter
- /// </summary>
- /// <summary>
- /// The option for this converter
- /// </summary>
- /// <remarks>
- /// <para>
- /// Gets or sets the option value for this converter
- /// </para>
- /// </remarks>
- public virtual string Option
- {
- get { return m_option; }
- set { m_option = value; }
- }
+ /// <summary>
+ /// Gets or sets the option value for this converter
+ /// </summary>
+ /// <summary>
+ /// The option for this converter
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Gets or sets the option value for this converter
+ /// </para>
+ /// </remarks>
+ public virtual string Option
+ {
+ get { return m_option; }
+ set { m_option = value; }
+ }
- #endregion Public Instance Properties
+ #endregion Public Instance Properties
- #region Protected Abstract Methods
+ #region Protected Abstract Methods
- /// <summary>
- /// Evaluate this pattern converter and write the output to a writer.
- /// </summary>
- /// <param name="writer"><see cref="TextWriter" /> that will receive the formatted result.</param>
- /// <param name="state">The state object on which the pattern converter should be executed.</param>
- /// <remarks>
- /// <para>
- /// Derived pattern converters must override this method in order to
- /// convert conversion specifiers in the appropriate way.
- /// </para>
- /// </remarks>
- protected abstract void Convert(TextWriter writer, object state);
+ /// <summary>
+ /// Evaluate this pattern converter and write the output to a writer.
+ /// </summary>
+ /// <param name="writer"><see cref="TextWriter" /> that will receive the formatted result.</param>
+ /// <param name="state">The state object on which the pattern converter should be executed.</param>
+ /// <remarks>
+ /// <para>
+ /// Derived pattern converters must override this method in order to
+ /// convert conversion specifiers in the appropriate way.
+ /// </para>
+ /// </remarks>
+ protected abstract void Convert(TextWriter writer, object state);
- #endregion Protected Abstract Methods
+ #endregion Protected Abstract Methods
- #region Public Instance Methods
+ #region Public Instance Methods
- /// <summary>
- /// Set the next pattern converter in the chains
- /// </summary>
- /// <param name="patternConverter">the pattern converter that should follow this converter in the chain</param>
- /// <returns>the next converter</returns>
- /// <remarks>
- /// <para>
- /// The PatternConverter can merge with its neighbor during this method (or a sub class).
- /// Therefore the return value may or may not be the value of the argument passed in.
- /// </para>
- /// </remarks>
- public virtual PatternConverter SetNext(PatternConverter patternConverter)
- {
- m_next = patternConverter;
- return m_next;
- }
+ /// <summary>
+ /// Set the next pattern converter in the chains
+ /// </summary>
+ /// <param name="patternConverter">the pattern converter that should follow this converter in the chain</param>
+ /// <returns>the next converter</returns>
+ /// <remarks>
+ /// <para>
+ /// The PatternConverter can merge with its neighbor during this method (or a sub class).
+ /// Therefore the return value may or may not be the value of the argument passed in.
+ /// </para>
+ /// </remarks>
+ public virtual PatternConverter SetNext(PatternConverter patternConverter)
+ {
+ m_next = patternConverter;
+ return m_next;
+ }
- /// <summary>
- /// Write the pattern converter to the writer with appropriate formatting
- /// </summary>
- /// <param name="writer"><see cref="TextWriter" /> that will receive the formatted result.</param>
- /// <param name="state">The state object on which the pattern converter should be executed.</param>
- /// <remarks>
- /// <para>
- /// This method calls <see cref="Convert"/> to allow the subclass to perform
- /// appropriate conversion of the pattern converter. If formatting options have
- /// been specified via the <see cref="FormattingInfo"/> then this method will
- /// apply those formattings before writing the output.
- /// </para>
- /// </remarks>
- public virtual void Format(TextWriter writer, object state)
- {
- if (m_min < 0 && m_max == int.MaxValue)
- {
- // Formatting options are not in use
- Convert(writer, state);
- }
- else
- {
+ /// <summary>
+ /// Write the pattern converter to the writer with appropriate formatting
+ /// </summary>
+ /// <param name="writer"><see cref="TextWriter" /> that will receive the formatted result.</param>
+ /// <param name="state">The state object on which the pattern converter should be executed.</param>
+ /// <remarks>
+ /// <para>
+ /// This method calls <see cref="Convert"/> to allow the subclass to perform
+ /// appropriate conversion of the pattern converter. If formatting options have
+ /// been specified via the <see cref="FormattingInfo"/> then this method will
+ /// apply those formattings before writing the output.
+ /// </para>
+ /// </remarks>
+ public virtual void Format(TextWriter writer, object state)
+ {
+ if (m_min < 0 && m_max == int.MaxValue)
+ {
+ // Formatting options are not in use
+ Convert(writer, state);
+ }
+ else
+ {
string msg = null;
int len;
lock (m_formatWriter)
@@ -195,193 +195,193 @@
}
}
- if (len < m_min)
- {
- if (m_leftAlign)
- {
- writer.Write(msg);
- SpacePad(writer, m_min - len);
- }
- else
- {
- SpacePad(writer, m_min - len);
- writer.Write(msg);
- }
- }
- else
- {
- writer.Write(msg);
- }
- }
- }
+ if (len < m_min)
+ {
+ if (m_leftAlign)
+ {
+ writer.Write(msg);
+ SpacePad(writer, m_min - len);
+ }
+ else
+ {
+ SpacePad(writer, m_min - len);
+ writer.Write(msg);
+ }
+ }
+ else
+ {
+ writer.Write(msg);
+ }
+ }
+ }
- private static readonly string[] SPACES = { " ", " ", " ", " ", // 1,2,4,8 spaces
- " ", // 16 spaces
- " " }; // 32 spaces
+ private static readonly string[] SPACES = { " ", " ", " ", " ", // 1,2,4,8 spaces
+ " ", // 16 spaces
+ " " }; // 32 spaces
- /// <summary>
- /// Fast space padding method.
- /// </summary>
- /// <param name="writer"><see cref="TextWriter" /> to which the spaces will be appended.</param>
- /// <param name="length">The number of spaces to be padded.</param>
- /// <remarks>
- /// <para>
- /// Fast space padding method.
- /// </para>
- /// </remarks>
- protected static void SpacePad(TextWriter writer, int length)
- {
- while(length >= 32)
- {
- writer.Write(SPACES[5]);
- length -= 32;
- }
+ /// <summary>
+ /// Fast space padding method.
+ /// </summary>
+ /// <param name="writer"><see cref="TextWriter" /> to which the spaces will be appended.</param>
+ /// <param name="length">The number of spaces to be padded.</param>
+ /// <remarks>
+ /// <para>
+ /// Fast space padding method.
+ /// </para>
+ /// </remarks>
+ protected static void SpacePad(TextWriter writer, int length)
+ {
+ while(length >= 32)
+ {
+ writer.Write(SPACES[5]);
+ length -= 32;
+ }
- for(int i = 4; i >= 0; i--)
- {
- if ((length & (1<<i)) != 0)
- {
- writer.Write(SPACES[i]);
- }
- }
- }
+ for(int i = 4; i >= 0; i--)
+ {
+ if ((length & (1<<i)) != 0)
+ {
+ writer.Write(SPACES[i]);
+ }
+ }
+ }
- #endregion Public Instance Methods
+ #endregion Public Instance Methods
- #region Private Instance Fields
+ #region Private Instance Fields
- private PatternConverter m_next;
- private int m_min = -1;
- private int m_max = int.MaxValue;
- private bool m_leftAlign = false;
+ private PatternConverter m_next;
+ private int m_min = -1;
+ private int m_max = int.MaxValue;
+ private bool m_leftAlign = false;
- /// <summary>
- /// The option string to the converter
- /// </summary>
- private string m_option = null;
+ /// <summary>
+ /// The option string to the converter
+ /// </summary>
+ private string m_option = null;
- private ReusableStringWriter m_formatWriter = new ReusableStringWriter(System.Globalization.CultureInfo.InvariantCulture);
+ private ReusableStringWriter m_formatWriter = new ReusableStringWriter(System.Globalization.CultureInfo.InvariantCulture);
- #endregion Private Instance Fields
+ #endregion Private Instance Fields
- #region Constants
+ #region Constants
- /// <summary>
- /// Initial buffer size
- /// </summary>
- private const int c_renderBufferSize = 256;
+ /// <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;
+ /// <summary>
+ /// Maximum buffer size before it is recycled
+ /// </summary>
+ private const int c_renderBufferMaxCapacity = 1024;
- #endregion
+ #endregion
- #region Static Methods
+ #region Static Methods
- /// <summary>
- /// Write an dictionary to a <see cref="TextWriter"/>
- /// </summary>
- /// <param name="writer">the writer to write to</param>
- /// <param name="repository">a <see cref="ILoggerRepository"/> to use for object conversion</param>
- /// <param name="value">the value to write to the writer</param>
- /// <remarks>
- /// <para>
- /// Writes the <see cref="IDictionary"/> to a writer in the form:
- /// </para>
- /// <code>
- /// {key1=value1, key2=value2, key3=value3}
- /// </code>
- /// <para>
- /// If the <see cref="ILoggerRepository"/> specified
- /// is not null then it is used to render the key and value to text, otherwise
- /// the object's ToString method is called.
- /// </para>
- /// </remarks>
- protected static void WriteDictionary(TextWriter writer, ILoggerRepository repository, IDictionary value)
- {
- WriteDictionary(writer, repository, value.GetEnumerator());
- }
+ /// <summary>
+ /// Write an dictionary to a <see cref="TextWriter"/>
+ /// </summary>
+ /// <param name="writer">the writer to write to</param>
+ /// <param name="repository">a <see cref="ILoggerRepository"/> to use for object conversion</param>
+ /// <param name="value">the value to write to the writer</param>
+ /// <remarks>
+ /// <para>
+ /// Writes the <see cref="IDictionary"/> to a writer in the form:
+ /// </para>
+ /// <code>
+ /// {key1=value1, key2=value2, key3=value3}
+ /// </code>
+ /// <para>
+ /// If the <see cref="ILoggerRepository"/> specified
+ /// is not null then it is used to render the key and value to text, otherwise
+ /// the object's ToString method is called.
+ /// </para>
+ /// </remarks>
+ protected static void WriteDictionary(TextWriter writer, ILoggerRepository repository, IDictionary value)
+ {
+ WriteDictionary(writer, repository, value.GetEnumerator());
+ }
- /// <summary>
- /// Write an dictionary to a <see cref="TextWriter"/>
- /// </summary>
- /// <param name="writer">the writer to write to</param>
- /// <param name="repository">a <see cref="ILoggerRepository"/> to use for object conversion</param>
- /// <param name="value">the value to write to the writer</param>
- /// <remarks>
- /// <para>
- /// Writes the <see cref="IDictionaryEnumerator"/> to a writer in the form:
- /// </para>
- /// <code>
- /// {key1=value1, key2=value2, key3=value3}
- /// </code>
- /// <para>
- /// If the <see cref="ILoggerRepository"/> specified
- /// is not null then it is used to render the key and value to text, otherwise
- /// the object's ToString method is called.
- /// </para>
- /// </remarks>
- protected static void WriteDictionary(TextWriter writer, ILoggerRepository repository, IDictionaryEnumerator value)
- {
- writer.Write("{");
+ /// <summary>
+ /// Write an dictionary to a <see cref="TextWriter"/>
+ /// </summary>
+ /// <param name="writer">the writer to write to</param>
+ /// <param name="repository">a <see cref="ILoggerRepository"/> to use for object conversion</param>
+ /// <param name="value">the value to write to the writer</param>
+ /// <remarks>
+ /// <para>
+ /// Writes the <see cref="IDictionaryEnumerator"/> to a writer in the form:
+ /// </para>
+ /// <code>
+ /// {key1=value1, key2=value2, key3=value3}
+ /// </code>
+ /// <para>
+ /// If the <see cref="ILoggerRepository"/> specified
+ /// is not null then it is used to render the key and value to text, otherwise
+ /// the object's ToString method is called.
+ /// </para>
+ /// </remarks>
+ protected static void WriteDictionary(TextWriter writer, ILoggerRepository repository, IDictionaryEnumerator value)
+ {
+ writer.Write("{");
- bool first = true;
+ bool first = true;
- // Write out all the dictionary key value pairs
- while (value.MoveNext())
- {
- if (first)
- {
- first = false;
- }
- else
- {
- writer.Write(", ");
- }
- WriteObject(writer, repository, value.Key);
- writer.Write("=");
- WriteObject(writer, repository, value.Value);
- }
+ // Write out all the dictionary key value pairs
+ while (value.MoveNext())
+ {
+ if (first)
+ {
+ first = false;
+ }
+ else
+ {
+ writer.Write(", ");
+ }
+ WriteObject(writer, repository, value.Key);
+ writer.Write("=");
+ WriteObject(writer, repository, value.Value);
+ }
- writer.Write("}");
- }
+ writer.Write("}");
+ }
- /// <summary>
- /// Write an object to a <see cref="TextWriter"/>
- /// </summary>
- /// <param name="writer">the writer to write to</param>
- /// <param name="repository">a <see cref="ILoggerRepository"/> to use for object conversion</param>
- /// <param name="value">the value to write to the writer</param>
- /// <remarks>
- /// <para>
- /// Writes the Object to a writer. If the <see cref="ILoggerRepository"/> specified
- /// is not null then it is used to render the object to text, otherwise
- /// the object's ToString method is called.
- /// </para>
- /// </remarks>
- protected static void WriteObject(TextWriter writer, ILoggerRepository repository, object value)
- {
- if (repository != null)
- {
- repository.RendererMap.FindAndRender(value, writer);
- }
- else
- {
- // Don't have a repository to render with so just have to rely on ToString
- if (value == null)
- {
- writer.Write( SystemInfo.NullText );
- }
- else
- {
- writer.Write( value.ToString() );
- }
- }
- }
+ /// <summary>
+ /// Write an object to a <see cref="TextWriter"/>
+ /// </summary>
+ /// <param name="writer">the writer to write to</param>
+ /// <param name="repository">a <see cref="ILoggerRepository"/> to use for object conversion</param>
+ /// <param name="value">the value to write to the writer</param>
+ /// <remarks>
+ /// <para>
+ /// Writes the Object to a writer. If the <see cref="ILoggerRepository"/> specified
+ /// is not null then it is used to render the object to text, otherwise
+ /// the object's ToString method is called.
+ /// </para>
+ /// </remarks>
+ protected static void WriteObject(TextWriter writer, ILoggerRepository repository, object value)
+ {
+ if (repository != null)
+ {
+ repository.RendererMap.FindAndRender(value, writer);
+ }
+ else
+ {
+ // Don't have a repository to render with so just have to rely on ToString
+ if (value == null)
+ {
+ writer.Write( SystemInfo.NullText );
+ }
+ else
+ {
+ writer.Write( value.ToString() );
+ }
+ }
+ }
- #endregion
+ #endregion
private PropertiesDictionary properties;
@@ -389,9 +389,9 @@
///
/// </summary>
public PropertiesDictionary Properties
- {
- get { return properties; }
- set { properties = value; }
- }
- }
+ {
+ get { return properties; }
+ set { properties = value; }
+ }
+ }
}
diff --git a/src/log4net/Util/PatternParser.cs b/src/log4net/Util/PatternParser.cs
index 7dfbb32..fc4c40b 100644
--- a/src/log4net/Util/PatternParser.cs
+++ b/src/log4net/Util/PatternParser.cs
@@ -26,410 +26,410 @@
namespace log4net.Util
{
- /// <summary>
- /// Most of the work of the <see cref="PatternLayout"/> class
- /// is delegated to the PatternParser class.
- /// </summary>
- /// <remarks>
- /// <para>
- /// The <c>PatternParser</c> processes a pattern string and
- /// returns a chain of <see cref="PatternConverter"/> objects.
- /// </para>
- /// </remarks>
- /// <author>Nicko Cadell</author>
- /// <author>Gert Driesen</author>
- public sealed class PatternParser
- {
- #region Public Instance Constructors
+ /// <summary>
+ /// Most of the work of the <see cref="PatternLayout"/> class
+ /// is delegated to the PatternParser class.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// The <c>PatternParser</c> processes a pattern string and
+ /// returns a chain of <see cref="PatternConverter"/> objects.
+ /// </para>
+ /// </remarks>
+ /// <author>Nicko Cadell</author>
+ /// <author>Gert Driesen</author>
+ public sealed class PatternParser
+ {
+ #region Public Instance Constructors
- /// <summary>
- /// Constructor
- /// </summary>
- /// <param name="pattern">The pattern to parse.</param>
- /// <remarks>
- /// <para>
- /// Initializes a new instance of the <see cref="PatternParser" /> class
- /// with the specified pattern string.
- /// </para>
- /// </remarks>
- public PatternParser(string pattern)
- {
- m_pattern = pattern;
- }
+ /// <summary>
+ /// Constructor
+ /// </summary>
+ /// <param name="pattern">The pattern to parse.</param>
+ /// <remarks>
+ /// <para>
+ /// Initializes a new instance of the <see cref="PatternParser" /> class
+ /// with the specified pattern string.
+ /// </para>
+ /// </remarks>
+ public PatternParser(string pattern)
+ {
+ m_pattern = pattern;
+ }
- #endregion Public Instance Constructors
+ #endregion Public Instance Constructors
- #region Public Instance Methods
+ #region Public Instance Methods
- /// <summary>
- /// Parses the pattern into a chain of pattern converters.
- /// </summary>
- /// <returns>The head of a chain of pattern converters.</returns>
- /// <remarks>
- /// <para>
- /// Parses the pattern into a chain of pattern converters.
- /// </para>
- /// </remarks>
- public PatternConverter Parse()
- {
- string[] converterNamesCache = BuildCache();
+ /// <summary>
+ /// Parses the pattern into a chain of pattern converters.
+ /// </summary>
+ /// <returns>The head of a chain of pattern converters.</returns>
+ /// <remarks>
+ /// <para>
+ /// Parses the pattern into a chain of pattern converters.
+ /// </para>
+ /// </remarks>
+ public PatternConverter Parse()
+ {
+ string[] converterNamesCache = BuildCache();
- ParseInternal(m_pattern, converterNamesCache);
+ ParseInternal(m_pattern, converterNamesCache);
- return m_head;
- }
+ return m_head;
+ }
- #endregion Public Instance Methods
+ #endregion Public Instance Methods
- #region Public Instance Properties
+ #region Public Instance Properties
- /// <summary>
- /// Get the converter registry used by this parser
- /// </summary>
- /// <value>
- /// The converter registry used by this parser
- /// </value>
- /// <remarks>
- /// <para>
- /// Get the converter registry used by this parser
- /// </para>
- /// </remarks>
- public Hashtable PatternConverters
- {
- get { return m_patternConverters; }
- }
+ /// <summary>
+ /// Get the converter registry used by this parser
+ /// </summary>
+ /// <value>
+ /// The converter registry used by this parser
+ /// </value>
+ /// <remarks>
+ /// <para>
+ /// Get the converter registry used by this parser
+ /// </para>
+ /// </remarks>
+ public Hashtable PatternConverters
+ {
+ get { return m_patternConverters; }
+ }
- #endregion Public Instance Properties
+ #endregion Public Instance Properties
- #region Private Instance Methods
+ #region Private Instance Methods
- /// <summary>
- /// Build the unified cache of converters from the static and instance maps
- /// </summary>
- /// <returns>the list of all the converter names</returns>
- /// <remarks>
- /// <para>
- /// Build the unified cache of converters from the static and instance maps
- /// </para>
- /// </remarks>
- private string[] BuildCache()
- {
- string[] converterNamesCache = new string[m_patternConverters.Keys.Count];
- m_patternConverters.Keys.CopyTo(converterNamesCache, 0);
+ /// <summary>
+ /// Build the unified cache of converters from the static and instance maps
+ /// </summary>
+ /// <returns>the list of all the converter names</returns>
+ /// <remarks>
+ /// <para>
+ /// Build the unified cache of converters from the static and instance maps
+ /// </para>
+ /// </remarks>
+ private string[] BuildCache()
+ {
+ string[] converterNamesCache = new string[m_patternConverters.Keys.Count];
+ m_patternConverters.Keys.CopyTo(converterNamesCache, 0);
- // sort array so that longer strings come first
- Array.Sort(converterNamesCache, 0, converterNamesCache.Length, StringLengthComparer.Instance);
+ // sort array so that longer strings come first
+ Array.Sort(converterNamesCache, 0, converterNamesCache.Length, StringLengthComparer.Instance);
- return converterNamesCache;
- }
+ return converterNamesCache;
+ }
- #region StringLengthComparer
+ #region StringLengthComparer
- /// <summary>
- /// Sort strings by length
- /// </summary>
- /// <remarks>
- /// <para>
- /// <see cref="IComparer" /> that orders strings by string length.
- /// The longest strings are placed first
- /// </para>
- /// </remarks>
- private sealed class StringLengthComparer : IComparer
- {
- public static readonly StringLengthComparer Instance = new StringLengthComparer();
+ /// <summary>
+ /// Sort strings by length
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// <see cref="IComparer" /> that orders strings by string length.
+ /// The longest strings are placed first
+ /// </para>
+ /// </remarks>
+ private sealed class StringLengthComparer : IComparer
+ {
+ public static readonly StringLengthComparer Instance = new StringLengthComparer();
- private StringLengthComparer()
- {
- }
+ private StringLengthComparer()
+ {
+ }
- #region Implementation of IComparer
+ #region Implementation of IComparer
- public int Compare(object x, object y)
- {
- string s1 = x as string;
- string s2 = y as string;
+ public int Compare(object x, object y)
+ {
+ string s1 = x as string;
+ string s2 = y as string;
- if (s1 == null && s2 == null)
- {
- return 0;
- }
- if (s1 == null)
- {
- return 1;
- }
- if (s2 == null)
- {
- return -1;
- }
+ if (s1 == null && s2 == null)
+ {
+ return 0;
+ }
+ if (s1 == null)
+ {
+ return 1;
+ }
+ if (s2 == null)
+ {
+ return -1;
+ }
- return s2.Length.CompareTo(s1.Length);
- }
-
- #endregion
- }
+ return s2.Length.CompareTo(s1.Length);
+ }
+
+ #endregion
+ }
- #endregion // StringLengthComparer
+ #endregion // StringLengthComparer
- /// <summary>
- /// Internal method to parse the specified pattern to find specified matches
- /// </summary>
- /// <param name="pattern">the pattern to parse</param>
- /// <param name="matches">the converter names to match in the pattern</param>
- /// <remarks>
- /// <para>
- /// The matches param must be sorted such that longer strings come before shorter ones.
- /// </para>
- /// </remarks>
- private void ParseInternal(string pattern, string[] matches)
- {
- int offset = 0;
- while(offset < pattern.Length)
- {
- int i = pattern.IndexOf('%', offset);
- if (i < 0 || i == pattern.Length - 1)
- {
- ProcessLiteral(pattern.Substring(offset));
- offset = pattern.Length;
- }
- else
- {
- if (pattern[i+1] == '%')
- {
- // Escaped
- ProcessLiteral(pattern.Substring(offset, i - offset + 1));
- offset = i + 2;
- }
- else
- {
- ProcessLiteral(pattern.Substring(offset, i - offset));
- offset = i + 1;
+ /// <summary>
+ /// Internal method to parse the specified pattern to find specified matches
+ /// </summary>
+ /// <param name="pattern">the pattern to parse</param>
+ /// <param name="matches">the converter names to match in the pattern</param>
+ /// <remarks>
+ /// <para>
+ /// The matches param must be sorted such that longer strings come before shorter ones.
+ /// </para>
+ /// </remarks>
+ private void ParseInternal(string pattern, string[] matches)
+ {
+ int offset = 0;
+ while(offset < pattern.Length)
+ {
+ int i = pattern.IndexOf('%', offset);
+ if (i < 0 || i == pattern.Length - 1)
+ {
+ ProcessLiteral(pattern.Substring(offset));
+ offset = pattern.Length;
+ }
+ else
+ {
+ if (pattern[i+1] == '%')
+ {
+ // Escaped
+ ProcessLiteral(pattern.Substring(offset, i - offset + 1));
+ offset = i + 2;
+ }
+ else
+ {
+ ProcessLiteral(pattern.Substring(offset, i - offset));
+ offset = i + 1;
- FormattingInfo formattingInfo = new FormattingInfo();
+ FormattingInfo formattingInfo = new FormattingInfo();
- // Process formatting options
+ // Process formatting options
- // Look for the align flag
- if (offset < pattern.Length)
- {
- if (pattern[offset] == '-')
- {
- // Seen align flag
- formattingInfo.LeftAlign = true;
- offset++;
- }
- }
- // Look for the minimum length
- while (offset < pattern.Length && char.IsDigit(pattern[offset]))
- {
- // Seen digit
- if (formattingInfo.Min < 0)
- {
- formattingInfo.Min = 0;
- }
+ // Look for the align flag
+ if (offset < pattern.Length)
+ {
+ if (pattern[offset] == '-')
+ {
+ // Seen align flag
+ formattingInfo.LeftAlign = true;
+ offset++;
+ }
+ }
+ // Look for the minimum length
+ while (offset < pattern.Length && char.IsDigit(pattern[offset]))
+ {
+ // Seen digit
+ if (formattingInfo.Min < 0)
+ {
+ formattingInfo.Min = 0;
+ }
- formattingInfo.Min = (formattingInfo.Min * 10) + int.Parse(pattern[offset].ToString(), NumberFormatInfo.InvariantInfo);
+ formattingInfo.Min = (formattingInfo.Min * 10) + int.Parse(pattern[offset].ToString(), NumberFormatInfo.InvariantInfo);
- offset++;
- }
- // Look for the separator between min and max
- if (offset < pattern.Length)
- {
- if (pattern[offset] == '.')
- {
- // Seen separator
- offset++;
- }
- }
- // Look for the maximum length
- while (offset < pattern.Length && char.IsDigit(pattern[offset]))
- {
- // Seen digit
- if (formattingInfo.Max == int.MaxValue)
- {
- formattingInfo.Max = 0;
- }
+ offset++;
+ }
+ // Look for the separator between min and max
+ if (offset < pattern.Length)
+ {
+ if (pattern[offset] == '.')
+ {
+ // Seen separator
+ offset++;
+ }
+ }
+ // Look for the maximum length
+ while (offset < pattern.Length && char.IsDigit(pattern[offset]))
+ {
+ // Seen digit
+ if (formattingInfo.Max == int.MaxValue)
+ {
+ formattingInfo.Max = 0;
+ }
- formattingInfo.Max = (formattingInfo.Max * 10) + int.Parse(pattern[offset].ToString(), NumberFormatInfo.InvariantInfo);
+ formattingInfo.Max = (formattingInfo.Max * 10) + int.Parse(pattern[offset].ToString(), NumberFormatInfo.InvariantInfo);
- offset++;
- }
+ offset++;
+ }
- int remainingStringLength = pattern.Length - offset;
+ int remainingStringLength = pattern.Length - offset;
- // Look for pattern
- for(int m=0; m<matches.Length; m++)
- {
- string key = matches[m];
+ // Look for pattern
+ for(int m=0; m<matches.Length; m++)
+ {
+ string key = matches[m];
- if (key.Length <= remainingStringLength)
- {
- if (string.Compare(pattern, offset, key, 0, key.Length) == 0)
- {
- // Found match
- offset = offset + matches[m].Length;
+ if (key.Length <= remainingStringLength)
+ {
+ if (string.Compare(pattern, offset, key, 0, key.Length) == 0)
+ {
+ // Found match
+ offset = offset + matches[m].Length;
- string option = null;
+ string option = null;
- // Look for option
- if (offset < pattern.Length)
- {
- if (pattern[offset] == '{')
- {
- // Seen option start
- offset++;
-
- int optEnd = pattern.IndexOf('}', offset);
- if (optEnd < 0)
- {
- // error
- }
- else
- {
- option = pattern.Substring(offset, optEnd - offset);
- offset = optEnd + 1;
- }
- }
- }
+ // Look for option
+ if (offset < pattern.Length)
+ {
+ if (pattern[offset] == '{')
+ {
+ // Seen option start
+ offset++;
+
+ int optEnd = pattern.IndexOf('}', offset);
+ if (optEnd < 0)
+ {
+ // error
+ }
+ else
+ {
+ option = pattern.Substring(offset, optEnd - offset);
+ offset = optEnd + 1;
+ }
+ }
+ }
- ProcessConverter(matches[m], option, formattingInfo);
- break;
- }
- }
- }
- }
- }
- }
- }
+ ProcessConverter(matches[m], option, formattingInfo);
+ break;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
- /// <summary>
- /// Process a parsed literal
- /// </summary>
- /// <param name="text">the literal text</param>
- private void ProcessLiteral(string text)
- {
- if (text.Length > 0)
- {
- // Convert into a pattern
- ProcessConverter("literal", text, new FormattingInfo());
- }
- }
+ /// <summary>
+ /// Process a parsed literal
+ /// </summary>
+ /// <param name="text">the literal text</param>
+ private void ProcessLiteral(string text)
+ {
+ if (text.Length > 0)
+ {
+ // Convert into a pattern
+ ProcessConverter("literal", text, new FormattingInfo());
+ }
+ }
- /// <summary>
- /// Process a parsed converter pattern
- /// </summary>
- /// <param name="converterName">the name of the converter</param>
- /// <param name="option">the optional option for the converter</param>
- /// <param name="formattingInfo">the formatting info for the converter</param>
- private void ProcessConverter(string converterName, string option, FormattingInfo formattingInfo)
- {
- LogLog.Debug(declaringType, "Converter ["+converterName+"] Option ["+option+"] Format [min="+formattingInfo.Min+",max="+formattingInfo.Max+",leftAlign="+formattingInfo.LeftAlign+"]");
+ /// <summary>
+ /// Process a parsed converter pattern
+ /// </summary>
+ /// <param name="converterName">the name of the converter</param>
+ /// <param name="option">the optional option for the converter</param>
+ /// <param name="formattingInfo">the formatting info for the converter</param>
+ private void ProcessConverter(string converterName, string option, FormattingInfo formattingInfo)
+ {
+ LogLog.Debug(declaringType, "Converter ["+converterName+"] Option ["+option+"] Format [min="+formattingInfo.Min+",max="+formattingInfo.Max+",leftAlign="+formattingInfo.LeftAlign+"]");
- // Lookup the converter type
+ // Lookup the converter type
ConverterInfo converterInfo = (ConverterInfo)m_patternConverters[converterName];
- if (converterInfo == null)
- {
- LogLog.Error(declaringType, "Unknown converter name ["+converterName+"] in conversion pattern.");
- }
- else
- {
- // Create the pattern converter
- PatternConverter pc = null;
- try
- {
+ if (converterInfo == null)
+ {
+ LogLog.Error(declaringType, "Unknown converter name ["+converterName+"] in conversion pattern.");
+ }
+ else
+ {
+ // Create the pattern converter
+ PatternConverter pc = null;
+ try
+ {
pc = (PatternConverter)Activator.CreateInstance(converterInfo.Type);
- }
- catch(Exception createInstanceEx)
- {
+ }
+ catch(Exception createInstanceEx)
+ {
LogLog.Error(declaringType, "Failed to create instance of Type [" + converterInfo.Type.FullName + "] using default constructor. Exception: " + createInstanceEx.ToString());
- }
+ }
- // formattingInfo variable is an instance variable, occasionally reset
- // and used over and over again
- pc.FormattingInfo = formattingInfo;
- pc.Option = option;
+ // formattingInfo variable is an instance variable, occasionally reset
+ // and used over and over again
+ pc.FormattingInfo = formattingInfo;
+ pc.Option = option;
pc.Properties = converterInfo.Properties;
- IOptionHandler optionHandler = pc as IOptionHandler;
- if (optionHandler != null)
- {
- optionHandler.ActivateOptions();
- }
+ IOptionHandler optionHandler = pc as IOptionHandler;
+ if (optionHandler != null)
+ {
+ optionHandler.ActivateOptions();
+ }
- AddConverter(pc);
- }
- }
+ AddConverter(pc);
+ }
+ }
- /// <summary>
- /// Resets the internal state of the parser and adds the specified pattern converter
- /// to the chain.
- /// </summary>
- /// <param name="pc">The pattern converter to add.</param>
- private void AddConverter(PatternConverter pc)
- {
- // Add the pattern converter to the list.
+ /// <summary>
+ /// Resets the internal state of the parser and adds the specified pattern converter
+ /// to the chain.
+ /// </summary>
+ /// <param name="pc">The pattern converter to add.</param>
+ private void AddConverter(PatternConverter pc)
+ {
+ // Add the pattern converter to the list.
- if (m_head == null)
- {
- m_head = m_tail = pc;
- }
- else
- {
- // Set the next converter on the tail
- // Update the tail reference
- // note that a converter may combine the 'next' into itself
- // and therefore the tail would not change!
- m_tail = m_tail.SetNext(pc);
- }
- }
+ if (m_head == null)
+ {
+ m_head = m_tail = pc;
+ }
+ else
+ {
+ // Set the next converter on the tail
+ // Update the tail reference
+ // note that a converter may combine the 'next' into itself
+ // and therefore the tail would not change!
+ m_tail = m_tail.SetNext(pc);
+ }
+ }
- #endregion Protected Instance Methods
+ #endregion Protected Instance Methods
- #region Private Constants
+ #region Private Constants
- private const char ESCAPE_CHAR = '%';
+ private const char ESCAPE_CHAR = '%';
- #endregion Private Constants
+ #endregion Private Constants
- #region Private Instance Fields
+ #region Private Instance Fields
- /// <summary>
- /// The first pattern converter in the chain
- /// </summary>
- private PatternConverter m_head;
+ /// <summary>
+ /// The first pattern converter in the chain
+ /// </summary>
+ private PatternConverter m_head;
- /// <summary>
- /// the last pattern converter in the chain
- /// </summary>
- private PatternConverter m_tail;
+ /// <summary>
+ /// the last pattern converter in the chain
+ /// </summary>
+ private PatternConverter m_tail;
- /// <summary>
- /// The pattern
- /// </summary>
- private string m_pattern;
+ /// <summary>
+ /// The pattern
+ /// </summary>
+ private string m_pattern;
- /// <summary>
- /// Internal map of converter identifiers to converter types
- /// </summary>
- /// <remarks>
- /// <para>
- /// This map overrides the static s_globalRulesRegistry map.
- /// </para>
- /// </remarks>
- private Hashtable m_patternConverters = new Hashtable();
+ /// <summary>
+ /// Internal map of converter identifiers to converter types
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// This map overrides the static s_globalRulesRegistry map.
+ /// </para>
+ /// </remarks>
+ private Hashtable m_patternConverters = new Hashtable();
- #endregion Private Instance Fields
+ #endregion Private Instance Fields
- #region Private Static Fields
+ #region Private Static Fields
- /// <summary>
- /// The fully qualified type of the PatternParser class.
- /// </summary>
- /// <remarks>
- /// Used by the internal logger to record the Type of the
- /// log message.
- /// </remarks>
- private static readonly Type declaringType = typeof(PatternParser);
+ /// <summary>
+ /// The fully qualified type of the PatternParser class.
+ /// </summary>
+ /// <remarks>
+ /// Used by the internal logger to record the Type of the
+ /// log message.
+ /// </remarks>
+ private static readonly Type declaringType = typeof(PatternParser);
- #endregion Private Static Fields
- }
+ #endregion Private Static Fields
+ }
}
diff --git a/src/log4net/Util/PatternString.cs b/src/log4net/Util/PatternString.cs
index c7d924b..cb5c446 100644
--- a/src/log4net/Util/PatternString.cs
+++ b/src/log4net/Util/PatternString.cs
@@ -26,464 +26,464 @@
namespace log4net.Util
{
- /// <summary>
- /// This class implements a patterned string.
- /// </summary>
- /// <remarks>
- /// <para>
- /// This string has embedded patterns that are resolved and expanded
- /// when the string is formatted.
- /// </para>
- /// <para>
- /// This class functions similarly to the <see cref="log4net.Layout.PatternLayout"/>
- /// in that it accepts a pattern and renders it to a string. Unlike the
- /// <see cref="log4net.Layout.PatternLayout"/> however the <c>PatternString</c>
- /// does not render the properties of a specific <see cref="LoggingEvent"/> but
- /// of the process in general.
- /// </para>
- /// <para>
- /// The recognized conversion pattern names are:
- /// </para>
- /// <list type="table">
- /// <listheader>
- /// <term>Conversion Pattern Name</term>
- /// <description>Effect</description>
- /// </listheader>
- /// <item>
- /// <term>appdomain</term>
- /// <description>
- /// <para>
- /// Used to output the friendly name of the current AppDomain.
- /// </para>
- /// </description>
- /// </item>
- /// <item>
- /// <term>appsetting</term>
- /// <description>
- /// <para>
- /// Used to output the value of a specific appSetting key in the application
- /// configuration file.
- /// </para>
- /// </description>
- /// </item>
- /// <item>
- /// <term>date</term>
- /// <description>
- /// <para>
- /// Used to output the current date and time in the local time zone.
- /// To output the date in universal time use the <c>%utcdate</c> pattern.
- /// The date conversion
- /// specifier may be followed by a <i>date format specifier</i> enclosed
- /// between braces. For example, <b>%date{HH:mm:ss,fff}</b> or
- /// <b>%date{dd MMM yyyy HH:mm:ss,fff}</b>. If no date format specifier is
- /// given then ISO8601 format is
- /// assumed (<see cref="log4net.DateFormatter.Iso8601DateFormatter"/>).
- /// </para>
- /// <para>
- /// The date format specifier admits the same syntax as the
- /// time pattern string of the <see cref="M:DateTime.ToString(string)"/>.
- /// </para>
- /// <para>
- /// For better results it is recommended to use the log4net date
- /// formatters. These can be specified using one of the strings
- /// "ABSOLUTE", "DATE" and "ISO8601" for specifying
- /// <see cref="log4net.DateFormatter.AbsoluteTimeDateFormatter"/>,
- /// <see cref="log4net.DateFormatter.DateTimeDateFormatter"/> and respectively
- /// <see cref="log4net.DateFormatter.Iso8601DateFormatter"/>. For example,
- /// <b>%date{ISO8601}</b> or <b>%date{ABSOLUTE}</b>.
- /// </para>
- /// <para>
- /// These dedicated date formatters perform significantly
- /// better than <see cref="M:DateTime.ToString(string)"/>.
- /// </para>
- /// </description>
- /// </item>
- /// <item>
- /// <term>env</term>
- /// <description>
- /// <para>
- /// Used to output the a specific environment variable. The key to
- /// lookup must be specified within braces and directly following the
- /// pattern specifier, e.g. <b>%env{COMPUTERNAME}</b> would include the value
- /// of the <c>COMPUTERNAME</c> environment variable.
- /// </para>
- /// <para>
- /// The <c>env</c> pattern is not supported on the .NET Compact Framework.
- /// </para>
- /// </description>
- /// </item>
- /// <item>
- /// <term>identity</term>
- /// <description>
- /// <para>
- /// Used to output the user name for the currently active user
- /// (Principal.Identity.Name).
- /// </para>
- /// </description>
- /// </item>
- /// <item>
- /// <term>newline</term>
- /// <description>
- /// <para>
- /// Outputs the platform dependent line separator character or
- /// characters.
- /// </para>
- /// <para>
- /// This conversion pattern name offers the same performance as using
- /// non-portable line separator strings such as "\n", or "\r\n".
- /// Thus, it is the preferred way of specifying a line separator.
- /// </para>
- /// </description>
- /// </item>
- /// <item>
- /// <term>processid</term>
- /// <description>
- /// <para>
- /// Used to output the system process ID for the current process.
- /// </para>
- /// </description>
- /// </item>
- /// <item>
- /// <term>property</term>
- /// <description>
- /// <para>
- /// Used to output a specific context property. The key to
- /// lookup must be specified within braces and directly following the
- /// pattern specifier, e.g. <b>%property{user}</b> would include the value
- /// from the property that is keyed by the string 'user'. Each property value
- /// that is to be included in the log must be specified separately.
- /// Properties are stored in logging contexts. By default
- /// the <c>log4net:HostName</c> property is set to the name of machine on
- /// which the event was originally logged.
- /// </para>
- /// <para>
- /// If no key is specified, e.g. <b>%property</b> then all the keys and their
- /// values are printed in a comma separated list.
- /// </para>
- /// <para>
- /// The properties of an event are combined from a number of different
- /// contexts. These are listed below in the order in which they are searched.
- /// </para>
- /// <list type="definition">
- /// <item>
- /// <term>the thread properties</term>
- /// <description>
- /// The <see cref="ThreadContext.Properties"/> that are set on the current
- /// thread. These properties are shared by all events logged on this thread.
- /// </description>
- /// </item>
- /// <item>
- /// <term>the global properties</term>
- /// <description>
- /// The <see cref="GlobalContext.Properties"/> that are set globally. These
- /// properties are shared by all the threads in the AppDomain.
- /// </description>
- /// </item>
- /// </list>
- /// </description>
- /// </item>
- /// <item>
- /// <term>random</term>
- /// <description>
- /// <para>
- /// Used to output a random string of characters. The string is made up of
- /// uppercase letters and numbers. By default the string is 4 characters long.
- /// The length of the string can be specified within braces directly following the
- /// pattern specifier, e.g. <b>%random{8}</b> would output an 8 character string.
- /// </para>
- /// </description>
- /// </item>
- /// <item>
- /// <term>username</term>
- /// <description>
- /// <para>
- /// Used to output the WindowsIdentity for the currently
- /// active user.
- /// </para>
- /// </description>
- /// </item>
- /// <item>
- /// <term>utcdate</term>
- /// <description>
- /// <para>
- /// Used to output the date of the logging event in universal time.
- /// The date conversion
- /// specifier may be followed by a <i>date format specifier</i> enclosed
- /// between braces. For example, <b>%utcdate{HH:mm:ss,fff}</b> or
- /// <b>%utcdate{dd MMM yyyy HH:mm:ss,fff}</b>. If no date format specifier is
- /// given then ISO8601 format is
- /// assumed (<see cref="log4net.DateFormatter.Iso8601DateFormatter"/>).
- /// </para>
- /// <para>
- /// The date format specifier admits the same syntax as the
- /// time pattern string of the <see cref="M:DateTime.ToString(string)"/>.
- /// </para>
- /// <para>
- /// For better results it is recommended to use the log4net date
- /// formatters. These can be specified using one of the strings
- /// "ABSOLUTE", "DATE" and "ISO8601" for specifying
- /// <see cref="log4net.DateFormatter.AbsoluteTimeDateFormatter"/>,
- /// <see cref="log4net.DateFormatter.DateTimeDateFormatter"/> and respectively
- /// <see cref="log4net.DateFormatter.Iso8601DateFormatter"/>. For example,
- /// <b>%utcdate{ISO8601}</b> or <b>%utcdate{ABSOLUTE}</b>.
- /// </para>
- /// <para>
- /// These dedicated date formatters perform significantly
- /// better than <see cref="M:DateTime.ToString(string)"/>.
- /// </para>
- /// </description>
- /// </item>
- /// <item>
- /// <term>%</term>
- /// <description>
- /// <para>
- /// The sequence %% outputs a single percent sign.
- /// </para>
- /// </description>
- /// </item>
- /// </list>
- /// <para>
- /// Additional pattern converters may be registered with a specific <see cref="PatternString"/>
- /// instance using <see cref="M:AddConverter(ConverterInfo)"/> or
- /// <see cref="M:AddConverter(string, Type)" />.
- /// </para>
- /// <para>
- /// See the <see cref="log4net.Layout.PatternLayout"/> for details on the
- /// <i>format modifiers</i> supported by the patterns.
- /// </para>
- /// </remarks>
- /// <author>Nicko Cadell</author>
- public class PatternString : IOptionHandler
- {
- #region Static Fields
+ /// <summary>
+ /// This class implements a patterned string.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// This string has embedded patterns that are resolved and expanded
+ /// when the string is formatted.
+ /// </para>
+ /// <para>
+ /// This class functions similarly to the <see cref="log4net.Layout.PatternLayout"/>
+ /// in that it accepts a pattern and renders it to a string. Unlike the
+ /// <see cref="log4net.Layout.PatternLayout"/> however the <c>PatternString</c>
+ /// does not render the properties of a specific <see cref="LoggingEvent"/> but
+ /// of the process in general.
+ /// </para>
+ /// <para>
+ /// The recognized conversion pattern names are:
+ /// </para>
+ /// <list type="table">
+ /// <listheader>
+ /// <term>Conversion Pattern Name</term>
+ /// <description>Effect</description>
+ /// </listheader>
+ /// <item>
+ /// <term>appdomain</term>
+ /// <description>
+ /// <para>
+ /// Used to output the friendly name of the current AppDomain.
+ /// </para>
+ /// </description>
+ /// </item>
+ /// <item>
+ /// <term>appsetting</term>
+ /// <description>
+ /// <para>
+ /// Used to output the value of a specific appSetting key in the application
+ /// configuration file.
+ /// </para>
+ /// </description>
+ /// </item>
+ /// <item>
+ /// <term>date</term>
+ /// <description>
+ /// <para>
+ /// Used to output the current date and time in the local time zone.
+ /// To output the date in universal time use the <c>%utcdate</c> pattern.
+ /// The date conversion
+ /// specifier may be followed by a <i>date format specifier</i> enclosed
+ /// between braces. For example, <b>%date{HH:mm:ss,fff}</b> or
+ /// <b>%date{dd MMM yyyy HH:mm:ss,fff}</b>. If no date format specifier is
+ /// given then ISO8601 format is
+ /// assumed (<see cref="log4net.DateFormatter.Iso8601DateFormatter"/>).
+ /// </para>
+ /// <para>
+ /// The date format specifier admits the same syntax as the
+ /// time pattern string of the <see cref="M:DateTime.ToString(string)"/>.
+ /// </para>
+ /// <para>
+ /// For better results it is recommended to use the log4net date
+ /// formatters. These can be specified using one of the strings
+ /// "ABSOLUTE", "DATE" and "ISO8601" for specifying
+ /// <see cref="log4net.DateFormatter.AbsoluteTimeDateFormatter"/>,
+ /// <see cref="log4net.DateFormatter.DateTimeDateFormatter"/> and respectively
+ /// <see cref="log4net.DateFormatter.Iso8601DateFormatter"/>. For example,
+ /// <b>%date{ISO8601}</b> or <b>%date{ABSOLUTE}</b>.
+ /// </para>
+ /// <para>
+ /// These dedicated date formatters perform significantly
+ /// better than <see cref="M:DateTime.ToString(string)"/>.
+ /// </para>
+ /// </description>
+ /// </item>
+ /// <item>
+ /// <term>env</term>
+ /// <description>
+ /// <para>
+ /// Used to output the a specific environment variable. The key to
+ /// lookup must be specified within braces and directly following the
+ /// pattern specifier, e.g. <b>%env{COMPUTERNAME}</b> would include the value
+ /// of the <c>COMPUTERNAME</c> environment variable.
+ /// </para>
+ /// <para>
+ /// The <c>env</c> pattern is not supported on the .NET Compact Framework.
+ /// </para>
+ /// </description>
+ /// </item>
+ /// <item>
+ /// <term>identity</term>
+ /// <description>
+ /// <para>
+ /// Used to output the user name for the currently active user
+ /// (Principal.Identity.Name).
+ /// </para>
+ /// </description>
+ /// </item>
+ /// <item>
+ /// <term>newline</term>
+ /// <description>
+ /// <para>
+ /// Outputs the platform dependent line separator character or
+ /// characters.
+ /// </para>
+ /// <para>
+ /// This conversion pattern name offers the same performance as using
+ /// non-portable line separator strings such as "\n", or "\r\n".
+ /// Thus, it is the preferred way of specifying a line separator.
+ /// </para>
+ /// </description>
+ /// </item>
+ /// <item>
+ /// <term>processid</term>
+ /// <description>
+ /// <para>
+ /// Used to output the system process ID for the current process.
+ /// </para>
+ /// </description>
+ /// </item>
+ /// <item>
+ /// <term>property</term>
+ /// <description>
+ /// <para>
+ /// Used to output a specific context property. The key to
+ /// lookup must be specified within braces and directly following the
+ /// pattern specifier, e.g. <b>%property{user}</b> would include the value
+ /// from the property that is keyed by the string 'user'. Each property value
+ /// that is to be included in the log must be specified separately.
+ /// Properties are stored in logging contexts. By default
+ /// the <c>log4net:HostName</c> property is set to the name of machine on
+ /// which the event was originally logged.
+ /// </para>
+ /// <para>
+ /// If no key is specified, e.g. <b>%property</b> then all the keys and their
+ /// values are printed in a comma separated list.
+ /// </para>
+ /// <para>
+ /// The properties of an event are combined from a number of different
+ /// contexts. These are listed below in the order in which they are searched.
+ /// </para>
+ /// <list type="definition">
+ /// <item>
+ /// <term>the thread properties</term>
+ /// <description>
+ /// The <see cref="ThreadContext.Properties"/> that are set on the current
+ /// thread. These properties are shared by all events logged on this thread.
+ /// </description>
+ /// </item>
+ /// <item>
+ /// <term>the global properties</term>
+ /// <description>
+ /// The <see cref="GlobalContext.Properties"/> that are set globally. These
+ /// properties are shared by all the threads in the AppDomain.
+ /// </description>
+ /// </item>
+ /// </list>
+ /// </description>
+ /// </item>
+ /// <item>
+ /// <term>random</term>
+ /// <description>
+ /// <para>
+ /// Used to output a random string of characters. The string is made up of
+ /// uppercase letters and numbers. By default the string is 4 characters long.
+ /// The length of the string can be specified within braces directly following the
+ /// pattern specifier, e.g. <b>%random{8}</b> would output an 8 character string.
+ /// </para>
+ /// </description>
+ /// </item>
+ /// <item>
+ /// <term>username</term>
+ /// <description>
+ /// <para>
+ /// Used to output the WindowsIdentity for the currently
+ /// active user.
+ /// </para>
+ /// </description>
+ /// </item>
+ /// <item>
+ /// <term>utcdate</term>
+ /// <description>
+ /// <para>
+ /// Used to output the date of the logging event in universal time.
+ /// The date conversion
+ /// specifier may be followed by a <i>date format specifier</i> enclosed
+ /// between braces. For example, <b>%utcdate{HH:mm:ss,fff}</b> or
+ /// <b>%utcdate{dd MMM yyyy HH:mm:ss,fff}</b>. If no date format specifier is
+ /// given then ISO8601 format is
+ /// assumed (<see cref="log4net.DateFormatter.Iso8601DateFormatter"/>).
+ /// </para>
+ /// <para>
+ /// The date format specifier admits the same syntax as the
+ /// time pattern string of the <see cref="M:DateTime.ToString(string)"/>.
+ /// </para>
+ /// <para>
+ /// For better results it is recommended to use the log4net date
+ /// formatters. These can be specified using one of the strings
+ /// "ABSOLUTE", "DATE" and "ISO8601" for specifying
+ /// <see cref="log4net.DateFormatter.AbsoluteTimeDateFormatter"/>,
+ /// <see cref="log4net.DateFormatter.DateTimeDateFormatter"/> and respectively
+ /// <see cref="log4net.DateFormatter.Iso8601DateFormatter"/>. For example,
+ /// <b>%utcdate{ISO8601}</b> or <b>%utcdate{ABSOLUTE}</b>.
+ /// </para>
+ /// <para>
+ /// These dedicated date formatters perform significantly
+ /// better than <see cref="M:DateTime.ToString(string)"/>.
+ /// </para>
+ /// </description>
+ /// </item>
+ /// <item>
+ /// <term>%</term>
+ /// <description>
+ /// <para>
+ /// The sequence %% outputs a single percent sign.
+ /// </para>
+ /// </description>
+ /// </item>
+ /// </list>
+ /// <para>
+ /// Additional pattern converters may be registered with a specific <see cref="PatternString"/>
+ /// instance using <see cref="M:AddConverter(ConverterInfo)"/> or
+ /// <see cref="M:AddConverter(string, Type)" />.
+ /// </para>
+ /// <para>
+ /// See the <see cref="log4net.Layout.PatternLayout"/> for details on the
+ /// <i>format modifiers</i> supported by the patterns.
+ /// </para>
+ /// </remarks>
+ /// <author>Nicko Cadell</author>
+ public class PatternString : IOptionHandler
+ {
+ #region Static Fields
- /// <summary>
- /// Internal map of converter identifiers to converter types.
- /// </summary>
- private static Hashtable s_globalRulesRegistry;
+ /// <summary>
+ /// Internal map of converter identifiers to converter types.
+ /// </summary>
+ private static Hashtable s_globalRulesRegistry;
- #endregion Static Fields
+ #endregion Static Fields
- #region Member Variables
+ #region Member Variables
- /// <summary>
- /// the pattern
- /// </summary>
- private string m_pattern;
+ /// <summary>
+ /// the pattern
+ /// </summary>
+ private string m_pattern;
- /// <summary>
- /// the head of the pattern converter chain
- /// </summary>
- private PatternConverter m_head;
+ /// <summary>
+ /// the head of the pattern converter chain
+ /// </summary>
+ private PatternConverter m_head;
- /// <summary>
- /// patterns defined on this PatternString only
- /// </summary>
- private Hashtable m_instanceRulesRegistry = new Hashtable();
+ /// <summary>
+ /// patterns defined on this PatternString only
+ /// </summary>
+ private Hashtable m_instanceRulesRegistry = new Hashtable();
- #endregion
+ #endregion
- #region Static Constructor
+ #region Static Constructor
- /// <summary>
- /// Initialize the global registry
- /// </summary>
- static PatternString()
- {
- s_globalRulesRegistry = new Hashtable(18);
+ /// <summary>
+ /// Initialize the global registry
+ /// </summary>
+ static PatternString()
+ {
+ s_globalRulesRegistry = new Hashtable(18);
- s_globalRulesRegistry.Add("appdomain", typeof(AppDomainPatternConverter));
- s_globalRulesRegistry.Add("date", typeof(DatePatternConverter));
+ s_globalRulesRegistry.Add("appdomain", typeof(AppDomainPatternConverter));
+ s_globalRulesRegistry.Add("date", typeof(DatePatternConverter));
#if !NETCF
- s_globalRulesRegistry.Add("env", typeof(EnvironmentPatternConverter));
+ s_globalRulesRegistry.Add("env", typeof(EnvironmentPatternConverter));
#if !NETSTANDARD1_3 // EnvironmentFolderPathPatternConverter not yet supported
- s_globalRulesRegistry.Add("envFolderPath", typeof(EnvironmentFolderPathPatternConverter));
+ s_globalRulesRegistry.Add("envFolderPath", typeof(EnvironmentFolderPathPatternConverter));
#endif
#endif
- s_globalRulesRegistry.Add("identity", typeof(IdentityPatternConverter));
- s_globalRulesRegistry.Add("literal", typeof(LiteralPatternConverter));
- s_globalRulesRegistry.Add("newline", typeof(NewLinePatternConverter));
- s_globalRulesRegistry.Add("processid", typeof(ProcessIdPatternConverter));
- s_globalRulesRegistry.Add("property", typeof(PropertyPatternConverter));
- s_globalRulesRegistry.Add("random", typeof(RandomStringPatternConverter));
- s_globalRulesRegistry.Add("username", typeof(UserNamePatternConverter));
+ s_globalRulesRegistry.Add("identity", typeof(IdentityPatternConverter));
+ s_globalRulesRegistry.Add("literal", typeof(LiteralPatternConverter));
+ s_globalRulesRegistry.Add("newline", typeof(NewLinePatternConverter));
+ s_globalRulesRegistry.Add("processid", typeof(ProcessIdPatternConverter));
+ s_globalRulesRegistry.Add("property", typeof(PropertyPatternConverter));
+ s_globalRulesRegistry.Add("random", typeof(RandomStringPatternConverter));
+ s_globalRulesRegistry.Add("username", typeof(UserNamePatternConverter));
- s_globalRulesRegistry.Add("utcdate", typeof(UtcDatePatternConverter));
- s_globalRulesRegistry.Add("utcDate", typeof(UtcDatePatternConverter));
- s_globalRulesRegistry.Add("UtcDate", typeof(UtcDatePatternConverter));
+ s_globalRulesRegistry.Add("utcdate", typeof(UtcDatePatternConverter));
+ s_globalRulesRegistry.Add("utcDate", typeof(UtcDatePatternConverter));
+ s_globalRulesRegistry.Add("UtcDate", typeof(UtcDatePatternConverter));
#if !NETCF && !NETSTANDARD1_3
- // TODO - have added common variants of casing like utcdate above.
- // Wouldn't it be better to use a case-insensitive Hashtable?
- s_globalRulesRegistry.Add("appsetting", typeof(AppSettingPatternConverter));
- s_globalRulesRegistry.Add("appSetting", typeof(AppSettingPatternConverter));
- s_globalRulesRegistry.Add("AppSetting", typeof(AppSettingPatternConverter));
+ // TODO - have added common variants of casing like utcdate above.
+ // Wouldn't it be better to use a case-insensitive Hashtable?
+ s_globalRulesRegistry.Add("appsetting", typeof(AppSettingPatternConverter));
+ s_globalRulesRegistry.Add("appSetting", typeof(AppSettingPatternConverter));
+ s_globalRulesRegistry.Add("AppSetting", typeof(AppSettingPatternConverter));
#endif
- }
+ }
- #endregion Static Constructor
+ #endregion Static Constructor
- #region Constructors
+ #region Constructors
- /// <summary>
- /// Default constructor
- /// </summary>
- /// <remarks>
- /// <para>
- /// Initialize a new instance of <see cref="PatternString"/>
- /// </para>
- /// </remarks>
- public PatternString()
- {
- }
+ /// <summary>
+ /// Default constructor
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Initialize a new instance of <see cref="PatternString"/>
+ /// </para>
+ /// </remarks>
+ public PatternString()
+ {
+ }
- /// <summary>
- /// Constructs a PatternString
- /// </summary>
- /// <param name="pattern">The pattern to use with this PatternString</param>
- /// <remarks>
- /// <para>
- /// Initialize a new instance of <see cref="PatternString"/> with the pattern specified.
- /// </para>
- /// </remarks>
- public PatternString(string pattern)
- {
- m_pattern = pattern;
- ActivateOptions();
- }
+ /// <summary>
+ /// Constructs a PatternString
+ /// </summary>
+ /// <param name="pattern">The pattern to use with this PatternString</param>
+ /// <remarks>
+ /// <para>
+ /// Initialize a new instance of <see cref="PatternString"/> with the pattern specified.
+ /// </para>
+ /// </remarks>
+ public PatternString(string pattern)
+ {
+ m_pattern = pattern;
+ ActivateOptions();
+ }
- #endregion
+ #endregion
- /// <summary>
- /// Gets or sets the pattern formatting string
- /// </summary>
- /// <value>
- /// The pattern formatting string
- /// </value>
- /// <remarks>
- /// <para>
- /// The <b>ConversionPattern</b> option. This is the string which
- /// controls formatting and consists of a mix of literal content and
- /// conversion specifiers.
- /// </para>
- /// </remarks>
- public string ConversionPattern
- {
- get { return m_pattern; }
- set { m_pattern = value; }
- }
+ /// <summary>
+ /// Gets or sets the pattern formatting string
+ /// </summary>
+ /// <value>
+ /// The pattern formatting string
+ /// </value>
+ /// <remarks>
+ /// <para>
+ /// The <b>ConversionPattern</b> option. This is the string which
+ /// controls formatting and consists of a mix of literal content and
+ /// conversion specifiers.
+ /// </para>
+ /// </remarks>
+ public string ConversionPattern
+ {
+ get { return m_pattern; }
+ set { m_pattern = value; }
+ }
- #region Implementation of IOptionHandler
+ #region Implementation of IOptionHandler
- /// <summary>
- /// Initialize object options
- /// </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>
- public virtual void ActivateOptions()
- {
- m_head = CreatePatternParser(m_pattern).Parse();
- }
+ /// <summary>
+ /// Initialize object options
+ /// </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>
+ public virtual void ActivateOptions()
+ {
+ m_head = CreatePatternParser(m_pattern).Parse();
+ }
- #endregion
+ #endregion
- /// <summary>
- /// Create the <see cref="PatternParser"/> used to parse the pattern
- /// </summary>
- /// <param name="pattern">the pattern to parse</param>
- /// <returns>The <see cref="PatternParser"/></returns>
- /// <remarks>
- /// <para>
- /// Returns PatternParser used to parse the conversion string. Subclasses
- /// may override this to return a subclass of PatternParser which recognize
- /// custom conversion pattern name.
- /// </para>
- /// </remarks>
- private PatternParser CreatePatternParser(string pattern)
- {
- PatternParser patternParser = new PatternParser(pattern);
+ /// <summary>
+ /// Create the <see cref="PatternParser"/> used to parse the pattern
+ /// </summary>
+ /// <param name="pattern">the pattern to parse</param>
+ /// <returns>The <see cref="PatternParser"/></returns>
+ /// <remarks>
+ /// <para>
+ /// Returns PatternParser used to parse the conversion string. Subclasses
+ /// may override this to return a subclass of PatternParser which recognize
+ /// custom conversion pattern name.
+ /// </para>
+ /// </remarks>
+ private PatternParser CreatePatternParser(string pattern)
+ {
+ PatternParser patternParser = new PatternParser(pattern);
- // Add all the builtin patterns
- foreach(DictionaryEntry entry in s_globalRulesRegistry)
- {
+ // Add all the builtin patterns
+ foreach(DictionaryEntry entry in s_globalRulesRegistry)
+ {
ConverterInfo converterInfo = new ConverterInfo();
converterInfo.Name = (string)entry.Key;
converterInfo.Type = (Type)entry.Value;
patternParser.PatternConverters.Add(entry.Key, converterInfo);
- }
- // Add the instance patterns
- foreach(DictionaryEntry entry in m_instanceRulesRegistry)
- {
- patternParser.PatternConverters[entry.Key] = entry.Value;
- }
+ }
+ // Add the instance patterns
+ foreach(DictionaryEntry entry in m_instanceRulesRegistry)
+ {
+ patternParser.PatternConverters[entry.Key] = entry.Value;
+ }
- return patternParser;
- }
+ return patternParser;
+ }
- /// <summary>
- /// Produces a formatted string as specified by the conversion pattern.
- /// </summary>
- /// <param name="writer">The TextWriter to write the formatted event to</param>
- /// <remarks>
- /// <para>
- /// Format the pattern to the <paramref name="writer"/>.
- /// </para>
- /// </remarks>
- public void Format(TextWriter writer)
- {
- if (writer == null)
- {
- throw new ArgumentNullException("writer");
- }
+ /// <summary>
+ /// Produces a formatted string as specified by the conversion pattern.
+ /// </summary>
+ /// <param name="writer">The TextWriter to write the formatted event to</param>
+ /// <remarks>
+ /// <para>
+ /// Format the pattern to the <paramref name="writer"/>.
+ /// </para>
+ /// </remarks>
+ public void Format(TextWriter writer)
+ {
+ if (writer == null)
+ {
+ throw new ArgumentNullException("writer");
+ }
- PatternConverter c = m_head;
+ PatternConverter c = m_head;
- // loop through the chain of pattern converters
- while(c != null)
- {
- c.Format(writer, null);
- c = c.Next;
- }
- }
+ // loop through the chain of pattern converters
+ while(c != null)
+ {
+ c.Format(writer, null);
+ c = c.Next;
+ }
+ }
- /// <summary>
- /// Format the pattern as a string
- /// </summary>
- /// <returns>the pattern formatted as a string</returns>
- /// <remarks>
- /// <para>
- /// Format the pattern to a string.
- /// </para>
- /// </remarks>
- public string Format()
- {
- using StringWriter writer = new StringWriter(System.Globalization.CultureInfo.InvariantCulture);
- Format(writer);
- return writer.ToString();
- }
+ /// <summary>
+ /// Format the pattern as a string
+ /// </summary>
+ /// <returns>the pattern formatted as a string</returns>
+ /// <remarks>
+ /// <para>
+ /// Format the pattern to a string.
+ /// </para>
+ /// </remarks>
+ public string Format()
+ {
+ using StringWriter writer = new StringWriter(System.Globalization.CultureInfo.InvariantCulture);
+ Format(writer);
+ return writer.ToString();
+ }
- /// <summary>
- /// Add a converter to this PatternString
- /// </summary>
- /// <param name="converterInfo">the converter info</param>
- /// <remarks>
- /// <para>
- /// This version of the method is used by the configurator.
- /// Programmatic users should use the alternative <see cref="M:AddConverter(string,Type)"/> method.
- /// </para>
- /// </remarks>
- public void AddConverter(ConverterInfo converterInfo)
- {
+ /// <summary>
+ /// Add a converter to this PatternString
+ /// </summary>
+ /// <param name="converterInfo">the converter info</param>
+ /// <remarks>
+ /// <para>
+ /// This version of the method is used by the configurator.
+ /// Programmatic users should use the alternative <see cref="M:AddConverter(string,Type)"/> method.
+ /// </para>
+ /// </remarks>
+ public void AddConverter(ConverterInfo converterInfo)
+ {
if (converterInfo == null) throw new ArgumentNullException("converterInfo");
if (!typeof(PatternConverter).IsAssignableFrom(converterInfo.Type))
@@ -491,28 +491,28 @@
throw new ArgumentException("The converter type specified [" + converterInfo.Type + "] must be a subclass of log4net.Util.PatternConverter", "converterInfo");
}
m_instanceRulesRegistry[converterInfo.Name] = converterInfo;
- }
+ }
- /// <summary>
- /// Add a converter to this PatternString
- /// </summary>
- /// <param name="name">the name of the conversion pattern for this converter</param>
- /// <param name="type">the type of the converter</param>
- /// <remarks>
- /// <para>
- /// Add a converter to this PatternString
- /// </para>
- /// </remarks>
- public void AddConverter(string name, Type type)
- {
- if (name == null) throw new ArgumentNullException("name");
- if (type == null) throw new ArgumentNullException("type");
+ /// <summary>
+ /// Add a converter to this PatternString
+ /// </summary>
+ /// <param name="name">the name of the conversion pattern for this converter</param>
+ /// <param name="type">the type of the converter</param>
+ /// <remarks>
+ /// <para>
+ /// Add a converter to this PatternString
+ /// </para>
+ /// </remarks>
+ public void AddConverter(string name, Type type)
+ {
+ if (name == null) throw new ArgumentNullException("name");
+ if (type == null) throw new ArgumentNullException("type");
ConverterInfo converterInfo = new ConverterInfo();
converterInfo.Name = name;
converterInfo.Type = type;
AddConverter(converterInfo);
- }
- }
+ }
+ }
}
diff --git a/src/log4net/Util/PatternStringConverters/AppDomainPatternConverter.cs b/src/log4net/Util/PatternStringConverters/AppDomainPatternConverter.cs
index 9a20d65..a874299 100644
--- a/src/log4net/Util/PatternStringConverters/AppDomainPatternConverter.cs
+++ b/src/log4net/Util/PatternStringConverters/AppDomainPatternConverter.cs
@@ -25,30 +25,30 @@
namespace log4net.Util.PatternStringConverters
{
- /// <summary>
- /// Write the name of the current AppDomain to the output
- /// </summary>
- /// <remarks>
- /// <para>
- /// Write the name of the current AppDomain to the output writer
- /// </para>
- /// </remarks>
- /// <author>Nicko Cadell</author>
- internal sealed class AppDomainPatternConverter : PatternConverter
- {
- /// <summary>
- /// Write the name of the current AppDomain to the output
- /// </summary>
- /// <param name="writer">the writer to write to</param>
- /// <param name="state">null, state is not set</param>
- /// <remarks>
- /// <para>
- /// Writes name of the current AppDomain to the output <paramref name="writer"/>.
- /// </para>
- /// </remarks>
- protected override void Convert(TextWriter writer, object state)
- {
- writer.Write( SystemInfo.ApplicationFriendlyName );
- }
- }
+ /// <summary>
+ /// Write the name of the current AppDomain to the output
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Write the name of the current AppDomain to the output writer
+ /// </para>
+ /// </remarks>
+ /// <author>Nicko Cadell</author>
+ internal sealed class AppDomainPatternConverter : PatternConverter
+ {
+ /// <summary>
+ /// Write the name of the current AppDomain to the output
+ /// </summary>
+ /// <param name="writer">the writer to write to</param>
+ /// <param name="state">null, state is not set</param>
+ /// <remarks>
+ /// <para>
+ /// Writes name of the current AppDomain to the output <paramref name="writer"/>.
+ /// </para>
+ /// </remarks>
+ protected override void Convert(TextWriter writer, object state)
+ {
+ writer.Write( SystemInfo.ApplicationFriendlyName );
+ }
+ }
}
diff --git a/src/log4net/Util/PatternStringConverters/DatePatternConverter.cs b/src/log4net/Util/PatternStringConverters/DatePatternConverter.cs
index 40ffd77..315ce0a 100644
--- a/src/log4net/Util/PatternStringConverters/DatePatternConverter.cs
+++ b/src/log4net/Util/PatternStringConverters/DatePatternConverter.cs
@@ -25,165 +25,165 @@
namespace log4net.Util.PatternStringConverters
{
- /// <summary>
- /// Write the current date to the output
- /// </summary>
- /// <remarks>
- /// <para>
- /// Date pattern converter, uses a <see cref="IDateFormatter"/> to format
- /// the current date and time to the writer as a string.
- /// </para>
- /// <para>
- /// The value of the <see cref="log4net.Util.PatternConverter.Option"/> determines
- /// the formatting of the date. The following values are allowed:
- /// <list type="definition">
- /// <listheader>
- /// <term>Option value</term>
- /// <description>Output</description>
- /// </listheader>
- /// <item>
- /// <term>ISO8601</term>
- /// <description>
- /// Uses the <see cref="Iso8601DateFormatter"/> formatter.
- /// Formats using the <c>"yyyy-MM-dd HH:mm:ss,fff"</c> pattern.
- /// </description>
- /// </item>
- /// <item>
- /// <term>DATE</term>
- /// <description>
- /// Uses the <see cref="DateTimeDateFormatter"/> formatter.
- /// Formats using the <c>"dd MMM yyyy HH:mm:ss,fff"</c> for example, <c>"06 Nov 1994 15:49:37,459"</c>.
- /// </description>
- /// </item>
- /// <item>
- /// <term>ABSOLUTE</term>
- /// <description>
- /// Uses the <see cref="AbsoluteTimeDateFormatter"/> formatter.
- /// Formats using the <c>"HH:mm:ss,fff"</c> for example, <c>"15:49:37,459"</c>.
- /// </description>
- /// </item>
- /// <item>
- /// <term>other</term>
- /// <description>
- /// Any other pattern string uses the <see cref="SimpleDateFormatter"/> formatter.
- /// This formatter passes the pattern string to the <see cref="DateTime"/>
- /// <see cref="M:DateTime.ToString(string)"/> method.
- /// For details on valid patterns see
- /// <a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemglobalizationdatetimeformatinfoclasstopic.asp">DateTimeFormatInfo Class</a>.
- /// </description>
- /// </item>
- /// </list>
- /// </para>
- /// <para>
- /// The date and time is in the local time zone and is rendered in that zone.
- /// To output the time in Universal time see <see cref="UtcDatePatternConverter"/>.
- /// </para>
- /// </remarks>
- /// <author>Nicko Cadell</author>
- internal class DatePatternConverter : PatternConverter, IOptionHandler
- {
- /// <summary>
- /// The <see cref="IDateFormatter"/> used to render the date to a string
- /// </summary>
- /// <remarks>
- /// <para>
- /// The <see cref="IDateFormatter"/> used to render the date to a string
- /// </para>
- /// </remarks>
- protected IDateFormatter m_dateFormatter;
-
- #region Implementation of IOptionHandler
+ /// <summary>
+ /// Write the current date to the output
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Date pattern converter, uses a <see cref="IDateFormatter"/> to format
+ /// the current date and time to the writer as a string.
+ /// </para>
+ /// <para>
+ /// The value of the <see cref="log4net.Util.PatternConverter.Option"/> determines
+ /// the formatting of the date. The following values are allowed:
+ /// <list type="definition">
+ /// <listheader>
+ /// <term>Option value</term>
+ /// <description>Output</description>
+ /// </listheader>
+ /// <item>
+ /// <term>ISO8601</term>
+ /// <description>
+ /// Uses the <see cref="Iso8601DateFormatter"/> formatter.
+ /// Formats using the <c>"yyyy-MM-dd HH:mm:ss,fff"</c> pattern.
+ /// </description>
+ /// </item>
+ /// <item>
+ /// <term>DATE</term>
+ /// <description>
+ /// Uses the <see cref="DateTimeDateFormatter"/> formatter.
+ /// Formats using the <c>"dd MMM yyyy HH:mm:ss,fff"</c> for example, <c>"06 Nov 1994 15:49:37,459"</c>.
+ /// </description>
+ /// </item>
+ /// <item>
+ /// <term>ABSOLUTE</term>
+ /// <description>
+ /// Uses the <see cref="AbsoluteTimeDateFormatter"/> formatter.
+ /// Formats using the <c>"HH:mm:ss,fff"</c> for example, <c>"15:49:37,459"</c>.
+ /// </description>
+ /// </item>
+ /// <item>
+ /// <term>other</term>
+ /// <description>
+ /// Any other pattern string uses the <see cref="SimpleDateFormatter"/> formatter.
+ /// This formatter passes the pattern string to the <see cref="DateTime"/>
+ /// <see cref="M:DateTime.ToString(string)"/> method.
+ /// For details on valid patterns see
+ /// <a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemglobalizationdatetimeformatinfoclasstopic.asp">DateTimeFormatInfo Class</a>.
+ /// </description>
+ /// </item>
+ /// </list>
+ /// </para>
+ /// <para>
+ /// The date and time is in the local time zone and is rendered in that zone.
+ /// To output the time in Universal time see <see cref="UtcDatePatternConverter"/>.
+ /// </para>
+ /// </remarks>
+ /// <author>Nicko Cadell</author>
+ internal class DatePatternConverter : PatternConverter, IOptionHandler
+ {
+ /// <summary>
+ /// The <see cref="IDateFormatter"/> used to render the date to a string
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// The <see cref="IDateFormatter"/> used to render the date to a string
+ /// </para>
+ /// </remarks>
+ protected IDateFormatter m_dateFormatter;
+
+ #region Implementation of IOptionHandler
- /// <summary>
- /// Initialize the converter options
- /// </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>
- public void ActivateOptions()
- {
- string dateFormatStr = Option;
+ /// <summary>
+ /// Initialize the converter options
+ /// </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>
+ public void ActivateOptions()
+ {
+ string dateFormatStr = Option;
- if (dateFormatStr == null)
- {
- dateFormatStr = AbsoluteTimeDateFormatter.Iso8601TimeDateFormat;
- }
-
- if (SystemInfo.EqualsIgnoringCase(dateFormatStr, AbsoluteTimeDateFormatter.Iso8601TimeDateFormat))
- {
- m_dateFormatter = new Iso8601DateFormatter();
- }
- else if (SystemInfo.EqualsIgnoringCase(dateFormatStr, AbsoluteTimeDateFormatter.AbsoluteTimeDateFormat))
- {
- m_dateFormatter = new AbsoluteTimeDateFormatter();
- }
- else if (SystemInfo.EqualsIgnoringCase(dateFormatStr, AbsoluteTimeDateFormatter.DateAndTimeDateFormat))
- {
- m_dateFormatter = new DateTimeDateFormatter();
- }
- else
- {
- try
- {
- m_dateFormatter = new SimpleDateFormatter(dateFormatStr);
- }
- catch (Exception e)
- {
- LogLog.Error(declaringType, "Could not instantiate SimpleDateFormatter with ["+dateFormatStr+"]", e);
- m_dateFormatter = new Iso8601DateFormatter();
- }
- }
- }
+ if (dateFormatStr == null)
+ {
+ dateFormatStr = AbsoluteTimeDateFormatter.Iso8601TimeDateFormat;
+ }
+
+ if (SystemInfo.EqualsIgnoringCase(dateFormatStr, AbsoluteTimeDateFormatter.Iso8601TimeDateFormat))
+ {
+ m_dateFormatter = new Iso8601DateFormatter();
+ }
+ else if (SystemInfo.EqualsIgnoringCase(dateFormatStr, AbsoluteTimeDateFormatter.AbsoluteTimeDateFormat))
+ {
+ m_dateFormatter = new AbsoluteTimeDateFormatter();
+ }
+ else if (SystemInfo.EqualsIgnoringCase(dateFormatStr, AbsoluteTimeDateFormatter.DateAndTimeDateFormat))
+ {
+ m_dateFormatter = new DateTimeDateFormatter();
+ }
+ else
+ {
+ try
+ {
+ m_dateFormatter = new SimpleDateFormatter(dateFormatStr);
+ }
+ catch (Exception e)
+ {
+ LogLog.Error(declaringType, "Could not instantiate SimpleDateFormatter with ["+dateFormatStr+"]", e);
+ m_dateFormatter = new Iso8601DateFormatter();
+ }
+ }
+ }
- #endregion
+ #endregion
- /// <summary>
- /// Write the current date to the output
- /// </summary>
- /// <param name="writer"><see cref="TextWriter" /> that will receive the formatted result.</param>
- /// <param name="state">null, state is not set</param>
- /// <remarks>
- /// <para>
- /// Pass the current date and time to the <see cref="IDateFormatter"/>
- /// for it to render it to the writer.
- /// </para>
- /// <para>
- /// The date and time passed is in the local time zone.
- /// </para>
- /// </remarks>
- protected override void Convert(TextWriter writer, object state)
- {
- try
- {
- m_dateFormatter.FormatDate(DateTime.Now, writer);
- }
- catch (Exception ex)
- {
- LogLog.Error(declaringType, "Error occurred while converting date.", ex);
- }
- }
+ /// <summary>
+ /// Write the current date to the output
+ /// </summary>
+ /// <param name="writer"><see cref="TextWriter" /> that will receive the formatted result.</param>
+ /// <param name="state">null, state is not set</param>
+ /// <remarks>
+ /// <para>
+ /// Pass the current date and time to the <see cref="IDateFormatter"/>
+ /// for it to render it to the writer.
+ /// </para>
+ /// <para>
+ /// The date and time passed is in the local time zone.
+ /// </para>
+ /// </remarks>
+ protected override void Convert(TextWriter writer, object state)
+ {
+ try
+ {
+ m_dateFormatter.FormatDate(DateTime.Now, writer);
+ }
+ catch (Exception ex)
+ {
+ LogLog.Error(declaringType, "Error occurred while converting date.", ex);
+ }
+ }
- #region Private Static Fields
+ #region Private Static Fields
- /// <summary>
- /// The fully qualified type of the DatePatternConverter class.
- /// </summary>
- /// <remarks>
- /// Used by the internal logger to record the Type of the
- /// log message.
- /// </remarks>
- private static readonly Type declaringType = typeof(DatePatternConverter);
+ /// <summary>
+ /// The fully qualified type of the DatePatternConverter class.
+ /// </summary>
+ /// <remarks>
+ /// Used by the internal logger to record the Type of the
+ /// log message.
+ /// </remarks>
+ private static readonly Type declaringType = typeof(DatePatternConverter);
- #endregion Private Static Fields
- }
+ #endregion Private Static Fields
+ }
}
diff --git a/src/log4net/Util/PatternStringConverters/EnvironmentPatternConverter.cs b/src/log4net/Util/PatternStringConverters/EnvironmentPatternConverter.cs
index 7085129..8b011a5 100644
--- a/src/log4net/Util/PatternStringConverters/EnvironmentPatternConverter.cs
+++ b/src/log4net/Util/PatternStringConverters/EnvironmentPatternConverter.cs
@@ -25,87 +25,87 @@
namespace log4net.Util.PatternStringConverters
{
- /// <summary>
- /// Write an environment variable to the output
- /// </summary>
- /// <remarks>
- /// <para>
- /// Write an environment variable to the output writer.
- /// The value of the <see cref="log4net.Util.PatternConverter.Option"/> determines
- /// the name of the variable to output.
- /// </para>
- /// </remarks>
- /// <author>Nicko Cadell</author>
- internal sealed class EnvironmentPatternConverter : PatternConverter
- {
- /// <summary>
- /// Write an environment variable to the output
- /// </summary>
- /// <param name="writer">the writer to write to</param>
- /// <param name="state">null, state is not set</param>
- /// <remarks>
- /// <para>
- /// Writes the environment variable to the output <paramref name="writer"/>.
- /// The name of the environment variable to output must be set
- /// using the <see cref="log4net.Util.PatternConverter.Option"/>
- /// property.
- /// </para>
- /// </remarks>
- protected override void Convert(TextWriter writer, object state)
- {
- try
- {
- if (this.Option != null && this.Option.Length > 0)
- {
- // Lookup the environment variable
- string envValue = Environment.GetEnvironmentVariable(this.Option);
+ /// <summary>
+ /// Write an environment variable to the output
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Write an environment variable to the output writer.
+ /// The value of the <see cref="log4net.Util.PatternConverter.Option"/> determines
+ /// the name of the variable to output.
+ /// </para>
+ /// </remarks>
+ /// <author>Nicko Cadell</author>
+ internal sealed class EnvironmentPatternConverter : PatternConverter
+ {
+ /// <summary>
+ /// Write an environment variable to the output
+ /// </summary>
+ /// <param name="writer">the writer to write to</param>
+ /// <param name="state">null, state is not set</param>
+ /// <remarks>
+ /// <para>
+ /// Writes the environment variable to the output <paramref name="writer"/>.
+ /// The name of the environment variable to output must be set
+ /// using the <see cref="log4net.Util.PatternConverter.Option"/>
+ /// property.
+ /// </para>
+ /// </remarks>
+ protected override void Convert(TextWriter writer, object state)
+ {
+ try
+ {
+ if (this.Option != null && this.Option.Length > 0)
+ {
+ // Lookup the environment variable
+ string envValue = Environment.GetEnvironmentVariable(this.Option);
#if NET_2_0 || NETSTANDARD2_0
// If we didn't see it for the process, try a user level variable.
- if (envValue == null)
- {
- envValue = Environment.GetEnvironmentVariable(this.Option, EnvironmentVariableTarget.User);
- }
+ if (envValue == null)
+ {
+ envValue = Environment.GetEnvironmentVariable(this.Option, EnvironmentVariableTarget.User);
+ }
// If we still didn't find it, try a system level one.
- if (envValue == null)
- {
- envValue = Environment.GetEnvironmentVariable(this.Option, EnvironmentVariableTarget.Machine);
- }
-#endif
+ if (envValue == null)
+ {
+ envValue = Environment.GetEnvironmentVariable(this.Option, EnvironmentVariableTarget.Machine);
+ }
+#endif
- if (envValue != null && envValue.Length > 0)
- {
- writer.Write(envValue);
- }
- }
- }
- catch(System.Security.SecurityException secEx)
- {
- // This security exception will occur if the caller does not have
- // unrestricted environment permission. If this occurs the expansion
- // will be skipped with the following warning message.
- LogLog.Debug(declaringType, "Security exception while trying to expand environment variables. Error Ignored. No Expansion.", secEx);
- }
- catch (Exception ex)
- {
- LogLog.Error(declaringType, "Error occurred while converting environment variable.", ex);
- }
- }
+ if (envValue != null && envValue.Length > 0)
+ {
+ writer.Write(envValue);
+ }
+ }
+ }
+ catch(System.Security.SecurityException secEx)
+ {
+ // This security exception will occur if the caller does not have
+ // unrestricted environment permission. If this occurs the expansion
+ // will be skipped with the following warning message.
+ LogLog.Debug(declaringType, "Security exception while trying to expand environment variables. Error Ignored. No Expansion.", secEx);
+ }
+ catch (Exception ex)
+ {
+ LogLog.Error(declaringType, "Error occurred while converting environment variable.", ex);
+ }
+ }
- #region Private Static Fields
+ #region Private Static Fields
- /// <summary>
- /// The fully qualified type of the EnvironmentPatternConverter class.
- /// </summary>
- /// <remarks>
- /// Used by the internal logger to record the Type of the
- /// log message.
- /// </remarks>
- private static readonly Type declaringType = typeof(EnvironmentPatternConverter);
+ /// <summary>
+ /// The fully qualified type of the EnvironmentPatternConverter class.
+ /// </summary>
+ /// <remarks>
+ /// Used by the internal logger to record the Type of the
+ /// log message.
+ /// </remarks>
+ private static readonly Type declaringType = typeof(EnvironmentPatternConverter);
- #endregion Private Static Fields
- }
+ #endregion Private Static Fields
+ }
}
#endif // !NETCF
diff --git a/src/log4net/Util/PatternStringConverters/IdentityPatternConverter.cs b/src/log4net/Util/PatternStringConverters/IdentityPatternConverter.cs
index f3ee860..f31ca0d 100644
--- a/src/log4net/Util/PatternStringConverters/IdentityPatternConverter.cs
+++ b/src/log4net/Util/PatternStringConverters/IdentityPatternConverter.cs
@@ -25,64 +25,64 @@
namespace log4net.Util.PatternStringConverters
{
- /// <summary>
- /// Write the current thread identity to the output
- /// </summary>
- /// <remarks>
- /// <para>
- /// Write the current thread identity to the output writer
- /// </para>
- /// </remarks>
- /// <author>Nicko Cadell</author>
- internal sealed class IdentityPatternConverter : PatternConverter
- {
- /// <summary>
- /// Write the current thread identity to the output
- /// </summary>
- /// <param name="writer">the writer to write to</param>
- /// <param name="state">null, state is not set</param>
- /// <remarks>
- /// <para>
- /// Writes the current thread identity to the output <paramref name="writer"/>.
- /// </para>
- /// </remarks>
- protected override void Convert(TextWriter writer, object state)
- {
+ /// <summary>
+ /// Write the current thread identity to the output
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Write the current thread identity to the output writer
+ /// </para>
+ /// </remarks>
+ /// <author>Nicko Cadell</author>
+ internal sealed class IdentityPatternConverter : PatternConverter
+ {
+ /// <summary>
+ /// Write the current thread identity to the output
+ /// </summary>
+ /// <param name="writer">the writer to write to</param>
+ /// <param name="state">null, state is not set</param>
+ /// <remarks>
+ /// <para>
+ /// Writes the current thread identity to the output <paramref name="writer"/>.
+ /// </para>
+ /// </remarks>
+ protected override void Convert(TextWriter writer, object state)
+ {
#if (NETCF || SSCLI || NETSTANDARD1_3)
- // On compact framework there's no notion of current thread principals
- writer.Write( SystemInfo.NotAvailableText );
+ // On compact framework there's no notion of current thread principals
+ writer.Write( SystemInfo.NotAvailableText );
#else
- try
- {
- if (System.Threading.Thread.CurrentPrincipal != null &&
- System.Threading.Thread.CurrentPrincipal.Identity != null &&
- System.Threading.Thread.CurrentPrincipal.Identity.Name != null)
- {
- writer.Write( System.Threading.Thread.CurrentPrincipal.Identity.Name );
- }
- }
- catch(System.Security.SecurityException)
- {
- // This security exception will occur if the caller does not have
- // some undefined set of SecurityPermission flags.
- LogLog.Debug(declaringType, "Security exception while trying to get current thread principal. Error Ignored.");
+ try
+ {
+ if (System.Threading.Thread.CurrentPrincipal != null &&
+ System.Threading.Thread.CurrentPrincipal.Identity != null &&
+ System.Threading.Thread.CurrentPrincipal.Identity.Name != null)
+ {
+ writer.Write( System.Threading.Thread.CurrentPrincipal.Identity.Name );
+ }
+ }
+ catch(System.Security.SecurityException)
+ {
+ // This security exception will occur if the caller does not have
+ // some undefined set of SecurityPermission flags.
+ LogLog.Debug(declaringType, "Security exception while trying to get current thread principal. Error Ignored.");
- writer.Write( SystemInfo.NotAvailableText );
- }
+ writer.Write( SystemInfo.NotAvailableText );
+ }
#endif
- }
+ }
- #region Private Static Fields
+ #region Private Static Fields
- /// <summary>
- /// The fully qualified type of the IdentityPatternConverter class.
- /// </summary>
- /// <remarks>
- /// Used by the internal logger to record the Type of the
- /// log message.
- /// </remarks>
- private static readonly Type declaringType = typeof(IdentityPatternConverter);
+ /// <summary>
+ /// The fully qualified type of the IdentityPatternConverter class.
+ /// </summary>
+ /// <remarks>
+ /// Used by the internal logger to record the Type of the
+ /// log message.
+ /// </remarks>
+ private static readonly Type declaringType = typeof(IdentityPatternConverter);
- #endregion Private Static Fields
- }
+ #endregion Private Static Fields
+ }
}
diff --git a/src/log4net/Util/PatternStringConverters/LiteralPatternConverter.cs b/src/log4net/Util/PatternStringConverters/LiteralPatternConverter.cs
index 3f3e242..bcdf7e4 100644
--- a/src/log4net/Util/PatternStringConverters/LiteralPatternConverter.cs
+++ b/src/log4net/Util/PatternStringConverters/LiteralPatternConverter.cs
@@ -25,83 +25,83 @@
namespace log4net.Util.PatternStringConverters
{
- /// <summary>
- /// Pattern converter for literal string instances in the pattern
- /// </summary>
- /// <remarks>
- /// <para>
- /// Writes the literal string value specified in the
- /// <see cref="log4net.Util.PatternConverter.Option"/> property to
- /// the output.
- /// </para>
- /// </remarks>
- /// <author>Nicko Cadell</author>
- internal class LiteralPatternConverter : PatternConverter
- {
- /// <summary>
- /// Set the next converter in the chain
- /// </summary>
- /// <param name="pc">The next pattern converter in the chain</param>
- /// <returns>The next pattern converter</returns>
- /// <remarks>
- /// <para>
- /// Special case the building of the pattern converter chain
- /// for <see cref="LiteralPatternConverter"/> instances. Two adjacent
- /// literals in the pattern can be represented by a single combined
- /// pattern converter. This implementation detects when a
- /// <see cref="LiteralPatternConverter"/> is added to the chain
- /// after this converter and combines its value with this converter's
- /// literal value.
- /// </para>
- /// </remarks>
- public override PatternConverter SetNext(PatternConverter pc)
- {
- LiteralPatternConverter literalPc = pc as LiteralPatternConverter;
- if (literalPc != null)
- {
- // Combine the two adjacent literals together
- Option = Option + literalPc.Option;
+ /// <summary>
+ /// Pattern converter for literal string instances in the pattern
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Writes the literal string value specified in the
+ /// <see cref="log4net.Util.PatternConverter.Option"/> property to
+ /// the output.
+ /// </para>
+ /// </remarks>
+ /// <author>Nicko Cadell</author>
+ internal class LiteralPatternConverter : PatternConverter
+ {
+ /// <summary>
+ /// Set the next converter in the chain
+ /// </summary>
+ /// <param name="pc">The next pattern converter in the chain</param>
+ /// <returns>The next pattern converter</returns>
+ /// <remarks>
+ /// <para>
+ /// Special case the building of the pattern converter chain
+ /// for <see cref="LiteralPatternConverter"/> instances. Two adjacent
+ /// literals in the pattern can be represented by a single combined
+ /// pattern converter. This implementation detects when a
+ /// <see cref="LiteralPatternConverter"/> is added to the chain
+ /// after this converter and combines its value with this converter's
+ /// literal value.
+ /// </para>
+ /// </remarks>
+ public override PatternConverter SetNext(PatternConverter pc)
+ {
+ LiteralPatternConverter literalPc = pc as LiteralPatternConverter;
+ if (literalPc != null)
+ {
+ // Combine the two adjacent literals together
+ Option = Option + literalPc.Option;
- // We are the next converter now
- return this;
- }
+ // We are the next converter now
+ return this;
+ }
- return base.SetNext(pc);
- }
+ return base.SetNext(pc);
+ }
- /// <summary>
- /// Write the literal to the output
- /// </summary>
- /// <param name="writer">the writer to write to</param>
- /// <param name="state">null, not set</param>
- /// <remarks>
- /// <para>
- /// Override the formatting behavior to ignore the FormattingInfo
- /// because we have a literal instead.
- /// </para>
- /// <para>
- /// Writes the value of <see cref="log4net.Util.PatternConverter.Option"/>
- /// to the output <paramref name="writer"/>.
- /// </para>
- /// </remarks>
- public override void Format(TextWriter writer, object state)
- {
- writer.Write(Option);
- }
+ /// <summary>
+ /// Write the literal to the output
+ /// </summary>
+ /// <param name="writer">the writer to write to</param>
+ /// <param name="state">null, not set</param>
+ /// <remarks>
+ /// <para>
+ /// Override the formatting behavior to ignore the FormattingInfo
+ /// because we have a literal instead.
+ /// </para>
+ /// <para>
+ /// Writes the value of <see cref="log4net.Util.PatternConverter.Option"/>
+ /// to the output <paramref name="writer"/>.
+ /// </para>
+ /// </remarks>
+ public override void Format(TextWriter writer, object state)
+ {
+ writer.Write(Option);
+ }
- /// <summary>
- /// Convert this pattern into the rendered message
- /// </summary>
- /// <param name="writer"><see cref="TextWriter" /> that will receive the formatted result.</param>
- /// <param name="state">null, not set</param>
- /// <remarks>
- /// <para>
- /// This method is not used.
- /// </para>
- /// </remarks>
- protected override void Convert(TextWriter writer, object state)
- {
- throw new InvalidOperationException("Should never get here because of the overridden Format method");
- }
- }
+ /// <summary>
+ /// Convert this pattern into the rendered message
+ /// </summary>
+ /// <param name="writer"><see cref="TextWriter" /> that will receive the formatted result.</param>
+ /// <param name="state">null, not set</param>
+ /// <remarks>
+ /// <para>
+ /// This method is not used.
+ /// </para>
+ /// </remarks>
+ protected override void Convert(TextWriter writer, object state)
+ {
+ throw new InvalidOperationException("Should never get here because of the overridden Format method");
+ }
+ }
}
diff --git a/src/log4net/Util/PatternStringConverters/NewLinePatternConverter.cs b/src/log4net/Util/PatternStringConverters/NewLinePatternConverter.cs
index 2ba276f..2d663a0 100644
--- a/src/log4net/Util/PatternStringConverters/NewLinePatternConverter.cs
+++ b/src/log4net/Util/PatternStringConverters/NewLinePatternConverter.cs
@@ -21,66 +21,66 @@
namespace log4net.Util.PatternStringConverters
{
- /// <summary>
- /// Writes a newline to the output
- /// </summary>
- /// <remarks>
- /// <para>
- /// Writes the system dependent line terminator to the output.
- /// This behavior can be overridden by setting the <see cref="PatternConverter.Option"/>:
- /// </para>
- /// <list type="definition">
- /// <listheader>
- /// <term>Option Value</term>
- /// <description>Output</description>
- /// </listheader>
- /// <item>
- /// <term>DOS</term>
- /// <description>DOS or Windows line terminator <c>"\r\n"</c></description>
- /// </item>
- /// <item>
- /// <term>UNIX</term>
- /// <description>UNIX line terminator <c>"\n"</c></description>
- /// </item>
- /// </list>
- /// </remarks>
- /// <author>Nicko Cadell</author>
- internal sealed class NewLinePatternConverter : LiteralPatternConverter, IOptionHandler
- {
- #region Implementation of IOptionHandler
+ /// <summary>
+ /// Writes a newline to the output
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Writes the system dependent line terminator to the output.
+ /// This behavior can be overridden by setting the <see cref="PatternConverter.Option"/>:
+ /// </para>
+ /// <list type="definition">
+ /// <listheader>
+ /// <term>Option Value</term>
+ /// <description>Output</description>
+ /// </listheader>
+ /// <item>
+ /// <term>DOS</term>
+ /// <description>DOS or Windows line terminator <c>"\r\n"</c></description>
+ /// </item>
+ /// <item>
+ /// <term>UNIX</term>
+ /// <description>UNIX line terminator <c>"\n"</c></description>
+ /// </item>
+ /// </list>
+ /// </remarks>
+ /// <author>Nicko Cadell</author>
+ internal sealed class NewLinePatternConverter : LiteralPatternConverter, IOptionHandler
+ {
+ #region Implementation of IOptionHandler
- /// <summary>
- /// Initialize the converter
- /// </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>
- public void ActivateOptions()
- {
- if (SystemInfo.EqualsIgnoringCase(Option, "DOS"))
- {
- Option = "\r\n";
- }
- else if (SystemInfo.EqualsIgnoringCase(Option, "UNIX"))
- {
- Option = "\n";
- }
- else
- {
- Option = SystemInfo.NewLine;
- }
- }
+ /// <summary>
+ /// Initialize the converter
+ /// </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>
+ public void ActivateOptions()
+ {
+ if (SystemInfo.EqualsIgnoringCase(Option, "DOS"))
+ {
+ Option = "\r\n";
+ }
+ else if (SystemInfo.EqualsIgnoringCase(Option, "UNIX"))
+ {
+ Option = "\n";
+ }
+ else
+ {
+ Option = SystemInfo.NewLine;
+ }
+ }
- #endregion
- }
+ #endregion
+ }
}
diff --git a/src/log4net/Util/PatternStringConverters/ProcessIdPatternConverter.cs b/src/log4net/Util/PatternStringConverters/ProcessIdPatternConverter.cs
index fbb796d..d4e197e 100644
--- a/src/log4net/Util/PatternStringConverters/ProcessIdPatternConverter.cs
+++ b/src/log4net/Util/PatternStringConverters/ProcessIdPatternConverter.cs
@@ -22,62 +22,62 @@
namespace log4net.Util.PatternStringConverters
{
- /// <summary>
- /// Write the current process ID to the output
- /// </summary>
- /// <remarks>
- /// <para>
- /// Write the current process ID to the output writer
- /// </para>
- /// </remarks>
- /// <author>Nicko Cadell</author>
- internal sealed class ProcessIdPatternConverter : PatternConverter
- {
- /// <summary>
- /// Write the current process ID to the output
- /// </summary>
- /// <param name="writer">the writer to write to</param>
- /// <param name="state">null, state is not set</param>
- /// <remarks>
- /// <para>
- /// Write the current process ID to the output <paramref name="writer"/>.
- /// </para>
- /// </remarks>
+ /// <summary>
+ /// Write the current process ID to the output
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Write the current process ID to the output writer
+ /// </para>
+ /// </remarks>
+ /// <author>Nicko Cadell</author>
+ internal sealed class ProcessIdPatternConverter : PatternConverter
+ {
+ /// <summary>
+ /// Write the current process ID to the output
+ /// </summary>
+ /// <param name="writer">the writer to write to</param>
+ /// <param name="state">null, state is not set</param>
+ /// <remarks>
+ /// <para>
+ /// Write the current process ID to the output <paramref name="writer"/>.
+ /// </para>
+ /// </remarks>
#if NET_4_0 || MONO_4_0 || NETSTANDARD
[System.Security.SecuritySafeCritical]
#endif
protected override void Convert(TextWriter writer, object state)
- {
+ {
#if (NETCF || SSCLI)
- // On compact framework there is no System.Diagnostics.Process class
- writer.Write( SystemInfo.NotAvailableText );
+ // On compact framework there is no System.Diagnostics.Process class
+ writer.Write( SystemInfo.NotAvailableText );
#else
- try
- {
- writer.Write( System.Diagnostics.Process.GetCurrentProcess().Id );
- }
- catch(System.Security.SecurityException)
- {
- // This security exception will occur if the caller does not have
- // some undefined set of SecurityPermission flags.
- LogLog.Debug(declaringType, "Security exception while trying to get current process id. Error Ignored.");
+ try
+ {
+ writer.Write( System.Diagnostics.Process.GetCurrentProcess().Id );
+ }
+ catch(System.Security.SecurityException)
+ {
+ // This security exception will occur if the caller does not have
+ // some undefined set of SecurityPermission flags.
+ LogLog.Debug(declaringType, "Security exception while trying to get current process id. Error Ignored.");
- writer.Write( SystemInfo.NotAvailableText );
- }
+ writer.Write( SystemInfo.NotAvailableText );
+ }
#endif
- }
+ }
- #region Private Static Fields
+ #region Private Static Fields
- /// <summary>
- /// The fully qualified type of the ProcessIdPatternConverter class.
- /// </summary>
- /// <remarks>
- /// Used by the internal logger to record the Type of the
- /// log message.
- /// </remarks>
- private static readonly Type declaringType = typeof(ProcessIdPatternConverter);
+ /// <summary>
+ /// The fully qualified type of the ProcessIdPatternConverter class.
+ /// </summary>
+ /// <remarks>
+ /// Used by the internal logger to record the Type of the
+ /// log message.
+ /// </remarks>
+ private static readonly Type declaringType = typeof(ProcessIdPatternConverter);
- #endregion Private Static Fields
- }
+ #endregion Private Static Fields
+ }
}
diff --git a/src/log4net/Util/PatternStringConverters/PropertyPatternConverter.cs b/src/log4net/Util/PatternStringConverters/PropertyPatternConverter.cs
index bf81f2a..76f4239 100644
--- a/src/log4net/Util/PatternStringConverters/PropertyPatternConverter.cs
+++ b/src/log4net/Util/PatternStringConverters/PropertyPatternConverter.cs
@@ -21,72 +21,72 @@
namespace log4net.Util.PatternStringConverters
{
- /// <summary>
- /// Property pattern converter
- /// </summary>
- /// <remarks>
- /// <para>
- /// This pattern converter reads the thread and global properties.
- /// The thread properties take priority over global properties.
- /// See <see cref="ThreadContext.Properties"/> for details of the
- /// thread properties. See <see cref="GlobalContext.Properties"/> for
- /// details of the global properties.
- /// </para>
- /// <para>
- /// If the <see cref="PatternConverter.Option"/> is specified then that will be used to
- /// lookup a single property. If no <see cref="PatternConverter.Option"/> is specified
- /// then all properties will be dumped as a list of key value pairs.
- /// </para>
- /// </remarks>
- /// <author>Nicko Cadell</author>
- internal sealed class PropertyPatternConverter : PatternConverter
- {
- /// <summary>
- /// Write the property value to the output
- /// </summary>
- /// <param name="writer"><see cref="TextWriter" /> that will receive the formatted result.</param>
- /// <param name="state">null, state is not set</param>
- /// <remarks>
- /// <para>
- /// Writes out the value of a named property. The property name
- /// should be set in the <see cref="log4net.Util.PatternConverter.Option"/>
- /// property.
- /// </para>
- /// <para>
- /// If the <see cref="log4net.Util.PatternConverter.Option"/> is set to <c>null</c>
- /// then all the properties are written as key value pairs.
- /// </para>
- /// </remarks>
- protected override void Convert(TextWriter writer, object state)
- {
- CompositeProperties compositeProperties = new CompositeProperties();
+ /// <summary>
+ /// Property pattern converter
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// This pattern converter reads the thread and global properties.
+ /// The thread properties take priority over global properties.
+ /// See <see cref="ThreadContext.Properties"/> for details of the
+ /// thread properties. See <see cref="GlobalContext.Properties"/> for
+ /// details of the global properties.
+ /// </para>
+ /// <para>
+ /// If the <see cref="PatternConverter.Option"/> is specified then that will be used to
+ /// lookup a single property. If no <see cref="PatternConverter.Option"/> is specified
+ /// then all properties will be dumped as a list of key value pairs.
+ /// </para>
+ /// </remarks>
+ /// <author>Nicko Cadell</author>
+ internal sealed class PropertyPatternConverter : PatternConverter
+ {
+ /// <summary>
+ /// Write the property value to the output
+ /// </summary>
+ /// <param name="writer"><see cref="TextWriter" /> that will receive the formatted result.</param>
+ /// <param name="state">null, state is not set</param>
+ /// <remarks>
+ /// <para>
+ /// Writes out the value of a named property. The property name
+ /// should be set in the <see cref="log4net.Util.PatternConverter.Option"/>
+ /// property.
+ /// </para>
+ /// <para>
+ /// If the <see cref="log4net.Util.PatternConverter.Option"/> is set to <c>null</c>
+ /// then all the properties are written as key value pairs.
+ /// </para>
+ /// </remarks>
+ protected override void Convert(TextWriter writer, object state)
+ {
+ CompositeProperties compositeProperties = new CompositeProperties();
#if !NETCF
- PropertiesDictionary logicalThreadProperties = LogicalThreadContext.Properties.GetProperties(false);
- if (logicalThreadProperties != null)
- {
- compositeProperties.Add(logicalThreadProperties);
- }
+ PropertiesDictionary logicalThreadProperties = LogicalThreadContext.Properties.GetProperties(false);
+ if (logicalThreadProperties != null)
+ {
+ compositeProperties.Add(logicalThreadProperties);
+ }
#endif
- PropertiesDictionary threadProperties = ThreadContext.Properties.GetProperties(false);
- if (threadProperties != null)
- {
- compositeProperties.Add(threadProperties);
- }
+ PropertiesDictionary threadProperties = ThreadContext.Properties.GetProperties(false);
+ if (threadProperties != null)
+ {
+ compositeProperties.Add(threadProperties);
+ }
- // TODO: Add Repository Properties
- compositeProperties.Add(GlobalContext.Properties.GetReadOnlyProperties());
+ // TODO: Add Repository Properties
+ compositeProperties.Add(GlobalContext.Properties.GetReadOnlyProperties());
- if (Option != null)
- {
- // Write the value for the specified key
- WriteObject(writer, null, compositeProperties[Option]);
- }
- else
- {
- // Write all the key value pairs
- WriteDictionary(writer, null, compositeProperties.Flatten());
- }
- }
- }
+ if (Option != null)
+ {
+ // Write the value for the specified key
+ WriteObject(writer, null, compositeProperties[Option]);
+ }
+ else
+ {
+ // Write all the key value pairs
+ WriteDictionary(writer, null, compositeProperties.Flatten());
+ }
+ }
+ }
}
diff --git a/src/log4net/Util/PatternStringConverters/RandomStringPatternConverter.cs b/src/log4net/Util/PatternStringConverters/RandomStringPatternConverter.cs
index 015cfd7..8b11c45 100644
--- a/src/log4net/Util/PatternStringConverters/RandomStringPatternConverter.cs
+++ b/src/log4net/Util/PatternStringConverters/RandomStringPatternConverter.cs
@@ -27,130 +27,130 @@
namespace log4net.Util.PatternStringConverters
{
- /// <summary>
- /// A Pattern converter that generates a string of random characters
- /// </summary>
- /// <remarks>
- /// <para>
- /// The converter generates a string of random characters. By default
- /// the string is length 4. This can be changed by setting the <see cref="PatternConverter.Option"/>
- /// to the string value of the length required.
- /// </para>
- /// <para>
- /// The random characters in the string are limited to uppercase letters
- /// and numbers only.
- /// </para>
- /// <para>
- /// The random number generator used by this class is not cryptographically secure.
- /// </para>
- /// </remarks>
- /// <author>Nicko Cadell</author>
- internal sealed class RandomStringPatternConverter : PatternConverter, IOptionHandler
- {
- /// <summary>
- /// Shared random number generator
- /// </summary>
- private static readonly Random s_random = new Random();
+ /// <summary>
+ /// A Pattern converter that generates a string of random characters
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// The converter generates a string of random characters. By default
+ /// the string is length 4. This can be changed by setting the <see cref="PatternConverter.Option"/>
+ /// to the string value of the length required.
+ /// </para>
+ /// <para>
+ /// The random characters in the string are limited to uppercase letters
+ /// and numbers only.
+ /// </para>
+ /// <para>
+ /// The random number generator used by this class is not cryptographically secure.
+ /// </para>
+ /// </remarks>
+ /// <author>Nicko Cadell</author>
+ internal sealed class RandomStringPatternConverter : PatternConverter, IOptionHandler
+ {
+ /// <summary>
+ /// Shared random number generator
+ /// </summary>
+ private static readonly Random s_random = new Random();
- /// <summary>
- /// Length of random string to generate. Default length 4.
- /// </summary>
- private int m_length = 4;
+ /// <summary>
+ /// Length of random string to generate. Default length 4.
+ /// </summary>
+ private int m_length = 4;
- #region Implementation of IOptionHandler
+ #region Implementation of IOptionHandler
- /// <summary>
- /// Initialize the converter options
- /// </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>
- public void ActivateOptions()
- {
- string optionStr = Option;
- if (optionStr != null && optionStr.Length > 0)
- {
- int lengthVal;
- if (SystemInfo.TryParse(optionStr, out lengthVal))
- {
- m_length = lengthVal;
- }
- else
- {
- LogLog.Error(declaringType, "RandomStringPatternConverter: Could not convert Option ["+optionStr+"] to Length Int32");
- }
- }
- }
+ /// <summary>
+ /// Initialize the converter options
+ /// </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>
+ public void ActivateOptions()
+ {
+ string optionStr = Option;
+ if (optionStr != null && optionStr.Length > 0)
+ {
+ int lengthVal;
+ if (SystemInfo.TryParse(optionStr, out lengthVal))
+ {
+ m_length = lengthVal;
+ }
+ else
+ {
+ LogLog.Error(declaringType, "RandomStringPatternConverter: Could not convert Option ["+optionStr+"] to Length Int32");
+ }
+ }
+ }
- #endregion
+ #endregion
- /// <summary>
- /// Write a randoim string to the output
- /// </summary>
- /// <param name="writer">the writer to write to</param>
- /// <param name="state">null, state is not set</param>
- /// <remarks>
- /// <para>
- /// Write a randoim string to the output <paramref name="writer"/>.
- /// </para>
- /// </remarks>
- protected override void Convert(TextWriter writer, object state)
- {
- try
- {
- lock(s_random)
- {
- for(int i=0; i<m_length; i++)
- {
- int randValue = s_random.Next(36);
+ /// <summary>
+ /// Write a randoim string to the output
+ /// </summary>
+ /// <param name="writer">the writer to write to</param>
+ /// <param name="state">null, state is not set</param>
+ /// <remarks>
+ /// <para>
+ /// Write a randoim string to the output <paramref name="writer"/>.
+ /// </para>
+ /// </remarks>
+ protected override void Convert(TextWriter writer, object state)
+ {
+ try
+ {
+ lock(s_random)
+ {
+ for(int i=0; i<m_length; i++)
+ {
+ int randValue = s_random.Next(36);
- if (randValue < 26)
- {
- // Letter
- char ch = (char)('A' + randValue);
- writer.Write(ch);
- }
- else if (randValue < 36)
- {
- // Number
- char ch = (char)('0' + (randValue - 26));
- writer.Write(ch);
- }
- else
- {
- // Should not get here
- writer.Write('X');
- }
- }
- }
- }
- catch (Exception ex)
- {
- LogLog.Error(declaringType, "Error occurred while converting.", ex);
- }
- }
+ if (randValue < 26)
+ {
+ // Letter
+ char ch = (char)('A' + randValue);
+ writer.Write(ch);
+ }
+ else if (randValue < 36)
+ {
+ // Number
+ char ch = (char)('0' + (randValue - 26));
+ writer.Write(ch);
+ }
+ else
+ {
+ // Should not get here
+ writer.Write('X');
+ }
+ }
+ }
+ }
+ catch (Exception ex)
+ {
+ LogLog.Error(declaringType, "Error occurred while converting.", ex);
+ }
+ }
- #region Private Static Fields
+ #region Private Static Fields
- /// <summary>
- /// The fully qualified type of the RandomStringPatternConverter class.
- /// </summary>
- /// <remarks>
- /// Used by the internal logger to record the Type of the
- /// log message.
- /// </remarks>
- private static readonly Type declaringType = typeof(RandomStringPatternConverter);
+ /// <summary>
+ /// The fully qualified type of the RandomStringPatternConverter class.
+ /// </summary>
+ /// <remarks>
+ /// Used by the internal logger to record the Type of the
+ /// log message.
+ /// </remarks>
+ private static readonly Type declaringType = typeof(RandomStringPatternConverter);
- #endregion Private Static Fields
- }
+ #endregion Private Static Fields
+ }
}
diff --git a/src/log4net/Util/PatternStringConverters/UserNamePatternConverter.cs b/src/log4net/Util/PatternStringConverters/UserNamePatternConverter.cs
index 9cc69fd..896e51d 100644
--- a/src/log4net/Util/PatternStringConverters/UserNamePatternConverter.cs
+++ b/src/log4net/Util/PatternStringConverters/UserNamePatternConverter.cs
@@ -22,64 +22,64 @@
namespace log4net.Util.PatternStringConverters
{
- /// <summary>
- /// Write the current threads username to the output
- /// </summary>
- /// <remarks>
- /// <para>
- /// Write the current threads username to the output writer
- /// </para>
- /// </remarks>
- /// <author>Nicko Cadell</author>
- internal sealed class UserNamePatternConverter : PatternConverter
- {
- /// <summary>
- /// Write the current threads username to the output
- /// </summary>
- /// <param name="writer">the writer to write to</param>
- /// <param name="state">null, state is not set</param>
- /// <remarks>
- /// <para>
- /// Write the current threads username to the output <paramref name="writer"/>.
- /// </para>
- /// </remarks>
- protected override void Convert(TextWriter writer, object state)
- {
+ /// <summary>
+ /// Write the current threads username to the output
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Write the current threads username to the output writer
+ /// </para>
+ /// </remarks>
+ /// <author>Nicko Cadell</author>
+ internal sealed class UserNamePatternConverter : PatternConverter
+ {
+ /// <summary>
+ /// Write the current threads username to the output
+ /// </summary>
+ /// <param name="writer">the writer to write to</param>
+ /// <param name="state">null, state is not set</param>
+ /// <remarks>
+ /// <para>
+ /// Write the current threads username to the output <paramref name="writer"/>.
+ /// </para>
+ /// </remarks>
+ protected override void Convert(TextWriter writer, object state)
+ {
#if (NETCF || SSCLI || NETSTANDARD1_3)
- // On compact framework there's no notion of current Windows user
- writer.Write( SystemInfo.NotAvailableText );
+ // On compact framework there's no notion of current Windows user
+ writer.Write( SystemInfo.NotAvailableText );
#else
- try
- {
- System.Security.Principal.WindowsIdentity windowsIdentity = null;
- windowsIdentity = System.Security.Principal.WindowsIdentity.GetCurrent();
- if (windowsIdentity != null && windowsIdentity.Name != null)
- {
- writer.Write( windowsIdentity.Name );
- }
- }
- catch(System.Security.SecurityException)
- {
- // This security exception will occur if the caller does not have
- // some undefined set of SecurityPermission flags.
- LogLog.Debug(declaringType, "Security exception while trying to get current windows identity. Error Ignored.");
+ try
+ {
+ System.Security.Principal.WindowsIdentity windowsIdentity = null;
+ windowsIdentity = System.Security.Principal.WindowsIdentity.GetCurrent();
+ if (windowsIdentity != null && windowsIdentity.Name != null)
+ {
+ writer.Write( windowsIdentity.Name );
+ }
+ }
+ catch(System.Security.SecurityException)
+ {
+ // This security exception will occur if the caller does not have
+ // some undefined set of SecurityPermission flags.
+ LogLog.Debug(declaringType, "Security exception while trying to get current windows identity. Error Ignored.");
- writer.Write( SystemInfo.NotAvailableText );
- }
+ writer.Write( SystemInfo.NotAvailableText );
+ }
#endif
- }
+ }
- #region Private Static Fields
+ #region Private Static Fields
- /// <summary>
- /// The fully qualified type of the UserNamePatternConverter class.
- /// </summary>
- /// <remarks>
- /// Used by the internal logger to record the Type of the
- /// log message.
- /// </remarks>
- private static readonly Type declaringType = typeof(UserNamePatternConverter);
+ /// <summary>
+ /// The fully qualified type of the UserNamePatternConverter class.
+ /// </summary>
+ /// <remarks>
+ /// Used by the internal logger to record the Type of the
+ /// log message.
+ /// </remarks>
+ private static readonly Type declaringType = typeof(UserNamePatternConverter);
- #endregion Private Static Fields
- }
+ #endregion Private Static Fields
+ }
}
diff --git a/src/log4net/Util/PatternStringConverters/UtcDatePatternConverter.cs b/src/log4net/Util/PatternStringConverters/UtcDatePatternConverter.cs
index 31d5f7f..6c59484 100644
--- a/src/log4net/Util/PatternStringConverters/UtcDatePatternConverter.cs
+++ b/src/log4net/Util/PatternStringConverters/UtcDatePatternConverter.cs
@@ -27,60 +27,60 @@
namespace log4net.Util.PatternStringConverters
{
- /// <summary>
- /// Write the UTC date time to the output
- /// </summary>
- /// <remarks>
- /// <para>
- /// Date pattern converter, uses a <see cref="IDateFormatter"/> to format
- /// the current date and time in Universal time.
- /// </para>
- /// <para>
- /// See the <see cref="DatePatternConverter"/> for details on the date pattern syntax.
- /// </para>
- /// </remarks>
- /// <seealso cref="DatePatternConverter"/>
- /// <author>Nicko Cadell</author>
- internal class UtcDatePatternConverter : DatePatternConverter
- {
- /// <summary>
- /// Write the current date and time to the output
- /// </summary>
- /// <param name="writer"><see cref="TextWriter" /> that will receive the formatted result.</param>
- /// <param name="state">null, state is not set</param>
- /// <remarks>
- /// <para>
- /// Pass the current date and time to the <see cref="IDateFormatter"/>
- /// for it to render it to the writer.
- /// </para>
- /// <para>
- /// The date is in Universal time when it is rendered.
- /// </para>
- /// </remarks>
- /// <seealso cref="DatePatternConverter"/>
- protected override void Convert(TextWriter writer, object state)
- {
- try
- {
- m_dateFormatter.FormatDate(DateTime.UtcNow, writer);
- }
- catch (Exception ex)
- {
- LogLog.Error(declaringType, "Error occurred while converting date.", ex);
- }
- }
+ /// <summary>
+ /// Write the UTC date time to the output
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Date pattern converter, uses a <see cref="IDateFormatter"/> to format
+ /// the current date and time in Universal time.
+ /// </para>
+ /// <para>
+ /// See the <see cref="DatePatternConverter"/> for details on the date pattern syntax.
+ /// </para>
+ /// </remarks>
+ /// <seealso cref="DatePatternConverter"/>
+ /// <author>Nicko Cadell</author>
+ internal class UtcDatePatternConverter : DatePatternConverter
+ {
+ /// <summary>
+ /// Write the current date and time to the output
+ /// </summary>
+ /// <param name="writer"><see cref="TextWriter" /> that will receive the formatted result.</param>
+ /// <param name="state">null, state is not set</param>
+ /// <remarks>
+ /// <para>
+ /// Pass the current date and time to the <see cref="IDateFormatter"/>
+ /// for it to render it to the writer.
+ /// </para>
+ /// <para>
+ /// The date is in Universal time when it is rendered.
+ /// </para>
+ /// </remarks>
+ /// <seealso cref="DatePatternConverter"/>
+ protected override void Convert(TextWriter writer, object state)
+ {
+ try
+ {
+ m_dateFormatter.FormatDate(DateTime.UtcNow, writer);
+ }
+ catch (Exception ex)
+ {
+ LogLog.Error(declaringType, "Error occurred while converting date.", ex);
+ }
+ }
- #region Private Static Fields
+ #region Private Static Fields
- /// <summary>
- /// The fully qualified type of the UtcDatePatternConverter class.
- /// </summary>
- /// <remarks>
- /// Used by the internal logger to record the Type of the
- /// log message.
- /// </remarks>
- private static readonly Type declaringType = typeof(UtcDatePatternConverter);
+ /// <summary>
+ /// The fully qualified type of the UtcDatePatternConverter class.
+ /// </summary>
+ /// <remarks>
+ /// Used by the internal logger to record the Type of the
+ /// log message.
+ /// </remarks>
+ private static readonly Type declaringType = typeof(UtcDatePatternConverter);
- #endregion Private Static Fields
- }
+ #endregion Private Static Fields
+ }
}
diff --git a/src/log4net/Util/PropertiesDictionary.cs b/src/log4net/Util/PropertiesDictionary.cs
index e70fb20..ce72e98 100644
--- a/src/log4net/Util/PropertiesDictionary.cs
+++ b/src/log4net/Util/PropertiesDictionary.cs
@@ -23,311 +23,311 @@
namespace log4net.Util
{
- /// <summary>
- /// String keyed object map.
- /// </summary>
- /// <remarks>
- /// <para>
- /// While this collection is serializable only member
- /// objects that are serializable will
- /// be serialized along with this collection.
- /// </para>
- /// </remarks>
- /// <author>Nicko Cadell</author>
- /// <author>Gert Driesen</author>
+ /// <summary>
+ /// String keyed object map.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// While this collection is serializable only member
+ /// objects that are serializable will
+ /// be serialized along with this collection.
+ /// </para>
+ /// </remarks>
+ /// <author>Nicko Cadell</author>
+ /// <author>Gert Driesen</author>
#if NETCF
- public sealed class PropertiesDictionary : ReadOnlyPropertiesDictionary, IDictionary
+ public sealed class PropertiesDictionary : ReadOnlyPropertiesDictionary, IDictionary
#else
- [Serializable]
- public sealed class PropertiesDictionary : ReadOnlyPropertiesDictionary, ISerializable, IDictionary
+ [Serializable]
+ public sealed class PropertiesDictionary : ReadOnlyPropertiesDictionary, ISerializable, IDictionary
#endif
- {
- #region Public Instance Constructors
+ {
+ #region Public Instance Constructors
- /// <summary>
- /// Constructor
- /// </summary>
- /// <remarks>
- /// <para>
- /// Initializes a new instance of the <see cref="PropertiesDictionary" /> class.
- /// </para>
- /// </remarks>
- public PropertiesDictionary()
- {
- }
+ /// <summary>
+ /// Constructor
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Initializes a new instance of the <see cref="PropertiesDictionary" /> class.
+ /// </para>
+ /// </remarks>
+ public PropertiesDictionary()
+ {
+ }
- /// <summary>
- /// Constructor
- /// </summary>
- /// <param name="propertiesDictionary">properties to copy</param>
- /// <remarks>
- /// <para>
- /// Initializes a new instance of the <see cref="PropertiesDictionary" /> class.
- /// </para>
- /// </remarks>
- public PropertiesDictionary(ReadOnlyPropertiesDictionary propertiesDictionary) : base(propertiesDictionary)
- {
- }
+ /// <summary>
+ /// Constructor
+ /// </summary>
+ /// <param name="propertiesDictionary">properties to copy</param>
+ /// <remarks>
+ /// <para>
+ /// Initializes a new instance of the <see cref="PropertiesDictionary" /> class.
+ /// </para>
+ /// </remarks>
+ public PropertiesDictionary(ReadOnlyPropertiesDictionary propertiesDictionary) : base(propertiesDictionary)
+ {
+ }
- #endregion Public Instance Constructors
+ #endregion Public Instance Constructors
- #region Private Instance Constructors
+ #region Private Instance Constructors
#if !NETCF
- /// <summary>
- /// Initializes a new instance of the <see cref="PropertiesDictionary" /> class
- /// with serialized data.
- /// </summary>
- /// <param name="info">The <see cref="SerializationInfo" /> that holds the serialized object data.</param>
- /// <param name="context">The <see cref="StreamingContext" /> that contains contextual information about the source or destination.</param>
- /// <remarks>
- /// <para>
- /// Because this class is sealed the serialization constructor is private.
- /// </para>
- /// </remarks>
- private PropertiesDictionary(SerializationInfo info, StreamingContext context) : base(info, context)
- {
- }
+ /// <summary>
+ /// Initializes a new instance of the <see cref="PropertiesDictionary" /> class
+ /// with serialized data.
+ /// </summary>
+ /// <param name="info">The <see cref="SerializationInfo" /> that holds the serialized object data.</param>
+ /// <param name="context">The <see cref="StreamingContext" /> that contains contextual information about the source or destination.</param>
+ /// <remarks>
+ /// <para>
+ /// Because this class is sealed the serialization constructor is private.
+ /// </para>
+ /// </remarks>
+ private PropertiesDictionary(SerializationInfo info, StreamingContext context) : base(info, context)
+ {
+ }
#endif
- #endregion Protected Instance Constructors
+ #endregion Protected Instance Constructors
- #region Public Instance Properties
+ #region Public Instance Properties
- /// <summary>
- /// Gets or sets the value of the property with the specified key.
- /// </summary>
- /// <value>
- /// The value of the property with the specified key.
- /// </value>
- /// <param name="key">The key of the property to get or set.</param>
- /// <remarks>
- /// <para>
- /// The property value will only be serialized if it is serializable.
- /// If it cannot be serialized it will be silently ignored if
- /// a serialization operation is performed.
- /// </para>
- /// </remarks>
- public override object this[string key]
- {
- get { return InnerHashtable[key]; }
- set { InnerHashtable[key] = value; }
- }
+ /// <summary>
+ /// Gets or sets the value of the property with the specified key.
+ /// </summary>
+ /// <value>
+ /// The value of the property with the specified key.
+ /// </value>
+ /// <param name="key">The key of the property to get or set.</param>
+ /// <remarks>
+ /// <para>
+ /// The property value will only be serialized if it is serializable.
+ /// If it cannot be serialized it will be silently ignored if
+ /// a serialization operation is performed.
+ /// </para>
+ /// </remarks>
+ public override object this[string key]
+ {
+ get { return InnerHashtable[key]; }
+ set { InnerHashtable[key] = value; }
+ }
- #endregion Public Instance Properties
+ #endregion Public Instance Properties
- #region Public Instance Methods
+ #region Public Instance Methods
- /// <summary>
- /// Remove the entry with the specified key from this dictionary
- /// </summary>
- /// <param name="key">the key for the entry to remove</param>
- /// <remarks>
- /// <para>
- /// Remove the entry with the specified key from this dictionary
- /// </para>
- /// </remarks>
- public void Remove(string key)
- {
- InnerHashtable.Remove(key);
- }
+ /// <summary>
+ /// Remove the entry with the specified key from this dictionary
+ /// </summary>
+ /// <param name="key">the key for the entry to remove</param>
+ /// <remarks>
+ /// <para>
+ /// Remove the entry with the specified key from this dictionary
+ /// </para>
+ /// </remarks>
+ public void Remove(string key)
+ {
+ InnerHashtable.Remove(key);
+ }
- #endregion Public Instance Methods
+ #endregion Public Instance Methods
- #region Implementation of IDictionary
+ #region Implementation of IDictionary
- /// <summary>
- /// See <see cref="IDictionary.GetEnumerator"/>
- /// </summary>
- /// <returns>an enumerator</returns>
- /// <remarks>
- /// <para>
- /// Returns a <see cref="IDictionaryEnumerator"/> over the contest of this collection.
- /// </para>
- /// </remarks>
- IDictionaryEnumerator IDictionary.GetEnumerator()
- {
- return InnerHashtable.GetEnumerator();
- }
+ /// <summary>
+ /// See <see cref="IDictionary.GetEnumerator"/>
+ /// </summary>
+ /// <returns>an enumerator</returns>
+ /// <remarks>
+ /// <para>
+ /// Returns a <see cref="IDictionaryEnumerator"/> over the contest of this collection.
+ /// </para>
+ /// </remarks>
+ IDictionaryEnumerator IDictionary.GetEnumerator()
+ {
+ return InnerHashtable.GetEnumerator();
+ }
- /// <summary>
- /// See <see cref="IDictionary.Remove"/>
- /// </summary>
- /// <param name="key">the key to remove</param>
- /// <remarks>
- /// <para>
- /// Remove the entry with the specified key from this dictionary
- /// </para>
- /// </remarks>
- void IDictionary.Remove(object key)
- {
- InnerHashtable.Remove(key);
- }
+ /// <summary>
+ /// See <see cref="IDictionary.Remove"/>
+ /// </summary>
+ /// <param name="key">the key to remove</param>
+ /// <remarks>
+ /// <para>
+ /// Remove the entry with the specified key from this dictionary
+ /// </para>
+ /// </remarks>
+ void IDictionary.Remove(object key)
+ {
+ InnerHashtable.Remove(key);
+ }
- /// <summary>
- /// See <see cref="IDictionary.Contains"/>
- /// </summary>
- /// <param name="key">the key to lookup in the collection</param>
- /// <returns><c>true</c> if the collection contains the specified key</returns>
- /// <remarks>
- /// <para>
- /// Test if this collection contains a specified key.
- /// </para>
- /// </remarks>
- bool IDictionary.Contains(object key)
- {
- return InnerHashtable.Contains(key);
- }
+ /// <summary>
+ /// See <see cref="IDictionary.Contains"/>
+ /// </summary>
+ /// <param name="key">the key to lookup in the collection</param>
+ /// <returns><c>true</c> if the collection contains the specified key</returns>
+ /// <remarks>
+ /// <para>
+ /// Test if this collection contains a specified key.
+ /// </para>
+ /// </remarks>
+ bool IDictionary.Contains(object key)
+ {
+ return InnerHashtable.Contains(key);
+ }
- /// <summary>
- /// Remove all properties from the properties collection
- /// </summary>
- /// <remarks>
- /// <para>
- /// Remove all properties from the properties collection
- /// </para>
- /// </remarks>
- public override void Clear()
- {
- InnerHashtable.Clear();
- }
+ /// <summary>
+ /// Remove all properties from the properties collection
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Remove all properties from the properties collection
+ /// </para>
+ /// </remarks>
+ public override void Clear()
+ {
+ InnerHashtable.Clear();
+ }
- /// <summary>
- /// See <see cref="IDictionary.Add"/>
- /// </summary>
- /// <param name="key">the key</param>
- /// <param name="value">the value to store for the key</param>
- /// <remarks>
- /// <para>
- /// Store a value for the specified <see cref="String"/> <paramref name="key"/>.
- /// </para>
- /// </remarks>
- /// <exception cref="ArgumentException">Thrown if the <paramref name="key"/> is not a string</exception>
- void IDictionary.Add(object key, object value)
- {
- if (!(key is string))
- {
- throw new ArgumentException("key must be a string", "key");
- }
- InnerHashtable.Add(key, value);
- }
+ /// <summary>
+ /// See <see cref="IDictionary.Add"/>
+ /// </summary>
+ /// <param name="key">the key</param>
+ /// <param name="value">the value to store for the key</param>
+ /// <remarks>
+ /// <para>
+ /// Store a value for the specified <see cref="String"/> <paramref name="key"/>.
+ /// </para>
+ /// </remarks>
+ /// <exception cref="ArgumentException">Thrown if the <paramref name="key"/> is not a string</exception>
+ void IDictionary.Add(object key, object value)
+ {
+ if (!(key is string))
+ {
+ throw new ArgumentException("key must be a string", "key");
+ }
+ InnerHashtable.Add(key, value);
+ }
- /// <summary>
- /// See <see cref="IDictionary.IsReadOnly"/>
- /// </summary>
- /// <value>
- /// <c>false</c>
- /// </value>
- /// <remarks>
- /// <para>
- /// This collection is modifiable. This property always
- /// returns <c>false</c>.
- /// </para>
- /// </remarks>
- bool IDictionary.IsReadOnly
- {
- get { return false; }
- }
+ /// <summary>
+ /// See <see cref="IDictionary.IsReadOnly"/>
+ /// </summary>
+ /// <value>
+ /// <c>false</c>
+ /// </value>
+ /// <remarks>
+ /// <para>
+ /// This collection is modifiable. This property always
+ /// returns <c>false</c>.
+ /// </para>
+ /// </remarks>
+ bool IDictionary.IsReadOnly
+ {
+ get { return false; }
+ }
- /// <summary>
- /// See <see cref="IDictionary.this"/>
- /// </summary>
- /// <value>
- /// The value for the key specified.
- /// </value>
- /// <remarks>
- /// <para>
- /// Get or set a value for the specified <see cref="String"/> <paramref name="key"/>.
- /// </para>
- /// </remarks>
- /// <exception cref="ArgumentException">Thrown if the <paramref name="key"/> is not a string</exception>
- object IDictionary.this[object key]
- {
- get
- {
- if (!(key is string))
- {
- throw new ArgumentException("key must be a string", "key");
- }
- return InnerHashtable[key];
- }
- set
- {
- if (!(key is string))
- {
- throw new ArgumentException("key must be a string", "key");
- }
- InnerHashtable[key] = value;
- }
- }
+ /// <summary>
+ /// See <see cref="IDictionary.this"/>
+ /// </summary>
+ /// <value>
+ /// The value for the key specified.
+ /// </value>
+ /// <remarks>
+ /// <para>
+ /// Get or set a value for the specified <see cref="String"/> <paramref name="key"/>.
+ /// </para>
+ /// </remarks>
+ /// <exception cref="ArgumentException">Thrown if the <paramref name="key"/> is not a string</exception>
+ object IDictionary.this[object key]
+ {
+ get
+ {
+ if (!(key is string))
+ {
+ throw new ArgumentException("key must be a string", "key");
+ }
+ return InnerHashtable[key];
+ }
+ set
+ {
+ if (!(key is string))
+ {
+ throw new ArgumentException("key must be a string", "key");
+ }
+ InnerHashtable[key] = value;
+ }
+ }
- /// <summary>
- /// See <see cref="IDictionary.Values"/>
- /// </summary>
- ICollection IDictionary.Values
- {
- get { return InnerHashtable.Values; }
- }
+ /// <summary>
+ /// See <see cref="IDictionary.Values"/>
+ /// </summary>
+ ICollection IDictionary.Values
+ {
+ get { return InnerHashtable.Values; }
+ }
- /// <summary>
- /// See <see cref="IDictionary.Keys"/>
- /// </summary>
- ICollection IDictionary.Keys
- {
- get { return InnerHashtable.Keys; }
- }
+ /// <summary>
+ /// See <see cref="IDictionary.Keys"/>
+ /// </summary>
+ ICollection IDictionary.Keys
+ {
+ get { return InnerHashtable.Keys; }
+ }
- /// <summary>
- /// See <see cref="IDictionary.IsFixedSize"/>
- /// </summary>
- bool IDictionary.IsFixedSize
- {
- get { return false; }
- }
+ /// <summary>
+ /// See <see cref="IDictionary.IsFixedSize"/>
+ /// </summary>
+ bool IDictionary.IsFixedSize
+ {
+ get { return false; }
+ }
- #endregion
+ #endregion
- #region Implementation of ICollection
+ #region Implementation of ICollection
- /// <summary>
- /// See <see cref="ICollection.CopyTo"/>
- /// </summary>
- /// <param name="array"></param>
- /// <param name="index"></param>
- void ICollection.CopyTo(Array array, int index)
- {
- InnerHashtable.CopyTo(array, index);
- }
+ /// <summary>
+ /// See <see cref="ICollection.CopyTo"/>
+ /// </summary>
+ /// <param name="array"></param>
+ /// <param name="index"></param>
+ void ICollection.CopyTo(Array array, int index)
+ {
+ InnerHashtable.CopyTo(array, index);
+ }
- /// <summary>
- /// See <see cref="ICollection.IsSynchronized"/>
- /// </summary>
- bool ICollection.IsSynchronized
- {
- get { return InnerHashtable.IsSynchronized; }
- }
+ /// <summary>
+ /// See <see cref="ICollection.IsSynchronized"/>
+ /// </summary>
+ bool ICollection.IsSynchronized
+ {
+ get { return InnerHashtable.IsSynchronized; }
+ }
- /// <summary>
- /// See <see cref="ICollection.SyncRoot"/>
- /// </summary>
- object ICollection.SyncRoot
- {
- get { return InnerHashtable.SyncRoot; }
- }
+ /// <summary>
+ /// See <see cref="ICollection.SyncRoot"/>
+ /// </summary>
+ object ICollection.SyncRoot
+ {
+ get { return InnerHashtable.SyncRoot; }
+ }
- #endregion
+ #endregion
- #region Implementation of IEnumerable
+ #region Implementation of IEnumerable
- /// <summary>
- /// See <see cref="IEnumerable.GetEnumerator"/>
- /// </summary>
- IEnumerator IEnumerable.GetEnumerator()
- {
- return ((IEnumerable)InnerHashtable).GetEnumerator();
- }
+ /// <summary>
+ /// See <see cref="IEnumerable.GetEnumerator"/>
+ /// </summary>
+ IEnumerator IEnumerable.GetEnumerator()
+ {
+ return ((IEnumerable)InnerHashtable).GetEnumerator();
+ }
- #endregion
- }
+ #endregion
+ }
}
diff --git a/src/log4net/Util/ProtectCloseTextWriter.cs b/src/log4net/Util/ProtectCloseTextWriter.cs
index a90f283..d0c2446 100644
--- a/src/log4net/Util/ProtectCloseTextWriter.cs
+++ b/src/log4net/Util/ProtectCloseTextWriter.cs
@@ -25,69 +25,69 @@
namespace log4net.Util
{
- /// <summary>
- /// A <see cref="TextWriter"/> that ignores the <see cref="Close"/> message
- /// </summary>
- /// <remarks>
- /// <para>
- /// This writer is used in special cases where it is necessary
- /// to protect a writer from being closed by a client.
- /// </para>
- /// </remarks>
- /// <author>Nicko Cadell</author>
- public class ProtectCloseTextWriter : TextWriterAdapter
- {
- #region Public Instance Constructors
+ /// <summary>
+ /// A <see cref="TextWriter"/> that ignores the <see cref="Close"/> message
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// This writer is used in special cases where it is necessary
+ /// to protect a writer from being closed by a client.
+ /// </para>
+ /// </remarks>
+ /// <author>Nicko Cadell</author>
+ public class ProtectCloseTextWriter : TextWriterAdapter
+ {
+ #region Public Instance Constructors
- /// <summary>
- /// Constructor
- /// </summary>
- /// <param name="writer">the writer to actually write to</param>
- /// <remarks>
- /// <para>
- /// Create a new ProtectCloseTextWriter using a writer
- /// </para>
- /// </remarks>
- public ProtectCloseTextWriter(TextWriter writer) : base(writer)
- {
- }
+ /// <summary>
+ /// Constructor
+ /// </summary>
+ /// <param name="writer">the writer to actually write to</param>
+ /// <remarks>
+ /// <para>
+ /// Create a new ProtectCloseTextWriter using a writer
+ /// </para>
+ /// </remarks>
+ public ProtectCloseTextWriter(TextWriter writer) : base(writer)
+ {
+ }
- #endregion Public Instance Constructors
+ #endregion Public Instance Constructors
- #region Public Properties
+ #region Public Properties
- /// <summary>
- /// Attach this instance to a different underlying <see cref="TextWriter"/>
- /// </summary>
- /// <param name="writer">the writer to attach to</param>
- /// <remarks>
- /// <para>
- /// Attach this instance to a different underlying <see cref="TextWriter"/>
- /// </para>
- /// </remarks>
- public void Attach(TextWriter writer)
- {
- this.Writer = writer;
- }
+ /// <summary>
+ /// Attach this instance to a different underlying <see cref="TextWriter"/>
+ /// </summary>
+ /// <param name="writer">the writer to attach to</param>
+ /// <remarks>
+ /// <para>
+ /// Attach this instance to a different underlying <see cref="TextWriter"/>
+ /// </para>
+ /// </remarks>
+ public void Attach(TextWriter writer)
+ {
+ this.Writer = writer;
+ }
- #endregion
+ #endregion
- #region Override Implementation of TextWriter
+ #region Override Implementation of TextWriter
- /// <summary>
- /// Does not close the underlying output writer.
- /// </summary>
- /// <remarks>
- /// <para>
- /// Does not close the underlying output writer.
- /// This method does nothing.
- /// </para>
- /// </remarks>
- public override void Close()
- {
- // do nothing
- }
+ /// <summary>
+ /// Does not close the underlying output writer.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Does not close the underlying output writer.
+ /// This method does nothing.
+ /// </para>
+ /// </remarks>
+ public override void Close()
+ {
+ // do nothing
+ }
- #endregion Public Instance Methods
- }
+ #endregion Public Instance Methods
+ }
}
diff --git a/src/log4net/Util/QuietTextWriter.cs b/src/log4net/Util/QuietTextWriter.cs
index 6f3c757..f74c9c0 100644
--- a/src/log4net/Util/QuietTextWriter.cs
+++ b/src/log4net/Util/QuietTextWriter.cs
@@ -24,182 +24,182 @@
namespace log4net.Util
{
- /// <summary>
- /// <see cref="TextWriter"/> that does not leak exceptions
- /// </summary>
- /// <remarks>
- /// <para>
- /// <see cref="QuietTextWriter"/> does not throw exceptions when things go wrong.
- /// Instead, it delegates error handling to its <see cref="IErrorHandler"/>.
- /// </para>
- /// </remarks>
- /// <author>Nicko Cadell</author>
- /// <author>Gert Driesen</author>
- public class QuietTextWriter : TextWriterAdapter
- {
- #region Public Instance Constructors
+ /// <summary>
+ /// <see cref="TextWriter"/> that does not leak exceptions
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// <see cref="QuietTextWriter"/> does not throw exceptions when things go wrong.
+ /// Instead, it delegates error handling to its <see cref="IErrorHandler"/>.
+ /// </para>
+ /// </remarks>
+ /// <author>Nicko Cadell</author>
+ /// <author>Gert Driesen</author>
+ public class QuietTextWriter : TextWriterAdapter
+ {
+ #region Public Instance Constructors
- /// <summary>
- /// Constructor
- /// </summary>
- /// <param name="writer">the writer to actually write to</param>
- /// <param name="errorHandler">the error handler to report error to</param>
- /// <remarks>
- /// <para>
- /// Create a new QuietTextWriter using a writer and error handler
- /// </para>
- /// </remarks>
- public QuietTextWriter(TextWriter writer, IErrorHandler errorHandler) : base(writer)
- {
- if (errorHandler == null)
- {
- throw new ArgumentNullException("errorHandler");
- }
- ErrorHandler = errorHandler;
- }
+ /// <summary>
+ /// Constructor
+ /// </summary>
+ /// <param name="writer">the writer to actually write to</param>
+ /// <param name="errorHandler">the error handler to report error to</param>
+ /// <remarks>
+ /// <para>
+ /// Create a new QuietTextWriter using a writer and error handler
+ /// </para>
+ /// </remarks>
+ public QuietTextWriter(TextWriter writer, IErrorHandler errorHandler) : base(writer)
+ {
+ if (errorHandler == null)
+ {
+ throw new ArgumentNullException("errorHandler");
+ }
+ ErrorHandler = errorHandler;
+ }
- #endregion Public Instance Constructors
+ #endregion Public Instance Constructors
- #region Public Instance Properties
+ #region Public Instance Properties
- /// <summary>
- /// Gets or sets the error handler that all errors are passed to.
- /// </summary>
- /// <value>
- /// The error handler that all errors are passed to.
- /// </value>
- /// <remarks>
- /// <para>
- /// Gets or sets the error handler that all errors are passed to.
- /// </para>
- /// </remarks>
- public IErrorHandler ErrorHandler
- {
- get { return m_errorHandler; }
- set
- {
- if (value == null)
- {
- // This is a programming error on the part of the enclosing appender.
- throw new ArgumentNullException("value");
- }
- m_errorHandler = value;
- }
- }
+ /// <summary>
+ /// Gets or sets the error handler that all errors are passed to.
+ /// </summary>
+ /// <value>
+ /// The error handler that all errors are passed to.
+ /// </value>
+ /// <remarks>
+ /// <para>
+ /// Gets or sets the error handler that all errors are passed to.
+ /// </para>
+ /// </remarks>
+ public IErrorHandler ErrorHandler
+ {
+ get { return m_errorHandler; }
+ set
+ {
+ if (value == null)
+ {
+ // This is a programming error on the part of the enclosing appender.
+ throw new ArgumentNullException("value");
+ }
+ m_errorHandler = value;
+ }
+ }
- /// <summary>
- /// Gets a value indicating whether this writer is closed.
- /// </summary>
- /// <value>
- /// <c>true</c> if this writer is closed, otherwise <c>false</c>.
- /// </value>
- /// <remarks>
- /// <para>
- /// Gets a value indicating whether this writer is closed.
- /// </para>
- /// </remarks>
- public bool Closed
- {
- get { return m_closed; }
- }
+ /// <summary>
+ /// Gets a value indicating whether this writer is closed.
+ /// </summary>
+ /// <value>
+ /// <c>true</c> if this writer is closed, otherwise <c>false</c>.
+ /// </value>
+ /// <remarks>
+ /// <para>
+ /// Gets a value indicating whether this writer is closed.
+ /// </para>
+ /// </remarks>
+ public bool Closed
+ {
+ get { return m_closed; }
+ }
- #endregion Public Instance Properties
+ #endregion Public Instance Properties
- #region Override Implementation of TextWriter
+ #region Override Implementation of TextWriter
- /// <summary>
- /// Writes a character to the underlying writer
- /// </summary>
- /// <param name="value">the char to write</param>
- /// <remarks>
- /// <para>
- /// Writes a character to the underlying writer
- /// </para>
- /// </remarks>
- public override void Write(char value)
- {
- try
- {
- base.Write(value);
- }
- catch(Exception e)
- {
- m_errorHandler.Error("Failed to write [" + value + "].", e, ErrorCode.WriteFailure);
- }
- }
+ /// <summary>
+ /// Writes a character to the underlying writer
+ /// </summary>
+ /// <param name="value">the char to write</param>
+ /// <remarks>
+ /// <para>
+ /// Writes a character to the underlying writer
+ /// </para>
+ /// </remarks>
+ public override void Write(char value)
+ {
+ try
+ {
+ base.Write(value);
+ }
+ catch(Exception e)
+ {
+ m_errorHandler.Error("Failed to write [" + value + "].", e, ErrorCode.WriteFailure);
+ }
+ }
- /// <summary>
- /// Writes a buffer to the underlying writer
- /// </summary>
- /// <param name="buffer">the buffer to write</param>
- /// <param name="index">the start index to write from</param>
- /// <param name="count">the number of characters to write</param>
- /// <remarks>
- /// <para>
- /// Writes a buffer to the underlying writer
- /// </para>
- /// </remarks>
- public override void Write(char[] buffer, int index, int count)
- {
- try
- {
- base.Write(buffer, index, count);
- }
- catch(Exception e)
- {
- m_errorHandler.Error("Failed to write buffer.", e, ErrorCode.WriteFailure);
- }
- }
+ /// <summary>
+ /// Writes a buffer to the underlying writer
+ /// </summary>
+ /// <param name="buffer">the buffer to write</param>
+ /// <param name="index">the start index to write from</param>
+ /// <param name="count">the number of characters to write</param>
+ /// <remarks>
+ /// <para>
+ /// Writes a buffer to the underlying writer
+ /// </para>
+ /// </remarks>
+ public override void Write(char[] buffer, int index, int count)
+ {
+ try
+ {
+ base.Write(buffer, index, count);
+ }
+ catch(Exception e)
+ {
+ m_errorHandler.Error("Failed to write buffer.", e, ErrorCode.WriteFailure);
+ }
+ }
- /// <summary>
- /// Writes a string to the output.
- /// </summary>
- /// <param name="value">The string data to write to the output.</param>
- /// <remarks>
- /// <para>
- /// Writes a string to the output.
- /// </para>
- /// </remarks>
- public override void Write(string value)
- {
- try
- {
- base.Write(value);
- }
- catch(Exception e)
- {
- m_errorHandler.Error("Failed to write [" + value + "].", e, ErrorCode.WriteFailure);
- }
- }
+ /// <summary>
+ /// Writes a string to the output.
+ /// </summary>
+ /// <param name="value">The string data to write to the output.</param>
+ /// <remarks>
+ /// <para>
+ /// Writes a string to the output.
+ /// </para>
+ /// </remarks>
+ public override void Write(string value)
+ {
+ try
+ {
+ base.Write(value);
+ }
+ catch(Exception e)
+ {
+ m_errorHandler.Error("Failed to write [" + value + "].", e, ErrorCode.WriteFailure);
+ }
+ }
- /// <summary>
- /// Closes the underlying output writer.
- /// </summary>
- /// <remarks>
- /// <para>
- /// Closes the underlying output writer.
- /// </para>
- /// </remarks>
- public override void Close()
- {
- m_closed = true;
- base.Close();
- }
+ /// <summary>
+ /// Closes the underlying output writer.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Closes the underlying output writer.
+ /// </para>
+ /// </remarks>
+ public override void Close()
+ {
+ m_closed = true;
+ base.Close();
+ }
- #endregion Public Instance Methods
+ #endregion Public Instance Methods
- #region Private Instance Fields
+ #region Private Instance Fields
- /// <summary>
- /// The error handler instance to pass all errors to
- /// </summary>
- private IErrorHandler m_errorHandler;
+ /// <summary>
+ /// The error handler instance to pass all errors to
+ /// </summary>
+ private IErrorHandler m_errorHandler;
- /// <summary>
- /// Flag to indicate if this writer is closed
- /// </summary>
- private bool m_closed = false;
+ /// <summary>
+ /// Flag to indicate if this writer is closed
+ /// </summary>
+ private bool m_closed = false;
- #endregion Private Instance Fields
- }
+ #endregion Private Instance Fields
+ }
}
diff --git a/src/log4net/Util/ReadOnlyPropertiesDictionary.cs b/src/log4net/Util/ReadOnlyPropertiesDictionary.cs
index be37baf..632ce8c 100644
--- a/src/log4net/Util/ReadOnlyPropertiesDictionary.cs
+++ b/src/log4net/Util/ReadOnlyPropertiesDictionary.cs
@@ -27,200 +27,200 @@
namespace log4net.Util
{
- /// <summary>
- /// String keyed object map that is read only.
- /// </summary>
- /// <remarks>
- /// <para>
- /// This collection is readonly and cannot be modified.
- /// </para>
- /// <para>
- /// While this collection is serializable only member
- /// objects that are serializable will
- /// be serialized along with this collection.
- /// </para>
- /// </remarks>
- /// <author>Nicko Cadell</author>
- /// <author>Gert Driesen</author>
+ /// <summary>
+ /// String keyed object map that is read only.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// This collection is readonly and cannot be modified.
+ /// </para>
+ /// <para>
+ /// While this collection is serializable only member
+ /// objects that are serializable will
+ /// be serialized along with this collection.
+ /// </para>
+ /// </remarks>
+ /// <author>Nicko Cadell</author>
+ /// <author>Gert Driesen</author>
#if NETCF
- public class ReadOnlyPropertiesDictionary : IDictionary
+ public class ReadOnlyPropertiesDictionary : IDictionary
#else
- [Serializable] public class ReadOnlyPropertiesDictionary : ISerializable, IDictionary
+ [Serializable] public class ReadOnlyPropertiesDictionary : ISerializable, IDictionary
#endif
- {
- #region Private Instance Fields
+ {
+ #region Private Instance Fields
- /// <summary>
- /// The Hashtable used to store the properties data
- /// </summary>
- private readonly Hashtable m_hashtable = new Hashtable();
+ /// <summary>
+ /// The Hashtable used to store the properties data
+ /// </summary>
+ private readonly Hashtable m_hashtable = new Hashtable();
- #endregion Private Instance Fields
+ #endregion Private Instance Fields
- #region Public Instance Constructors
+ #region Public Instance Constructors
- /// <summary>
- /// Constructor
- /// </summary>
- /// <remarks>
- /// <para>
- /// Initializes a new instance of the <see cref="ReadOnlyPropertiesDictionary" /> class.
- /// </para>
- /// </remarks>
- public ReadOnlyPropertiesDictionary()
- {
- }
+ /// <summary>
+ /// Constructor
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Initializes a new instance of the <see cref="ReadOnlyPropertiesDictionary" /> class.
+ /// </para>
+ /// </remarks>
+ public ReadOnlyPropertiesDictionary()
+ {
+ }
- /// <summary>
- /// Copy Constructor
- /// </summary>
- /// <param name="propertiesDictionary">properties to copy</param>
- /// <remarks>
- /// <para>
- /// Initializes a new instance of the <see cref="ReadOnlyPropertiesDictionary" /> class.
- /// </para>
- /// </remarks>
- public ReadOnlyPropertiesDictionary(ReadOnlyPropertiesDictionary propertiesDictionary)
- {
- foreach(DictionaryEntry entry in propertiesDictionary)
- {
- InnerHashtable.Add(entry.Key, entry.Value);
- }
- }
+ /// <summary>
+ /// Copy Constructor
+ /// </summary>
+ /// <param name="propertiesDictionary">properties to copy</param>
+ /// <remarks>
+ /// <para>
+ /// Initializes a new instance of the <see cref="ReadOnlyPropertiesDictionary" /> class.
+ /// </para>
+ /// </remarks>
+ public ReadOnlyPropertiesDictionary(ReadOnlyPropertiesDictionary propertiesDictionary)
+ {
+ foreach(DictionaryEntry entry in propertiesDictionary)
+ {
+ InnerHashtable.Add(entry.Key, entry.Value);
+ }
+ }
- #endregion Public Instance Constructors
+ #endregion Public Instance Constructors
- #region Private Instance Constructors
+ #region Private Instance Constructors
#if !NETCF
- /// <summary>
- /// Deserialization constructor
- /// </summary>
- /// <param name="info">The <see cref="SerializationInfo" /> that holds the serialized object data.</param>
- /// <param name="context">The <see cref="StreamingContext" /> that contains contextual information about the source or destination.</param>
- /// <remarks>
- /// <para>
- /// Initializes a new instance of the <see cref="ReadOnlyPropertiesDictionary" /> class
- /// with serialized data.
- /// </para>
- /// </remarks>
- protected ReadOnlyPropertiesDictionary(SerializationInfo info, StreamingContext context)
- {
- foreach(var entry in info)
- {
- // The keys are stored as Xml encoded names
- InnerHashtable[XmlConvert.DecodeName(entry.Name)] = entry.Value;
- }
- }
+ /// <summary>
+ /// Deserialization constructor
+ /// </summary>
+ /// <param name="info">The <see cref="SerializationInfo" /> that holds the serialized object data.</param>
+ /// <param name="context">The <see cref="StreamingContext" /> that contains contextual information about the source or destination.</param>
+ /// <remarks>
+ /// <para>
+ /// Initializes a new instance of the <see cref="ReadOnlyPropertiesDictionary" /> class
+ /// with serialized data.
+ /// </para>
+ /// </remarks>
+ protected ReadOnlyPropertiesDictionary(SerializationInfo info, StreamingContext context)
+ {
+ foreach(var entry in info)
+ {
+ // The keys are stored as Xml encoded names
+ InnerHashtable[XmlConvert.DecodeName(entry.Name)] = entry.Value;
+ }
+ }
#endif
- #endregion Protected Instance Constructors
+ #endregion Protected Instance Constructors
- #region Public Instance Properties
+ #region Public Instance Properties
- /// <summary>
- /// Gets the key names.
- /// </summary>
- /// <returns>An array of all the keys.</returns>
- /// <remarks>
- /// <para>
- /// Gets the key names.
- /// </para>
- /// </remarks>
- public string[] GetKeys()
- {
- var keys = new String[InnerHashtable.Count];
- InnerHashtable.Keys.CopyTo(keys, 0);
- return keys;
- }
+ /// <summary>
+ /// Gets the key names.
+ /// </summary>
+ /// <returns>An array of all the keys.</returns>
+ /// <remarks>
+ /// <para>
+ /// Gets the key names.
+ /// </para>
+ /// </remarks>
+ public string[] GetKeys()
+ {
+ var keys = new String[InnerHashtable.Count];
+ InnerHashtable.Keys.CopyTo(keys, 0);
+ return keys;
+ }
- /// <summary>
- /// Gets or sets the value of the property with the specified key.
- /// </summary>
- /// <value>
- /// The value of the property with the specified key.
- /// </value>
- /// <param name="key">The key of the property to get or set.</param>
- /// <remarks>
- /// <para>
- /// The property value will only be serialized if it is serializable.
- /// If it cannot be serialized it will be silently ignored if
- /// a serialization operation is performed.
- /// </para>
- /// </remarks>
- public virtual object this[string key]
- {
- get { return InnerHashtable[key]; }
- set { throw new NotSupportedException("This is a Read Only Dictionary and can not be modified"); }
- }
+ /// <summary>
+ /// Gets or sets the value of the property with the specified key.
+ /// </summary>
+ /// <value>
+ /// The value of the property with the specified key.
+ /// </value>
+ /// <param name="key">The key of the property to get or set.</param>
+ /// <remarks>
+ /// <para>
+ /// The property value will only be serialized if it is serializable.
+ /// If it cannot be serialized it will be silently ignored if
+ /// a serialization operation is performed.
+ /// </para>
+ /// </remarks>
+ public virtual object this[string key]
+ {
+ get { return InnerHashtable[key]; }
+ set { throw new NotSupportedException("This is a Read Only Dictionary and can not be modified"); }
+ }
- #endregion Public Instance Properties
+ #endregion Public Instance Properties
- #region Public Instance Methods
+ #region Public Instance Methods
- /// <summary>
- /// Test if the dictionary contains a specified key
- /// </summary>
- /// <param name="key">the key to look for</param>
- /// <returns>true if the dictionary contains the specified key</returns>
- /// <remarks>
- /// <para>
- /// Test if the dictionary contains a specified key
- /// </para>
- /// </remarks>
- public bool Contains(string key)
- {
- return InnerHashtable.Contains(key);
- }
+ /// <summary>
+ /// Test if the dictionary contains a specified key
+ /// </summary>
+ /// <param name="key">the key to look for</param>
+ /// <returns>true if the dictionary contains the specified key</returns>
+ /// <remarks>
+ /// <para>
+ /// Test if the dictionary contains a specified key
+ /// </para>
+ /// </remarks>
+ public bool Contains(string key)
+ {
+ return InnerHashtable.Contains(key);
+ }
- #endregion
+ #endregion
- /// <summary>
- /// The hashtable used to store the properties
- /// </summary>
- /// <value>
- /// The internal collection used to store the properties
- /// </value>
- /// <remarks>
- /// <para>
- /// The hashtable used to store the properties
- /// </para>
- /// </remarks>
- protected Hashtable InnerHashtable
- {
- get { return m_hashtable; }
- }
+ /// <summary>
+ /// The hashtable used to store the properties
+ /// </summary>
+ /// <value>
+ /// The internal collection used to store the properties
+ /// </value>
+ /// <remarks>
+ /// <para>
+ /// The hashtable used to store the properties
+ /// </para>
+ /// </remarks>
+ protected Hashtable InnerHashtable
+ {
+ get { return m_hashtable; }
+ }
- #region Implementation of ISerializable
+ #region Implementation of ISerializable
#if !NETCF
- /// <summary>
- /// Serializes this object into the <see cref="SerializationInfo" /> provided.
- /// </summary>
- /// <param name="info">The <see cref="SerializationInfo" /> to populate with data.</param>
- /// <param name="context">The destination for this serialization.</param>
- /// <remarks>
- /// <para>
- /// Serializes this object into the <see cref="SerializationInfo" /> provided.
- /// </para>
- /// </remarks>
+ /// <summary>
+ /// Serializes this object into the <see cref="SerializationInfo" /> provided.
+ /// </summary>
+ /// <param name="info">The <see cref="SerializationInfo" /> to populate with data.</param>
+ /// <param name="context">The destination for this serialization.</param>
+ /// <remarks>
+ /// <para>
+ /// Serializes this object into the <see cref="SerializationInfo" /> provided.
+ /// </para>
+ /// </remarks>
#if NET_4_0 || MONO_4_0 || NETSTANDARD
[System.Security.SecurityCritical]
#endif
#if !NETCF && !NETSTANDARD1_3
- [System.Security.Permissions.SecurityPermission(System.Security.Permissions.SecurityAction.Demand, SerializationFormatter = true)]
+ [System.Security.Permissions.SecurityPermission(System.Security.Permissions.SecurityAction.Demand, SerializationFormatter = true)]
#endif
public virtual void GetObjectData(SerializationInfo info, StreamingContext context)
- {
- foreach(DictionaryEntry entry in InnerHashtable.Clone() as IDictionary)
- {
- var entryKey = entry.Key as string;
- if (entryKey is null)
- {
- continue;
- }
+ {
+ foreach(DictionaryEntry entry in InnerHashtable.Clone() as IDictionary)
+ {
+ var entryKey = entry.Key as string;
+ if (entryKey is null)
+ {
+ continue;
+ }
- var entryValue = entry.Value;
+ var entryValue = entry.Value;
// If value is serializable then we add it to the list
#if NETSTANDARD1_3
@@ -228,172 +228,172 @@
#else
var isSerializable = entryValue?.GetType().IsSerializable ?? false;
#endif
- if (!isSerializable)
- {
- continue;
- }
+ if (!isSerializable)
+ {
+ continue;
+ }
- // Store the keys as an Xml encoded local name as it may contain colons (':')
- // which are NOT escaped by the Xml Serialization framework.
- // This must be a bug in the serialization framework as we cannot be expected
- // to know the implementation details of all the possible transport layers.
- var localKeyName = XmlConvert.EncodeLocalName(entryKey);
- if (localKeyName is not null)
- {
- info.AddValue(localKeyName, entryValue);
- }
- }
- }
+ // Store the keys as an Xml encoded local name as it may contain colons (':')
+ // which are NOT escaped by the Xml Serialization framework.
+ // This must be a bug in the serialization framework as we cannot be expected
+ // to know the implementation details of all the possible transport layers.
+ var localKeyName = XmlConvert.EncodeLocalName(entryKey);
+ if (localKeyName is not null)
+ {
+ info.AddValue(localKeyName, entryValue);
+ }
+ }
+ }
#endif
- #endregion Implementation of ISerializable
+ #endregion Implementation of ISerializable
- #region Implementation of IDictionary
+ #region Implementation of IDictionary
- /// <summary>
- /// See <see cref="IDictionary.GetEnumerator"/>
- /// </summary>
- IDictionaryEnumerator IDictionary.GetEnumerator()
- {
- return InnerHashtable.GetEnumerator();
- }
+ /// <summary>
+ /// See <see cref="IDictionary.GetEnumerator"/>
+ /// </summary>
+ IDictionaryEnumerator IDictionary.GetEnumerator()
+ {
+ return InnerHashtable.GetEnumerator();
+ }
- /// <summary>
- /// See <see cref="IDictionary.Remove"/>
- /// </summary>
- /// <param name="key"></param>
- void IDictionary.Remove(object key)
- {
- throw new NotSupportedException("This is a Read Only Dictionary and can not be modified");
- }
+ /// <summary>
+ /// See <see cref="IDictionary.Remove"/>
+ /// </summary>
+ /// <param name="key"></param>
+ void IDictionary.Remove(object key)
+ {
+ throw new NotSupportedException("This is a Read Only Dictionary and can not be modified");
+ }
- /// <summary>
- /// See <see cref="IDictionary.Contains"/>
- /// </summary>
- /// <param name="key"></param>
- /// <returns></returns>
- bool IDictionary.Contains(object key)
- {
- return InnerHashtable.Contains(key);
- }
+ /// <summary>
+ /// See <see cref="IDictionary.Contains"/>
+ /// </summary>
+ /// <param name="key"></param>
+ /// <returns></returns>
+ bool IDictionary.Contains(object key)
+ {
+ return InnerHashtable.Contains(key);
+ }
- /// <summary>
- /// Remove all properties from the properties collection
- /// </summary>
- public virtual void Clear()
- {
- throw new NotSupportedException("This is a Read Only Dictionary and can not be modified");
- }
+ /// <summary>
+ /// Remove all properties from the properties collection
+ /// </summary>
+ public virtual void Clear()
+ {
+ throw new NotSupportedException("This is a Read Only Dictionary and can not be modified");
+ }
- /// <summary>
- /// See <see cref="IDictionary.Add"/>
- /// </summary>
- /// <param name="key"></param>
- /// <param name="value"></param>
- void IDictionary.Add(object key, object value)
- {
- throw new NotSupportedException("This is a Read Only Dictionary and can not be modified");
- }
+ /// <summary>
+ /// See <see cref="IDictionary.Add"/>
+ /// </summary>
+ /// <param name="key"></param>
+ /// <param name="value"></param>
+ void IDictionary.Add(object key, object value)
+ {
+ throw new NotSupportedException("This is a Read Only Dictionary and can not be modified");
+ }
- /// <summary>
- /// See <see cref="IDictionary.IsReadOnly"/>
- /// </summary>
- bool IDictionary.IsReadOnly
- {
- get { return true; }
- }
+ /// <summary>
+ /// See <see cref="IDictionary.IsReadOnly"/>
+ /// </summary>
+ bool IDictionary.IsReadOnly
+ {
+ get { return true; }
+ }
- /// <summary>
- /// See <see cref="IDictionary.this[object]"/>
- /// </summary>
- object IDictionary.this[object key]
- {
- get
- {
- if (!(key is string)) throw new ArgumentException("key must be a string");
- return InnerHashtable[key];
- }
- set
- {
- throw new NotSupportedException("This is a Read Only Dictionary and can not be modified");
- }
- }
+ /// <summary>
+ /// See <see cref="IDictionary.this[object]"/>
+ /// </summary>
+ object IDictionary.this[object key]
+ {
+ get
+ {
+ if (!(key is string)) throw new ArgumentException("key must be a string");
+ return InnerHashtable[key];
+ }
+ set
+ {
+ throw new NotSupportedException("This is a Read Only Dictionary and can not be modified");
+ }
+ }
- /// <summary>
- /// See <see cref="IDictionary.Values"/>
- /// </summary>
- ICollection IDictionary.Values
- {
- get { return InnerHashtable.Values; }
- }
+ /// <summary>
+ /// See <see cref="IDictionary.Values"/>
+ /// </summary>
+ ICollection IDictionary.Values
+ {
+ get { return InnerHashtable.Values; }
+ }
- /// <summary>
- /// See <see cref="IDictionary.Keys"/>
- /// </summary>
- ICollection IDictionary.Keys
- {
- get { return InnerHashtable.Keys; }
- }
+ /// <summary>
+ /// See <see cref="IDictionary.Keys"/>
+ /// </summary>
+ ICollection IDictionary.Keys
+ {
+ get { return InnerHashtable.Keys; }
+ }
- /// <summary>
- /// See <see cref="IDictionary.IsFixedSize"/>
- /// </summary>
- bool IDictionary.IsFixedSize
- {
- get { return InnerHashtable.IsFixedSize; }
- }
+ /// <summary>
+ /// See <see cref="IDictionary.IsFixedSize"/>
+ /// </summary>
+ bool IDictionary.IsFixedSize
+ {
+ get { return InnerHashtable.IsFixedSize; }
+ }
- #endregion
+ #endregion
- #region Implementation of ICollection
+ #region Implementation of ICollection
- /// <summary>
- /// See <see cref="ICollection.CopyTo"/>
- /// </summary>
- /// <param name="array"></param>
- /// <param name="index"></param>
- void ICollection.CopyTo(Array array, int index)
- {
- InnerHashtable.CopyTo(array, index);
- }
+ /// <summary>
+ /// See <see cref="ICollection.CopyTo"/>
+ /// </summary>
+ /// <param name="array"></param>
+ /// <param name="index"></param>
+ void ICollection.CopyTo(Array array, int index)
+ {
+ InnerHashtable.CopyTo(array, index);
+ }
- /// <summary>
- /// See <see cref="ICollection.IsSynchronized"/>
- /// </summary>
- bool ICollection.IsSynchronized
- {
- get { return InnerHashtable.IsSynchronized; }
- }
+ /// <summary>
+ /// See <see cref="ICollection.IsSynchronized"/>
+ /// </summary>
+ bool ICollection.IsSynchronized
+ {
+ get { return InnerHashtable.IsSynchronized; }
+ }
- /// <summary>
- /// The number of properties in this collection
- /// </summary>
- public int Count
- {
- get { return InnerHashtable.Count; }
- }
+ /// <summary>
+ /// The number of properties in this collection
+ /// </summary>
+ public int Count
+ {
+ get { return InnerHashtable.Count; }
+ }
- /// <summary>
- /// See <see cref="ICollection.SyncRoot"/>
- /// </summary>
- object ICollection.SyncRoot
- {
- get { return InnerHashtable.SyncRoot; }
- }
+ /// <summary>
+ /// See <see cref="ICollection.SyncRoot"/>
+ /// </summary>
+ object ICollection.SyncRoot
+ {
+ get { return InnerHashtable.SyncRoot; }
+ }
- #endregion
+ #endregion
- #region Implementation of IEnumerable
+ #region Implementation of IEnumerable
- /// <summary>
- /// See <see cref="IEnumerable.GetEnumerator"/>
- /// </summary>
- IEnumerator IEnumerable.GetEnumerator()
- {
- return ((IEnumerable)InnerHashtable).GetEnumerator();
- }
+ /// <summary>
+ /// See <see cref="IEnumerable.GetEnumerator"/>
+ /// </summary>
+ IEnumerator IEnumerable.GetEnumerator()
+ {
+ return ((IEnumerable)InnerHashtable).GetEnumerator();
+ }
- #endregion
- }
+ #endregion
+ }
}
diff --git a/src/log4net/Util/ReaderWriterLock.cs b/src/log4net/Util/ReaderWriterLock.cs
index 3c70b9d..7654d39 100644
--- a/src/log4net/Util/ReaderWriterLock.cs
+++ b/src/log4net/Util/ReaderWriterLock.cs
@@ -28,164 +28,164 @@
namespace log4net.Util
{
- /// <summary>
- /// Defines a lock that supports single writers and multiple readers
- /// </summary>
- /// <remarks>
- /// <para>
- /// <c>ReaderWriterLock</c> is used to synchronize access to a resource.
- /// At any given time, it allows either concurrent read access for
- /// multiple threads, or write access for a single thread. In a
- /// situation where a resource is changed infrequently, a
- /// <c>ReaderWriterLock</c> provides better throughput than a simple
- /// one-at-a-time lock, such as <see cref="System.Threading.Monitor"/>.
- /// </para>
- /// <para>
- /// If a platform does not support a <c>System.Threading.ReaderWriterLock</c>
- /// implementation then all readers and writers are serialized. Therefore
- /// the caller must not rely on multiple simultaneous readers.
- /// </para>
- /// </remarks>
- /// <author>Nicko Cadell</author>
- public sealed class ReaderWriterLock
- {
- #region Instance Constructors
+ /// <summary>
+ /// Defines a lock that supports single writers and multiple readers
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// <c>ReaderWriterLock</c> is used to synchronize access to a resource.
+ /// At any given time, it allows either concurrent read access for
+ /// multiple threads, or write access for a single thread. In a
+ /// situation where a resource is changed infrequently, a
+ /// <c>ReaderWriterLock</c> provides better throughput than a simple
+ /// one-at-a-time lock, such as <see cref="System.Threading.Monitor"/>.
+ /// </para>
+ /// <para>
+ /// If a platform does not support a <c>System.Threading.ReaderWriterLock</c>
+ /// implementation then all readers and writers are serialized. Therefore
+ /// the caller must not rely on multiple simultaneous readers.
+ /// </para>
+ /// </remarks>
+ /// <author>Nicko Cadell</author>
+ public sealed class ReaderWriterLock
+ {
+ #region Instance Constructors
- /// <summary>
- /// Constructor
- /// </summary>
- /// <remarks>
- /// <para>
- /// Initializes a new instance of the <see cref="ReaderWriterLock" /> class.
- /// </para>
- /// </remarks>
- public ReaderWriterLock()
- {
+ /// <summary>
+ /// Constructor
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Initializes a new instance of the <see cref="ReaderWriterLock" /> class.
+ /// </para>
+ /// </remarks>
+ public ReaderWriterLock()
+ {
#if HAS_READERWRITERLOCK
#if HAS_READERWRITERLOCKSLIM
- m_lock = new System.Threading.ReaderWriterLockSlim(System.Threading.LockRecursionPolicy.SupportsRecursion);
+ m_lock = new System.Threading.ReaderWriterLockSlim(System.Threading.LockRecursionPolicy.SupportsRecursion);
#else
- m_lock = new System.Threading.ReaderWriterLock();
+ m_lock = new System.Threading.ReaderWriterLock();
#endif
#endif
- }
+ }
- #endregion Private Instance Constructors
+ #endregion Private Instance Constructors
- #region Public Methods
+ #region Public Methods
- /// <summary>
- /// Acquires a reader lock
- /// </summary>
- /// <remarks>
- /// <para>
- /// <see cref="AcquireReaderLock"/> blocks if a different thread has the writer
- /// lock, or if at least one thread is waiting for the writer lock.
- /// </para>
- /// </remarks>
- public void AcquireReaderLock()
- {
+ /// <summary>
+ /// Acquires a reader lock
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// <see cref="AcquireReaderLock"/> blocks if a different thread has the writer
+ /// lock, or if at least one thread is waiting for the writer lock.
+ /// </para>
+ /// </remarks>
+ public void AcquireReaderLock()
+ {
#if HAS_READERWRITERLOCK
#if HAS_READERWRITERLOCKSLIM
// prevent ThreadAbort while updating state, see https://issues.apache.org/jira/browse/LOG4NET-443
try { }
finally
{
- m_lock.EnterReadLock();
+ m_lock.EnterReadLock();
}
#else
- m_lock.AcquireReaderLock(-1);
+ m_lock.AcquireReaderLock(-1);
#endif
#else
- System.Threading.Monitor.Enter(this);
+ System.Threading.Monitor.Enter(this);
#endif
- }
+ }
- /// <summary>
- /// Decrements the lock count
- /// </summary>
- /// <remarks>
- /// <para>
- /// <see cref="ReleaseReaderLock"/> decrements the lock count. When the count
- /// reaches zero, the lock is released.
- /// </para>
- /// </remarks>
- public void ReleaseReaderLock()
- {
+ /// <summary>
+ /// Decrements the lock count
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// <see cref="ReleaseReaderLock"/> decrements the lock count. When the count
+ /// reaches zero, the lock is released.
+ /// </para>
+ /// </remarks>
+ public void ReleaseReaderLock()
+ {
#if HAS_READERWRITERLOCK
#if HAS_READERWRITERLOCKSLIM
- m_lock.ExitReadLock();
+ m_lock.ExitReadLock();
#else
- m_lock.ReleaseReaderLock();
+ m_lock.ReleaseReaderLock();
#endif
#else
- System.Threading.Monitor.Exit(this);
+ System.Threading.Monitor.Exit(this);
#endif
- }
+ }
- /// <summary>
- /// Acquires the writer lock
- /// </summary>
- /// <remarks>
- /// <para>
- /// This method blocks if another thread has a reader lock or writer lock.
- /// </para>
- /// </remarks>
- public void AcquireWriterLock()
- {
+ /// <summary>
+ /// Acquires the writer lock
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// This method blocks if another thread has a reader lock or writer lock.
+ /// </para>
+ /// </remarks>
+ public void AcquireWriterLock()
+ {
#if HAS_READERWRITERLOCK
#if HAS_READERWRITERLOCKSLIM
// prevent ThreadAbort while updating state, see https://issues.apache.org/jira/browse/LOG4NET-443
try { }
finally
{
- m_lock.EnterWriteLock();
+ m_lock.EnterWriteLock();
}
#else
- m_lock.AcquireWriterLock(-1);
+ m_lock.AcquireWriterLock(-1);
#endif
#else
- System.Threading.Monitor.Enter(this);
+ System.Threading.Monitor.Enter(this);
#endif
- }
+ }
- /// <summary>
- /// Decrements the lock count on the writer lock
- /// </summary>
- /// <remarks>
- /// <para>
- /// ReleaseWriterLock decrements the writer lock count.
- /// When the count reaches zero, the writer lock is released.
- /// </para>
- /// </remarks>
- public void ReleaseWriterLock()
- {
+ /// <summary>
+ /// Decrements the lock count on the writer lock
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// ReleaseWriterLock decrements the writer lock count.
+ /// When the count reaches zero, the writer lock is released.
+ /// </para>
+ /// </remarks>
+ public void ReleaseWriterLock()
+ {
#if HAS_READERWRITERLOCK
#if HAS_READERWRITERLOCKSLIM
- m_lock.ExitWriteLock();
+ m_lock.ExitWriteLock();
#else
- m_lock.ReleaseWriterLock();
+ m_lock.ReleaseWriterLock();
#endif
#else
- System.Threading.Monitor.Exit(this);
+ System.Threading.Monitor.Exit(this);
#endif
- }
+ }
- #endregion Public Methods
+ #endregion Public Methods
- #region Private Members
+ #region Private Members
#if HAS_READERWRITERLOCK
#if HAS_READERWRITERLOCKSLIM
- private System.Threading.ReaderWriterLockSlim m_lock;
+ private System.Threading.ReaderWriterLockSlim m_lock;
#else
- private System.Threading.ReaderWriterLock m_lock;
+ private System.Threading.ReaderWriterLock m_lock;
#endif
#endif
- #endregion
- }
+ #endregion
+ }
}
\ No newline at end of file
diff --git a/src/log4net/Util/ReusableStringWriter.cs b/src/log4net/Util/ReusableStringWriter.cs
index 8c1aad1..3a7edee 100644
--- a/src/log4net/Util/ReusableStringWriter.cs
+++ b/src/log4net/Util/ReusableStringWriter.cs
@@ -23,72 +23,72 @@
namespace log4net.Util
{
- /// <summary>
- /// A <see cref="StringWriter"/> that can be <see cref="Reset"/> and reused
- /// </summary>
- /// <remarks>
- /// <para>
- /// A <see cref="StringWriter"/> that can be <see cref="Reset"/> and reused.
- /// This uses a single buffer for string operations.
- /// </para>
- /// </remarks>
- /// <author>Nicko Cadell</author>
- public class ReusableStringWriter : StringWriter
- {
- #region Constructor
+ /// <summary>
+ /// A <see cref="StringWriter"/> that can be <see cref="Reset"/> and reused
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// A <see cref="StringWriter"/> that can be <see cref="Reset"/> and reused.
+ /// This uses a single buffer for string operations.
+ /// </para>
+ /// </remarks>
+ /// <author>Nicko Cadell</author>
+ public class ReusableStringWriter : StringWriter
+ {
+ #region Constructor
- /// <summary>
- /// Create an instance of <see cref="ReusableStringWriter"/>
- /// </summary>
- /// <param name="formatProvider">the format provider to use</param>
- /// <remarks>
- /// <para>
- /// Create an instance of <see cref="ReusableStringWriter"/>
- /// </para>
- /// </remarks>
- public ReusableStringWriter(IFormatProvider formatProvider) : base(formatProvider)
- {
- }
+ /// <summary>
+ /// Create an instance of <see cref="ReusableStringWriter"/>
+ /// </summary>
+ /// <param name="formatProvider">the format provider to use</param>
+ /// <remarks>
+ /// <para>
+ /// Create an instance of <see cref="ReusableStringWriter"/>
+ /// </para>
+ /// </remarks>
+ public ReusableStringWriter(IFormatProvider formatProvider) : base(formatProvider)
+ {
+ }
- #endregion
+ #endregion
- /// <summary>
- /// Override Dispose to prevent closing of writer
- /// </summary>
- /// <param name="disposing">flag</param>
- /// <remarks>
- /// <para>
- /// Override Dispose to prevent closing of writer
- /// </para>
- /// </remarks>
- protected override void Dispose(bool disposing)
- {
- // Do not close the writer
- }
+ /// <summary>
+ /// Override Dispose to prevent closing of writer
+ /// </summary>
+ /// <param name="disposing">flag</param>
+ /// <remarks>
+ /// <para>
+ /// Override Dispose to prevent closing of writer
+ /// </para>
+ /// </remarks>
+ protected override void Dispose(bool disposing)
+ {
+ // Do not close the writer
+ }
- /// <summary>
- /// Reset this string writer so that it can be reused.
- /// </summary>
- /// <param name="maxCapacity">the maximum buffer capacity before it is trimmed</param>
- /// <param name="defaultSize">the default size to make the buffer</param>
- /// <remarks>
- /// <para>
- /// Reset this string writer so that it can be reused.
- /// The internal buffers are cleared and reset.
- /// </para>
- /// </remarks>
- public void Reset(int maxCapacity, int defaultSize)
- {
- // Reset working string buffer
- StringBuilder sb = this.GetStringBuilder();
+ /// <summary>
+ /// Reset this string writer so that it can be reused.
+ /// </summary>
+ /// <param name="maxCapacity">the maximum buffer capacity before it is trimmed</param>
+ /// <param name="defaultSize">the default size to make the buffer</param>
+ /// <remarks>
+ /// <para>
+ /// Reset this string writer so that it can be reused.
+ /// The internal buffers are cleared and reset.
+ /// </para>
+ /// </remarks>
+ public void Reset(int maxCapacity, int defaultSize)
+ {
+ // Reset working string buffer
+ StringBuilder sb = this.GetStringBuilder();
- sb.Length = 0;
-
- // Check if over max size
- if (sb.Capacity > maxCapacity)
- {
- sb.Capacity = defaultSize;
- }
- }
- }
+ sb.Length = 0;
+
+ // Check if over max size
+ if (sb.Capacity > maxCapacity)
+ {
+ sb.Capacity = defaultSize;
+ }
+ }
+ }
}
diff --git a/src/log4net/Util/SystemInfo.cs b/src/log4net/Util/SystemInfo.cs
index 821a230..5cf7980 100644
--- a/src/log4net/Util/SystemInfo.cs
+++ b/src/log4net/Util/SystemInfo.cs
@@ -29,1307 +29,1307 @@
namespace log4net.Util
{
- /// <summary>
- /// Utility class for system specific information.
- /// </summary>
- /// <remarks>
- /// <para>
- /// Utility class of static methods for system specific information.
- /// </para>
- /// </remarks>
- /// <author>Nicko Cadell</author>
- /// <author>Gert Driesen</author>
- /// <author>Alexey Solofnenko</author>
- public sealed class SystemInfo
- {
- #region Private Constants
+ /// <summary>
+ /// Utility class for system specific information.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Utility class of static methods for system specific information.
+ /// </para>
+ /// </remarks>
+ /// <author>Nicko Cadell</author>
+ /// <author>Gert Driesen</author>
+ /// <author>Alexey Solofnenko</author>
+ public sealed class SystemInfo
+ {
+ #region Private Constants
- private const string DEFAULT_NULL_TEXT = "(null)";
- private const string DEFAULT_NOT_AVAILABLE_TEXT = "NOT AVAILABLE";
+ private const string DEFAULT_NULL_TEXT = "(null)";
+ private const string DEFAULT_NOT_AVAILABLE_TEXT = "NOT AVAILABLE";
- #endregion
+ #endregion
- #region Private Instance Constructors
+ #region Private Instance Constructors
- /// <summary>
- /// Private constructor to prevent instances.
- /// </summary>
- /// <remarks>
- /// <para>
- /// Only static methods are exposed from this type.
- /// </para>
- /// </remarks>
- private SystemInfo()
- {
- }
+ /// <summary>
+ /// Private constructor to prevent instances.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Only static methods are exposed from this type.
+ /// </para>
+ /// </remarks>
+ private SystemInfo()
+ {
+ }
- #endregion Private Instance Constructors
+ #endregion Private Instance Constructors
- #region Public Static Constructor
+ #region Public Static Constructor
- /// <summary>
- /// Initialize default values for private static fields.
- /// </summary>
- /// <remarks>
- /// <para>
- /// Only static methods are exposed from this type.
- /// </para>
- /// </remarks>
- static SystemInfo()
- {
- string nullText = DEFAULT_NULL_TEXT;
- string notAvailableText = DEFAULT_NOT_AVAILABLE_TEXT;
+ /// <summary>
+ /// Initialize default values for private static fields.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Only static methods are exposed from this type.
+ /// </para>
+ /// </remarks>
+ static SystemInfo()
+ {
+ string nullText = DEFAULT_NULL_TEXT;
+ string notAvailableText = DEFAULT_NOT_AVAILABLE_TEXT;
#if !NETCF
- // Look for log4net.NullText in AppSettings
- string nullTextAppSettingsKey = SystemInfo.GetAppSetting("log4net.NullText");
- if (nullTextAppSettingsKey != null && nullTextAppSettingsKey.Length > 0)
- {
- LogLog.Debug(declaringType, "Initializing NullText value to [" + nullTextAppSettingsKey + "].");
- nullText = nullTextAppSettingsKey;
- }
+ // Look for log4net.NullText in AppSettings
+ string nullTextAppSettingsKey = SystemInfo.GetAppSetting("log4net.NullText");
+ if (nullTextAppSettingsKey != null && nullTextAppSettingsKey.Length > 0)
+ {
+ LogLog.Debug(declaringType, "Initializing NullText value to [" + nullTextAppSettingsKey + "].");
+ nullText = nullTextAppSettingsKey;
+ }
- // Look for log4net.NotAvailableText in AppSettings
- string notAvailableTextAppSettingsKey = SystemInfo.GetAppSetting("log4net.NotAvailableText");
- if (notAvailableTextAppSettingsKey != null && notAvailableTextAppSettingsKey.Length > 0)
- {
- LogLog.Debug(declaringType, "Initializing NotAvailableText value to [" + notAvailableTextAppSettingsKey + "].");
- notAvailableText = notAvailableTextAppSettingsKey;
- }
+ // Look for log4net.NotAvailableText in AppSettings
+ string notAvailableTextAppSettingsKey = SystemInfo.GetAppSetting("log4net.NotAvailableText");
+ if (notAvailableTextAppSettingsKey != null && notAvailableTextAppSettingsKey.Length > 0)
+ {
+ LogLog.Debug(declaringType, "Initializing NotAvailableText value to [" + notAvailableTextAppSettingsKey + "].");
+ notAvailableText = notAvailableTextAppSettingsKey;
+ }
#endif
- s_notAvailableText = notAvailableText;
- s_nullText = nullText;
- }
+ s_notAvailableText = notAvailableText;
+ s_nullText = nullText;
+ }
- #endregion
+ #endregion
- #region Public Static Properties
+ #region Public Static Properties
- /// <summary>
- /// Gets the system dependent line terminator.
- /// </summary>
- /// <value>
- /// The system dependent line terminator.
- /// </value>
- /// <remarks>
- /// <para>
- /// Gets the system dependent line terminator.
- /// </para>
- /// </remarks>
- public static string NewLine
- {
- get
- {
+ /// <summary>
+ /// Gets the system dependent line terminator.
+ /// </summary>
+ /// <value>
+ /// The system dependent line terminator.
+ /// </value>
+ /// <remarks>
+ /// <para>
+ /// Gets the system dependent line terminator.
+ /// </para>
+ /// </remarks>
+ public static string NewLine
+ {
+ get
+ {
#if NETCF
- return "\r\n";
+ return "\r\n";
#else
- return System.Environment.NewLine;
+ return System.Environment.NewLine;
#endif
- }
- }
+ }
+ }
- /// <summary>
- /// Gets the base directory for this <see cref="AppDomain"/>.
- /// </summary>
- /// <value>The base directory path for the current <see cref="AppDomain"/>.</value>
- /// <remarks>
- /// <para>
- /// Gets the base directory for this <see cref="AppDomain"/>.
- /// </para>
- /// <para>
- /// The value returned may be either a local file path or a URI.
- /// </para>
- /// </remarks>
- public static string ApplicationBaseDirectory
- {
- get
- {
+ /// <summary>
+ /// Gets the base directory for this <see cref="AppDomain"/>.
+ /// </summary>
+ /// <value>The base directory path for the current <see cref="AppDomain"/>.</value>
+ /// <remarks>
+ /// <para>
+ /// Gets the base directory for this <see cref="AppDomain"/>.
+ /// </para>
+ /// <para>
+ /// The value returned may be either a local file path or a URI.
+ /// </para>
+ /// </remarks>
+ public static string ApplicationBaseDirectory
+ {
+ get
+ {
#if NETCF
-- return System.IO.Path.GetDirectoryName(SystemInfo.EntryAssemblyLocation) + System.IO.Path.DirectorySeparatorChar;
+- return System.IO.Path.GetDirectoryName(SystemInfo.EntryAssemblyLocation) + System.IO.Path.DirectorySeparatorChar;
#elif NETSTANDARD1_3
- return Directory.GetCurrentDirectory();
+ return Directory.GetCurrentDirectory();
#else
- return AppDomain.CurrentDomain.BaseDirectory;
+ return AppDomain.CurrentDomain.BaseDirectory;
#endif
- }
- }
+ }
+ }
- /// <summary>
- /// Gets the path to the configuration file for the current <see cref="AppDomain"/>.
- /// </summary>
- /// <value>The path to the configuration file for the current <see cref="AppDomain"/>.</value>
- /// <remarks>
- /// <para>
- /// The .NET Compact Framework 1.0 does not have a concept of a configuration
- /// file. For this runtime, we use the entry assembly location as the root for
- /// the configuration file name.
- /// </para>
- /// <para>
- /// The value returned may be either a local file path or a URI.
- /// </para>
- /// </remarks>
- public static string ConfigurationFileLocation
- {
- get
- {
+ /// <summary>
+ /// Gets the path to the configuration file for the current <see cref="AppDomain"/>.
+ /// </summary>
+ /// <value>The path to the configuration file for the current <see cref="AppDomain"/>.</value>
+ /// <remarks>
+ /// <para>
+ /// The .NET Compact Framework 1.0 does not have a concept of a configuration
+ /// file. For this runtime, we use the entry assembly location as the root for
+ /// the configuration file name.
+ /// </para>
+ /// <para>
+ /// The value returned may be either a local file path or a URI.
+ /// </para>
+ /// </remarks>
+ public static string ConfigurationFileLocation
+ {
+ get
+ {
#if NETCF || NETSTANDARD
- return SystemInfo.EntryAssemblyLocation+".config";
+ return SystemInfo.EntryAssemblyLocation+".config";
#else
- return System.AppDomain.CurrentDomain.SetupInformation.ConfigurationFile;
+ return System.AppDomain.CurrentDomain.SetupInformation.ConfigurationFile;
#endif
- }
- }
+ }
+ }
- private static string entryAssemblyLocation;
+ private static string entryAssemblyLocation;
- /// <summary>
- /// Gets the path to the file that first executed in the current <see cref="AppDomain"/>.
- /// </summary>
- /// <value>The path to the entry assembly.</value>
- /// <remarks>
- /// <para>
- /// Gets the path to the file that first executed in the current <see cref="AppDomain"/>.
- /// </para>
- /// </remarks>
- public static string EntryAssemblyLocation
- {
- get
- {
- if (entryAssemblyLocation != null)
- return entryAssemblyLocation;
+ /// <summary>
+ /// Gets the path to the file that first executed in the current <see cref="AppDomain"/>.
+ /// </summary>
+ /// <value>The path to the entry assembly.</value>
+ /// <remarks>
+ /// <para>
+ /// Gets the path to the file that first executed in the current <see cref="AppDomain"/>.
+ /// </para>
+ /// </remarks>
+ public static string EntryAssemblyLocation
+ {
+ get
+ {
+ if (entryAssemblyLocation != null)
+ return entryAssemblyLocation;
#if NETCF
- return entryAssemblyLocation = SystemInfo.NativeEntryAssemblyLocation;
+ return entryAssemblyLocation = SystemInfo.NativeEntryAssemblyLocation;
#elif NETSTANDARD1_3 // TODO GetEntryAssembly is available for netstandard1.5
- return entryAssemblyLocation = AppContext.BaseDirectory;
+ return entryAssemblyLocation = AppContext.BaseDirectory;
#else
- return entryAssemblyLocation = Assembly.GetEntryAssembly()?.Location
- ?? throw new InvalidOperationException($"Unable to determine EntryAssembly location: EntryAssembly is null. Try explicitly setting {nameof(SystemInfo)}.{nameof(EntryAssemblyLocation)}");
+ return entryAssemblyLocation = Assembly.GetEntryAssembly()?.Location
+ ?? throw new InvalidOperationException($"Unable to determine EntryAssembly location: EntryAssembly is null. Try explicitly setting {nameof(SystemInfo)}.{nameof(EntryAssemblyLocation)}");
#endif
- }
- set => entryAssemblyLocation = value;
- }
+ }
+ set => entryAssemblyLocation = value;
+ }
- /// <summary>
- /// Gets the ID of the current thread.
- /// </summary>
- /// <value>The ID of the current thread.</value>
- /// <remarks>
- /// <para>
- /// On the .NET framework, the <c>AppDomain.GetCurrentThreadId</c> method
- /// is used to obtain the thread ID for the current thread. This is the
- /// operating system ID for the thread.
- /// </para>
- /// <para>
- /// On the .NET Compact Framework 1.0 it is not possible to get the
- /// operating system thread ID for the current thread. The native method
- /// <c>GetCurrentThreadId</c> is implemented inline in a header file
- /// and cannot be called.
- /// </para>
- /// <para>
- /// On the .NET Framework 2.0 the <c>Thread.ManagedThreadId</c> is used as this
- /// gives a stable id unrelated to the operating system thread ID which may
- /// change if the runtime is using fibers.
- /// </para>
- /// </remarks>
- public static int CurrentThreadId
- {
- get
- {
+ /// <summary>
+ /// Gets the ID of the current thread.
+ /// </summary>
+ /// <value>The ID of the current thread.</value>
+ /// <remarks>
+ /// <para>
+ /// On the .NET framework, the <c>AppDomain.GetCurrentThreadId</c> method
+ /// is used to obtain the thread ID for the current thread. This is the
+ /// operating system ID for the thread.
+ /// </para>
+ /// <para>
+ /// On the .NET Compact Framework 1.0 it is not possible to get the
+ /// operating system thread ID for the current thread. The native method
+ /// <c>GetCurrentThreadId</c> is implemented inline in a header file
+ /// and cannot be called.
+ /// </para>
+ /// <para>
+ /// On the .NET Framework 2.0 the <c>Thread.ManagedThreadId</c> is used as this
+ /// gives a stable id unrelated to the operating system thread ID which may
+ /// change if the runtime is using fibers.
+ /// </para>
+ /// </remarks>
+ public static int CurrentThreadId
+ {
+ get
+ {
#if NETCF_1_0
- return System.Threading.Thread.CurrentThread.GetHashCode();
+ return System.Threading.Thread.CurrentThread.GetHashCode();
#elif NET_2_0 || NETCF_2_0 || MONO_2_0 || MONO_3_5 || MONO_4_0 || NETSTANDARD
- return System.Threading.Thread.CurrentThread.ManagedThreadId;
+ return System.Threading.Thread.CurrentThread.ManagedThreadId;
#else
- return AppDomain.GetCurrentThreadId();
+ return AppDomain.GetCurrentThreadId();
#endif
- }
- }
+ }
+ }
- /// <summary>
- /// Get the host name or machine name for the current machine
- /// </summary>
- /// <value>
- /// The hostname or machine name
- /// </value>
- /// <remarks>
- /// <para>
- /// Get the host name or machine name for the current machine
- /// </para>
- /// <para>
- /// The host name (<see cref="System.Net.Dns.GetHostName"/>) or
- /// the machine name (<c>Environment.MachineName</c>) for
- /// the current machine, or if neither of these are available
- /// then <c>NOT AVAILABLE</c> is returned.
- /// </para>
- /// </remarks>
- public static string HostName
- {
- get
- {
- if (s_hostName == null)
- {
+ /// <summary>
+ /// Get the host name or machine name for the current machine
+ /// </summary>
+ /// <value>
+ /// The hostname or machine name
+ /// </value>
+ /// <remarks>
+ /// <para>
+ /// Get the host name or machine name for the current machine
+ /// </para>
+ /// <para>
+ /// The host name (<see cref="System.Net.Dns.GetHostName"/>) or
+ /// the machine name (<c>Environment.MachineName</c>) for
+ /// the current machine, or if neither of these are available
+ /// then <c>NOT AVAILABLE</c> is returned.
+ /// </para>
+ /// </remarks>
+ public static string HostName
+ {
+ get
+ {
+ if (s_hostName == null)
+ {
- // Get the DNS host name of the current machine
- try
- {
- // Lookup the host name
- s_hostName = System.Net.Dns.GetHostName();
- }
- catch (System.Net.Sockets.SocketException)
- {
- LogLog.Debug(declaringType, "Socket exception occurred while getting the dns hostname. Error Ignored.");
- }
- catch (System.Security.SecurityException)
- {
- // We may get a security exception looking up the hostname
- // You must have Unrestricted DnsPermission to access resource
- LogLog.Debug(declaringType, "Security exception occurred while getting the dns hostname. Error Ignored.");
- }
- catch (Exception ex)
- {
- LogLog.Debug(declaringType, "Some other exception occurred while getting the dns hostname. Error Ignored.", ex);
- }
+ // Get the DNS host name of the current machine
+ try
+ {
+ // Lookup the host name
+ s_hostName = System.Net.Dns.GetHostName();
+ }
+ catch (System.Net.Sockets.SocketException)
+ {
+ LogLog.Debug(declaringType, "Socket exception occurred while getting the dns hostname. Error Ignored.");
+ }
+ catch (System.Security.SecurityException)
+ {
+ // We may get a security exception looking up the hostname
+ // You must have Unrestricted DnsPermission to access resource
+ LogLog.Debug(declaringType, "Security exception occurred while getting the dns hostname. Error Ignored.");
+ }
+ catch (Exception ex)
+ {
+ LogLog.Debug(declaringType, "Some other exception occurred while getting the dns hostname. Error Ignored.", ex);
+ }
- // Get the NETBIOS machine name of the current machine
- if (s_hostName == null || s_hostName.Length == 0)
- {
- try
- {
+ // Get the NETBIOS machine name of the current machine
+ if (s_hostName == null || s_hostName.Length == 0)
+ {
+ try
+ {
#if NETSTANDARD1_3
- s_hostName = Environment.GetEnvironmentVariable("COMPUTERNAME");
+ s_hostName = Environment.GetEnvironmentVariable("COMPUTERNAME");
#elif (!SSCLI && !NETCF)
- s_hostName = Environment.MachineName;
+ s_hostName = Environment.MachineName;
#endif
- }
- catch (InvalidOperationException)
- {
- }
- catch (System.Security.SecurityException)
- {
- // We may get a security exception looking up the machine name
- // You must have Unrestricted EnvironmentPermission to access resource
- }
- }
+ }
+ catch (InvalidOperationException)
+ {
+ }
+ catch (System.Security.SecurityException)
+ {
+ // We may get a security exception looking up the machine name
+ // You must have Unrestricted EnvironmentPermission to access resource
+ }
+ }
- // Couldn't find a value
- if (s_hostName == null || s_hostName.Length == 0)
- {
- s_hostName = s_notAvailableText;
- LogLog.Debug(declaringType, "Could not determine the hostname. Error Ignored. Empty host name will be used");
- }
- }
- return s_hostName;
- }
- }
+ // Couldn't find a value
+ if (s_hostName == null || s_hostName.Length == 0)
+ {
+ s_hostName = s_notAvailableText;
+ LogLog.Debug(declaringType, "Could not determine the hostname. Error Ignored. Empty host name will be used");
+ }
+ }
+ return s_hostName;
+ }
+ }
- /// <summary>
- /// Get this application's friendly name
- /// </summary>
- /// <value>
- /// The friendly name of this application as a string
- /// </value>
- /// <remarks>
- /// <para>
- /// If available the name of the application is retrieved from
- /// the <c>AppDomain</c> using <c>AppDomain.CurrentDomain.FriendlyName</c>.
- /// </para>
- /// <para>
- /// Otherwise the file name of the entry assembly is used.
- /// </para>
- /// </remarks>
- public static string ApplicationFriendlyName
- {
- get
- {
- if (s_appFriendlyName == null)
- {
- try
- {
+ /// <summary>
+ /// Get this application's friendly name
+ /// </summary>
+ /// <value>
+ /// The friendly name of this application as a string
+ /// </value>
+ /// <remarks>
+ /// <para>
+ /// If available the name of the application is retrieved from
+ /// the <c>AppDomain</c> using <c>AppDomain.CurrentDomain.FriendlyName</c>.
+ /// </para>
+ /// <para>
+ /// Otherwise the file name of the entry assembly is used.
+ /// </para>
+ /// </remarks>
+ public static string ApplicationFriendlyName
+ {
+ get
+ {
+ if (s_appFriendlyName == null)
+ {
+ try
+ {
#if !NETCF && !NETSTANDARD1_3
- s_appFriendlyName = AppDomain.CurrentDomain.FriendlyName;
+ s_appFriendlyName = AppDomain.CurrentDomain.FriendlyName;
#endif
- }
- catch (System.Security.SecurityException)
- {
- // This security exception will occur if the caller does not have
- // some undefined set of SecurityPermission flags.
- LogLog.Debug(declaringType, "Security exception while trying to get current domain friendly name. Error Ignored.");
- }
+ }
+ catch (System.Security.SecurityException)
+ {
+ // This security exception will occur if the caller does not have
+ // some undefined set of SecurityPermission flags.
+ LogLog.Debug(declaringType, "Security exception while trying to get current domain friendly name. Error Ignored.");
+ }
- if (s_appFriendlyName == null || s_appFriendlyName.Length == 0)
- {
- try
- {
- string assemblyLocation = SystemInfo.EntryAssemblyLocation;
- s_appFriendlyName = System.IO.Path.GetFileName(assemblyLocation);
- }
- catch (System.Security.SecurityException)
- {
- // Caller needs path discovery permission
- }
- }
+ if (s_appFriendlyName == null || s_appFriendlyName.Length == 0)
+ {
+ try
+ {
+ string assemblyLocation = SystemInfo.EntryAssemblyLocation;
+ s_appFriendlyName = System.IO.Path.GetFileName(assemblyLocation);
+ }
+ catch (System.Security.SecurityException)
+ {
+ // Caller needs path discovery permission
+ }
+ }
- if (s_appFriendlyName == null || s_appFriendlyName.Length == 0)
- {
- s_appFriendlyName = s_notAvailableText;
- }
- }
- return s_appFriendlyName;
- }
- }
+ if (s_appFriendlyName == null || s_appFriendlyName.Length == 0)
+ {
+ s_appFriendlyName = s_notAvailableText;
+ }
+ }
+ return s_appFriendlyName;
+ }
+ }
- /// <summary>
- /// Get the start time for the current process.
- /// </summary>
- /// <remarks>
- /// <para>
- /// This is the time at which the log4net library was loaded into the
- /// AppDomain. Due to reports of a hang in the call to <c>System.Diagnostics.Process.StartTime</c>
- /// this is not the start time for the current process.
- /// </para>
- /// <para>
- /// The log4net library should be loaded by an application early during its
- /// startup, therefore this start time should be a good approximation for
- /// the actual start time.
- /// </para>
- /// <para>
- /// Note that AppDomains may be loaded and unloaded within the
- /// same process without the process terminating, however this start time
- /// will be set per AppDomain.
- /// </para>
- /// </remarks>
- [Obsolete("Use ProcessStartTimeUtc and convert to local time if needed.")]
- public static DateTime ProcessStartTime
- {
- get { return s_processStartTimeUtc.ToLocalTime(); }
- }
+ /// <summary>
+ /// Get the start time for the current process.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// This is the time at which the log4net library was loaded into the
+ /// AppDomain. Due to reports of a hang in the call to <c>System.Diagnostics.Process.StartTime</c>
+ /// this is not the start time for the current process.
+ /// </para>
+ /// <para>
+ /// The log4net library should be loaded by an application early during its
+ /// startup, therefore this start time should be a good approximation for
+ /// the actual start time.
+ /// </para>
+ /// <para>
+ /// Note that AppDomains may be loaded and unloaded within the
+ /// same process without the process terminating, however this start time
+ /// will be set per AppDomain.
+ /// </para>
+ /// </remarks>
+ [Obsolete("Use ProcessStartTimeUtc and convert to local time if needed.")]
+ public static DateTime ProcessStartTime
+ {
+ get { return s_processStartTimeUtc.ToLocalTime(); }
+ }
- /// <summary>
- /// Get the UTC start time for the current process.
- /// </summary>
- /// <remarks>
- /// <para>
- /// This is the UTC time at which the log4net library was loaded into the
- /// AppDomain. Due to reports of a hang in the call to <c>System.Diagnostics.Process.StartTime</c>
- /// this is not the start time for the current process.
- /// </para>
- /// <para>
- /// The log4net library should be loaded by an application early during its
- /// startup, therefore this start time should be a good approximation for
- /// the actual start time.
- /// </para>
- /// <para>
- /// Note that AppDomains may be loaded and unloaded within the
- /// same process without the process terminating, however this start time
- /// will be set per AppDomain.
- /// </para>
- /// </remarks>
- public static DateTime ProcessStartTimeUtc
- {
- get { return s_processStartTimeUtc; }
- }
+ /// <summary>
+ /// Get the UTC start time for the current process.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// This is the UTC time at which the log4net library was loaded into the
+ /// AppDomain. Due to reports of a hang in the call to <c>System.Diagnostics.Process.StartTime</c>
+ /// this is not the start time for the current process.
+ /// </para>
+ /// <para>
+ /// The log4net library should be loaded by an application early during its
+ /// startup, therefore this start time should be a good approximation for
+ /// the actual start time.
+ /// </para>
+ /// <para>
+ /// Note that AppDomains may be loaded and unloaded within the
+ /// same process without the process terminating, however this start time
+ /// will be set per AppDomain.
+ /// </para>
+ /// </remarks>
+ public static DateTime ProcessStartTimeUtc
+ {
+ get { return s_processStartTimeUtc; }
+ }
- /// <summary>
- /// Text to output when a <c>null</c> is encountered.
- /// </summary>
- /// <remarks>
- /// <para>
- /// Use this value to indicate a <c>null</c> has been encountered while
- /// outputting a string representation of an item.
- /// </para>
- /// <para>
- /// The default value is <c>(null)</c>. This value can be overridden by specifying
- /// a value for the <c>log4net.NullText</c> appSetting in the application's
- /// .config file.
- /// </para>
- /// </remarks>
- public static string NullText
- {
- get { return s_nullText; }
- set { s_nullText = value; }
- }
+ /// <summary>
+ /// Text to output when a <c>null</c> is encountered.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Use this value to indicate a <c>null</c> has been encountered while
+ /// outputting a string representation of an item.
+ /// </para>
+ /// <para>
+ /// The default value is <c>(null)</c>. This value can be overridden by specifying
+ /// a value for the <c>log4net.NullText</c> appSetting in the application's
+ /// .config file.
+ /// </para>
+ /// </remarks>
+ public static string NullText
+ {
+ get { return s_nullText; }
+ set { s_nullText = value; }
+ }
- /// <summary>
- /// Text to output when an unsupported feature is requested.
- /// </summary>
- /// <remarks>
- /// <para>
- /// Use this value when an unsupported feature is requested.
- /// </para>
- /// <para>
- /// The default value is <c>NOT AVAILABLE</c>. This value can be overridden by specifying
- /// a value for the <c>log4net.NotAvailableText</c> appSetting in the application's
- /// .config file.
- /// </para>
- /// </remarks>
- public static string NotAvailableText
- {
- get { return s_notAvailableText; }
- set { s_notAvailableText = value; }
- }
+ /// <summary>
+ /// Text to output when an unsupported feature is requested.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Use this value when an unsupported feature is requested.
+ /// </para>
+ /// <para>
+ /// The default value is <c>NOT AVAILABLE</c>. This value can be overridden by specifying
+ /// a value for the <c>log4net.NotAvailableText</c> appSetting in the application's
+ /// .config file.
+ /// </para>
+ /// </remarks>
+ public static string NotAvailableText
+ {
+ get { return s_notAvailableText; }
+ set { s_notAvailableText = value; }
+ }
- #endregion Public Static Properties
+ #endregion Public Static Properties
- #region Public Static Methods
+ #region Public Static Methods
- /// <summary>
- /// Gets the assembly location path for the specified assembly.
- /// </summary>
- /// <param name="myAssembly">The assembly to get the location for.</param>
- /// <returns>The location of the assembly.</returns>
- /// <remarks>
- /// <para>
- /// This method does not guarantee to return the correct path
- /// to the assembly. If only tries to give an indication as to
- /// where the assembly was loaded from.
- /// </para>
- /// </remarks>
- public static string AssemblyLocationInfo(Assembly myAssembly)
- {
+ /// <summary>
+ /// Gets the assembly location path for the specified assembly.
+ /// </summary>
+ /// <param name="myAssembly">The assembly to get the location for.</param>
+ /// <returns>The location of the assembly.</returns>
+ /// <remarks>
+ /// <para>
+ /// This method does not guarantee to return the correct path
+ /// to the assembly. If only tries to give an indication as to
+ /// where the assembly was loaded from.
+ /// </para>
+ /// </remarks>
+ public static string AssemblyLocationInfo(Assembly myAssembly)
+ {
#if NETCF
- return "Not supported on Microsoft .NET Compact Framework";
+ return "Not supported on Microsoft .NET Compact Framework";
#elif NETSTANDARD1_3
- return "Not supported on .NET Core";
+ return "Not supported on .NET Core";
#else
- if (myAssembly.GlobalAssemblyCache)
- {
- return "Global Assembly Cache";
- }
- else
- {
- try
- {
+ if (myAssembly.GlobalAssemblyCache)
+ {
+ return "Global Assembly Cache";
+ }
+ else
+ {
+ try
+ {
#if NET_4_0 || MONO_4_0
- if (myAssembly.IsDynamic)
- {
- return "Dynamic Assembly";
- }
+ if (myAssembly.IsDynamic)
+ {
+ return "Dynamic Assembly";
+ }
#else
#if !NETSTANDARD2_0
- if (myAssembly is System.Reflection.Emit.AssemblyBuilder)
- {
- return "Dynamic Assembly";
- }
+ if (myAssembly is System.Reflection.Emit.AssemblyBuilder)
+ {
+ return "Dynamic Assembly";
+ }
#endif
- if (myAssembly.GetType().FullName == "System.Reflection.Emit.InternalAssemblyBuilder")
- {
- return "Dynamic Assembly";
- }
+ if (myAssembly.GetType().FullName == "System.Reflection.Emit.InternalAssemblyBuilder")
+ {
+ return "Dynamic Assembly";
+ }
#endif
- else
- {
- // This call requires FileIOPermission for access to the path
- // if we don't have permission then we just ignore it and
- // carry on.
- return myAssembly.Location;
- }
- }
- catch (NotSupportedException)
- {
- // The location information may be unavailable for dynamic assemblies and a NotSupportedException
- // is thrown in those cases. See: http://msdn.microsoft.com/de-de/library/system.reflection.assembly.location.aspx
- return "Dynamic Assembly";
- }
- catch (TargetInvocationException ex)
- {
- return "Location Detect Failed (" + ex.Message + ")";
- }
- catch (ArgumentException ex)
- {
- return "Location Detect Failed (" + ex.Message + ")";
- }
- catch (System.Security.SecurityException)
- {
- return "Location Permission Denied";
- }
- }
+ else
+ {
+ // This call requires FileIOPermission for access to the path
+ // if we don't have permission then we just ignore it and
+ // carry on.
+ return myAssembly.Location;
+ }
+ }
+ catch (NotSupportedException)
+ {
+ // The location information may be unavailable for dynamic assemblies and a NotSupportedException
+ // is thrown in those cases. See: http://msdn.microsoft.com/de-de/library/system.reflection.assembly.location.aspx
+ return "Dynamic Assembly";
+ }
+ catch (TargetInvocationException ex)
+ {
+ return "Location Detect Failed (" + ex.Message + ")";
+ }
+ catch (ArgumentException ex)
+ {
+ return "Location Detect Failed (" + ex.Message + ")";
+ }
+ catch (System.Security.SecurityException)
+ {
+ return "Location Permission Denied";
+ }
+ }
#endif
- }
+ }
- /// <summary>
- /// Gets the fully qualified name of the <see cref="Type" />, including
- /// the name of the assembly from which the <see cref="Type" /> was
- /// loaded.
- /// </summary>
- /// <param name="type">The <see cref="Type" /> to get the fully qualified name for.</param>
- /// <returns>The fully qualified name for the <see cref="Type" />.</returns>
- /// <remarks>
- /// <para>
- /// This is equivalent to the <c>Type.AssemblyQualifiedName</c> property,
- /// but this method works on the .NET Compact Framework 1.0 as well as
- /// the full .NET runtime.
- /// </para>
- /// </remarks>
- public static string AssemblyQualifiedName(Type type)
- {
- return type.FullName + ", "
+ /// <summary>
+ /// Gets the fully qualified name of the <see cref="Type" />, including
+ /// the name of the assembly from which the <see cref="Type" /> was
+ /// loaded.
+ /// </summary>
+ /// <param name="type">The <see cref="Type" /> to get the fully qualified name for.</param>
+ /// <returns>The fully qualified name for the <see cref="Type" />.</returns>
+ /// <remarks>
+ /// <para>
+ /// This is equivalent to the <c>Type.AssemblyQualifiedName</c> property,
+ /// but this method works on the .NET Compact Framework 1.0 as well as
+ /// the full .NET runtime.
+ /// </para>
+ /// </remarks>
+ public static string AssemblyQualifiedName(Type type)
+ {
+ return type.FullName + ", "
#if NETSTANDARD1_3
- + type.GetTypeInfo().Assembly.FullName;
+ + type.GetTypeInfo().Assembly.FullName;
#else
- + type.Assembly.FullName;
+ + type.Assembly.FullName;
#endif
- }
+ }
- /// <summary>
- /// Gets the short name of the <see cref="Assembly" />.
- /// </summary>
- /// <param name="myAssembly">The <see cref="Assembly" /> to get the name for.</param>
- /// <returns>The short name of the <see cref="Assembly" />.</returns>
- /// <remarks>
- /// <para>
- /// The short name of the assembly is the <see cref="Assembly.FullName" />
- /// without the version, culture, or public key. i.e. it is just the
- /// assembly's file name without the extension.
- /// </para>
- /// <para>
- /// Use this rather than <c>Assembly.GetName().Name</c> because that
- /// is not available on the Compact Framework.
- /// </para>
- /// <para>
- /// Because of a FileIOPermission security demand we cannot do
- /// the obvious Assembly.GetName().Name. We are allowed to get
- /// the <see cref="Assembly.FullName" /> of the assembly so we
- /// start from there and strip out just the assembly name.
- /// </para>
- /// </remarks>
- public static string AssemblyShortName(Assembly myAssembly)
- {
- string name = myAssembly.FullName;
- int offset = name.IndexOf(',');
- if (offset > 0)
- {
- name = name.Substring(0, offset);
- }
- return name.Trim();
+ /// <summary>
+ /// Gets the short name of the <see cref="Assembly" />.
+ /// </summary>
+ /// <param name="myAssembly">The <see cref="Assembly" /> to get the name for.</param>
+ /// <returns>The short name of the <see cref="Assembly" />.</returns>
+ /// <remarks>
+ /// <para>
+ /// The short name of the assembly is the <see cref="Assembly.FullName" />
+ /// without the version, culture, or public key. i.e. it is just the
+ /// assembly's file name without the extension.
+ /// </para>
+ /// <para>
+ /// Use this rather than <c>Assembly.GetName().Name</c> because that
+ /// is not available on the Compact Framework.
+ /// </para>
+ /// <para>
+ /// Because of a FileIOPermission security demand we cannot do
+ /// the obvious Assembly.GetName().Name. We are allowed to get
+ /// the <see cref="Assembly.FullName" /> of the assembly so we
+ /// start from there and strip out just the assembly name.
+ /// </para>
+ /// </remarks>
+ public static string AssemblyShortName(Assembly myAssembly)
+ {
+ string name = myAssembly.FullName;
+ int offset = name.IndexOf(',');
+ if (offset > 0)
+ {
+ name = name.Substring(0, offset);
+ }
+ return name.Trim();
- // TODO: Do we need to unescape the assembly name string?
- // Doc says '\' is an escape char but has this already been
- // done by the string loader?
- }
+ // TODO: Do we need to unescape the assembly name string?
+ // Doc says '\' is an escape char but has this already been
+ // done by the string loader?
+ }
- /// <summary>
- /// Gets the file name portion of the <see cref="Assembly" />, including the extension.
- /// </summary>
- /// <param name="myAssembly">The <see cref="Assembly" /> to get the file name for.</param>
- /// <returns>The file name of the assembly.</returns>
- /// <remarks>
- /// <para>
- /// Gets the file name portion of the <see cref="Assembly" />, including the extension.
- /// </para>
- /// </remarks>
- public static string AssemblyFileName(Assembly myAssembly)
- {
+ /// <summary>
+ /// Gets the file name portion of the <see cref="Assembly" />, including the extension.
+ /// </summary>
+ /// <param name="myAssembly">The <see cref="Assembly" /> to get the file name for.</param>
+ /// <returns>The file name of the assembly.</returns>
+ /// <remarks>
+ /// <para>
+ /// Gets the file name portion of the <see cref="Assembly" />, including the extension.
+ /// </para>
+ /// </remarks>
+ public static string AssemblyFileName(Assembly myAssembly)
+ {
#if NETCF || NETSTANDARD1_3 // TODO Assembly.Location is in netstandard1.5 System.Reflection
- // This is not very good because it assumes that only
- // the entry assembly can be an EXE. In fact multiple
- // EXEs can be loaded in to a process.
+ // This is not very good because it assumes that only
+ // the entry assembly can be an EXE. In fact multiple
+ // EXEs can be loaded in to a process.
- string assemblyShortName = SystemInfo.AssemblyShortName(myAssembly);
- string entryAssemblyShortName = System.IO.Path.GetFileNameWithoutExtension(SystemInfo.EntryAssemblyLocation);
+ string assemblyShortName = SystemInfo.AssemblyShortName(myAssembly);
+ string entryAssemblyShortName = System.IO.Path.GetFileNameWithoutExtension(SystemInfo.EntryAssemblyLocation);
- if (string.Compare(assemblyShortName, entryAssemblyShortName, true) == 0)
- {
- // assembly is entry assembly
- return assemblyShortName + ".exe";
- }
- else
- {
- // assembly is not entry assembly
- return assemblyShortName + ".dll";
- }
+ if (string.Compare(assemblyShortName, entryAssemblyShortName, true) == 0)
+ {
+ // assembly is entry assembly
+ return assemblyShortName + ".exe";
+ }
+ else
+ {
+ // assembly is not entry assembly
+ return assemblyShortName + ".dll";
+ }
#else
- return System.IO.Path.GetFileName(myAssembly.Location);
+ return System.IO.Path.GetFileName(myAssembly.Location);
#endif
- }
+ }
- /// <summary>
- /// Loads the type specified in the type string.
- /// </summary>
- /// <param name="relativeType">A sibling type to use to load the type.</param>
- /// <param name="typeName">The name of the type to load.</param>
- /// <param name="throwOnError">Flag set to <c>true</c> to throw an exception if the type cannot be loaded.</param>
- /// <param name="ignoreCase"><c>true</c> to ignore the case of the type name; otherwise, <c>false</c></param>
- /// <returns>The type loaded or <c>null</c> if it could not be loaded.</returns>
- /// <remarks>
- /// <para>
- /// If the type name is fully qualified, i.e. if contains an assembly name in
- /// the type name, the type will be loaded from the system using
- /// <see cref="M:Type.GetType(string,bool)"/>.
- /// </para>
- /// <para>
- /// If the type name is not fully qualified, it will be loaded from the assembly
- /// containing the specified relative type. If the type is not found in the assembly
- /// then all the loaded assemblies will be searched for the type.
- /// </para>
- /// </remarks>
- public static Type GetTypeFromString(Type relativeType, string typeName, bool throwOnError, bool ignoreCase)
- {
+ /// <summary>
+ /// Loads the type specified in the type string.
+ /// </summary>
+ /// <param name="relativeType">A sibling type to use to load the type.</param>
+ /// <param name="typeName">The name of the type to load.</param>
+ /// <param name="throwOnError">Flag set to <c>true</c> to throw an exception if the type cannot be loaded.</param>
+ /// <param name="ignoreCase"><c>true</c> to ignore the case of the type name; otherwise, <c>false</c></param>
+ /// <returns>The type loaded or <c>null</c> if it could not be loaded.</returns>
+ /// <remarks>
+ /// <para>
+ /// If the type name is fully qualified, i.e. if contains an assembly name in
+ /// the type name, the type will be loaded from the system using
+ /// <see cref="M:Type.GetType(string,bool)"/>.
+ /// </para>
+ /// <para>
+ /// If the type name is not fully qualified, it will be loaded from the assembly
+ /// containing the specified relative type. If the type is not found in the assembly
+ /// then all the loaded assemblies will be searched for the type.
+ /// </para>
+ /// </remarks>
+ public static Type GetTypeFromString(Type relativeType, string typeName, bool throwOnError, bool ignoreCase)
+ {
#if NETSTANDARD1_3
- return GetTypeFromString(relativeType.GetTypeInfo().Assembly, typeName, throwOnError, ignoreCase);
+ return GetTypeFromString(relativeType.GetTypeInfo().Assembly, typeName, throwOnError, ignoreCase);
#else
- return GetTypeFromString(relativeType.Assembly, typeName, throwOnError, ignoreCase);
+ return GetTypeFromString(relativeType.Assembly, typeName, throwOnError, ignoreCase);
#endif
- }
+ }
#if !NETSTANDARD1_3
- /// <summary>
- /// Loads the type specified in the type string.
- /// </summary>
- /// <param name="typeName">The name of the type to load.</param>
- /// <param name="throwOnError">Flag set to <c>true</c> to throw an exception if the type cannot be loaded.</param>
- /// <param name="ignoreCase"><c>true</c> to ignore the case of the type name; otherwise, <c>false</c></param>
- /// <returns>The type loaded or <c>null</c> if it could not be loaded.</returns>
- /// <remarks>
- /// <para>
- /// If the type name is fully qualified, i.e. if contains an assembly name in
- /// the type name, the type will be loaded from the system using
- /// <see cref="M:Type.GetType(string,bool)"/>.
- /// </para>
- /// <para>
- /// If the type name is not fully qualified it will be loaded from the
- /// assembly that is directly calling this method. If the type is not found
- /// in the assembly then all the loaded assemblies will be searched for the type.
- /// </para>
- /// </remarks>
- public static Type GetTypeFromString(string typeName, bool throwOnError, bool ignoreCase)
- {
- return GetTypeFromString(Assembly.GetCallingAssembly(), typeName, throwOnError, ignoreCase);
- }
+ /// <summary>
+ /// Loads the type specified in the type string.
+ /// </summary>
+ /// <param name="typeName">The name of the type to load.</param>
+ /// <param name="throwOnError">Flag set to <c>true</c> to throw an exception if the type cannot be loaded.</param>
+ /// <param name="ignoreCase"><c>true</c> to ignore the case of the type name; otherwise, <c>false</c></param>
+ /// <returns>The type loaded or <c>null</c> if it could not be loaded.</returns>
+ /// <remarks>
+ /// <para>
+ /// If the type name is fully qualified, i.e. if contains an assembly name in
+ /// the type name, the type will be loaded from the system using
+ /// <see cref="M:Type.GetType(string,bool)"/>.
+ /// </para>
+ /// <para>
+ /// If the type name is not fully qualified it will be loaded from the
+ /// assembly that is directly calling this method. If the type is not found
+ /// in the assembly then all the loaded assemblies will be searched for the type.
+ /// </para>
+ /// </remarks>
+ public static Type GetTypeFromString(string typeName, bool throwOnError, bool ignoreCase)
+ {
+ return GetTypeFromString(Assembly.GetCallingAssembly(), typeName, throwOnError, ignoreCase);
+ }
#endif
- /// <summary>
- /// Loads the type specified in the type string.
- /// </summary>
- /// <param name="relativeAssembly">An assembly to load the type from.</param>
- /// <param name="typeName">The name of the type to load.</param>
- /// <param name="throwOnError">Flag set to <c>true</c> to throw an exception if the type cannot be loaded.</param>
- /// <param name="ignoreCase"><c>true</c> to ignore the case of the type name; otherwise, <c>false</c></param>
- /// <returns>The type loaded or <c>null</c> if it could not be loaded.</returns>
- /// <remarks>
- /// <para>
- /// If the type name is fully qualified, i.e. if contains an assembly name in
- /// the type name, the type will be loaded from the system using
- /// <see cref="M:Type.GetType(string,bool)"/>.
- /// </para>
- /// <para>
- /// If the type name is not fully qualified it will be loaded from the specified
- /// assembly. If the type is not found in the assembly then all the loaded assemblies
- /// will be searched for the type.
- /// </para>
- /// </remarks>
- public static Type GetTypeFromString(Assembly relativeAssembly, string typeName, bool throwOnError, bool ignoreCase)
- {
- // Check if the type name specifies the assembly name
- if (typeName.IndexOf(',') == -1)
- {
- //LogLog.Debug(declaringType, "SystemInfo: Loading type ["+typeName+"] from assembly ["+relativeAssembly.FullName+"]");
+ /// <summary>
+ /// Loads the type specified in the type string.
+ /// </summary>
+ /// <param name="relativeAssembly">An assembly to load the type from.</param>
+ /// <param name="typeName">The name of the type to load.</param>
+ /// <param name="throwOnError">Flag set to <c>true</c> to throw an exception if the type cannot be loaded.</param>
+ /// <param name="ignoreCase"><c>true</c> to ignore the case of the type name; otherwise, <c>false</c></param>
+ /// <returns>The type loaded or <c>null</c> if it could not be loaded.</returns>
+ /// <remarks>
+ /// <para>
+ /// If the type name is fully qualified, i.e. if contains an assembly name in
+ /// the type name, the type will be loaded from the system using
+ /// <see cref="M:Type.GetType(string,bool)"/>.
+ /// </para>
+ /// <para>
+ /// If the type name is not fully qualified it will be loaded from the specified
+ /// assembly. If the type is not found in the assembly then all the loaded assemblies
+ /// will be searched for the type.
+ /// </para>
+ /// </remarks>
+ public static Type GetTypeFromString(Assembly relativeAssembly, string typeName, bool throwOnError, bool ignoreCase)
+ {
+ // Check if the type name specifies the assembly name
+ if (typeName.IndexOf(',') == -1)
+ {
+ //LogLog.Debug(declaringType, "SystemInfo: Loading type ["+typeName+"] from assembly ["+relativeAssembly.FullName+"]");
#if NETSTANDARD1_3
- return relativeAssembly.GetType(typeName, throwOnError, ignoreCase);
+ return relativeAssembly.GetType(typeName, throwOnError, ignoreCase);
#elif NETCF
- return relativeAssembly.GetType(typeName, throwOnError);
+ return relativeAssembly.GetType(typeName, throwOnError);
#else
- // Attempt to lookup the type from the relativeAssembly
- Type type = relativeAssembly.GetType(typeName, false, ignoreCase);
- if (type != null)
- {
- // Found type in relative assembly
- //LogLog.Debug(declaringType, "SystemInfo: Loaded type ["+typeName+"] from assembly ["+relativeAssembly.FullName+"]");
- return type;
- }
+ // Attempt to lookup the type from the relativeAssembly
+ Type type = relativeAssembly.GetType(typeName, false, ignoreCase);
+ if (type != null)
+ {
+ // Found type in relative assembly
+ //LogLog.Debug(declaringType, "SystemInfo: Loaded type ["+typeName+"] from assembly ["+relativeAssembly.FullName+"]");
+ return type;
+ }
- Assembly[] loadedAssemblies = null;
- try
- {
- loadedAssemblies = AppDomain.CurrentDomain.GetAssemblies();
- }
- catch (System.Security.SecurityException)
- {
- // Insufficient permissions to get the list of loaded assemblies
- }
+ Assembly[] loadedAssemblies = null;
+ try
+ {
+ loadedAssemblies = AppDomain.CurrentDomain.GetAssemblies();
+ }
+ catch (System.Security.SecurityException)
+ {
+ // Insufficient permissions to get the list of loaded assemblies
+ }
- if (loadedAssemblies != null)
- {
- Type fallback = null;
- // Search the loaded assemblies for the type
- foreach (Assembly assembly in loadedAssemblies)
- {
- Type t = assembly.GetType(typeName, false, ignoreCase);
- if (t != null)
- {
- // Found type in loaded assembly
- LogLog.Debug(declaringType, "Loaded type [" + typeName + "] from assembly [" + assembly.FullName + "] by searching loaded assemblies.");
- if (assembly.GlobalAssemblyCache)
- {
- fallback = t;
- }
- else
- {
- return t;
- }
- }
- }
- if (fallback != null)
- {
- return fallback;
- }
- }
+ if (loadedAssemblies != null)
+ {
+ Type fallback = null;
+ // Search the loaded assemblies for the type
+ foreach (Assembly assembly in loadedAssemblies)
+ {
+ Type t = assembly.GetType(typeName, false, ignoreCase);
+ if (t != null)
+ {
+ // Found type in loaded assembly
+ LogLog.Debug(declaringType, "Loaded type [" + typeName + "] from assembly [" + assembly.FullName + "] by searching loaded assemblies.");
+ if (assembly.GlobalAssemblyCache)
+ {
+ fallback = t;
+ }
+ else
+ {
+ return t;
+ }
+ }
+ }
+ if (fallback != null)
+ {
+ return fallback;
+ }
+ }
- // Didn't find the type
- if (throwOnError)
- {
- throw new TypeLoadException("Could not load type [" + typeName + "]. Tried assembly [" + relativeAssembly.FullName + "] and all loaded assemblies");
- }
- return null;
+ // Didn't find the type
+ if (throwOnError)
+ {
+ throw new TypeLoadException("Could not load type [" + typeName + "]. Tried assembly [" + relativeAssembly.FullName + "] and all loaded assemblies");
+ }
+ return null;
#endif
- }
- else
- {
- // Includes explicit assembly name
- //LogLog.Debug(declaringType, "SystemInfo: Loading type ["+typeName+"] from global Type");
+ }
+ else
+ {
+ // Includes explicit assembly name
+ //LogLog.Debug(declaringType, "SystemInfo: Loading type ["+typeName+"] from global Type");
#if NETCF
- // In NETCF 2 and 3 arg versions seem to behave differently
- // https://issues.apache.org/jira/browse/LOG4NET-113
- return Type.GetType(typeName, throwOnError);
+ // In NETCF 2 and 3 arg versions seem to behave differently
+ // https://issues.apache.org/jira/browse/LOG4NET-113
+ return Type.GetType(typeName, throwOnError);
#else
- return Type.GetType(typeName, throwOnError, ignoreCase);
+ return Type.GetType(typeName, throwOnError, ignoreCase);
#endif
- }
- }
+ }
+ }
- /// <summary>
- /// Generate a new guid
- /// </summary>
- /// <returns>A new Guid</returns>
- /// <remarks>
- /// <para>
- /// Generate a new guid
- /// </para>
- /// </remarks>
- public static Guid NewGuid()
- {
+ /// <summary>
+ /// Generate a new guid
+ /// </summary>
+ /// <returns>A new Guid</returns>
+ /// <remarks>
+ /// <para>
+ /// Generate a new guid
+ /// </para>
+ /// </remarks>
+ public static Guid NewGuid()
+ {
#if NETCF_1_0
- return PocketGuid.NewGuid();
+ return PocketGuid.NewGuid();
#else
- return Guid.NewGuid();
+ return Guid.NewGuid();
#endif
- }
+ }
- /// <summary>
- /// Create an <see cref="ArgumentOutOfRangeException"/>
- /// </summary>
- /// <param name="parameterName">The name of the parameter that caused the exception</param>
- /// <param name="actualValue">The value of the argument that causes this exception</param>
- /// <param name="message">The message that describes the error</param>
- /// <returns>the ArgumentOutOfRangeException object</returns>
- /// <remarks>
- /// <para>
- /// Create a new instance of the <see cref="ArgumentOutOfRangeException"/> class
- /// with a specified error message, the parameter name, and the value
- /// of the argument.
- /// </para>
- /// <para>
- /// The Compact Framework does not support the 3 parameter constructor for the
- /// <see cref="ArgumentOutOfRangeException"/> type. This method provides an
- /// implementation that works for all platforms.
- /// </para>
- /// </remarks>
- public static ArgumentOutOfRangeException CreateArgumentOutOfRangeException(string parameterName, object actualValue, string message)
- {
+ /// <summary>
+ /// Create an <see cref="ArgumentOutOfRangeException"/>
+ /// </summary>
+ /// <param name="parameterName">The name of the parameter that caused the exception</param>
+ /// <param name="actualValue">The value of the argument that causes this exception</param>
+ /// <param name="message">The message that describes the error</param>
+ /// <returns>the ArgumentOutOfRangeException object</returns>
+ /// <remarks>
+ /// <para>
+ /// Create a new instance of the <see cref="ArgumentOutOfRangeException"/> class
+ /// with a specified error message, the parameter name, and the value
+ /// of the argument.
+ /// </para>
+ /// <para>
+ /// The Compact Framework does not support the 3 parameter constructor for the
+ /// <see cref="ArgumentOutOfRangeException"/> type. This method provides an
+ /// implementation that works for all platforms.
+ /// </para>
+ /// </remarks>
+ public static ArgumentOutOfRangeException CreateArgumentOutOfRangeException(string parameterName, object actualValue, string message)
+ {
#if NETCF_1_0
- return new ArgumentOutOfRangeException(message + " [param=" + parameterName + "] [value=" + actualValue + "]");
+ return new ArgumentOutOfRangeException(message + " [param=" + parameterName + "] [value=" + actualValue + "]");
#elif NETCF_2_0
- return new ArgumentOutOfRangeException(parameterName, message + " [value=" + actualValue + "]");
+ return new ArgumentOutOfRangeException(parameterName, message + " [value=" + actualValue + "]");
#else
- return new ArgumentOutOfRangeException(parameterName, actualValue, message);
+ return new ArgumentOutOfRangeException(parameterName, actualValue, message);
#endif
- }
+ }
- /// <summary>
- /// Parse a string into an <see cref="Int32"/> value
- /// </summary>
- /// <param name="s">the string to parse</param>
- /// <param name="val">out param where the parsed value is placed</param>
- /// <returns><c>true</c> if the string was able to be parsed into an integer</returns>
- /// <remarks>
- /// <para>
- /// Attempts to parse the string into an integer. If the string cannot
- /// be parsed then this method returns <c>false</c>. The method does not throw an exception.
- /// </para>
- /// </remarks>
- public static bool TryParse(string s, out int val)
- {
+ /// <summary>
+ /// Parse a string into an <see cref="Int32"/> value
+ /// </summary>
+ /// <param name="s">the string to parse</param>
+ /// <param name="val">out param where the parsed value is placed</param>
+ /// <returns><c>true</c> if the string was able to be parsed into an integer</returns>
+ /// <remarks>
+ /// <para>
+ /// Attempts to parse the string into an integer. If the string cannot
+ /// be parsed then this method returns <c>false</c>. The method does not throw an exception.
+ /// </para>
+ /// </remarks>
+ public static bool TryParse(string s, out int val)
+ {
#if NETCF
- val = 0;
- try
- {
- val = int.Parse(s, System.Globalization.NumberStyles.Integer, System.Globalization.CultureInfo.InvariantCulture);
- return true;
- }
- catch
- {
- }
+ val = 0;
+ try
+ {
+ val = int.Parse(s, System.Globalization.NumberStyles.Integer, System.Globalization.CultureInfo.InvariantCulture);
+ return true;
+ }
+ catch
+ {
+ }
- return false;
+ return false;
#else
- // Initialise out param
- val = 0;
+ // Initialise out param
+ val = 0;
- try
- {
- double doubleVal;
- if (Double.TryParse(s, System.Globalization.NumberStyles.Integer, System.Globalization.CultureInfo.InvariantCulture, out doubleVal))
- {
- val = Convert.ToInt32(doubleVal);
- return true;
- }
- }
- catch
- {
- // Ignore exception, just return false
- }
+ try
+ {
+ double doubleVal;
+ if (Double.TryParse(s, System.Globalization.NumberStyles.Integer, System.Globalization.CultureInfo.InvariantCulture, out doubleVal))
+ {
+ val = Convert.ToInt32(doubleVal);
+ return true;
+ }
+ }
+ catch
+ {
+ // Ignore exception, just return false
+ }
- return false;
+ return false;
#endif
- }
+ }
- /// <summary>
- /// Parse a string into an <see cref="Int64"/> value
- /// </summary>
- /// <param name="s">the string to parse</param>
- /// <param name="val">out param where the parsed value is placed</param>
- /// <returns><c>true</c> if the string was able to be parsed into an integer</returns>
- /// <remarks>
- /// <para>
- /// Attempts to parse the string into an integer. If the string cannot
- /// be parsed then this method returns <c>false</c>. The method does not throw an exception.
- /// </para>
- /// </remarks>
- public static bool TryParse(string s, out long val)
- {
+ /// <summary>
+ /// Parse a string into an <see cref="Int64"/> value
+ /// </summary>
+ /// <param name="s">the string to parse</param>
+ /// <param name="val">out param where the parsed value is placed</param>
+ /// <returns><c>true</c> if the string was able to be parsed into an integer</returns>
+ /// <remarks>
+ /// <para>
+ /// Attempts to parse the string into an integer. If the string cannot
+ /// be parsed then this method returns <c>false</c>. The method does not throw an exception.
+ /// </para>
+ /// </remarks>
+ public static bool TryParse(string s, out long val)
+ {
#if NETCF
- val = 0;
- try
- {
- val = long.Parse(s, System.Globalization.NumberStyles.Integer, System.Globalization.CultureInfo.InvariantCulture);
- return true;
- }
- catch
- {
- }
+ val = 0;
+ try
+ {
+ val = long.Parse(s, System.Globalization.NumberStyles.Integer, System.Globalization.CultureInfo.InvariantCulture);
+ return true;
+ }
+ catch
+ {
+ }
- return false;
+ return false;
#else
- // Initialise out param
- val = 0;
+ // Initialise out param
+ val = 0;
- try
- {
- double doubleVal;
- if (Double.TryParse(s, System.Globalization.NumberStyles.Integer, System.Globalization.CultureInfo.InvariantCulture, out doubleVal))
- {
- val = Convert.ToInt64(doubleVal);
- return true;
- }
- }
- catch
- {
- // Ignore exception, just return false
- }
+ try
+ {
+ double doubleVal;
+ if (Double.TryParse(s, System.Globalization.NumberStyles.Integer, System.Globalization.CultureInfo.InvariantCulture, out doubleVal))
+ {
+ val = Convert.ToInt64(doubleVal);
+ return true;
+ }
+ }
+ catch
+ {
+ // Ignore exception, just return false
+ }
- return false;
+ return false;
#endif
- }
+ }
- /// <summary>
- /// Parse a string into an <see cref="Int16"/> value
- /// </summary>
- /// <param name="s">the string to parse</param>
- /// <param name="val">out param where the parsed value is placed</param>
- /// <returns><c>true</c> if the string was able to be parsed into an integer</returns>
- /// <remarks>
- /// <para>
- /// Attempts to parse the string into an integer. If the string cannot
- /// be parsed then this method returns <c>false</c>. The method does not throw an exception.
- /// </para>
- /// </remarks>
- public static bool TryParse(string s, out short val)
- {
+ /// <summary>
+ /// Parse a string into an <see cref="Int16"/> value
+ /// </summary>
+ /// <param name="s">the string to parse</param>
+ /// <param name="val">out param where the parsed value is placed</param>
+ /// <returns><c>true</c> if the string was able to be parsed into an integer</returns>
+ /// <remarks>
+ /// <para>
+ /// Attempts to parse the string into an integer. If the string cannot
+ /// be parsed then this method returns <c>false</c>. The method does not throw an exception.
+ /// </para>
+ /// </remarks>
+ public static bool TryParse(string s, out short val)
+ {
#if NETCF
- val = 0;
- try
- {
- val = short.Parse(s, System.Globalization.NumberStyles.Integer, System.Globalization.CultureInfo.InvariantCulture);
- return true;
- }
- catch
- {
- }
+ val = 0;
+ try
+ {
+ val = short.Parse(s, System.Globalization.NumberStyles.Integer, System.Globalization.CultureInfo.InvariantCulture);
+ return true;
+ }
+ catch
+ {
+ }
- return false;
+ return false;
#else
- // Initialise out param
- val = 0;
+ // Initialise out param
+ val = 0;
- try
- {
- double doubleVal;
- if (Double.TryParse(s, System.Globalization.NumberStyles.Integer, System.Globalization.CultureInfo.InvariantCulture, out doubleVal))
- {
- val = Convert.ToInt16(doubleVal);
- return true;
- }
- }
- catch
- {
- // Ignore exception, just return false
- }
+ try
+ {
+ double doubleVal;
+ if (Double.TryParse(s, System.Globalization.NumberStyles.Integer, System.Globalization.CultureInfo.InvariantCulture, out doubleVal))
+ {
+ val = Convert.ToInt16(doubleVal);
+ return true;
+ }
+ }
+ catch
+ {
+ // Ignore exception, just return false
+ }
- return false;
+ return false;
#endif
- }
+ }
- /// <summary>
- /// Lookup an application setting
- /// </summary>
- /// <param name="key">the application settings key to lookup</param>
- /// <returns>the value for the key, or <c>null</c></returns>
- /// <remarks>
- /// <para>
- /// Configuration APIs are not supported under the Compact Framework
- /// </para>
- /// </remarks>
- public static string GetAppSetting(string key)
- {
- try
- {
+ /// <summary>
+ /// Lookup an application setting
+ /// </summary>
+ /// <param name="key">the application settings key to lookup</param>
+ /// <returns>the value for the key, or <c>null</c></returns>
+ /// <remarks>
+ /// <para>
+ /// Configuration APIs are not supported under the Compact Framework
+ /// </para>
+ /// </remarks>
+ public static string GetAppSetting(string key)
+ {
+ try
+ {
#if NETCF || NETSTANDARD1_3
- // Configuration APIs are not suported under the Compact Framework
+ // Configuration APIs are not suported under the Compact Framework
#elif NET_2_0 || NETSTANDARD2_0
- return ConfigurationManager.AppSettings[key];
+ return ConfigurationManager.AppSettings[key];
#else
- return ConfigurationSettings.AppSettings[key];
+ return ConfigurationSettings.AppSettings[key];
#endif
- }
- catch (Exception ex)
- {
- // If an exception is thrown here then it looks like the config file does not parse correctly.
- LogLog.Error(declaringType, "Exception while reading ConfigurationSettings. Check your .config file is well formed XML.", ex);
- }
- return null;
- }
+ }
+ catch (Exception ex)
+ {
+ // If an exception is thrown here then it looks like the config file does not parse correctly.
+ LogLog.Error(declaringType, "Exception while reading ConfigurationSettings. Check your .config file is well formed XML.", ex);
+ }
+ return null;
+ }
- /// <summary>
- /// Convert a path into a fully qualified local file path.
- /// </summary>
- /// <param name="path">The path to convert.</param>
- /// <returns>The fully qualified path.</returns>
- /// <remarks>
- /// <para>
- /// Converts the path specified to a fully
- /// qualified path. If the path is relative it is
- /// taken as relative from the application base
- /// directory.
- /// </para>
- /// <para>
- /// The path specified must be a local file path, a URI is not supported.
- /// </para>
- /// </remarks>
- public static string ConvertToFullPath(string path)
- {
- if (path == null)
- {
- throw new ArgumentNullException("path");
- }
+ /// <summary>
+ /// Convert a path into a fully qualified local file path.
+ /// </summary>
+ /// <param name="path">The path to convert.</param>
+ /// <returns>The fully qualified path.</returns>
+ /// <remarks>
+ /// <para>
+ /// Converts the path specified to a fully
+ /// qualified path. If the path is relative it is
+ /// taken as relative from the application base
+ /// directory.
+ /// </para>
+ /// <para>
+ /// The path specified must be a local file path, a URI is not supported.
+ /// </para>
+ /// </remarks>
+ public static string ConvertToFullPath(string path)
+ {
+ if (path == null)
+ {
+ throw new ArgumentNullException("path");
+ }
- string baseDirectory = "";
- try
- {
- string applicationBaseDirectory = SystemInfo.ApplicationBaseDirectory;
- if (applicationBaseDirectory != null)
- {
- // applicationBaseDirectory may be a URI not a local file path
- Uri applicationBaseDirectoryUri = new Uri(applicationBaseDirectory);
- if (applicationBaseDirectoryUri.IsFile)
- {
- baseDirectory = applicationBaseDirectoryUri.LocalPath;
- }
- }
- }
- catch
- {
- // Ignore URI exceptions & SecurityExceptions from SystemInfo.ApplicationBaseDirectory
- }
+ string baseDirectory = "";
+ try
+ {
+ string applicationBaseDirectory = SystemInfo.ApplicationBaseDirectory;
+ if (applicationBaseDirectory != null)
+ {
+ // applicationBaseDirectory may be a URI not a local file path
+ Uri applicationBaseDirectoryUri = new Uri(applicationBaseDirectory);
+ if (applicationBaseDirectoryUri.IsFile)
+ {
+ baseDirectory = applicationBaseDirectoryUri.LocalPath;
+ }
+ }
+ }
+ catch
+ {
+ // Ignore URI exceptions & SecurityExceptions from SystemInfo.ApplicationBaseDirectory
+ }
- if (baseDirectory != null && baseDirectory.Length > 0)
- {
- // Note that Path.Combine will return the second path if it is rooted
- return Path.GetFullPath(Path.Combine(baseDirectory, path));
- }
- return Path.GetFullPath(path);
- }
+ if (baseDirectory != null && baseDirectory.Length > 0)
+ {
+ // Note that Path.Combine will return the second path if it is rooted
+ return Path.GetFullPath(Path.Combine(baseDirectory, path));
+ }
+ return Path.GetFullPath(path);
+ }
- /// <summary>
- /// Creates a new case-insensitive instance of the <see cref="Hashtable"/> class with the default initial capacity.
- /// </summary>
- /// <returns>A new case-insensitive instance of the <see cref="Hashtable"/> class with the default initial capacity</returns>
- /// <remarks>
- /// <para>
- /// The new Hashtable instance uses the default load factor, the CaseInsensitiveHashCodeProvider, and the CaseInsensitiveComparer.
- /// </para>
- /// </remarks>
- public static Hashtable CreateCaseInsensitiveHashtable()
- {
+ /// <summary>
+ /// Creates a new case-insensitive instance of the <see cref="Hashtable"/> class with the default initial capacity.
+ /// </summary>
+ /// <returns>A new case-insensitive instance of the <see cref="Hashtable"/> class with the default initial capacity</returns>
+ /// <remarks>
+ /// <para>
+ /// The new Hashtable instance uses the default load factor, the CaseInsensitiveHashCodeProvider, and the CaseInsensitiveComparer.
+ /// </para>
+ /// </remarks>
+ public static Hashtable CreateCaseInsensitiveHashtable()
+ {
#if NETCF_1_0
- return new Hashtable(CaseInsensitiveHashCodeProvider.Default, CaseInsensitiveComparer.Default);
+ return new Hashtable(CaseInsensitiveHashCodeProvider.Default, CaseInsensitiveComparer.Default);
#elif NETCF_2_0 || NET_2_0 || MONO_2_0 || MONO_3_5 || MONO_4_0
- return new Hashtable(StringComparer.OrdinalIgnoreCase);
+ return new Hashtable(StringComparer.OrdinalIgnoreCase);
#else
- return System.Collections.Specialized.CollectionsUtil.CreateCaseInsensitiveHashtable();
+ return System.Collections.Specialized.CollectionsUtil.CreateCaseInsensitiveHashtable();
#endif
- }
+ }
- /// <summary>
- /// Tests two strings for equality, the ignoring case.
- /// </summary>
- /// <remarks>
- /// If the platform permits, culture information is ignored completely (ordinal comparison).
- /// The aim of this method is to provide a fast comparison that deals with <c>null</c> and ignores different casing.
- /// It is not supposed to deal with various, culture-specific habits.
- /// Use it to compare against pure ASCII constants, like keywords etc.
- /// </remarks>
- /// <param name="a">The one string.</param>
- /// <param name="b">The other string.</param>
- /// <returns><c>true</c> if the strings are equal, <c>false</c> otherwise.</returns>
- public static Boolean EqualsIgnoringCase(String a, String b)
- {
+ /// <summary>
+ /// Tests two strings for equality, the ignoring case.
+ /// </summary>
+ /// <remarks>
+ /// If the platform permits, culture information is ignored completely (ordinal comparison).
+ /// The aim of this method is to provide a fast comparison that deals with <c>null</c> and ignores different casing.
+ /// It is not supposed to deal with various, culture-specific habits.
+ /// Use it to compare against pure ASCII constants, like keywords etc.
+ /// </remarks>
+ /// <param name="a">The one string.</param>
+ /// <param name="b">The other string.</param>
+ /// <returns><c>true</c> if the strings are equal, <c>false</c> otherwise.</returns>
+ public static Boolean EqualsIgnoringCase(String a, String b)
+ {
#if NET_1_0 || NET_1_1 || NETCF_1_0
- return string.Compare(a, b, true, System.Globalization.CultureInfo.InvariantCulture) == 0
+ return string.Compare(a, b, true, System.Globalization.CultureInfo.InvariantCulture) == 0
#elif NETSTANDARD1_3
- return CultureInfo.InvariantCulture.CompareInfo.Compare(a, b, CompareOptions.IgnoreCase) == 0;
+ return CultureInfo.InvariantCulture.CompareInfo.Compare(a, b, CompareOptions.IgnoreCase) == 0;
#else // >= .NET-2.0
- return String.Equals(a, b, StringComparison.OrdinalIgnoreCase);
+ return String.Equals(a, b, StringComparison.OrdinalIgnoreCase);
#endif
- }
+ }
- #endregion Public Static Methods
+ #endregion Public Static Methods
- #region Private Static Methods
+ #region Private Static Methods
#if NETCF
- private static string NativeEntryAssemblyLocation
- {
- get
- {
- StringBuilder moduleName = null;
+ private static string NativeEntryAssemblyLocation
+ {
+ get
+ {
+ StringBuilder moduleName = null;
- IntPtr moduleHandle = GetModuleHandle(IntPtr.Zero);
+ IntPtr moduleHandle = GetModuleHandle(IntPtr.Zero);
- if (moduleHandle != IntPtr.Zero)
- {
- moduleName = new StringBuilder(255);
- if (GetModuleFileName(moduleHandle, moduleName, moduleName.Capacity) == 0)
- {
- throw new NotSupportedException(NativeError.GetLastError().ToString());
- }
- }
- else
- {
- throw new NotSupportedException(NativeError.GetLastError().ToString());
- }
+ if (moduleHandle != IntPtr.Zero)
+ {
+ moduleName = new StringBuilder(255);
+ if (GetModuleFileName(moduleHandle, moduleName, moduleName.Capacity) == 0)
+ {
+ throw new NotSupportedException(NativeError.GetLastError().ToString());
+ }
+ }
+ else
+ {
+ throw new NotSupportedException(NativeError.GetLastError().ToString());
+ }
- return moduleName.ToString();
- }
- }
+ return moduleName.ToString();
+ }
+ }
- [DllImport("CoreDll.dll", SetLastError=true, CharSet=CharSet.Unicode)]
- private static extern IntPtr GetModuleHandle(IntPtr ModuleName);
+ [DllImport("CoreDll.dll", SetLastError=true, CharSet=CharSet.Unicode)]
+ private static extern IntPtr GetModuleHandle(IntPtr ModuleName);
- [DllImport("CoreDll.dll", SetLastError=true, CharSet=CharSet.Unicode)]
- private static extern Int32 GetModuleFileName(
- IntPtr hModule,
- StringBuilder ModuleName,
- Int32 cch);
+ [DllImport("CoreDll.dll", SetLastError=true, CharSet=CharSet.Unicode)]
+ private static extern Int32 GetModuleFileName(
+ IntPtr hModule,
+ StringBuilder ModuleName,
+ Int32 cch);
#endif
- #endregion Private Static Methods
+ #endregion Private Static Methods
- #region Public Static Fields
+ #region Public Static Fields
- /// <summary>
- /// Gets an empty array of types.
- /// </summary>
- /// <remarks>
- /// <para>
- /// The <c>Type.EmptyTypes</c> field is not available on
- /// the .NET Compact Framework 1.0.
- /// </para>
- /// </remarks>
- public static readonly Type[] EmptyTypes = new Type[0];
+ /// <summary>
+ /// Gets an empty array of types.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// The <c>Type.EmptyTypes</c> field is not available on
+ /// the .NET Compact Framework 1.0.
+ /// </para>
+ /// </remarks>
+ public static readonly Type[] EmptyTypes = new Type[0];
- #endregion Public Static Fields
+ #endregion Public Static Fields
- #region Private Static Fields
+ #region Private Static Fields
- /// <summary>
- /// The fully qualified type of the SystemInfo class.
- /// </summary>
- /// <remarks>
- /// Used by the internal logger to record the Type of the
- /// log message.
- /// </remarks>
- private static readonly Type declaringType = typeof(SystemInfo);
+ /// <summary>
+ /// The fully qualified type of the SystemInfo class.
+ /// </summary>
+ /// <remarks>
+ /// Used by the internal logger to record the Type of the
+ /// log message.
+ /// </remarks>
+ private static readonly Type declaringType = typeof(SystemInfo);
- /// <summary>
- /// Cache the host name for the current machine
- /// </summary>
- private static string s_hostName;
+ /// <summary>
+ /// Cache the host name for the current machine
+ /// </summary>
+ private static string s_hostName;
- /// <summary>
- /// Cache the application friendly name
- /// </summary>
- private static string s_appFriendlyName;
+ /// <summary>
+ /// Cache the application friendly name
+ /// </summary>
+ private static string s_appFriendlyName;
- /// <summary>
- /// Text to output when a <c>null</c> is encountered.
- /// </summary>
- private static string s_nullText;
+ /// <summary>
+ /// Text to output when a <c>null</c> is encountered.
+ /// </summary>
+ private static string s_nullText;
- /// <summary>
- /// Text to output when an unsupported feature is requested.
- /// </summary>
- private static string s_notAvailableText;
+ /// <summary>
+ /// Text to output when an unsupported feature is requested.
+ /// </summary>
+ private static string s_notAvailableText;
- /// <summary>
- /// Start time for the current process.
- /// </summary>
- private static DateTime s_processStartTimeUtc = DateTime.UtcNow;
+ /// <summary>
+ /// Start time for the current process.
+ /// </summary>
+ private static DateTime s_processStartTimeUtc = DateTime.UtcNow;
- #endregion
+ #endregion
- #region Compact Framework Helper Classes
+ #region Compact Framework Helper Classes
#if NETCF_1_0
- /// <summary>
- /// Generate GUIDs on the .NET Compact Framework.
- /// </summary>
- public class PocketGuid
- {
- // guid variant types
- private enum GuidVariant
- {
- ReservedNCS = 0x00,
- Standard = 0x02,
- ReservedMicrosoft = 0x06,
- ReservedFuture = 0x07
- }
+ /// <summary>
+ /// Generate GUIDs on the .NET Compact Framework.
+ /// </summary>
+ public class PocketGuid
+ {
+ // guid variant types
+ private enum GuidVariant
+ {
+ ReservedNCS = 0x00,
+ Standard = 0x02,
+ ReservedMicrosoft = 0x06,
+ ReservedFuture = 0x07
+ }
- // guid version types
- private enum GuidVersion
- {
- TimeBased = 0x01,
- Reserved = 0x02,
- NameBased = 0x03,
- Random = 0x04
- }
+ // guid version types
+ private enum GuidVersion
+ {
+ TimeBased = 0x01,
+ Reserved = 0x02,
+ NameBased = 0x03,
+ Random = 0x04
+ }
- // constants that are used in the class
- private class Const
- {
- // number of bytes in guid
- public const int ByteArraySize = 16;
+ // constants that are used in the class
+ private class Const
+ {
+ // number of bytes in guid
+ public const int ByteArraySize = 16;
- // multiplex variant info
- public const int VariantByte = 8;
- public const int VariantByteMask = 0x3f;
- public const int VariantByteShift = 6;
+ // multiplex variant info
+ public const int VariantByte = 8;
+ public const int VariantByteMask = 0x3f;
+ public const int VariantByteShift = 6;
- // multiplex version info
- public const int VersionByte = 7;
- public const int VersionByteMask = 0x0f;
- public const int VersionByteShift = 4;
- }
+ // multiplex version info
+ public const int VersionByte = 7;
+ public const int VersionByteMask = 0x0f;
+ public const int VersionByteShift = 4;
+ }
- // imports for the crypto api functions
- private class WinApi
- {
- public const uint PROV_RSA_FULL = 1;
- public const uint CRYPT_VERIFYCONTEXT = 0xf0000000;
+ // imports for the crypto api functions
+ private class WinApi
+ {
+ public const uint PROV_RSA_FULL = 1;
+ public const uint CRYPT_VERIFYCONTEXT = 0xf0000000;
- [DllImport("CoreDll.dll")]
- public static extern bool CryptAcquireContext(
- ref IntPtr phProv, string pszContainer, string pszProvider,
- uint dwProvType, uint dwFlags);
+ [DllImport("CoreDll.dll")]
+ public static extern bool CryptAcquireContext(
+ ref IntPtr phProv, string pszContainer, string pszProvider,
+ uint dwProvType, uint dwFlags);
- [DllImport("CoreDll.dll")]
- public static extern bool CryptReleaseContext(
- IntPtr hProv, uint dwFlags);
+ [DllImport("CoreDll.dll")]
+ public static extern bool CryptReleaseContext(
+ IntPtr hProv, uint dwFlags);
- [DllImport("CoreDll.dll")]
- public static extern bool CryptGenRandom(
- IntPtr hProv, int dwLen, byte[] pbBuffer);
- }
+ [DllImport("CoreDll.dll")]
+ public static extern bool CryptGenRandom(
+ IntPtr hProv, int dwLen, byte[] pbBuffer);
+ }
- // all static methods
- private PocketGuid()
- {
- }
+ // all static methods
+ private PocketGuid()
+ {
+ }
- /// <summary>
- /// Return a new System.Guid object.
- /// </summary>
- public static Guid NewGuid()
- {
- IntPtr hCryptProv = IntPtr.Zero;
- Guid guid = Guid.Empty;
+ /// <summary>
+ /// Return a new System.Guid object.
+ /// </summary>
+ public static Guid NewGuid()
+ {
+ IntPtr hCryptProv = IntPtr.Zero;
+ Guid guid = Guid.Empty;
- try
- {
- // holds random bits for guid
- byte[] bits = new byte[Const.ByteArraySize];
+ try
+ {
+ // holds random bits for guid
+ byte[] bits = new byte[Const.ByteArraySize];
- // get crypto provider handle
- if (!WinApi.CryptAcquireContext(ref hCryptProv, null, null,
- WinApi.PROV_RSA_FULL, WinApi.CRYPT_VERIFYCONTEXT))
- {
- throw new SystemException(
- "Failed to acquire cryptography handle.");
- }
+ // get crypto provider handle
+ if (!WinApi.CryptAcquireContext(ref hCryptProv, null, null,
+ WinApi.PROV_RSA_FULL, WinApi.CRYPT_VERIFYCONTEXT))
+ {
+ throw new SystemException(
+ "Failed to acquire cryptography handle.");
+ }
- // generate a 128 bit (16 byte) cryptographically random number
- if (!WinApi.CryptGenRandom(hCryptProv, bits.Length, bits))
- {
- throw new SystemException(
- "Failed to generate cryptography random bytes.");
- }
+ // generate a 128 bit (16 byte) cryptographically random number
+ if (!WinApi.CryptGenRandom(hCryptProv, bits.Length, bits))
+ {
+ throw new SystemException(
+ "Failed to generate cryptography random bytes.");
+ }
- // set the variant
- bits[Const.VariantByte] &= Const.VariantByteMask;
- bits[Const.VariantByte] |=
- ((int)GuidVariant.Standard << Const.VariantByteShift);
+ // set the variant
+ bits[Const.VariantByte] &= Const.VariantByteMask;
+ bits[Const.VariantByte] |=
+ ((int)GuidVariant.Standard << Const.VariantByteShift);
- // set the version
- bits[Const.VersionByte] &= Const.VersionByteMask;
- bits[Const.VersionByte] |=
- ((int)GuidVersion.Random << Const.VersionByteShift);
+ // set the version
+ bits[Const.VersionByte] &= Const.VersionByteMask;
+ bits[Const.VersionByte] |=
+ ((int)GuidVersion.Random << Const.VersionByteShift);
- // create the new System.Guid object
- guid = new Guid(bits);
- }
- finally
- {
- // release the crypto provider handle
- if (hCryptProv != IntPtr.Zero)
- WinApi.CryptReleaseContext(hCryptProv, 0);
- }
+ // create the new System.Guid object
+ guid = new Guid(bits);
+ }
+ finally
+ {
+ // release the crypto provider handle
+ if (hCryptProv != IntPtr.Zero)
+ WinApi.CryptReleaseContext(hCryptProv, 0);
+ }
- return guid;
- }
- }
+ return guid;
+ }
+ }
#endif
- #endregion Compact Framework Helper Classes
- }
+ #endregion Compact Framework Helper Classes
+ }
}
diff --git a/src/log4net/Util/SystemStringFormat.cs b/src/log4net/Util/SystemStringFormat.cs
index f28f077..9b558f3 100644
--- a/src/log4net/Util/SystemStringFormat.cs
+++ b/src/log4net/Util/SystemStringFormat.cs
@@ -24,222 +24,222 @@
namespace log4net.Util
{
- /// <summary>
- /// Utility class that represents a format string.
- /// </summary>
- /// <remarks>
- /// <para>
- /// Utility class that represents a format string.
- /// </para>
- /// </remarks>
- /// <author>Nicko Cadell</author>
- public sealed class SystemStringFormat
- {
- private readonly IFormatProvider m_provider;
+ /// <summary>
+ /// Utility class that represents a format string.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Utility class that represents a format string.
+ /// </para>
+ /// </remarks>
+ /// <author>Nicko Cadell</author>
+ public sealed class SystemStringFormat
+ {
+ private readonly IFormatProvider m_provider;
- /// <summary>
- /// Format
- /// </summary>
- public string Format { get; set; }
+ /// <summary>
+ /// Format
+ /// </summary>
+ public string Format { get; set; }
- /// <summary>
- /// Args
- /// </summary>
- public object[] Args { get; set; }
+ /// <summary>
+ /// Args
+ /// </summary>
+ public object[] Args { get; set; }
- #region Constructor
+ #region Constructor
- /// <summary>
- /// Initialise the <see cref="SystemStringFormat"/>
- /// </summary>
- /// <param name="provider">An <see cref="System.IFormatProvider"/> that supplies culture-specific formatting information.</param>
- /// <param name="format">A <see cref="System.String"/> containing zero or more format items.</param>
- /// <param name="args">An <see cref="System.Object"/> array containing zero or more objects to format.</param>
- public SystemStringFormat(IFormatProvider provider, string format, params object[] args)
- {
- m_provider = provider;
- Format = format;
- Args = args;
- }
+ /// <summary>
+ /// Initialise the <see cref="SystemStringFormat"/>
+ /// </summary>
+ /// <param name="provider">An <see cref="System.IFormatProvider"/> that supplies culture-specific formatting information.</param>
+ /// <param name="format">A <see cref="System.String"/> containing zero or more format items.</param>
+ /// <param name="args">An <see cref="System.Object"/> array containing zero or more objects to format.</param>
+ public SystemStringFormat(IFormatProvider provider, string format, params object[] args)
+ {
+ m_provider = provider;
+ Format = format;
+ Args = args;
+ }
- #endregion Constructor
+ #endregion Constructor
- /// <summary>
- /// Format the string and arguments
- /// </summary>
- /// <returns>the formatted string</returns>
- public override string ToString()
- {
- return StringFormat(m_provider, Format, Args);
- }
+ /// <summary>
+ /// Format the string and arguments
+ /// </summary>
+ /// <returns>the formatted string</returns>
+ public override string ToString()
+ {
+ return StringFormat(m_provider, Format, Args);
+ }
- #region StringFormat
+ #region StringFormat
- /// <summary>
- /// Replaces the format item in a specified <see cref="System.String"/> with the text equivalent
- /// of the value of a corresponding <see cref="System.Object"/> instance in a specified array.
- /// A specified parameter supplies culture-specific formatting information.
- /// </summary>
- /// <param name="provider">An <see cref="System.IFormatProvider"/> that supplies culture-specific formatting information.</param>
- /// <param name="format">A <see cref="System.String"/> containing zero or more format items.</param>
- /// <param name="args">An <see cref="System.Object"/> array containing zero or more objects to format.</param>
- /// <returns>
- /// A copy of format in which the format items have been replaced by the <see cref="System.String"/>
- /// equivalent of the corresponding instances of <see cref="System.Object"/> in args.
- /// </returns>
- /// <remarks>
- /// <para>
- /// This method does not throw exceptions. If an exception thrown while formatting the result the
- /// exception and arguments are returned in the result string.
- /// </para>
- /// </remarks>
- private static string StringFormat(IFormatProvider provider, string format, params object[] args)
- {
- try
- {
- // The format is missing, log null value
- if (format == null)
- {
- return null;
- }
+ /// <summary>
+ /// Replaces the format item in a specified <see cref="System.String"/> with the text equivalent
+ /// of the value of a corresponding <see cref="System.Object"/> instance in a specified array.
+ /// A specified parameter supplies culture-specific formatting information.
+ /// </summary>
+ /// <param name="provider">An <see cref="System.IFormatProvider"/> that supplies culture-specific formatting information.</param>
+ /// <param name="format">A <see cref="System.String"/> containing zero or more format items.</param>
+ /// <param name="args">An <see cref="System.Object"/> array containing zero or more objects to format.</param>
+ /// <returns>
+ /// A copy of format in which the format items have been replaced by the <see cref="System.String"/>
+ /// equivalent of the corresponding instances of <see cref="System.Object"/> in args.
+ /// </returns>
+ /// <remarks>
+ /// <para>
+ /// This method does not throw exceptions. If an exception thrown while formatting the result the
+ /// exception and arguments are returned in the result string.
+ /// </para>
+ /// </remarks>
+ private static string StringFormat(IFormatProvider provider, string format, params object[] args)
+ {
+ try
+ {
+ // The format is missing, log null value
+ if (format == null)
+ {
+ return null;
+ }
- // The args are missing - should not happen unless we are called explicitly with a null array
- if (args == null)
- {
- return format;
- }
+ // The args are missing - should not happen unless we are called explicitly with a null array
+ if (args == null)
+ {
+ return format;
+ }
- // Try to format the string
- return String.Format(provider, format, args);
- }
- catch(Exception ex)
- {
- log4net.Util.LogLog.Warn(declaringType, "Exception while rendering format ["+format+"]", ex);
- return StringFormatError(ex, format, args);
- }
+ // Try to format the string
+ return String.Format(provider, format, args);
+ }
+ catch(Exception ex)
+ {
+ log4net.Util.LogLog.Warn(declaringType, "Exception while rendering format ["+format+"]", ex);
+ return StringFormatError(ex, format, args);
+ }
#if !NET_2_0 && !MONO_2_0 && !MONO_3_5 && !MONO_4_0 && !NETSTANDARD
- catch
- {
- log4net.Util.LogLog.Warn(declaringType, "Exception while rendering format ["+format+"]");
- return StringFormatError(null, format, args);
- }
+ catch
+ {
+ log4net.Util.LogLog.Warn(declaringType, "Exception while rendering format ["+format+"]");
+ return StringFormatError(null, format, args);
+ }
#endif
- }
+ }
- /// <summary>
- /// Process an error during StringFormat
- /// </summary>
- private static string StringFormatError(Exception formatException, string format, object[] args)
- {
- try
- {
- StringBuilder buf = new StringBuilder("<log4net.Error>");
+ /// <summary>
+ /// Process an error during StringFormat
+ /// </summary>
+ private static string StringFormatError(Exception formatException, string format, object[] args)
+ {
+ try
+ {
+ StringBuilder buf = new StringBuilder("<log4net.Error>");
- if (formatException != null)
- {
- buf.Append("Exception during StringFormat: ").Append(formatException.Message);
- }
- else
- {
- buf.Append("Exception during StringFormat");
- }
- buf.Append(" <format>").Append(format).Append("</format>");
- buf.Append("<args>");
- RenderArray(args, buf);
- buf.Append("</args>");
- buf.Append("</log4net.Error>");
+ if (formatException != null)
+ {
+ buf.Append("Exception during StringFormat: ").Append(formatException.Message);
+ }
+ else
+ {
+ buf.Append("Exception during StringFormat");
+ }
+ buf.Append(" <format>").Append(format).Append("</format>");
+ buf.Append("<args>");
+ RenderArray(args, buf);
+ buf.Append("</args>");
+ buf.Append("</log4net.Error>");
- return buf.ToString();
- }
- catch(Exception ex)
- {
- log4net.Util.LogLog.Error(declaringType, "INTERNAL ERROR during StringFormat error handling", ex);
- return "<log4net.Error>Exception during StringFormat. See Internal Log.</log4net.Error>";
- }
+ return buf.ToString();
+ }
+ catch(Exception ex)
+ {
+ log4net.Util.LogLog.Error(declaringType, "INTERNAL ERROR during StringFormat error handling", ex);
+ return "<log4net.Error>Exception during StringFormat. See Internal Log.</log4net.Error>";
+ }
#if !NET_2_0 && !MONO_2_0 && !MONO_3_5 && !MONO_4_0 && !NETSTANDARD
- catch
- {
- log4net.Util.LogLog.Error(declaringType, "INTERNAL ERROR during StringFormat error handling");
- return "<log4net.Error>Exception during StringFormat. See Internal Log.</log4net.Error>";
- }
+ catch
+ {
+ log4net.Util.LogLog.Error(declaringType, "INTERNAL ERROR during StringFormat error handling");
+ return "<log4net.Error>Exception during StringFormat. See Internal Log.</log4net.Error>";
+ }
#endif
- }
+ }
- /// <summary>
- /// Dump the contents of an array into a string builder
- /// </summary>
- private static void RenderArray(Array array, StringBuilder buffer)
- {
- if (array == null)
- {
- buffer.Append(SystemInfo.NullText);
- }
- else
- {
- if (array.Rank != 1)
- {
- buffer.Append(array.ToString());
- }
- else
- {
- buffer.Append("{");
- int len = array.Length;
+ /// <summary>
+ /// Dump the contents of an array into a string builder
+ /// </summary>
+ private static void RenderArray(Array array, StringBuilder buffer)
+ {
+ if (array == null)
+ {
+ buffer.Append(SystemInfo.NullText);
+ }
+ else
+ {
+ if (array.Rank != 1)
+ {
+ buffer.Append(array.ToString());
+ }
+ else
+ {
+ buffer.Append("{");
+ int len = array.Length;
- if (len > 0)
- {
- RenderObject(array.GetValue(0), buffer);
- for (int i = 1; i < len; i++)
- {
- buffer.Append(", ");
- RenderObject(array.GetValue(i), buffer);
- }
- }
- buffer.Append("}");
- }
- }
- }
+ if (len > 0)
+ {
+ RenderObject(array.GetValue(0), buffer);
+ for (int i = 1; i < len; i++)
+ {
+ buffer.Append(", ");
+ RenderObject(array.GetValue(i), buffer);
+ }
+ }
+ buffer.Append("}");
+ }
+ }
+ }
- /// <summary>
- /// Dump an object to a string
- /// </summary>
- private static void RenderObject(Object obj, StringBuilder buffer)
- {
- if (obj == null)
- {
- buffer.Append(SystemInfo.NullText);
- }
- else
- {
- try
- {
- buffer.Append(obj);
- }
- catch(Exception ex)
- {
- buffer.Append("<Exception: ").Append(ex.Message).Append(">");
- }
+ /// <summary>
+ /// Dump an object to a string
+ /// </summary>
+ private static void RenderObject(Object obj, StringBuilder buffer)
+ {
+ if (obj == null)
+ {
+ buffer.Append(SystemInfo.NullText);
+ }
+ else
+ {
+ try
+ {
+ buffer.Append(obj);
+ }
+ catch(Exception ex)
+ {
+ buffer.Append("<Exception: ").Append(ex.Message).Append(">");
+ }
#if !NET_2_0 && !MONO_2_0 && !MONO_3_5 && !MONO_4_0 && !NETSTANDARD
- catch
- {
- buffer.Append("<Exception>");
- }
+ catch
+ {
+ buffer.Append("<Exception>");
+ }
#endif
- }
- }
+ }
+ }
- #endregion StringFormat
+ #endregion StringFormat
- #region Private Static Fields
+ #region Private Static Fields
- /// <summary>
- /// The fully qualified type of the SystemStringFormat class.
- /// </summary>
- /// <remarks>
- /// Used by the internal logger to record the Type of the
- /// log message.
- /// </remarks>
- private static readonly Type declaringType = typeof(SystemStringFormat);
+ /// <summary>
+ /// The fully qualified type of the SystemStringFormat class.
+ /// </summary>
+ /// <remarks>
+ /// Used by the internal logger to record the Type of the
+ /// log message.
+ /// </remarks>
+ private static readonly Type declaringType = typeof(SystemStringFormat);
- #endregion Private Static Fields
- }
+ #endregion Private Static Fields
+ }
}
diff --git a/src/log4net/Util/TextWriterAdapter.cs b/src/log4net/Util/TextWriterAdapter.cs
index 851eac4..e130e58 100644
--- a/src/log4net/Util/TextWriterAdapter.cs
+++ b/src/log4net/Util/TextWriterAdapter.cs
@@ -24,216 +24,216 @@
namespace log4net.Util
{
- /// <summary>
- /// Adapter that extends <see cref="TextWriter"/> and forwards all
- /// messages to an instance of <see cref="TextWriter"/>.
- /// </summary>
- /// <remarks>
- /// <para>
- /// Adapter that extends <see cref="TextWriter"/> and forwards all
- /// messages to an instance of <see cref="TextWriter"/>.
- /// </para>
- /// </remarks>
- /// <author>Nicko Cadell</author>
- public abstract class TextWriterAdapter : TextWriter
- {
- #region Private Member Variables
+ /// <summary>
+ /// Adapter that extends <see cref="TextWriter"/> and forwards all
+ /// messages to an instance of <see cref="TextWriter"/>.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Adapter that extends <see cref="TextWriter"/> and forwards all
+ /// messages to an instance of <see cref="TextWriter"/>.
+ /// </para>
+ /// </remarks>
+ /// <author>Nicko Cadell</author>
+ public abstract class TextWriterAdapter : TextWriter
+ {
+ #region Private Member Variables
- /// <summary>
- /// The writer to forward messages to
- /// </summary>
- private TextWriter m_writer;
+ /// <summary>
+ /// The writer to forward messages to
+ /// </summary>
+ private TextWriter m_writer;
- #endregion
+ #endregion
- #region Constructors
+ #region Constructors
- /// <summary>
- /// Create an instance of <see cref="TextWriterAdapter"/> that forwards all
- /// messages to a <see cref="TextWriter"/>.
- /// </summary>
- /// <param name="writer">The <see cref="TextWriter"/> to forward to</param>
- /// <remarks>
- /// <para>
- /// Create an instance of <see cref="TextWriterAdapter"/> that forwards all
- /// messages to a <see cref="TextWriter"/>.
- /// </para>
- /// </remarks>
- protected TextWriterAdapter(TextWriter writer) : base(CultureInfo.InvariantCulture)
- {
- m_writer = writer;
- }
+ /// <summary>
+ /// Create an instance of <see cref="TextWriterAdapter"/> that forwards all
+ /// messages to a <see cref="TextWriter"/>.
+ /// </summary>
+ /// <param name="writer">The <see cref="TextWriter"/> to forward to</param>
+ /// <remarks>
+ /// <para>
+ /// Create an instance of <see cref="TextWriterAdapter"/> that forwards all
+ /// messages to a <see cref="TextWriter"/>.
+ /// </para>
+ /// </remarks>
+ protected TextWriterAdapter(TextWriter writer) : base(CultureInfo.InvariantCulture)
+ {
+ m_writer = writer;
+ }
- #endregion
+ #endregion
- #region Protected Instance Properties
+ #region Protected Instance Properties
- /// <summary>
- /// Gets or sets the underlying <see cref="TextWriter" />.
- /// </summary>
- /// <value>
- /// The underlying <see cref="TextWriter" />.
- /// </value>
- /// <remarks>
- /// <para>
- /// Gets or sets the underlying <see cref="TextWriter" />.
- /// </para>
- /// </remarks>
- protected TextWriter Writer
- {
- get { return m_writer; }
- set { m_writer = value; }
- }
+ /// <summary>
+ /// Gets or sets the underlying <see cref="TextWriter" />.
+ /// </summary>
+ /// <value>
+ /// The underlying <see cref="TextWriter" />.
+ /// </value>
+ /// <remarks>
+ /// <para>
+ /// Gets or sets the underlying <see cref="TextWriter" />.
+ /// </para>
+ /// </remarks>
+ protected TextWriter Writer
+ {
+ get { return m_writer; }
+ set { m_writer = value; }
+ }
- #endregion Protected Instance Properties
+ #endregion Protected Instance Properties
- #region Public Properties
+ #region Public Properties
- /// <summary>
- /// The Encoding in which the output is written
- /// </summary>
- /// <value>
- /// The <see cref="Encoding"/>
- /// </value>
- /// <remarks>
- /// <para>
- /// The Encoding in which the output is written
- /// </para>
- /// </remarks>
- public override Encoding Encoding
- {
- get { return m_writer.Encoding; }
- }
+ /// <summary>
+ /// The Encoding in which the output is written
+ /// </summary>
+ /// <value>
+ /// The <see cref="Encoding"/>
+ /// </value>
+ /// <remarks>
+ /// <para>
+ /// The Encoding in which the output is written
+ /// </para>
+ /// </remarks>
+ public override Encoding Encoding
+ {
+ get { return m_writer.Encoding; }
+ }
- /// <summary>
- /// Gets an object that controls formatting
- /// </summary>
- /// <value>
- /// The format provider
- /// </value>
- /// <remarks>
- /// <para>
- /// Gets an object that controls formatting
- /// </para>
- /// </remarks>
- public override IFormatProvider FormatProvider
- {
- get { return m_writer.FormatProvider; }
- }
+ /// <summary>
+ /// Gets an object that controls formatting
+ /// </summary>
+ /// <value>
+ /// The format provider
+ /// </value>
+ /// <remarks>
+ /// <para>
+ /// Gets an object that controls formatting
+ /// </para>
+ /// </remarks>
+ public override IFormatProvider FormatProvider
+ {
+ get { return m_writer.FormatProvider; }
+ }
- /// <summary>
- /// Gets or sets the line terminator string used by the TextWriter
- /// </summary>
- /// <value>
- /// The line terminator to use
- /// </value>
- /// <remarks>
- /// <para>
- /// Gets or sets the line terminator string used by the TextWriter
- /// </para>
- /// </remarks>
- public override String NewLine
- {
- get { return m_writer.NewLine; }
- set { m_writer.NewLine = value; }
- }
+ /// <summary>
+ /// Gets or sets the line terminator string used by the TextWriter
+ /// </summary>
+ /// <value>
+ /// The line terminator to use
+ /// </value>
+ /// <remarks>
+ /// <para>
+ /// Gets or sets the line terminator string used by the TextWriter
+ /// </para>
+ /// </remarks>
+ public override String NewLine
+ {
+ get { return m_writer.NewLine; }
+ set { m_writer.NewLine = value; }
+ }
- #endregion
+ #endregion
- #region Public Methods
+ #region Public Methods
- /// <summary>
- /// Closes the writer and releases any system resources associated with the writer
- /// </summary>
- /// <remarks>
- /// <para>
- /// </para>
- /// </remarks>
+ /// <summary>
+ /// Closes the writer and releases any system resources associated with the writer
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// </para>
+ /// </remarks>
#if !NETSTANDARD1_3
- override
+ override
#else
- virtual
+ virtual
#endif
- public void Close()
- {
- m_writer.Close();
- }
+ public void Close()
+ {
+ m_writer.Close();
+ }
- /// <summary>
- /// Dispose this writer
- /// </summary>
- /// <param name="disposing">flag indicating if we are being disposed</param>
- /// <remarks>
- /// <para>
- /// Dispose this writer
- /// </para>
- /// </remarks>
- protected override void Dispose(bool disposing)
- {
- if (disposing)
- {
- ((IDisposable)m_writer).Dispose();
- }
- }
+ /// <summary>
+ /// Dispose this writer
+ /// </summary>
+ /// <param name="disposing">flag indicating if we are being disposed</param>
+ /// <remarks>
+ /// <para>
+ /// Dispose this writer
+ /// </para>
+ /// </remarks>
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing)
+ {
+ ((IDisposable)m_writer).Dispose();
+ }
+ }
- /// <summary>
- /// Flushes any buffered output
- /// </summary>
- /// <remarks>
- /// <para>
- /// Clears all buffers for the writer and causes any buffered data to be written
- /// to the underlying device
- /// </para>
- /// </remarks>
- public override void Flush()
- {
- m_writer.Flush();
- }
+ /// <summary>
+ /// Flushes any buffered output
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Clears all buffers for the writer and causes any buffered data to be written
+ /// to the underlying device
+ /// </para>
+ /// </remarks>
+ public override void Flush()
+ {
+ m_writer.Flush();
+ }
- /// <summary>
- /// Writes a character to the wrapped TextWriter
- /// </summary>
- /// <param name="value">the value to write to the TextWriter</param>
- /// <remarks>
- /// <para>
- /// Writes a character to the wrapped TextWriter
- /// </para>
- /// </remarks>
- public override void Write(char value)
- {
- m_writer.Write(value);
- }
+ /// <summary>
+ /// Writes a character to the wrapped TextWriter
+ /// </summary>
+ /// <param name="value">the value to write to the TextWriter</param>
+ /// <remarks>
+ /// <para>
+ /// Writes a character to the wrapped TextWriter
+ /// </para>
+ /// </remarks>
+ public override void Write(char value)
+ {
+ m_writer.Write(value);
+ }
- /// <summary>
- /// Writes a character buffer to the wrapped TextWriter
- /// </summary>
- /// <param name="buffer">the data buffer</param>
- /// <param name="index">the start index</param>
- /// <param name="count">the number of characters to write</param>
- /// <remarks>
- /// <para>
- /// Writes a character buffer to the wrapped TextWriter
- /// </para>
- /// </remarks>
- public override void Write(char[] buffer, int index, int count)
- {
- m_writer.Write(buffer, index, count);
- }
+ /// <summary>
+ /// Writes a character buffer to the wrapped TextWriter
+ /// </summary>
+ /// <param name="buffer">the data buffer</param>
+ /// <param name="index">the start index</param>
+ /// <param name="count">the number of characters to write</param>
+ /// <remarks>
+ /// <para>
+ /// Writes a character buffer to the wrapped TextWriter
+ /// </para>
+ /// </remarks>
+ public override void Write(char[] buffer, int index, int count)
+ {
+ m_writer.Write(buffer, index, count);
+ }
- /// <summary>
- /// Writes a string to the wrapped TextWriter
- /// </summary>
- /// <param name="value">the value to write to the TextWriter</param>
- /// <remarks>
- /// <para>
- /// Writes a string to the wrapped TextWriter
- /// </para>
- /// </remarks>
- public override void Write(String value)
- {
- m_writer.Write(value);
- }
+ /// <summary>
+ /// Writes a string to the wrapped TextWriter
+ /// </summary>
+ /// <param name="value">the value to write to the TextWriter</param>
+ /// <remarks>
+ /// <para>
+ /// Writes a string to the wrapped TextWriter
+ /// </para>
+ /// </remarks>
+ public override void Write(String value)
+ {
+ m_writer.Write(value);
+ }
- #endregion
- }
+ #endregion
+ }
}
diff --git a/src/log4net/Util/ThreadContextProperties.cs b/src/log4net/Util/ThreadContextProperties.cs
index e002c1b..a35697b 100644
--- a/src/log4net/Util/ThreadContextProperties.cs
+++ b/src/log4net/Util/ThreadContextProperties.cs
@@ -24,177 +24,177 @@
namespace log4net.Util
{
- /// <summary>
- /// Implementation of Properties collection for the <see cref="log4net.ThreadContext"/>
- /// </summary>
- /// <remarks>
- /// <para>
- /// Class implements a collection of properties that is specific to each thread.
- /// The class is not synchronized as each thread has its own <see cref="PropertiesDictionary"/>.
- /// </para>
- /// </remarks>
- /// <author>Nicko Cadell</author>
- public sealed class ThreadContextProperties : ContextPropertiesBase
- {
- #region Private Instance Fields
+ /// <summary>
+ /// Implementation of Properties collection for the <see cref="log4net.ThreadContext"/>
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Class implements a collection of properties that is specific to each thread.
+ /// The class is not synchronized as each thread has its own <see cref="PropertiesDictionary"/>.
+ /// </para>
+ /// </remarks>
+ /// <author>Nicko Cadell</author>
+ public sealed class ThreadContextProperties : ContextPropertiesBase
+ {
+ #region Private Instance Fields
#if NETCF
- /// <summary>
- /// The thread local data slot to use to store a PropertiesDictionary.
- /// </summary>
- private readonly static LocalDataStoreSlot s_threadLocalSlot = System.Threading.Thread.AllocateDataSlot();
+ /// <summary>
+ /// The thread local data slot to use to store a PropertiesDictionary.
+ /// </summary>
+ private readonly static LocalDataStoreSlot s_threadLocalSlot = System.Threading.Thread.AllocateDataSlot();
#else
- /// <summary>
- /// Each thread will automatically have its instance.
- /// </summary>
- [ThreadStatic]
- private static PropertiesDictionary _dictionary;
+ /// <summary>
+ /// Each thread will automatically have its instance.
+ /// </summary>
+ [ThreadStatic]
+ private static PropertiesDictionary _dictionary;
#endif
- #endregion Private Instance Fields
+ #endregion Private Instance Fields
- #region Public Instance Constructors
+ #region Public Instance Constructors
- /// <summary>
- /// Internal constructor
- /// </summary>
- /// <remarks>
- /// <para>
- /// Initializes a new instance of the <see cref="ThreadContextProperties" /> class.
- /// </para>
- /// </remarks>
- internal ThreadContextProperties()
- {
- }
+ /// <summary>
+ /// Internal constructor
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Initializes a new instance of the <see cref="ThreadContextProperties" /> class.
+ /// </para>
+ /// </remarks>
+ internal ThreadContextProperties()
+ {
+ }
- #endregion Public Instance Constructors
+ #endregion Public Instance Constructors
- #region Public Instance Properties
+ #region Public Instance Properties
- /// <summary>
- /// Gets or sets the value of a property
- /// </summary>
- /// <value>
- /// The value for the property with the specified key
- /// </value>
- /// <remarks>
- /// <para>
- /// Gets or sets the value of a property
- /// </para>
- /// </remarks>
- public override object this[string key]
- {
- get
- {
+ /// <summary>
+ /// Gets or sets the value of a property
+ /// </summary>
+ /// <value>
+ /// The value for the property with the specified key
+ /// </value>
+ /// <remarks>
+ /// <para>
+ /// Gets or sets the value of a property
+ /// </para>
+ /// </remarks>
+ public override object this[string key]
+ {
+ get
+ {
#if NETCF
- PropertiesDictionary _dictionary = GetProperties(false);
+ PropertiesDictionary _dictionary = GetProperties(false);
#endif
- if (_dictionary != null)
- {
- return _dictionary[key];
- }
- return null;
- }
- set
- {
- GetProperties(true)[key] = value;
- }
- }
+ if (_dictionary != null)
+ {
+ return _dictionary[key];
+ }
+ return null;
+ }
+ set
+ {
+ GetProperties(true)[key] = value;
+ }
+ }
- #endregion Public Instance Properties
+ #endregion Public Instance Properties
- #region Public Instance Methods
+ #region Public Instance Methods
- /// <summary>
- /// Remove a property
- /// </summary>
- /// <param name="key">the key for the entry to remove</param>
- /// <remarks>
- /// <para>
- /// Remove a property
- /// </para>
- /// </remarks>
- public void Remove(string key)
- {
+ /// <summary>
+ /// Remove a property
+ /// </summary>
+ /// <param name="key">the key for the entry to remove</param>
+ /// <remarks>
+ /// <para>
+ /// Remove a property
+ /// </para>
+ /// </remarks>
+ public void Remove(string key)
+ {
#if NETCF
- PropertiesDictionary _dictionary = GetProperties(false);
+ PropertiesDictionary _dictionary = GetProperties(false);
#endif
- if (_dictionary != null)
- {
- _dictionary.Remove(key);
- }
- }
+ if (_dictionary != null)
+ {
+ _dictionary.Remove(key);
+ }
+ }
- /// <summary>
- /// Get the keys stored in the properties.
- /// </summary>
- /// <para>
- /// Gets the keys stored in the properties.
- /// </para>
- /// <returns>a set of the defined keys</returns>
- public string[] GetKeys()
- {
+ /// <summary>
+ /// Get the keys stored in the properties.
+ /// </summary>
+ /// <para>
+ /// Gets the keys stored in the properties.
+ /// </para>
+ /// <returns>a set of the defined keys</returns>
+ public string[] GetKeys()
+ {
#if NETCF
- PropertiesDictionary _dictionary = GetProperties(false);
+ PropertiesDictionary _dictionary = GetProperties(false);
#endif
- if (_dictionary != null)
- {
- return _dictionary.GetKeys();
- }
- return null;
- }
+ if (_dictionary != null)
+ {
+ return _dictionary.GetKeys();
+ }
+ return null;
+ }
- /// <summary>
- /// Clear all properties
- /// </summary>
- /// <remarks>
- /// <para>
- /// Clear all properties
- /// </para>
- /// </remarks>
- public void Clear()
- {
+ /// <summary>
+ /// Clear all properties
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Clear all properties
+ /// </para>
+ /// </remarks>
+ public void Clear()
+ {
#if NETCF
- PropertiesDictionary _dictionary = GetProperties(false);
+ PropertiesDictionary _dictionary = GetProperties(false);
#endif
- if (_dictionary != null)
- {
- _dictionary.Clear();
- }
- }
+ if (_dictionary != null)
+ {
+ _dictionary.Clear();
+ }
+ }
- #endregion Public Instance Methods
+ #endregion Public Instance Methods
- #region Internal Instance Methods
+ #region Internal Instance Methods
- /// <summary>
- /// Get the <c>PropertiesDictionary</c> for this thread.
- /// </summary>
- /// <param name="create">create the dictionary if it does not exist, otherwise return null if does not exist</param>
- /// <returns>the properties for this thread</returns>
- /// <remarks>
- /// <para>
- /// The collection returned is only to be used on the calling thread. If the
- /// caller needs to share the collection between different threads then the
- /// caller must clone the collection before doing so.
- /// </para>
- /// </remarks>
- internal PropertiesDictionary GetProperties(bool create)
- {
+ /// <summary>
+ /// Get the <c>PropertiesDictionary</c> for this thread.
+ /// </summary>
+ /// <param name="create">create the dictionary if it does not exist, otherwise return null if does not exist</param>
+ /// <returns>the properties for this thread</returns>
+ /// <remarks>
+ /// <para>
+ /// The collection returned is only to be used on the calling thread. If the
+ /// caller needs to share the collection between different threads then the
+ /// caller must clone the collection before doing so.
+ /// </para>
+ /// </remarks>
+ internal PropertiesDictionary GetProperties(bool create)
+ {
#if NETCF
- PropertiesDictionary _dictionary = (PropertiesDictionary)System.Threading.Thread.GetData(s_threadLocalSlot);
+ PropertiesDictionary _dictionary = (PropertiesDictionary)System.Threading.Thread.GetData(s_threadLocalSlot);
#endif
- if (_dictionary == null && create)
- {
- _dictionary = new PropertiesDictionary();
+ if (_dictionary == null && create)
+ {
+ _dictionary = new PropertiesDictionary();
#if NETCF
- System.Threading.Thread.SetData(s_threadLocalSlot, _dictionary);
+ System.Threading.Thread.SetData(s_threadLocalSlot, _dictionary);
#endif
- }
- return _dictionary;
- }
+ }
+ return _dictionary;
+ }
- #endregion Internal Instance Methods
- }
+ #endregion Internal Instance Methods
+ }
}
diff --git a/src/log4net/Util/ThreadContextStack.cs b/src/log4net/Util/ThreadContextStack.cs
index 53d6fba..2d51b81 100644
--- a/src/log4net/Util/ThreadContextStack.cs
+++ b/src/log4net/Util/ThreadContextStack.cs
@@ -27,429 +27,429 @@
namespace log4net.Util
{
- /// <summary>
- /// Implementation of Stack for the <see cref="log4net.ThreadContext"/>
- /// </summary>
- /// <remarks>
- /// <para>
- /// Implementation of Stack for the <see cref="log4net.ThreadContext"/>
- /// </para>
- /// </remarks>
- /// <author>Nicko Cadell</author>
- public sealed class ThreadContextStack : IFixingRequired
- {
- #region Private Static Fields
+ /// <summary>
+ /// Implementation of Stack for the <see cref="log4net.ThreadContext"/>
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Implementation of Stack for the <see cref="log4net.ThreadContext"/>
+ /// </para>
+ /// </remarks>
+ /// <author>Nicko Cadell</author>
+ public sealed class ThreadContextStack : IFixingRequired
+ {
+ #region Private Static Fields
- /// <summary>
- /// The stack store.
- /// </summary>
- private Stack m_stack = new Stack();
+ /// <summary>
+ /// The stack store.
+ /// </summary>
+ private Stack m_stack = new Stack();
- #endregion Private Static Fields
+ #endregion Private Static Fields
- #region Public Instance Constructors
+ #region Public Instance Constructors
- /// <summary>
- /// Internal constructor
- /// </summary>
- /// <remarks>
- /// <para>
- /// Initializes a new instance of the <see cref="ThreadContextStack" /> class.
- /// </para>
- /// </remarks>
- internal ThreadContextStack()
- {
- }
+ /// <summary>
+ /// Internal constructor
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Initializes a new instance of the <see cref="ThreadContextStack" /> class.
+ /// </para>
+ /// </remarks>
+ internal ThreadContextStack()
+ {
+ }
- #endregion Public Instance Constructors
+ #endregion Public Instance Constructors
- #region Public Properties
+ #region Public Properties
- /// <summary>
- /// The number of messages in the stack
- /// </summary>
- /// <value>
- /// The current number of messages in the stack
- /// </value>
- /// <remarks>
- /// <para>
- /// The current number of messages in the stack. That is
- /// the number of times <see cref="Push"/> has been called
- /// minus the number of times <see cref="Pop"/> has been called.
- /// </para>
- /// </remarks>
- public int Count
- {
- get { return m_stack.Count; }
- }
+ /// <summary>
+ /// The number of messages in the stack
+ /// </summary>
+ /// <value>
+ /// The current number of messages in the stack
+ /// </value>
+ /// <remarks>
+ /// <para>
+ /// The current number of messages in the stack. That is
+ /// the number of times <see cref="Push"/> has been called
+ /// minus the number of times <see cref="Pop"/> has been called.
+ /// </para>
+ /// </remarks>
+ public int Count
+ {
+ get { return m_stack.Count; }
+ }
- #endregion // Public Properties
+ #endregion // Public Properties
- #region Public Methods
+ #region Public Methods
- /// <summary>
- /// Clears all the contextual information held in this stack.
- /// </summary>
- /// <remarks>
- /// <para>
- /// Clears all the contextual information held in this stack.
- /// Only call this if you think that this tread is being reused after
- /// a previous call execution which may not have completed correctly.
- /// You do not need to use this method if you always guarantee to call
- /// the <see cref="IDisposable.Dispose"/> method of the <see cref="IDisposable"/>
- /// returned from <see cref="Push"/> even in exceptional circumstances,
- /// for example by using the <c>using(log4net.ThreadContext.Stacks["NDC"].Push("Stack_Message"))</c>
- /// syntax.
- /// </para>
- /// </remarks>
- public void Clear()
- {
- m_stack.Clear();
- }
+ /// <summary>
+ /// Clears all the contextual information held in this stack.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Clears all the contextual information held in this stack.
+ /// Only call this if you think that this tread is being reused after
+ /// a previous call execution which may not have completed correctly.
+ /// You do not need to use this method if you always guarantee to call
+ /// the <see cref="IDisposable.Dispose"/> method of the <see cref="IDisposable"/>
+ /// returned from <see cref="Push"/> even in exceptional circumstances,
+ /// for example by using the <c>using(log4net.ThreadContext.Stacks["NDC"].Push("Stack_Message"))</c>
+ /// syntax.
+ /// </para>
+ /// </remarks>
+ public void Clear()
+ {
+ m_stack.Clear();
+ }
- /// <summary>
- /// Removes the top context from this stack.
- /// </summary>
- /// <returns>The message in the context that was removed from the top of this stack.</returns>
- /// <remarks>
- /// <para>
- /// Remove the top context from this stack, and return
- /// it to the caller. If this stack is empty then an
- /// empty string (not <see langword="null"/>) is returned.
- /// </para>
- /// </remarks>
- public string Pop()
- {
- Stack stack = m_stack;
- if (stack.Count > 0)
- {
- return ((StackFrame)(stack.Pop())).Message;
- }
- return "";
- }
+ /// <summary>
+ /// Removes the top context from this stack.
+ /// </summary>
+ /// <returns>The message in the context that was removed from the top of this stack.</returns>
+ /// <remarks>
+ /// <para>
+ /// Remove the top context from this stack, and return
+ /// it to the caller. If this stack is empty then an
+ /// empty string (not <see langword="null"/>) is returned.
+ /// </para>
+ /// </remarks>
+ public string Pop()
+ {
+ Stack stack = m_stack;
+ if (stack.Count > 0)
+ {
+ return ((StackFrame)(stack.Pop())).Message;
+ }
+ return "";
+ }
- /// <summary>
- /// Pushes a new context message into this stack.
- /// </summary>
- /// <param name="message">The new context message.</param>
- /// <returns>
- /// An <see cref="IDisposable"/> that can be used to clean up the context stack.
- /// </returns>
- /// <remarks>
- /// <para>
- /// Pushes a new context onto this stack. An <see cref="IDisposable"/>
- /// is returned that can be used to clean up this stack. This
- /// can be easily combined with the <c>using</c> keyword to scope the
- /// context.
- /// </para>
- /// </remarks>
- /// <example>Simple example of using the <c>Push</c> method with the <c>using</c> keyword.
- /// <code lang="C#">
- /// using(log4net.ThreadContext.Stacks["NDC"].Push("Stack_Message"))
- /// {
- /// log.Warn("This should have an ThreadContext Stack message");
- /// }
- /// </code>
- /// </example>
- public IDisposable Push(string message)
- {
- Stack stack = m_stack;
- stack.Push(new StackFrame(message, (stack.Count>0) ? (StackFrame)stack.Peek() : null));
+ /// <summary>
+ /// Pushes a new context message into this stack.
+ /// </summary>
+ /// <param name="message">The new context message.</param>
+ /// <returns>
+ /// An <see cref="IDisposable"/> that can be used to clean up the context stack.
+ /// </returns>
+ /// <remarks>
+ /// <para>
+ /// Pushes a new context onto this stack. An <see cref="IDisposable"/>
+ /// is returned that can be used to clean up this stack. This
+ /// can be easily combined with the <c>using</c> keyword to scope the
+ /// context.
+ /// </para>
+ /// </remarks>
+ /// <example>Simple example of using the <c>Push</c> method with the <c>using</c> keyword.
+ /// <code lang="C#">
+ /// using(log4net.ThreadContext.Stacks["NDC"].Push("Stack_Message"))
+ /// {
+ /// log.Warn("This should have an ThreadContext Stack message");
+ /// }
+ /// </code>
+ /// </example>
+ public IDisposable Push(string message)
+ {
+ Stack stack = m_stack;
+ stack.Push(new StackFrame(message, (stack.Count>0) ? (StackFrame)stack.Peek() : null));
- return new AutoPopStackFrame(stack, stack.Count - 1);
- }
+ return new AutoPopStackFrame(stack, stack.Count - 1);
+ }
- /// <summary>
- /// Returns the top context from this stack.
- /// </summary>
- /// <returns>The message in the context from the top of this stack.</returns>
- /// <remarks>
- /// <para>
- /// Returns the top context from this stack. If this stack is empty then an
- /// empty string (not <see langword="null"/>) is returned.
- /// </para>
- /// </remarks>
- public string Peek()
- {
- Stack stack = m_stack;
- if (stack.Count > 0)
- {
- return ((StackFrame)stack.Peek()).Message;
- }
- return "";
- }
+ /// <summary>
+ /// Returns the top context from this stack.
+ /// </summary>
+ /// <returns>The message in the context from the top of this stack.</returns>
+ /// <remarks>
+ /// <para>
+ /// Returns the top context from this stack. If this stack is empty then an
+ /// empty string (not <see langword="null"/>) is returned.
+ /// </para>
+ /// </remarks>
+ public string Peek()
+ {
+ Stack stack = m_stack;
+ if (stack.Count > 0)
+ {
+ return ((StackFrame)stack.Peek()).Message;
+ }
+ return "";
+ }
- #endregion Public Methods
+ #endregion Public Methods
- #region Internal Methods
+ #region Internal Methods
- /// <summary>
- /// Gets the current context information for this stack.
- /// </summary>
- /// <returns>The current context information.</returns>
- internal string GetFullMessage()
- {
- Stack stack = m_stack;
- if (stack.Count > 0)
- {
- return ((StackFrame)(stack.Peek())).FullMessage;
- }
- return null;
- }
+ /// <summary>
+ /// Gets the current context information for this stack.
+ /// </summary>
+ /// <returns>The current context information.</returns>
+ internal string GetFullMessage()
+ {
+ Stack stack = m_stack;
+ if (stack.Count > 0)
+ {
+ return ((StackFrame)(stack.Peek())).FullMessage;
+ }
+ return null;
+ }
- /// <summary>
- /// Gets and sets the internal stack used by this <see cref="ThreadContextStack"/>
- /// </summary>
- /// <value>The internal storage stack</value>
- /// <remarks>
- /// <para>
- /// This property is provided only to support backward compatability
- /// of the <see cref="NDC"/>. Tytpically the internal stack should not
- /// be modified.
- /// </para>
- /// </remarks>
- internal Stack InternalStack
- {
- get { return m_stack; }
- set { m_stack = value; }
- }
+ /// <summary>
+ /// Gets and sets the internal stack used by this <see cref="ThreadContextStack"/>
+ /// </summary>
+ /// <value>The internal storage stack</value>
+ /// <remarks>
+ /// <para>
+ /// This property is provided only to support backward compatability
+ /// of the <see cref="NDC"/>. Tytpically the internal stack should not
+ /// be modified.
+ /// </para>
+ /// </remarks>
+ internal Stack InternalStack
+ {
+ get { return m_stack; }
+ set { m_stack = value; }
+ }
- #endregion Internal Methods
+ #endregion Internal Methods
- /// <summary>
- /// Gets the current context information for this stack.
- /// </summary>
- /// <returns>Gets the current context information</returns>
- /// <remarks>
- /// <para>
- /// Gets the current context information for this stack.
- /// </para>
- /// </remarks>
- public override string ToString()
- {
- return GetFullMessage();
- }
+ /// <summary>
+ /// Gets the current context information for this stack.
+ /// </summary>
+ /// <returns>Gets the current context information</returns>
+ /// <remarks>
+ /// <para>
+ /// Gets the current context information for this stack.
+ /// </para>
+ /// </remarks>
+ public override string ToString()
+ {
+ return GetFullMessage();
+ }
- /// <summary>
- /// Get a portable version of this object
- /// </summary>
- /// <returns>the portable instance of this object</returns>
- /// <remarks>
- /// <para>
- /// Get a cross thread portable version of this object
- /// </para>
- /// </remarks>
- object IFixingRequired.GetFixedObject()
- {
- return GetFullMessage();
- }
+ /// <summary>
+ /// Get a portable version of this object
+ /// </summary>
+ /// <returns>the portable instance of this object</returns>
+ /// <remarks>
+ /// <para>
+ /// Get a cross thread portable version of this object
+ /// </para>
+ /// </remarks>
+ object IFixingRequired.GetFixedObject()
+ {
+ return GetFullMessage();
+ }
- /// <summary>
- /// Inner class used to represent a single context frame in the stack.
- /// </summary>
- /// <remarks>
- /// <para>
- /// Inner class used to represent a single context frame in the stack.
- /// </para>
- /// </remarks>
- private sealed class StackFrame
- {
- #region Private Instance Fields
+ /// <summary>
+ /// Inner class used to represent a single context frame in the stack.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Inner class used to represent a single context frame in the stack.
+ /// </para>
+ /// </remarks>
+ private sealed class StackFrame
+ {
+ #region Private Instance Fields
- private readonly string m_message;
- private readonly StackFrame m_parent;
- private string m_fullMessage = null;
+ private readonly string m_message;
+ private readonly StackFrame m_parent;
+ private string m_fullMessage = null;
- #endregion
+ #endregion
- #region Internal Instance Constructors
+ #region Internal Instance Constructors
- /// <summary>
- /// Constructor
- /// </summary>
- /// <param name="message">The message for this context.</param>
- /// <param name="parent">The parent context in the chain.</param>
- /// <remarks>
- /// <para>
- /// Initializes a new instance of the <see cref="StackFrame" /> class
- /// with the specified message and parent context.
- /// </para>
- /// </remarks>
- internal StackFrame(string message, StackFrame parent)
- {
- m_message = message;
- m_parent = parent;
+ /// <summary>
+ /// Constructor
+ /// </summary>
+ /// <param name="message">The message for this context.</param>
+ /// <param name="parent">The parent context in the chain.</param>
+ /// <remarks>
+ /// <para>
+ /// Initializes a new instance of the <see cref="StackFrame" /> class
+ /// with the specified message and parent context.
+ /// </para>
+ /// </remarks>
+ internal StackFrame(string message, StackFrame parent)
+ {
+ m_message = message;
+ m_parent = parent;
- if (parent == null)
- {
- m_fullMessage = message;
- }
- }
+ if (parent == null)
+ {
+ m_fullMessage = message;
+ }
+ }
- #endregion Internal Instance Constructors
+ #endregion Internal Instance Constructors
- #region Internal Instance Properties
+ #region Internal Instance Properties
- /// <summary>
- /// Get the message.
- /// </summary>
- /// <value>The message.</value>
- /// <remarks>
- /// <para>
- /// Get the message.
- /// </para>
- /// </remarks>
- internal string Message
- {
- get { return m_message; }
- }
+ /// <summary>
+ /// Get the message.
+ /// </summary>
+ /// <value>The message.</value>
+ /// <remarks>
+ /// <para>
+ /// Get the message.
+ /// </para>
+ /// </remarks>
+ internal string Message
+ {
+ get { return m_message; }
+ }
- /// <summary>
- /// Gets the full text of the context down to the root level.
- /// </summary>
- /// <value>
- /// The full text of the context down to the root level.
- /// </value>
- /// <remarks>
- /// <para>
- /// Gets the full text of the context down to the root level.
- /// </para>
- /// </remarks>
- internal string FullMessage
- {
- get
- {
- if (m_fullMessage == null && m_parent != null)
- {
- m_fullMessage = string.Concat(m_parent.FullMessage, " ", m_message);
- }
- return m_fullMessage;
- }
- }
+ /// <summary>
+ /// Gets the full text of the context down to the root level.
+ /// </summary>
+ /// <value>
+ /// The full text of the context down to the root level.
+ /// </value>
+ /// <remarks>
+ /// <para>
+ /// Gets the full text of the context down to the root level.
+ /// </para>
+ /// </remarks>
+ internal string FullMessage
+ {
+ get
+ {
+ if (m_fullMessage == null && m_parent != null)
+ {
+ m_fullMessage = string.Concat(m_parent.FullMessage, " ", m_message);
+ }
+ return m_fullMessage;
+ }
+ }
- #endregion Internal Instance Properties
- }
+ #endregion Internal Instance Properties
+ }
- /// <summary>
- /// Struct returned from the <see cref="ThreadContextStack.Push"/> method.
- /// </summary>
- /// <remarks>
- /// <para>
- /// This struct implements the <see cref="IDisposable"/> and is designed to be used
- /// with the <see langword="using"/> pattern to remove the stack frame at the end of the scope.
- /// </para>
- /// </remarks>
- private struct AutoPopStackFrame : IDisposable
- {
- #region Private Instance Fields
+ /// <summary>
+ /// Struct returned from the <see cref="ThreadContextStack.Push"/> method.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// This struct implements the <see cref="IDisposable"/> and is designed to be used
+ /// with the <see langword="using"/> pattern to remove the stack frame at the end of the scope.
+ /// </para>
+ /// </remarks>
+ private struct AutoPopStackFrame : IDisposable
+ {
+ #region Private Instance Fields
- /// <summary>
- /// The ThreadContextStack internal stack
- /// </summary>
- private Stack m_frameStack;
+ /// <summary>
+ /// The ThreadContextStack internal stack
+ /// </summary>
+ private Stack m_frameStack;
- /// <summary>
- /// The depth to trim the stack to when this instance is disposed
- /// </summary>
- private int m_frameDepth;
+ /// <summary>
+ /// The depth to trim the stack to when this instance is disposed
+ /// </summary>
+ private int m_frameDepth;
- #endregion Private Instance Fields
+ #endregion Private Instance Fields
- #region Internal Instance Constructors
+ #region Internal Instance Constructors
- /// <summary>
- /// Constructor
- /// </summary>
- /// <param name="frameStack">The internal stack used by the ThreadContextStack.</param>
- /// <param name="frameDepth">The depth to return the stack to when this object is disposed.</param>
- /// <remarks>
- /// <para>
- /// Initializes a new instance of the <see cref="AutoPopStackFrame" /> class with
- /// the specified stack and return depth.
- /// </para>
- /// </remarks>
- internal AutoPopStackFrame(Stack frameStack, int frameDepth)
- {
- m_frameStack = frameStack;
- m_frameDepth = frameDepth;
- }
+ /// <summary>
+ /// Constructor
+ /// </summary>
+ /// <param name="frameStack">The internal stack used by the ThreadContextStack.</param>
+ /// <param name="frameDepth">The depth to return the stack to when this object is disposed.</param>
+ /// <remarks>
+ /// <para>
+ /// Initializes a new instance of the <see cref="AutoPopStackFrame" /> class with
+ /// the specified stack and return depth.
+ /// </para>
+ /// </remarks>
+ internal AutoPopStackFrame(Stack frameStack, int frameDepth)
+ {
+ m_frameStack = frameStack;
+ m_frameDepth = frameDepth;
+ }
- #endregion Internal Instance Constructors
+ #endregion Internal Instance Constructors
- #region Implementation of IDisposable
+ #region Implementation of IDisposable
- /// <summary>
- /// Returns the stack to the correct depth.
- /// </summary>
- /// <remarks>
- /// <para>
- /// Returns the stack to the correct depth.
- /// </para>
- /// </remarks>
- public void Dispose()
- {
- if (m_frameDepth >= 0 && m_frameStack != null)
- {
- while(m_frameStack.Count > m_frameDepth)
- {
- m_frameStack.Pop();
- }
- }
- }
+ /// <summary>
+ /// Returns the stack to the correct depth.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Returns the stack to the correct depth.
+ /// </para>
+ /// </remarks>
+ public void Dispose()
+ {
+ if (m_frameDepth >= 0 && m_frameStack != null)
+ {
+ while(m_frameStack.Count > m_frameDepth)
+ {
+ m_frameStack.Pop();
+ }
+ }
+ }
- #endregion Implementation of IDisposable
- }
+ #endregion Implementation of IDisposable
+ }
#if NETCF_1_0
- /// <summary>
- /// Subclass of <see cref="System.Collections.Stack"/> to
- /// provide missing methods.
- /// </summary>
- /// <remarks>
- /// <para>
- /// The Compact Framework version of the <see cref="System.Collections.Stack"/>
- /// class is missing the <c>Clear</c> and <c>Clone</c> methods.
- /// This subclass adds implementations of those missing methods.
- /// </para>
- /// </remarks>
- public class Stack : System.Collections.Stack
- {
- /// <summary>
- /// Clears the stack of all elements.
- /// </summary>
- /// <remarks>
- /// <para>
- /// Clears the stack of all elements.
- /// </para>
- /// </remarks>
- public void Clear()
- {
- while(Count > 0)
- {
- Pop();
- }
- }
+ /// <summary>
+ /// Subclass of <see cref="System.Collections.Stack"/> to
+ /// provide missing methods.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// The Compact Framework version of the <see cref="System.Collections.Stack"/>
+ /// class is missing the <c>Clear</c> and <c>Clone</c> methods.
+ /// This subclass adds implementations of those missing methods.
+ /// </para>
+ /// </remarks>
+ public class Stack : System.Collections.Stack
+ {
+ /// <summary>
+ /// Clears the stack of all elements.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Clears the stack of all elements.
+ /// </para>
+ /// </remarks>
+ public void Clear()
+ {
+ while(Count > 0)
+ {
+ Pop();
+ }
+ }
- /// <summary>
- /// Makes a shallow copy of the stack's elements.
- /// </summary>
- /// <returns>A new stack that has a shallow copy of the stack's elements.</returns>
- /// <remarks>
- /// <para>
- /// Makes a shallow copy of the stack's elements.
- /// </para>
- /// </remarks>
- public Stack Clone()
- {
- Stack res = new Stack();
- object[] items = ToArray();
- foreach(object item in items)
- {
- res.Push(item);
- }
- return res;
- }
- }
+ /// <summary>
+ /// Makes a shallow copy of the stack's elements.
+ /// </summary>
+ /// <returns>A new stack that has a shallow copy of the stack's elements.</returns>
+ /// <remarks>
+ /// <para>
+ /// Makes a shallow copy of the stack's elements.
+ /// </para>
+ /// </remarks>
+ public Stack Clone()
+ {
+ Stack res = new Stack();
+ object[] items = ToArray();
+ foreach(object item in items)
+ {
+ res.Push(item);
+ }
+ return res;
+ }
+ }
#endif
- }
+ }
}
diff --git a/src/log4net/Util/ThreadContextStacks.cs b/src/log4net/Util/ThreadContextStacks.cs
index 0e9c198..20219da 100644
--- a/src/log4net/Util/ThreadContextStacks.cs
+++ b/src/log4net/Util/ThreadContextStacks.cs
@@ -22,103 +22,103 @@
namespace log4net.Util
{
- /// <summary>
- /// Implementation of Stacks collection for the <see cref="log4net.ThreadContext"/>
- /// </summary>
- /// <remarks>
- /// <para>
- /// Implementation of Stacks collection for the <see cref="log4net.ThreadContext"/>
- /// </para>
- /// </remarks>
- /// <author>Nicko Cadell</author>
- public sealed class ThreadContextStacks
- {
- private readonly ContextPropertiesBase m_properties;
+ /// <summary>
+ /// Implementation of Stacks collection for the <see cref="log4net.ThreadContext"/>
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Implementation of Stacks collection for the <see cref="log4net.ThreadContext"/>
+ /// </para>
+ /// </remarks>
+ /// <author>Nicko Cadell</author>
+ public sealed class ThreadContextStacks
+ {
+ private readonly ContextPropertiesBase m_properties;
- #region Public Instance Constructors
+ #region Public Instance Constructors
- /// <summary>
- /// Internal constructor
- /// </summary>
- /// <remarks>
- /// <para>
- /// Initializes a new instance of the <see cref="ThreadContextStacks" /> class.
- /// </para>
- /// </remarks>
- internal ThreadContextStacks(ContextPropertiesBase properties)
- {
- m_properties = properties;
- }
+ /// <summary>
+ /// Internal constructor
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Initializes a new instance of the <see cref="ThreadContextStacks" /> class.
+ /// </para>
+ /// </remarks>
+ internal ThreadContextStacks(ContextPropertiesBase properties)
+ {
+ m_properties = properties;
+ }
- #endregion Public Instance Constructors
+ #endregion Public Instance Constructors
- #region Public Instance Properties
+ #region Public Instance Properties
- /// <summary>
- /// Gets the named thread context stack
- /// </summary>
- /// <value>
- /// The named stack
- /// </value>
- /// <remarks>
- /// <para>
- /// Gets the named thread context stack
- /// </para>
- /// </remarks>
- public ThreadContextStack this[string key]
- {
- get
- {
- ThreadContextStack stack = null;
+ /// <summary>
+ /// Gets the named thread context stack
+ /// </summary>
+ /// <value>
+ /// The named stack
+ /// </value>
+ /// <remarks>
+ /// <para>
+ /// Gets the named thread context stack
+ /// </para>
+ /// </remarks>
+ public ThreadContextStack this[string key]
+ {
+ get
+ {
+ ThreadContextStack stack = null;
- object propertyValue = m_properties[key];
- if (propertyValue == null)
- {
- // Stack does not exist, create
- stack = new ThreadContextStack();
- m_properties[key] = stack;
- }
- else
- {
- // Look for existing stack
- stack = propertyValue as ThreadContextStack;
- if (stack == null)
- {
- // Property is not set to a stack!
- string propertyValueString = SystemInfo.NullText;
+ object propertyValue = m_properties[key];
+ if (propertyValue == null)
+ {
+ // Stack does not exist, create
+ stack = new ThreadContextStack();
+ m_properties[key] = stack;
+ }
+ else
+ {
+ // Look for existing stack
+ stack = propertyValue as ThreadContextStack;
+ if (stack == null)
+ {
+ // Property is not set to a stack!
+ string propertyValueString = SystemInfo.NullText;
- try
- {
- propertyValueString = propertyValue.ToString();
- }
- catch
- {
- }
+ try
+ {
+ propertyValueString = propertyValue.ToString();
+ }
+ catch
+ {
+ }
- LogLog.Error(declaringType, "ThreadContextStacks: Request for stack named ["+key+"] failed because a property with the same name exists which is a ["+propertyValue.GetType().Name+"] with value ["+propertyValueString+"]");
+ LogLog.Error(declaringType, "ThreadContextStacks: Request for stack named ["+key+"] failed because a property with the same name exists which is a ["+propertyValue.GetType().Name+"] with value ["+propertyValueString+"]");
- stack = new ThreadContextStack();
- }
- }
+ stack = new ThreadContextStack();
+ }
+ }
- return stack;
- }
- }
+ return stack;
+ }
+ }
- #endregion Public Instance Properties
+ #endregion Public Instance Properties
- #region Private Static Fields
+ #region Private Static Fields
- /// <summary>
- /// The fully qualified type of the ThreadContextStacks class.
- /// </summary>
- /// <remarks>
- /// Used by the internal logger to record the Type of the
- /// log message.
- /// </remarks>
- private static readonly Type declaringType = typeof(ThreadContextStacks);
+ /// <summary>
+ /// The fully qualified type of the ThreadContextStacks class.
+ /// </summary>
+ /// <remarks>
+ /// Used by the internal logger to record the Type of the
+ /// log message.
+ /// </remarks>
+ private static readonly Type declaringType = typeof(ThreadContextStacks);
- #endregion Private Static Fields
- }
+ #endregion Private Static Fields
+ }
}
diff --git a/src/log4net/Util/Transform.cs b/src/log4net/Util/Transform.cs
index 7e8f408..1689b34 100644
--- a/src/log4net/Util/Transform.cs
+++ b/src/log4net/Util/Transform.cs
@@ -24,177 +24,177 @@
namespace log4net.Util
{
- /// <summary>
- /// Utility class for transforming strings.
- /// </summary>
- /// <remarks>
- /// <para>
- /// Utility class for transforming strings.
- /// </para>
- /// </remarks>
- /// <author>Nicko Cadell</author>
- /// <author>Gert Driesen</author>
- public sealed class Transform
- {
- #region Private Instance Constructors
+ /// <summary>
+ /// Utility class for transforming strings.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Utility class for transforming strings.
+ /// </para>
+ /// </remarks>
+ /// <author>Nicko Cadell</author>
+ /// <author>Gert Driesen</author>
+ public sealed class Transform
+ {
+ #region Private Instance Constructors
- /// <summary>
- /// Initializes a new instance of the <see cref="Transform" /> class.
- /// </summary>
- /// <remarks>
- /// <para>
- /// Uses a private access modifier to prevent instantiation of this class.
- /// </para>
- /// </remarks>
- private Transform()
- {
- }
+ /// <summary>
+ /// Initializes a new instance of the <see cref="Transform" /> class.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Uses a private access modifier to prevent instantiation of this class.
+ /// </para>
+ /// </remarks>
+ private Transform()
+ {
+ }
- #endregion Private Instance Constructors
+ #endregion Private Instance Constructors
- #region XML String Methods
+ #region XML String Methods
- /// <summary>
- /// Write a string to an <see cref="XmlWriter"/>
- /// </summary>
- /// <param name="writer">the writer to write to</param>
- /// <param name="textData">the string to write</param>
- /// <param name="invalidCharReplacement">The string to replace non XML compliant chars with</param>
- /// <remarks>
- /// <para>
- /// The test is escaped either using XML escape entities
- /// or using CDATA sections.
- /// </para>
- /// </remarks>
- public static void WriteEscapedXmlString(XmlWriter writer, string textData, string invalidCharReplacement)
- {
- string stringData = MaskXmlInvalidCharacters(textData, invalidCharReplacement);
- // Write either escaped text or CDATA sections
+ /// <summary>
+ /// Write a string to an <see cref="XmlWriter"/>
+ /// </summary>
+ /// <param name="writer">the writer to write to</param>
+ /// <param name="textData">the string to write</param>
+ /// <param name="invalidCharReplacement">The string to replace non XML compliant chars with</param>
+ /// <remarks>
+ /// <para>
+ /// The test is escaped either using XML escape entities
+ /// or using CDATA sections.
+ /// </para>
+ /// </remarks>
+ public static void WriteEscapedXmlString(XmlWriter writer, string textData, string invalidCharReplacement)
+ {
+ string stringData = MaskXmlInvalidCharacters(textData, invalidCharReplacement);
+ // Write either escaped text or CDATA sections
- int weightCData = 12 * (1 + CountSubstrings(stringData, CDATA_END));
- int weightStringEscapes = 3*(CountSubstrings(stringData, "<") + CountSubstrings(stringData, ">")) + 4*CountSubstrings(stringData, "&");
+ int weightCData = 12 * (1 + CountSubstrings(stringData, CDATA_END));
+ int weightStringEscapes = 3*(CountSubstrings(stringData, "<") + CountSubstrings(stringData, ">")) + 4*CountSubstrings(stringData, "&");
- if (weightStringEscapes <= weightCData)
- {
- // Write string using string escapes
- writer.WriteString(stringData);
- }
- else
- {
- // Write string using CDATA section
+ if (weightStringEscapes <= weightCData)
+ {
+ // Write string using string escapes
+ writer.WriteString(stringData);
+ }
+ else
+ {
+ // Write string using CDATA section
- int end = stringData.IndexOf(CDATA_END);
-
- if (end < 0)
- {
- writer.WriteCData(stringData);
- }
- else
- {
- int start = 0;
- while (end > -1)
- {
- writer.WriteCData(stringData.Substring(start, end - start));
- if (end == stringData.Length - 3)
- {
- start = stringData.Length;
- writer.WriteString(CDATA_END);
- break;
- }
- else
- {
- writer.WriteString(CDATA_UNESCAPABLE_TOKEN);
- start = end + 2;
- end = stringData.IndexOf(CDATA_END, start);
- }
- }
-
- if (start < stringData.Length)
- {
- writer.WriteCData(stringData.Substring(start));
- }
- }
- }
- }
+ int end = stringData.IndexOf(CDATA_END);
+
+ if (end < 0)
+ {
+ writer.WriteCData(stringData);
+ }
+ else
+ {
+ int start = 0;
+ while (end > -1)
+ {
+ writer.WriteCData(stringData.Substring(start, end - start));
+ if (end == stringData.Length - 3)
+ {
+ start = stringData.Length;
+ writer.WriteString(CDATA_END);
+ break;
+ }
+ else
+ {
+ writer.WriteString(CDATA_UNESCAPABLE_TOKEN);
+ start = end + 2;
+ end = stringData.IndexOf(CDATA_END, start);
+ }
+ }
+
+ if (start < stringData.Length)
+ {
+ writer.WriteCData(stringData.Substring(start));
+ }
+ }
+ }
+ }
- /// <summary>
- /// Replace invalid XML characters in text string
- /// </summary>
- /// <param name="textData">the XML text input string</param>
- /// <param name="mask">the string to use in place of invalid characters</param>
- /// <returns>A string that does not contain invalid XML characters.</returns>
- /// <remarks>
- /// <para>
- /// Certain Unicode code points are not allowed in the XML InfoSet, for
- /// details see: <a href="http://www.w3.org/TR/REC-xml/#charsets">http://www.w3.org/TR/REC-xml/#charsets</a>.
- /// </para>
- /// <para>
- /// This method replaces any illegal characters in the input string
- /// with the mask string specified.
- /// </para>
- /// </remarks>
- public static string MaskXmlInvalidCharacters(string textData, string mask)
- {
- return INVALIDCHARS.Replace(textData, mask);
- }
+ /// <summary>
+ /// Replace invalid XML characters in text string
+ /// </summary>
+ /// <param name="textData">the XML text input string</param>
+ /// <param name="mask">the string to use in place of invalid characters</param>
+ /// <returns>A string that does not contain invalid XML characters.</returns>
+ /// <remarks>
+ /// <para>
+ /// Certain Unicode code points are not allowed in the XML InfoSet, for
+ /// details see: <a href="http://www.w3.org/TR/REC-xml/#charsets">http://www.w3.org/TR/REC-xml/#charsets</a>.
+ /// </para>
+ /// <para>
+ /// This method replaces any illegal characters in the input string
+ /// with the mask string specified.
+ /// </para>
+ /// </remarks>
+ public static string MaskXmlInvalidCharacters(string textData, string mask)
+ {
+ return INVALIDCHARS.Replace(textData, mask);
+ }
- #endregion XML String Methods
+ #endregion XML String Methods
- #region Private Helper Methods
+ #region Private Helper Methods
- /// <summary>
- /// Count the number of times that the substring occurs in the text
- /// </summary>
- /// <param name="text">the text to search</param>
- /// <param name="substring">the substring to find</param>
- /// <returns>the number of times the substring occurs in the text</returns>
- /// <remarks>
- /// <para>
- /// The substring is assumed to be non repeating within itself.
- /// </para>
- /// </remarks>
- private static int CountSubstrings(string text, string substring)
- {
- int count = 0;
- int offset = 0;
- int length = text.Length;
- int substringLength = substring.Length;
+ /// <summary>
+ /// Count the number of times that the substring occurs in the text
+ /// </summary>
+ /// <param name="text">the text to search</param>
+ /// <param name="substring">the substring to find</param>
+ /// <returns>the number of times the substring occurs in the text</returns>
+ /// <remarks>
+ /// <para>
+ /// The substring is assumed to be non repeating within itself.
+ /// </para>
+ /// </remarks>
+ private static int CountSubstrings(string text, string substring)
+ {
+ int count = 0;
+ int offset = 0;
+ int length = text.Length;
+ int substringLength = substring.Length;
- if (length == 0)
- {
- return 0;
- }
- if (substringLength == 0)
- {
- return 0;
- }
+ if (length == 0)
+ {
+ return 0;
+ }
+ if (substringLength == 0)
+ {
+ return 0;
+ }
- while(offset < length)
- {
- int index = text.IndexOf(substring, offset);
+ while(offset < length)
+ {
+ int index = text.IndexOf(substring, offset);
- if (index == -1)
- {
- break;
- }
+ if (index == -1)
+ {
+ break;
+ }
- count++;
- offset = index + substringLength;
- }
- return count;
- }
+ count++;
+ offset = index + substringLength;
+ }
+ return count;
+ }
- #endregion
+ #endregion
- #region Private Static Fields
+ #region Private Static Fields
- private const string CDATA_END = "]]>";
- private const string CDATA_UNESCAPABLE_TOKEN = "]]";
+ private const string CDATA_END = "]]>";
+ private const string CDATA_UNESCAPABLE_TOKEN = "]]";
/// <summary>
/// Characters illegal in XML 1.0
/// </summary>
- private static Regex INVALIDCHARS=new Regex(@"[^\x09\x0A\x0D\x20-\uD7FF\uE000-\uFFFD]",RegexOptions.Compiled);
- #endregion Private Static Fields
- }
+ private static Regex INVALIDCHARS=new Regex(@"[^\x09\x0A\x0D\x20-\uD7FF\uE000-\uFFFD]",RegexOptions.Compiled);
+ #endregion Private Static Fields
+ }
}
diff --git a/src/log4net/Util/TypeConverters/BooleanConverter.cs b/src/log4net/Util/TypeConverters/BooleanConverter.cs
index 7853c45..7ca6496 100644
--- a/src/log4net/Util/TypeConverters/BooleanConverter.cs
+++ b/src/log4net/Util/TypeConverters/BooleanConverter.cs
@@ -21,65 +21,65 @@
namespace log4net.Util.TypeConverters
{
- /// <summary>
- /// Type converter for Boolean.
- /// </summary>
- /// <remarks>
- /// <para>
- /// Supports conversion from string to <c>bool</c> type.
- /// </para>
- /// </remarks>
- /// <seealso cref="ConverterRegistry"/>
- /// <seealso cref="IConvertFrom"/>
- /// <seealso cref="IConvertTo"/>
- /// <author>Nicko Cadell</author>
- /// <author>Gert Driesen</author>
- internal class BooleanConverter : IConvertFrom
- {
- #region Implementation of IConvertFrom
+ /// <summary>
+ /// Type converter for Boolean.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Supports conversion from string to <c>bool</c> type.
+ /// </para>
+ /// </remarks>
+ /// <seealso cref="ConverterRegistry"/>
+ /// <seealso cref="IConvertFrom"/>
+ /// <seealso cref="IConvertTo"/>
+ /// <author>Nicko Cadell</author>
+ /// <author>Gert Driesen</author>
+ internal class BooleanConverter : IConvertFrom
+ {
+ #region Implementation of IConvertFrom
- /// <summary>
- /// Can the source type be converted to the type supported by this object
- /// </summary>
- /// <param name="sourceType">the type to convert</param>
- /// <returns>true if the conversion is possible</returns>
- /// <remarks>
- /// <para>
- /// Returns <c>true</c> if the <paramref name="sourceType"/> is
- /// the <see cref="String"/> type.
- /// </para>
- /// </remarks>
- public bool CanConvertFrom(Type sourceType)
- {
- return (sourceType == typeof(string));
- }
+ /// <summary>
+ /// Can the source type be converted to the type supported by this object
+ /// </summary>
+ /// <param name="sourceType">the type to convert</param>
+ /// <returns>true if the conversion is possible</returns>
+ /// <remarks>
+ /// <para>
+ /// Returns <c>true</c> if the <paramref name="sourceType"/> is
+ /// the <see cref="String"/> type.
+ /// </para>
+ /// </remarks>
+ public bool CanConvertFrom(Type sourceType)
+ {
+ return (sourceType == typeof(string));
+ }
- /// <summary>
- /// Convert the source object to the type supported by this object
- /// </summary>
- /// <param name="source">the object to convert</param>
- /// <returns>the converted object</returns>
- /// <remarks>
- /// <para>
- /// Uses the <see cref="Boolean.Parse"/> method to convert the
- /// <see cref="String"/> argument to a <see cref="Boolean"/>.
- /// </para>
- /// </remarks>
- /// <exception cref="ConversionNotSupportedException">
- /// The <paramref name="source"/> object cannot be converted to the
- /// target type. To check for this condition use the <see cref="CanConvertFrom"/>
- /// method.
- /// </exception>
- public object ConvertFrom(object source)
- {
- string str = source as string;
- if (str != null)
- {
- return bool.Parse(str);
- }
- throw ConversionNotSupportedException.Create(typeof(bool), source);
- }
+ /// <summary>
+ /// Convert the source object to the type supported by this object
+ /// </summary>
+ /// <param name="source">the object to convert</param>
+ /// <returns>the converted object</returns>
+ /// <remarks>
+ /// <para>
+ /// Uses the <see cref="Boolean.Parse"/> method to convert the
+ /// <see cref="String"/> argument to a <see cref="Boolean"/>.
+ /// </para>
+ /// </remarks>
+ /// <exception cref="ConversionNotSupportedException">
+ /// The <paramref name="source"/> object cannot be converted to the
+ /// target type. To check for this condition use the <see cref="CanConvertFrom"/>
+ /// method.
+ /// </exception>
+ public object ConvertFrom(object source)
+ {
+ string str = source as string;
+ if (str != null)
+ {
+ return bool.Parse(str);
+ }
+ throw ConversionNotSupportedException.Create(typeof(bool), source);
+ }
- #endregion
- }
+ #endregion
+ }
}
diff --git a/src/log4net/Util/TypeConverters/ConversionNotSupportedException.cs b/src/log4net/Util/TypeConverters/ConversionNotSupportedException.cs
index 717e8bc..ea59d98 100644
--- a/src/log4net/Util/TypeConverters/ConversionNotSupportedException.cs
+++ b/src/log4net/Util/TypeConverters/ConversionNotSupportedException.cs
@@ -24,135 +24,135 @@
namespace log4net.Util.TypeConverters
{
- /// <summary>
- /// Exception base type for conversion errors.
- /// </summary>
- /// <remarks>
- /// <para>
- /// This type extends <see cref="ApplicationException"/>. It
- /// does not add any new functionality but does differentiate the
- /// type of exception being thrown.
- /// </para>
- /// </remarks>
- /// <author>Nicko Cadell</author>
- /// <author>Gert Driesen</author>
+ /// <summary>
+ /// Exception base type for conversion errors.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// This type extends <see cref="ApplicationException"/>. It
+ /// does not add any new functionality but does differentiate the
+ /// type of exception being thrown.
+ /// </para>
+ /// </remarks>
+ /// <author>Nicko Cadell</author>
+ /// <author>Gert Driesen</author>
#if !NETCF
- [Serializable]
+ [Serializable]
#endif
#if NETSTANDARD1_3
- public class ConversionNotSupportedException : Exception
+ public class ConversionNotSupportedException : Exception
#else
- public class ConversionNotSupportedException : ApplicationException
+ public class ConversionNotSupportedException : ApplicationException
#endif
- {
- #region Public Instance Constructors
+ {
+ #region Public Instance Constructors
- /// <summary>
- /// Constructor
- /// </summary>
- /// <remarks>
- /// <para>
- /// Initializes a new instance of the <see cref="ConversionNotSupportedException" /> class.
- /// </para>
- /// </remarks>
- public ConversionNotSupportedException()
- {
- }
+ /// <summary>
+ /// Constructor
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Initializes a new instance of the <see cref="ConversionNotSupportedException" /> class.
+ /// </para>
+ /// </remarks>
+ public ConversionNotSupportedException()
+ {
+ }
- /// <summary>
- /// Constructor
- /// </summary>
- /// <param name="message">A message to include with the exception.</param>
- /// <remarks>
- /// <para>
- /// Initializes a new instance of the <see cref="ConversionNotSupportedException" /> class
- /// with the specified message.
- /// </para>
- /// </remarks>
- public ConversionNotSupportedException(String message) : base(message)
- {
- }
-
- /// <summary>
- /// Constructor
- /// </summary>
- /// <param name="message">A message to include with the exception.</param>
- /// <param name="innerException">A nested exception to include.</param>
- /// <remarks>
- /// <para>
- /// Initializes a new instance of the <see cref="ConversionNotSupportedException" /> class
- /// with the specified message and inner exception.
- /// </para>
- /// </remarks>
- public ConversionNotSupportedException(String message, Exception innerException) : base(message, innerException)
- {
- }
+ /// <summary>
+ /// Constructor
+ /// </summary>
+ /// <param name="message">A message to include with the exception.</param>
+ /// <remarks>
+ /// <para>
+ /// Initializes a new instance of the <see cref="ConversionNotSupportedException" /> class
+ /// with the specified message.
+ /// </para>
+ /// </remarks>
+ public ConversionNotSupportedException(String message) : base(message)
+ {
+ }
+
+ /// <summary>
+ /// Constructor
+ /// </summary>
+ /// <param name="message">A message to include with the exception.</param>
+ /// <param name="innerException">A nested exception to include.</param>
+ /// <remarks>
+ /// <para>
+ /// Initializes a new instance of the <see cref="ConversionNotSupportedException" /> class
+ /// with the specified message and inner exception.
+ /// </para>
+ /// </remarks>
+ public ConversionNotSupportedException(String message, Exception innerException) : base(message, innerException)
+ {
+ }
- #endregion Public Instance Constructors
+ #endregion Public Instance Constructors
- #region Protected Instance Constructors
+ #region Protected Instance Constructors
#if !NETCF && !NETSTANDARD1_3
- /// <summary>
- /// Serialization constructor
- /// </summary>
- /// <param name="info">The <see cref="SerializationInfo" /> that holds the serialized object data about the exception being thrown.</param>
- /// <param name="context">The <see cref="StreamingContext" /> that contains contextual information about the source or destination.</param>
- /// <remarks>
- /// <para>
- /// Initializes a new instance of the <see cref="ConversionNotSupportedException" /> class
- /// with serialized data.
- /// </para>
- /// </remarks>
- protected ConversionNotSupportedException(SerializationInfo info, StreamingContext context) : base(info, context)
- {
- }
+ /// <summary>
+ /// Serialization constructor
+ /// </summary>
+ /// <param name="info">The <see cref="SerializationInfo" /> that holds the serialized object data about the exception being thrown.</param>
+ /// <param name="context">The <see cref="StreamingContext" /> that contains contextual information about the source or destination.</param>
+ /// <remarks>
+ /// <para>
+ /// Initializes a new instance of the <see cref="ConversionNotSupportedException" /> class
+ /// with serialized data.
+ /// </para>
+ /// </remarks>
+ protected ConversionNotSupportedException(SerializationInfo info, StreamingContext context) : base(info, context)
+ {
+ }
#endif
- #endregion Protected Instance Constructors
+ #endregion Protected Instance Constructors
- #region Public Static Methods
+ #region Public Static Methods
- /// <summary>
- /// Creates a new instance of the <see cref="ConversionNotSupportedException" /> class.
- /// </summary>
- /// <param name="destinationType">The conversion destination type.</param>
- /// <param name="sourceValue">The value to convert.</param>
- /// <returns>An instance of the <see cref="ConversionNotSupportedException" />.</returns>
- /// <remarks>
- /// <para>
- /// Creates a new instance of the <see cref="ConversionNotSupportedException" /> class.
- /// </para>
- /// </remarks>
- public static ConversionNotSupportedException Create(Type destinationType, object sourceValue)
- {
- return Create(destinationType, sourceValue, null);
- }
+ /// <summary>
+ /// Creates a new instance of the <see cref="ConversionNotSupportedException" /> class.
+ /// </summary>
+ /// <param name="destinationType">The conversion destination type.</param>
+ /// <param name="sourceValue">The value to convert.</param>
+ /// <returns>An instance of the <see cref="ConversionNotSupportedException" />.</returns>
+ /// <remarks>
+ /// <para>
+ /// Creates a new instance of the <see cref="ConversionNotSupportedException" /> class.
+ /// </para>
+ /// </remarks>
+ public static ConversionNotSupportedException Create(Type destinationType, object sourceValue)
+ {
+ return Create(destinationType, sourceValue, null);
+ }
- /// <summary>
- /// Creates a new instance of the <see cref="ConversionNotSupportedException" /> class.
- /// </summary>
- /// <param name="destinationType">The conversion destination type.</param>
- /// <param name="sourceValue">The value to convert.</param>
- /// <param name="innerException">A nested exception to include.</param>
- /// <returns>An instance of the <see cref="ConversionNotSupportedException" />.</returns>
- /// <remarks>
- /// <para>
- /// Creates a new instance of the <see cref="ConversionNotSupportedException" /> class.
- /// </para>
- /// </remarks>
- public static ConversionNotSupportedException Create(Type destinationType, object sourceValue, Exception innerException)
- {
- if (sourceValue == null)
- {
- return new ConversionNotSupportedException("Cannot convert value [null] to type ["+destinationType+"]", innerException);
- }
- else
- {
- return new ConversionNotSupportedException("Cannot convert from type ["+sourceValue.GetType()+"] value ["+sourceValue+"] to type ["+destinationType+"]", innerException);
- }
- }
+ /// <summary>
+ /// Creates a new instance of the <see cref="ConversionNotSupportedException" /> class.
+ /// </summary>
+ /// <param name="destinationType">The conversion destination type.</param>
+ /// <param name="sourceValue">The value to convert.</param>
+ /// <param name="innerException">A nested exception to include.</param>
+ /// <returns>An instance of the <see cref="ConversionNotSupportedException" />.</returns>
+ /// <remarks>
+ /// <para>
+ /// Creates a new instance of the <see cref="ConversionNotSupportedException" /> class.
+ /// </para>
+ /// </remarks>
+ public static ConversionNotSupportedException Create(Type destinationType, object sourceValue, Exception innerException)
+ {
+ if (sourceValue == null)
+ {
+ return new ConversionNotSupportedException("Cannot convert value [null] to type ["+destinationType+"]", innerException);
+ }
+ else
+ {
+ return new ConversionNotSupportedException("Cannot convert from type ["+sourceValue.GetType()+"] value ["+sourceValue+"] to type ["+destinationType+"]", innerException);
+ }
+ }
- #endregion Public Static Methods
- }
+ #endregion Public Static Methods
+ }
}
diff --git a/src/log4net/Util/TypeConverters/ConverterRegistry.cs b/src/log4net/Util/TypeConverters/ConverterRegistry.cs
index e20bbd5..bc0fa10 100644
--- a/src/log4net/Util/TypeConverters/ConverterRegistry.cs
+++ b/src/log4net/Util/TypeConverters/ConverterRegistry.cs
@@ -25,280 +25,280 @@
namespace log4net.Util.TypeConverters
{
- /// <summary>
- /// Register of type converters for specific types.
- /// </summary>
- /// <remarks>
- /// <para>
- /// Maintains a registry of type converters used to convert between
- /// types.
- /// </para>
- /// <para>
- /// Use the <see cref="M:AddConverter(Type, object)"/> and
- /// <see cref="M:AddConverter(Type, Type)"/> methods to register new converters.
- /// The <see cref="GetConvertTo"/> and <see cref="GetConvertFrom"/> methods
- /// lookup appropriate converters to use.
- /// </para>
- /// </remarks>
- /// <seealso cref="IConvertFrom"/>
- /// <seealso cref="IConvertTo"/>
- /// <author>Nicko Cadell</author>
- /// <author>Gert Driesen</author>
- public sealed class ConverterRegistry
- {
- #region Private Constructors
+ /// <summary>
+ /// Register of type converters for specific types.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Maintains a registry of type converters used to convert between
+ /// types.
+ /// </para>
+ /// <para>
+ /// Use the <see cref="M:AddConverter(Type, object)"/> and
+ /// <see cref="M:AddConverter(Type, Type)"/> methods to register new converters.
+ /// The <see cref="GetConvertTo"/> and <see cref="GetConvertFrom"/> methods
+ /// lookup appropriate converters to use.
+ /// </para>
+ /// </remarks>
+ /// <seealso cref="IConvertFrom"/>
+ /// <seealso cref="IConvertTo"/>
+ /// <author>Nicko Cadell</author>
+ /// <author>Gert Driesen</author>
+ public sealed class ConverterRegistry
+ {
+ #region Private Constructors
- /// <summary>
- /// Private constructor
- /// </summary>
- /// <remarks>
- /// Initializes a new instance of the <see cref="ConverterRegistry" /> class.
- /// </remarks>
- private ConverterRegistry()
- {
- }
+ /// <summary>
+ /// Private constructor
+ /// </summary>
+ /// <remarks>
+ /// Initializes a new instance of the <see cref="ConverterRegistry" /> class.
+ /// </remarks>
+ private ConverterRegistry()
+ {
+ }
- #endregion Private Constructors
+ #endregion Private Constructors
- #region Static Constructor
+ #region Static Constructor
- /// <summary>
- /// Static constructor.
- /// </summary>
- /// <remarks>
- /// <para>
- /// This constructor defines the intrinsic type converters.
- /// </para>
- /// </remarks>
- static ConverterRegistry()
- {
- // Add predefined converters here
- AddConverter(typeof(bool), typeof(BooleanConverter));
- AddConverter(typeof(System.Text.Encoding), typeof(EncodingConverter));
- AddConverter(typeof(System.Type), typeof(TypeConverter));
- AddConverter(typeof(log4net.Layout.PatternLayout), typeof(PatternLayoutConverter));
- AddConverter(typeof(log4net.Util.PatternString), typeof(PatternStringConverter));
- AddConverter(typeof(System.Net.IPAddress), typeof(IPAddressConverter));
- }
+ /// <summary>
+ /// Static constructor.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// This constructor defines the intrinsic type converters.
+ /// </para>
+ /// </remarks>
+ static ConverterRegistry()
+ {
+ // Add predefined converters here
+ AddConverter(typeof(bool), typeof(BooleanConverter));
+ AddConverter(typeof(System.Text.Encoding), typeof(EncodingConverter));
+ AddConverter(typeof(System.Type), typeof(TypeConverter));
+ AddConverter(typeof(log4net.Layout.PatternLayout), typeof(PatternLayoutConverter));
+ AddConverter(typeof(log4net.Util.PatternString), typeof(PatternStringConverter));
+ AddConverter(typeof(System.Net.IPAddress), typeof(IPAddressConverter));
+ }
- #endregion Static Constructor
+ #endregion Static Constructor
- #region Public Static Methods
+ #region Public Static Methods
- /// <summary>
- /// Adds a converter for a specific type.
- /// </summary>
- /// <param name="destinationType">The type being converted to.</param>
- /// <param name="converter">The type converter to use to convert to the destination type.</param>
- /// <remarks>
- /// <para>
- /// Adds a converter instance for a specific type.
- /// </para>
- /// </remarks>
- public static void AddConverter(Type destinationType, object converter)
- {
- if (destinationType != null && converter != null)
- {
- lock(s_type2converter)
- {
- s_type2converter[destinationType] = converter;
- }
- }
- }
+ /// <summary>
+ /// Adds a converter for a specific type.
+ /// </summary>
+ /// <param name="destinationType">The type being converted to.</param>
+ /// <param name="converter">The type converter to use to convert to the destination type.</param>
+ /// <remarks>
+ /// <para>
+ /// Adds a converter instance for a specific type.
+ /// </para>
+ /// </remarks>
+ public static void AddConverter(Type destinationType, object converter)
+ {
+ if (destinationType != null && converter != null)
+ {
+ lock(s_type2converter)
+ {
+ s_type2converter[destinationType] = converter;
+ }
+ }
+ }
- /// <summary>
- /// Adds a converter for a specific type.
- /// </summary>
- /// <param name="destinationType">The type being converted to.</param>
- /// <param name="converterType">The type of the type converter to use to convert to the destination type.</param>
- /// <remarks>
- /// <para>
- /// Adds a converter <see cref="Type"/> for a specific type.
- /// </para>
- /// </remarks>
- public static void AddConverter(Type destinationType, Type converterType)
- {
- AddConverter(destinationType, CreateConverterInstance(converterType));
- }
+ /// <summary>
+ /// Adds a converter for a specific type.
+ /// </summary>
+ /// <param name="destinationType">The type being converted to.</param>
+ /// <param name="converterType">The type of the type converter to use to convert to the destination type.</param>
+ /// <remarks>
+ /// <para>
+ /// Adds a converter <see cref="Type"/> for a specific type.
+ /// </para>
+ /// </remarks>
+ public static void AddConverter(Type destinationType, Type converterType)
+ {
+ AddConverter(destinationType, CreateConverterInstance(converterType));
+ }
- /// <summary>
- /// Gets the type converter to use to convert values to the destination type.
- /// </summary>
- /// <param name="sourceType">The type being converted from.</param>
- /// <param name="destinationType">The type being converted to.</param>
- /// <returns>
- /// The type converter instance to use for type conversions or <c>null</c>
- /// if no type converter is found.
- /// </returns>
- /// <remarks>
- /// <para>
- /// Gets the type converter to use to convert values to the destination type.
- /// </para>
- /// </remarks>
- public static IConvertTo GetConvertTo(Type sourceType, Type destinationType)
- {
- // TODO: Support inheriting type converters.
- // i.e. getting a type converter for a base of sourceType
+ /// <summary>
+ /// Gets the type converter to use to convert values to the destination type.
+ /// </summary>
+ /// <param name="sourceType">The type being converted from.</param>
+ /// <param name="destinationType">The type being converted to.</param>
+ /// <returns>
+ /// The type converter instance to use for type conversions or <c>null</c>
+ /// if no type converter is found.
+ /// </returns>
+ /// <remarks>
+ /// <para>
+ /// Gets the type converter to use to convert values to the destination type.
+ /// </para>
+ /// </remarks>
+ public static IConvertTo GetConvertTo(Type sourceType, Type destinationType)
+ {
+ // TODO: Support inheriting type converters.
+ // i.e. getting a type converter for a base of sourceType
- // TODO: Is destinationType required? We don't use it for anything.
+ // TODO: Is destinationType required? We don't use it for anything.
- lock(s_type2converter)
- {
- // Lookup in the static registry
- IConvertTo converter = s_type2converter[sourceType] as IConvertTo;
+ lock(s_type2converter)
+ {
+ // Lookup in the static registry
+ IConvertTo converter = s_type2converter[sourceType] as IConvertTo;
- if (converter == null)
- {
- // Lookup using attributes
- converter = GetConverterFromAttribute(sourceType) as IConvertTo;
+ if (converter == null)
+ {
+ // Lookup using attributes
+ converter = GetConverterFromAttribute(sourceType) as IConvertTo;
- if (converter != null)
- {
- // Store in registry
- s_type2converter[sourceType] = converter;
- }
- }
+ if (converter != null)
+ {
+ // Store in registry
+ s_type2converter[sourceType] = converter;
+ }
+ }
- return converter;
- }
- }
+ return converter;
+ }
+ }
- /// <summary>
- /// Gets the type converter to use to convert values to the destination type.
- /// </summary>
- /// <param name="destinationType">The type being converted to.</param>
- /// <returns>
- /// The type converter instance to use for type conversions or <c>null</c>
- /// if no type converter is found.
- /// </returns>
- /// <remarks>
- /// <para>
- /// Gets the type converter to use to convert values to the destination type.
- /// </para>
- /// </remarks>
- public static IConvertFrom GetConvertFrom(Type destinationType)
- {
- // TODO: Support inheriting type converters.
- // i.e. getting a type converter for a base of destinationType
+ /// <summary>
+ /// Gets the type converter to use to convert values to the destination type.
+ /// </summary>
+ /// <param name="destinationType">The type being converted to.</param>
+ /// <returns>
+ /// The type converter instance to use for type conversions or <c>null</c>
+ /// if no type converter is found.
+ /// </returns>
+ /// <remarks>
+ /// <para>
+ /// Gets the type converter to use to convert values to the destination type.
+ /// </para>
+ /// </remarks>
+ public static IConvertFrom GetConvertFrom(Type destinationType)
+ {
+ // TODO: Support inheriting type converters.
+ // i.e. getting a type converter for a base of destinationType
- lock(s_type2converter)
- {
- // Lookup in the static registry
- IConvertFrom converter = s_type2converter[destinationType] as IConvertFrom;
+ lock(s_type2converter)
+ {
+ // Lookup in the static registry
+ IConvertFrom converter = s_type2converter[destinationType] as IConvertFrom;
- if (converter == null)
- {
- // Lookup using attributes
- converter = GetConverterFromAttribute(destinationType) as IConvertFrom;
+ if (converter == null)
+ {
+ // Lookup using attributes
+ converter = GetConverterFromAttribute(destinationType) as IConvertFrom;
- if (converter != null)
- {
- // Store in registry
- s_type2converter[destinationType] = converter;
- }
- }
+ if (converter != null)
+ {
+ // Store in registry
+ s_type2converter[destinationType] = converter;
+ }
+ }
- return converter;
- }
- }
-
- /// <summary>
- /// Lookups the type converter to use as specified by the attributes on the
- /// destination type.
- /// </summary>
- /// <param name="destinationType">The type being converted to.</param>
- /// <returns>
- /// The type converter instance to use for type conversions or <c>null</c>
- /// if no type converter is found.
- /// </returns>
- private static object GetConverterFromAttribute(Type destinationType)
- {
- // Look for an attribute on the destination type
- var attributes = destinationType
+ return converter;
+ }
+ }
+
+ /// <summary>
+ /// Lookups the type converter to use as specified by the attributes on the
+ /// destination type.
+ /// </summary>
+ /// <param name="destinationType">The type being converted to.</param>
+ /// <returns>
+ /// The type converter instance to use for type conversions or <c>null</c>
+ /// if no type converter is found.
+ /// </returns>
+ private static object GetConverterFromAttribute(Type destinationType)
+ {
+ // Look for an attribute on the destination type
+ var attributes = destinationType
#if NETSTANDARD1_3
- .GetTypeInfo()
+ .GetTypeInfo()
#endif
- .GetCustomAttributes(typeof(TypeConverterAttribute), true);
- if (attributes is null)
- {
- // I assume the original null check is perhaps for CF or older .NET versions -- please leave in place
- return null;
- }
+ .GetCustomAttributes(typeof(TypeConverterAttribute), true);
+ if (attributes is null)
+ {
+ // I assume the original null check is perhaps for CF or older .NET versions -- please leave in place
+ return null;
+ }
- foreach (var attribute in attributes)
- {
- var tcAttr = attribute as TypeConverterAttribute;
- if (tcAttr != null)
- {
- var converterType = SystemInfo.GetTypeFromString(destinationType, tcAttr.ConverterTypeName, false, true);
- return CreateConverterInstance(converterType);
- }
- }
+ foreach (var attribute in attributes)
+ {
+ var tcAttr = attribute as TypeConverterAttribute;
+ if (tcAttr != null)
+ {
+ var converterType = SystemInfo.GetTypeFromString(destinationType, tcAttr.ConverterTypeName, false, true);
+ return CreateConverterInstance(converterType);
+ }
+ }
- // Not found converter using attributes
- return null;
- }
+ // Not found converter using attributes
+ return null;
+ }
- /// <summary>
- /// Creates the instance of the type converter.
- /// </summary>
- /// <param name="converterType">The type of the type converter.</param>
- /// <returns>
- /// The type converter instance to use for type conversions or <c>null</c>
- /// if no type converter is found.
- /// </returns>
- /// <remarks>
- /// <para>
- /// The type specified for the type converter must implement
- /// the <see cref="IConvertFrom"/> or <see cref="IConvertTo"/> interfaces
- /// and must have a public default (no argument) constructor.
- /// </para>
- /// </remarks>
- private static object CreateConverterInstance(Type converterType)
- {
- if (converterType == null)
- {
- throw new ArgumentNullException("converterType", "CreateConverterInstance cannot create instance, converterType is null");
- }
+ /// <summary>
+ /// Creates the instance of the type converter.
+ /// </summary>
+ /// <param name="converterType">The type of the type converter.</param>
+ /// <returns>
+ /// The type converter instance to use for type conversions or <c>null</c>
+ /// if no type converter is found.
+ /// </returns>
+ /// <remarks>
+ /// <para>
+ /// The type specified for the type converter must implement
+ /// the <see cref="IConvertFrom"/> or <see cref="IConvertTo"/> interfaces
+ /// and must have a public default (no argument) constructor.
+ /// </para>
+ /// </remarks>
+ private static object CreateConverterInstance(Type converterType)
+ {
+ if (converterType == null)
+ {
+ throw new ArgumentNullException("converterType", "CreateConverterInstance cannot create instance, converterType is null");
+ }
- // Check type is a converter
- if (typeof(IConvertFrom).IsAssignableFrom(converterType) || typeof(IConvertTo).IsAssignableFrom(converterType))
- {
- try
- {
- // Create the type converter
- return Activator.CreateInstance(converterType);
- }
- catch(Exception ex)
- {
- LogLog.Error(declaringType, "Cannot CreateConverterInstance of type ["+converterType.FullName+"], Exception in call to Activator.CreateInstance", ex);
- }
- }
- else
- {
- LogLog.Error(declaringType, "Cannot CreateConverterInstance of type ["+converterType.FullName+"], type does not implement IConvertFrom or IConvertTo");
- }
- return null;
- }
+ // Check type is a converter
+ if (typeof(IConvertFrom).IsAssignableFrom(converterType) || typeof(IConvertTo).IsAssignableFrom(converterType))
+ {
+ try
+ {
+ // Create the type converter
+ return Activator.CreateInstance(converterType);
+ }
+ catch(Exception ex)
+ {
+ LogLog.Error(declaringType, "Cannot CreateConverterInstance of type ["+converterType.FullName+"], Exception in call to Activator.CreateInstance", ex);
+ }
+ }
+ else
+ {
+ LogLog.Error(declaringType, "Cannot CreateConverterInstance of type ["+converterType.FullName+"], type does not implement IConvertFrom or IConvertTo");
+ }
+ return null;
+ }
- #endregion Public Static Methods
+ #endregion Public Static Methods
- #region Private Static Fields
+ #region Private Static Fields
- /// <summary>
- /// The fully qualified type of the ConverterRegistry class.
- /// </summary>
- /// <remarks>
- /// Used by the internal logger to record the Type of the
- /// log message.
- /// </remarks>
- private static readonly Type declaringType = typeof(ConverterRegistry);
+ /// <summary>
+ /// The fully qualified type of the ConverterRegistry class.
+ /// </summary>
+ /// <remarks>
+ /// Used by the internal logger to record the Type of the
+ /// log message.
+ /// </remarks>
+ private static readonly Type declaringType = typeof(ConverterRegistry);
- /// <summary>
- /// Mapping from <see cref="Type" /> to type converter.
- /// </summary>
- private static Hashtable s_type2converter = new Hashtable();
+ /// <summary>
+ /// Mapping from <see cref="Type" /> to type converter.
+ /// </summary>
+ private static Hashtable s_type2converter = new Hashtable();
- #endregion
- }
+ #endregion
+ }
}
diff --git a/src/log4net/Util/TypeConverters/EncodingConverter.cs b/src/log4net/Util/TypeConverters/EncodingConverter.cs
index 93c9eac..27dd4bb 100644
--- a/src/log4net/Util/TypeConverters/EncodingConverter.cs
+++ b/src/log4net/Util/TypeConverters/EncodingConverter.cs
@@ -22,65 +22,65 @@
namespace log4net.Util.TypeConverters
{
- /// <summary>
- /// Supports conversion from string to <see cref="Encoding"/> type.
- /// </summary>
- /// <remarks>
- /// <para>
- /// Supports conversion from string to <see cref="Encoding"/> type.
- /// </para>
- /// </remarks>
- /// <seealso cref="ConverterRegistry"/>
- /// <seealso cref="IConvertFrom"/>
- /// <seealso cref="IConvertTo"/>
- /// <author>Nicko Cadell</author>
- /// <author>Gert Driesen</author>
- internal class EncodingConverter : IConvertFrom
- {
- #region Implementation of IConvertFrom
+ /// <summary>
+ /// Supports conversion from string to <see cref="Encoding"/> type.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Supports conversion from string to <see cref="Encoding"/> type.
+ /// </para>
+ /// </remarks>
+ /// <seealso cref="ConverterRegistry"/>
+ /// <seealso cref="IConvertFrom"/>
+ /// <seealso cref="IConvertTo"/>
+ /// <author>Nicko Cadell</author>
+ /// <author>Gert Driesen</author>
+ internal class EncodingConverter : IConvertFrom
+ {
+ #region Implementation of IConvertFrom
- /// <summary>
- /// Can the source type be converted to the type supported by this object
- /// </summary>
- /// <param name="sourceType">the type to convert</param>
- /// <returns>true if the conversion is possible</returns>
- /// <remarks>
- /// <para>
- /// Returns <c>true</c> if the <paramref name="sourceType"/> is
- /// the <see cref="String"/> type.
- /// </para>
- /// </remarks>
- public bool CanConvertFrom(Type sourceType)
- {
- return (sourceType == typeof(string));
- }
+ /// <summary>
+ /// Can the source type be converted to the type supported by this object
+ /// </summary>
+ /// <param name="sourceType">the type to convert</param>
+ /// <returns>true if the conversion is possible</returns>
+ /// <remarks>
+ /// <para>
+ /// Returns <c>true</c> if the <paramref name="sourceType"/> is
+ /// the <see cref="String"/> type.
+ /// </para>
+ /// </remarks>
+ public bool CanConvertFrom(Type sourceType)
+ {
+ return (sourceType == typeof(string));
+ }
- /// <summary>
- /// Overrides the ConvertFrom method of IConvertFrom.
- /// </summary>
- /// <param name="source">the object to convert to an encoding</param>
- /// <returns>the encoding</returns>
- /// <remarks>
- /// <para>
- /// Uses the <see cref="M:Encoding.GetEncoding(string)"/> method to
- /// convert the <see cref="String"/> argument to an <see cref="Encoding"/>.
- /// </para>
- /// </remarks>
- /// <exception cref="ConversionNotSupportedException">
- /// The <paramref name="source"/> object cannot be converted to the
- /// target type. To check for this condition use the <see cref="CanConvertFrom"/>
- /// method.
- /// </exception>
- public object ConvertFrom(object source)
- {
- string str = source as string;
- if (str != null)
- {
- return Encoding.GetEncoding(str);
- }
- throw ConversionNotSupportedException.Create(typeof(Encoding), source);
- }
+ /// <summary>
+ /// Overrides the ConvertFrom method of IConvertFrom.
+ /// </summary>
+ /// <param name="source">the object to convert to an encoding</param>
+ /// <returns>the encoding</returns>
+ /// <remarks>
+ /// <para>
+ /// Uses the <see cref="M:Encoding.GetEncoding(string)"/> method to
+ /// convert the <see cref="String"/> argument to an <see cref="Encoding"/>.
+ /// </para>
+ /// </remarks>
+ /// <exception cref="ConversionNotSupportedException">
+ /// The <paramref name="source"/> object cannot be converted to the
+ /// target type. To check for this condition use the <see cref="CanConvertFrom"/>
+ /// method.
+ /// </exception>
+ public object ConvertFrom(object source)
+ {
+ string str = source as string;
+ if (str != null)
+ {
+ return Encoding.GetEncoding(str);
+ }
+ throw ConversionNotSupportedException.Create(typeof(Encoding), source);
+ }
- #endregion
- }
+ #endregion
+ }
}
diff --git a/src/log4net/Util/TypeConverters/IConvertFrom.cs b/src/log4net/Util/TypeConverters/IConvertFrom.cs
index 1dbd473..f34f9b2 100644
--- a/src/log4net/Util/TypeConverters/IConvertFrom.cs
+++ b/src/log4net/Util/TypeConverters/IConvertFrom.cs
@@ -21,43 +21,43 @@
namespace log4net.Util.TypeConverters
{
- /// <summary>
- /// Interface supported by type converters
- /// </summary>
- /// <remarks>
- /// <para>
- /// This interface supports conversion from arbitrary types
- /// to a single target type. See <see cref="TypeConverterAttribute"/>.
- /// </para>
- /// </remarks>
- /// <author>Nicko Cadell</author>
- /// <author>Gert Driesen</author>
- public interface IConvertFrom
- {
- /// <summary>
- /// Can the source type be converted to the type supported by this object
- /// </summary>
- /// <param name="sourceType">the type to convert</param>
- /// <returns>true if the conversion is possible</returns>
- /// <remarks>
- /// <para>
- /// Test if the <paramref name="sourceType"/> can be converted to the
- /// type supported by this converter.
- /// </para>
- /// </remarks>
- bool CanConvertFrom(Type sourceType);
+ /// <summary>
+ /// Interface supported by type converters
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// This interface supports conversion from arbitrary types
+ /// to a single target type. See <see cref="TypeConverterAttribute"/>.
+ /// </para>
+ /// </remarks>
+ /// <author>Nicko Cadell</author>
+ /// <author>Gert Driesen</author>
+ public interface IConvertFrom
+ {
+ /// <summary>
+ /// Can the source type be converted to the type supported by this object
+ /// </summary>
+ /// <param name="sourceType">the type to convert</param>
+ /// <returns>true if the conversion is possible</returns>
+ /// <remarks>
+ /// <para>
+ /// Test if the <paramref name="sourceType"/> can be converted to the
+ /// type supported by this converter.
+ /// </para>
+ /// </remarks>
+ bool CanConvertFrom(Type sourceType);
- /// <summary>
- /// Convert the source object to the type supported by this object
- /// </summary>
- /// <param name="source">the object to convert</param>
- /// <returns>the converted object</returns>
- /// <remarks>
- /// <para>
- /// Converts the <paramref name="source"/> to the type supported
- /// by this converter.
- /// </para>
- /// </remarks>
- object ConvertFrom(object source);
- }
+ /// <summary>
+ /// Convert the source object to the type supported by this object
+ /// </summary>
+ /// <param name="source">the object to convert</param>
+ /// <returns>the converted object</returns>
+ /// <remarks>
+ /// <para>
+ /// Converts the <paramref name="source"/> to the type supported
+ /// by this converter.
+ /// </para>
+ /// </remarks>
+ object ConvertFrom(object source);
+ }
}
diff --git a/src/log4net/Util/TypeConverters/IConvertTo.cs b/src/log4net/Util/TypeConverters/IConvertTo.cs
index e986372..abd748f 100644
--- a/src/log4net/Util/TypeConverters/IConvertTo.cs
+++ b/src/log4net/Util/TypeConverters/IConvertTo.cs
@@ -21,43 +21,43 @@
namespace log4net.Util.TypeConverters
{
- /// <summary>
- /// Interface supported by type converters
- /// </summary>
- /// <remarks>
- /// <para>
- /// This interface supports conversion from a single type to arbitrary types.
- /// See <see cref="TypeConverterAttribute"/>.
- /// </para>
- /// </remarks>
- /// <author>Nicko Cadell</author>
- public interface IConvertTo
- {
- /// <summary>
- /// Returns whether this converter can convert the object to the specified type
- /// </summary>
- /// <param name="targetType">A Type that represents the type you want to convert to</param>
- /// <returns>true if the conversion is possible</returns>
- /// <remarks>
- /// <para>
- /// Test if the type supported by this converter can be converted to the
- /// <paramref name="targetType"/>.
- /// </para>
- /// </remarks>
- bool CanConvertTo(Type targetType);
+ /// <summary>
+ /// Interface supported by type converters
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// This interface supports conversion from a single type to arbitrary types.
+ /// See <see cref="TypeConverterAttribute"/>.
+ /// </para>
+ /// </remarks>
+ /// <author>Nicko Cadell</author>
+ public interface IConvertTo
+ {
+ /// <summary>
+ /// Returns whether this converter can convert the object to the specified type
+ /// </summary>
+ /// <param name="targetType">A Type that represents the type you want to convert to</param>
+ /// <returns>true if the conversion is possible</returns>
+ /// <remarks>
+ /// <para>
+ /// Test if the type supported by this converter can be converted to the
+ /// <paramref name="targetType"/>.
+ /// </para>
+ /// </remarks>
+ bool CanConvertTo(Type targetType);
- /// <summary>
- /// Converts the given value object to the specified type, using the arguments
- /// </summary>
- /// <param name="source">the object to convert</param>
- /// <param name="targetType">The Type to convert the value parameter to</param>
- /// <returns>the converted object</returns>
- /// <remarks>
- /// <para>
- /// Converts the <paramref name="source"/> (which must be of the type supported
- /// by this converter) to the <paramref name="targetType"/> specified..
- /// </para>
- /// </remarks>
- object ConvertTo(object source, Type targetType);
- }
+ /// <summary>
+ /// Converts the given value object to the specified type, using the arguments
+ /// </summary>
+ /// <param name="source">the object to convert</param>
+ /// <param name="targetType">The Type to convert the value parameter to</param>
+ /// <returns>the converted object</returns>
+ /// <remarks>
+ /// <para>
+ /// Converts the <paramref name="source"/> (which must be of the type supported
+ /// by this converter) to the <paramref name="targetType"/> specified..
+ /// </para>
+ /// </remarks>
+ object ConvertTo(object source, Type targetType);
+ }
}
diff --git a/src/log4net/Util/TypeConverters/IPAddressConverter.cs b/src/log4net/Util/TypeConverters/IPAddressConverter.cs
index 56e6b31..2c133a4 100644
--- a/src/log4net/Util/TypeConverters/IPAddressConverter.cs
+++ b/src/log4net/Util/TypeConverters/IPAddressConverter.cs
@@ -22,127 +22,127 @@
namespace log4net.Util.TypeConverters
{
- /// <summary>
- /// Supports conversion from string to <see cref="IPAddress"/> type.
- /// </summary>
- /// <remarks>
- /// <para>
- /// Supports conversion from string to <see cref="IPAddress"/> type.
- /// </para>
- /// </remarks>
- /// <seealso cref="ConverterRegistry"/>
- /// <seealso cref="IConvertFrom"/>
- /// <author>Nicko Cadell</author>
- internal class IPAddressConverter : IConvertFrom
- {
- #region Implementation of IConvertFrom
+ /// <summary>
+ /// Supports conversion from string to <see cref="IPAddress"/> type.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Supports conversion from string to <see cref="IPAddress"/> type.
+ /// </para>
+ /// </remarks>
+ /// <seealso cref="ConverterRegistry"/>
+ /// <seealso cref="IConvertFrom"/>
+ /// <author>Nicko Cadell</author>
+ internal class IPAddressConverter : IConvertFrom
+ {
+ #region Implementation of IConvertFrom
- /// <summary>
- /// Can the source type be converted to the type supported by this object
- /// </summary>
- /// <param name="sourceType">the type to convert</param>
- /// <returns>true if the conversion is possible</returns>
- /// <remarks>
- /// <para>
- /// Returns <c>true</c> if the <paramref name="sourceType"/> is
- /// the <see cref="String"/> type.
- /// </para>
- /// </remarks>
- public bool CanConvertFrom(Type sourceType)
- {
- return (sourceType == typeof(string));
- }
+ /// <summary>
+ /// Can the source type be converted to the type supported by this object
+ /// </summary>
+ /// <param name="sourceType">the type to convert</param>
+ /// <returns>true if the conversion is possible</returns>
+ /// <remarks>
+ /// <para>
+ /// Returns <c>true</c> if the <paramref name="sourceType"/> is
+ /// the <see cref="String"/> type.
+ /// </para>
+ /// </remarks>
+ public bool CanConvertFrom(Type sourceType)
+ {
+ return (sourceType == typeof(string));
+ }
- /// <summary>
- /// Overrides the ConvertFrom method of IConvertFrom.
- /// </summary>
- /// <param name="source">the object to convert to an IPAddress</param>
- /// <returns>the IPAddress</returns>
- /// <remarks>
- /// <para>
- /// Uses the <see cref="IPAddress.Parse"/> method to convert the
- /// <see cref="String"/> argument to an <see cref="IPAddress"/>.
- /// If that fails then the string is resolved as a DNS hostname.
- /// </para>
- /// </remarks>
- /// <exception cref="ConversionNotSupportedException">
- /// The <paramref name="source"/> object cannot be converted to the
- /// target type. To check for this condition use the <see cref="CanConvertFrom"/>
- /// method.
- /// </exception>
- public object ConvertFrom(object source)
- {
- string str = source as string;
- if (str != null && str.Length > 0)
- {
- try
- {
+ /// <summary>
+ /// Overrides the ConvertFrom method of IConvertFrom.
+ /// </summary>
+ /// <param name="source">the object to convert to an IPAddress</param>
+ /// <returns>the IPAddress</returns>
+ /// <remarks>
+ /// <para>
+ /// Uses the <see cref="IPAddress.Parse"/> method to convert the
+ /// <see cref="String"/> argument to an <see cref="IPAddress"/>.
+ /// If that fails then the string is resolved as a DNS hostname.
+ /// </para>
+ /// </remarks>
+ /// <exception cref="ConversionNotSupportedException">
+ /// The <paramref name="source"/> object cannot be converted to the
+ /// target type. To check for this condition use the <see cref="CanConvertFrom"/>
+ /// method.
+ /// </exception>
+ public object ConvertFrom(object source)
+ {
+ string str = source as string;
+ if (str != null && str.Length > 0)
+ {
+ try
+ {
#if NET_2_0 || NETCF_2_0
#if !NETCF_2_0
- // Try an explicit parse of string representation of an IPAddress (v4 or v6)
- IPAddress result;
- if (IPAddress.TryParse(str, out result))
- {
- return result;
- }
+ // Try an explicit parse of string representation of an IPAddress (v4 or v6)
+ IPAddress result;
+ if (IPAddress.TryParse(str, out result))
+ {
+ return result;
+ }
#endif
- // Try to resolve via DNS. This is a blocking call.
- // GetHostEntry works with either an IPAddress string or a host name
- IPHostEntry host = Dns.GetHostEntry(str);
- if (host != null &&
- host.AddressList != null &&
- host.AddressList.Length > 0 &&
- host.AddressList[0] != null)
- {
- return host.AddressList[0];
- }
+ // Try to resolve via DNS. This is a blocking call.
+ // GetHostEntry works with either an IPAddress string or a host name
+ IPHostEntry host = Dns.GetHostEntry(str);
+ if (host != null &&
+ host.AddressList != null &&
+ host.AddressList.Length > 0 &&
+ host.AddressList[0] != null)
+ {
+ return host.AddressList[0];
+ }
#else
- // Before .NET 2 we need to try to parse the IPAddress from the string first
+ // Before .NET 2 we need to try to parse the IPAddress from the string first
- // Check if the string only contains IP address valid chars
- if (str.Trim(validIpAddressChars).Length == 0)
- {
- try
- {
- // try to parse the string as an IP address
- return IPAddress.Parse(str);
- }
- catch(FormatException)
- {
- // Ignore a FormatException, try to resolve via DNS
- }
- }
+ // Check if the string only contains IP address valid chars
+ if (str.Trim(validIpAddressChars).Length == 0)
+ {
+ try
+ {
+ // try to parse the string as an IP address
+ return IPAddress.Parse(str);
+ }
+ catch(FormatException)
+ {
+ // Ignore a FormatException, try to resolve via DNS
+ }
+ }
- // Try to resolve via DNS. This is a blocking call.
+ // Try to resolve via DNS. This is a blocking call.
#if NETSTANDARD
- IPHostEntry host = Dns.GetHostEntryAsync(str).GetAwaiter().GetResult();
+ IPHostEntry host = Dns.GetHostEntryAsync(str).GetAwaiter().GetResult();
#else
- IPHostEntry host = Dns.GetHostByName(str);
+ IPHostEntry host = Dns.GetHostByName(str);
#endif
- if (host != null &&
- host.AddressList != null &&
- host.AddressList.Length > 0 &&
- host.AddressList[0] != null)
- {
- return host.AddressList[0];
- }
+ if (host != null &&
+ host.AddressList != null &&
+ host.AddressList.Length > 0 &&
+ host.AddressList[0] != null)
+ {
+ return host.AddressList[0];
+ }
#endif
- }
- catch(Exception ex)
- {
- throw ConversionNotSupportedException.Create(typeof(IPAddress), source, ex);
- }
- }
- throw ConversionNotSupportedException.Create(typeof(IPAddress), source);
- }
+ }
+ catch(Exception ex)
+ {
+ throw ConversionNotSupportedException.Create(typeof(IPAddress), source, ex);
+ }
+ }
+ throw ConversionNotSupportedException.Create(typeof(IPAddress), source);
+ }
- #endregion
+ #endregion
- /// <summary>
- /// Valid characters in an IPv4 or IPv6 address string. (Does not support subnets)
- /// </summary>
- private static readonly char[] validIpAddressChars = {'0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f','A','B','C','D','E','F','x','X','.',':','%'};
- }
+ /// <summary>
+ /// Valid characters in an IPv4 or IPv6 address string. (Does not support subnets)
+ /// </summary>
+ private static readonly char[] validIpAddressChars = {'0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f','A','B','C','D','E','F','x','X','.',':','%'};
+ }
}
diff --git a/src/log4net/Util/TypeConverters/PatternLayoutConverter.cs b/src/log4net/Util/TypeConverters/PatternLayoutConverter.cs
index c9942b2..a3f594c 100644
--- a/src/log4net/Util/TypeConverters/PatternLayoutConverter.cs
+++ b/src/log4net/Util/TypeConverters/PatternLayoutConverter.cs
@@ -24,69 +24,69 @@
namespace log4net.Util.TypeConverters
{
- /// <summary>
- /// Supports conversion from string to <see cref="PatternLayout"/> type.
- /// </summary>
- /// <remarks>
- /// <para>
- /// Supports conversion from string to <see cref="PatternLayout"/> type.
- /// </para>
- /// <para>
- /// The string is used as the <see cref="PatternLayout.ConversionPattern"/>
- /// of the <see cref="PatternLayout"/>.
- /// </para>
- /// </remarks>
- /// <seealso cref="ConverterRegistry"/>
- /// <seealso cref="IConvertFrom"/>
- /// <seealso cref="IConvertTo"/>
- /// <author>Nicko Cadell</author>
- internal class PatternLayoutConverter : IConvertFrom
- {
- #region Implementation of IConvertFrom
+ /// <summary>
+ /// Supports conversion from string to <see cref="PatternLayout"/> type.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Supports conversion from string to <see cref="PatternLayout"/> type.
+ /// </para>
+ /// <para>
+ /// The string is used as the <see cref="PatternLayout.ConversionPattern"/>
+ /// of the <see cref="PatternLayout"/>.
+ /// </para>
+ /// </remarks>
+ /// <seealso cref="ConverterRegistry"/>
+ /// <seealso cref="IConvertFrom"/>
+ /// <seealso cref="IConvertTo"/>
+ /// <author>Nicko Cadell</author>
+ internal class PatternLayoutConverter : IConvertFrom
+ {
+ #region Implementation of IConvertFrom
- /// <summary>
- /// Can the source type be converted to the type supported by this object
- /// </summary>
- /// <param name="sourceType">the type to convert</param>
- /// <returns>true if the conversion is possible</returns>
- /// <remarks>
- /// <para>
- /// Returns <c>true</c> if the <paramref name="sourceType"/> is
- /// the <see cref="String"/> type.
- /// </para>
- /// </remarks>
- public bool CanConvertFrom(System.Type sourceType)
- {
- return (sourceType == typeof(string));
- }
+ /// <summary>
+ /// Can the source type be converted to the type supported by this object
+ /// </summary>
+ /// <param name="sourceType">the type to convert</param>
+ /// <returns>true if the conversion is possible</returns>
+ /// <remarks>
+ /// <para>
+ /// Returns <c>true</c> if the <paramref name="sourceType"/> is
+ /// the <see cref="String"/> type.
+ /// </para>
+ /// </remarks>
+ public bool CanConvertFrom(System.Type sourceType)
+ {
+ return (sourceType == typeof(string));
+ }
- /// <summary>
- /// Overrides the ConvertFrom method of IConvertFrom.
- /// </summary>
- /// <param name="source">the object to convert to a PatternLayout</param>
- /// <returns>the PatternLayout</returns>
- /// <remarks>
- /// <para>
- /// Creates and returns a new <see cref="PatternLayout"/> using
- /// the <paramref name="source"/> <see cref="String"/> as the
- /// <see cref="PatternLayout.ConversionPattern"/>.
- /// </para>
- /// </remarks>
- /// <exception cref="ConversionNotSupportedException">
- /// The <paramref name="source"/> object cannot be converted to the
- /// target type. To check for this condition use the <see cref="CanConvertFrom"/>
- /// method.
- /// </exception>
- public object ConvertFrom(object source)
- {
- string str = source as string;
- if (str != null)
- {
- return new PatternLayout(str);
- }
- throw ConversionNotSupportedException.Create(typeof(PatternLayout), source);
- }
+ /// <summary>
+ /// Overrides the ConvertFrom method of IConvertFrom.
+ /// </summary>
+ /// <param name="source">the object to convert to a PatternLayout</param>
+ /// <returns>the PatternLayout</returns>
+ /// <remarks>
+ /// <para>
+ /// Creates and returns a new <see cref="PatternLayout"/> using
+ /// the <paramref name="source"/> <see cref="String"/> as the
+ /// <see cref="PatternLayout.ConversionPattern"/>.
+ /// </para>
+ /// </remarks>
+ /// <exception cref="ConversionNotSupportedException">
+ /// The <paramref name="source"/> object cannot be converted to the
+ /// target type. To check for this condition use the <see cref="CanConvertFrom"/>
+ /// method.
+ /// </exception>
+ public object ConvertFrom(object source)
+ {
+ string str = source as string;
+ if (str != null)
+ {
+ return new PatternLayout(str);
+ }
+ throw ConversionNotSupportedException.Create(typeof(PatternLayout), source);
+ }
- #endregion
- }
+ #endregion
+ }
}
diff --git a/src/log4net/Util/TypeConverters/PatternStringConverter.cs b/src/log4net/Util/TypeConverters/PatternStringConverter.cs
index 82104d0..c414b63 100644
--- a/src/log4net/Util/TypeConverters/PatternStringConverter.cs
+++ b/src/log4net/Util/TypeConverters/PatternStringConverter.cs
@@ -21,117 +21,117 @@
namespace log4net.Util.TypeConverters
{
- /// <summary>
- /// Convert between string and <see cref="PatternString"/>
- /// </summary>
- /// <remarks>
- /// <para>
- /// Supports conversion from string to <see cref="PatternString"/> type,
- /// and from a <see cref="PatternString"/> type to a string.
- /// </para>
- /// <para>
- /// The string is used as the <see cref="PatternString.ConversionPattern"/>
- /// of the <see cref="PatternString"/>.
- /// </para>
- /// </remarks>
- /// <seealso cref="ConverterRegistry"/>
- /// <seealso cref="IConvertFrom"/>
- /// <seealso cref="IConvertTo"/>
- /// <author>Nicko Cadell</author>
- internal class PatternStringConverter : IConvertTo, IConvertFrom
- {
- #region Implementation of IConvertTo
+ /// <summary>
+ /// Convert between string and <see cref="PatternString"/>
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Supports conversion from string to <see cref="PatternString"/> type,
+ /// and from a <see cref="PatternString"/> type to a string.
+ /// </para>
+ /// <para>
+ /// The string is used as the <see cref="PatternString.ConversionPattern"/>
+ /// of the <see cref="PatternString"/>.
+ /// </para>
+ /// </remarks>
+ /// <seealso cref="ConverterRegistry"/>
+ /// <seealso cref="IConvertFrom"/>
+ /// <seealso cref="IConvertTo"/>
+ /// <author>Nicko Cadell</author>
+ internal class PatternStringConverter : IConvertTo, IConvertFrom
+ {
+ #region Implementation of IConvertTo
- /// <summary>
- /// Can the target type be converted to the type supported by this object
- /// </summary>
- /// <param name="targetType">A <see cref="Type"/> that represents the type you want to convert to</param>
- /// <returns>true if the conversion is possible</returns>
- /// <remarks>
- /// <para>
- /// Returns <c>true</c> if the <paramref name="targetType"/> is
- /// assignable from a <see cref="String"/> type.
- /// </para>
- /// </remarks>
- public bool CanConvertTo(Type targetType)
- {
- return (typeof(string).IsAssignableFrom(targetType));
- }
+ /// <summary>
+ /// Can the target type be converted to the type supported by this object
+ /// </summary>
+ /// <param name="targetType">A <see cref="Type"/> that represents the type you want to convert to</param>
+ /// <returns>true if the conversion is possible</returns>
+ /// <remarks>
+ /// <para>
+ /// Returns <c>true</c> if the <paramref name="targetType"/> is
+ /// assignable from a <see cref="String"/> type.
+ /// </para>
+ /// </remarks>
+ public bool CanConvertTo(Type targetType)
+ {
+ return (typeof(string).IsAssignableFrom(targetType));
+ }
- /// <summary>
- /// Converts the given value object to the specified type, using the arguments
- /// </summary>
- /// <param name="source">the object to convert</param>
- /// <param name="targetType">The Type to convert the value parameter to</param>
- /// <returns>the converted object</returns>
- /// <remarks>
- /// <para>
- /// Uses the <see cref="M:PatternString.Format()"/> method to convert the
- /// <see cref="PatternString"/> argument to a <see cref="String"/>.
- /// </para>
- /// </remarks>
- /// <exception cref="ConversionNotSupportedException">
- /// The <paramref name="source"/> object cannot be converted to the
- /// <paramref name="targetType"/>. To check for this condition use the
- /// <see cref="CanConvertTo"/> method.
- /// </exception>
- public object ConvertTo(object source, Type targetType)
- {
- PatternString patternString = source as PatternString;
- if (patternString != null && CanConvertTo(targetType))
- {
- return patternString.Format();
- }
- throw ConversionNotSupportedException.Create(targetType, source);
- }
+ /// <summary>
+ /// Converts the given value object to the specified type, using the arguments
+ /// </summary>
+ /// <param name="source">the object to convert</param>
+ /// <param name="targetType">The Type to convert the value parameter to</param>
+ /// <returns>the converted object</returns>
+ /// <remarks>
+ /// <para>
+ /// Uses the <see cref="M:PatternString.Format()"/> method to convert the
+ /// <see cref="PatternString"/> argument to a <see cref="String"/>.
+ /// </para>
+ /// </remarks>
+ /// <exception cref="ConversionNotSupportedException">
+ /// The <paramref name="source"/> object cannot be converted to the
+ /// <paramref name="targetType"/>. To check for this condition use the
+ /// <see cref="CanConvertTo"/> method.
+ /// </exception>
+ public object ConvertTo(object source, Type targetType)
+ {
+ PatternString patternString = source as PatternString;
+ if (patternString != null && CanConvertTo(targetType))
+ {
+ return patternString.Format();
+ }
+ throw ConversionNotSupportedException.Create(targetType, source);
+ }
- #endregion
+ #endregion
- #region Implementation of IConvertFrom
+ #region Implementation of IConvertFrom
- /// <summary>
- /// Can the source type be converted to the type supported by this object
- /// </summary>
- /// <param name="sourceType">the type to convert</param>
- /// <returns>true if the conversion is possible</returns>
- /// <remarks>
- /// <para>
- /// Returns <c>true</c> if the <paramref name="sourceType"/> is
- /// the <see cref="String"/> type.
- /// </para>
- /// </remarks>
- public bool CanConvertFrom(System.Type sourceType)
- {
- return (sourceType == typeof(string));
- }
+ /// <summary>
+ /// Can the source type be converted to the type supported by this object
+ /// </summary>
+ /// <param name="sourceType">the type to convert</param>
+ /// <returns>true if the conversion is possible</returns>
+ /// <remarks>
+ /// <para>
+ /// Returns <c>true</c> if the <paramref name="sourceType"/> is
+ /// the <see cref="String"/> type.
+ /// </para>
+ /// </remarks>
+ public bool CanConvertFrom(System.Type sourceType)
+ {
+ return (sourceType == typeof(string));
+ }
- /// <summary>
- /// Overrides the ConvertFrom method of IConvertFrom.
- /// </summary>
- /// <param name="source">the object to convert to a PatternString</param>
- /// <returns>the PatternString</returns>
- /// <remarks>
- /// <para>
- /// Creates and returns a new <see cref="PatternString"/> using
- /// the <paramref name="source"/> <see cref="String"/> as the
- /// <see cref="PatternString.ConversionPattern"/>.
- /// </para>
- /// </remarks>
- /// <exception cref="ConversionNotSupportedException">
- /// The <paramref name="source"/> object cannot be converted to the
- /// target type. To check for this condition use the <see cref="CanConvertFrom"/>
- /// method.
- /// </exception>
- public object ConvertFrom(object source)
- {
- string str = source as string;
- if (str != null)
- {
- return new PatternString(str);
- }
- throw ConversionNotSupportedException.Create(typeof(PatternString), source);
- }
+ /// <summary>
+ /// Overrides the ConvertFrom method of IConvertFrom.
+ /// </summary>
+ /// <param name="source">the object to convert to a PatternString</param>
+ /// <returns>the PatternString</returns>
+ /// <remarks>
+ /// <para>
+ /// Creates and returns a new <see cref="PatternString"/> using
+ /// the <paramref name="source"/> <see cref="String"/> as the
+ /// <see cref="PatternString.ConversionPattern"/>.
+ /// </para>
+ /// </remarks>
+ /// <exception cref="ConversionNotSupportedException">
+ /// The <paramref name="source"/> object cannot be converted to the
+ /// target type. To check for this condition use the <see cref="CanConvertFrom"/>
+ /// method.
+ /// </exception>
+ public object ConvertFrom(object source)
+ {
+ string str = source as string;
+ if (str != null)
+ {
+ return new PatternString(str);
+ }
+ throw ConversionNotSupportedException.Create(typeof(PatternString), source);
+ }
- #endregion
- }
+ #endregion
+ }
}
diff --git a/src/log4net/Util/TypeConverters/TypeConverter.cs b/src/log4net/Util/TypeConverters/TypeConverter.cs
index a4c7c5a..606abf0 100644
--- a/src/log4net/Util/TypeConverters/TypeConverter.cs
+++ b/src/log4net/Util/TypeConverters/TypeConverter.cs
@@ -24,70 +24,70 @@
namespace log4net.Util.TypeConverters
{
- /// <summary>
- /// Supports conversion from string to <see cref="Type"/> type.
- /// </summary>
- /// <remarks>
- /// <para>
- /// Supports conversion from string to <see cref="Type"/> type.
- /// </para>
- /// </remarks>
- /// <seealso cref="ConverterRegistry"/>
- /// <seealso cref="IConvertFrom"/>
- /// <seealso cref="IConvertTo"/>
- /// <author>Nicko Cadell</author>
- internal class TypeConverter : IConvertFrom
- {
- #region Implementation of IConvertFrom
+ /// <summary>
+ /// Supports conversion from string to <see cref="Type"/> type.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Supports conversion from string to <see cref="Type"/> type.
+ /// </para>
+ /// </remarks>
+ /// <seealso cref="ConverterRegistry"/>
+ /// <seealso cref="IConvertFrom"/>
+ /// <seealso cref="IConvertTo"/>
+ /// <author>Nicko Cadell</author>
+ internal class TypeConverter : IConvertFrom
+ {
+ #region Implementation of IConvertFrom
- /// <summary>
- /// Can the source type be converted to the type supported by this object
- /// </summary>
- /// <param name="sourceType">the type to convert</param>
- /// <returns>true if the conversion is possible</returns>
- /// <remarks>
- /// <para>
- /// Returns <c>true</c> if the <paramref name="sourceType"/> is
- /// the <see cref="String"/> type.
- /// </para>
- /// </remarks>
- public bool CanConvertFrom(Type sourceType)
- {
- return (sourceType == typeof(string));
- }
+ /// <summary>
+ /// Can the source type be converted to the type supported by this object
+ /// </summary>
+ /// <param name="sourceType">the type to convert</param>
+ /// <returns>true if the conversion is possible</returns>
+ /// <remarks>
+ /// <para>
+ /// Returns <c>true</c> if the <paramref name="sourceType"/> is
+ /// the <see cref="String"/> type.
+ /// </para>
+ /// </remarks>
+ public bool CanConvertFrom(Type sourceType)
+ {
+ return (sourceType == typeof(string));
+ }
- /// <summary>
- /// Overrides the ConvertFrom method of IConvertFrom.
- /// </summary>
- /// <param name="source">the object to convert to a Type</param>
- /// <returns>the Type</returns>
- /// <remarks>
- /// <para>
- /// Uses the <see cref="M:Type.GetType(string,bool)"/> method to convert the
- /// <see cref="String"/> argument to a <see cref="Type"/>.
- /// Additional effort is made to locate partially specified types
- /// by searching the loaded assemblies.
- /// </para>
- /// </remarks>
- /// <exception cref="ConversionNotSupportedException">
- /// The <paramref name="source"/> object cannot be converted to the
- /// target type. To check for this condition use the <see cref="CanConvertFrom"/>
- /// method.
- /// </exception>
- public object ConvertFrom(object source)
- {
- string str = source as string;
- if (str != null)
- {
+ /// <summary>
+ /// Overrides the ConvertFrom method of IConvertFrom.
+ /// </summary>
+ /// <param name="source">the object to convert to a Type</param>
+ /// <returns>the Type</returns>
+ /// <remarks>
+ /// <para>
+ /// Uses the <see cref="M:Type.GetType(string,bool)"/> method to convert the
+ /// <see cref="String"/> argument to a <see cref="Type"/>.
+ /// Additional effort is made to locate partially specified types
+ /// by searching the loaded assemblies.
+ /// </para>
+ /// </remarks>
+ /// <exception cref="ConversionNotSupportedException">
+ /// The <paramref name="source"/> object cannot be converted to the
+ /// target type. To check for this condition use the <see cref="CanConvertFrom"/>
+ /// method.
+ /// </exception>
+ public object ConvertFrom(object source)
+ {
+ string str = source as string;
+ if (str != null)
+ {
#if NETSTANDARD1_3 // TODO can we use ComponentModel here?
- return SystemInfo.GetTypeFromString(GetType().GetTypeInfo().Assembly, str, true, true);
+ return SystemInfo.GetTypeFromString(GetType().GetTypeInfo().Assembly, str, true, true);
#else
- return SystemInfo.GetTypeFromString(str, true, true);
+ return SystemInfo.GetTypeFromString(str, true, true);
#endif
- }
- throw ConversionNotSupportedException.Create(typeof(Type), source);
- }
+ }
+ throw ConversionNotSupportedException.Create(typeof(Type), source);
+ }
- #endregion
- }
+ #endregion
+ }
}
diff --git a/src/log4net/Util/TypeConverters/TypeConverterAttribute.cs b/src/log4net/Util/TypeConverters/TypeConverterAttribute.cs
index 196c5a8..d7f40fa 100644
--- a/src/log4net/Util/TypeConverters/TypeConverterAttribute.cs
+++ b/src/log4net/Util/TypeConverters/TypeConverterAttribute.cs
@@ -21,96 +21,96 @@
namespace log4net.Util.TypeConverters
{
- /// <summary>
- /// Attribute used to associate a type converter
- /// </summary>
- /// <remarks>
- /// <para>
- /// Class and Interface level attribute that specifies a type converter
- /// to use with the associated type.
- /// </para>
- /// <para>
- /// To associate a type converter with a target type apply a
- /// <c>TypeConverterAttribute</c> to the target type. Specify the
- /// type of the type converter on the attribute.
- /// </para>
- /// </remarks>
- /// <author>Nicko Cadell</author>
- /// <author>Gert Driesen</author>
- [AttributeUsage(AttributeTargets.Class|AttributeTargets.Interface|AttributeTargets.Enum)]
- public sealed class TypeConverterAttribute : Attribute
- {
- #region Member Variables
+ /// <summary>
+ /// Attribute used to associate a type converter
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Class and Interface level attribute that specifies a type converter
+ /// to use with the associated type.
+ /// </para>
+ /// <para>
+ /// To associate a type converter with a target type apply a
+ /// <c>TypeConverterAttribute</c> to the target type. Specify the
+ /// type of the type converter on the attribute.
+ /// </para>
+ /// </remarks>
+ /// <author>Nicko Cadell</author>
+ /// <author>Gert Driesen</author>
+ [AttributeUsage(AttributeTargets.Class|AttributeTargets.Interface|AttributeTargets.Enum)]
+ public sealed class TypeConverterAttribute : Attribute
+ {
+ #region Member Variables
- /// <summary>
- /// The string type name of the type converter
- /// </summary>
- private string m_typeName = null;
+ /// <summary>
+ /// The string type name of the type converter
+ /// </summary>
+ private string m_typeName = null;
- #endregion
+ #endregion
- #region Constructors
+ #region Constructors
- /// <summary>
- /// Default constructor
- /// </summary>
- /// <remarks>
- /// <para>
- /// Default constructor
- /// </para>
- /// </remarks>
- public TypeConverterAttribute()
- {
- }
+ /// <summary>
+ /// Default constructor
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Default constructor
+ /// </para>
+ /// </remarks>
+ public TypeConverterAttribute()
+ {
+ }
- /// <summary>
- /// Create a new type converter attribute for the specified type name
- /// </summary>
- /// <param name="typeName">The string type name of the type converter</param>
- /// <remarks>
- /// <para>
- /// The type specified must implement the <see cref="IConvertFrom"/>
- /// or the <see cref="IConvertTo"/> interfaces.
- /// </para>
- /// </remarks>
- public TypeConverterAttribute(string typeName)
- {
- m_typeName = typeName;
- }
+ /// <summary>
+ /// Create a new type converter attribute for the specified type name
+ /// </summary>
+ /// <param name="typeName">The string type name of the type converter</param>
+ /// <remarks>
+ /// <para>
+ /// The type specified must implement the <see cref="IConvertFrom"/>
+ /// or the <see cref="IConvertTo"/> interfaces.
+ /// </para>
+ /// </remarks>
+ public TypeConverterAttribute(string typeName)
+ {
+ m_typeName = typeName;
+ }
- /// <summary>
- /// Create a new type converter attribute for the specified type
- /// </summary>
- /// <param name="converterType">The type of the type converter</param>
- /// <remarks>
- /// <para>
- /// The type specified must implement the <see cref="IConvertFrom"/>
- /// or the <see cref="IConvertTo"/> interfaces.
- /// </para>
- /// </remarks>
- public TypeConverterAttribute(Type converterType)
- {
- m_typeName = log4net.Util.SystemInfo.AssemblyQualifiedName(converterType);
- }
+ /// <summary>
+ /// Create a new type converter attribute for the specified type
+ /// </summary>
+ /// <param name="converterType">The type of the type converter</param>
+ /// <remarks>
+ /// <para>
+ /// The type specified must implement the <see cref="IConvertFrom"/>
+ /// or the <see cref="IConvertTo"/> interfaces.
+ /// </para>
+ /// </remarks>
+ public TypeConverterAttribute(Type converterType)
+ {
+ m_typeName = log4net.Util.SystemInfo.AssemblyQualifiedName(converterType);
+ }
- #endregion
+ #endregion
- /// <summary>
- /// The string type name of the type converter
- /// </summary>
- /// <value>
- /// The string type name of the type converter
- /// </value>
- /// <remarks>
- /// <para>
- /// The type specified must implement the <see cref="IConvertFrom"/>
- /// or the <see cref="IConvertTo"/> interfaces.
- /// </para>
- /// </remarks>
- public string ConverterTypeName
- {
- get { return m_typeName; }
- set { m_typeName = value ; }
- }
- }
+ /// <summary>
+ /// The string type name of the type converter
+ /// </summary>
+ /// <value>
+ /// The string type name of the type converter
+ /// </value>
+ /// <remarks>
+ /// <para>
+ /// The type specified must implement the <see cref="IConvertFrom"/>
+ /// or the <see cref="IConvertTo"/> interfaces.
+ /// </para>
+ /// </remarks>
+ public string ConverterTypeName
+ {
+ get { return m_typeName; }
+ set { m_typeName = value ; }
+ }
+ }
}
diff --git a/src/log4net/Util/WindowsSecurityContext.cs b/src/log4net/Util/WindowsSecurityContext.cs
index 6fac8cc..d58f47f 100644
--- a/src/log4net/Util/WindowsSecurityContext.cs
+++ b/src/log4net/Util/WindowsSecurityContext.cs
@@ -36,349 +36,349 @@
namespace log4net.Util
{
- /// <summary>
- /// Impersonate a Windows Account
- /// </summary>
- /// <remarks>
- /// <para>
- /// This <see cref="SecurityContext"/> impersonates a Windows account.
- /// </para>
- /// <para>
- /// How the impersonation is done depends on the value of <see cref="Impersonate"/>.
- /// This allows the context to either impersonate a set of user credentials specified
- /// using username, domain name and password or to revert to the process credentials.
- /// </para>
- /// </remarks>
- public class WindowsSecurityContext : SecurityContext, IOptionHandler
- {
- /// <summary>
- /// The impersonation modes for the <see cref="WindowsSecurityContext"/>
- /// </summary>
- /// <remarks>
- /// <para>
- /// See the <see cref="WindowsSecurityContext.Credentials"/> property for
- /// details.
- /// </para>
- /// </remarks>
- public enum ImpersonationMode
- {
- /// <summary>
- /// Impersonate a user using the credentials supplied
- /// </summary>
- User,
+ /// <summary>
+ /// Impersonate a Windows Account
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// This <see cref="SecurityContext"/> impersonates a Windows account.
+ /// </para>
+ /// <para>
+ /// How the impersonation is done depends on the value of <see cref="Impersonate"/>.
+ /// This allows the context to either impersonate a set of user credentials specified
+ /// using username, domain name and password or to revert to the process credentials.
+ /// </para>
+ /// </remarks>
+ public class WindowsSecurityContext : SecurityContext, IOptionHandler
+ {
+ /// <summary>
+ /// The impersonation modes for the <see cref="WindowsSecurityContext"/>
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// See the <see cref="WindowsSecurityContext.Credentials"/> property for
+ /// details.
+ /// </para>
+ /// </remarks>
+ public enum ImpersonationMode
+ {
+ /// <summary>
+ /// Impersonate a user using the credentials supplied
+ /// </summary>
+ User,
- /// <summary>
- /// Revert this the thread to the credentials of the process
- /// </summary>
- Process
- }
+ /// <summary>
+ /// Revert this the thread to the credentials of the process
+ /// </summary>
+ Process
+ }
- #region Member Variables
+ #region Member Variables
- private ImpersonationMode m_impersonationMode = ImpersonationMode.User;
- private string m_userName;
- private string m_domainName = Environment.MachineName;
- private string m_password;
- private WindowsIdentity m_identity;
+ private ImpersonationMode m_impersonationMode = ImpersonationMode.User;
+ private string m_userName;
+ private string m_domainName = Environment.MachineName;
+ private string m_password;
+ private WindowsIdentity m_identity;
- #endregion
+ #endregion
- #region Constructor
+ #region Constructor
- /// <summary>
- /// Default constructor
- /// </summary>
- /// <remarks>
- /// <para>
- /// Default constructor
- /// </para>
- /// </remarks>
- public WindowsSecurityContext()
- {
- }
+ /// <summary>
+ /// Default constructor
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Default constructor
+ /// </para>
+ /// </remarks>
+ public WindowsSecurityContext()
+ {
+ }
- #endregion
+ #endregion
- #region Public Properties
+ #region Public Properties
- /// <summary>
- /// Gets or sets the impersonation mode for this security context
- /// </summary>
- /// <value>
- /// The impersonation mode for this security context
- /// </value>
- /// <remarks>
- /// <para>
- /// Impersonate either a user with user credentials or
- /// revert this thread to the credentials of the process.
- /// The value is one of the <see cref="ImpersonationMode"/>
- /// enum.
- /// </para>
- /// <para>
- /// The default value is <see cref="ImpersonationMode.User"/>
- /// </para>
- /// <para>
- /// When the mode is set to <see cref="ImpersonationMode.User"/>
- /// the user's credentials are established using the
- /// <see cref="UserName"/>, <see cref="DomainName"/> and <see cref="Password"/>
- /// values.
- /// </para>
- /// <para>
- /// When the mode is set to <see cref="ImpersonationMode.Process"/>
- /// no other properties need to be set. If the calling thread is
- /// impersonating then it will be reverted back to the process credentials.
- /// </para>
- /// </remarks>
- public ImpersonationMode Credentials
- {
- get { return m_impersonationMode; }
- set { m_impersonationMode = value; }
- }
+ /// <summary>
+ /// Gets or sets the impersonation mode for this security context
+ /// </summary>
+ /// <value>
+ /// The impersonation mode for this security context
+ /// </value>
+ /// <remarks>
+ /// <para>
+ /// Impersonate either a user with user credentials or
+ /// revert this thread to the credentials of the process.
+ /// The value is one of the <see cref="ImpersonationMode"/>
+ /// enum.
+ /// </para>
+ /// <para>
+ /// The default value is <see cref="ImpersonationMode.User"/>
+ /// </para>
+ /// <para>
+ /// When the mode is set to <see cref="ImpersonationMode.User"/>
+ /// the user's credentials are established using the
+ /// <see cref="UserName"/>, <see cref="DomainName"/> and <see cref="Password"/>
+ /// values.
+ /// </para>
+ /// <para>
+ /// When the mode is set to <see cref="ImpersonationMode.Process"/>
+ /// no other properties need to be set. If the calling thread is
+ /// impersonating then it will be reverted back to the process credentials.
+ /// </para>
+ /// </remarks>
+ public ImpersonationMode Credentials
+ {
+ get { return m_impersonationMode; }
+ set { m_impersonationMode = value; }
+ }
- /// <summary>
- /// Gets or sets the Windows username for this security context
- /// </summary>
- /// <value>
- /// The Windows username for this security context
- /// </value>
- /// <remarks>
- /// <para>
- /// This property must be set if <see cref="Credentials"/>
- /// is set to <see cref="ImpersonationMode.User"/> (the default setting).
- /// </para>
- /// </remarks>
- public string UserName
- {
- get { return m_userName; }
- set { m_userName = value; }
- }
+ /// <summary>
+ /// Gets or sets the Windows username for this security context
+ /// </summary>
+ /// <value>
+ /// The Windows username for this security context
+ /// </value>
+ /// <remarks>
+ /// <para>
+ /// This property must be set if <see cref="Credentials"/>
+ /// is set to <see cref="ImpersonationMode.User"/> (the default setting).
+ /// </para>
+ /// </remarks>
+ public string UserName
+ {
+ get { return m_userName; }
+ set { m_userName = value; }
+ }
- /// <summary>
- /// Gets or sets the Windows domain name for this security context
- /// </summary>
- /// <value>
- /// The Windows domain name for this security context
- /// </value>
- /// <remarks>
- /// <para>
- /// The default value for <see cref="DomainName"/> is the local machine name
- /// taken from the <see cref="Environment.MachineName"/> property.
- /// </para>
- /// <para>
- /// This property must be set if <see cref="Credentials"/>
- /// is set to <see cref="ImpersonationMode.User"/> (the default setting).
- /// </para>
- /// </remarks>
- public string DomainName
- {
- get { return m_domainName; }
- set { m_domainName = value; }
- }
+ /// <summary>
+ /// Gets or sets the Windows domain name for this security context
+ /// </summary>
+ /// <value>
+ /// The Windows domain name for this security context
+ /// </value>
+ /// <remarks>
+ /// <para>
+ /// The default value for <see cref="DomainName"/> is the local machine name
+ /// taken from the <see cref="Environment.MachineName"/> property.
+ /// </para>
+ /// <para>
+ /// This property must be set if <see cref="Credentials"/>
+ /// is set to <see cref="ImpersonationMode.User"/> (the default setting).
+ /// </para>
+ /// </remarks>
+ public string DomainName
+ {
+ get { return m_domainName; }
+ set { m_domainName = value; }
+ }
- /// <summary>
- /// Sets the password for the Windows account specified by the <see cref="UserName"/> and <see cref="DomainName"/> properties.
- /// </summary>
- /// <value>
- /// The password for the Windows account specified by the <see cref="UserName"/> and <see cref="DomainName"/> properties.
- /// </value>
- /// <remarks>
- /// <para>
- /// This property must be set if <see cref="Credentials"/>
- /// is set to <see cref="ImpersonationMode.User"/> (the default setting).
- /// </para>
- /// </remarks>
- public string Password
- {
- set { m_password = value; }
- }
+ /// <summary>
+ /// Sets the password for the Windows account specified by the <see cref="UserName"/> and <see cref="DomainName"/> properties.
+ /// </summary>
+ /// <value>
+ /// The password for the Windows account specified by the <see cref="UserName"/> and <see cref="DomainName"/> properties.
+ /// </value>
+ /// <remarks>
+ /// <para>
+ /// This property must be set if <see cref="Credentials"/>
+ /// is set to <see cref="ImpersonationMode.User"/> (the default setting).
+ /// </para>
+ /// </remarks>
+ public string Password
+ {
+ set { m_password = value; }
+ }
- #endregion
+ #endregion
- #region IOptionHandler Members
+ #region IOptionHandler Members
- /// <summary>
- /// Initialize the SecurityContext 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>
- /// <para>
- /// The security context will try to Logon the specified user account and
- /// capture a primary token for impersonation.
- /// </para>
- /// </remarks>
- /// <exception cref="ArgumentNullException">The required <see cref="UserName" />,
- /// <see cref="DomainName" /> or <see cref="Password" /> properties were not specified.</exception>
- public void ActivateOptions()
- {
- if (m_impersonationMode == ImpersonationMode.User)
- {
- if (m_userName == null) throw new ArgumentNullException("m_userName");
- if (m_domainName == null) throw new ArgumentNullException("m_domainName");
- if (m_password == null) throw new ArgumentNullException("m_password");
+ /// <summary>
+ /// Initialize the SecurityContext 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>
+ /// <para>
+ /// The security context will try to Logon the specified user account and
+ /// capture a primary token for impersonation.
+ /// </para>
+ /// </remarks>
+ /// <exception cref="ArgumentNullException">The required <see cref="UserName" />,
+ /// <see cref="DomainName" /> or <see cref="Password" /> properties were not specified.</exception>
+ public void ActivateOptions()
+ {
+ if (m_impersonationMode == ImpersonationMode.User)
+ {
+ if (m_userName == null) throw new ArgumentNullException("m_userName");
+ if (m_domainName == null) throw new ArgumentNullException("m_domainName");
+ if (m_password == null) throw new ArgumentNullException("m_password");
- m_identity = LogonUser(m_userName, m_domainName, m_password);
- }
- }
+ m_identity = LogonUser(m_userName, m_domainName, m_password);
+ }
+ }
- #endregion
+ #endregion
- /// <summary>
- /// Impersonate the Windows account specified by the <see cref="UserName"/> and <see cref="DomainName"/> properties.
- /// </summary>
- /// <param name="state">caller provided state</param>
- /// <returns>
- /// An <see cref="IDisposable"/> instance that will revoke the impersonation of this SecurityContext
- /// </returns>
- /// <remarks>
- /// <para>
- /// Depending on the <see cref="Credentials"/> property either
- /// impersonate a user using credentials supplied or revert
- /// to the process credentials.
- /// </para>
- /// </remarks>
- public override IDisposable Impersonate(object state)
- {
- if (m_impersonationMode == ImpersonationMode.User)
- {
- if (m_identity != null)
- {
- return new DisposableImpersonationContext(m_identity.Impersonate());
- }
- }
- else if (m_impersonationMode == ImpersonationMode.Process)
- {
- // Impersonate(0) will revert to the process credentials
- return new DisposableImpersonationContext(WindowsIdentity.Impersonate(IntPtr.Zero));
- }
- return null;
- }
+ /// <summary>
+ /// Impersonate the Windows account specified by the <see cref="UserName"/> and <see cref="DomainName"/> properties.
+ /// </summary>
+ /// <param name="state">caller provided state</param>
+ /// <returns>
+ /// An <see cref="IDisposable"/> instance that will revoke the impersonation of this SecurityContext
+ /// </returns>
+ /// <remarks>
+ /// <para>
+ /// Depending on the <see cref="Credentials"/> property either
+ /// impersonate a user using credentials supplied or revert
+ /// to the process credentials.
+ /// </para>
+ /// </remarks>
+ public override IDisposable Impersonate(object state)
+ {
+ if (m_impersonationMode == ImpersonationMode.User)
+ {
+ if (m_identity != null)
+ {
+ return new DisposableImpersonationContext(m_identity.Impersonate());
+ }
+ }
+ else if (m_impersonationMode == ImpersonationMode.Process)
+ {
+ // Impersonate(0) will revert to the process credentials
+ return new DisposableImpersonationContext(WindowsIdentity.Impersonate(IntPtr.Zero));
+ }
+ return null;
+ }
- /// <summary>
- /// Create a <see cref="WindowsIdentity"/> given the userName, domainName and password.
- /// </summary>
- /// <param name="userName">the user name</param>
- /// <param name="domainName">the domain name</param>
- /// <param name="password">the password</param>
- /// <returns>the <see cref="WindowsIdentity"/> for the account specified</returns>
- /// <remarks>
- /// <para>
- /// Uses the Windows API call LogonUser to get a principal token for the account. This
- /// token is used to initialize the WindowsIdentity.
- /// </para>
- /// </remarks>
+ /// <summary>
+ /// Create a <see cref="WindowsIdentity"/> given the userName, domainName and password.
+ /// </summary>
+ /// <param name="userName">the user name</param>
+ /// <param name="domainName">the domain name</param>
+ /// <param name="password">the password</param>
+ /// <returns>the <see cref="WindowsIdentity"/> for the account specified</returns>
+ /// <remarks>
+ /// <para>
+ /// Uses the Windows API call LogonUser to get a principal token for the account. This
+ /// token is used to initialize the WindowsIdentity.
+ /// </para>
+ /// </remarks>
#if NET_4_0 || MONO_4_0
[System.Security.SecuritySafeCritical]
#endif
[System.Security.Permissions.SecurityPermission(System.Security.Permissions.SecurityAction.Demand, UnmanagedCode = true)]
private static WindowsIdentity LogonUser(string userName, string domainName, string password)
- {
- const int LOGON32_PROVIDER_DEFAULT = 0;
- //This parameter causes LogonUser to create a primary token.
- const int LOGON32_LOGON_INTERACTIVE = 2;
+ {
+ const int LOGON32_PROVIDER_DEFAULT = 0;
+ //This parameter causes LogonUser to create a primary token.
+ const int LOGON32_LOGON_INTERACTIVE = 2;
- // Call LogonUser to obtain a handle to an access token.
- IntPtr tokenHandle = IntPtr.Zero;
- if(!LogonUser(userName, domainName, password, LOGON32_LOGON_INTERACTIVE, LOGON32_PROVIDER_DEFAULT, ref tokenHandle))
- {
- NativeError error = NativeError.GetLastError();
- throw new Exception("Failed to LogonUser ["+userName+"] in Domain ["+domainName+"]. Error: "+ error.ToString());
- }
+ // Call LogonUser to obtain a handle to an access token.
+ IntPtr tokenHandle = IntPtr.Zero;
+ if(!LogonUser(userName, domainName, password, LOGON32_LOGON_INTERACTIVE, LOGON32_PROVIDER_DEFAULT, ref tokenHandle))
+ {
+ NativeError error = NativeError.GetLastError();
+ throw new Exception("Failed to LogonUser ["+userName+"] in Domain ["+domainName+"]. Error: "+ error.ToString());
+ }
- const int SecurityImpersonation = 2;
- IntPtr dupeTokenHandle = IntPtr.Zero;
- if(!DuplicateToken(tokenHandle, SecurityImpersonation, ref dupeTokenHandle))
- {
- NativeError error = NativeError.GetLastError();
- if (tokenHandle != IntPtr.Zero)
- {
- CloseHandle(tokenHandle);
- }
- throw new Exception("Failed to DuplicateToken after LogonUser. Error: " + error.ToString());
- }
+ const int SecurityImpersonation = 2;
+ IntPtr dupeTokenHandle = IntPtr.Zero;
+ if(!DuplicateToken(tokenHandle, SecurityImpersonation, ref dupeTokenHandle))
+ {
+ NativeError error = NativeError.GetLastError();
+ if (tokenHandle != IntPtr.Zero)
+ {
+ CloseHandle(tokenHandle);
+ }
+ throw new Exception("Failed to DuplicateToken after LogonUser. Error: " + error.ToString());
+ }
- WindowsIdentity identity = new WindowsIdentity(dupeTokenHandle);
+ WindowsIdentity identity = new WindowsIdentity(dupeTokenHandle);
- // Free the tokens.
- if (dupeTokenHandle != IntPtr.Zero)
- {
- CloseHandle(dupeTokenHandle);
- }
- if (tokenHandle != IntPtr.Zero)
- {
- CloseHandle(tokenHandle);
- }
+ // Free the tokens.
+ if (dupeTokenHandle != IntPtr.Zero)
+ {
+ CloseHandle(dupeTokenHandle);
+ }
+ if (tokenHandle != IntPtr.Zero)
+ {
+ CloseHandle(tokenHandle);
+ }
- return identity;
- }
+ return identity;
+ }
- #region Native Method Stubs
+ #region Native Method Stubs
- [DllImport("advapi32.dll", SetLastError=true)]
- private static extern bool LogonUser(String lpszUsername, String lpszDomain, String lpszPassword, int dwLogonType, int dwLogonProvider, ref IntPtr phToken);
+ [DllImport("advapi32.dll", SetLastError=true)]
+ private static extern bool LogonUser(String lpszUsername, String lpszDomain, String lpszPassword, int dwLogonType, int dwLogonProvider, ref IntPtr phToken);
- [DllImport("kernel32.dll", CharSet=CharSet.Auto)]
- private static extern bool CloseHandle(IntPtr handle);
+ [DllImport("kernel32.dll", CharSet=CharSet.Auto)]
+ private static extern bool CloseHandle(IntPtr handle);
- [DllImport("advapi32.dll", CharSet=CharSet.Auto, SetLastError=true)]
- private static extern bool DuplicateToken(IntPtr ExistingTokenHandle, int SECURITY_IMPERSONATION_LEVEL, ref IntPtr DuplicateTokenHandle);
+ [DllImport("advapi32.dll", CharSet=CharSet.Auto, SetLastError=true)]
+ private static extern bool DuplicateToken(IntPtr ExistingTokenHandle, int SECURITY_IMPERSONATION_LEVEL, ref IntPtr DuplicateTokenHandle);
- #endregion
+ #endregion
- #region DisposableImpersonationContext class
+ #region DisposableImpersonationContext class
- /// <summary>
- /// Adds <see cref="IDisposable"/> to <see cref="WindowsImpersonationContext"/>
- /// </summary>
- /// <remarks>
- /// <para>
- /// Helper class to expose the <see cref="WindowsImpersonationContext"/>
- /// through the <see cref="IDisposable"/> interface.
- /// </para>
- /// </remarks>
- private sealed class DisposableImpersonationContext : IDisposable
- {
- private readonly WindowsImpersonationContext m_impersonationContext;
+ /// <summary>
+ /// Adds <see cref="IDisposable"/> to <see cref="WindowsImpersonationContext"/>
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Helper class to expose the <see cref="WindowsImpersonationContext"/>
+ /// through the <see cref="IDisposable"/> interface.
+ /// </para>
+ /// </remarks>
+ private sealed class DisposableImpersonationContext : IDisposable
+ {
+ private readonly WindowsImpersonationContext m_impersonationContext;
- /// <summary>
- /// Constructor
- /// </summary>
- /// <param name="impersonationContext">the impersonation context being wrapped</param>
- /// <remarks>
- /// <para>
- /// Constructor
- /// </para>
- /// </remarks>
- public DisposableImpersonationContext(WindowsImpersonationContext impersonationContext)
- {
- m_impersonationContext = impersonationContext;
- }
+ /// <summary>
+ /// Constructor
+ /// </summary>
+ /// <param name="impersonationContext">the impersonation context being wrapped</param>
+ /// <remarks>
+ /// <para>
+ /// Constructor
+ /// </para>
+ /// </remarks>
+ public DisposableImpersonationContext(WindowsImpersonationContext impersonationContext)
+ {
+ m_impersonationContext = impersonationContext;
+ }
- /// <summary>
- /// Revert the impersonation
- /// </summary>
- /// <remarks>
- /// <para>
- /// Revert the impersonation
- /// </para>
- /// </remarks>
- public void Dispose()
- {
- m_impersonationContext.Undo();
- }
- }
+ /// <summary>
+ /// Revert the impersonation
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Revert the impersonation
+ /// </para>
+ /// </remarks>
+ public void Dispose()
+ {
+ m_impersonationContext.Undo();
+ }
+ }
- #endregion
- }
+ #endregion
+ }
}
#endif // !CLI_1_0