http://git-wip-us.apache.org/repos/asf/logging-log4net/blob/82c3e389/src/Appender/TelnetAppender.cs ---------------------------------------------------------------------- diff --git a/src/Appender/TelnetAppender.cs b/src/Appender/TelnetAppender.cs index 4c8a301..ded2a27 100644 --- a/src/Appender/TelnetAppender.cs +++ b/src/Appender/TelnetAppender.cs @@ -72,18 +72,18 @@ namespace log4net.Appender #endregion - #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 readonly static Type declaringType = typeof(TelnetAppender); - - #endregion 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 readonly static Type declaringType = typeof(TelnetAppender); + + #endregion Private Static Fields /// <summary> /// Gets or sets the TCP port number on which this <see cref="TelnetAppender"/> will listen for connections.
http://git-wip-us.apache.org/repos/asf/logging-log4net/blob/82c3e389/src/Appender/TextWriterAppender.cs ---------------------------------------------------------------------- diff --git a/src/Appender/TextWriterAppender.cs b/src/Appender/TextWriterAppender.cs index fe42089..8124102 100644 --- a/src/Appender/TextWriterAppender.cs +++ b/src/Appender/TextWriterAppender.cs @@ -42,7 +42,7 @@ namespace log4net.Appender /// <author>Nicko Cadell</author> /// <author>Gert Driesen</author> /// <author>Douglas de la Torre</author> - public class TextWriterAppender : AppenderSkeleton + public class TextWriterAppender : AppenderSkeleton { #region Public Instance Constructors @@ -437,13 +437,13 @@ namespace log4net.Appender { get { return m_qtw; } set { m_qtw = value; } - } + } - #endregion Protected Instance Methods + #endregion Protected Instance Methods - #region Private Instance Fields + #region Private Instance Fields - /// <summary> + /// <summary> /// This is the <see cref="log4net.Util.QuietTextWriter"/> where logging events /// will be written to. /// </summary> @@ -469,36 +469,36 @@ namespace log4net.Appender #endregion Private Instance 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 readonly static Type declaringType = typeof(TextWriterAppender); - - #endregion Private Static Fields - - /// <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) - { - // Nothing to do if ImmediateFlush is true - if (m_immediateFlush) return true; - - // lock(this) will block any Appends while the buffer is flushed. - lock (this) - { - m_qtw.Flush(); - } - - return true; - } + #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 readonly static Type declaringType = typeof(TextWriterAppender); + + #endregion Private Static Fields + + /// <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) + { + // Nothing to do if ImmediateFlush is true + if (m_immediateFlush) return true; + + // lock(this) will block any Appends while the buffer is flushed. + lock (this) + { + m_qtw.Flush(); + } + + return true; + } } } http://git-wip-us.apache.org/repos/asf/logging-log4net/blob/82c3e389/src/Appender/TraceAppender.cs ---------------------------------------------------------------------- diff --git a/src/Appender/TraceAppender.cs b/src/Appender/TraceAppender.cs index acc910f..dd5efae 100644 --- a/src/Appender/TraceAppender.cs +++ b/src/Appender/TraceAppender.cs @@ -37,7 +37,7 @@ namespace log4net.Appender /// <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. + /// of the Write method. /// </para> /// <para> /// <b>Compact Framework</b><br /> @@ -50,7 +50,7 @@ namespace log4net.Appender /// <author>Douglas de la Torre</author> /// <author>Nicko Cadell</author> /// <author>Gert Driesen</author> - /// <author>Ron Grabowski</author> + /// <author>Ron Grabowski</author> public class TraceAppender : AppenderSkeleton { #region Public Instance Constructors @@ -111,24 +111,24 @@ namespace log4net.Appender set { m_immediateFlush = value; } } - /// <summary> - /// The category parameter sent to the Trace method. - /// </summary> - /// <remarks> - /// <para> - /// Defaults to %logger which will use the logger name of the current - /// <see cref="LoggingEvent"/> as the category parameter. - /// </para> - /// <para> - /// </para> - /// </remarks> - public PatternLayout Category - { - get { return m_category; } - set { m_category = value; } - } - - #endregion Public Instance Properties + /// <summary> + /// The category parameter sent to the Trace method. + /// </summary> + /// <remarks> + /// <para> + /// Defaults to %logger which will use the logger name of the current + /// <see cref="LoggingEvent"/> as the category parameter. + /// </para> + /// <para> + /// </para> + /// </remarks> + public PatternLayout Category + { + get { return m_category; } + set { m_category = value; } + } + + #endregion Public Instance Properties #region Override implementation of AppenderSkeleton @@ -149,7 +149,7 @@ namespace log4net.Appender #if NETCF System.Diagnostics.Debug.Write(RenderLoggingEvent(loggingEvent), m_category.Format(loggingEvent)); #else - System.Diagnostics.Trace.Write(RenderLoggingEvent(loggingEvent), m_category.Format(loggingEvent)); + System.Diagnostics.Trace.Write(RenderLoggingEvent(loggingEvent), m_category.Format(loggingEvent)); #endif // @@ -200,30 +200,30 @@ namespace log4net.Appender /// </remarks> private bool m_immediateFlush = true; - /// <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 Private Instance Fields - /// <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) - { - // Nothing to do if ImmediateFlush is true - if (m_immediateFlush) return true; - - // System.Diagnostics.Trace and System.Diagnostics.Debug are thread-safe, so no need for lock(this). + /// <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) + { + // Nothing to do if ImmediateFlush is true + if (m_immediateFlush) return true; + + // System.Diagnostics.Trace and System.Diagnostics.Debug are thread-safe, so no need for lock(this). #if NETCF System.Diagnostics.Debug.Flush(); #else - System.Diagnostics.Trace.Flush(); + System.Diagnostics.Trace.Flush(); #endif - return true; - } - } + return true; + } + } } http://git-wip-us.apache.org/repos/asf/logging-log4net/blob/82c3e389/src/Config/BasicConfigurator.cs ---------------------------------------------------------------------- diff --git a/src/Config/BasicConfigurator.cs b/src/Config/BasicConfigurator.cs index a976d51..0b49dbd 100644 --- a/src/Config/BasicConfigurator.cs +++ b/src/Config/BasicConfigurator.cs @@ -50,23 +50,23 @@ namespace log4net.Config /// <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 readonly static 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 readonly static Type declaringType = typeof(BasicConfigurator); - #endregion Private Static Fields + #endregion Private Static Fields - #region Private Instance Constructors + #region Private Instance Constructors - /// <summary> + /// <summary> /// Initializes a new instance of the <see cref="BasicConfigurator" /> class. /// </summary> /// <remarks> @@ -95,37 +95,37 @@ namespace log4net.Config /// layout style. /// </para> /// </remarks> - static public ICollection Configure() + static public ICollection Configure() + { + return BasicConfigurator.Configure(LogManager.GetRepository(Assembly.GetCallingAssembly())); + } + + /// <summary> + /// Initializes the log4net system using the specified appenders. + /// </summary> + /// <param name="appenders">The appenders to use to log all logging events.</param> + /// <remarks> + /// <para> + /// Initializes the log4net system using the specified appenders. + /// </para> + /// </remarks> + static public ICollection Configure(params IAppender[] appenders) { - return BasicConfigurator.Configure(LogManager.GetRepository(Assembly.GetCallingAssembly())); - } - - /// <summary> - /// Initializes the log4net system using the specified appenders. - /// </summary> - /// <param name="appenders">The appenders to use to log all logging events.</param> - /// <remarks> - /// <para> - /// Initializes the log4net system using the specified appenders. - /// </para> - /// </remarks> - static public ICollection Configure(params IAppender[] appenders) - { - ArrayList configurationMessages = new ArrayList(); - - ILoggerRepository repository = LogManager.GetRepository(Assembly.GetCallingAssembly()); - - using (new LogLog.LogReceivedAdapter(configurationMessages)) - { - InternalConfigure(repository, appenders); - } - - repository.ConfigurationMessages = configurationMessages; - - return configurationMessages; - } - - /// <summary> + ArrayList configurationMessages = new ArrayList(); + + ILoggerRepository repository = LogManager.GetRepository(Assembly.GetCallingAssembly()); + + using (new LogLog.LogReceivedAdapter(configurationMessages)) + { + InternalConfigure(repository, appenders); + } + + repository.ConfigurationMessages = configurationMessages; + + 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> @@ -136,7 +136,7 @@ namespace log4net.Config /// </remarks> static public ICollection Configure(IAppender appender) { - return Configure(new IAppender[] { appender }); + return Configure(new IAppender[] { appender }); } #endif // !NETSTANDARD1_3 @@ -153,80 +153,80 @@ namespace log4net.Config /// layout style. /// </para> /// </remarks> - static public ICollection Configure(ILoggerRepository repository) + static public ICollection Configure(ILoggerRepository repository) { - ArrayList configurationMessages = new ArrayList(); + ArrayList configurationMessages = new ArrayList(); + + using (new LogLog.LogReceivedAdapter(configurationMessages)) + { + // Create the layout + PatternLayout layout = new PatternLayout(); + layout.ConversionPattern = PatternLayout.DetailConversionPattern; + layout.ActivateOptions(); - using (new LogLog.LogReceivedAdapter(configurationMessages)) - { - // Create the layout - PatternLayout layout = new PatternLayout(); - layout.ConversionPattern = PatternLayout.DetailConversionPattern; - layout.ActivateOptions(); + // Create the appender + ConsoleAppender appender = new ConsoleAppender(); + appender.Layout = layout; + appender.ActivateOptions(); - // Create the appender - ConsoleAppender appender = new ConsoleAppender(); - appender.Layout = layout; - appender.ActivateOptions(); + InternalConfigure(repository, appender); + } - InternalConfigure(repository, appender); - } + repository.ConfigurationMessages = configurationMessages; - repository.ConfigurationMessages = configurationMessages; + return configurationMessages; + } - return configurationMessages; + /// <summary> + /// Initializes the <see cref="ILoggerRepository"/> using the specified appender. + /// </summary> + /// <param name="repository">The repository to configure.</param> + /// <param name="appender">The appender to use to log all logging events.</param> + /// <remarks> + /// <para> + /// Initializes the <see cref="ILoggerRepository"/> using the specified appender. + /// </para> + /// </remarks> + static public ICollection Configure(ILoggerRepository repository, IAppender appender) + { + return Configure(repository, new IAppender[] { appender }); } - /// <summary> - /// Initializes the <see cref="ILoggerRepository"/> using the specified appender. - /// </summary> - /// <param name="repository">The repository to configure.</param> - /// <param name="appender">The appender to use to log all logging events.</param> - /// <remarks> - /// <para> - /// Initializes the <see cref="ILoggerRepository"/> using the specified appender. - /// </para> - /// </remarks> - static public ICollection Configure(ILoggerRepository repository, IAppender appender) - { - return Configure(repository, new IAppender[] { appender }); - } - - /// <summary> - /// Initializes the <see cref="ILoggerRepository"/> using the specified appenders. - /// </summary> - /// <param name="repository">The repository to configure.</param> - /// <param name="appenders">The appenders to use to log all logging events.</param> - /// <remarks> - /// <para> - /// Initializes the <see cref="ILoggerRepository"/> using the specified appender. - /// </para> - /// </remarks> - static public ICollection Configure(ILoggerRepository repository, params IAppender[] appenders) - { - ArrayList configurationMessages = new ArrayList(); - - using (new LogLog.LogReceivedAdapter(configurationMessages)) - { - InternalConfigure(repository, appenders); - } - - repository.ConfigurationMessages = configurationMessages; - - return configurationMessages; - } + /// <summary> + /// Initializes the <see cref="ILoggerRepository"/> using the specified appenders. + /// </summary> + /// <param name="repository">The repository to configure.</param> + /// <param name="appenders">The appenders to use to log all logging events.</param> + /// <remarks> + /// <para> + /// Initializes the <see cref="ILoggerRepository"/> using the specified appender. + /// </para> + /// </remarks> + static public ICollection Configure(ILoggerRepository repository, params IAppender[] appenders) + { + ArrayList configurationMessages = new ArrayList(); + + using (new LogLog.LogReceivedAdapter(configurationMessages)) + { + InternalConfigure(repository, appenders); + } + + repository.ConfigurationMessages = configurationMessages; + + return configurationMessages; + } static private void InternalConfigure(ILoggerRepository repository, params IAppender[] appenders) { - IBasicRepositoryConfigurator configurableRepository = repository as IBasicRepositoryConfigurator; - if (configurableRepository != null) - { - configurableRepository.Configure(appenders); - } - else - { - LogLog.Warn(declaringType, "BasicConfigurator: Repository [" + repository + "] does not support the BasicConfigurator"); - } + IBasicRepositoryConfigurator configurableRepository = repository as IBasicRepositoryConfigurator; + if (configurableRepository != null) + { + configurableRepository.Configure(appenders); + } + else + { + LogLog.Warn(declaringType, "BasicConfigurator: Repository [" + repository + "] does not support the BasicConfigurator"); + } } #endregion Public Static Methods http://git-wip-us.apache.org/repos/asf/logging-log4net/blob/82c3e389/src/Config/SecurityContextProviderAttribute.cs ---------------------------------------------------------------------- diff --git a/src/Config/SecurityContextProviderAttribute.cs b/src/Config/SecurityContextProviderAttribute.cs index 4b92a00..259c869 100644 --- a/src/Config/SecurityContextProviderAttribute.cs +++ b/src/Config/SecurityContextProviderAttribute.cs @@ -133,18 +133,18 @@ namespace log4net.Config #endregion Private Instance 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 readonly static Type declaringType = typeof(SecurityContextProviderAttribute); - - #endregion 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 readonly static Type declaringType = typeof(SecurityContextProviderAttribute); + + #endregion Private Static Fields } } http://git-wip-us.apache.org/repos/asf/logging-log4net/blob/82c3e389/src/Config/XmlConfigurator.cs ---------------------------------------------------------------------- diff --git a/src/Config/XmlConfigurator.cs b/src/Config/XmlConfigurator.cs index 2374b40..7c81a36 100644 --- a/src/Config/XmlConfigurator.cs +++ b/src/Config/XmlConfigurator.cs @@ -57,26 +57,26 @@ namespace log4net.Config #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 @@ -93,21 +93,21 @@ namespace log4net.Config /// </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"); @@ -198,10 +198,10 @@ namespace log4net.Config /// </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 @@ -215,18 +215,18 @@ namespace log4net.Config /// <param name="element">The element to parse.</param> 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 @@ -318,14 +318,14 @@ namespace log4net.Config #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> @@ -344,17 +344,17 @@ namespace log4net.Config /// </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> @@ -373,99 +373,99 @@ namespace log4net.Config /// </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 @@ -504,19 +504,19 @@ namespace log4net.Config /// </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) { @@ -577,35 +577,35 @@ namespace log4net.Config } } - /// <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); - } - - repository.ConfigurationMessages = configurationMessages; - - return configurationMessages; - } + /// <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); + } + + repository.ConfigurationMessages = configurationMessages; + + return configurationMessages; + } static private void InternalConfigure(ILoggerRepository repository, Uri configUri) { @@ -681,35 +681,35 @@ namespace log4net.Config } } - /// <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); - } - - repository.ConfigurationMessages = configurationMessages; - - return configurationMessages; - } + /// <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); + } + + repository.ConfigurationMessages = configurationMessages; + + return configurationMessages; + } static private void InternalConfigure(ILoggerRepository repository, Stream configStream) { @@ -731,8 +731,8 @@ namespace log4net.Config #elif NET_2_0 || NETSTANDARD1_3 // 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 @@ -815,57 +815,57 @@ namespace log4net.Config /// <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(); - - using (new LogLog.LogReceivedAdapter(configurationMessages)) - { - InternalConfigureAndWatch(repository, configFile); - } - - repository.ConfigurationMessages = configurationMessages; - - return configurationMessages; - } + /// <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); + } + + repository.ConfigurationMessages = configurationMessages; + + return configurationMessages; + } static private void InternalConfigureAndWatch(ILoggerRepository repository, FileInfo configFile) { @@ -882,23 +882,23 @@ namespace log4net.Config 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) { @@ -952,15 +952,15 @@ namespace log4net.Config /// </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> @@ -970,9 +970,9 @@ namespace log4net.Config /// </para> /// </remarks> #if NET_4_0 || MONO_4_0 || NETSTANDARD1_3 - [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; @@ -996,7 +996,7 @@ namespace log4net.Config 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> @@ -1046,18 +1046,18 @@ namespace log4net.Config 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 || NETSTANDARD1_3 - [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 @@ -1115,25 +1115,25 @@ namespace log4net.Config #endregion Private Static Methods - #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> - /// 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 + #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> + /// 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 } } http://git-wip-us.apache.org/repos/asf/logging-log4net/blob/82c3e389/src/Config/XmlConfiguratorAttribute.cs ---------------------------------------------------------------------- diff --git a/src/Config/XmlConfiguratorAttribute.cs b/src/Config/XmlConfiguratorAttribute.cs index 3ea1bdd..bafa024 100644 --- a/src/Config/XmlConfiguratorAttribute.cs +++ b/src/Config/XmlConfiguratorAttribute.cs @@ -195,35 +195,35 @@ namespace log4net.Config /// configure it. /// </para> /// </remarks> - /// <exception cref="ArgumentOutOfRangeException">The <paramref name="targetRepository" /> does not extend <see cref="Hierarchy"/>.</exception> + /// <exception cref="ArgumentOutOfRangeException">The <paramref name="targetRepository" /> does not extend <see cref="Hierarchy"/>.</exception> override public void Configure(Assembly sourceAssembly, ILoggerRepository targetRepository) { - IList configurationMessages = new ArrayList(); - - using (new LogLog.LogReceivedAdapter(configurationMessages)) - { - string applicationBaseDirectory = null; - try - { - applicationBaseDirectory = SystemInfo.ApplicationBaseDirectory; - } - catch - { - // Ignore this exception because it is only thrown when ApplicationBaseDirectory is a file - // and the application does not have PathDiscovery permission - } - - if (applicationBaseDirectory == null || (new Uri(applicationBaseDirectory)).IsFile) - { - ConfigureFromFile(sourceAssembly, targetRepository); - } - else - { - ConfigureFromUri(sourceAssembly, targetRepository); - } - } - - targetRepository.ConfigurationMessages = configurationMessages; + IList configurationMessages = new ArrayList(); + + using (new LogLog.LogReceivedAdapter(configurationMessages)) + { + string applicationBaseDirectory = null; + try + { + applicationBaseDirectory = SystemInfo.ApplicationBaseDirectory; + } + catch + { + // Ignore this exception because it is only thrown when ApplicationBaseDirectory is a file + // and the application does not have PathDiscovery permission + } + + if (applicationBaseDirectory == null || (new Uri(applicationBaseDirectory)).IsFile) + { + ConfigureFromFile(sourceAssembly, targetRepository); + } + else + { + ConfigureFromUri(sourceAssembly, targetRepository); + } + } + + targetRepository.ConfigurationMessages = configurationMessages; } #endregion @@ -451,18 +451,18 @@ namespace log4net.Config #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 readonly static 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 readonly static Type declaringType = typeof(XmlConfiguratorAttribute); - #endregion Private Static Fields + #endregion Private Static Fields } } http://git-wip-us.apache.org/repos/asf/logging-log4net/blob/82c3e389/src/Core/CompactRepositorySelector.cs ---------------------------------------------------------------------- diff --git a/src/Core/CompactRepositorySelector.cs b/src/Core/CompactRepositorySelector.cs index 4b79269..baf1d0c 100644 --- a/src/Core/CompactRepositorySelector.cs +++ b/src/Core/CompactRepositorySelector.cs @@ -302,18 +302,18 @@ namespace log4net.Core #endregion - #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 readonly static Type declaringType = typeof(CompactRepositorySelector); - - #endregion 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 readonly static Type declaringType = typeof(CompactRepositorySelector); + + #endregion Private Static Fields /// <summary> /// Event to notify that a logger repository has been created. http://git-wip-us.apache.org/repos/asf/logging-log4net/blob/82c3e389/src/Core/DefaultRepositorySelector.cs ---------------------------------------------------------------------- diff --git a/src/Core/DefaultRepositorySelector.cs b/src/Core/DefaultRepositorySelector.cs index 866ad3b..de75099 100644 --- a/src/Core/DefaultRepositorySelector.cs +++ b/src/Core/DefaultRepositorySelector.cs @@ -709,37 +709,37 @@ namespace log4net.Core 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) - { - repositoryConfigFilePath = Path.Combine(applicationBaseDirectory, repositoryConfigFile); - } - - // Determine whether to watch the file or not based on an app setting value: - bool watchRepositoryConfigFile = false; + string repositoryConfigFilePath = repositoryConfigFile; + if (applicationBaseDirectory != null) + { + repositoryConfigFilePath = Path.Combine(applicationBaseDirectory, repositoryConfigFile); + } + + // Determine whether to watch the file or not based on an app setting value: + bool watchRepositoryConfigFile = false; #if NET_2_0 || MONO_2_0 || MONO_3_5 || MONO_4_0 || NETSTANDARD1_3 - 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"); - if (watch != null && watch.Length > 0) - { - try - { - watchRepositoryConfigFile = Boolean.Parse(watch); - } - catch (FormatException) - { - // simply not a Boolean - } - } - } + { + string watch = SystemInfo.GetAppSetting("log4net.Config.Watch"); + if (watch != null && watch.Length > 0) + { + try + { + watchRepositoryConfigFile = Boolean.Parse(watch); + } + catch (FormatException) + { + // simply not a Boolean + } + } + } #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 + // 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 { @@ -747,27 +747,27 @@ namespace log4net.Core } catch (Exception ex) { - LogLog.Error(declaringType, "DefaultRepositorySelector: Exception while parsing log4net.Config file physical path [" + repositoryConfigFilePath + "]", ex); + LogLog.Error(declaringType, "DefaultRepositorySelector: Exception while parsing log4net.Config file physical path [" + repositoryConfigFilePath + "]", ex); } try { - LogLog.Debug(declaringType, "Loading and watching configuration for default repository from AppSettings specified Config path [" + repositoryConfigFilePath + "]"); + LogLog.Debug(declaringType, "Loading and watching configuration for default repository from AppSettings specified Config path [" + repositoryConfigFilePath + "]"); - XmlConfigurator.ConfigureAndWatch(repository, repositoryConfigFileInfo); + XmlConfigurator.ConfigureAndWatch(repository, repositoryConfigFileInfo); } catch (Exception ex) { - LogLog.Error(declaringType, "DefaultRepositorySelector: Exception calling XmlConfigurator.ConfigureAndWatch method with ConfigFilePath [" + repositoryConfigFilePath + "]", ex); + LogLog.Error(declaringType, "DefaultRepositorySelector: Exception calling XmlConfigurator.ConfigureAndWatch method with ConfigFilePath [" + repositoryConfigFilePath + "]", ex); } } else { - // As we are not going to watch the config file it is easiest to just resolve it as a + // 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); + repositoryConfigUri = new Uri(repositoryConfigFilePath); } catch(Exception ex) { @@ -788,7 +788,7 @@ namespace log4net.Core LogLog.Error(declaringType, "Exception calling XmlConfigurator.Configure method with ConfigUri ["+repositoryConfigUri+"]", ex); } } - } + } } } } @@ -884,14 +884,14 @@ namespace log4net.Core #region Private Static Fields - /// <summary> - /// The fully qualified type of the DefaultRepositorySelector class. - /// </summary> - /// <remarks> - /// Used by the internal logger to record the Type of the - /// log message. - /// </remarks> - private readonly static Type declaringType = typeof(DefaultRepositorySelector); + /// <summary> + /// The fully qualified type of the DefaultRepositorySelector class. + /// </summary> + /// <remarks> + /// Used by the internal logger to record the Type of the + /// log message. + /// </remarks> + private readonly static Type declaringType = typeof(DefaultRepositorySelector); private const string DefaultRepositoryName = "log4net-default-repository"; http://git-wip-us.apache.org/repos/asf/logging-log4net/blob/82c3e389/src/Core/Level.cs ---------------------------------------------------------------------- diff --git a/src/Core/Level.cs b/src/Core/Level.cs index a083156..4bcb263 100644 --- a/src/Core/Level.cs +++ b/src/Core/Level.cs @@ -502,11 +502,11 @@ namespace log4net.Core /// </summary> public readonly static Level Off = new Level(int.MaxValue, "OFF"); - /// <summary> - /// The <see cref="Emergency" /> level designates very severe error events. - /// System unusable, emergencies. - /// </summary> - public readonly static Level Log4Net_Debug = new Level(120000, "log4net:DEBUG"); + /// <summary> + /// The <see cref="Emergency" /> level designates very severe error events. + /// System unusable, emergencies. + /// </summary> + public readonly static Level Log4Net_Debug = new Level(120000, "log4net:DEBUG"); /// <summary> /// The <see cref="Emergency" /> level designates very severe error events. http://git-wip-us.apache.org/repos/asf/logging-log4net/blob/82c3e389/src/Core/LocationInfo.cs ---------------------------------------------------------------------- diff --git a/src/Core/LocationInfo.cs b/src/Core/LocationInfo.cs index 99e27db..9cc0868 100644 --- a/src/Core/LocationInfo.cs +++ b/src/Core/LocationInfo.cs @@ -117,7 +117,7 @@ namespace log4net.Core { // take into account the frames we skip above int adjustedFrameCount = st.FrameCount - frameIndex; - ArrayList stackFramesList = new ArrayList(adjustedFrameCount); + ArrayList stackFramesList = new ArrayList(adjustedFrameCount); m_stackFrames = new StackFrameItem[adjustedFrameCount]; for (int i=frameIndex; i < st.FrameCount; i++) { @@ -298,14 +298,14 @@ namespace log4net.Core #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 readonly static 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 readonly static Type declaringType = typeof(LocationInfo); /// <summary> /// When location information is not available the constant http://git-wip-us.apache.org/repos/asf/logging-log4net/blob/82c3e389/src/Core/LoggerManager.cs ---------------------------------------------------------------------- diff --git a/src/Core/LoggerManager.cs b/src/Core/LoggerManager.cs index f64c9a4..b0d50c5 100644 --- a/src/Core/LoggerManager.cs +++ b/src/Core/LoggerManager.cs @@ -99,7 +99,7 @@ namespace log4net.Core } // Dump out our assembly version into the log if debug is enabled - LogLog.Debug(declaringType, GetVersionInfo()); + LogLog.Debug(declaringType, GetVersionInfo()); // Set the default repository selector #if NETCF @@ -812,7 +812,7 @@ namespace log4net.Core 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()); + sb.Append(" on ").Append(Environment.OSVersion.ToString()); #endif #endif // NETSTANDARD1_3 sb.Append(")"); @@ -861,14 +861,14 @@ namespace log4net.Core #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 readonly static 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 readonly static Type declaringType = typeof(LoggerManager); /// <summary> /// Initialize the default repository selector http://git-wip-us.apache.org/repos/asf/logging-log4net/blob/82c3e389/src/Core/LoggingEvent.cs ---------------------------------------------------------------------- diff --git a/src/Core/LoggingEvent.cs b/src/Core/LoggingEvent.cs index 1b872d5..dcb2f7c 100644 --- a/src/Core/LoggingEvent.cs +++ b/src/Core/LoggingEvent.cs @@ -91,46 +91,46 @@ namespace log4net.Core /// Gets or sets the local time the event was logged /// </summary> /// <remarks> - /// <para> - /// Prefer using the <see cref="TimeStampUtc"/> setter, since local time can be ambiguous. + /// <para> + /// Prefer using the <see cref="TimeStampUtc"/> setter, since local time can be ambiguous. + /// </para> + /// </remarks> + [Obsolete("Prefer using TimeStampUtc, since local time can be ambiguous in time zones with daylight savings time.")] + public DateTime TimeStamp; + + /// <summary> + /// Gets or sets the UTC time the event was logged + /// </summary> + /// <remarks> + /// <para> + /// The TimeStamp is stored in the UTC time zone. /// </para> /// </remarks> - [Obsolete("Prefer using TimeStampUtc, since local time can be ambiguous in time zones with daylight savings time.")] - public DateTime TimeStamp; - - /// <summary> - /// Gets or sets the UTC time the event was logged - /// </summary> - /// <remarks> - /// <para> - /// The TimeStamp is stored in the UTC time zone. - /// </para> - /// </remarks> #pragma warning disable 618 // Suppress warnings that TimeStamp field is obsolete - public DateTime TimeStampUtc - { - get - { - if (TimeStamp != default(DateTime) && - _timeStampUtc == default(DateTime)) - { - // TimeStamp field has been set explicitly but TimeStampUtc hasn't - // => use TimeStamp - return TimeStamp.ToUniversalTime(); - } - return _timeStampUtc; - } - set - { - _timeStampUtc = value; - // For backwards compatibility - TimeStamp = _timeStampUtc.ToLocalTime(); - } - } - private DateTime _timeStampUtc; + public DateTime TimeStampUtc + { + get + { + if (TimeStamp != default(DateTime) && + _timeStampUtc == default(DateTime)) + { + // TimeStamp field has been set explicitly but TimeStampUtc hasn't + // => use TimeStamp + return TimeStamp.ToUniversalTime(); + } + return _timeStampUtc; + } + set + { + _timeStampUtc = value; + // For backwards compatibility + TimeStamp = _timeStampUtc.ToLocalTime(); + } + } + private DateTime _timeStampUtc; #pragma warning restore 618 - /// <summary> + /// <summary> /// Location information for the caller. /// </summary> /// <remarks> @@ -330,7 +330,7 @@ namespace log4net.Core : ISerializable #endif { - private readonly static Type declaringType = typeof(LoggingEvent); + private readonly static Type declaringType = typeof(LoggingEvent); #region Public Instance Constructors @@ -532,27 +532,27 @@ namespace log4net.Core get { return SystemInfo.ProcessStartTimeUtc.ToLocalTime(); } } - /// <summary> - /// Gets the UTC time when the current process started. - /// </summary> - /// <value> - /// This is the UTC time when this process started. - /// </value> - /// <remarks> - /// <para> - /// Tries to get the start time for the current process. - /// Failing that it returns the time of the first call to - /// this property. - /// </para> - /// <para> - /// Note that AppDomains may be loaded and unloaded within the - /// same process without the process terminating and therefore - /// without the process start time being reset. - /// </para> - /// </remarks> - public static DateTime StartTimeUtc - { - get { return SystemInfo.ProcessStartTimeUtc; } + /// <summary> + /// Gets the UTC time when the current process started. + /// </summary> + /// <value> + /// This is the UTC time when this process started. + /// </value> + /// <remarks> + /// <para> + /// Tries to get the start time for the current process. + /// Failing that it returns the time of the first call to + /// this property. + /// </para> + /// <para> + /// Note that AppDomains may be loaded and unloaded within the + /// same process without the process terminating and therefore + /// without the process start time being reset. + /// </para> + /// </remarks> + public static DateTime StartTimeUtc + { + get { return SystemInfo.ProcessStartTimeUtc; } } /// <summary> @@ -587,15 +587,15 @@ namespace log4net.Core get { return m_data.TimeStampUtc.ToLocalTime(); } } - /// <summary> - /// Gets UTC the time of the logging event. - /// </summary> - /// <value> - /// The UTC time of the logging event. - /// </value> - public DateTime TimeStampUtc - { - get { return m_data.TimeStampUtc; } + /// <summary> + /// Gets UTC the time of the logging event. + /// </summary> + /// <value> + /// The UTC time of the logging event. + /// </value> + public DateTime TimeStampUtc + { + get { return m_data.TimeStampUtc; } } /// <summary> @@ -1092,7 +1092,7 @@ namespace log4net.Core /// </para> /// </remarks> #if NET_4_0 || MONO_4_0 || NETSTANDARD1_3 - [System.Security.SecurityCritical] + [System.Security.SecurityCritical] #else [System.Security.Permissions.SecurityPermissionAttribute(System.Security.Permissions.SecurityAction.Demand, SerializationFormatter=true)] #endif @@ -1105,13 +1105,13 @@ namespace log4net.Core info.AddValue("Level", m_data.Level); info.AddValue("Message", m_data.Message); info.AddValue("ThreadName", m_data.ThreadName); - // TODO: consider serializing UTC rather than local time. Not implemented here because it - // would give an unexpected result if client and server have different versions of this class. - // info.AddValue("TimeStamp", m_data.TimeStampUtc); + // TODO: consider serializing UTC rather than local time. Not implemented here because it + // would give an unexpected result if client and server have different versions of this class. + // info.AddValue("TimeStamp", m_data.TimeStampUtc); #pragma warning disable 618 info.AddValue("TimeStamp", m_data.TimeStamp); #pragma warning restore 618 - info.AddValue("LocationInfo", m_data.LocationInfo); + info.AddValue("LocationInfo", m_data.LocationInfo); info.AddValue("UserName", m_data.UserName); info.AddValue("ExceptionString", m_data.ExceptionString); info.AddValue("Properties", m_data.Properties); @@ -1416,7 +1416,7 @@ namespace log4net.Core compositeProperties.Add(eventProperties); compositeProperties.Add(GlobalContext.Properties.GetReadOnlyProperties()); - m_compositeProperties = compositeProperties; + m_compositeProperties = compositeProperties; } private void CacheProperties() http://git-wip-us.apache.org/repos/asf/logging-log4net/blob/82c3e389/src/Core/MethodItem.cs ---------------------------------------------------------------------- diff --git a/src/Core/MethodItem.cs b/src/Core/MethodItem.cs index cc719fa..5f5f454 100644 --- a/src/Core/MethodItem.cs +++ b/src/Core/MethodItem.cs @@ -66,13 +66,13 @@ namespace log4net.Core 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> + /// <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)) - { + { } #endregion http://git-wip-us.apache.org/repos/asf/logging-log4net/blob/82c3e389/src/Core/StackFrameItem.cs ---------------------------------------------------------------------- diff --git a/src/Core/StackFrameItem.cs b/src/Core/StackFrameItem.cs index 8de50a4..3d24668 100644 --- a/src/Core/StackFrameItem.cs +++ b/src/Core/StackFrameItem.cs @@ -25,28 +25,28 @@ using log4net.Util; namespace log4net.Core { - /// <summary> - /// provides stack frame information without actually referencing a System.Diagnostics.StackFrame - /// as that would require that the containing assembly is loaded. - /// </summary> - /// - [Serializable] - public class StackFrameItem - { - #region Public Instance Constructors - - /// <summary> - /// returns a stack frame item from a stack frame. This - /// </summary> - /// <param name="frame"></param> - /// <returns></returns> - public StackFrameItem(StackFrame frame) - { - // set default values - m_lineNumber = NA; - m_fileName = NA; - m_method = new MethodItem(); - m_className = NA; + /// <summary> + /// provides stack frame information without actually referencing a System.Diagnostics.StackFrame + /// as that would require that the containing assembly is loaded. + /// </summary> + /// + [Serializable] + public class StackFrameItem + { + #region Public Instance Constructors + + /// <summary> + /// returns a stack frame item from a stack frame. This + /// </summary> + /// <param name="frame"></param> + /// <returns></returns> + public StackFrameItem(StackFrame frame) + { + // set default values + m_lineNumber = NA; + m_fileName = NA; + m_method = new MethodItem(); + m_className = NA; try { @@ -67,130 +67,130 @@ namespace log4net.Core 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 + ')'; - } - - #endregion - - #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 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 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 MethodItem Method - { - get { return m_method; } - } - - /// <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; } - } - - #endregion Public Instance Properties - - #region Private Instance Fields - - private readonly string m_lineNumber; - private readonly string m_fileName; - private readonly string m_className; - private readonly string m_fullInfo; + // set full info + m_fullInfo = m_className + '.' + m_method.Name + '(' + m_fileName + ':' + m_lineNumber + ')'; + } + + #endregion + + #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 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 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 MethodItem Method + { + get { return m_method; } + } + + /// <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; } + } + + #endregion Public Instance Properties + + #region Private Instance Fields + + private readonly string m_lineNumber; + private readonly string m_fileName; + private readonly string m_className; + private readonly string m_fullInfo; private readonly MethodItem m_method; - #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 readonly static Type declaringType = typeof(StackFrameItem); + /// <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 readonly static Type declaringType = typeof(StackFrameItem); - /// <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 + } } #endif
