Fix CA2000, CA2237, CA3075
diff --git a/src/log4net/Appender/AdoNetAppender.cs b/src/log4net/Appender/AdoNetAppender.cs
index a509cc1..72a5a76 100644
--- a/src/log4net/Appender/AdoNetAppender.cs
+++ b/src/log4net/Appender/AdoNetAppender.cs
@@ -617,7 +617,7 @@
}
else
{
- StringWriter writer = new StringWriter(System.Globalization.CultureInfo.InvariantCulture);
+ using StringWriter writer = new StringWriter(System.Globalization.CultureInfo.InvariantCulture);
Layout.Format(writer, logEvent);
return writer.ToString();
}
diff --git a/src/log4net/Appender/FileAppender.cs b/src/log4net/Appender/FileAppender.cs
index e283f49..f0c2bc1 100644
--- a/src/log4net/Appender/FileAppender.cs
+++ b/src/log4net/Appender/FileAppender.cs
@@ -19,6 +19,9 @@
using System;
using System.IO;
+#if !NETCF && !NETSTANDARD1_3
+using System.Runtime.Serialization;
+#endif
using System.Text;
using System.Threading;
using log4net.Util;
@@ -138,12 +141,29 @@
/// </summary>
private sealed class LockingStream : Stream, IDisposable
{
+#if !NETCR
+ [Serializable]
+#endif
public sealed class LockStateException : LogException
{
public LockStateException(string message)
: base(message)
{
}
+
+ public LockStateException()
+ {
+ }
+
+ public LockStateException(string message, Exception innerException) : base(message, innerException)
+ {
+ }
+
+#if !NETCR && !NETSTANDARD1_3
+ private LockStateException(SerializationInfo info, StreamingContext context) : base(info, context)
+ {
+ }
+#endif
}
private Stream m_realStream = null;
@@ -1409,7 +1429,10 @@
/// </remarks>
virtual protected void SetQWForFiles(Stream fileStream)
{
- SetQWForFiles(new StreamWriter(fileStream, m_encoding));
+#pragma warning disable CA2000 // Dispose objects before losing scope
+ StreamWriter writer = new StreamWriter(fileStream, m_encoding);
+#pragma warning restore CA2000 // Dispose objects before losing scope
+ SetQWForFiles(writer);
}
/// <summary>
diff --git a/src/log4net/Appender/SmtpAppender.cs b/src/log4net/Appender/SmtpAppender.cs
index d19ad90..bbe8bd5 100644
--- a/src/log4net/Appender/SmtpAppender.cs
+++ b/src/log4net/Appender/SmtpAppender.cs
@@ -92,20 +92,20 @@
/// 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>
+ /// <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>
+ /// <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
{
@@ -113,49 +113,49 @@
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.
@@ -324,29 +324,29 @@
}
#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>
@@ -387,7 +387,7 @@
// appender. This frees us from needing to synchronize again.
try
{
- StringWriter writer = new StringWriter(System.Globalization.CultureInfo.InvariantCulture);
+ using StringWriter writer = new StringWriter(System.Globalization.CultureInfo.InvariantCulture);
string t = Layout.Header;
if (t != null)
@@ -449,14 +449,18 @@
// The old API is deprecated.
// Create and configure the smtp client
+#if NET_4_0 || MONO_4_0 || NETSTANDARD2_0
+ using SmtpClient smtpClient = new SmtpClient();
+#else
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;
+ smtpClient.EnableSsl = m_enableSsl;
if (m_authentication == SmtpAuthentication.Basic)
{
@@ -469,38 +473,38 @@
smtpClient.Credentials = System.Net.CredentialCache.DefaultNetworkCredentials;
}
- using (MailMessage mailMessage = new MailMessage())
- {
- mailMessage.Body = messageBody;
+ 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'
+ 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.Subject = m_subject;
mailMessage.SubjectEncoding = m_subjectEncoding;
- mailMessage.Priority = m_mailPriority;
+ 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
@@ -509,14 +513,14 @@
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;
- }
+ 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;
@@ -585,8 +589,8 @@
#region Private Instance Fields
private string m_to;
- private string m_cc;
- private string m_bcc;
+ private string m_cc;
+ private string m_bcc;
private string m_from;
private string m_subject;
private string m_smtpHost;
@@ -604,8 +608,8 @@
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
@@ -646,19 +650,19 @@
#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/Config/XmlConfigurator.cs b/src/log4net/Config/XmlConfigurator.cs
index 02795fd..cd9ebfe 100644
--- a/src/log4net/Config/XmlConfigurator.cs
+++ b/src/log4net/Config/XmlConfigurator.cs
@@ -49,8 +49,8 @@
/// <summary>
/// Private constructor
/// </summary>
- private XmlConfigurator()
- {
+ private XmlConfigurator()
+ {
}
#endregion Protected Instance Constructors
@@ -58,26 +58,26 @@
#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
@@ -94,21 +94,21 @@
/// </remarks>
/// <param name="repository">The repository to configure.</param>
#endif
- static public ICollection Configure(ILoggerRepository repository)
- {
- ArrayList configurationMessages = new ArrayList();
+ static public 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;
+ }
- static private void InternalConfigure(ILoggerRepository repository)
+ static private void InternalConfigure(ILoggerRepository repository)
{
LogLog.Debug(declaringType, "configuring repository [" + repository.Name + "] using .config file section");
@@ -194,10 +194,10 @@
/// </para>
/// </remarks>
#endif
- static public ICollection Configure()
- {
- return Configure(LogManager.GetRepository(Assembly.GetCallingAssembly()));
- }
+ static public ICollection Configure()
+ {
+ return Configure(LogManager.GetRepository(Assembly.GetCallingAssembly()));
+ }
/// <summary>
/// Configures log4net using a <c>log4net</c> element
@@ -209,20 +209,20 @@
/// </para>
/// </remarks>
/// <param name="element">The element to parse.</param>
- static public ICollection Configure(XmlElement element)
+ static public ICollection Configure(XmlElement element)
{
- ArrayList configurationMessages = new ArrayList();
+ 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
@@ -314,14 +314,14 @@
#endif
static public ICollection Configure(FileInfo configFile)
{
- ArrayList configurationMessages = new ArrayList();
+ 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>
@@ -340,17 +340,17 @@
/// </remarks>
static public ICollection Configure(Uri configUri)
{
- ArrayList configurationMessages = new ArrayList();
+ 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>
@@ -369,99 +369,99 @@
/// </remarks>
static public ICollection Configure(Stream configStream)
{
- ArrayList configurationMessages = new ArrayList();
+ 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>
- static public 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>
+ static public 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
@@ -500,20 +500,20 @@
/// </code>
/// </remarks>
#endif
- static public ICollection Configure(ILoggerRepository repository, FileInfo configFile)
- {
- ArrayList configurationMessages = new ArrayList();
+ static public 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;
+ }
+
static private void InternalConfigure(ILoggerRepository repository, FileInfo configFile)
{
LogLog.Debug(declaringType, "configuring repository [" + repository.Name + "] using file [" + configFile + "]");
@@ -530,7 +530,7 @@
{
// Open the file for reading
FileStream fs = null;
-
+
// Try hard to open the file
for(int retry = 5; --retry >= 0; )
{
@@ -573,36 +573,36 @@
}
}
- /// <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>
- static public 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>
+ static public 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;
+ }
+
static private void InternalConfigure(ILoggerRepository repository, Uri configUri)
{
LogLog.Debug(declaringType, "configuring repository [" + repository.Name + "] using URI ["+configUri+"]");
@@ -667,36 +667,36 @@
}
}
- /// <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>
- static public 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>
+ static public 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;
+ }
+
static private void InternalConfigure(ILoggerRepository repository, Stream configStream)
{
LogLog.Debug(declaringType, "configuring repository [" + repository.Name + "] using stream");
@@ -708,7 +708,11 @@
else
{
// Load the config file into a document
+#if NETSTANDARD1_3
XmlDocument doc = new XmlDocument();
+#else
+ XmlDocument doc = new XmlDocument { XmlResolver = null };
+#endif
try
{
#if (NETCF)
@@ -717,8 +721,8 @@
#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.'
+ // .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;
#elif !NET_4_0 && !MONO_4_0 && !NETSTANDARD2_0
@@ -728,17 +732,17 @@
#endif
// Create a reader over the input stream
- XmlReader xmlReader = XmlReader.Create(configStream, settings);
+ using XmlReader xmlReader = XmlReader.Create(configStream, settings);
#else
// Create a validating reader around a text reader for the file stream
- XmlValidatingReader xmlReader = new XmlValidatingReader(new XmlTextReader(configStream));
+ 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;
#endif
-
+
// load the data into the document
doc.Load(xmlReader);
}
@@ -801,58 +805,58 @@
/// <seealso cref="M:Configure(FileInfo)"/>
static public ICollection ConfigureAndWatch(FileInfo configFile)
{
- ArrayList configurationMessages = new ArrayList();
+ 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)"/>
- static public 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)"/>
+ static public 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;
+ }
+
static private void InternalConfigureAndWatch(ILoggerRepository repository, FileInfo configFile)
{
LogLog.Debug(declaringType, "configuring repository [" + repository.Name + "] using file [" + configFile + "] watching for file updates");
@@ -868,23 +872,23 @@
try
{
- lock (m_repositoryName2ConfigAndWatchHandler)
- {
- // support multiple repositories each having their own watcher
- ConfigureAndWatchHandler handler =
+ lock (m_repositoryName2ConfigAndWatchHandler)
+ {
+ // support multiple repositories each having their own watcher
+ ConfigureAndWatchHandler handler =
(ConfigureAndWatchHandler)m_repositoryName2ConfigAndWatchHandler[configFile.FullName];
- if (handler != null)
- {
+ if (handler != null)
+ {
m_repositoryName2ConfigAndWatchHandler.Remove(configFile.FullName);
- handler.Dispose();
- }
+ handler.Dispose();
+ }
- // Create and start a watch handler that will reload the
- // configuration whenever the config file is modified.
- handler = new ConfigureAndWatchHandler(repository, configFile);
+ // 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)
{
@@ -938,15 +942,15 @@
/// </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.
+ /// 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>
@@ -956,9 +960,9 @@
/// </para>
/// </remarks>
#if NET_4_0 || MONO_4_0 || NETSTANDARD
- [System.Security.SecuritySafeCritical]
+ [System.Security.SecuritySafeCritical]
#endif
- public ConfigureAndWatchHandler(ILoggerRepository repository, FileInfo configFile)
+ public ConfigureAndWatchHandler(ILoggerRepository repository, FileInfo configFile)
{
m_repository = repository;
m_configFile = configFile;
@@ -982,7 +986,7 @@
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);
+ m_timer = new Timer(new TimerCallback(OnWatchedFileChange), null, Timeout.Infinite, Timeout.Infinite);
}
/// <summary>
@@ -1032,18 +1036,18 @@
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
@@ -1066,7 +1070,7 @@
/// to load the configuration from an <see cref="XmlElement"/>.
/// </para>
/// </remarks>
- static private void InternalConfigureFromXml(ILoggerRepository repository, XmlElement element)
+ static private void InternalConfigureFromXml(ILoggerRepository repository, XmlElement element)
{
if (element == null)
{
@@ -1090,36 +1094,40 @@
// 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();
+#else
+ XmlDocument newDoc = new XmlDocument { XmlResolver = null };
+#endif
XmlElement newElement = (XmlElement)newDoc.AppendChild(newDoc.ImportNode(element, true));
// Pass the configurator the config element
configurableRepository.Configure(newElement);
- }
+ }
}
}
#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 readonly static 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 readonly static 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 readonly static 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 readonly static Type declaringType = typeof(XmlConfigurator);
- #endregion Private Static Fields
+ #endregion Private Static Fields
}
}
diff --git a/src/log4net/Layout/Layout2RawLayoutAdapter.cs b/src/log4net/Layout/Layout2RawLayoutAdapter.cs
index 5b3707c..4945784 100644
--- a/src/log4net/Layout/Layout2RawLayoutAdapter.cs
+++ b/src/log4net/Layout/Layout2RawLayoutAdapter.cs
@@ -83,7 +83,7 @@
/// </remarks>
virtual public object Format(LoggingEvent loggingEvent)
{
- StringWriter writer = new StringWriter(System.Globalization.CultureInfo.InvariantCulture);
+ using StringWriter writer = new StringWriter(System.Globalization.CultureInfo.InvariantCulture);
m_layout.Format(writer, loggingEvent);
return writer.ToString();
}
diff --git a/src/log4net/Layout/LayoutSkeleton.cs b/src/log4net/Layout/LayoutSkeleton.cs
index b373ee1..afae60e 100644
--- a/src/log4net/Layout/LayoutSkeleton.cs
+++ b/src/log4net/Layout/LayoutSkeleton.cs
@@ -117,9 +117,9 @@
/// 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>
+ /// <para>
+ /// This method must be implemented by the subclass.
+ /// </para>
/// </remarks>
abstract public void ActivateOptions();
@@ -140,93 +140,93 @@
/// </remarks>
abstract public 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)
- {
- 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>
- virtual public 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>
+ virtual public 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>
- virtual public 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>
+ virtual public 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>
- virtual public 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>
+ virtual public 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>
- virtual public 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>
+ virtual public bool IgnoresException
+ {
+ get { return m_ignoresException; }
+ set { m_ignoresException = value; }
+ }
- #endregion
+ #endregion
}
}
diff --git a/src/log4net/ObjectRenderer/RendererMap.cs b/src/log4net/ObjectRenderer/RendererMap.cs
index 7f4db96..666dfda 100644
--- a/src/log4net/ObjectRenderer/RendererMap.cs
+++ b/src/log4net/ObjectRenderer/RendererMap.cs
@@ -45,7 +45,7 @@
/// <author>Gert Driesen</author>
public class RendererMap
{
- private readonly static Type declaringType = typeof(RendererMap);
+ private readonly static Type declaringType = typeof(RendererMap);
#region Member Variables
@@ -94,7 +94,7 @@
return strData;
}
- StringWriter stringWriter = new StringWriter(System.Globalization.CultureInfo.InvariantCulture);
+ using StringWriter stringWriter = new StringWriter(System.Globalization.CultureInfo.InvariantCulture);
FindAndRender(obj, stringWriter);
return stringWriter.ToString();
}
diff --git a/src/log4net/Util/PatternString.cs b/src/log4net/Util/PatternString.cs
index 4a840ed..72d9ba9 100644
--- a/src/log4net/Util/PatternString.cs
+++ b/src/log4net/Util/PatternString.cs
@@ -467,7 +467,7 @@
/// </remarks>
public string Format()
{
- StringWriter writer = new StringWriter(System.Globalization.CultureInfo.InvariantCulture);
+ using StringWriter writer = new StringWriter(System.Globalization.CultureInfo.InvariantCulture);
Format(writer);
return writer.ToString();
}