format documents #111
diff --git a/src/log4net/Appender/AnsiColorTerminalAppender.cs b/src/log4net/Appender/AnsiColorTerminalAppender.cs
index 1331833..da8cc08 100644
--- a/src/log4net/Appender/AnsiColorTerminalAppender.cs
+++ b/src/log4net/Appender/AnsiColorTerminalAppender.cs
@@ -121,16 +121,16 @@
/// <summary>
/// text is bright
/// </summary>
- Bright = 1,
+ Bright = 1,
/// <summary>
/// text is dim
/// </summary>
- Dim = 2,
+ Dim = 2,
/// <summary>
/// text is underlined
/// </summary>
- Underscore = 4,
+ Underscore = 4,
/// <summary>
/// text is blinking
@@ -138,27 +138,27 @@
/// <remarks>
/// Not all terminals support this attribute
/// </remarks>
- Blink = 8,
+ Blink = 8,
/// <summary>
/// text and background colors are reversed
/// </summary>
- Reverse = 16,
+ Reverse = 16,
/// <summary>
/// text is hidden
/// </summary>
- Hidden = 32,
+ Hidden = 32,
/// <summary>
/// text is displayed with a strikethrough
/// </summary>
- Strikethrough = 64,
+ Strikethrough = 64,
/// <summary>
/// text color is light
/// </summary>
- Light = 128
+ Light = 128
}
/// <summary>
@@ -176,42 +176,42 @@
/// <summary>
/// color is black
/// </summary>
- Black = 0,
+ Black = 0,
/// <summary>
/// color is red
/// </summary>
- Red = 1,
+ Red = 1,
/// <summary>
/// color is green
/// </summary>
- Green = 2,
+ Green = 2,
/// <summary>
/// color is yellow
/// </summary>
- Yellow = 3,
+ Yellow = 3,
/// <summary>
/// color is blue
/// </summary>
- Blue = 4,
+ Blue = 4,
/// <summary>
/// color is magenta
/// </summary>
- Magenta = 5,
+ Magenta = 5,
/// <summary>
/// color is cyan
/// </summary>
- Cyan = 6,
+ Cyan = 6,
/// <summary>
/// color is white
/// </summary>
- White = 7
+ White = 7
}
#endregion
@@ -225,7 +225,7 @@
/// The instance of the <see cref="AnsiColorTerminalAppender" /> class is set up to write
/// to the standard output stream.
/// </remarks>
- public AnsiColorTerminalAppender()
+ public AnsiColorTerminalAppender()
{
}
@@ -256,8 +256,8 @@
if (SystemInfo.EqualsIgnoringCase(ConsoleError, trimmedTargetName))
{
m_writeToErrorStream = true;
- }
- else
+ }
+ else
{
m_writeToErrorStream = false;
}
@@ -296,7 +296,7 @@
/// The format of the output will depend on the appender's layout.
/// </para>
/// </remarks>
- protected override void Append(log4net.Core.LoggingEvent loggingEvent)
+ protected override void Append(log4net.Core.LoggingEvent loggingEvent)
{
string loggingMessage = RenderLoggingEvent(loggingEvent);
@@ -314,26 +314,26 @@
// are inserted afterwards.
if (loggingMessage.Length > 1)
{
- if (loggingMessage.EndsWith("\r\n") || loggingMessage.EndsWith("\n\r"))
+ if (loggingMessage.EndsWith("\r\n") || loggingMessage.EndsWith("\n\r"))
{
loggingMessage = loggingMessage.Insert(loggingMessage.Length - 2, PostEventCodes);
- }
- else if (loggingMessage.EndsWith("\n") || loggingMessage.EndsWith("\r"))
+ }
+ else if (loggingMessage.EndsWith("\n") || loggingMessage.EndsWith("\r"))
{
loggingMessage = loggingMessage.Insert(loggingMessage.Length - 1, PostEventCodes);
- }
- else
+ }
+ else
{
loggingMessage = loggingMessage + PostEventCodes;
}
}
else
{
- if (loggingMessage[0] == '\n' || loggingMessage[0] == '\r')
+ if (loggingMessage[0] == '\n' || loggingMessage[0] == '\r')
{
loggingMessage = PostEventCodes + loggingMessage;
- }
- else
+ }
+ else
{
loggingMessage = loggingMessage + PostEventCodes;
}
@@ -354,7 +354,7 @@
Console.Write(loggingMessage);
}
#endif
-
+
}
/// <summary>
@@ -516,7 +516,7 @@
buf.Append("\x1b[0;");
int lightAdjustment = ((m_attributes & AnsiAttributes.Light) > 0) ? 60 : 0;
-
+
// set the foreground color
buf.Append(30 + lightAdjustment + (int)m_foreColor);
buf.Append(';');
diff --git a/src/log4net/Appender/AppenderCollection.cs b/src/log4net/Appender/AppenderCollection.cs
index 9728661..768f318 100644
--- a/src/log4net/Appender/AppenderCollection.cs
+++ b/src/log4net/Appender/AppenderCollection.cs
@@ -71,7 +71,7 @@
private int m_version = 0;
#endregion
-
+
#region Static Wrappers
/// <summary>
@@ -83,7 +83,7 @@
/// </returns>
public static AppenderCollection ReadOnly(AppenderCollection list)
{
- if(list==null) throw new ArgumentNullException("list");
+ if (list == null) throw new ArgumentNullException("list");
return new ReadOnlyAppenderCollection(list);
}
@@ -109,7 +109,7 @@
{
m_array = new IAppender[DEFAULT_CAPACITY];
}
-
+
/// <summary>
/// Initializes a new instance of the <c>AppenderCollection</c> class
/// that has the specified initial capacity.
@@ -143,7 +143,7 @@
m_array = new IAppender[a.Length];
AddRange(a);
}
-
+
/// <summary>
/// Initializes a new instance of the <c>AppenderCollection</c> class
/// that contains elements copied from the specified <see cref="IAppender"/> collection.
@@ -160,7 +160,7 @@
/// Used to access protected constructor
/// </summary>
/// <exclude/>
- protected internal enum Tag
+ protected internal enum Tag
{
/// <summary>
/// A value
@@ -179,7 +179,7 @@
}
#endregion
-
+
#region Operations (type-safe ICollection)
/// <summary>
@@ -212,8 +212,8 @@
{
throw new System.ArgumentException("Destination array was not long enough.");
}
-
- Array.Copy(m_array, 0, array, start, m_count);
+
+ Array.Copy(m_array, 0, array, start, m_count);
}
/// <summary>
@@ -234,7 +234,7 @@
}
#endregion
-
+
#region Operations (type-safe IList)
/// <summary>
@@ -251,13 +251,13 @@
get
{
ValidateIndex(index); // throws
- return m_array[index];
+ return m_array[index];
}
set
{
ValidateIndex(index); // throws
- ++m_version;
- m_array[index] = value;
+ ++m_version;
+ m_array[index] = value;
}
}
@@ -278,7 +278,7 @@
return m_count++;
}
-
+
/// <summary>
/// Removes all elements from the <c>AppenderCollection</c>.
/// </summary>
@@ -288,7 +288,7 @@
m_array = new IAppender[DEFAULT_CAPACITY];
m_count = 0;
}
-
+
/// <summary>
/// Creates a shallow copy of the <see cref="AppenderCollection"/>.
/// </summary>
@@ -310,7 +310,7 @@
/// <returns><c>true</c> if <paramref name="item"/> is found in the <c>AppenderCollection</c>; otherwise, <c>false</c>.</returns>
public virtual bool Contains(IAppender item)
{
- for (int i=0; i != m_count; ++i)
+ for (int i = 0; i != m_count; ++i)
{
if (m_array[i].Equals(item))
{
@@ -331,7 +331,7 @@
/// </returns>
public virtual int IndexOf(IAppender item)
{
- for (int i=0; i != m_count; ++i)
+ for (int i = 0; i != m_count; ++i)
{
if (m_array[i].Equals(item))
{
@@ -354,7 +354,7 @@
public virtual void Insert(int index, IAppender item)
{
ValidateIndex(index, true); // throws
-
+
if (m_count == m_array.Length)
{
EnsureCapacity(m_count + 1);
@@ -378,13 +378,13 @@
/// The specified <see cref="IAppender"/> was not found in the <c>AppenderCollection</c>.
/// </exception>
public virtual void Remove(IAppender item)
- {
+ {
int i = IndexOf(item);
if (i < 0)
{
throw new System.ArgumentException("Cannot remove the specified item because it was not found in the specified Collection.");
}
-
+
++m_version;
RemoveAt(i);
}
@@ -401,14 +401,14 @@
public virtual void RemoveAt(int index)
{
ValidateIndex(index); // throws
-
+
m_count--;
if (index < m_count)
{
Array.Copy(m_array, index + 1, m_array, index, m_count - index);
}
-
+
// We can't set the deleted entry equal to null, because it might be a value type.
// Instead, we'll create an empty single-element array of the right type and copy it
// over the entry we want to erase.
@@ -438,7 +438,7 @@
#endregion
#region Operations (type-safe IEnumerable)
-
+
/// <summary>
/// Returns an enumerator that can iterate through the <c>AppenderCollection</c>.
/// </summary>
@@ -451,15 +451,15 @@
#endregion
#region Public helpers (just to mimic some nice features of ArrayList)
-
+
/// <summary>
/// Gets or sets the number of elements the <c>AppenderCollection</c> can contain.
/// </summary>
public virtual int Capacity
{
- get
- {
- return m_array.Length;
+ get
+ {
+ return m_array.Length;
}
set
{
@@ -495,7 +495,7 @@
{
EnsureCapacity(m_count + x.Count);
}
-
+
Array.Copy(x.m_array, 0, m_array, m_count, x.Count);
m_count += x.Count;
m_version++;
@@ -521,7 +521,7 @@
return m_count;
}
-
+
/// <summary>
/// Adds the elements of a <see cref="IAppender"/> collection to the current <c>AppenderCollection</c>.
/// </summary>
@@ -534,7 +534,7 @@
EnsureCapacity(m_count + col.Count);
}
- foreach(object item in col)
+ foreach (object item in col)
{
Add((IAppender)item);
}
@@ -585,7 +585,7 @@
/// </exception>
private void ValidateIndex(int i, bool allowEqualEnd)
{
- int max = (allowEqualEnd) ? (m_count) : (m_count-1);
+ int max = (allowEqualEnd) ? (m_count) : (m_count - 1);
if (i < 0 || i > max)
{
throw log4net.Util.SystemInfo.CreateArgumentOutOfRangeException("i", (object)i, "Index was out of range. Must be non-negative and less than the size of the collection. [" + (object)i + "] Specified argument was out of the range of valid values.");
@@ -604,7 +604,7 @@
}
#endregion
-
+
#region Implementation (ICollection)
void ICollection.CopyTo(Array array, int start)
@@ -675,15 +675,15 @@
private sealed class Enumerator : IEnumerator, IAppenderCollectionEnumerator
{
#region Implementation (data)
-
+
private readonly AppenderCollection m_collection;
private int m_index;
private int m_version;
-
+
#endregion
-
+
#region Construction
-
+
/// <summary>
/// Initializes a new instance of the <c>Enumerator</c> class.
/// </summary>
@@ -694,11 +694,11 @@
m_index = -1;
m_version = tc.m_version;
}
-
+
#endregion
-
+
#region Operations (type-safe IEnumerator)
-
+
/// <summary>
/// Gets the current element in the collection.
/// </summary>
@@ -736,14 +736,14 @@
m_index = -1;
}
#endregion
-
+
#region Implementation (IEnumerator)
-
+
object IEnumerator.Current
{
get { return this.Current; }
}
-
+
#endregion
}
@@ -778,7 +778,7 @@
public override void CopyTo(IAppender[] array, int start)
{
- m_collection.CopyTo(array,start);
+ m_collection.CopyTo(array, start);
}
void ICollection.CopyTo(Array array, int start)
diff --git a/src/log4net/Appender/AppenderSkeleton.cs b/src/log4net/Appender/AppenderSkeleton.cs
index 0ababc3..29354c9 100644
--- a/src/log4net/Appender/AppenderSkeleton.cs
+++ b/src/log4net/Appender/AppenderSkeleton.cs
@@ -73,13 +73,13 @@
/// will call <see cref="Close"/>.
/// </para>
/// </remarks>
- ~AppenderSkeleton()
+ ~AppenderSkeleton()
{
// An appender might be closed then garbage collected.
// There is no point in closing twice.
- if (!m_closed)
+ if (!m_closed)
{
- LogLog.Debug(declaringType, "Finalizing appender named ["+m_name+"].");
+ LogLog.Debug(declaringType, "Finalizing appender named [" + m_name + "].");
Close();
}
}
@@ -105,7 +105,7 @@
/// string, such as "DEBUG", "INFO" and so on.
/// </para>
/// </remarks>
- public Level Threshold
+ public Level Threshold
{
get { return m_threshold; }
set { m_threshold = value; }
@@ -121,20 +121,20 @@
/// implementation for the <see cref="ErrorHandler"/> property.
/// </para>
/// </remarks>
- public virtual IErrorHandler ErrorHandler
+ public virtual IErrorHandler ErrorHandler
{
get { return this.m_errorHandler; }
- set
+ set
{
- lock(this)
+ lock (this)
{
- if (value == null)
+ if (value == null)
{
// We do not throw exception here since the cause is probably a
// bad config file.
LogLog.Warn(declaringType, "You have tried to set a null error-handler.");
- }
- else
+ }
+ else
{
m_errorHandler = value;
}
@@ -167,7 +167,7 @@
/// </para>
/// </remarks>
/// <seealso cref="RequiresLayout"/>
- public virtual ILayout Layout
+ public virtual ILayout Layout
{
get { return m_layout; }
set { m_layout = value; }
@@ -193,7 +193,7 @@
/// <see cref="ActivateOptions"/> must be called again.
/// </para>
/// </remarks>
- public virtual void ActivateOptions()
+ public virtual void ActivateOptions()
{
}
@@ -210,7 +210,7 @@
/// The name uniquely identifies the appender.
/// </para>
/// </remarks>
- public string Name
+ public string Name
{
get { return m_name; }
set { m_name = value; }
@@ -236,7 +236,7 @@
public void Close()
{
// This lock prevents the appender being closed while it is still appending
- lock(this)
+ lock (this)
{
if (!m_closed)
{
@@ -287,18 +287,18 @@
/// will be passed to the abstract <see cref="M:Append(LoggingEvent)"/> method.
/// </para>
/// </remarks>
- public void DoAppend(LoggingEvent loggingEvent)
+ public void DoAppend(LoggingEvent loggingEvent)
{
// This lock is absolutely critical for correct formatting
// of the message in a multi-threaded environment. Without
// this, the message may be broken up into elements from
// multiple thread contexts (like get the wrong thread ID).
- lock(this)
+ lock (this)
{
if (m_closed)
{
- ErrorHandler.Error("Attempted to append to closed appender named ["+m_name+"].");
+ ErrorHandler.Error("Attempted to append to closed appender named [" + m_name + "].");
return;
}
@@ -317,7 +317,7 @@
this.Append(loggingEvent);
}
}
- catch(Exception ex)
+ catch (Exception ex)
{
ErrorHandler.Error("Failed in DoAppend", ex);
}
@@ -384,18 +384,18 @@
/// will be passed to the <see cref="M:Append(LoggingEvent[])"/> method.
/// </para>
/// </remarks>
- public void DoAppend(LoggingEvent[] loggingEvents)
+ public void DoAppend(LoggingEvent[] loggingEvents)
{
// This lock is absolutely critical for correct formatting
// of the message in a multi-threaded environment. Without
// this, the message may be broken up into elements from
// multiple thread contexts (like get the wrong thread ID).
- lock(this)
+ lock (this)
{
if (m_closed)
{
- ErrorHandler.Error("Attempted to append to closed appender named ["+m_name+"].");
+ ErrorHandler.Error("Attempted to append to closed appender named [" + m_name + "].");
return;
}
@@ -411,7 +411,7 @@
ArrayList filteredEvents = new ArrayList(loggingEvents.Length);
- foreach(LoggingEvent loggingEvent in loggingEvents)
+ foreach (LoggingEvent loggingEvent in loggingEvents)
{
if (FilterEvent(loggingEvent))
{
@@ -424,7 +424,7 @@
this.Append((LoggingEvent[])filteredEvents.ToArray(typeof(LoggingEvent)));
}
}
- catch(Exception ex)
+ catch (Exception ex)
{
ErrorHandler.Error("Failed in Bulk DoAppend", ex);
}
@@ -481,18 +481,18 @@
/// </remarks>
protected virtual bool FilterEvent(LoggingEvent loggingEvent)
{
- if (!IsAsSevereAsThreshold(loggingEvent.Level))
+ if (!IsAsSevereAsThreshold(loggingEvent.Level))
{
return false;
}
IFilter f = this.FilterHead;
- while(f != null)
+ while (f != null)
{
- switch(f.Decide(loggingEvent))
+ switch (f.Decide(loggingEvent))
{
- case FilterDecision.Deny:
+ case FilterDecision.Deny:
return false; // Return without appending
case FilterDecision.Accept:
@@ -530,14 +530,14 @@
throw new ArgumentNullException("filter param must not be null");
}
- if (m_headFilter == null)
+ if (m_headFilter == null)
{
m_headFilter = m_tailFilter = filter;
- }
- else
+ }
+ else
{
m_tailFilter.Next = filter;
- m_tailFilter = filter;
+ m_tailFilter = filter;
}
}
@@ -571,7 +571,7 @@
/// <c>true</c> if the <paramref name="level"/> meets the <see cref="Threshold"/>
/// requirements of this appender.
/// </returns>
- protected virtual bool IsAsSevereAsThreshold(Level level)
+ protected virtual bool IsAsSevereAsThreshold(Level level)
{
return ((m_threshold == null) || level >= m_threshold);
}
@@ -589,7 +589,7 @@
/// It is a programming error to append to a closed appender.
/// </para>
/// </remarks>
- protected virtual void OnClose()
+ protected virtual void OnClose()
{
// Do nothing by default
}
@@ -630,7 +630,7 @@
/// </remarks>
protected virtual void Append(LoggingEvent[] loggingEvents)
{
- foreach(LoggingEvent loggingEvent in loggingEvents)
+ foreach (LoggingEvent loggingEvent in loggingEvents)
{
Append(loggingEvent);
}
@@ -658,7 +658,7 @@
{
if ((m_layout == null) && RequiresLayout)
{
- ErrorHandler.Error("AppenderSkeleton: No layout set for the appender named ["+m_name+"].");
+ ErrorHandler.Error("AppenderSkeleton: No layout set for the appender named [" + m_name + "].");
return false;
}
@@ -697,14 +697,14 @@
m_renderWriter = new ReusableStringWriter(System.Globalization.CultureInfo.InvariantCulture);
}
- lock (m_renderWriter)
- {
- // Reset the writer so we can reuse it
- m_renderWriter.Reset(c_renderBufferMaxCapacity, c_renderBufferSize);
+ lock (m_renderWriter)
+ {
+ // Reset the writer so we can reuse it
+ m_renderWriter.Reset(c_renderBufferMaxCapacity, c_renderBufferSize);
- RenderLoggingEvent(m_renderWriter, loggingEvent);
- return m_renderWriter.ToString();
- }
+ RenderLoggingEvent(m_renderWriter, loggingEvent);
+ return m_renderWriter.ToString();
+ }
}
/// <summary>
@@ -732,27 +732,27 @@
/// </remarks>
protected void RenderLoggingEvent(TextWriter writer, LoggingEvent loggingEvent)
{
- if (m_layout == null)
+ if (m_layout == null)
{
throw new InvalidOperationException("A layout must be set");
}
- if (m_layout.IgnoresException)
+ if (m_layout.IgnoresException)
{
string exceptionStr = loggingEvent.GetExceptionString();
- if (exceptionStr != null && exceptionStr.Length > 0)
+ if (exceptionStr != null && exceptionStr.Length > 0)
{
// render the event and the exception
m_layout.Format(writer, loggingEvent);
writer.WriteLine(exceptionStr);
}
- else
+ else
{
// there is no exception to render
m_layout.Format(writer, loggingEvent);
}
}
- else
+ else
{
// The layout will render the exception
m_layout.Format(writer, loggingEvent);
@@ -783,16 +783,16 @@
#endregion
/// <summary>
- /// Flushes any buffered log data.
- /// </summary>
+ /// Flushes any buffered log data.
+ /// </summary>
/// <remarks>
/// This implementation doesn't flush anything and always returns true
/// </remarks>
- /// <returns><c>True</c> if all logging events were flushed successfully, else <c>false</c>.</returns>
- public virtual bool Flush(int millisecondsTimeout)
- {
- return true;
- }
+ /// <returns><c>True</c> if all logging events were flushed successfully, else <c>false</c>.</returns>
+ public virtual bool Flush(int millisecondsTimeout)
+ {
+ return true;
+ }
#region Private Instance Fields
@@ -893,17 +893,17 @@
#endregion
- #region Private Static Fields
+ #region Private Static Fields
- /// <summary>
- /// The fully qualified type of the AppenderSkeleton class.
- /// </summary>
- /// <remarks>
- /// Used by the internal logger to record the Type of the
- /// log message.
- /// </remarks>
- private static readonly Type declaringType = typeof(AppenderSkeleton);
+ /// <summary>
+ /// The fully qualified type of the AppenderSkeleton class.
+ /// </summary>
+ /// <remarks>
+ /// Used by the internal logger to record the Type of the
+ /// log message.
+ /// </remarks>
+ private static readonly Type declaringType = typeof(AppenderSkeleton);
- #endregion Private Static Fields
+ #endregion Private Static Fields
}
}
diff --git a/src/log4net/Appender/AspNetTraceAppender.cs b/src/log4net/Appender/AspNetTraceAppender.cs
index addd4c1..c478a49 100644
--- a/src/log4net/Appender/AspNetTraceAppender.cs
+++ b/src/log4net/Appender/AspNetTraceAppender.cs
@@ -27,7 +27,7 @@
using log4net.Layout;
using log4net.Core;
-namespace log4net.Appender
+namespace log4net.Appender
{
/// <summary>
/// <para>
@@ -48,13 +48,13 @@
/// <para>
/// The logging event is passed to the <see cref="M:TraceContext.Write(string)"/> or
/// <see cref="M:TraceContext.Warn(string)"/> method depending on the level of the logging event.
- /// The event's logger name is the default value for the category parameter of the Write/Warn method.
+ /// The event's logger name is the default value for the category parameter of the Write/Warn method.
/// </para>
/// </remarks>
/// <author>Nicko Cadell</author>
/// <author>Gert Driesen</author>
/// <author>Ron Grabowski</author>
- public class AspNetTraceAppender : AppenderSkeleton
+ public class AspNetTraceAppender : AppenderSkeleton
{
#region Public Instances Constructors
@@ -66,7 +66,7 @@
/// Default constructor.
/// </para>
/// </remarks>
- public AspNetTraceAppender()
+ public AspNetTraceAppender()
{
}
@@ -85,21 +85,21 @@
/// (<see cref="TraceContext"/>).
/// </para>
/// </remarks>
- protected override void Append(LoggingEvent loggingEvent)
+ protected override void Append(LoggingEvent loggingEvent)
{
// check if log4net is running in the context of an ASP.NET application
- if (HttpContext.Current != null)
+ if (HttpContext.Current != null)
{
// check if tracing is enabled for the current context
- if (HttpContext.Current.Trace.IsEnabled)
+ if (HttpContext.Current.Trace.IsEnabled)
{
- if (loggingEvent.Level >= Level.Warn)
+ if (loggingEvent.Level >= Level.Warn)
{
- HttpContext.Current.Trace.Warn(m_category.Format(loggingEvent), RenderLoggingEvent(loggingEvent));
+ HttpContext.Current.Trace.Warn(m_category.Format(loggingEvent), RenderLoggingEvent(loggingEvent));
}
- else
+ else
{
- HttpContext.Current.Trace.Write(m_category.Format(loggingEvent), RenderLoggingEvent(loggingEvent));
+ HttpContext.Current.Trace.Write(m_category.Format(loggingEvent), RenderLoggingEvent(loggingEvent));
}
}
}
@@ -121,35 +121,35 @@
#endregion // Override implementation of AppenderSkeleton
- #region Public Instance Properties
+ #region 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; }
- }
+ /// <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
+ #endregion
- #region Private Instance Fields
+ #region Private Instance Fields
- /// <summary>
- /// Defaults to %logger
- /// </summary>
- private PatternLayout m_category = new PatternLayout("%logger");
+ /// <summary>
+ /// Defaults to %logger
+ /// </summary>
+ private PatternLayout m_category = new PatternLayout("%logger");
- #endregion
+ #endregion
}
}
diff --git a/src/log4net/Appender/BufferingAppenderSkeleton.cs b/src/log4net/Appender/BufferingAppenderSkeleton.cs
index e8f8e49..5af27c8 100644
--- a/src/log4net/Appender/BufferingAppenderSkeleton.cs
+++ b/src/log4net/Appender/BufferingAppenderSkeleton.cs
@@ -69,7 +69,7 @@
/// </remarks>
/// <author>Nicko Cadell</author>
/// <author>Gert Driesen</author>
- public abstract class BufferingAppenderSkeleton : AppenderSkeleton
+ public abstract class BufferingAppenderSkeleton : AppenderSkeleton
{
#region Protected Instance Constructors
@@ -182,7 +182,7 @@
public ITriggeringEventEvaluator Evaluator
{
get { return m_evaluator; }
- set { m_evaluator = value; }
+ set { m_evaluator = value; }
}
/// <summary>
@@ -201,7 +201,7 @@
public ITriggeringEventEvaluator LossyEvaluator
{
get { return m_lossyEvaluator; }
- set { m_lossyEvaluator = value; }
+ set { m_lossyEvaluator = value; }
}
/// <summary>
@@ -225,8 +225,8 @@
public virtual bool OnlyFixPartialEventData
{
get { return (Fix == FixFlags.Partial); }
- set
- {
+ set
+ {
if (value)
{
Fix = FixFlags.Partial;
@@ -262,16 +262,16 @@
#region Public Methods
- /// <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)
- {
- Flush();
- return true;
- }
+ /// <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)
+ {
+ Flush();
+ return true;
+ }
/// <summary>
/// Flush the currently buffered events
@@ -316,7 +316,7 @@
// This method will be called outside of the AppenderSkeleton DoAppend() method
// therefore it needs to be protected by its own lock. This will block any
// Appends while the buffer is flushed.
- lock(this)
+ lock (this)
{
if (m_cb != null && m_cb.Length > 0)
{
@@ -331,7 +331,7 @@
LoggingEvent[] bufferedEvents = m_cb.PopAll();
ArrayList filteredEvents = new ArrayList(bufferedEvents.Length);
- foreach(LoggingEvent loggingEvent in bufferedEvents)
+ foreach (LoggingEvent loggingEvent in bufferedEvents)
{
if (m_lossyEvaluator.IsTriggeringEvent(loggingEvent))
{
@@ -381,7 +381,7 @@
/// <see cref="ActivateOptions"/> must be called again.
/// </para>
/// </remarks>
- public override void ActivateOptions()
+ public override void ActivateOptions()
{
base.ActivateOptions();
@@ -390,7 +390,7 @@
// therefore check we have an evaluator.
if (m_lossy && m_evaluator == null)
{
- ErrorHandler.Error("Appender ["+Name+"] is Lossy but has no Evaluator. The buffer will never be sent!");
+ ErrorHandler.Error("Appender [" + Name + "] is Lossy but has no Evaluator. The buffer will never be sent!");
}
if (m_bufferSize > 1)
@@ -417,7 +417,7 @@
/// the buffer must be sent when the appender is closed.
/// </para>
/// </remarks>
- protected override void OnClose()
+ protected override void OnClose()
{
// Flush the buffer on close
Flush(true);
@@ -453,7 +453,7 @@
/// is processed.
/// </para>
/// </remarks>
- protected override void Append(LoggingEvent loggingEvent)
+ protected override void Append(LoggingEvent loggingEvent)
{
// If the buffer size is set to 1 or less then the buffer will be
// sent immediately because there is not enough space in the buffer
@@ -462,8 +462,8 @@
if (m_cb == null || m_bufferSize <= 1)
{
// Only send the event if we are in non lossy mode or the event is a triggering event
- if ((!m_lossy) ||
- (m_evaluator != null && m_evaluator.IsTriggeringEvent(loggingEvent)) ||
+ if ((!m_lossy) ||
+ (m_evaluator != null && m_evaluator.IsTriggeringEvent(loggingEvent)) ||
(m_lossyEvaluator != null && m_lossyEvaluator.IsTriggeringEvent(loggingEvent)))
{
if (m_eventMustBeFixed)
@@ -473,7 +473,7 @@
}
// Not buffering events, send immediately
- SendBuffer(new LoggingEvent[] { loggingEvent } );
+ SendBuffer(new LoggingEvent[] { loggingEvent });
}
}
else
@@ -511,7 +511,7 @@
else if (discardedLoggingEvent != null)
{
// Just send the discarded event
- SendBuffer(new LoggingEvent[] { discardedLoggingEvent } );
+ SendBuffer(new LoggingEvent[] { discardedLoggingEvent });
}
}
}
@@ -552,7 +552,7 @@
}
else if (bufferEvents.Length == 0)
{
- SendBuffer(new LoggingEvent[] { firstLoggingEvent } );
+ SendBuffer(new LoggingEvent[] { firstLoggingEvent });
}
else
{
diff --git a/src/log4net/Appender/BufferingForwardingAppender.cs b/src/log4net/Appender/BufferingForwardingAppender.cs
index c228b22..360c8f9 100644
--- a/src/log4net/Appender/BufferingForwardingAppender.cs
+++ b/src/log4net/Appender/BufferingForwardingAppender.cs
@@ -77,7 +77,7 @@
protected override void OnClose()
{
// Remove all the attached appenders
- lock(this)
+ lock (this)
{
// Delegate to base, which will flush buffers
base.OnClose();
@@ -126,15 +126,15 @@
/// appenders, then it won't be added again.
/// </para>
/// </remarks>
- public virtual void AddAppender(IAppender newAppender)
+ public virtual void AddAppender(IAppender newAppender)
{
if (newAppender == null)
{
throw new ArgumentNullException("newAppender");
}
- lock(this)
+ lock (this)
{
- if (m_appenderAttachedImpl == null)
+ if (m_appenderAttachedImpl == null)
{
m_appenderAttachedImpl = new log4net.Util.AppenderAttachedImpl();
}
@@ -157,13 +157,13 @@
{
get
{
- lock(this)
+ lock (this)
{
if (m_appenderAttachedImpl == null)
{
return AppenderCollection.EmptyCollection;
}
- else
+ else
{
return m_appenderAttachedImpl.Appenders;
}
@@ -183,9 +183,9 @@
/// Get the named appender attached to this buffering appender.
/// </para>
/// </remarks>
- public virtual IAppender GetAppender(string name)
+ public virtual IAppender GetAppender(string name)
{
- lock(this)
+ lock (this)
{
if (m_appenderAttachedImpl == null || name == null)
{
@@ -204,11 +204,11 @@
/// This is useful when re-reading configuration information.
/// </para>
/// </remarks>
- public virtual void RemoveAllAppenders()
+ public virtual void RemoveAllAppenders()
{
- lock(this)
+ lock (this)
{
- if (m_appenderAttachedImpl != null)
+ if (m_appenderAttachedImpl != null)
{
m_appenderAttachedImpl.RemoveAllAppenders();
m_appenderAttachedImpl = null;
@@ -226,11 +226,11 @@
/// If you are discarding the appender you must call
/// <see cref="IAppender.Close"/> on the appender removed.
/// </remarks>
- public virtual IAppender RemoveAppender(IAppender appender)
+ public virtual IAppender RemoveAppender(IAppender appender)
{
- lock(this)
+ lock (this)
{
- if (appender != null && m_appenderAttachedImpl != null)
+ if (appender != null && m_appenderAttachedImpl != null)
{
return m_appenderAttachedImpl.RemoveAppender(appender);
}
@@ -248,9 +248,9 @@
/// If you are discarding the appender you must call
/// <see cref="IAppender.Close"/> on the appender removed.
/// </remarks>
- public virtual IAppender RemoveAppender(string name)
+ public virtual IAppender RemoveAppender(string name)
{
- lock(this)
+ lock (this)
{
if (name != null && m_appenderAttachedImpl != null)
{
@@ -259,7 +259,7 @@
}
return null;
}
-
+
#endregion Implementation of IAppenderAttachable
#region Private Instance Fields
diff --git a/src/log4net/Appender/ColoredConsoleAppender.cs b/src/log4net/Appender/ColoredConsoleAppender.cs
index c90cf5f..00a07d2 100644
--- a/src/log4net/Appender/ColoredConsoleAppender.cs
+++ b/src/log4net/Appender/ColoredConsoleAppender.cs
@@ -162,7 +162,7 @@
/// The instance of the <see cref="ColoredConsoleAppender" /> class is set up to write
/// to the standard output stream.
/// </remarks>
- public ColoredConsoleAppender()
+ public ColoredConsoleAppender()
{
}
@@ -192,7 +192,7 @@
/// output stream.
/// </remarks>
[Obsolete("Instead use the default constructor and set the Layout & Target properties")]
- public ColoredConsoleAppender(ILayout layout, bool writeToErrorStream)
+ public ColoredConsoleAppender(ILayout layout, bool writeToErrorStream)
{
Layout = layout;
m_writeToErrorStream = writeToErrorStream;
@@ -222,12 +222,12 @@
set
{
string v = value.Trim();
-
- if (string.Compare(ConsoleError, v, true, CultureInfo.InvariantCulture) == 0)
+
+ if (string.Compare(ConsoleError, v, true, CultureInfo.InvariantCulture) == 0)
{
m_writeToErrorStream = true;
- }
- else
+ }
+ else
{
m_writeToErrorStream = false;
}
@@ -270,7 +270,7 @@
[System.Security.SecuritySafeCritical]
#endif
[System.Security.Permissions.SecurityPermission(System.Security.Permissions.SecurityAction.Demand, UnmanagedCode = true)]
- protected override void Append(log4net.Core.LoggingEvent loggingEvent)
+ protected override void Append(log4net.Core.LoggingEvent loggingEvent)
{
if (m_consoleOutputWriter != null)
{
@@ -391,7 +391,7 @@
bool appendNewline = false;
// Trim off last newline, if it exists
- if (arrayLength > 1 && messageCharArray[arrayLength-2] == '\r' && messageCharArray[arrayLength-1] == '\n')
+ if (arrayLength > 1 && messageCharArray[arrayLength - 2] == '\r' && messageCharArray[arrayLength - 1] == '\n')
{
arrayLength -= 2;
appendNewline = true;
@@ -411,7 +411,7 @@
}
}
- private static readonly char[] s_windowsNewline = {'\r', '\n'};
+ private static readonly char[] s_windowsNewline = { '\r', '\n' };
/// <summary>
/// This appender requires a <see cref="Layout"/> to be set.
@@ -529,59 +529,59 @@
#region Win32 Methods
- [DllImport("Kernel32.dll", SetLastError=true, CharSet=CharSet.Auto)]
+ [DllImport("Kernel32.dll", SetLastError = true, CharSet = CharSet.Auto)]
private static extern int GetConsoleOutputCP();
- [DllImport("Kernel32.dll", SetLastError=true, CharSet=CharSet.Auto)]
+ [DllImport("Kernel32.dll", SetLastError = true, CharSet = CharSet.Auto)]
private static extern bool SetConsoleTextAttribute(
IntPtr consoleHandle,
ushort attributes);
- [DllImport("Kernel32.dll", SetLastError=true, CharSet=CharSet.Auto)]
+ [DllImport("Kernel32.dll", SetLastError = true, CharSet = CharSet.Auto)]
private static extern bool GetConsoleScreenBufferInfo(
IntPtr consoleHandle,
out CONSOLE_SCREEN_BUFFER_INFO bufferInfo);
-// [DllImport("Kernel32.dll", SetLastError=true, CharSet=CharSet.Unicode)]
-// private static extern bool WriteConsoleW(
-// IntPtr hConsoleHandle,
-// [MarshalAs(UnmanagedType.LPWStr)] string strBuffer,
-// UInt32 bufferLen,
-// out UInt32 written,
-// IntPtr reserved);
+ // [DllImport("Kernel32.dll", SetLastError=true, CharSet=CharSet.Unicode)]
+ // private static extern bool WriteConsoleW(
+ // IntPtr hConsoleHandle,
+ // [MarshalAs(UnmanagedType.LPWStr)] string strBuffer,
+ // UInt32 bufferLen,
+ // out UInt32 written,
+ // IntPtr reserved);
//private const UInt32 STD_INPUT_HANDLE = unchecked((UInt32)(-10));
private const UInt32 STD_OUTPUT_HANDLE = unchecked((UInt32)(-11));
private const UInt32 STD_ERROR_HANDLE = unchecked((UInt32)(-12));
- [DllImport("Kernel32.dll", SetLastError=true, CharSet=CharSet.Auto)]
+ [DllImport("Kernel32.dll", SetLastError = true, CharSet = CharSet.Auto)]
private static extern IntPtr GetStdHandle(
UInt32 type);
[StructLayout(LayoutKind.Sequential)]
- private struct COORD
+ private struct COORD
{
- public UInt16 x;
- public UInt16 y;
+ public UInt16 x;
+ public UInt16 y;
}
[StructLayout(LayoutKind.Sequential)]
- private struct SMALL_RECT
+ private struct SMALL_RECT
{
- public UInt16 Left;
- public UInt16 Top;
- public UInt16 Right;
- public UInt16 Bottom;
+ public UInt16 Left;
+ public UInt16 Top;
+ public UInt16 Right;
+ public UInt16 Bottom;
}
[StructLayout(LayoutKind.Sequential)]
- private struct CONSOLE_SCREEN_BUFFER_INFO
- {
- public COORD dwSize;
- public COORD dwCursorPosition;
- public ushort wAttributes;
- public SMALL_RECT srWindow;
- public COORD dwMaximumWindowSize;
+ private struct CONSOLE_SCREEN_BUFFER_INFO
+ {
+ public COORD dwSize;
+ public COORD dwCursorPosition;
+ public ushort wAttributes;
+ public SMALL_RECT srWindow;
+ public COORD dwMaximumWindowSize;
}
#endregion // Win32 Methods
@@ -644,7 +644,7 @@
public override void ActivateOptions()
{
base.ActivateOptions();
- m_combinedColor = (ushort)( (int)m_foreColor + (((int)m_backColor) << 4) );
+ m_combinedColor = (ushort)((int)m_foreColor + (((int)m_backColor) << 4));
}
/// <summary>
diff --git a/src/log4net/Appender/ConsoleAppender.cs b/src/log4net/Appender/ConsoleAppender.cs
index 7964391..a7299ee 100644
--- a/src/log4net/Appender/ConsoleAppender.cs
+++ b/src/log4net/Appender/ConsoleAppender.cs
@@ -61,7 +61,7 @@
/// The instance of the <see cref="ConsoleAppender" /> class is set up to write
/// to the standard output stream.
/// </remarks>
- public ConsoleAppender()
+ public ConsoleAppender()
{
}
@@ -91,7 +91,7 @@
/// output stream.
/// </remarks>
[Obsolete("Instead use the default constructor and set the Layout & Target properties")]
- public ConsoleAppender(ILayout layout, bool writeToErrorStream)
+ public ConsoleAppender(ILayout layout, bool writeToErrorStream)
{
Layout = layout;
m_writeToErrorStream = writeToErrorStream;
@@ -125,8 +125,8 @@
if (SystemInfo.EqualsIgnoringCase(ConsoleError, v))
{
m_writeToErrorStream = true;
- }
- else
+ }
+ else
{
m_writeToErrorStream = false;
}
@@ -149,7 +149,7 @@
/// The format of the output will depend on the appender's layout.
/// </para>
/// </remarks>
- protected override void Append(LoggingEvent loggingEvent)
+ protected override void Append(LoggingEvent loggingEvent)
{
#if NETCF_1_0
// Write to the output stream
diff --git a/src/log4net/Appender/DebugAppender.cs b/src/log4net/Appender/DebugAppender.cs
index 668d622..9aa9e97 100644
--- a/src/log4net/Appender/DebugAppender.cs
+++ b/src/log4net/Appender/DebugAppender.cs
@@ -75,7 +75,7 @@
#endregion Public Instance Constructors
#region Public Instance Properties
-
+
#if !NETSTANDARD1_3 // System.Diagnostics.Debug has no Flush() in netstandard1.3
/// <summary>
/// Gets or sets a value that indicates whether the appender will
@@ -102,45 +102,45 @@
}
#endif // !NETSTANDARD1_3
- /// <summary>
- /// Formats the category parameter sent to the Debug method.
- /// </summary>
- /// <remarks>
- /// <para>
- /// Defaults to a <see cref="Layout.PatternLayout"/> with %logger as the pattern 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; }
- }
-
+ /// <summary>
+ /// Formats the category parameter sent to the Debug method.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Defaults to a <see cref="Layout.PatternLayout"/> with %logger as the pattern 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
#if !NETSTANDARD1_3
- /// <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;
+ /// <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.Debug is thread-safe, so no need for lock(this).
- System.Diagnostics.Debug.Flush();
+ // System.Diagnostics.Debug is thread-safe, so no need for lock(this).
+ System.Diagnostics.Debug.Flush();
- return true;
- }
+ return true;
+ }
#endif
#region Override implementation of AppenderSkeleton
-
+
#if NETSTANDARD1_3
/// <summary>
/// Writes the logging event to the <see cref="System.Diagnostics.Debug"/> system.
@@ -169,30 +169,30 @@
//
// Write the string to the Debug system
//
- if(m_category == null)
- {
- System.Diagnostics.Debug.Write(RenderLoggingEvent(loggingEvent));
- }
- else
- {
- string category = m_category.Format(loggingEvent);
- if (string.IsNullOrEmpty(category))
- {
- System.Diagnostics.Debug.Write(RenderLoggingEvent(loggingEvent));
- }
- else
- {
- System.Diagnostics.Debug.Write(RenderLoggingEvent(loggingEvent), category);
- }
- }
+ if (m_category == null)
+ {
+ System.Diagnostics.Debug.Write(RenderLoggingEvent(loggingEvent));
+ }
+ else
+ {
+ string category = m_category.Format(loggingEvent);
+ if (string.IsNullOrEmpty(category))
+ {
+ System.Diagnostics.Debug.Write(RenderLoggingEvent(loggingEvent));
+ }
+ else
+ {
+ System.Diagnostics.Debug.Write(RenderLoggingEvent(loggingEvent), category);
+ }
+ }
#if !NETSTANDARD1_3
//
// Flush the Debug system if needed
//
- if (m_immediateFlush)
+ if (m_immediateFlush)
{
System.Diagnostics.Debug.Flush();
- }
+ }
#endif
}
@@ -213,8 +213,8 @@
#endregion Override implementation of AppenderSkeleton
#region Private Instance Fields
-
-#if !NETSTANDARD1_3
+
+#if !NETSTANDARD1_3
/// <summary>
/// Immediate flush means that the underlying writer or output stream
/// will be flushed at the end of each append operation.
@@ -233,10 +233,10 @@
private bool m_immediateFlush = true;
#endif
- /// <summary>
- /// Defaults to a <see cref="Layout.PatternLayout"/> with %logger as the pattern.
- /// </summary>
- private PatternLayout m_category = new PatternLayout("%logger");
+ /// <summary>
+ /// Defaults to a <see cref="Layout.PatternLayout"/> with %logger as the pattern.
+ /// </summary>
+ private PatternLayout m_category = new PatternLayout("%logger");
#endregion Private Instance Fields
}
diff --git a/src/log4net/Appender/EventLogAppender.cs b/src/log4net/Appender/EventLogAppender.cs
index 2de708b..f87a7bc 100644
--- a/src/log4net/Appender/EventLogAppender.cs
+++ b/src/log4net/Appender/EventLogAppender.cs
@@ -40,17 +40,17 @@
/// Writes events to the system event log.
/// </summary>
/// <remarks>
- /// <para>
- /// The appender will fail if you try to write using an event source that doesn't exist unless it is running with local administrator privileges.
- /// See also http://logging.apache.org/log4net/release/faq.html#trouble-EventLog
- /// </para>
+ /// <para>
+ /// The appender will fail if you try to write using an event source that doesn't exist unless it is running with local administrator privileges.
+ /// See also http://logging.apache.org/log4net/release/faq.html#trouble-EventLog
+ /// </para>
/// <para>
/// The <c>EventID</c> of the event log entry can be
/// set using the <c>EventID</c> property (<see cref="LoggingEvent.Properties"/>)
/// on the <see cref="LoggingEvent"/>.
/// </para>
- /// <para>
- /// The <c>Category</c> of the event log entry can be
+ /// <para>
+ /// The <c>Category</c> of the event log entry can be
/// set using the <c>Category</c> property (<see cref="LoggingEvent.Properties"/>)
/// on the <see cref="LoggingEvent"/>.
/// </para>
@@ -100,9 +100,9 @@
/// </remarks>
public EventLogAppender()
{
- m_applicationName = System.Threading.Thread.GetDomain().FriendlyName;
- m_logName = "Application"; // Defaults to application log
- m_machineName = "."; // Only log on the local machine
+ m_applicationName = System.Threading.Thread.GetDomain().FriendlyName;
+ m_logName = "Application"; // Defaults to application log
+ m_machineName = "."; // Only log on the local machine
}
/// <summary>
@@ -216,46 +216,47 @@
/// of the current thread.
/// </para>
/// </remarks>
- public SecurityContext SecurityContext
+ public SecurityContext SecurityContext
{
get { return m_securityContext; }
set { m_securityContext = value; }
}
- /// <summary>
- /// Gets or sets the <c>EventId</c> to use unless one is explicitly specified via the <c>LoggingEvent</c>'s properties.
- /// </summary>
- /// <remarks>
- /// <para>
- /// The <c>EventID</c> of the event log entry will normally be
- /// set using the <c>EventID</c> property (<see cref="LoggingEvent.Properties"/>)
- /// on the <see cref="LoggingEvent"/>.
- /// This property provides the fallback value which defaults to 0.
- /// </para>
- /// </remarks>
- public int EventId {
- get { return m_eventId; }
- set { m_eventId = value; }
- }
+ /// <summary>
+ /// Gets or sets the <c>EventId</c> to use unless one is explicitly specified via the <c>LoggingEvent</c>'s properties.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// The <c>EventID</c> of the event log entry will normally be
+ /// set using the <c>EventID</c> property (<see cref="LoggingEvent.Properties"/>)
+ /// on the <see cref="LoggingEvent"/>.
+ /// This property provides the fallback value which defaults to 0.
+ /// </para>
+ /// </remarks>
+ public int EventId
+ {
+ get { return m_eventId; }
+ set { m_eventId = value; }
+ }
- /// <summary>
- /// Gets or sets the <c>Category</c> to use unless one is explicitly specified via the <c>LoggingEvent</c>'s properties.
- /// </summary>
- /// <remarks>
- /// <para>
- /// The <c>Category</c> of the event log entry will normally be
- /// set using the <c>Category</c> property (<see cref="LoggingEvent.Properties"/>)
- /// on the <see cref="LoggingEvent"/>.
- /// This property provides the fallback value which defaults to 0.
- /// </para>
- /// </remarks>
- public short Category
- {
- get { return m_category; }
- set { m_category = value; }
- }
- #endregion // Public Instance Properties
+ /// <summary>
+ /// Gets or sets the <c>Category</c> to use unless one is explicitly specified via the <c>LoggingEvent</c>'s properties.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// The <c>Category</c> of the event log entry will normally be
+ /// set using the <c>Category</c> property (<see cref="LoggingEvent.Properties"/>)
+ /// on the <see cref="LoggingEvent"/>.
+ /// This property provides the fallback value which defaults to 0.
+ /// </para>
+ /// </remarks>
+ public short Category
+ {
+ get { return m_category; }
+ set { m_category = value; }
+ }
+ #endregion // Public Instance Properties
#region Implementation of IOptionHandler
@@ -275,73 +276,74 @@
/// <see cref="ActivateOptions"/> must be called again.
/// </para>
/// </remarks>
- public override void ActivateOptions()
+ public override void ActivateOptions()
{
- try
- {
- base.ActivateOptions();
+ try
+ {
+ base.ActivateOptions();
- if (m_securityContext == null)
- {
- m_securityContext = SecurityContextProvider.DefaultProvider.CreateSecurityContext(this);
- }
+ if (m_securityContext == null)
+ {
+ m_securityContext = SecurityContextProvider.DefaultProvider.CreateSecurityContext(this);
+ }
- bool sourceAlreadyExists = false;
- string currentLogName = null;
+ bool sourceAlreadyExists = false;
+ string currentLogName = null;
- using (SecurityContext.Impersonate(this))
- {
- sourceAlreadyExists = EventLog.SourceExists(m_applicationName);
- if (sourceAlreadyExists) {
- currentLogName = EventLog.LogNameFromSourceName(m_applicationName, m_machineName);
- }
- }
+ using (SecurityContext.Impersonate(this))
+ {
+ sourceAlreadyExists = EventLog.SourceExists(m_applicationName);
+ if (sourceAlreadyExists)
+ {
+ currentLogName = EventLog.LogNameFromSourceName(m_applicationName, m_machineName);
+ }
+ }
- if (sourceAlreadyExists && currentLogName != m_logName)
- {
- LogLog.Debug(declaringType, "Changing event source [" + m_applicationName + "] from log [" + currentLogName + "] to log [" + m_logName + "]");
- }
- else if (!sourceAlreadyExists)
- {
- LogLog.Debug(declaringType, "Creating event source Source [" + m_applicationName + "] in log " + m_logName + "]");
- }
+ if (sourceAlreadyExists && currentLogName != m_logName)
+ {
+ LogLog.Debug(declaringType, "Changing event source [" + m_applicationName + "] from log [" + currentLogName + "] to log [" + m_logName + "]");
+ }
+ else if (!sourceAlreadyExists)
+ {
+ LogLog.Debug(declaringType, "Creating event source Source [" + m_applicationName + "] in log " + m_logName + "]");
+ }
- string registeredLogName = null;
+ string registeredLogName = null;
- using (SecurityContext.Impersonate(this))
- {
- if (sourceAlreadyExists && currentLogName != m_logName)
- {
- //
- // Re-register this to the current application if the user has changed
- // the application / logfile association
- //
- EventLog.DeleteEventSource(m_applicationName, m_machineName);
- CreateEventSource(m_applicationName, m_logName, m_machineName);
+ using (SecurityContext.Impersonate(this))
+ {
+ if (sourceAlreadyExists && currentLogName != m_logName)
+ {
+ //
+ // Re-register this to the current application if the user has changed
+ // the application / logfile association
+ //
+ EventLog.DeleteEventSource(m_applicationName, m_machineName);
+ CreateEventSource(m_applicationName, m_logName, m_machineName);
- registeredLogName = EventLog.LogNameFromSourceName(m_applicationName, m_machineName);
- }
- else if (!sourceAlreadyExists)
- {
- CreateEventSource(m_applicationName, m_logName, m_machineName);
+ registeredLogName = EventLog.LogNameFromSourceName(m_applicationName, m_machineName);
+ }
+ else if (!sourceAlreadyExists)
+ {
+ CreateEventSource(m_applicationName, m_logName, m_machineName);
- registeredLogName = EventLog.LogNameFromSourceName(m_applicationName, m_machineName);
- }
- }
+ registeredLogName = EventLog.LogNameFromSourceName(m_applicationName, m_machineName);
+ }
+ }
- m_levelMapping.ActivateOptions();
+ m_levelMapping.ActivateOptions();
- LogLog.Debug(declaringType, "Source [" + m_applicationName + "] is registered to log [" + registeredLogName + "]");
- }
- catch (System.Security.SecurityException ex)
- {
- ErrorHandler.Error("Caught a SecurityException trying to access the EventLog. Most likely the event source "
- + m_applicationName
- + " doesn't exist and must be created by a local administrator. Will disable EventLogAppender."
- + " See http://logging.apache.org/log4net/release/faq.html#trouble-EventLog",
- ex);
- Threshold = Level.Off;
- }
+ LogLog.Debug(declaringType, "Source [" + m_applicationName + "] is registered to log [" + registeredLogName + "]");
+ }
+ catch (System.Security.SecurityException ex)
+ {
+ ErrorHandler.Error("Caught a SecurityException trying to access the EventLog. Most likely the event source "
+ + m_applicationName
+ + " doesn't exist and must be created by a local administrator. Will disable EventLogAppender."
+ + " See http://logging.apache.org/log4net/release/faq.html#trouble-EventLog",
+ ex);
+ Threshold = Level.Off;
+ }
}
#endregion // Implementation of IOptionHandler
@@ -362,7 +364,7 @@
EventLog.CreateEventSource(source, logName, machineName);
#endif
}
-
+
#region Override implementation of AppenderSkeleton
/// <summary>
@@ -381,7 +383,7 @@
/// There is a limit of 32K characters for an event log message
/// </para>
/// </remarks>
- protected override void Append(LoggingEvent loggingEvent)
+ protected override void Append(LoggingEvent loggingEvent)
{
//
// Write the resulting string to the event log system
@@ -399,10 +401,10 @@
else
{
string eventIDPropertyString = eventIDPropertyObj as string;
- if (eventIDPropertyString == null)
- {
- eventIDPropertyString = eventIDPropertyObj.ToString();
- }
+ if (eventIDPropertyString == null)
+ {
+ eventIDPropertyString = eventIDPropertyObj.ToString();
+ }
if (eventIDPropertyString != null && eventIDPropertyString.Length > 0)
{
// Read the string property into a number
@@ -419,37 +421,37 @@
}
}
- short category = m_category;
- // Look for the Category property
- object categoryPropertyObj = loggingEvent.LookupProperty("Category");
- if (categoryPropertyObj != null)
+ short category = m_category;
+ // Look for the Category property
+ object categoryPropertyObj = loggingEvent.LookupProperty("Category");
+ if (categoryPropertyObj != null)
+ {
+ if (categoryPropertyObj is short)
+ {
+ category = (short)categoryPropertyObj;
+ }
+ else
+ {
+ string categoryPropertyString = categoryPropertyObj as string;
+ if (categoryPropertyString == null)
+ {
+ categoryPropertyString = categoryPropertyObj.ToString();
+ }
+ if (categoryPropertyString != null && categoryPropertyString.Length > 0)
+ {
+ // Read the string property into a number
+ short shortVal;
+ if (SystemInfo.TryParse(categoryPropertyString, out shortVal))
{
- if (categoryPropertyObj is short)
- {
- category = (short) categoryPropertyObj;
- }
- else
- {
- string categoryPropertyString = categoryPropertyObj as string;
- if (categoryPropertyString == null)
- {
- categoryPropertyString = categoryPropertyObj.ToString();
- }
- if (categoryPropertyString != null && categoryPropertyString.Length > 0)
- {
- // Read the string property into a number
- short shortVal;
- if (SystemInfo.TryParse(categoryPropertyString, out shortVal))
- {
- category = shortVal;
- }
- else
- {
- ErrorHandler.Error("Unable to parse event category property [" + categoryPropertyString + "].");
- }
- }
- }
+ category = shortVal;
}
+ else
+ {
+ ErrorHandler.Error("Unable to parse event category property [" + categoryPropertyString + "].");
+ }
+ }
+ }
+ }
// Write to the event log
try
@@ -464,16 +466,16 @@
EventLogEntryType entryType = GetEntryType(loggingEvent.Level);
- using(SecurityContext.Impersonate(this))
+ using (SecurityContext.Impersonate(this))
{
EventLog.WriteEntry(m_applicationName, eventTxt, entryType, eventID, category);
}
}
- catch(Exception ex)
+ catch (Exception ex)
{
ErrorHandler.Error("Unable to write to event log [" + m_logName + "] using source [" + m_applicationName + "]", ex);
}
- }
+ }
/// <summary>
/// This appender requires a <see cref="Layout"/> to be set.
@@ -515,14 +517,14 @@
// Use default behavior
- if (level >= Level.Error)
+ if (level >= Level.Error)
{
return EventLogEntryType.Error;
}
- else if (level == Level.Warn)
+ else if (level == Level.Warn)
{
return EventLogEntryType.Warning;
- }
+ }
// Default setting
return EventLogEntryType.Information;
@@ -560,17 +562,17 @@
/// </summary>
private SecurityContext m_securityContext;
- /// <summary>
- /// The event ID to use unless one is explicitly specified via the <c>LoggingEvent</c>'s properties.
- /// </summary>
- private int m_eventId = 0;
+ /// <summary>
+ /// The event ID to use unless one is explicitly specified via the <c>LoggingEvent</c>'s properties.
+ /// </summary>
+ private int m_eventId = 0;
- /// <summary>
- /// The event category to use unless one is explicitly specified via the <c>LoggingEvent</c>'s properties.
- /// </summary>
- private short m_category = 0;
+ /// <summary>
+ /// The event category to use unless one is explicitly specified via the <c>LoggingEvent</c>'s properties.
+ /// </summary>
+ private short m_category = 0;
- #endregion // Private Instance Fields
+ #endregion // Private Instance Fields
#region Level2EventLogEntryType LevelMapping Entry
@@ -605,16 +607,16 @@
#endregion // LevelColors LevelMapping Entry
- #region Private Static Fields
+ #region Private Static Fields
- /// <summary>
- /// The fully qualified type of the EventLogAppender class.
- /// </summary>
- /// <remarks>
- /// Used by the internal logger to record the Type of the
- /// log message.
- /// </remarks>
- private static readonly Type declaringType = typeof(EventLogAppender);
+ /// <summary>
+ /// The fully qualified type of the EventLogAppender class.
+ /// </summary>
+ /// <remarks>
+ /// Used by the internal logger to record the Type of the
+ /// log message.
+ /// </remarks>
+ private static readonly Type declaringType = typeof(EventLogAppender);
/// <summary>
/// The maximum size supported by default.
@@ -684,7 +686,7 @@
return MAX_EVENTLOG_MESSAGE_SIZE_DEFAULT;
}
- #endregion Private Static Fields
+ #endregion Private Static Fields
}
}
diff --git a/src/log4net/Appender/FileAppender.cs b/src/log4net/Appender/FileAppender.cs
index a9cce8e..4179190 100644
--- a/src/log4net/Appender/FileAppender.cs
+++ b/src/log4net/Appender/FileAppender.cs
@@ -36,54 +36,54 @@
namespace log4net.Appender
{
#if !NETCF
- /// <summary>
- /// Appends logging events to a file.
- /// </summary>
- /// <remarks>
- /// <para>
- /// Logging events are sent to the file specified by
- /// the <see cref="File"/> property.
- /// </para>
- /// <para>
- /// The file can be opened in either append or overwrite mode
- /// by specifying the <see cref="AppendToFile"/> property.
- /// If the file path is relative it is taken as relative from
- /// the application base directory. The file encoding can be
- /// specified by setting the <see cref="Encoding"/> property.
- /// </para>
- /// <para>
- /// The layout's <see cref="ILayout.Header"/> and <see cref="ILayout.Footer"/>
- /// values will be written each time the file is opened and closed
- /// respectively. If the <see cref="AppendToFile"/> property is <see langword="true"/>
- /// then the file may contain multiple copies of the header and footer.
- /// </para>
- /// <para>
- /// This appender will first try to open the file for writing when <see cref="ActivateOptions"/>
- /// is called. This will typically be during configuration.
- /// If the file cannot be opened for writing the appender will attempt
- /// to open the file again each time a message is logged to the appender.
- /// If the file cannot be opened for writing when a message is logged then
- /// the message will be discarded by this appender.
- /// </para>
- /// <para>
- /// The <see cref="FileAppender"/> supports pluggable file locking models via
- /// the <see cref="LockingModel"/> property.
- /// The default behavior, implemented by <see cref="FileAppender.ExclusiveLock"/>
- /// is to obtain an exclusive write lock on the file until this appender is closed.
- /// The alternative models only hold a
- /// write lock while the appender is writing a logging event (<see cref="FileAppender.MinimalLock"/>)
- /// or synchronize by using a named system wide Mutex (<see cref="FileAppender.InterProcessLock"/>).
- /// </para>
- /// <para>
- /// All locking strategies have issues and you should seriously consider using a different strategy that
- /// avoids having multiple processes logging to the same file.
- /// </para>
- /// </remarks>
- /// <author>Nicko Cadell</author>
- /// <author>Gert Driesen</author>
- /// <author>Rodrigo B. de Oliveira</author>
- /// <author>Douglas de la Torre</author>
- /// <author>Niall Daley</author>
+ /// <summary>
+ /// Appends logging events to a file.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Logging events are sent to the file specified by
+ /// the <see cref="File"/> property.
+ /// </para>
+ /// <para>
+ /// The file can be opened in either append or overwrite mode
+ /// by specifying the <see cref="AppendToFile"/> property.
+ /// If the file path is relative it is taken as relative from
+ /// the application base directory. The file encoding can be
+ /// specified by setting the <see cref="Encoding"/> property.
+ /// </para>
+ /// <para>
+ /// The layout's <see cref="ILayout.Header"/> and <see cref="ILayout.Footer"/>
+ /// values will be written each time the file is opened and closed
+ /// respectively. If the <see cref="AppendToFile"/> property is <see langword="true"/>
+ /// then the file may contain multiple copies of the header and footer.
+ /// </para>
+ /// <para>
+ /// This appender will first try to open the file for writing when <see cref="ActivateOptions"/>
+ /// is called. This will typically be during configuration.
+ /// If the file cannot be opened for writing the appender will attempt
+ /// to open the file again each time a message is logged to the appender.
+ /// If the file cannot be opened for writing when a message is logged then
+ /// the message will be discarded by this appender.
+ /// </para>
+ /// <para>
+ /// The <see cref="FileAppender"/> supports pluggable file locking models via
+ /// the <see cref="LockingModel"/> property.
+ /// The default behavior, implemented by <see cref="FileAppender.ExclusiveLock"/>
+ /// is to obtain an exclusive write lock on the file until this appender is closed.
+ /// The alternative models only hold a
+ /// write lock while the appender is writing a logging event (<see cref="FileAppender.MinimalLock"/>)
+ /// or synchronize by using a named system wide Mutex (<see cref="FileAppender.InterProcessLock"/>).
+ /// </para>
+ /// <para>
+ /// All locking strategies have issues and you should seriously consider using a different strategy that
+ /// avoids having multiple processes logging to the same file.
+ /// </para>
+ /// </remarks>
+ /// <author>Nicko Cadell</author>
+ /// <author>Gert Driesen</author>
+ /// <author>Rodrigo B. de Oliveira</author>
+ /// <author>Douglas de la Torre</author>
+ /// <author>Niall Daley</author>
#else
/// <summary>
/// Appends logging events to a file.
@@ -133,57 +133,57 @@
/// <author>Douglas de la Torre</author>
/// <author>Niall Daley</author>
#endif
- public class FileAppender : TextWriterAppender
+ public class FileAppender : TextWriterAppender
+ {
+ #region LockingStream Inner Class
+
+ /// <summary>
+ /// Write only <see cref="Stream"/> that uses the <see cref="LockingModelBase"/>
+ /// to manage access to an underlying resource.
+ /// </summary>
+ private sealed class LockingStream : Stream, IDisposable
{
- #region LockingStream Inner Class
-
- /// <summary>
- /// Write only <see cref="Stream"/> that uses the <see cref="LockingModelBase"/>
- /// to manage access to an underlying resource.
- /// </summary>
- private sealed class LockingStream : Stream, IDisposable
- {
#if !NETCR
- [Serializable]
+ [Serializable]
#endif
- public sealed class LockStateException : LogException
- {
- public LockStateException(string message)
- : base(message)
- {
- }
+ public sealed class LockStateException : LogException
+ {
+ public LockStateException(string message)
+ : base(message)
+ {
+ }
- public LockStateException()
- {
- }
+ public LockStateException()
+ {
+ }
- public LockStateException(string message, Exception innerException) : base(message, innerException)
- {
- }
+ public LockStateException(string message, Exception innerException) : base(message, innerException)
+ {
+ }
#if !NETCR && !NETSTANDARD1_3
- private LockStateException(SerializationInfo info, StreamingContext context) : base(info, context)
- {
- }
+ private LockStateException(SerializationInfo info, StreamingContext context) : base(info, context)
+ {
+ }
#endif
- }
+ }
- private Stream m_realStream = null;
- private LockingModelBase m_lockingModel = null;
- private int m_lockLevel = 0;
+ private Stream m_realStream = null;
+ private LockingModelBase m_lockingModel = null;
+ private int m_lockLevel = 0;
- public LockingStream(LockingModelBase locking)
- : base()
- {
- if (locking == null)
- {
- throw new ArgumentException("Locking model may not be null", "locking");
- }
+ public LockingStream(LockingModelBase locking)
+ : base()
+ {
+ if (locking == null)
+ {
+ throw new ArgumentException("Locking model may not be null", "locking");
+ }
- m_lockingModel = locking;
- }
+ m_lockingModel = locking;
+ }
- #region Override Implementation of Stream
+ #region Override Implementation of Stream
#if NETSTANDARD
protected override void Dispose(bool disposing)
@@ -193,51 +193,51 @@
}
#else
- private int m_readTotal = -1;
+ private int m_readTotal = -1;
- // Methods
- public override IAsyncResult BeginRead(byte[] buffer,
- int offset,
- int count,
- AsyncCallback callback,
- object state)
- {
- AssertLocked();
- IAsyncResult ret = m_realStream.BeginRead(buffer, offset, count, callback, state);
- m_readTotal = EndRead(ret);
- return ret;
- }
+ // Methods
+ public override IAsyncResult BeginRead(byte[] buffer,
+ int offset,
+ int count,
+ AsyncCallback callback,
+ object state)
+ {
+ AssertLocked();
+ IAsyncResult ret = m_realStream.BeginRead(buffer, offset, count, callback, state);
+ m_readTotal = EndRead(ret);
+ return ret;
+ }
- /// <summary>
- /// True asynchronous writes are not supported, the implementation forces a synchronous write.
- /// </summary>
- public override IAsyncResult BeginWrite(byte[] buffer,
- int offset,
- int count,
- AsyncCallback callback,
- object state)
- {
- AssertLocked();
- IAsyncResult ret = m_realStream.BeginWrite(buffer, offset, count, callback, state);
- EndWrite(ret);
- return ret;
- }
+ /// <summary>
+ /// True asynchronous writes are not supported, the implementation forces a synchronous write.
+ /// </summary>
+ public override IAsyncResult BeginWrite(byte[] buffer,
+ int offset,
+ int count,
+ AsyncCallback callback,
+ object state)
+ {
+ AssertLocked();
+ IAsyncResult ret = m_realStream.BeginWrite(buffer, offset, count, callback, state);
+ EndWrite(ret);
+ return ret;
+ }
- public override void Close()
- {
- m_lockingModel.CloseFile();
- }
+ public override void Close()
+ {
+ m_lockingModel.CloseFile();
+ }
- public override int EndRead(IAsyncResult asyncResult)
- {
- AssertLocked();
- return m_readTotal;
- }
+ public override int EndRead(IAsyncResult asyncResult)
+ {
+ AssertLocked();
+ return m_readTotal;
+ }
- public override void EndWrite(IAsyncResult asyncResult)
- {
- //No-op, it has already been handled
- }
+ public override void EndWrite(IAsyncResult asyncResult)
+ {
+ //No-op, it has already been handled
+ }
#endif
#if NET_4_5 || NETSTANDARD
@@ -254,928 +254,928 @@
}
#endif
- public override void Flush()
- {
- AssertLocked();
- m_realStream.Flush();
- }
+ public override void Flush()
+ {
+ AssertLocked();
+ m_realStream.Flush();
+ }
- public override int Read(byte[] buffer, int offset, int count)
- {
- return m_realStream.Read(buffer, offset, count);
- }
+ public override int Read(byte[] buffer, int offset, int count)
+ {
+ return m_realStream.Read(buffer, offset, count);
+ }
- public override int ReadByte()
- {
- return m_realStream.ReadByte();
- }
+ public override int ReadByte()
+ {
+ return m_realStream.ReadByte();
+ }
- public override long Seek(long offset, SeekOrigin origin)
- {
- AssertLocked();
- return m_realStream.Seek(offset, origin);
- }
+ public override long Seek(long offset, SeekOrigin origin)
+ {
+ AssertLocked();
+ return m_realStream.Seek(offset, origin);
+ }
- public override void SetLength(long value)
- {
- AssertLocked();
- m_realStream.SetLength(value);
- }
+ public override void SetLength(long value)
+ {
+ AssertLocked();
+ m_realStream.SetLength(value);
+ }
- void IDisposable.Dispose()
- {
+ void IDisposable.Dispose()
+ {
#if NETSTANDARD
Dispose(true);
#else
- Close();
+ Close();
#endif
- }
+ }
- public override void Write(byte[] buffer, int offset, int count)
- {
- AssertLocked();
- m_realStream.Write(buffer, offset, count);
- }
+ public override void Write(byte[] buffer, int offset, int count)
+ {
+ AssertLocked();
+ m_realStream.Write(buffer, offset, count);
+ }
- public override void WriteByte(byte value)
- {
- AssertLocked();
- m_realStream.WriteByte(value);
- }
+ public override void WriteByte(byte value)
+ {
+ AssertLocked();
+ m_realStream.WriteByte(value);
+ }
- // Properties
- public override bool CanRead
- {
- get { return false; }
- }
+ // Properties
+ public override bool CanRead
+ {
+ get { return false; }
+ }
- public override bool CanSeek
- {
- get
- {
- AssertLocked();
- return m_realStream.CanSeek;
- }
- }
-
- public override bool CanWrite
- {
- get
- {
- AssertLocked();
- return m_realStream.CanWrite;
- }
- }
-
- public override long Length
- {
- get
- {
- AssertLocked();
- return m_realStream.Length;
- }
- }
-
- public override long Position
- {
- get
- {
- AssertLocked();
- return m_realStream.Position;
- }
- set
- {
- AssertLocked();
- m_realStream.Position = value;
- }
- }
-
- #endregion Override Implementation of Stream
-
- #region Locking Methods
-
- private void AssertLocked()
- {
- if (m_realStream == null)
- {
- throw new LockStateException("The file is not currently locked");
- }
- }
-
- public bool AcquireLock()
- {
- bool ret = false;
- lock (this)
- {
- if (m_lockLevel == 0)
- {
- // If lock is already acquired, nop
- m_realStream = m_lockingModel.AcquireLock();
- }
-
- if (m_realStream != null)
- {
- m_lockLevel++;
- ret = true;
- }
- }
-
- return ret;
- }
-
- public void ReleaseLock()
- {
- lock (this)
- {
- m_lockLevel--;
- if (m_lockLevel == 0)
- {
- // If already unlocked, nop
- m_lockingModel.ReleaseLock();
- m_realStream = null;
- }
- }
- }
-
- #endregion Locking Methods
- }
-
- #endregion LockingStream Inner Class
-
- #region Locking Models
-
- /// <summary>
- /// Locking model base class
- /// </summary>
- /// <remarks>
- /// <para>
- /// Base class for the locking models available to the <see cref="FileAppender"/> derived loggers.
- /// </para>
- /// </remarks>
- public abstract class LockingModelBase
+ public override bool CanSeek
+ {
+ get
{
- private FileAppender m_appender = null;
-
- /// <summary>
- /// Open the output file
- /// </summary>
- /// <param name="filename">The filename to use</param>
- /// <param name="append">Whether to append to the file, or overwrite</param>
- /// <param name="encoding">The encoding to use</param>
- /// <remarks>
- /// <para>
- /// Open the file specified and prepare for logging.
- /// No writes will be made until <see cref="AcquireLock"/> is called.
- /// Must be called before any calls to <see cref="AcquireLock"/>,
- /// <see cref="ReleaseLock"/> and <see cref="CloseFile"/>.
- /// </para>
- /// </remarks>
- public abstract void OpenFile(string filename, bool append, Encoding encoding);
-
- /// <summary>
- /// Close the file
- /// </summary>
- /// <remarks>
- /// <para>
- /// Close the file. No further writes will be made.
- /// </para>
- /// </remarks>
- public abstract void CloseFile();
-
- /// <summary>
- /// Initializes all resources used by this locking model.
- /// </summary>
- public abstract void ActivateOptions();
-
- /// <summary>
- /// Disposes all resources that were initialized by this locking model.
- /// </summary>
- public abstract void OnClose();
-
- /// <summary>
- /// Acquire the lock on the file
- /// </summary>
- /// <returns>A stream that is ready to be written to.</returns>
- /// <remarks>
- /// <para>
- /// Acquire the lock on the file in preparation for writing to it.
- /// Return a stream pointing to the file. <see cref="ReleaseLock"/>
- /// must be called to release the lock on the output file.
- /// </para>
- /// </remarks>
- public abstract Stream AcquireLock();
-
- /// <summary>
- /// Release the lock on the file
- /// </summary>
- /// <remarks>
- /// <para>
- /// Release the lock on the file. No further writes will be made to the
- /// stream until <see cref="AcquireLock"/> is called again.
- /// </para>
- /// </remarks>
- public abstract void ReleaseLock();
-
- /// <summary>
- /// Gets or sets the <see cref="FileAppender"/> for this LockingModel
- /// </summary>
- /// <value>
- /// The <see cref="FileAppender"/> for this LockingModel
- /// </value>
- /// <remarks>
- /// <para>
- /// The file appender this locking model is attached to and working on
- /// behalf of.
- /// </para>
- /// <para>
- /// The file appender is used to locate the security context and the error handler to use.
- /// </para>
- /// <para>
- /// The value of this property will be set before <see cref="OpenFile"/> is
- /// called.
- /// </para>
- /// </remarks>
- public FileAppender CurrentAppender
- {
- get { return m_appender; }
- set { m_appender = value; }
- }
-
- /// <summary>
- /// Helper method that creates a FileStream under CurrentAppender's SecurityContext.
- /// </summary>
- /// <remarks>
- /// <para>
- /// Typically called during OpenFile or AcquireLock.
- /// </para>
- /// <para>
- /// If the directory portion of the <paramref name="filename"/> does not exist, it is created
- /// via Directory.CreateDirecctory.
- /// </para>
- /// </remarks>
- /// <param name="filename"></param>
- /// <param name="append"></param>
- /// <param name="fileShare"></param>
- /// <returns></returns>
- protected Stream CreateStream(string filename, bool append, FileShare fileShare)
- {
- filename = Environment.ExpandEnvironmentVariables(filename);
- using (CurrentAppender.SecurityContext.Impersonate(this))
- {
- // Ensure that the directory structure exists
- string directoryFullName = Path.GetDirectoryName(filename);
-
- // Only create the directory if it does not exist
- // doing this check here resolves some permissions failures
- if (!Directory.Exists(directoryFullName))
- {
- Directory.CreateDirectory(directoryFullName);
- }
-
- FileMode fileOpenMode = append
- ? FileMode.Append
- : FileMode.Create;
- return new FileStream(filename, fileOpenMode, FileAccess.Write, fileShare);
- }
- }
-
- /// <summary>
- /// Helper method to close <paramref name="stream"/> under CurrentAppender's SecurityContext.
- /// </summary>
- /// <remarks>
- /// Does not set <paramref name="stream"/> to null.
- /// </remarks>
- /// <param name="stream"></param>
- protected void CloseStream(Stream stream)
- {
- using (CurrentAppender.SecurityContext.Impersonate(this))
- {
- stream.Dispose();
- }
- }
+ AssertLocked();
+ return m_realStream.CanSeek;
}
+ }
- /// <summary>
- /// Hold an exclusive lock on the output file
- /// </summary>
- /// <remarks>
- /// <para>
- /// Open the file once for writing and hold it open until <see cref="CloseFile"/> is called.
- /// Maintains an exclusive lock on the file during this time.
- /// </para>
- /// </remarks>
- public class ExclusiveLock : LockingModelBase
+ public override bool CanWrite
+ {
+ get
{
- private Stream m_stream = null;
-
- /// <summary>
- /// Open the file specified and prepare for logging.
- /// </summary>
- /// <param name="filename">The filename to use</param>
- /// <param name="append">Whether to append to the file, or overwrite</param>
- /// <param name="encoding">The encoding to use</param>
- /// <remarks>
- /// <para>
- /// Open the file specified and prepare for logging.
- /// No writes will be made until <see cref="AcquireLock"/> is called.
- /// Must be called before any calls to <see cref="AcquireLock"/>,
- /// <see cref="ReleaseLock"/> and <see cref="CloseFile"/>.
- /// </para>
- /// </remarks>
- public override void OpenFile(string filename, bool append, Encoding encoding)
- {
- try
- {
- m_stream = CreateStream(filename, append, FileShare.Read);
- }
- catch (Exception e1)
- {
- CurrentAppender.ErrorHandler.Error("Unable to acquire lock on file " + filename + ". " +
- e1.Message);
- }
- }
-
- /// <summary>
- /// Close the file
- /// </summary>
- /// <remarks>
- /// <para>
- /// Close the file. No further writes will be made.
- /// </para>
- /// </remarks>
- public override void CloseFile()
- {
- CloseStream(m_stream);
- m_stream = null;
- }
-
- /// <summary>
- /// Acquire the lock on the file
- /// </summary>
- /// <returns>A stream that is ready to be written to.</returns>
- /// <remarks>
- /// <para>
- /// Does nothing. The lock is already taken
- /// </para>
- /// </remarks>
- public override Stream AcquireLock()
- {
- return m_stream;
- }
-
- /// <summary>
- /// Release the lock on the file
- /// </summary>
- /// <remarks>
- /// <para>
- /// Does nothing. The lock will be released when the file is closed.
- /// </para>
- /// </remarks>
- public override void ReleaseLock()
- {
- //NOP
- }
-
- /// <summary>
- /// Initializes all resources used by this locking model.
- /// </summary>
- public override void ActivateOptions()
- {
- //NOP
- }
-
- /// <summary>
- /// Disposes all resources that were initialized by this locking model.
- /// </summary>
- public override void OnClose()
- {
- //NOP
- }
+ AssertLocked();
+ return m_realStream.CanWrite;
}
+ }
- /// <summary>
- /// Acquires the file lock for each write
- /// </summary>
- /// <remarks>
- /// <para>
- /// Opens the file once for each <see cref="AcquireLock"/>/<see cref="ReleaseLock"/> cycle,
- /// thus holding the lock for the minimal amount of time. This method of locking
- /// is considerably slower than <see cref="FileAppender.ExclusiveLock"/> but allows
- /// other processes to move/delete the log file whilst logging continues.
- /// </para>
- /// </remarks>
- public class MinimalLock : LockingModelBase
+ public override long Length
+ {
+ get
{
- private string m_filename;
- private bool m_append;
- private Stream m_stream = null;
-
- /// <summary>
- /// Prepares to open the file when the first message is logged.
- /// </summary>
- /// <param name="filename">The filename to use</param>
- /// <param name="append">Whether to append to the file, or overwrite</param>
- /// <param name="encoding">The encoding to use</param>
- /// <remarks>
- /// <para>
- /// Open the file specified and prepare for logging.
- /// No writes will be made until <see cref="AcquireLock"/> is called.
- /// Must be called before any calls to <see cref="AcquireLock"/>,
- /// <see cref="ReleaseLock"/> and <see cref="CloseFile"/>.
- /// </para>
- /// </remarks>
- public override void OpenFile(string filename, bool append, Encoding encoding)
- {
- m_filename = filename;
- m_append = append;
- }
-
- /// <summary>
- /// Close the file
- /// </summary>
- /// <remarks>
- /// <para>
- /// Close the file. No further writes will be made.
- /// </para>
- /// </remarks>
- public override void CloseFile()
- {
- // NOP
- }
-
- /// <summary>
- /// Acquire the lock on the file
- /// </summary>
- /// <returns>A stream that is ready to be written to.</returns>
- /// <remarks>
- /// <para>
- /// Acquire the lock on the file in preparation for writing to it.
- /// Return a stream pointing to the file. <see cref="ReleaseLock"/>
- /// must be called to release the lock on the output file.
- /// </para>
- /// </remarks>
- public override Stream AcquireLock()
- {
- if (m_stream == null)
- {
- try
- {
- m_stream = CreateStream(m_filename, m_append, FileShare.Read);
- m_append = true;
- }
- catch (Exception e1)
- {
- CurrentAppender.ErrorHandler.Error("Unable to acquire lock on file " + m_filename + ". " +
- e1.Message);
- }
- }
-
- return m_stream;
- }
-
- /// <summary>
- /// Release the lock on the file
- /// </summary>
- /// <remarks>
- /// <para>
- /// Release the lock on the file. No further writes will be made to the
- /// stream until <see cref="AcquireLock"/> is called again.
- /// </para>
- /// </remarks>
- public override void ReleaseLock()
- {
- CloseStream(m_stream);
- m_stream = null;
- }
-
- /// <summary>
- /// Initializes all resources used by this locking model.
- /// </summary>
- public override void ActivateOptions()
- {
- //NOP
- }
-
- /// <summary>
- /// Disposes all resources that were initialized by this locking model.
- /// </summary>
- public override void OnClose()
- {
- //NOP
- }
+ AssertLocked();
+ return m_realStream.Length;
}
+ }
+
+ public override long Position
+ {
+ get
+ {
+ AssertLocked();
+ return m_realStream.Position;
+ }
+ set
+ {
+ AssertLocked();
+ m_realStream.Position = value;
+ }
+ }
+
+ #endregion Override Implementation of Stream
+
+ #region Locking Methods
+
+ private void AssertLocked()
+ {
+ if (m_realStream == null)
+ {
+ throw new LockStateException("The file is not currently locked");
+ }
+ }
+
+ public bool AcquireLock()
+ {
+ bool ret = false;
+ lock (this)
+ {
+ if (m_lockLevel == 0)
+ {
+ // If lock is already acquired, nop
+ m_realStream = m_lockingModel.AcquireLock();
+ }
+
+ if (m_realStream != null)
+ {
+ m_lockLevel++;
+ ret = true;
+ }
+ }
+
+ return ret;
+ }
+
+ public void ReleaseLock()
+ {
+ lock (this)
+ {
+ m_lockLevel--;
+ if (m_lockLevel == 0)
+ {
+ // If already unlocked, nop
+ m_lockingModel.ReleaseLock();
+ m_realStream = null;
+ }
+ }
+ }
+
+ #endregion Locking Methods
+ }
+
+ #endregion LockingStream Inner Class
+
+ #region Locking Models
+
+ /// <summary>
+ /// Locking model base class
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Base class for the locking models available to the <see cref="FileAppender"/> derived loggers.
+ /// </para>
+ /// </remarks>
+ public abstract class LockingModelBase
+ {
+ private FileAppender m_appender = null;
+
+ /// <summary>
+ /// Open the output file
+ /// </summary>
+ /// <param name="filename">The filename to use</param>
+ /// <param name="append">Whether to append to the file, or overwrite</param>
+ /// <param name="encoding">The encoding to use</param>
+ /// <remarks>
+ /// <para>
+ /// Open the file specified and prepare for logging.
+ /// No writes will be made until <see cref="AcquireLock"/> is called.
+ /// Must be called before any calls to <see cref="AcquireLock"/>,
+ /// <see cref="ReleaseLock"/> and <see cref="CloseFile"/>.
+ /// </para>
+ /// </remarks>
+ public abstract void OpenFile(string filename, bool append, Encoding encoding);
+
+ /// <summary>
+ /// Close the file
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Close the file. No further writes will be made.
+ /// </para>
+ /// </remarks>
+ public abstract void CloseFile();
+
+ /// <summary>
+ /// Initializes all resources used by this locking model.
+ /// </summary>
+ public abstract void ActivateOptions();
+
+ /// <summary>
+ /// Disposes all resources that were initialized by this locking model.
+ /// </summary>
+ public abstract void OnClose();
+
+ /// <summary>
+ /// Acquire the lock on the file
+ /// </summary>
+ /// <returns>A stream that is ready to be written to.</returns>
+ /// <remarks>
+ /// <para>
+ /// Acquire the lock on the file in preparation for writing to it.
+ /// Return a stream pointing to the file. <see cref="ReleaseLock"/>
+ /// must be called to release the lock on the output file.
+ /// </para>
+ /// </remarks>
+ public abstract Stream AcquireLock();
+
+ /// <summary>
+ /// Release the lock on the file
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Release the lock on the file. No further writes will be made to the
+ /// stream until <see cref="AcquireLock"/> is called again.
+ /// </para>
+ /// </remarks>
+ public abstract void ReleaseLock();
+
+ /// <summary>
+ /// Gets or sets the <see cref="FileAppender"/> for this LockingModel
+ /// </summary>
+ /// <value>
+ /// The <see cref="FileAppender"/> for this LockingModel
+ /// </value>
+ /// <remarks>
+ /// <para>
+ /// The file appender this locking model is attached to and working on
+ /// behalf of.
+ /// </para>
+ /// <para>
+ /// The file appender is used to locate the security context and the error handler to use.
+ /// </para>
+ /// <para>
+ /// The value of this property will be set before <see cref="OpenFile"/> is
+ /// called.
+ /// </para>
+ /// </remarks>
+ public FileAppender CurrentAppender
+ {
+ get { return m_appender; }
+ set { m_appender = value; }
+ }
+
+ /// <summary>
+ /// Helper method that creates a FileStream under CurrentAppender's SecurityContext.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Typically called during OpenFile or AcquireLock.
+ /// </para>
+ /// <para>
+ /// If the directory portion of the <paramref name="filename"/> does not exist, it is created
+ /// via Directory.CreateDirecctory.
+ /// </para>
+ /// </remarks>
+ /// <param name="filename"></param>
+ /// <param name="append"></param>
+ /// <param name="fileShare"></param>
+ /// <returns></returns>
+ protected Stream CreateStream(string filename, bool append, FileShare fileShare)
+ {
+ filename = Environment.ExpandEnvironmentVariables(filename);
+ using (CurrentAppender.SecurityContext.Impersonate(this))
+ {
+ // Ensure that the directory structure exists
+ string directoryFullName = Path.GetDirectoryName(filename);
+
+ // Only create the directory if it does not exist
+ // doing this check here resolves some permissions failures
+ if (!Directory.Exists(directoryFullName))
+ {
+ Directory.CreateDirectory(directoryFullName);
+ }
+
+ FileMode fileOpenMode = append
+ ? FileMode.Append
+ : FileMode.Create;
+ return new FileStream(filename, fileOpenMode, FileAccess.Write, fileShare);
+ }
+ }
+
+ /// <summary>
+ /// Helper method to close <paramref name="stream"/> under CurrentAppender's SecurityContext.
+ /// </summary>
+ /// <remarks>
+ /// Does not set <paramref name="stream"/> to null.
+ /// </remarks>
+ /// <param name="stream"></param>
+ protected void CloseStream(Stream stream)
+ {
+ using (CurrentAppender.SecurityContext.Impersonate(this))
+ {
+ stream.Dispose();
+ }
+ }
+ }
+
+ /// <summary>
+ /// Hold an exclusive lock on the output file
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Open the file once for writing and hold it open until <see cref="CloseFile"/> is called.
+ /// Maintains an exclusive lock on the file during this time.
+ /// </para>
+ /// </remarks>
+ public class ExclusiveLock : LockingModelBase
+ {
+ private Stream m_stream = null;
+
+ /// <summary>
+ /// Open the file specified and prepare for logging.
+ /// </summary>
+ /// <param name="filename">The filename to use</param>
+ /// <param name="append">Whether to append to the file, or overwrite</param>
+ /// <param name="encoding">The encoding to use</param>
+ /// <remarks>
+ /// <para>
+ /// Open the file specified and prepare for logging.
+ /// No writes will be made until <see cref="AcquireLock"/> is called.
+ /// Must be called before any calls to <see cref="AcquireLock"/>,
+ /// <see cref="ReleaseLock"/> and <see cref="CloseFile"/>.
+ /// </para>
+ /// </remarks>
+ public override void OpenFile(string filename, bool append, Encoding encoding)
+ {
+ try
+ {
+ m_stream = CreateStream(filename, append, FileShare.Read);
+ }
+ catch (Exception e1)
+ {
+ CurrentAppender.ErrorHandler.Error("Unable to acquire lock on file " + filename + ". " +
+ e1.Message);
+ }
+ }
+
+ /// <summary>
+ /// Close the file
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Close the file. No further writes will be made.
+ /// </para>
+ /// </remarks>
+ public override void CloseFile()
+ {
+ CloseStream(m_stream);
+ m_stream = null;
+ }
+
+ /// <summary>
+ /// Acquire the lock on the file
+ /// </summary>
+ /// <returns>A stream that is ready to be written to.</returns>
+ /// <remarks>
+ /// <para>
+ /// Does nothing. The lock is already taken
+ /// </para>
+ /// </remarks>
+ public override Stream AcquireLock()
+ {
+ return m_stream;
+ }
+
+ /// <summary>
+ /// Release the lock on the file
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Does nothing. The lock will be released when the file is closed.
+ /// </para>
+ /// </remarks>
+ public override void ReleaseLock()
+ {
+ //NOP
+ }
+
+ /// <summary>
+ /// Initializes all resources used by this locking model.
+ /// </summary>
+ public override void ActivateOptions()
+ {
+ //NOP
+ }
+
+ /// <summary>
+ /// Disposes all resources that were initialized by this locking model.
+ /// </summary>
+ public override void OnClose()
+ {
+ //NOP
+ }
+ }
+
+ /// <summary>
+ /// Acquires the file lock for each write
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Opens the file once for each <see cref="AcquireLock"/>/<see cref="ReleaseLock"/> cycle,
+ /// thus holding the lock for the minimal amount of time. This method of locking
+ /// is considerably slower than <see cref="FileAppender.ExclusiveLock"/> but allows
+ /// other processes to move/delete the log file whilst logging continues.
+ /// </para>
+ /// </remarks>
+ public class MinimalLock : LockingModelBase
+ {
+ private string m_filename;
+ private bool m_append;
+ private Stream m_stream = null;
+
+ /// <summary>
+ /// Prepares to open the file when the first message is logged.
+ /// </summary>
+ /// <param name="filename">The filename to use</param>
+ /// <param name="append">Whether to append to the file, or overwrite</param>
+ /// <param name="encoding">The encoding to use</param>
+ /// <remarks>
+ /// <para>
+ /// Open the file specified and prepare for logging.
+ /// No writes will be made until <see cref="AcquireLock"/> is called.
+ /// Must be called before any calls to <see cref="AcquireLock"/>,
+ /// <see cref="ReleaseLock"/> and <see cref="CloseFile"/>.
+ /// </para>
+ /// </remarks>
+ public override void OpenFile(string filename, bool append, Encoding encoding)
+ {
+ m_filename = filename;
+ m_append = append;
+ }
+
+ /// <summary>
+ /// Close the file
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Close the file. No further writes will be made.
+ /// </para>
+ /// </remarks>
+ public override void CloseFile()
+ {
+ // NOP
+ }
+
+ /// <summary>
+ /// Acquire the lock on the file
+ /// </summary>
+ /// <returns>A stream that is ready to be written to.</returns>
+ /// <remarks>
+ /// <para>
+ /// Acquire the lock on the file in preparation for writing to it.
+ /// Return a stream pointing to the file. <see cref="ReleaseLock"/>
+ /// must be called to release the lock on the output file.
+ /// </para>
+ /// </remarks>
+ public override Stream AcquireLock()
+ {
+ if (m_stream == null)
+ {
+ try
+ {
+ m_stream = CreateStream(m_filename, m_append, FileShare.Read);
+ m_append = true;
+ }
+ catch (Exception e1)
+ {
+ CurrentAppender.ErrorHandler.Error("Unable to acquire lock on file " + m_filename + ". " +
+ e1.Message);
+ }
+ }
+
+ return m_stream;
+ }
+
+ /// <summary>
+ /// Release the lock on the file
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Release the lock on the file. No further writes will be made to the
+ /// stream until <see cref="AcquireLock"/> is called again.
+ /// </para>
+ /// </remarks>
+ public override void ReleaseLock()
+ {
+ CloseStream(m_stream);
+ m_stream = null;
+ }
+
+ /// <summary>
+ /// Initializes all resources used by this locking model.
+ /// </summary>
+ public override void ActivateOptions()
+ {
+ //NOP
+ }
+
+ /// <summary>
+ /// Disposes all resources that were initialized by this locking model.
+ /// </summary>
+ public override void OnClose()
+ {
+ //NOP
+ }
+ }
#if !NETCF
- /// <summary>
- /// Provides cross-process file locking.
- /// </summary>
- /// <author>Ron Grabowski</author>
- /// <author>Steve Wranovsky</author>
- public class InterProcessLock : LockingModelBase
- {
- private Mutex m_mutex = null;
- private Stream m_stream = null;
- private int m_recursiveWatch = 0;
+ /// <summary>
+ /// Provides cross-process file locking.
+ /// </summary>
+ /// <author>Ron Grabowski</author>
+ /// <author>Steve Wranovsky</author>
+ public class InterProcessLock : LockingModelBase
+ {
+ private Mutex m_mutex = null;
+ private Stream m_stream = null;
+ private int m_recursiveWatch = 0;
- /// <summary>
- /// Open the file specified and prepare for logging.
- /// </summary>
- /// <param name="filename">The filename to use</param>
- /// <param name="append">Whether to append to the file, or overwrite</param>
- /// <param name="encoding">The encoding to use</param>
- /// <remarks>
- /// <para>
- /// Open the file specified and prepare for logging.
- /// No writes will be made until <see cref="AcquireLock"/> is called.
- /// Must be called before any calls to <see cref="AcquireLock"/>,
- /// -<see cref="ReleaseLock"/> and <see cref="CloseFile"/>.
- /// </para>
- /// </remarks>
+ /// <summary>
+ /// Open the file specified and prepare for logging.
+ /// </summary>
+ /// <param name="filename">The filename to use</param>
+ /// <param name="append">Whether to append to the file, or overwrite</param>
+ /// <param name="encoding">The encoding to use</param>
+ /// <remarks>
+ /// <para>
+ /// Open the file specified and prepare for logging.
+ /// No writes will be made until <see cref="AcquireLock"/> is called.
+ /// Must be called before any calls to <see cref="AcquireLock"/>,
+ /// -<see cref="ReleaseLock"/> and <see cref="CloseFile"/>.
+ /// </para>
+ /// </remarks>
#if NET_4_0 || MONO_4_0 || NETSTANDARD
[System.Security.SecuritySafeCritical]
#endif
- public override void OpenFile(string filename, bool append, Encoding encoding)
+ public override void OpenFile(string filename, bool append, Encoding encoding)
+ {
+ try
+ {
+ m_stream = CreateStream(filename, append, FileShare.ReadWrite);
+ }
+ catch (Exception e1)
+ {
+ CurrentAppender.ErrorHandler.Error("Unable to acquire lock on file " + filename + ". " +
+ e1.Message);
+ }
+ }
+
+ /// <summary>
+ /// Close the file
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Close the file. No further writes will be made.
+ /// </para>
+ /// </remarks>
+ public override void CloseFile()
+ {
+ try
+ {
+ CloseStream(m_stream);
+ m_stream = null;
+ }
+ finally
+ {
+ ReleaseLock();
+ }
+ }
+
+ /// <summary>
+ /// Acquire the lock on the file
+ /// </summary>
+ /// <returns>A stream that is ready to be written to.</returns>
+ /// <remarks>
+ /// <para>
+ /// Does nothing. The lock is already taken
+ /// </para>
+ /// </remarks>
+ public override Stream AcquireLock()
+ {
+ if (m_mutex != null)
+ {
+ // TODO: add timeout?
+ m_mutex.WaitOne();
+
+ // increment recursive watch
+ m_recursiveWatch++;
+
+ // should always be true (and fast) for FileStream
+ if (m_stream != null)
+ {
+ if (m_stream.CanSeek)
{
- try
- {
- m_stream = CreateStream(filename, append, FileShare.ReadWrite);
- }
- catch (Exception e1)
- {
- CurrentAppender.ErrorHandler.Error("Unable to acquire lock on file " + filename + ". " +
- e1.Message);
- }
+ m_stream.Seek(0, SeekOrigin.End);
}
+ }
+ else
+ {
+ // this can happen when the file appender cannot open a file for writing
+ }
+ }
+ else
+ {
+ CurrentAppender.ErrorHandler.Error(
+ "Programming error, no mutex available to acquire lock! From here on things will be dangerous!");
+ }
- /// <summary>
- /// Close the file
- /// </summary>
- /// <remarks>
- /// <para>
- /// Close the file. No further writes will be made.
- /// </para>
- /// </remarks>
- public override void CloseFile()
- {
- try
- {
- CloseStream(m_stream);
- m_stream = null;
- }
- finally
- {
- ReleaseLock();
- }
- }
+ return m_stream;
+ }
- /// <summary>
- /// Acquire the lock on the file
- /// </summary>
- /// <returns>A stream that is ready to be written to.</returns>
- /// <remarks>
- /// <para>
- /// Does nothing. The lock is already taken
- /// </para>
- /// </remarks>
- public override Stream AcquireLock()
- {
- if (m_mutex != null)
- {
- // TODO: add timeout?
- m_mutex.WaitOne();
+ /// <summary>
+ /// Releases the lock and allows others to acquire a lock.
+ /// </summary>
+ public override void ReleaseLock()
+ {
+ if (m_mutex != null)
+ {
+ if (m_recursiveWatch > 0)
+ {
+ m_recursiveWatch--;
+ m_mutex.ReleaseMutex();
+ }
+ }
+ else
+ {
+ CurrentAppender.ErrorHandler.Error("Programming error, no mutex available to release the lock!");
+ }
+ }
- // increment recursive watch
- m_recursiveWatch++;
+ /// <summary>
+ /// Initializes all resources used by this locking model.
+ /// </summary>
+ public override void ActivateOptions()
+ {
+ if (m_mutex == null)
+ {
+ string mutexFriendlyFilename = CurrentAppender.File
+ .Replace("\\", "_")
+ .Replace(":", "_")
+ .Replace("/", "_");
- // should always be true (and fast) for FileStream
- if (m_stream != null)
- {
- if (m_stream.CanSeek)
- {
- m_stream.Seek(0, SeekOrigin.End);
- }
- }
- else
- {
- // this can happen when the file appender cannot open a file for writing
- }
- }
- else
- {
- CurrentAppender.ErrorHandler.Error(
- "Programming error, no mutex available to acquire lock! From here on things will be dangerous!");
- }
+ m_mutex = new Mutex(false, mutexFriendlyFilename);
+ }
+ else
+ {
+ CurrentAppender.ErrorHandler.Error("Programming error, mutex already initialized!");
+ }
+ }
- return m_stream;
- }
-
- /// <summary>
- /// Releases the lock and allows others to acquire a lock.
- /// </summary>
- public override void ReleaseLock()
- {
- if (m_mutex != null)
- {
- if (m_recursiveWatch > 0)
- {
- m_recursiveWatch--;
- m_mutex.ReleaseMutex();
- }
- }
- else
- {
- CurrentAppender.ErrorHandler.Error("Programming error, no mutex available to release the lock!");
- }
- }
-
- /// <summary>
- /// Initializes all resources used by this locking model.
- /// </summary>
- public override void ActivateOptions()
- {
- if (m_mutex == null)
- {
- string mutexFriendlyFilename = CurrentAppender.File
- .Replace("\\", "_")
- .Replace(":", "_")
- .Replace("/", "_");
-
- m_mutex = new Mutex(false, mutexFriendlyFilename);
- }
- else
- {
- CurrentAppender.ErrorHandler.Error("Programming error, mutex already initialized!");
- }
- }
-
- /// <summary>
- /// Disposes all resources that were initialized by this locking model.
- /// </summary>
- public override void OnClose()
- {
- if (m_mutex != null)
- {
+ /// <summary>
+ /// Disposes all resources that were initialized by this locking model.
+ /// </summary>
+ public override void OnClose()
+ {
+ if (m_mutex != null)
+ {
#if NET_4_0 || MONO_4_0 || NETSTANDARD
m_mutex.Dispose();
#else
- m_mutex.Close();
+ m_mutex.Close();
#endif
- m_mutex = null;
- }
- else
- {
- CurrentAppender.ErrorHandler.Error("Programming error, mutex not initialized!");
- }
- }
+ m_mutex = null;
}
+ else
+ {
+ CurrentAppender.ErrorHandler.Error("Programming error, mutex not initialized!");
+ }
+ }
+ }
#endif
- /// <summary>
- /// Hold no lock on the output file
- /// </summary>
- /// <remarks>
- /// <para>
- /// Open the file once and hold it open until <see cref="CloseFile"/> is called.
- /// Maintains no lock on the file during this time.
- /// </para>
- /// </remarks>
- public class NoLock : LockingModelBase
+ /// <summary>
+ /// Hold no lock on the output file
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Open the file once and hold it open until <see cref="CloseFile"/> is called.
+ /// Maintains no lock on the file during this time.
+ /// </para>
+ /// </remarks>
+ public class NoLock : LockingModelBase
+ {
+ private Stream m_stream = null;
+
+ /// <summary>
+ /// Open the file specified and prepare for logging.
+ /// </summary>
+ /// <param name="filename">The filename to use</param>
+ /// <param name="append">Whether to append to the file, or overwrite</param>
+ /// <param name="encoding">The encoding to use</param>
+ /// <remarks>
+ /// <para>
+ /// Open the file specified and prepare for logging.
+ /// No writes will be made until <see cref="AcquireLock"/> is called.
+ /// Must be called before any calls to <see cref="AcquireLock"/>,
+ /// <see cref="ReleaseLock"/> and <see cref="CloseFile"/>.
+ /// </para>
+ /// </remarks>
+ public override void OpenFile(string filename, bool append, Encoding encoding)
+ {
+ try
{
- private Stream m_stream = null;
-
- /// <summary>
- /// Open the file specified and prepare for logging.
- /// </summary>
- /// <param name="filename">The filename to use</param>
- /// <param name="append">Whether to append to the file, or overwrite</param>
- /// <param name="encoding">The encoding to use</param>
- /// <remarks>
- /// <para>
- /// Open the file specified and prepare for logging.
- /// No writes will be made until <see cref="AcquireLock"/> is called.
- /// Must be called before any calls to <see cref="AcquireLock"/>,
- /// <see cref="ReleaseLock"/> and <see cref="CloseFile"/>.
- /// </para>
- /// </remarks>
- public override void OpenFile(string filename, bool append, Encoding encoding)
- {
- try
- {
- // no lock
- m_stream = CreateStream(filename, append, FileShare.ReadWrite);
- }
- catch (Exception e1)
- {
- CurrentAppender.ErrorHandler.Error(
- $"Unable to acquire lock on file {filename}. {e1.Message}"
- );
- }
- }
-
- /// <summary>
- /// Close the file
- /// </summary>
- /// <remarks>
- /// <para>
- /// Close the file. No further writes will be made.
- /// </para>
- /// </remarks>
- public override void CloseFile()
- {
- CloseStream(m_stream);
- m_stream = null;
- }
-
- /// <summary>
- /// Acquire the lock on the file
- /// </summary>
- /// <returns>A stream that is ready to be written to.</returns>
- /// <remarks>
- /// <para>
- /// Does nothing. The lock is already taken
- /// </para>
- /// </remarks>
- public override Stream AcquireLock()
- {
- return m_stream;
- }
-
- /// <summary>
- /// Release the lock on the file
- /// </summary>
- /// <remarks>
- /// <para>
- /// Does nothing. The lock will be released when the file is closed.
- /// </para>
- /// </remarks>
- public override void ReleaseLock()
- {
- // NOP
- }
-
- /// <summary>
- /// Initializes all resources used by this locking model.
- /// </summary>
- public override void ActivateOptions()
- {
- // NOP
- }
-
- /// <summary>
- /// Disposes all resources that were initialized by this locking model.
- /// </summary>
- public override void OnClose()
- {
- // NOP
- }
+ // no lock
+ m_stream = CreateStream(filename, append, FileShare.ReadWrite);
}
-
- /// <summary>
- /// Default locking model (when no locking model was configured)
- /// </summary>
- private static Type defaultLockingModelType = typeof(ExclusiveLock);
-
- /// <summary>
- /// Specify default locking model
- /// </summary>
- /// <typeparam name="TLockingModel">Type of LockingModel</typeparam>
- public static void SetDefaultLockingModelType<TLockingModel>() where TLockingModel : LockingModelBase
+ catch (Exception e1)
{
- defaultLockingModelType = typeof(TLockingModel);
+ CurrentAppender.ErrorHandler.Error(
+ $"Unable to acquire lock on file {filename}. {e1.Message}"
+ );
}
+ }
- #endregion Locking Models
+ /// <summary>
+ /// Close the file
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Close the file. No further writes will be made.
+ /// </para>
+ /// </remarks>
+ public override void CloseFile()
+ {
+ CloseStream(m_stream);
+ m_stream = null;
+ }
- #region Public Instance Constructors
+ /// <summary>
+ /// Acquire the lock on the file
+ /// </summary>
+ /// <returns>A stream that is ready to be written to.</returns>
+ /// <remarks>
+ /// <para>
+ /// Does nothing. The lock is already taken
+ /// </para>
+ /// </remarks>
+ public override Stream AcquireLock()
+ {
+ return m_stream;
+ }
- /// <summary>
- /// Default constructor
- /// </summary>
- /// <remarks>
- /// <para>
- /// Default constructor
- /// </para>
- /// </remarks>
- public FileAppender()
- {
- }
+ /// <summary>
+ /// Release the lock on the file
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Does nothing. The lock will be released when the file is closed.
+ /// </para>
+ /// </remarks>
+ public override void ReleaseLock()
+ {
+ // NOP
+ }
- /// <summary>
- /// Construct a new appender using the layout, file and append mode.
- /// </summary>
- /// <param name="layout">the layout to use with this appender</param>
- /// <param name="filename">the full path to the file to write to</param>
- /// <param name="append">flag to indicate if the file should be appended to</param>
- /// <remarks>
- /// <para>
- /// Obsolete constructor.
- /// </para>
- /// </remarks>
- [Obsolete("Instead use the default constructor and set the Layout, File & AppendToFile properties")]
- public FileAppender(ILayout layout, string filename, bool append)
- {
- Layout = layout;
- File = filename;
- AppendToFile = append;
- ActivateOptions();
- }
+ /// <summary>
+ /// Initializes all resources used by this locking model.
+ /// </summary>
+ public override void ActivateOptions()
+ {
+ // NOP
+ }
- /// <summary>
- /// Construct a new appender using the layout and file specified.
- /// The file will be appended to.
- /// </summary>
- /// <param name="layout">the layout to use with this appender</param>
- /// <param name="filename">the full path to the file to write to</param>
- /// <remarks>
- /// <para>
- /// Obsolete constructor.
- /// </para>
- /// </remarks>
- [Obsolete("Instead use the default constructor and set the Layout & File properties")]
- public FileAppender(ILayout layout, string filename)
- : this(layout, filename, true)
- {
- }
+ /// <summary>
+ /// Disposes all resources that were initialized by this locking model.
+ /// </summary>
+ public override void OnClose()
+ {
+ // NOP
+ }
+ }
- #endregion Public Instance Constructors
+ /// <summary>
+ /// Default locking model (when no locking model was configured)
+ /// </summary>
+ private static Type defaultLockingModelType = typeof(ExclusiveLock);
- #region Public Instance Properties
+ /// <summary>
+ /// Specify default locking model
+ /// </summary>
+ /// <typeparam name="TLockingModel">Type of LockingModel</typeparam>
+ public static void SetDefaultLockingModelType<TLockingModel>() where TLockingModel : LockingModelBase
+ {
+ defaultLockingModelType = typeof(TLockingModel);
+ }
- /// <summary>
- /// Gets or sets the path to the file that logging will be written to.
- /// </summary>
- /// <value>
- /// The path to the file that logging will be written to.
- /// </value>
- /// <remarks>
- /// <para>
- /// If the path is relative it is taken as relative from
- /// the application base directory.
- /// </para>
- /// </remarks>
- public virtual string File
- {
- get { return m_fileName; }
- set { m_fileName = value; }
- }
+ #endregion Locking Models
- /// <summary>
- /// Gets or sets a flag that indicates whether the file should be
- /// appended to or overwritten.
- /// </summary>
- /// <value>
- /// Indicates whether the file should be appended to or overwritten.
- /// </value>
- /// <remarks>
- /// <para>
- /// If the value is set to false then the file will be overwritten, if
- /// it is set to true then the file will be appended to.
- /// </para>
- /// The default value is true.
- /// </remarks>
- public bool AppendToFile
- {
- get { return m_appendToFile; }
- set { m_appendToFile = value; }
- }
+ #region Public Instance Constructors
- /// <summary>
- /// Gets or sets <see cref="Encoding"/> used to write to the file.
- /// </summary>
- /// <value>
- /// The <see cref="Encoding"/> used to write to the file.
- /// </value>
- /// <remarks>
- /// <para>
- /// The default encoding set is <see cref="System.Text.Encoding.Default"/>
- /// which is the encoding for the system's current ANSI code page.
- /// </para>
- /// </remarks>
- public Encoding Encoding
- {
- get { return m_encoding; }
- set { m_encoding = value; }
- }
+ /// <summary>
+ /// Default constructor
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Default constructor
+ /// </para>
+ /// </remarks>
+ public FileAppender()
+ {
+ }
- /// <summary>
- /// Gets or sets the <see cref="SecurityContext"/> used to write to the file.
- /// </summary>
- /// <value>
- /// The <see cref="SecurityContext"/> used to write to the file.
- /// </value>
- /// <remarks>
- /// <para>
- /// Unless a <see cref="SecurityContext"/> specified here for this appender
- /// the <see cref="SecurityContextProvider.DefaultProvider"/> is queried for the
- /// security context to use. The default behavior is to use the security context
- /// of the current thread.
- /// </para>
- /// </remarks>
- public SecurityContext SecurityContext
- {
- get { return m_securityContext; }
- set { m_securityContext = value; }
- }
+ /// <summary>
+ /// Construct a new appender using the layout, file and append mode.
+ /// </summary>
+ /// <param name="layout">the layout to use with this appender</param>
+ /// <param name="filename">the full path to the file to write to</param>
+ /// <param name="append">flag to indicate if the file should be appended to</param>
+ /// <remarks>
+ /// <para>
+ /// Obsolete constructor.
+ /// </para>
+ /// </remarks>
+ [Obsolete("Instead use the default constructor and set the Layout, File & AppendToFile properties")]
+ public FileAppender(ILayout layout, string filename, bool append)
+ {
+ Layout = layout;
+ File = filename;
+ AppendToFile = append;
+ ActivateOptions();
+ }
+
+ /// <summary>
+ /// Construct a new appender using the layout and file specified.
+ /// The file will be appended to.
+ /// </summary>
+ /// <param name="layout">the layout to use with this appender</param>
+ /// <param name="filename">the full path to the file to write to</param>
+ /// <remarks>
+ /// <para>
+ /// Obsolete constructor.
+ /// </para>
+ /// </remarks>
+ [Obsolete("Instead use the default constructor and set the Layout & File properties")]
+ public FileAppender(ILayout layout, string filename)
+ : this(layout, filename, true)
+ {
+ }
+
+ #endregion Public Instance Constructors
+
+ #region Public Instance Properties
+
+ /// <summary>
+ /// Gets or sets the path to the file that logging will be written to.
+ /// </summary>
+ /// <value>
+ /// The path to the file that logging will be written to.
+ /// </value>
+ /// <remarks>
+ /// <para>
+ /// If the path is relative it is taken as relative from
+ /// the application base directory.
+ /// </para>
+ /// </remarks>
+ public virtual string File
+ {
+ get { return m_fileName; }
+ set { m_fileName = value; }
+ }
+
+ /// <summary>
+ /// Gets or sets a flag that indicates whether the file should be
+ /// appended to or overwritten.
+ /// </summary>
+ /// <value>
+ /// Indicates whether the file should be appended to or overwritten.
+ /// </value>
+ /// <remarks>
+ /// <para>
+ /// If the value is set to false then the file will be overwritten, if
+ /// it is set to true then the file will be appended to.
+ /// </para>
+ /// The default value is true.
+ /// </remarks>
+ public bool AppendToFile
+ {
+ get { return m_appendToFile; }
+ set { m_appendToFile = value; }
+ }
+
+ /// <summary>
+ /// Gets or sets <see cref="Encoding"/> used to write to the file.
+ /// </summary>
+ /// <value>
+ /// The <see cref="Encoding"/> used to write to the file.
+ /// </value>
+ /// <remarks>
+ /// <para>
+ /// The default encoding set is <see cref="System.Text.Encoding.Default"/>
+ /// which is the encoding for the system's current ANSI code page.
+ /// </para>
+ /// </remarks>
+ public Encoding Encoding
+ {
+ get { return m_encoding; }
+ set { m_encoding = value; }
+ }
+
+ /// <summary>
+ /// Gets or sets the <see cref="SecurityContext"/> used to write to the file.
+ /// </summary>
+ /// <value>
+ /// The <see cref="SecurityContext"/> used to write to the file.
+ /// </value>
+ /// <remarks>
+ /// <para>
+ /// Unless a <see cref="SecurityContext"/> specified here for this appender
+ /// the <see cref="SecurityContextProvider.DefaultProvider"/> is queried for the
+ /// security context to use. The default behavior is to use the security context
+ /// of the current thread.
+ /// </para>
+ /// </remarks>
+ public SecurityContext SecurityContext
+ {
+ get { return m_securityContext; }
+ set { m_securityContext = value; }
+ }
#if NETCF
/// <summary>
@@ -1199,479 +1199,479 @@
/// </para>
/// </remarks>
#else
- /// <summary>
- /// Gets or sets the <see cref="FileAppender.LockingModel"/> used to handle locking of the file.
- /// </summary>
- /// <value>
- /// The <see cref="FileAppender.LockingModel"/> used to lock the file.
- /// </value>
- /// <remarks>
- /// <para>
- /// Gets or sets the <see cref="FileAppender.LockingModel"/> used to handle locking of the file.
- /// </para>
- /// <para>
- /// There are three built in locking models, <see cref="FileAppender.ExclusiveLock"/>, <see cref="FileAppender.MinimalLock"/> and <see cref="FileAppender.InterProcessLock"/> .
- /// The first locks the file from the start of logging to the end, the
- /// second locks only for the minimal amount of time when logging each message
- /// and the last synchronizes processes using a named system wide Mutex.
- /// </para>
- /// <para>
- /// The default locking model is the <see cref="FileAppender.ExclusiveLock"/>.
- /// </para>
- /// </remarks>
+ /// <summary>
+ /// Gets or sets the <see cref="FileAppender.LockingModel"/> used to handle locking of the file.
+ /// </summary>
+ /// <value>
+ /// The <see cref="FileAppender.LockingModel"/> used to lock the file.
+ /// </value>
+ /// <remarks>
+ /// <para>
+ /// Gets or sets the <see cref="FileAppender.LockingModel"/> used to handle locking of the file.
+ /// </para>
+ /// <para>
+ /// There are three built in locking models, <see cref="FileAppender.ExclusiveLock"/>, <see cref="FileAppender.MinimalLock"/> and <see cref="FileAppender.InterProcessLock"/> .
+ /// The first locks the file from the start of logging to the end, the
+ /// second locks only for the minimal amount of time when logging each message
+ /// and the last synchronizes processes using a named system wide Mutex.
+ /// </para>
+ /// <para>
+ /// The default locking model is the <see cref="FileAppender.ExclusiveLock"/>.
+ /// </para>
+ /// </remarks>
#endif
- public FileAppender.LockingModelBase LockingModel
- {
- get { return m_lockingModel; }
- set { m_lockingModel = value; }
- }
-
- #endregion Public Instance Properties
-
- #region Override implementation of AppenderSkeleton
-
- /// <summary>
- /// Activate the options on the file appender.
- /// </summary>
- /// <remarks>
- /// <para>
- /// This is part of the <see cref="IOptionHandler"/> delayed object
- /// activation scheme. The <see cref="ActivateOptions"/> method must
- /// be called on this object after the configuration properties have
- /// been set. Until <see cref="ActivateOptions"/> is called this
- /// object is in an undefined state and must not be used.
- /// </para>
- /// <para>
- /// If any of the configuration properties are modified then
- /// <see cref="ActivateOptions"/> must be called again.
- /// </para>
- /// <para>
- /// This will cause the file to be opened.
- /// </para>
- /// </remarks>
- public override void ActivateOptions()
- {
- base.ActivateOptions();
-
- if (m_securityContext == null)
- {
- m_securityContext = SecurityContextProvider.DefaultProvider.CreateSecurityContext(this);
- }
-
- if (m_lockingModel == null)
- {
- m_lockingModel = (LockingModelBase) Activator.CreateInstance(defaultLockingModelType);
- }
-
- m_lockingModel.CurrentAppender = this;
- m_lockingModel.ActivateOptions();
-
- if (m_fileName != null)
- {
- using (SecurityContext.Impersonate(this))
- {
- m_fileName = ConvertToFullPath(m_fileName.Trim());
- }
-
- SafeOpenFile(m_fileName, m_appendToFile);
- }
- else
- {
- LogLog.Warn(declaringType, "FileAppender: File option not set for appender [" + Name + "].");
- LogLog.Warn(declaringType, "FileAppender: Are you using FileAppender instead of ConsoleAppender?");
- }
- }
-
- #endregion Override implementation of AppenderSkeleton
-
- #region Override implementation of TextWriterAppender
-
- /// <summary>
- /// Closes any previously opened file and calls the parent's <see cref="TextWriterAppender.Reset"/>.
- /// </summary>
- /// <remarks>
- /// <para>
- /// Resets the filename and the file stream.
- /// </para>
- /// </remarks>
- protected override void Reset()
- {
- base.Reset();
- m_fileName = null;
- }
-
- /// <summary>
- /// Close this appender instance. The underlying stream or writer is also closed.
- /// </summary>
- protected override void OnClose()
- {
- base.OnClose();
- m_lockingModel.OnClose();
- }
-
- /// <summary>
- /// Called to initialize the file writer
- /// </summary>
- /// <remarks>
- /// <para>
- /// Will be called for each logged message until the file is
- /// successfully opened.
- /// </para>
- /// </remarks>
- protected override void PrepareWriter()
- {
- SafeOpenFile(m_fileName, m_appendToFile);
- }
-
- /// <summary>
- /// This method is called by the <see cref="M:AppenderSkeleton.DoAppend(LoggingEvent)"/>
- /// method.
- /// </summary>
- /// <param name="loggingEvent">The event to log.</param>
- /// <remarks>
- /// <para>
- /// Writes a log statement to the output stream if the output stream exists
- /// and is writable.
- /// </para>
- /// <para>
- /// The format of the output will depend on the appender's layout.
- /// </para>
- /// </remarks>
- protected override void Append(LoggingEvent loggingEvent)
- {
- if (m_stream.AcquireLock())
- {
- try
- {
- base.Append(loggingEvent);
- }
- finally
- {
- m_stream.ReleaseLock();
- }
- }
- }
-
- /// <summary>
- /// This method is called by the <see cref="M:AppenderSkeleton.DoAppend(LoggingEvent[])"/>
- /// method.
- /// </summary>
- /// <param name="loggingEvents">The array of events to log.</param>
- /// <remarks>
- /// <para>
- /// Acquires the output file locks once before writing all the events to
- /// the stream.
- /// </para>
- /// </remarks>
- protected override void Append(LoggingEvent[] loggingEvents)
- {
- if (m_stream.AcquireLock())
- {
- try
- {
- base.Append(loggingEvents);
- }
- finally
- {
- m_stream.ReleaseLock();
- }
- }
- }
-
- /// <summary>
- /// Writes a footer as produced by the embedded layout's <see cref="ILayout.Footer"/> property.
- /// </summary>
- /// <remarks>
- /// <para>
- /// Writes a footer as produced by the embedded layout's <see cref="ILayout.Footer"/> property.
- /// </para>
- /// </remarks>
- protected override void WriteFooter()
- {
- if (m_stream != null)
- {
- //WriteFooter can be called even before a file is opened
- m_stream.AcquireLock();
- try
- {
- base.WriteFooter();
- }
- finally
- {
- m_stream.ReleaseLock();
- }
- }
- }
-
- /// <summary>
- /// Writes a header produced by the embedded layout's <see cref="ILayout.Header"/> property.
- /// </summary>
- /// <remarks>
- /// <para>
- /// Writes a header produced by the embedded layout's <see cref="ILayout.Header"/> property.
- /// </para>
- /// </remarks>
- protected override void WriteHeader()
- {
- if (m_stream != null)
- {
- if (m_stream.AcquireLock())
- {
- try
- {
- base.WriteHeader();
- }
- finally
- {
- m_stream.ReleaseLock();
- }
- }
- }
- }
-
- /// <summary>
- /// Closes the underlying <see cref="TextWriter"/>.
- /// </summary>
- /// <remarks>
- /// <para>
- /// Closes the underlying <see cref="TextWriter"/>.
- /// </para>
- /// </remarks>
- protected override void CloseWriter()
- {
- if (m_stream != null)
- {
- m_stream.AcquireLock();
- try
- {
- base.CloseWriter();
- }
- finally
- {
- m_stream.ReleaseLock();
- }
- }
- }
-
- #endregion Override implementation of TextWriterAppender
-
- #region Public Instance Methods
-
- /// <summary>
- /// Closes the previously opened file.
- /// </summary>
- /// <remarks>
- /// <para>
- /// Writes the <see cref="ILayout.Footer"/> to the file and then
- /// closes the file.
- /// </para>
- /// </remarks>
- protected void CloseFile()
- {
- WriteFooterAndCloseWriter();
- }
-
- #endregion Public Instance Methods
-
- #region Protected Instance Methods
-
- /// <summary>
- /// Sets and <i>opens</i> the file where the log output will go. The specified file must be writable.
- /// </summary>
- /// <param name="fileName">The path to the log file. Must be a fully qualified path.</param>
- /// <param name="append">If true will append to fileName. Otherwise will truncate fileName</param>
- /// <remarks>
- /// <para>
- /// Calls <see cref="OpenFile"/> but guarantees not to throw an exception.
- /// Errors are passed to the <see cref="TextWriterAppender.ErrorHandler"/>.
- /// </para>
- /// </remarks>
- protected virtual void SafeOpenFile(string fileName, bool append)
- {
- try
- {
- OpenFile(fileName, append);
- }
- catch (Exception e)
- {
- ErrorHandler.Error("OpenFile(" + fileName + "," + append + ") call failed.", e,
- ErrorCode.FileOpenFailure);
- }
- }
-
- /// <summary>
- /// Sets and <i>opens</i> the file where the log output will go. The specified file must be writable.
- /// </summary>
- /// <param name="fileName">The path to the log file. Must be a fully qualified path.</param>
- /// <param name="append">If true will append to fileName. Otherwise will truncate fileName</param>
- /// <remarks>
- /// <para>
- /// If there was already an opened file, then the previous file
- /// is closed first.
- /// </para>
- /// <para>
- /// This method will ensure that the directory structure
- /// for the <paramref name="fileName"/> specified exists.
- /// </para>
- /// </remarks>
- protected virtual void OpenFile(string fileName, bool append)
- {
- if (LogLog.IsErrorEnabled)
- {
- // Internal check that the fileName passed in is a rooted path
- bool isPathRooted = false;
- using (SecurityContext.Impersonate(this))
- {
- isPathRooted = Path.IsPathRooted(fileName);
- }
-
- if (!isPathRooted)
- {
- LogLog.Error(declaringType,
- "INTERNAL ERROR. OpenFile(" + fileName + "): File name is not fully qualified.");
- }
- }
-
- lock (this)
- {
- Reset();
-
- LogLog.Debug(declaringType, "Opening file for writing [" + fileName + "] append [" + append + "]");
-
- // Save these for later, allowing retries if file open fails
- m_fileName = fileName;
- m_appendToFile = append;
-
- LockingModel.CurrentAppender = this;
- LockingModel.OpenFile(fileName, append, m_encoding);
- m_stream = new LockingStream(LockingModel);
-
- if (m_stream != null)
- {
- m_stream.AcquireLock();
- try
- {
- SetQWForFiles(m_stream);
- }
- finally
- {
- m_stream.ReleaseLock();
- }
- }
-
- WriteHeader();
- }
- }
-
- /// <summary>
- /// Sets the quiet writer used for file output
- /// </summary>
- /// <param name="fileStream">the file stream that has been opened for writing</param>
- /// <remarks>
- /// <para>
- /// This implementation of <see cref="M:SetQWForFiles(Stream)"/> creates a <see cref="StreamWriter"/>
- /// over the <paramref name="fileStream"/> and passes it to the
- /// <see cref="M:SetQWForFiles(TextWriter)"/> method.
- /// </para>
- /// <para>
- /// This method can be overridden by sub classes that want to wrap the
- /// <see cref="Stream"/> in some way, for example to encrypt the output
- /// data using a <c>System.Security.Cryptography.CryptoStream</c>.
- /// </para>
- /// </remarks>
- protected virtual void SetQWForFiles(Stream fileStream)
- {
-#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>
- /// Sets the quiet writer being used.
- /// </summary>
- /// <param name="writer">the writer over the file stream that has been opened for writing</param>
- /// <remarks>
- /// <para>
- /// This method can be overridden by sub classes that want to
- /// wrap the <see cref="TextWriter"/> in some way.
- /// </para>
- /// </remarks>
- protected virtual void SetQWForFiles(TextWriter writer)
- {
- QuietWriter = new QuietTextWriter(writer, ErrorHandler);
- }
-
- #endregion Protected Instance Methods
-
- #region Protected Static Methods
-
- /// <summary>
- /// Convert a path into a fully qualified path.
- /// </summary>
- /// <param name="path">The path to convert.</param>
- /// <returns>The fully qualified path.</returns>
- /// <remarks>
- /// <para>
- /// Converts the path specified to a fully
- /// qualified path. If the path is relative it is
- /// taken as relative from the application base
- /// directory.
- /// </para>
- /// </remarks>
- protected static string ConvertToFullPath(string path)
- {
- return SystemInfo.ConvertToFullPath(path);
- }
-
- #endregion Protected Static Methods
-
- #region Private Instance Fields
-
- /// <summary>
- /// Flag to indicate if we should append to the file
- /// or overwrite the file. The default is to append.
- /// </summary>
- private bool m_appendToFile = true;
-
- /// <summary>
- /// The name of the log file.
- /// </summary>
- private string m_fileName = null;
-
- /// <summary>
- /// The encoding to use for the file stream.
- /// </summary>
- private Encoding m_encoding = Encoding.GetEncoding(0);
-
- /// <summary>
- /// The security context to use for privileged calls
- /// </summary>
- private SecurityContext m_securityContext;
-
- /// <summary>
- /// The stream to log to. Has added locking semantics
- /// </summary>
- private FileAppender.LockingStream m_stream = null;
-
- /// <summary>
- /// The locking model to use
- /// </summary>
- private FileAppender.LockingModelBase m_lockingModel;
-
- #endregion Private Instance Fields
-
- #region Private Static Fields
-
- /// <summary>
- /// The fully qualified type of the FileAppender class.
- /// </summary>
- /// <remarks>
- /// Used by the internal logger to record the Type of the
- /// log message.
- /// </remarks>
- private static readonly Type declaringType = typeof(FileAppender);
-
- #endregion Private Static Fields
+ public FileAppender.LockingModelBase LockingModel
+ {
+ get { return m_lockingModel; }
+ set { m_lockingModel = value; }
}
+
+ #endregion Public Instance Properties
+
+ #region Override implementation of AppenderSkeleton
+
+ /// <summary>
+ /// Activate the options on the file appender.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// This is part of the <see cref="IOptionHandler"/> delayed object
+ /// activation scheme. The <see cref="ActivateOptions"/> method must
+ /// be called on this object after the configuration properties have
+ /// been set. Until <see cref="ActivateOptions"/> is called this
+ /// object is in an undefined state and must not be used.
+ /// </para>
+ /// <para>
+ /// If any of the configuration properties are modified then
+ /// <see cref="ActivateOptions"/> must be called again.
+ /// </para>
+ /// <para>
+ /// This will cause the file to be opened.
+ /// </para>
+ /// </remarks>
+ public override void ActivateOptions()
+ {
+ base.ActivateOptions();
+
+ if (m_securityContext == null)
+ {
+ m_securityContext = SecurityContextProvider.DefaultProvider.CreateSecurityContext(this);
+ }
+
+ if (m_lockingModel == null)
+ {
+ m_lockingModel = (LockingModelBase)Activator.CreateInstance(defaultLockingModelType);
+ }
+
+ m_lockingModel.CurrentAppender = this;
+ m_lockingModel.ActivateOptions();
+
+ if (m_fileName != null)
+ {
+ using (SecurityContext.Impersonate(this))
+ {
+ m_fileName = ConvertToFullPath(m_fileName.Trim());
+ }
+
+ SafeOpenFile(m_fileName, m_appendToFile);
+ }
+ else
+ {
+ LogLog.Warn(declaringType, "FileAppender: File option not set for appender [" + Name + "].");
+ LogLog.Warn(declaringType, "FileAppender: Are you using FileAppender instead of ConsoleAppender?");
+ }
+ }
+
+ #endregion Override implementation of AppenderSkeleton
+
+ #region Override implementation of TextWriterAppender
+
+ /// <summary>
+ /// Closes any previously opened file and calls the parent's <see cref="TextWriterAppender.Reset"/>.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Resets the filename and the file stream.
+ /// </para>
+ /// </remarks>
+ protected override void Reset()
+ {
+ base.Reset();
+ m_fileName = null;
+ }
+
+ /// <summary>
+ /// Close this appender instance. The underlying stream or writer is also closed.
+ /// </summary>
+ protected override void OnClose()
+ {
+ base.OnClose();
+ m_lockingModel.OnClose();
+ }
+
+ /// <summary>
+ /// Called to initialize the file writer
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Will be called for each logged message until the file is
+ /// successfully opened.
+ /// </para>
+ /// </remarks>
+ protected override void PrepareWriter()
+ {
+ SafeOpenFile(m_fileName, m_appendToFile);
+ }
+
+ /// <summary>
+ /// This method is called by the <see cref="M:AppenderSkeleton.DoAppend(LoggingEvent)"/>
+ /// method.
+ /// </summary>
+ /// <param name="loggingEvent">The event to log.</param>
+ /// <remarks>
+ /// <para>
+ /// Writes a log statement to the output stream if the output stream exists
+ /// and is writable.
+ /// </para>
+ /// <para>
+ /// The format of the output will depend on the appender's layout.
+ /// </para>
+ /// </remarks>
+ protected override void Append(LoggingEvent loggingEvent)
+ {
+ if (m_stream.AcquireLock())
+ {
+ try
+ {
+ base.Append(loggingEvent);
+ }
+ finally
+ {
+ m_stream.ReleaseLock();
+ }
+ }
+ }
+
+ /// <summary>
+ /// This method is called by the <see cref="M:AppenderSkeleton.DoAppend(LoggingEvent[])"/>
+ /// method.
+ /// </summary>
+ /// <param name="loggingEvents">The array of events to log.</param>
+ /// <remarks>
+ /// <para>
+ /// Acquires the output file locks once before writing all the events to
+ /// the stream.
+ /// </para>
+ /// </remarks>
+ protected override void Append(LoggingEvent[] loggingEvents)
+ {
+ if (m_stream.AcquireLock())
+ {
+ try
+ {
+ base.Append(loggingEvents);
+ }
+ finally
+ {
+ m_stream.ReleaseLock();
+ }
+ }
+ }
+
+ /// <summary>
+ /// Writes a footer as produced by the embedded layout's <see cref="ILayout.Footer"/> property.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Writes a footer as produced by the embedded layout's <see cref="ILayout.Footer"/> property.
+ /// </para>
+ /// </remarks>
+ protected override void WriteFooter()
+ {
+ if (m_stream != null)
+ {
+ //WriteFooter can be called even before a file is opened
+ m_stream.AcquireLock();
+ try
+ {
+ base.WriteFooter();
+ }
+ finally
+ {
+ m_stream.ReleaseLock();
+ }
+ }
+ }
+
+ /// <summary>
+ /// Writes a header produced by the embedded layout's <see cref="ILayout.Header"/> property.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Writes a header produced by the embedded layout's <see cref="ILayout.Header"/> property.
+ /// </para>
+ /// </remarks>
+ protected override void WriteHeader()
+ {
+ if (m_stream != null)
+ {
+ if (m_stream.AcquireLock())
+ {
+ try
+ {
+ base.WriteHeader();
+ }
+ finally
+ {
+ m_stream.ReleaseLock();
+ }
+ }
+ }
+ }
+
+ /// <summary>
+ /// Closes the underlying <see cref="TextWriter"/>.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Closes the underlying <see cref="TextWriter"/>.
+ /// </para>
+ /// </remarks>
+ protected override void CloseWriter()
+ {
+ if (m_stream != null)
+ {
+ m_stream.AcquireLock();
+ try
+ {
+ base.CloseWriter();
+ }
+ finally
+ {
+ m_stream.ReleaseLock();
+ }
+ }
+ }
+
+ #endregion Override implementation of TextWriterAppender
+
+ #region Public Instance Methods
+
+ /// <summary>
+ /// Closes the previously opened file.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Writes the <see cref="ILayout.Footer"/> to the file and then
+ /// closes the file.
+ /// </para>
+ /// </remarks>
+ protected void CloseFile()
+ {
+ WriteFooterAndCloseWriter();
+ }
+
+ #endregion Public Instance Methods
+
+ #region Protected Instance Methods
+
+ /// <summary>
+ /// Sets and <i>opens</i> the file where the log output will go. The specified file must be writable.
+ /// </summary>
+ /// <param name="fileName">The path to the log file. Must be a fully qualified path.</param>
+ /// <param name="append">If true will append to fileName. Otherwise will truncate fileName</param>
+ /// <remarks>
+ /// <para>
+ /// Calls <see cref="OpenFile"/> but guarantees not to throw an exception.
+ /// Errors are passed to the <see cref="TextWriterAppender.ErrorHandler"/>.
+ /// </para>
+ /// </remarks>
+ protected virtual void SafeOpenFile(string fileName, bool append)
+ {
+ try
+ {
+ OpenFile(fileName, append);
+ }
+ catch (Exception e)
+ {
+ ErrorHandler.Error("OpenFile(" + fileName + "," + append + ") call failed.", e,
+ ErrorCode.FileOpenFailure);
+ }
+ }
+
+ /// <summary>
+ /// Sets and <i>opens</i> the file where the log output will go. The specified file must be writable.
+ /// </summary>
+ /// <param name="fileName">The path to the log file. Must be a fully qualified path.</param>
+ /// <param name="append">If true will append to fileName. Otherwise will truncate fileName</param>
+ /// <remarks>
+ /// <para>
+ /// If there was already an opened file, then the previous file
+ /// is closed first.
+ /// </para>
+ /// <para>
+ /// This method will ensure that the directory structure
+ /// for the <paramref name="fileName"/> specified exists.
+ /// </para>
+ /// </remarks>
+ protected virtual void OpenFile(string fileName, bool append)
+ {
+ if (LogLog.IsErrorEnabled)
+ {
+ // Internal check that the fileName passed in is a rooted path
+ bool isPathRooted = false;
+ using (SecurityContext.Impersonate(this))
+ {
+ isPathRooted = Path.IsPathRooted(fileName);
+ }
+
+ if (!isPathRooted)
+ {
+ LogLog.Error(declaringType,
+ "INTERNAL ERROR. OpenFile(" + fileName + "): File name is not fully qualified.");
+ }
+ }
+
+ lock (this)
+ {
+ Reset();
+
+ LogLog.Debug(declaringType, "Opening file for writing [" + fileName + "] append [" + append + "]");
+
+ // Save these for later, allowing retries if file open fails
+ m_fileName = fileName;
+ m_appendToFile = append;
+
+ LockingModel.CurrentAppender = this;
+ LockingModel.OpenFile(fileName, append, m_encoding);
+ m_stream = new LockingStream(LockingModel);
+
+ if (m_stream != null)
+ {
+ m_stream.AcquireLock();
+ try
+ {
+ SetQWForFiles(m_stream);
+ }
+ finally
+ {
+ m_stream.ReleaseLock();
+ }
+ }
+
+ WriteHeader();
+ }
+ }
+
+ /// <summary>
+ /// Sets the quiet writer used for file output
+ /// </summary>
+ /// <param name="fileStream">the file stream that has been opened for writing</param>
+ /// <remarks>
+ /// <para>
+ /// This implementation of <see cref="M:SetQWForFiles(Stream)"/> creates a <see cref="StreamWriter"/>
+ /// over the <paramref name="fileStream"/> and passes it to the
+ /// <see cref="M:SetQWForFiles(TextWriter)"/> method.
+ /// </para>
+ /// <para>
+ /// This method can be overridden by sub classes that want to wrap the
+ /// <see cref="Stream"/> in some way, for example to encrypt the output
+ /// data using a <c>System.Security.Cryptography.CryptoStream</c>.
+ /// </para>
+ /// </remarks>
+ protected virtual void SetQWForFiles(Stream fileStream)
+ {
+#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>
+ /// Sets the quiet writer being used.
+ /// </summary>
+ /// <param name="writer">the writer over the file stream that has been opened for writing</param>
+ /// <remarks>
+ /// <para>
+ /// This method can be overridden by sub classes that want to
+ /// wrap the <see cref="TextWriter"/> in some way.
+ /// </para>
+ /// </remarks>
+ protected virtual void SetQWForFiles(TextWriter writer)
+ {
+ QuietWriter = new QuietTextWriter(writer, ErrorHandler);
+ }
+
+ #endregion Protected Instance Methods
+
+ #region Protected Static Methods
+
+ /// <summary>
+ /// Convert a path into a fully qualified path.
+ /// </summary>
+ /// <param name="path">The path to convert.</param>
+ /// <returns>The fully qualified path.</returns>
+ /// <remarks>
+ /// <para>
+ /// Converts the path specified to a fully
+ /// qualified path. If the path is relative it is
+ /// taken as relative from the application base
+ /// directory.
+ /// </para>
+ /// </remarks>
+ protected static string ConvertToFullPath(string path)
+ {
+ return SystemInfo.ConvertToFullPath(path);
+ }
+
+ #endregion Protected Static Methods
+
+ #region Private Instance Fields
+
+ /// <summary>
+ /// Flag to indicate if we should append to the file
+ /// or overwrite the file. The default is to append.
+ /// </summary>
+ private bool m_appendToFile = true;
+
+ /// <summary>
+ /// The name of the log file.
+ /// </summary>
+ private string m_fileName = null;
+
+ /// <summary>
+ /// The encoding to use for the file stream.
+ /// </summary>
+ private Encoding m_encoding = Encoding.GetEncoding(0);
+
+ /// <summary>
+ /// The security context to use for privileged calls
+ /// </summary>
+ private SecurityContext m_securityContext;
+
+ /// <summary>
+ /// The stream to log to. Has added locking semantics
+ /// </summary>
+ private FileAppender.LockingStream m_stream = null;
+
+ /// <summary>
+ /// The locking model to use
+ /// </summary>
+ private FileAppender.LockingModelBase m_lockingModel;
+
+ #endregion Private Instance Fields
+
+ #region Private Static Fields
+
+ /// <summary>
+ /// The fully qualified type of the FileAppender class.
+ /// </summary>
+ /// <remarks>
+ /// Used by the internal logger to record the Type of the
+ /// log message.
+ /// </remarks>
+ private static readonly Type declaringType = typeof(FileAppender);
+
+ #endregion Private Static Fields
+ }
}
\ No newline at end of file
diff --git a/src/log4net/Appender/ForwardingAppender.cs b/src/log4net/Appender/ForwardingAppender.cs
index f1a1396..57d2907 100644
--- a/src/log4net/Appender/ForwardingAppender.cs
+++ b/src/log4net/Appender/ForwardingAppender.cs
@@ -71,7 +71,7 @@
protected override void OnClose()
{
// Remove all the attached appenders
- lock(this)
+ lock (this)
{
if (m_appenderAttachedImpl != null)
{
@@ -89,14 +89,14 @@
/// Delivers the logging event to all the attached appenders.
/// </para>
/// </remarks>
- protected override void Append(LoggingEvent loggingEvent)
+ protected override void Append(LoggingEvent loggingEvent)
{
// Pass the logging event on the the attached appenders
if (m_appenderAttachedImpl != null)
{
m_appenderAttachedImpl.AppendLoopOnAppenders(loggingEvent);
}
- }
+ }
/// <summary>
/// Forward the logging events to the attached appenders
@@ -107,14 +107,14 @@
/// Delivers the logging events to all the attached appenders.
/// </para>
/// </remarks>
- protected override void Append(LoggingEvent[] loggingEvents)
+ protected override void Append(LoggingEvent[] loggingEvents)
{
// Pass the logging event on the the attached appenders
if (m_appenderAttachedImpl != null)
{
m_appenderAttachedImpl.AppendLoopOnAppenders(loggingEvents);
}
- }
+ }
#endregion Override implementation of AppenderSkeleton
@@ -131,15 +131,15 @@
/// appenders, then it won't be added again.
/// </para>
/// </remarks>
- public virtual void AddAppender(IAppender newAppender)
+ public virtual void AddAppender(IAppender newAppender)
{
if (newAppender == null)
{
throw new ArgumentNullException("newAppender");
}
- lock(this)
+ lock (this)
{
- if (m_appenderAttachedImpl == null)
+ if (m_appenderAttachedImpl == null)
{
m_appenderAttachedImpl = new log4net.Util.AppenderAttachedImpl();
}
@@ -158,17 +158,17 @@
/// <returns>
/// A collection of the appenders in this appender.
/// </returns>
- public virtual AppenderCollection Appenders
+ public virtual AppenderCollection Appenders
{
get
{
- lock(this)
+ lock (this)
{
if (m_appenderAttachedImpl == null)
{
return AppenderCollection.EmptyCollection;
}
- else
+ else
{
return m_appenderAttachedImpl.Appenders;
}
@@ -188,9 +188,9 @@
/// Get the named appender attached to this appender.
/// </para>
/// </remarks>
- public virtual IAppender GetAppender(string name)
+ public virtual IAppender GetAppender(string name)
{
- lock(this)
+ lock (this)
{
if (m_appenderAttachedImpl == null || name == null)
{
@@ -209,11 +209,11 @@
/// This is useful when re-reading configuration information.
/// </para>
/// </remarks>
- public virtual void RemoveAllAppenders()
+ public virtual void RemoveAllAppenders()
{
- lock(this)
+ lock (this)
{
- if (m_appenderAttachedImpl != null)
+ if (m_appenderAttachedImpl != null)
{
m_appenderAttachedImpl.RemoveAllAppenders();
m_appenderAttachedImpl = null;
@@ -231,11 +231,11 @@
/// If you are discarding the appender you must call
/// <see cref="IAppender.Close"/> on the appender removed.
/// </remarks>
- public virtual IAppender RemoveAppender(IAppender appender)
+ public virtual IAppender RemoveAppender(IAppender appender)
{
- lock(this)
+ lock (this)
{
- if (appender != null && m_appenderAttachedImpl != null)
+ if (appender != null && m_appenderAttachedImpl != null)
{
return m_appenderAttachedImpl.RemoveAppender(appender);
}
@@ -253,9 +253,9 @@
/// If you are discarding the appender you must call
/// <see cref="IAppender.Close"/> on the appender removed.
/// </remarks>
- public virtual IAppender RemoveAppender(string name)
+ public virtual IAppender RemoveAppender(string name)
{
- lock(this)
+ lock (this)
{
if (name != null && m_appenderAttachedImpl != null)
{
@@ -264,7 +264,7 @@
}
return null;
}
-
+
#endregion Implementation of IAppenderAttachable
#region Private Instance Fields
diff --git a/src/log4net/Appender/IFlushable.cs b/src/log4net/Appender/IFlushable.cs
index 2cb7ae3..65c7bbf 100644
--- a/src/log4net/Appender/IFlushable.cs
+++ b/src/log4net/Appender/IFlushable.cs
@@ -21,39 +21,39 @@
namespace log4net.Appender
{
+ /// <summary>
+ /// Interface that can be implemented by Appenders that buffer logging data and expose a <see cref="Flush"/> method.
+ /// </summary>
+ public interface IFlushable
+ {
/// <summary>
- /// Interface that can be implemented by Appenders that buffer logging data and expose a <see cref="Flush"/> method.
+ /// Flushes any buffered log data.
/// </summary>
- public interface IFlushable
- {
- /// <summary>
- /// Flushes any buffered log data.
- /// </summary>
- /// <remarks>
- /// Appenders that implement the <see cref="Flush"/> method must do so in a thread-safe manner: it can be called concurrently with
- /// the <see cref="log4net.Appender.IAppender.DoAppend"/> method.
- /// <para>
- /// Typically this is done by locking on the Appender instance, e.g.:
- /// <code>
- /// <![CDATA[
- /// public bool Flush(int millisecondsTimeout)
- /// {
- /// lock(this)
- /// {
- /// // Flush buffered logging data
- /// ...
- /// }
- /// }
- /// ]]>
- /// </code>
- /// </para>
- /// <para>
- /// The <paramref name="millisecondsTimeout"/> parameter is only relevant for appenders that process logging events asynchronously,
- /// such as <see cref="RemotingAppender"/>.
- /// </para>
- /// </remarks>
- /// <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>
- bool Flush(int millisecondsTimeout);
- }
+ /// <remarks>
+ /// Appenders that implement the <see cref="Flush"/> method must do so in a thread-safe manner: it can be called concurrently with
+ /// the <see cref="log4net.Appender.IAppender.DoAppend"/> method.
+ /// <para>
+ /// Typically this is done by locking on the Appender instance, e.g.:
+ /// <code>
+ /// <![CDATA[
+ /// public bool Flush(int millisecondsTimeout)
+ /// {
+ /// lock(this)
+ /// {
+ /// // Flush buffered logging data
+ /// ...
+ /// }
+ /// }
+ /// ]]>
+ /// </code>
+ /// </para>
+ /// <para>
+ /// The <paramref name="millisecondsTimeout"/> parameter is only relevant for appenders that process logging events asynchronously,
+ /// such as <see cref="RemotingAppender"/>.
+ /// </para>
+ /// </remarks>
+ /// <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>
+ bool Flush(int millisecondsTimeout);
+ }
}
diff --git a/src/log4net/Appender/LocalSyslogAppender.cs b/src/log4net/Appender/LocalSyslogAppender.cs
index 3cd0c16..549d2ee 100644
--- a/src/log4net/Appender/LocalSyslogAppender.cs
+++ b/src/log4net/Appender/LocalSyslogAppender.cs
@@ -27,7 +27,7 @@
using log4net.Core;
using log4net.Util;
-namespace log4net.Appender
+namespace log4net.Appender
{
/// <summary>
/// Logs events to a local syslog service.
@@ -62,7 +62,7 @@
/// </remarks>
/// <author>Rob Lyon</author>
/// <author>Nicko Cadell</author>
- public class LocalSyslogAppender : AppenderSkeleton
+ public class LocalSyslogAppender : AppenderSkeleton
{
#region Enumerations
@@ -262,14 +262,14 @@
/// This instance of the <see cref="LocalSyslogAppender" /> class is set up to write
/// to a local syslog service.
/// </remarks>
- public LocalSyslogAppender()
+ public LocalSyslogAppender()
{
}
#endregion // Public Instance Constructors
#region Public Instance Properties
-
+
/// <summary>
/// Message identity
/// </summary>
@@ -300,7 +300,7 @@
get { return m_facility; }
set { m_facility = value; }
}
-
+
#endregion // Public Instance Properties
/// <summary>
@@ -341,7 +341,7 @@
public override void ActivateOptions()
{
base.ActivateOptions();
-
+
m_levelMapping.ActivateOptions();
string identString = m_identity;
@@ -382,7 +382,7 @@
#if !NETSTANDARD1_3
[System.Security.Permissions.SecurityPermission(System.Security.Permissions.SecurityAction.Demand, UnmanagedCode = true)]
#endif
- protected override void Append(LoggingEvent loggingEvent)
+ protected override void Append(LoggingEvent loggingEvent)
{
int priority = GeneratePriority(m_facility, GetSeverity(loggingEvent.Level));
string message = RenderLoggingEvent(loggingEvent);
@@ -412,11 +412,11 @@
// close syslog
closelog();
}
- catch(DllNotFoundException)
+ catch (DllNotFoundException)
{
// Ignore dll not found at this point
}
-
+
if (m_handleToIdentity != IntPtr.Zero)
{
// free global ident
@@ -464,30 +464,30 @@
// Fallback to sensible default values
//
- if (level >= Level.Alert)
+ if (level >= Level.Alert)
{
return SyslogSeverity.Alert;
- }
- else if (level >= Level.Critical)
+ }
+ else if (level >= Level.Critical)
{
return SyslogSeverity.Critical;
- }
- else if (level >= Level.Error)
+ }
+ else if (level >= Level.Error)
{
return SyslogSeverity.Error;
- }
- else if (level >= Level.Warn)
+ }
+ else if (level >= Level.Warn)
{
return SyslogSeverity.Warning;
- }
- else if (level >= Level.Notice)
+ }
+ else if (level >= Level.Notice)
{
return SyslogSeverity.Notice;
- }
- else if (level >= Level.Info)
+ }
+ else if (level >= Level.Info)
{
return SyslogSeverity.Informational;
- }
+ }
// Default setting
return SyslogSeverity.Debug;
}
@@ -536,7 +536,7 @@
#endregion // Private Instances Fields
#region External Members
-
+
/// <summary>
/// Open connection to system logger.
/// </summary>
@@ -555,7 +555,7 @@
/// string to <c>"%s"</c>.
/// </para>
/// </remarks>
- [DllImport("libc", CharSet=CharSet.Ansi, CallingConvention=CallingConvention.Cdecl)]
+ [DllImport("libc", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
private static extern void syslog(int priority, string format, string message);
/// <summary>
diff --git a/src/log4net/Appender/ManagedColoredConsoleAppender.cs b/src/log4net/Appender/ManagedColoredConsoleAppender.cs
index ecc6949..263ce17 100644
--- a/src/log4net/Appender/ManagedColoredConsoleAppender.cs
+++ b/src/log4net/Appender/ManagedColoredConsoleAppender.cs
@@ -98,7 +98,7 @@
/// <author>Rick Hobbs</author>
/// <author>Nicko Cadell</author>
/// <author>Pavlos Touboulidis</author>
- public class ManagedColoredConsoleAppender: AppenderSkeleton
+ public class ManagedColoredConsoleAppender : AppenderSkeleton
{
/// <summary>
/// Initializes a new instance of the <see cref="ManagedColoredConsoleAppender" /> class.
@@ -107,10 +107,10 @@
/// The instance of the <see cref="ManagedColoredConsoleAppender" /> class is set up to write
/// to the standard output stream.
/// </remarks>
- public ManagedColoredConsoleAppender()
+ public ManagedColoredConsoleAppender()
{
}
-
+
#region Public Instance Properties
/// <summary>
/// Target is the value of the console output stream.
@@ -136,8 +136,8 @@
if (SystemInfo.EqualsIgnoringCase(ConsoleError, v))
{
m_writeToErrorStream = true;
- }
- else
+ }
+ else
{
m_writeToErrorStream = false;
}
@@ -174,18 +174,18 @@
/// The format of the output will depend on the appender's layout.
/// </para>
/// </remarks>
- protected override void Append(log4net.Core.LoggingEvent loggingEvent)
+ protected override void Append(log4net.Core.LoggingEvent loggingEvent)
{
System.IO.TextWriter writer;
-
+
if (m_writeToErrorStream)
writer = Console.Error;
else
writer = Console.Out;
-
+
// Reset color
Console.ResetColor();
-
+
// see if there is a specified lookup
LevelColors levelColors = m_levelMapping.Lookup(loggingEvent.Level) as LevelColors;
if (levelColors != null)
@@ -197,7 +197,7 @@
if (levelColors.HasForeColor)
Console.ForegroundColor = levelColors.ForeColor;
}
-
+
// Render the event to a string
string strLoggingMessage = RenderLoggingEvent(loggingEvent);
// and write it
@@ -304,11 +304,13 @@
}
private ConsoleColor foreColor;
private bool hasForeColor;
- internal bool HasForeColor {
- get {
- return hasForeColor;
- }
- }
+ internal bool HasForeColor
+ {
+ get
+ {
+ return hasForeColor;
+ }
+ }
/// <summary>
/// The mapped background color for the specified level
@@ -327,12 +329,14 @@
set { this.backColor = value; this.hasBackColor = true; }
}
private ConsoleColor backColor;
- private bool hasBackColor;
- internal bool HasBackColor {
- get {
- return hasBackColor;
- }
- }
+ private bool hasBackColor;
+ internal bool HasBackColor
+ {
+ get
+ {
+ return hasBackColor;
+ }
+ }
}
#endregion // LevelColors LevelMapping Entry
}
diff --git a/src/log4net/Appender/MemoryAppender.cs b/src/log4net/Appender/MemoryAppender.cs
index 5c30c2b..486a410 100644
--- a/src/log4net/Appender/MemoryAppender.cs
+++ b/src/log4net/Appender/MemoryAppender.cs
@@ -86,10 +86,10 @@
/// </remarks>
public virtual LoggingEvent[] GetEvents()
{
- lock (m_eventsList.SyncRoot)
- {
- return (LoggingEvent[]) m_eventsList.ToArray(typeof(LoggingEvent));
- }
+ lock (m_eventsList.SyncRoot)
+ {
+ return (LoggingEvent[])m_eventsList.ToArray(typeof(LoggingEvent));
+ }
}
/// <summary>
@@ -113,8 +113,8 @@
public virtual bool OnlyFixPartialEventData
{
get { return (Fix == FixFlags.Partial); }
- set
- {
+ set
+ {
if (value)
{
Fix = FixFlags.Partial;
@@ -153,18 +153,18 @@
/// <remarks>
/// <para>Stores the <paramref name="loggingEvent"/> in the events list.</para>
/// </remarks>
- protected override void Append(LoggingEvent loggingEvent)
+ protected override void Append(LoggingEvent loggingEvent)
{
// Because we are caching the LoggingEvent beyond the
// lifetime of the Append() method we must fix any
// volatile data in the event.
loggingEvent.Fix = this.Fix;
- lock (m_eventsList.SyncRoot)
- {
- m_eventsList.Add(loggingEvent);
- }
- }
+ lock (m_eventsList.SyncRoot)
+ {
+ m_eventsList.Add(loggingEvent);
+ }
+ }
#endregion Override implementation of AppenderSkeleton
@@ -178,30 +178,30 @@
/// </remarks>
public virtual void Clear()
{
- lock (m_eventsList.SyncRoot)
- {
- m_eventsList.Clear();
- }
+ lock (m_eventsList.SyncRoot)
+ {
+ m_eventsList.Clear();
+ }
}
- /// <summary>
- /// Gets the events that have been logged and clears the list of events.
- /// </summary>
- /// <returns>The events that have been logged</returns>
- /// <remarks>
- /// <para>
- /// Gets the events that have been logged and clears the list of events.
- /// </para>
- /// </remarks>
- public virtual LoggingEvent[] PopAllEvents()
- {
- lock (m_eventsList.SyncRoot)
- {
- LoggingEvent[] tmp = (LoggingEvent[]) m_eventsList.ToArray(typeof (LoggingEvent));
- m_eventsList.Clear();
- return tmp;
- }
- }
+ /// <summary>
+ /// Gets the events that have been logged and clears the list of events.
+ /// </summary>
+ /// <returns>The events that have been logged</returns>
+ /// <remarks>
+ /// <para>
+ /// Gets the events that have been logged and clears the list of events.
+ /// </para>
+ /// </remarks>
+ public virtual LoggingEvent[] PopAllEvents()
+ {
+ lock (m_eventsList.SyncRoot)
+ {
+ LoggingEvent[] tmp = (LoggingEvent[])m_eventsList.ToArray(typeof(LoggingEvent));
+ m_eventsList.Clear();
+ return tmp;
+ }
+ }
#endregion Public Instance Methods
diff --git a/src/log4net/Appender/NetSendAppender.cs b/src/log4net/Appender/NetSendAppender.cs
index f6fdbb5..1c0d0ae 100644
--- a/src/log4net/Appender/NetSendAppender.cs
+++ b/src/log4net/Appender/NetSendAppender.cs
@@ -35,7 +35,7 @@
using log4net.Core;
-namespace log4net.Appender
+namespace log4net.Appender
{
/// <summary>
/// Logs entries by sending network messages using the
@@ -138,7 +138,7 @@
/// </example>
/// <author>Nicko Cadell</author>
/// <author>Gert Driesen</author>
- public class NetSendAppender : AppenderSkeleton
+ public class NetSendAppender : AppenderSkeleton
{
#region Member Variables
@@ -172,7 +172,7 @@
/// <remarks>
/// The default constructor initializes all fields to their default values.
/// </remarks>
- public NetSendAppender()
+ public NetSendAppender()
{
}
@@ -189,7 +189,7 @@
/// <remarks>
/// If this property is not specified, the message is sent from the local computer.
/// </remarks>
- public string Sender
+ public string Sender
{
get { return m_sender; }
set { m_sender = value; }
@@ -204,12 +204,12 @@
/// <remarks>
/// This property should always be specified in order to send a message.
/// </remarks>
- public string Recipient
+ public string Recipient
{
get { return m_recipient; }
set { m_recipient = value; }
}
-
+
/// <summary>
/// Gets or sets the DNS or NetBIOS name of the remote server on which the function is to execute.
/// </summary>
@@ -224,7 +224,7 @@
/// If this property is not specified, the local computer is used.
/// </para>
/// </remarks>
- public string Server
+ public string Server
{
get { return m_server; }
set { m_server = value; }
@@ -244,7 +244,7 @@
/// of the current thread.
/// </para>
/// </remarks>
- public SecurityContext SecurityContext
+ public SecurityContext SecurityContext
{
get { return m_securityContext; }
set { m_securityContext = value; }
@@ -277,8 +277,8 @@
public override void ActivateOptions()
{
base.ActivateOptions();
-
- if (this.Recipient == null)
+
+ if (this.Recipient == null)
{
throw new ArgumentNullException("Recipient", "The required property 'Recipient' was not specified.");
}
@@ -308,20 +308,20 @@
#if !NETSTANDARD1_3
[System.Security.Permissions.SecurityPermission(System.Security.Permissions.SecurityAction.Demand, UnmanagedCode = true)]
#endif
- protected override void Append(LoggingEvent loggingEvent)
+ protected override void Append(LoggingEvent loggingEvent)
{
NativeError nativeError = null;
// Render the event in the callers security context
string renderedLoggingEvent = RenderLoggingEvent(loggingEvent);
- using(m_securityContext.Impersonate(this))
+ using (m_securityContext.Impersonate(this))
{
// Send the message
- int returnValue = NetMessageBufferSend(this.Server, this.Recipient, this.Sender, renderedLoggingEvent, renderedLoggingEvent.Length * Marshal.SystemDefaultCharSize);
+ int returnValue = NetMessageBufferSend(this.Server, this.Recipient, this.Sender, renderedLoggingEvent, renderedLoggingEvent.Length * Marshal.SystemDefaultCharSize);
// Log the error if the message could not be sent
- if (returnValue != 0)
+ if (returnValue != 0)
{
// Lookup the native error
nativeError = NativeError.GetError(returnValue);
@@ -407,8 +407,8 @@
/// If the function succeeds, the return value is zero.
/// </para>
/// </returns>
- [DllImport("netapi32.dll", SetLastError=true)]
- protected static extern int NetMessageBufferSend(
+ [DllImport("netapi32.dll", SetLastError = true)]
+ protected static extern int NetMessageBufferSend(
[MarshalAs(UnmanagedType.LPWStr)] string serverName,
[MarshalAs(UnmanagedType.LPWStr)] string msgName,
[MarshalAs(UnmanagedType.LPWStr)] string fromName,
diff --git a/src/log4net/Appender/OutputDebugStringAppender.cs b/src/log4net/Appender/OutputDebugStringAppender.cs
index 7a074f0..5580532 100644
--- a/src/log4net/Appender/OutputDebugStringAppender.cs
+++ b/src/log4net/Appender/OutputDebugStringAppender.cs
@@ -80,7 +80,7 @@
#if !NETCF && !NETSTANDARD1_3
[System.Security.Permissions.SecurityPermission(System.Security.Permissions.SecurityAction.Demand, UnmanagedCode = true)]
#endif
- protected override void Append(LoggingEvent loggingEvent)
+ protected override void Append(LoggingEvent loggingEvent)
{
#if NETSTANDARD
if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
@@ -90,7 +90,7 @@
#endif
OutputDebugString(RenderLoggingEvent(loggingEvent));
- }
+ }
/// <summary>
/// This appender requires a <see cref="Layout"/> to be set.
diff --git a/src/log4net/Appender/RemotingAppender.cs b/src/log4net/Appender/RemotingAppender.cs
index 7a9fd77..69a0b6b 100644
--- a/src/log4net/Appender/RemotingAppender.cs
+++ b/src/log4net/Appender/RemotingAppender.cs
@@ -141,11 +141,11 @@
#if NET_4_0 || MONO_4_0
[System.Security.SecuritySafeCritical]
#endif
- public override void ActivateOptions()
+ public override void ActivateOptions()
{
base.ActivateOptions();
- IDictionary channelProperties = new Hashtable();
+ IDictionary channelProperties = new Hashtable();
channelProperties["typeFilterLevel"] = "Full";
m_sinkObj = (IRemoteLoggingSink)Activator.GetObject(typeof(IRemoteLoggingSink), m_sinkUrl, channelProperties);
@@ -184,7 +184,7 @@
// Cancel the async send
EndAsyncSend();
- ErrorHandler.Error("RemotingAppender ["+Name+"] failed to ThreadPool.QueueUserWorkItem logging events in SendBuffer.");
+ ErrorHandler.Error("RemotingAppender [" + Name + "] failed to ThreadPool.QueueUserWorkItem logging events in SendBuffer.");
}
}
@@ -214,7 +214,7 @@
// Wait for the work queue to become empty before closing, timeout 30 seconds
if (!m_workQueueEmptyEvent.WaitOne(30 * 1000, false))
{
- ErrorHandler.Error("RemotingAppender ["+Name+"] failed to send all queued events before close, in OnClose.");
+ ErrorHandler.Error("RemotingAppender [" + Name + "] failed to send all queued events before close, in OnClose.");
}
}
@@ -274,7 +274,7 @@
// Send the events
m_sinkObj.LogEvents(events);
}
- catch(Exception ex)
+ catch (Exception ex)
{
ErrorHandler.Error("Failed in SendBufferCallback", ex);
}
diff --git a/src/log4net/Appender/RollingFileAppender.cs b/src/log4net/Appender/RollingFileAppender.cs
index b1943d7..aaf0b33 100644
--- a/src/log4net/Appender/RollingFileAppender.cs
+++ b/src/log4net/Appender/RollingFileAppender.cs
@@ -124,10 +124,10 @@
/// <author>Douglas de la Torre</author>
/// <author>Edward Smit</author>
public class RollingFileAppender : FileAppender
- {
- #region Public Enums
+ {
+ #region Public Enums
- /// <summary>
+ /// <summary>
/// Style of rolling to use
/// </summary>
/// <remarks>
@@ -152,22 +152,22 @@
/// this appender would just be a normal file appender.
/// </para>
/// </remarks>
- Once = 0,
+ Once = 0,
/// <summary>
/// Roll files based only on the size of the file
/// </summary>
- Size = 1,
+ Size = 1,
/// <summary>
/// Roll files based only on the date
/// </summary>
- Date = 2,
+ Date = 2,
/// <summary>
/// Roll files based on both the size and date of the file
/// </summary>
- Composite = 3
+ Composite = 3
}
#endregion
@@ -187,37 +187,37 @@
/// <summary>
/// Roll the log not based on the date
/// </summary>
- InvalidRollPoint =-1,
+ InvalidRollPoint = -1,
/// <summary>
/// Roll the log for each minute
/// </summary>
- TopOfMinute = 0,
+ TopOfMinute = 0,
/// <summary>
/// Roll the log for each hour
/// </summary>
- TopOfHour = 1,
+ TopOfHour = 1,
/// <summary>
/// Roll the log twice a day (midday and midnight)
/// </summary>
- HalfDay = 2,
+ HalfDay = 2,
/// <summary>
/// Roll the log each day (midnight)
/// </summary>
- TopOfDay = 3,
+ TopOfDay = 3,
/// <summary>
/// Roll the log each week
/// </summary>
- TopOfWeek = 4,
+ TopOfWeek = 4,
/// <summary>
/// Roll the log each month
/// </summary>
- TopOfMonth = 5
+ TopOfMonth = 5
}
#endregion Protected Enums
@@ -232,7 +232,7 @@
/// Default constructor.
/// </para>
/// </remarks>
- public RollingFileAppender()
+ public RollingFileAppender()
{
}
@@ -259,7 +259,7 @@
#region Public Instance Properties
#if !NET_1_0 && !CLI_1_0 && !NETCF
- /// <summary>
+ /// <summary>
/// Gets or sets the strategy for determining the current date and time. The default
/// implementation is to use LocalDateTime which internally calls through to DateTime.Now.
/// DateTime.UtcNow may be used on frameworks newer than .NET 1.0 by specifying
@@ -272,12 +272,12 @@
/// <para>
/// Gets or sets the <see cref="RollingFileAppender.IDateTime"/> used to return the current date and time.
/// </para>
- /// <para>
- /// There are two built strategies for determining the current date and time,
+ /// <para>
+ /// There are two built strategies for determining the current date and time,
/// <see cref="RollingFileAppender.LocalDateTime"/>
- /// and <see cref="RollingFileAppender.UniversalDateTime"/>.
- /// </para>
- /// <para>
+ /// and <see cref="RollingFileAppender.UniversalDateTime"/>.
+ /// </para>
+ /// <para>
/// The default strategy is <see cref="RollingFileAppender.LocalDateTime"/>.
/// </para>
/// </remarks>
@@ -298,7 +298,7 @@
/// </para>
/// </remarks>
#endif
- public IDateTime DateTimeStrategy
+ public IDateTime DateTimeStrategy
{
get { return m_dateTime; }
set { m_dateTime = value; }
@@ -327,7 +327,7 @@
get { return m_datePattern; }
set { m_datePattern = value; }
}
-
+
/// <summary>
/// Gets or sets the maximum number of backup files that are kept before
/// the oldest is erased.
@@ -356,7 +356,7 @@
get { return m_maxSizeRollBackups; }
set { m_maxSizeRollBackups = value; }
}
-
+
/// <summary>
/// Gets or sets the maximum size that the output file is allowed to reach
/// before being rolled over to backup files.
@@ -381,7 +381,7 @@
get { return m_maxFileSize; }
set { m_maxFileSize = value; }
}
-
+
/// <summary>
/// Gets or sets the maximum size that the output file is allowed to reach
/// before being rolled over to backup files.
@@ -442,7 +442,7 @@
get { return m_countDirection; }
set { m_countDirection = value; }
}
-
+
/// <summary>
/// Gets or sets the rolling style.
/// </summary>
@@ -464,7 +464,7 @@
set
{
m_rollingStyle = value;
- switch (m_rollingStyle)
+ switch (m_rollingStyle)
{
case RollingMode.Once:
m_rollDate = false;
@@ -486,30 +486,30 @@
case RollingMode.Composite:
m_rollDate = true;
m_rollSize = true;
- break;
+ break;
}
}
}
- /// <summary>
- /// Gets or sets a value indicating whether to preserve the file name extension when rolling.
- /// </summary>
- /// <value>
- /// <c>true</c> if the file name extension should be preserved.
- /// </value>
- /// <remarks>
- /// <para>
- /// By default file.log is rolled to file.log.yyyy-MM-dd or file.log.curSizeRollBackup.
- /// However, under Windows the new file name will loose any program associations as the
- /// extension is changed. Optionally file.log can be renamed to file.yyyy-MM-dd.log or
- /// file.curSizeRollBackup.log to maintain any program associations.
- /// </para>
- /// </remarks>
- public bool PreserveLogFileNameExtension
- {
- get { return m_preserveLogFileNameExtension; }
- set { m_preserveLogFileNameExtension = value; }
- }
+ /// <summary>
+ /// Gets or sets a value indicating whether to preserve the file name extension when rolling.
+ /// </summary>
+ /// <value>
+ /// <c>true</c> if the file name extension should be preserved.
+ /// </value>
+ /// <remarks>
+ /// <para>
+ /// By default file.log is rolled to file.log.yyyy-MM-dd or file.log.curSizeRollBackup.
+ /// However, under Windows the new file name will loose any program associations as the
+ /// extension is changed. Optionally file.log can be renamed to file.yyyy-MM-dd.log or
+ /// file.curSizeRollBackup.log to maintain any program associations.
+ /// </para>
+ /// </remarks>
+ public bool PreserveLogFileNameExtension
+ {
+ get { return m_preserveLogFileNameExtension; }
+ set { m_preserveLogFileNameExtension = value; }
+ }
/// <summary>
/// Gets or sets a value indicating whether to always log to
@@ -538,21 +538,21 @@
#endregion Public Instance Properties
- #region Private Static Fields
+ #region Private Static Fields
- /// <summary>
- /// The fully qualified type of the RollingFileAppender class.
- /// </summary>
- /// <remarks>
- /// Used by the internal logger to record the Type of the
- /// log message.
- /// </remarks>
- private static readonly Type declaringType = typeof(RollingFileAppender);
+ /// <summary>
+ /// The fully qualified type of the RollingFileAppender class.
+ /// </summary>
+ /// <remarks>
+ /// Used by the internal logger to record the Type of the
+ /// log message.
+ /// </remarks>
+ private static readonly Type declaringType = typeof(RollingFileAppender);
- #endregion Private Static Fields
+ #endregion Private Static Fields
#region Override implementation of FileAppender
-
+
/// <summary>
/// Sets the quiet writer being used.
/// </summary>
@@ -560,7 +560,7 @@
/// This method can be overridden by sub classes.
/// </remarks>
/// <param name="writer">the writer to set</param>
- protected override void SetQWForFiles(TextWriter writer)
+ protected override void SetQWForFiles(TextWriter writer)
{
QuietWriter = new CountingQuietTextWriter(writer, ErrorHandler);
}
@@ -576,13 +576,13 @@
/// is need and then appends to the file last.
/// </para>
/// </remarks>
- protected override void Append(LoggingEvent loggingEvent)
+ protected override void Append(LoggingEvent loggingEvent)
{
AdjustFileBeforeAppend();
base.Append(loggingEvent);
}
-
- /// <summary>
+
+ /// <summary>
/// Write out an array of logging events.
/// </summary>
/// <param name="loggingEvents">the events to write to file.</param>
@@ -593,7 +593,7 @@
/// is need and then appends to the file last.
/// </para>
/// </remarks>
- protected override void Append(LoggingEvent[] loggingEvents)
+ protected override void Append(LoggingEvent[] loggingEvents)
{
AdjustFileBeforeAppend();
base.Append(loggingEvents);
@@ -665,15 +665,15 @@
/// </remarks>
protected override void OpenFile(string fileName, bool append)
{
- lock(this)
+ lock (this)
{
fileName = GetNextOutputFileName(fileName);
// Calculate the current size of the file
long currentCount = 0;
- if (append)
+ if (append)
{
- using(SecurityContext.Impersonate(this))
+ using (SecurityContext.Impersonate(this))
{
if (System.IO.File.Exists(fileName))
{
@@ -691,12 +691,12 @@
// The only exception is if we are not allowed to roll the existing file away.
if (m_maxSizeRollBackups != 0 && FileExists(fileName))
{
- LogLog.Error(declaringType, "RollingFileAppender: INTERNAL ERROR. Append is False but OutputFile ["+fileName+"] already exists.");
+ LogLog.Error(declaringType, "RollingFileAppender: INTERNAL ERROR. Append is False but OutputFile [" + fileName + "] already exists.");
}
}
}
- if (!m_staticLogFileName)
+ if (!m_staticLogFileName)
{
m_scheduledFilename = fileName;
}
@@ -723,18 +723,18 @@
/// </remarks>
protected string GetNextOutputFileName(string fileName)
{
- if (!m_staticLogFileName)
+ if (!m_staticLogFileName)
{
fileName = fileName.Trim();
if (m_rollDate)
{
- fileName = CombinePath(fileName, m_now.ToString(m_datePattern, DateTimeFormatInfo.InvariantInfo));
+ fileName = CombinePath(fileName, m_now.ToString(m_datePattern, DateTimeFormatInfo.InvariantInfo));
}
- if (m_countDirection >= 0)
+ if (m_countDirection >= 0)
{
- fileName = CombinePath(fileName, "." + m_curSizeRollBackups);
+ fileName = CombinePath(fileName, "." + m_curSizeRollBackups);
}
}
@@ -751,11 +751,11 @@
private void DetermineCurSizeRollBackups()
{
m_curSizeRollBackups = 0;
-
+
string fullPath = null;
string fileName = null;
- using(SecurityContext.Impersonate(this))
+ using (SecurityContext.Impersonate(this))
{
fullPath = Path.GetFullPath(m_baseFileName);
fileName = Path.GetFileName(fullPath);
@@ -764,7 +764,7 @@
var arrayFiles = GetExistingFiles(fullPath);
InitializeRollBackups(fileName, arrayFiles);
- LogLog.Debug(declaringType, "curSizeRollBackups starts at ["+m_curSizeRollBackups+"]");
+ LogLog.Debug(declaringType, "curSizeRollBackups starts at [" + m_curSizeRollBackups + "]");
}
/// <summary>
@@ -775,14 +775,14 @@
/// <returns></returns>
private string GetWildcardPatternForFile(string baseFileName)
{
- if (m_preserveLogFileNameExtension)
- {
- return Path.GetFileNameWithoutExtension(baseFileName) + "*" + Path.GetExtension(baseFileName);
- }
- else
- {
- return baseFileName + '*';
- }
+ if (m_preserveLogFileNameExtension)
+ {
+ return Path.GetFileNameWithoutExtension(baseFileName) + "*" + Path.GetExtension(baseFileName);
+ }
+ else
+ {
+ return baseFileName + '*';
+ }
}
/// <summary>
@@ -797,7 +797,7 @@
string directory = null;
- using(SecurityContext.Impersonate(this))
+ using (SecurityContext.Impersonate(this))
{
var fullPath = Path.GetFullPath(baseFilePath);
@@ -807,10 +807,10 @@
var baseFileName = Path.GetFileName(fullPath);
var files = Directory.GetFiles(directory, GetWildcardPatternForFile(baseFileName));
-
+
if (files != null)
{
- for (var i = 0; i < files.Length; i++)
+ for (var i = 0; i < files.Length; i++)
{
var curFileName = Path.GetFileName(files[i]);
if (curFileName.StartsWith(Path.GetFileNameWithoutExtension(baseFileName)))
@@ -821,7 +821,7 @@
}
}
}
- LogLog.Debug(declaringType, "Searched for existing files in ["+directory+"]");
+ LogLog.Debug(declaringType, "Searched for existing files in [" + directory + "]");
return alFiles;
}
@@ -830,14 +830,15 @@
/// </summary>
private void RollOverIfDateBoundaryCrossing()
{
- if (m_staticLogFileName && m_rollDate)
+ if (m_staticLogFileName && m_rollDate)
{
- if (FileExists(m_baseFileName))
+ if (FileExists(m_baseFileName))
{
DateTime last;
- using(SecurityContext.Impersonate(this)) {
+ using (SecurityContext.Impersonate(this))
+ {
#if !NET_1_0 && !CLI_1_0 && !NETCF
- if (DateTimeStrategy is UniversalDateTime)
+ if (DateTimeStrategy is UniversalDateTime)
{
last = System.IO.File.GetLastWriteTimeUtc(m_baseFileName);
}
@@ -846,17 +847,17 @@
#endif
last = System.IO.File.GetLastWriteTime(m_baseFileName);
#if !NET_1_0 && !CLI_1_0 && !NETCF
- }
+ }
#endif
- }
- LogLog.Debug(declaringType, "["+last.ToString(m_datePattern,DateTimeFormatInfo.InvariantInfo)+"] vs. ["+m_now.ToString(m_datePattern,DateTimeFormatInfo.InvariantInfo)+"]");
+ }
+ LogLog.Debug(declaringType, "[" + last.ToString(m_datePattern, DateTimeFormatInfo.InvariantInfo) + "] vs. [" + m_now.ToString(m_datePattern, DateTimeFormatInfo.InvariantInfo) + "]");
- if (!(last.ToString(m_datePattern,DateTimeFormatInfo.InvariantInfo).Equals(m_now.ToString(m_datePattern, DateTimeFormatInfo.InvariantInfo))))
+ if (!(last.ToString(m_datePattern, DateTimeFormatInfo.InvariantInfo).Equals(m_now.ToString(m_datePattern, DateTimeFormatInfo.InvariantInfo))))
{
m_scheduledFilename = CombinePath(m_baseFileName, last.ToString(m_datePattern, DateTimeFormatInfo.InvariantInfo));
- LogLog.Debug(declaringType, "Initial roll over to ["+m_scheduledFilename+"]");
+ LogLog.Debug(declaringType, "Initial roll over to [" + m_scheduledFilename + "]");
RollOverTime(false);
- LogLog.Debug(declaringType, "curSizeRollBackups after rollOver at ["+m_curSizeRollBackups+"]");
+ LogLog.Debug(declaringType, "curSizeRollBackups after rollOver at [" + m_curSizeRollBackups + "]");
}
}
}
@@ -875,7 +876,7 @@
/// </list>
/// </para>
/// </remarks>
- protected void ExistingInit()
+ protected void ExistingInit()
{
DetermineCurSizeRollBackups();
RollOverIfDateBoundaryCrossing();
@@ -889,7 +890,7 @@
bool fileExists;
var fileName = GetNextOutputFileName(m_baseFileName);
- using(SecurityContext.Impersonate(this))
+ using (SecurityContext.Impersonate(this))
{
fileExists = System.IO.File.Exists(fileName);
}
@@ -901,11 +902,11 @@
if (m_maxSizeRollBackups == 0)
{
- LogLog.Debug(declaringType, "Output file ["+fileName+"] already exists. MaxSizeRollBackups is 0; cannot roll. Overwriting existing file.");
+ LogLog.Debug(declaringType, "Output file [" + fileName + "] already exists. MaxSizeRollBackups is 0; cannot roll. Overwriting existing file.");
}
else
{
- LogLog.Debug(declaringType, "Output file ["+fileName+"] already exists. Not appending to file. Rolling existing file out of the way.");
+ LogLog.Debug(declaringType, "Output file [" + fileName + "] already exists. Not appending to file. Rolling existing file out of the way.");
RollOverRenameFiles(fileName);
}
@@ -924,113 +925,113 @@
{
curFileName = curFileName.ToLower();
baseFile = baseFile.ToLower();
- if (curFileName.StartsWith(Path.GetFileNameWithoutExtension(baseFile)) == false)
+ if (curFileName.StartsWith(Path.GetFileNameWithoutExtension(baseFile)) == false)
{
// This is not a log file, so ignore
return;
}
- if (curFileName.Equals(baseFile))
+ if (curFileName.Equals(baseFile))
{
// Base log file is not an incremented logfile (.1 or .2, etc)
return;
}
-
+
// Only look for files in the current roll point
if (m_rollDate && !m_staticLogFileName)
{
var date = m_dateTime.Now.ToString(m_datePattern, DateTimeFormatInfo.InvariantInfo).ToLower();
- var prefix = (m_preserveLogFileNameExtension
- ? Path.GetFileNameWithoutExtension(baseFile) + date
+ var prefix = (m_preserveLogFileNameExtension
+ ? Path.GetFileNameWithoutExtension(baseFile) + date
: baseFile + date).ToLower();
- var suffix = m_preserveLogFileNameExtension
+ var suffix = m_preserveLogFileNameExtension
? Path.GetExtension(baseFile).ToLower()
: "";
if (!curFileName.StartsWith(prefix) || !curFileName.EndsWith(suffix))
{
- LogLog.Debug(declaringType, "Ignoring file ["+curFileName+"] because it is from a different date period");
+ LogLog.Debug(declaringType, "Ignoring file [" + curFileName + "] because it is from a different date period");
return;
}
}
-
- try
+
+ try
{
// Bump the counter up to the highest count seen so far
- var backup = GetBackUpIndex(curFileName);
-
- // caution: we might get a false positive when certain
- // date patterns such as yyyyMMdd are used...those are
- // valid number but aren't the kind of back up index
- // we're looking for
- if (backup > m_curSizeRollBackups)
- {
- if (0 == m_maxSizeRollBackups)
- {
- // Stay at zero when zero backups are desired
- }
- else if (-1 == m_maxSizeRollBackups)
- {
- // Infinite backups, so go as high as the highest value
- m_curSizeRollBackups = backup;
- }
- else
- {
- // Backups limited to a finite number
- if (m_countDirection >= 0)
- {
- // Go with the highest file when counting up
- m_curSizeRollBackups = backup;
- }
- else
- {
- // Clip to the limit when counting down
- if (backup <= m_maxSizeRollBackups)
- {
- m_curSizeRollBackups = backup;
- }
- }
- }
- LogLog.Debug(declaringType, "File name [" + curFileName + "] moves current count to [" + m_curSizeRollBackups + "]");
- }
- }
- catch(FormatException)
+ var backup = GetBackUpIndex(curFileName);
+
+ // caution: we might get a false positive when certain
+ // date patterns such as yyyyMMdd are used...those are
+ // valid number but aren't the kind of back up index
+ // we're looking for
+ if (backup > m_curSizeRollBackups)
+ {
+ if (0 == m_maxSizeRollBackups)
+ {
+ // Stay at zero when zero backups are desired
+ }
+ else if (-1 == m_maxSizeRollBackups)
+ {
+ // Infinite backups, so go as high as the highest value
+ m_curSizeRollBackups = backup;
+ }
+ else
+ {
+ // Backups limited to a finite number
+ if (m_countDirection >= 0)
+ {
+ // Go with the highest file when counting up
+ m_curSizeRollBackups = backup;
+ }
+ else
+ {
+ // Clip to the limit when counting down
+ if (backup <= m_maxSizeRollBackups)
+ {
+ m_curSizeRollBackups = backup;
+ }
+ }
+ }
+ LogLog.Debug(declaringType, "File name [" + curFileName + "] moves current count to [" + m_curSizeRollBackups + "]");
+ }
+ }
+ catch (FormatException)
{
//this happens when file.log -> file.log.yyyy-MM-dd which is normal
//when staticLogFileName == false
- LogLog.Debug(declaringType, "Encountered a backup file not ending in .x ["+curFileName+"]");
+ LogLog.Debug(declaringType, "Encountered a backup file not ending in .x [" + curFileName + "]");
}
}
- /// <summary>
- /// Attempts to extract a number from the end of the file name that indicates
- /// the number of the times the file has been rolled over.
- /// </summary>
- /// <remarks>
- /// Certain date pattern extensions like yyyyMMdd will be parsed as valid backup indexes.
- /// </remarks>
- /// <param name="curFileName"></param>
- /// <returns></returns>
- private int GetBackUpIndex(string curFileName)
+ /// <summary>
+ /// Attempts to extract a number from the end of the file name that indicates
+ /// the number of the times the file has been rolled over.
+ /// </summary>
+ /// <remarks>
+ /// Certain date pattern extensions like yyyyMMdd will be parsed as valid backup indexes.
+ /// </remarks>
+ /// <param name="curFileName"></param>
+ /// <returns></returns>
+ private int GetBackUpIndex(string curFileName)
+ {
+ var backUpIndex = -1;
+ var fileName = curFileName;
+
+ if (m_preserveLogFileNameExtension)
{
- var backUpIndex = -1;
- var fileName = curFileName;
-
- if (m_preserveLogFileNameExtension)
- {
- fileName = Path.GetFileNameWithoutExtension(fileName);
- }
-
- var index = fileName.LastIndexOf(".");
- if (index > 0)
- {
- // if the "yyyy-MM-dd" component of file.log.yyyy-MM-dd is passed to TryParse
- // it will gracefully fail and return backUpIndex will be 0
- SystemInfo.TryParse(fileName.Substring(index + 1), out backUpIndex);
- }
-
- return backUpIndex;
+ fileName = Path.GetFileNameWithoutExtension(fileName);
}
- /// <summary>
+ var index = fileName.LastIndexOf(".");
+ if (index > 0)
+ {
+ // if the "yyyy-MM-dd" component of file.log.yyyy-MM-dd is passed to TryParse
+ // it will gracefully fail and return backUpIndex will be 0
+ SystemInfo.TryParse(fileName.Substring(index + 1), out backUpIndex);
+ }
+
+ return backUpIndex;
+ }
+
+ /// <summary>
/// Takes a list of files and a base file name, and looks for
/// 'incremented' versions of the base file. Bumps the max
/// count up to the highest count seen.
@@ -1043,7 +1044,7 @@
{
var baseFileLower = baseFile.ToLowerInvariant();
- foreach(string curFileName in arrayFiles)
+ foreach (string curFileName in arrayFiles)
{
InitializeFromOneFile(baseFileLower, curFileName.ToLowerInvariant());
}
@@ -1063,7 +1064,7 @@
/// and hour then the smallest roll point that can be detected would be
/// and hourly roll point as minutes could not be detected.
/// </remarks>
- private RollPoint ComputeCheckPeriod(string datePattern)
+ private RollPoint ComputeCheckPeriod(string datePattern)
{
// s_date1970 is 1970-01-01 00:00:00 this is UniversalSortableDateTimePattern
// (based on ISO 8601) using universal time. This date is used for reference
@@ -1073,15 +1074,15 @@
var r0 = s_date1970.ToString(datePattern, DateTimeFormatInfo.InvariantInfo);
// Check each type of rolling mode starting with the smallest increment.
- for(var i = (int)RollPoint.TopOfMinute; i <= (int)RollPoint.TopOfMonth; i++)
+ for (var i = (int)RollPoint.TopOfMinute; i <= (int)RollPoint.TopOfMonth; i++)
{
// Get string representation of next pattern
var r1 = NextCheckDate(s_date1970, (RollPoint)i).ToString(datePattern, DateTimeFormatInfo.InvariantInfo);
- LogLog.Debug(declaringType, "Type = ["+i+"], r0 = ["+r0+"], r1 = ["+r1+"]");
+ LogLog.Debug(declaringType, "Type = [" + i + "], r0 = [" + r0 + "], r1 = [" + r1 + "]");
// Check if the string representations are different
- if (r0 != null && r1 != null && !r0.Equals(r1))
+ if (r0 != null && r1 != null && !r0.Equals(r1))
{
// Found highest precision roll point
return (RollPoint)i;
@@ -1112,31 +1113,31 @@
/// the current number of backups.
/// </para>
/// </remarks>
- public override void ActivateOptions()
+ public override void ActivateOptions()
{
if (m_dateTime == null)
{
m_dateTime = new LocalDateTime();
}
- if (m_rollDate && m_datePattern != null)
+ if (m_rollDate && m_datePattern != null)
{
m_now = m_dateTime.Now;
m_rollPoint = ComputeCheckPeriod(m_datePattern);
if (m_rollPoint == RollPoint.InvalidRollPoint)
{
- throw new ArgumentException("Invalid RollPoint, unable to parse ["+m_datePattern+"]");
+ throw new ArgumentException("Invalid RollPoint, unable to parse [" + m_datePattern + "]");
}
// next line added as this removes the name check in rollOver
m_nextCheck = NextCheckDate(m_now, m_rollPoint);
- }
- else
+ }
+ else
{
if (m_rollDate)
{
- ErrorHandler.Error("Either DatePattern or rollingStyle options are not set for ["+Name+"].");
+ ErrorHandler.Error("Either DatePattern or rollingStyle options are not set for [" + Name + "].");
}
}
@@ -1145,7 +1146,7 @@
SecurityContext = SecurityContextProvider.DefaultProvider.CreateSecurityContext(this);
}
- using(SecurityContext.Impersonate(this))
+ using (SecurityContext.Impersonate(this))
{
// Must convert the FileAppender's m_filePath to an absolute path before we
// call ExistingInit(). This will be done by the base.ActivateOptions() but
@@ -1167,36 +1168,36 @@
if (m_rollDate && File != null && m_scheduledFilename == null)
{
- m_scheduledFilename = CombinePath(File, m_now.ToString(m_datePattern, DateTimeFormatInfo.InvariantInfo));
+ m_scheduledFilename = CombinePath(File, m_now.ToString(m_datePattern, DateTimeFormatInfo.InvariantInfo));
}
ExistingInit();
-
+
base.ActivateOptions();
}
#endregion
-
+
#region Roll File
- /// <summary>
- ///
- /// </summary>
- /// <param name="path1"></param>
- /// <param name="path2">.1, .2, .3, etc.</param>
- /// <returns></returns>
- private string CombinePath(string path1, string path2)
- {
- var extension = Path.GetExtension(path1);
- if (m_preserveLogFileNameExtension && extension.Length > 0)
- {
- return Path.Combine(Path.GetDirectoryName(path1), Path.GetFileNameWithoutExtension(path1) + path2 + extension);
- }
- else
- {
- return path1 + path2;
- }
- }
+ /// <summary>
+ ///
+ /// </summary>
+ /// <param name="path1"></param>
+ /// <param name="path2">.1, .2, .3, etc.</param>
+ /// <returns></returns>
+ private string CombinePath(string path1, string path2)
+ {
+ var extension = Path.GetExtension(path1);
+ if (m_preserveLogFileNameExtension && extension.Length > 0)
+ {
+ return Path.Combine(Path.GetDirectoryName(path1), Path.GetFileNameWithoutExtension(path1) + path2 + extension);
+ }
+ else
+ {
+ return path1 + path2;
+ }
+ }
/// <summary>
/// Rollover the file(s) to date/time tagged file(s).
@@ -1209,49 +1210,49 @@
/// If fileIsOpen is set then the new file is opened (through SafeOpenFile).
/// </para>
/// </remarks>
- protected void RollOverTime(bool fileIsOpen)
+ protected void RollOverTime(bool fileIsOpen)
{
- if (m_staticLogFileName)
+ if (m_staticLogFileName)
{
// Compute filename, but only if datePattern is specified
- if (m_datePattern == null)
+ if (m_datePattern == null)
{
ErrorHandler.Error("Missing DatePattern option in rollOver().");
return;
}
-
+
//is the new file name equivalent to the 'current' one
//something has gone wrong if we hit this -- we should only
//roll over if the new file will be different from the old
var dateFormat = m_now.ToString(m_datePattern, DateTimeFormatInfo.InvariantInfo);
- if (m_scheduledFilename.Equals(CombinePath(File, dateFormat)))
+ if (m_scheduledFilename.Equals(CombinePath(File, dateFormat)))
{
- ErrorHandler.Error("Compare " + m_scheduledFilename + " : " + CombinePath(File, dateFormat));
+ ErrorHandler.Error("Compare " + m_scheduledFilename + " : " + CombinePath(File, dateFormat));
return;
}
-
+
if (fileIsOpen)
{
// close current file, and rename it to datedFilename
CloseFile();
}
-
+
//we may have to roll over a large number of backups here
- for (var i = 1; i <= m_curSizeRollBackups; i++)
+ for (var i = 1; i <= m_curSizeRollBackups; i++)
{
- var from = CombinePath(File, "." + i);
- var to = CombinePath(m_scheduledFilename, "." + i);
+ var from = CombinePath(File, "." + i);
+ var to = CombinePath(m_scheduledFilename, "." + i);
RollFile(from, to);
}
-
+
RollFile(File, m_scheduledFilename);
}
-
+
//We've cleared out the old date and are ready for the new
- m_curSizeRollBackups = 0;
-
+ m_curSizeRollBackups = 0;
+
//new scheduled name
- m_scheduledFilename = CombinePath(File, m_now.ToString(m_datePattern, DateTimeFormatInfo.InvariantInfo));
+ m_scheduledFilename = CombinePath(File, m_now.ToString(m_datePattern, DateTimeFormatInfo.InvariantInfo));
if (fileIsOpen)
{
@@ -1259,7 +1260,7 @@
SafeOpenFile(m_baseFileName, false);
}
}
-
+
/// <summary>
/// Renames file <paramref name="fromFile"/> to file <paramref name="toFile"/>.
/// </summary>
@@ -1271,7 +1272,7 @@
/// also checks for existence of target file and deletes if it does.
/// </para>
/// </remarks>
- protected void RollFile(string fromFile, string toFile)
+ protected void RollFile(string fromFile, string toFile)
{
if (FileExists(fromFile))
{
@@ -1282,12 +1283,12 @@
try
{
LogLog.Debug(declaringType, "Moving [" + fromFile + "] -> [" + toFile + "]");
- using(SecurityContext.Impersonate(this))
+ using (SecurityContext.Impersonate(this))
{
System.IO.File.Move(fromFile, toFile);
}
}
- catch(Exception moveEx)
+ catch (Exception moveEx)
{
ErrorHandler.Error("Exception while rolling file [" + fromFile + "] -> [" + toFile + "]", moveEx, ErrorCode.GenericFailure);
}
@@ -1310,12 +1311,12 @@
/// </remarks>
protected bool FileExists(string path)
{
- using(SecurityContext.Impersonate(this))
+ using (SecurityContext.Impersonate(this))
{
return System.IO.File.Exists(path);
}
}
-
+
/// <summary>
/// Deletes the specified file if it exists.
/// </summary>
@@ -1328,9 +1329,9 @@
/// be deleted, but it still can be moved.
/// </para>
/// </remarks>
- protected void DeleteFile(string fileName)
+ protected void DeleteFile(string fileName)
{
- if (FileExists(fileName))
+ if (FileExists(fileName))
{
// We may not have permission to delete the file, or the file may be locked
@@ -1341,13 +1342,13 @@
var tempFileName = fileName + "." + Environment.TickCount + ".DeletePending";
try
{
- using(SecurityContext.Impersonate(this))
+ using (SecurityContext.Impersonate(this))
{
System.IO.File.Move(fileName, tempFileName);
}
fileToDelete = tempFileName;
}
- catch(Exception moveEx)
+ catch (Exception moveEx)
{
LogLog.Debug(declaringType, "Exception while moving file to be deleted [" + fileName + "] -> [" + tempFileName + "]", moveEx);
}
@@ -1355,13 +1356,13 @@
// Try to delete the file (either the original or the moved file)
try
{
- using(SecurityContext.Impersonate(this))
+ using (SecurityContext.Impersonate(this))
{
System.IO.File.Delete(fileToDelete);
}
LogLog.Debug(declaringType, "Deleted file [" + fileName + "]");
}
- catch(Exception deleteEx)
+ catch (Exception deleteEx)
{
if (fileToDelete == fileName)
{
@@ -1377,7 +1378,7 @@
}
}
}
-
+
/// <summary>
/// Implements file roll base on file size.
/// </summary>
@@ -1404,18 +1405,18 @@
/// renamed if needed and no files are deleted.
/// </para>
/// </remarks>
- protected void RollOverSize()
+ protected void RollOverSize()
{
CloseFile(); // keep windows happy.
-
- LogLog.Debug(declaringType, "rolling over count ["+((CountingQuietTextWriter)QuietWriter).Count+"]");
- LogLog.Debug(declaringType, "maxSizeRollBackups ["+m_maxSizeRollBackups+"]");
- LogLog.Debug(declaringType, "curSizeRollBackups ["+m_curSizeRollBackups+"]");
- LogLog.Debug(declaringType, "countDirection ["+m_countDirection+"]");
+
+ LogLog.Debug(declaringType, "rolling over count [" + ((CountingQuietTextWriter)QuietWriter).Count + "]");
+ LogLog.Debug(declaringType, "maxSizeRollBackups [" + m_maxSizeRollBackups + "]");
+ LogLog.Debug(declaringType, "curSizeRollBackups [" + m_curSizeRollBackups + "]");
+ LogLog.Debug(declaringType, "countDirection [" + m_countDirection + "]");
RollOverRenameFiles(File);
-
- if (!m_staticLogFileName && m_countDirection >= 0)
+
+ if (!m_staticLogFileName && m_countDirection >= 0)
{
m_curSizeRollBackups++;
}
@@ -1450,35 +1451,35 @@
/// This is called by <see cref="RollOverSize"/> to rename the files.
/// </para>
/// </remarks>
- protected void RollOverRenameFiles(string baseFileName)
+ protected void RollOverRenameFiles(string baseFileName)
{
// If maxBackups <= 0, then there is no file renaming to be done.
- if (m_maxSizeRollBackups != 0)
+ if (m_maxSizeRollBackups != 0)
{
- if (m_countDirection < 0)
+ if (m_countDirection < 0)
{
// Delete the oldest file, to keep Windows happy.
- if (m_curSizeRollBackups == m_maxSizeRollBackups)
+ if (m_curSizeRollBackups == m_maxSizeRollBackups)
{
- DeleteFile(CombinePath(baseFileName, "." + m_maxSizeRollBackups));
+ DeleteFile(CombinePath(baseFileName, "." + m_maxSizeRollBackups));
m_curSizeRollBackups--;
}
-
+
// Map {(maxBackupIndex - 1), ..., 2, 1} to {maxBackupIndex, ..., 3, 2}
- for (var i = m_curSizeRollBackups; i >= 1; i--)
+ for (var i = m_curSizeRollBackups; i >= 1; i--)
{
- RollFile((CombinePath(baseFileName, "." + i)), (CombinePath(baseFileName, "." + (i + 1))));
+ RollFile((CombinePath(baseFileName, "." + i)), (CombinePath(baseFileName, "." + (i + 1))));
}
-
+
m_curSizeRollBackups++;
// Rename fileName to fileName.1
- RollFile(baseFileName, CombinePath(baseFileName, ".1"));
- }
- else
+ RollFile(baseFileName, CombinePath(baseFileName, ".1"));
+ }
+ else
{
//countDirection >= 0
- if (m_curSizeRollBackups >= m_maxSizeRollBackups && m_maxSizeRollBackups > 0)
+ if (m_curSizeRollBackups >= m_maxSizeRollBackups && m_maxSizeRollBackups > 0)
{
//delete the first and keep counting up.
var oldestFileIndex = m_curSizeRollBackups - m_maxSizeRollBackups;
@@ -1495,34 +1496,34 @@
var archiveFileBaseName = baseFileName;
if (!m_staticLogFileName)
{
- if (m_preserveLogFileNameExtension)
- {
- var extension = Path.GetExtension(archiveFileBaseName);
- var baseName = Path.GetFileNameWithoutExtension(archiveFileBaseName);
- var lastDotIndex = baseName.LastIndexOf(".");
- if (lastDotIndex >= 0)
+ if (m_preserveLogFileNameExtension)
{
- archiveFileBaseName = baseName.Substring(0, lastDotIndex) + extension;
+ var extension = Path.GetExtension(archiveFileBaseName);
+ var baseName = Path.GetFileNameWithoutExtension(archiveFileBaseName);
+ var lastDotIndex = baseName.LastIndexOf(".");
+ if (lastDotIndex >= 0)
+ {
+ archiveFileBaseName = baseName.Substring(0, lastDotIndex) + extension;
+ }
}
- }
- else
- {
- var lastDotIndex = archiveFileBaseName.LastIndexOf(".");
- if (lastDotIndex >= 0)
+ else
{
- archiveFileBaseName = archiveFileBaseName.Substring(0, lastDotIndex);
+ var lastDotIndex = archiveFileBaseName.LastIndexOf(".");
+ if (lastDotIndex >= 0)
+ {
+ archiveFileBaseName = archiveFileBaseName.Substring(0, lastDotIndex);
+ }
}
- }
}
// Delete the archive file
- DeleteFile(CombinePath(archiveFileBaseName, "." + oldestFileIndex));
+ DeleteFile(CombinePath(archiveFileBaseName, "." + oldestFileIndex));
}
-
- if (m_staticLogFileName)
+
+ if (m_staticLogFileName)
{
m_curSizeRollBackups++;
- RollFile(baseFileName, CombinePath(baseFileName, "." + m_curSizeRollBackups));
+ RollFile(baseFileName, CombinePath(baseFileName, "." + m_curSizeRollBackups));
}
}
}
@@ -1549,13 +1550,13 @@
/// worth of time and get the start time of the next window for the rollpoint.
/// </para>
/// </remarks>
- protected DateTime NextCheckDate(DateTime currentDateTime, RollPoint rollPoint)
+ protected DateTime NextCheckDate(DateTime currentDateTime, RollPoint rollPoint)
{
// Local variable to work on (this does not look very efficient)
var current = currentDateTime;
// Do slightly different things depending on what the type of roll point we want.
- switch(rollPoint)
+ switch (rollPoint)
{
case RollPoint.TopOfMinute:
current = current.AddMilliseconds(-current.Millisecond);
@@ -1575,11 +1576,11 @@
current = current.AddSeconds(-current.Second);
current = current.AddMinutes(-current.Minute);
- if (current.Hour < 12)
+ if (current.Hour < 12)
{
current = current.AddHours(12 - current.Hour);
- }
- else
+ }
+ else
{
current = current.AddHours(-current.Hour);
current = current.AddDays(1);
@@ -1610,7 +1611,7 @@
current = current.AddDays(1 - current.Day); /* first day of month is 1 not 0 */
current = current.AddMonths(1);
break;
- }
+ }
return current;
}
@@ -1630,49 +1631,49 @@
/// meaning daily rollover.
/// </summary>
private string m_datePattern = ".yyyy-MM-dd";
-
+
/// <summary>
/// The actual formatted filename that is currently being written to
/// or will be the file transferred to on roll over
/// (based on staticLogFileName).
/// </summary>
private string m_scheduledFilename = null;
-
+
/// <summary>
/// The timestamp when we shall next recompute the filename.
/// </summary>
private DateTime m_nextCheck = DateTime.MaxValue;
-
+
/// <summary>
/// Holds date of last roll over
/// </summary>
private DateTime m_now;
-
+
/// <summary>
/// The type of rolling done
/// </summary>
private RollPoint m_rollPoint;
-
+
/// <summary>
/// The default maximum file size is 10MB
/// </summary>
- private long m_maxFileSize = 10*1024*1024;
-
+ private long m_maxFileSize = 10 * 1024 * 1024;
+
/// <summary>
/// There is zero backup files by default
/// </summary>
- private int m_maxSizeRollBackups = 0;
+ private int m_maxSizeRollBackups = 0;
/// <summary>
/// How many sized based backups have been made so far
/// </summary>
private int m_curSizeRollBackups = 0;
-
+
/// <summary>
/// The rolling file count direction.
/// </summary>
private int m_countDirection = -1;
-
+
/// <summary>
/// The rolling mode used in this appender.
/// </summary>
@@ -1687,13 +1688,13 @@
/// Cache flag set if we are rolling by size.
/// </summary>
private bool m_rollSize = true;
-
+
/// <summary>
/// Value indicating whether to always log to the same file.
/// </summary>
private bool m_staticLogFileName = true;
-
- /// <summary>
+
+ /// <summary>
/// Value indicating whether to preserve the file name extension when rolling.
/// </summary>
private bool m_preserveLogFileNameExtension = false;
@@ -1767,7 +1768,7 @@
}
#if !NET_1_0 && !CLI_1_0 && !NETCF
- /// <summary>
+ /// <summary>
/// Implementation of <see cref="IDateTime"/> that returns the current time as the coordinated universal time (UTC).
/// </summary>
private class UniversalDateTime : IDateTime
@@ -1788,6 +1789,6 @@
}
#endif
- #endregion DateTime
+ #endregion DateTime
}
}
diff --git a/src/log4net/Appender/SmtpAppender.cs b/src/log4net/Appender/SmtpAppender.cs
index c0d1246..58f822b 100644
--- a/src/log4net/Appender/SmtpAppender.cs
+++ b/src/log4net/Appender/SmtpAppender.cs
@@ -81,7 +81,7 @@
/// </para>
/// </remarks>
public SmtpAppender()
- {
+ {
}
#endregion // Public Instance Constructors
@@ -168,7 +168,7 @@
/// The e-mail address of the sender.
/// </para>
/// </remarks>
- public string From
+ public string From
{
get { return m_from; }
set { m_from = value; }
@@ -185,12 +185,12 @@
/// The subject line of the e-mail message.
/// </para>
/// </remarks>
- public string Subject
+ public string Subject
{
get { return m_subject; }
set { m_subject = value; }
}
-
+
/// <summary>
/// Gets or sets the name of the SMTP relay mail server to use to send
/// the e-mail messages.
@@ -226,7 +226,7 @@
public bool LocationInfo
{
get { return false; }
- set { ; }
+ set {; }
}
/// <summary>
@@ -381,12 +381,12 @@
/// Sends the contents of the cyclic buffer as an e-mail message.
/// </summary>
/// <param name="events">The logging events to send.</param>
- protected override void SendBuffer(LoggingEvent[] events)
+ protected override void SendBuffer(LoggingEvent[] events)
{
// Note: this code already owns the monitor for this
// appender. This frees us from needing to synchronize again.
- try
- {
+ try
+ {
using StringWriter writer = new StringWriter(System.Globalization.CultureInfo.InvariantCulture);
string t = Layout.Header;
@@ -395,7 +395,7 @@
writer.Write(t);
}
- for(int i = 0; i < events.Length; i++)
+ for (int i = 0; i < events.Length; i++)
{
// Render the event and append the text to the buffer
RenderLoggingEvent(writer, events[i]);
@@ -408,8 +408,8 @@
}
SendEmail(writer.ToString());
- }
- catch(Exception e)
+ }
+ catch (Exception e)
{
ErrorHandler.Error("Error occurred while sending e-mail notification.", e);
}
@@ -650,19 +650,20 @@
#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);
#endif
- }
}
+ }
}
#endif // !NETCF && !SSCLI
diff --git a/src/log4net/Appender/SmtpPickupDirAppender.cs b/src/log4net/Appender/SmtpPickupDirAppender.cs
index f3f3aa0..8a0fab0 100644
--- a/src/log4net/Appender/SmtpPickupDirAppender.cs
+++ b/src/log4net/Appender/SmtpPickupDirAppender.cs
@@ -80,7 +80,7 @@
/// A semicolon-delimited list of e-mail addresses.
/// </para>
/// </remarks>
- public string To
+ public string To
{
get { return m_to; }
set { m_to = value; }
@@ -97,7 +97,7 @@
/// The e-mail address of the sender.
/// </para>
/// </remarks>
- public string From
+ public string From
{
get { return m_from; }
set { m_from = value; }
@@ -114,12 +114,12 @@
/// The subject line of the e-mail message.
/// </para>
/// </remarks>
- public string Subject
+ public string Subject
{
get { return m_subject; }
set { m_subject = value; }
}
-
+
/// <summary>
/// Gets or sets the path to write the messages to.
/// </summary>
@@ -135,7 +135,7 @@
set { m_pickupDir = value; }
}
- /// <summary>
+ /// <summary>
/// Gets or sets the file extension for the generated files
/// </summary>
/// <value>
@@ -182,7 +182,7 @@
/// of the current thread.
/// </para>
/// </remarks>
- public SecurityContext SecurityContext
+ public SecurityContext SecurityContext
{
get { return m_securityContext; }
set { m_securityContext = value; }
@@ -201,17 +201,17 @@
/// Sends the contents of the cyclic buffer as an e-mail message.
/// </para>
/// </remarks>
- protected override void SendBuffer(LoggingEvent[] events)
+ protected override void SendBuffer(LoggingEvent[] events)
{
// Note: this code already owns the monitor for this
// appender. This frees us from needing to synchronize again.
- try
+ try
{
string filePath = null;
StreamWriter writer = null;
// Impersonate to open the file
- using(SecurityContext.Impersonate(this))
+ using (SecurityContext.Impersonate(this))
{
filePath = Path.Combine(m_pickupDir, SystemInfo.NewGuid().ToString("N") + m_fileExtension);
writer = File.CreateText(filePath);
@@ -219,11 +219,11 @@
if (writer == null)
{
- ErrorHandler.Error("Failed to create output file for writing ["+filePath+"]", null, ErrorCode.FileOpenFailure);
+ ErrorHandler.Error("Failed to create output file for writing [" + filePath + "]", null, ErrorCode.FileOpenFailure);
}
else
{
- using(writer)
+ using (writer)
{
writer.WriteLine("To: " + m_to);
writer.WriteLine("From: " + m_from);
@@ -237,7 +237,7 @@
writer.Write(t);
}
- for(int i = 0; i < events.Length; i++)
+ for (int i = 0; i < events.Length; i++)
{
// Render the event and append the text to the buffer
RenderLoggingEvent(writer, events[i]);
@@ -253,8 +253,8 @@
writer.WriteLine(".");
}
}
- }
- catch(Exception e)
+ }
+ catch (Exception e)
{
ErrorHandler.Error("Error occurred while sending e-mail notification.", e);
}
@@ -280,8 +280,8 @@
/// <see cref="ActivateOptions"/> must be called again.
/// </para>
/// </remarks>
- public override void ActivateOptions()
- {
+ public override void ActivateOptions()
+ {
base.ActivateOptions();
if (m_securityContext == null)
@@ -289,7 +289,7 @@
m_securityContext = SecurityContextProvider.DefaultProvider.CreateSecurityContext(this);
}
- using(SecurityContext.Impersonate(this))
+ using (SecurityContext.Impersonate(this))
{
m_pickupDir = ConvertToFullPath(m_pickupDir.Trim());
}
diff --git a/src/log4net/Appender/TelnetAppender.cs b/src/log4net/Appender/TelnetAppender.cs
index 9aa503e..b0e2130 100644
--- a/src/log4net/Appender/TelnetAppender.cs
+++ b/src/log4net/Appender/TelnetAppender.cs
@@ -30,7 +30,7 @@
using log4net.Core;
using log4net.Util;
-namespace log4net.Appender
+namespace log4net.Appender
{
/// <summary>
/// Appender that allows clients to connect via Telnet to receive log messages
@@ -49,7 +49,7 @@
/// </remarks>
/// <author>Keith Long</author>
/// <author>Nicko Cadell</author>
- public class TelnetAppender : AppenderSkeleton
+ public class TelnetAppender : AppenderSkeleton
{
private SocketHandler m_handler;
private int m_listeningPort = 23;
@@ -70,18 +70,18 @@
#endregion
- #region Private Static Fields
+ #region Private Static Fields
- /// <summary>
- /// The fully qualified type of the TelnetAppender class.
- /// </summary>
- /// <remarks>
- /// Used by the internal logger to record the Type of the
- /// log message.
- /// </remarks>
- private static readonly Type declaringType = typeof(TelnetAppender);
+ /// <summary>
+ /// The fully qualified type of the TelnetAppender class.
+ /// </summary>
+ /// <remarks>
+ /// Used by the internal logger to record the Type of the
+ /// log message.
+ /// </remarks>
+ private static readonly Type declaringType = typeof(TelnetAppender);
- #endregion Private Static Fields
+ #endregion Private Static Fields
/// <summary>
/// Gets or sets the TCP port number on which this <see cref="TelnetAppender"/> will listen for connections.
@@ -108,9 +108,9 @@
if (value < IPEndPoint.MinPort || value > IPEndPoint.MaxPort)
{
throw log4net.Util.SystemInfo.CreateArgumentOutOfRangeException("value", (object)value,
- "The value specified for Port is less than " +
- IPEndPoint.MinPort.ToString(NumberFormatInfo.InvariantInfo) +
- " or greater than " +
+ "The value specified for Port is less than " +
+ IPEndPoint.MinPort.ToString(NumberFormatInfo.InvariantInfo) +
+ " or greater than " +
IPEndPoint.MaxPort.ToString(NumberFormatInfo.InvariantInfo) + ".");
}
else
@@ -130,7 +130,7 @@
/// Closes all the outstanding connections.
/// </para>
/// </remarks>
- protected override void OnClose()
+ protected override void OnClose()
{
base.OnClose();
@@ -174,15 +174,15 @@
/// Create the socket handler and wait for connections
/// </para>
/// </remarks>
- public override void ActivateOptions()
+ public override void ActivateOptions()
{
base.ActivateOptions();
- try
+ try
{
- LogLog.Debug(declaringType, "Creating SocketHandler to listen on port ["+m_listeningPort+"]");
+ LogLog.Debug(declaringType, "Creating SocketHandler to listen on port [" + m_listeningPort + "]");
m_handler = new SocketHandler(m_listeningPort);
}
- catch(Exception ex)
+ catch (Exception ex)
{
LogLog.Error(declaringType, "Failed to create SocketHandler", ex);
throw;
@@ -198,7 +198,7 @@
/// Writes the logging event to each connected client.
/// </para>
/// </remarks>
- protected override void Append(LoggingEvent loggingEvent)
+ protected override void Append(LoggingEvent loggingEvent)
{
if (m_handler != null && m_handler.HasConnections)
{
@@ -221,7 +221,7 @@
/// </para>
/// </remarks>
protected class SocketHandler : IDisposable
- {
+ {
private const int MAX_CONNECTIONS = 20;
private Socket m_serverSocket;
@@ -325,7 +325,7 @@
#endregion
}
-
+
/// <summary>
/// Opens a new server port on <paramref ref="port"/>
/// </summary>
@@ -387,7 +387,7 @@
/// <param name="client">client to add</param>
private void AddClient(SocketClient client)
{
- lock(this)
+ lock (this)
{
ArrayList clientsCopy = (ArrayList)m_clients.Clone();
clientsCopy.Add(client);
@@ -401,7 +401,7 @@
/// <param name="client">client to remove</param>
private void RemoveClient(SocketClient client)
{
- lock(this)
+ lock (this)
{
ArrayList clientsCopy = (ArrayList)m_clients.Clone();
clientsCopy.Remove(client);
@@ -431,7 +431,7 @@
return (localClients != null && localClients.Count > 0);
}
}
-
+
#if NETSTANDARD
private void OnConnect(Task<Socket> acceptTask)
@@ -457,11 +457,11 @@
// Block until a client connects
Socket socket = m_serverSocket.EndAccept(asyncResult);
#endif
- LogLog.Debug(declaringType, "Accepting connection from ["+socket.RemoteEndPoint.ToString()+"]");
+ LogLog.Debug(declaringType, "Accepting connection from [" + socket.RemoteEndPoint.ToString() + "]");
SocketClient client = new SocketClient(socket);
int currentActiveConnectionsCount = m_clients.Count;
- if (currentActiveConnectionsCount < MAX_CONNECTIONS)
+ if (currentActiveConnectionsCount < MAX_CONNECTIONS)
{
try
{
@@ -473,7 +473,7 @@
client.Dispose();
}
}
- else
+ else
{
client.Send("Sorry - Too many connections.\r\n");
client.Dispose();
@@ -513,12 +513,12 @@
Socket localSocket = m_serverSocket;
m_serverSocket = null;
- try
+ try
{
localSocket.Shutdown(SocketShutdown.Both);
- }
- catch
- {
+ }
+ catch
+ {
}
try
@@ -529,9 +529,9 @@
localSocket.Dispose();
#endif
}
- catch
- {
- }
+ catch
+ {
+ }
}
#endregion
diff --git a/src/log4net/Appender/TextWriterAppender.cs b/src/log4net/Appender/TextWriterAppender.cs
index b047be2..41b9dc5 100644
--- a/src/log4net/Appender/TextWriterAppender.cs
+++ b/src/log4net/Appender/TextWriterAppender.cs
@@ -42,7 +42,7 @@
/// <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
@@ -54,7 +54,7 @@
/// Default constructor.
/// </para>
/// </remarks>
- public TextWriterAppender()
+ public TextWriterAppender()
{
}
@@ -90,7 +90,7 @@
/// </para>
/// </remarks>
[Obsolete("Instead use the default constructor and set the Layout & Writer properties")]
- public TextWriterAppender(ILayout layout, TextWriter writer)
+ public TextWriterAppender(ILayout layout, TextWriter writer)
{
Layout = layout;
Writer = writer;
@@ -123,7 +123,7 @@
/// be recorded on disk when the application exits. This is a high
/// price to pay even for a 20% performance gain.
/// </remarks>
- public bool ImmediateFlush
+ public bool ImmediateFlush
{
get { return m_immediateFlush; }
set { m_immediateFlush = value; }
@@ -144,12 +144,12 @@
/// <b>Note:</b> Logging to an unopened <see cref="TextWriter"/> will fail.
/// </para>
/// </remarks>
- public virtual TextWriter Writer
+ public virtual TextWriter Writer
{
get { return m_qtw; }
- set
+ set
{
- lock(this)
+ lock (this)
{
Reset();
if (value != null)
@@ -175,27 +175,27 @@
/// </para>
/// </remarks>
/// <returns><c>false</c> if any of the preconditions fail.</returns>
- protected override bool PreAppendCheck()
+ protected override bool PreAppendCheck()
{
- if (!base.PreAppendCheck())
+ if (!base.PreAppendCheck())
{
return false;
}
- if (m_qtw == null)
+ if (m_qtw == null)
{
// Allow subclass to lazily create the writer
PrepareWriter();
- if (m_qtw == null)
+ if (m_qtw == null)
{
- ErrorHandler.Error("No output stream or file set for the appender named ["+ Name +"].");
+ ErrorHandler.Error("No output stream or file set for the appender named [" + Name + "].");
return false;
}
}
- if (m_qtw.Closed)
+ if (m_qtw.Closed)
{
- ErrorHandler.Error("Output stream for appender named ["+ Name +"] has been closed.");
+ ErrorHandler.Error("Output stream for appender named [" + Name + "] has been closed.");
return false;
}
@@ -216,14 +216,14 @@
/// The format of the output will depend on the appender's layout.
/// </para>
/// </remarks>
- protected override void Append(LoggingEvent loggingEvent)
+ protected override void Append(LoggingEvent loggingEvent)
{
RenderLoggingEvent(m_qtw, loggingEvent);
- if (m_immediateFlush)
+ if (m_immediateFlush)
{
m_qtw.Flush();
- }
+ }
}
/// <summary>
@@ -237,17 +237,17 @@
/// before flushing the stream.
/// </para>
/// </remarks>
- protected override void Append(LoggingEvent[] loggingEvents)
+ protected override void Append(LoggingEvent[] loggingEvents)
{
- foreach(LoggingEvent loggingEvent in loggingEvents)
+ foreach (LoggingEvent loggingEvent in loggingEvents)
{
RenderLoggingEvent(m_qtw, loggingEvent);
}
- if (m_immediateFlush)
+ if (m_immediateFlush)
{
m_qtw.Flush();
- }
+ }
}
/// <summary>
@@ -256,9 +256,9 @@
/// <remarks>
/// Closed appenders cannot be reused.
/// </remarks>
- protected override void OnClose()
+ protected override void OnClose()
{
- lock(this)
+ lock (this)
{
Reset();
}
@@ -276,20 +276,20 @@
get { return base.ErrorHandler; }
set
{
- lock(this)
+ lock (this)
{
- if (value == null)
+ if (value == null)
{
LogLog.Warn(declaringType, "TextWriterAppender: You have tried to set a null error-handler.");
- }
- else
+ }
+ else
{
base.ErrorHandler = value;
- if (m_qtw != null)
+ if (m_qtw != null)
{
m_qtw.ErrorHandler = value;
}
- }
+ }
}
}
}
@@ -334,17 +334,17 @@
/// Closes the underlying <see cref="TextWriter"/>.
/// </para>
/// </remarks>
- protected virtual void CloseWriter()
+ protected virtual void CloseWriter()
{
- if (m_qtw != null)
+ if (m_qtw != null)
{
- try
+ try
{
m_qtw.Close();
- }
- catch(Exception e)
+ }
+ catch (Exception e)
{
- ErrorHandler.Error("Could not close writer ["+m_qtw+"]", e);
+ ErrorHandler.Error("Could not close writer [" + m_qtw + "]", e);
// do need to invoke an error handler
// at this late stage
}
@@ -360,7 +360,7 @@
/// Subclasses can override this method for an alternate closing behavior.
/// </para>
/// </remarks>
- protected virtual void Reset()
+ protected virtual void Reset()
{
WriteFooterAndCloseWriter();
m_qtw = null;
@@ -374,9 +374,9 @@
/// Writes a footer as produced by the embedded layout's <see cref="ILayout.Footer"/> property.
/// </para>
/// </remarks>
- protected virtual void WriteFooter()
+ protected virtual void WriteFooter()
{
- if (Layout != null && m_qtw != null && !m_qtw.Closed)
+ if (Layout != null && m_qtw != null && !m_qtw.Closed)
{
string f = Layout.Footer;
if (f != null)
@@ -394,9 +394,9 @@
/// Writes a header produced by the embedded layout's <see cref="ILayout.Header"/> property.
/// </para>
/// </remarks>
- protected virtual void WriteHeader()
+ protected virtual void WriteHeader()
{
- if (Layout != null && m_qtw != null && !m_qtw.Closed)
+ if (Layout != null && m_qtw != null && !m_qtw.Closed)
{
string h = Layout.Header;
if (h != null)
@@ -437,13 +437,13 @@
{
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 @@
#endregion Private Instance Fields
- #region Private Static Fields
+ #region Private Static Fields
- /// <summary>
- /// The fully qualified type of the TextWriterAppender class.
- /// </summary>
- /// <remarks>
- /// Used by the internal logger to record the Type of the
- /// log message.
- /// </remarks>
- private static readonly Type declaringType = typeof(TextWriterAppender);
+ /// <summary>
+ /// The fully qualified type of the TextWriterAppender class.
+ /// </summary>
+ /// <remarks>
+ /// Used by the internal logger to record the Type of the
+ /// log message.
+ /// </remarks>
+ private static readonly Type declaringType = typeof(TextWriterAppender);
- #endregion Private Static Fields
+ #endregion Private Static Fields
- /// <summary>
- /// Flushes any buffered log data.
- /// </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;
+ /// <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();
- }
+ // lock(this) will block any Appends while the buffer is flushed.
+ lock (this)
+ {
+ m_qtw.Flush();
+ }
- return true;
- }
+ return true;
+ }
}
}
diff --git a/src/log4net/Appender/TraceAppender.cs b/src/log4net/Appender/TraceAppender.cs
index e266f4b..e495336 100644
--- a/src/log4net/Appender/TraceAppender.cs
+++ b/src/log4net/Appender/TraceAppender.cs
@@ -37,7 +37,7 @@
/// <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 @@
/// <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 @@
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; }
- }
+ /// <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
+ #endregion Public Instance Properties
#region Override implementation of AppenderSkeleton
@@ -141,7 +141,7 @@
/// Writes the logging event to the <see cref="System.Diagnostics.Trace"/> system.
/// </para>
/// </remarks>
- protected override void Append(LoggingEvent loggingEvent)
+ protected override void Append(LoggingEvent loggingEvent)
{
//
// Write the string to the Trace system
@@ -149,20 +149,20 @@
#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
-
+
//
// Flush the Trace system if needed
//
- if (m_immediateFlush)
+ if (m_immediateFlush)
{
#if NETCF
System.Diagnostics.Debug.Flush();
#else
System.Diagnostics.Trace.Flush();
#endif
- }
+ }
}
/// <summary>
@@ -200,30 +200,30 @@
/// </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;
+ /// <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).
+ // 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;
}
+ }
}
diff --git a/src/log4net/Appender/UdpAppender.cs b/src/log4net/Appender/UdpAppender.cs
index 70acff0..b0d4f68 100644
--- a/src/log4net/Appender/UdpAppender.cs
+++ b/src/log4net/Appender/UdpAppender.cs
@@ -25,7 +25,7 @@
using log4net.Core;
-namespace log4net.Appender
+namespace log4net.Appender
{
/// <summary>
/// Sends logging events as connectionless UDP datagrams to a remote host or a
@@ -114,7 +114,7 @@
/// <remarks>
/// The default constructor initializes all fields to their default values.
/// </remarks>
- public UdpAppender()
+ public UdpAppender()
{
}
@@ -212,17 +212,17 @@
public int RemotePort
{
get { return m_remotePort; }
- set
+ set
{
- if (value < IPEndPoint.MinPort || value > IPEndPoint.MaxPort)
+ if (value < IPEndPoint.MinPort || value > IPEndPoint.MaxPort)
{
throw log4net.Util.SystemInfo.CreateArgumentOutOfRangeException("value", (object)value,
- "The value specified is less than " +
- IPEndPoint.MinPort.ToString(NumberFormatInfo.InvariantInfo) +
- " or greater than " +
+ "The value specified is less than " +
+ IPEndPoint.MinPort.ToString(NumberFormatInfo.InvariantInfo) +
+ " or greater than " +
IPEndPoint.MaxPort.ToString(NumberFormatInfo.InvariantInfo) + ".");
- }
- else
+ }
+ else
{
m_remotePort = value;
}
@@ -249,17 +249,17 @@
public int LocalPort
{
get { return m_localPort; }
- set
+ set
{
if (value != 0 && (value < IPEndPoint.MinPort || value > IPEndPoint.MaxPort))
{
throw log4net.Util.SystemInfo.CreateArgumentOutOfRangeException("value", (object)value,
- "The value specified is less than " +
- IPEndPoint.MinPort.ToString(NumberFormatInfo.InvariantInfo) +
- " or greater than " +
+ "The value specified is less than " +
+ IPEndPoint.MinPort.ToString(NumberFormatInfo.InvariantInfo) +
+ " or greater than " +
IPEndPoint.MaxPort.ToString(NumberFormatInfo.InvariantInfo) + ".");
- }
- else
+ }
+ else
{
m_localPort = value;
}
@@ -353,27 +353,27 @@
{
base.ActivateOptions();
- if (this.RemoteAddress == null)
+ if (this.RemoteAddress == null)
{
throw new ArgumentNullException("The required property 'Address' was not specified.");
- }
- else if (this.RemotePort < IPEndPoint.MinPort || this.RemotePort > IPEndPoint.MaxPort)
+ }
+ else if (this.RemotePort < IPEndPoint.MinPort || this.RemotePort > IPEndPoint.MaxPort)
{
throw log4net.Util.SystemInfo.CreateArgumentOutOfRangeException("this.RemotePort", (object)this.RemotePort,
- "The RemotePort is less than " +
- IPEndPoint.MinPort.ToString(NumberFormatInfo.InvariantInfo) +
- " or greater than " +
+ "The RemotePort is less than " +
+ IPEndPoint.MinPort.ToString(NumberFormatInfo.InvariantInfo) +
+ " or greater than " +
IPEndPoint.MaxPort.ToString(NumberFormatInfo.InvariantInfo) + ".");
- }
+ }
else if (this.LocalPort != 0 && (this.LocalPort < IPEndPoint.MinPort || this.LocalPort > IPEndPoint.MaxPort))
{
throw log4net.Util.SystemInfo.CreateArgumentOutOfRangeException("this.LocalPort", (object)this.LocalPort,
- "The LocalPort is less than " +
- IPEndPoint.MinPort.ToString(NumberFormatInfo.InvariantInfo) +
- " or greater than " +
+ "The LocalPort is less than " +
+ IPEndPoint.MinPort.ToString(NumberFormatInfo.InvariantInfo) +
+ " or greater than " +
IPEndPoint.MaxPort.ToString(NumberFormatInfo.InvariantInfo) + ".");
- }
- else
+ }
+ else
{
this.RemoteEndPoint = new IPEndPoint(this.RemoteAddress, this.RemotePort);
this.InitializeClientConnection();
@@ -396,25 +396,25 @@
/// Exceptions are passed to the <see cref="AppenderSkeleton.ErrorHandler"/>.
/// </para>
/// </remarks>
- protected override void Append(LoggingEvent loggingEvent)
+ protected override void Append(LoggingEvent loggingEvent)
{
- try
+ try
{
- Byte [] buffer = m_encoding.GetBytes(RenderLoggingEvent(loggingEvent).ToCharArray());
+ Byte[] buffer = m_encoding.GetBytes(RenderLoggingEvent(loggingEvent).ToCharArray());
#if NETSTANDARD
Client.SendAsync(buffer, buffer.Length, RemoteEndPoint).Wait();
#else
this.Client.Send(buffer, buffer.Length, this.RemoteEndPoint);
#endif
- }
- catch (Exception ex)
+ }
+ catch (Exception ex)
{
ErrorHandler.Error(
- "Unable to send logging event to remote host " +
- this.RemoteAddress.ToString() +
- " on port " +
- this.RemotePort + ".",
- ex,
+ "Unable to send logging event to remote host " +
+ this.RemoteAddress.ToString() +
+ " on port " +
+ this.RemotePort + ".",
+ ex,
ErrorCode.WriteFailure);
}
}
@@ -443,11 +443,11 @@
/// and unmanaged resources associated with the <see cref="UdpAppender" />.
/// </para>
/// </remarks>
- protected override void OnClose()
+ protected override void OnClose()
{
base.OnClose();
- if (this.Client != null)
+ if (this.Client != null)
{
this.Client.Close();
}
@@ -469,9 +469,9 @@
/// Exceptions are passed to the <see cref="AppenderSkeleton.ErrorHandler"/>.
/// </para>
/// </remarks>
- protected virtual void InitializeClientConnection()
+ protected virtual void InitializeClientConnection()
{
- try
+ try
{
if (this.LocalPort == 0)
{
@@ -489,13 +489,13 @@
this.Client = new UdpClient(this.LocalPort, RemoteAddress.AddressFamily);
#endif
}
- }
- catch (Exception ex)
+ }
+ catch (Exception ex)
{
ErrorHandler.Error(
- "Could not initialize the UdpClient connection on port " +
- this.LocalPort.ToString(NumberFormatInfo.InvariantInfo) + ".",
- ex,
+ "Could not initialize the UdpClient connection on port " +
+ this.LocalPort.ToString(NumberFormatInfo.InvariantInfo) + ".",
+ ex,
ErrorCode.GenericFailure);
this.Client = null;
@@ -511,7 +511,7 @@
/// the logging event will be sent.
/// </summary>
private IPAddress m_remoteAddress;
-
+
/// <summary>
/// The TCP port number of the remote host or multicast group to
/// which the logging event will be sent.
diff --git a/src/log4net/AssemblyInfo.cs b/src/log4net/AssemblyInfo.cs
index 19772bc..3c55f6b 100644
--- a/src/log4net/AssemblyInfo.cs
+++ b/src/log4net/AssemblyInfo.cs
@@ -137,8 +137,8 @@
[assembly: AssemblyProduct("log4net")]
[assembly: AssemblyDefaultAlias("log4net")]
-[assembly: AssemblyCulture("")]
-
+[assembly: AssemblyCulture("")]
+
//
// In order to sign your assembly you must specify a key to use. Refer to the
// Microsoft .NET Framework documentation for more information on assembly signing.
diff --git a/src/log4net/Config/AliasDomainAttribute.cs b/src/log4net/Config/AliasDomainAttribute.cs
index dc1af1f..c1da999 100644
--- a/src/log4net/Config/AliasDomainAttribute.cs
+++ b/src/log4net/Config/AliasDomainAttribute.cs
@@ -46,7 +46,7 @@
/// </remarks>
/// <author>Nicko Cadell</author>
/// <author>Gert Driesen</author>
- [AttributeUsage(AttributeTargets.Assembly,AllowMultiple=true)]
+ [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
[Serializable]
[Obsolete("Use AliasRepositoryAttribute instead of AliasDomainAttribute")]
public sealed class AliasDomainAttribute : AliasRepositoryAttribute
diff --git a/src/log4net/Config/AliasRepositoryAttribute.cs b/src/log4net/Config/AliasRepositoryAttribute.cs
index 1b6021f..29b4a8f 100644
--- a/src/log4net/Config/AliasRepositoryAttribute.cs
+++ b/src/log4net/Config/AliasRepositoryAttribute.cs
@@ -43,7 +43,7 @@
/// </remarks>
/// <author>Nicko Cadell</author>
/// <author>Gert Driesen</author>
- [AttributeUsage(AttributeTargets.Assembly,AllowMultiple=true)]
+ [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
[Serializable]
public /*sealed*/ class AliasRepositoryAttribute : Attribute
{
@@ -87,7 +87,7 @@
public string Name
{
get { return m_name; }
- set { m_name = value ; }
+ set { m_name = value; }
}
#endregion Public Instance Properties
diff --git a/src/log4net/Config/BasicConfigurator.cs b/src/log4net/Config/BasicConfigurator.cs
index 8e5a6b2..53afeae 100644
--- a/src/log4net/Config/BasicConfigurator.cs
+++ b/src/log4net/Config/BasicConfigurator.cs
@@ -52,23 +52,23 @@
/// <author>Nicko Cadell</author>
/// <author>Gert Driesen</author>
public sealed class BasicConfigurator
- {
- #region Private Static Fields
+ {
+ #region Private Static Fields
- /// <summary>
- /// The fully qualified type of the BasicConfigurator class.
- /// </summary>
- /// <remarks>
- /// Used by the internal logger to record the Type of the
- /// log message.
- /// </remarks>
- private static readonly Type declaringType = typeof(BasicConfigurator);
+ /// <summary>
+ /// The fully qualified type of the BasicConfigurator class.
+ /// </summary>
+ /// <remarks>
+ /// Used by the internal logger to record the Type of the
+ /// log message.
+ /// </remarks>
+ private static readonly Type declaringType = typeof(BasicConfigurator);
- #endregion Private Static Fields
+ #endregion Private Static Fields
- #region Private Instance Constructors
+ #region Private Instance Constructors
- /// <summary>
+ /// <summary>
/// Initializes a new instance of the <see cref="BasicConfigurator" /> class.
/// </summary>
/// <remarks>
@@ -97,37 +97,37 @@
/// layout style.
/// </para>
/// </remarks>
- public static ICollection Configure()
+ public static ICollection Configure()
{
- return BasicConfigurator.Configure(LogManager.GetRepository(Assembly.GetCallingAssembly()));
- }
+ 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>
- public static ICollection Configure(params IAppender[] appenders)
- {
- ArrayList configurationMessages = new ArrayList();
+ /// <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>
+ public static ICollection Configure(params IAppender[] appenders)
+ {
+ ArrayList configurationMessages = new ArrayList();
- ILoggerRepository repository = LogManager.GetRepository(Assembly.GetCallingAssembly());
+ ILoggerRepository repository = LogManager.GetRepository(Assembly.GetCallingAssembly());
- using (new LogLog.LogReceivedAdapter(configurationMessages))
- {
- InternalConfigure(repository, appenders);
- }
+ using (new LogLog.LogReceivedAdapter(configurationMessages))
+ {
+ InternalConfigure(repository, appenders);
+ }
- repository.ConfigurationMessages = configurationMessages;
+ repository.ConfigurationMessages = configurationMessages;
- return configurationMessages;
- }
+ return configurationMessages;
+ }
- /// <summary>
+ /// <summary>
/// Initializes the log4net system using the specified appender.
/// </summary>
/// <param name="appender">The appender to use to log all logging events.</param>
@@ -136,9 +136,9 @@
/// Initializes the log4net system using the specified appender.
/// </para>
/// </remarks>
- public static ICollection Configure(IAppender appender)
+ public static ICollection Configure(IAppender appender)
{
- return Configure(new IAppender[] { appender });
+ return Configure(new IAppender[] { appender });
}
#endif // !NETSTANDARD1_3
@@ -155,80 +155,80 @@
/// layout style.
/// </para>
/// </remarks>
- public static ICollection Configure(ILoggerRepository repository)
+ public static 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>
- public static 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>
- public static ICollection Configure(ILoggerRepository repository, params IAppender[] appenders)
- {
- ArrayList configurationMessages = new ArrayList();
-
- using (new LogLog.LogReceivedAdapter(configurationMessages))
- {
- InternalConfigure(repository, appenders);
- }
-
- repository.ConfigurationMessages = configurationMessages;
-
- return configurationMessages;
- }
-
- private static void InternalConfigure(ILoggerRepository repository, params IAppender[] appenders)
+ /// <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>
+ public static ICollection Configure(ILoggerRepository repository, IAppender appender)
{
- IBasicRepositoryConfigurator configurableRepository = repository as IBasicRepositoryConfigurator;
- if (configurableRepository != null)
- {
- configurableRepository.Configure(appenders);
- }
- else
- {
- LogLog.Warn(declaringType, "BasicConfigurator: Repository [" + repository + "] does not support the BasicConfigurator");
- }
+ 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>
+ public static ICollection Configure(ILoggerRepository repository, params IAppender[] appenders)
+ {
+ ArrayList configurationMessages = new ArrayList();
+
+ using (new LogLog.LogReceivedAdapter(configurationMessages))
+ {
+ InternalConfigure(repository, appenders);
+ }
+
+ repository.ConfigurationMessages = configurationMessages;
+
+ return configurationMessages;
+ }
+
+ private static 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");
+ }
}
#endregion Public Static Methods
diff --git a/src/log4net/Config/DOMConfigurator.cs b/src/log4net/Config/DOMConfigurator.cs
index 0486edf..b7c1563 100644
--- a/src/log4net/Config/DOMConfigurator.cs
+++ b/src/log4net/Config/DOMConfigurator.cs
@@ -52,8 +52,8 @@
/// <summary>
/// Private constructor
/// </summary>
- private DOMConfigurator()
- {
+ private DOMConfigurator()
+ {
}
#endregion Protected Instance Constructors
@@ -75,7 +75,7 @@
/// <c>log4net</c> that contains the configuration data.
/// </remarks>
[Obsolete("Use XmlConfigurator.Configure instead of DOMConfigurator.Configure")]
- public static void Configure()
+ public static void Configure()
{
XmlConfigurator.Configure(LogManager.GetRepository(Assembly.GetCallingAssembly()));
}
@@ -96,7 +96,7 @@
/// </remarks>
/// <param name="repository">The repository to configure.</param>
[Obsolete("Use XmlConfigurator.Configure instead of DOMConfigurator.Configure")]
- public static void Configure(ILoggerRepository repository)
+ public static void Configure(ILoggerRepository repository)
{
XmlConfigurator.Configure(repository);
}
@@ -113,7 +113,7 @@
/// </remarks>
/// <param name="element">The element to parse.</param>
[Obsolete("Use XmlConfigurator.Configure instead of DOMConfigurator.Configure")]
- public static void Configure(XmlElement element)
+ public static void Configure(XmlElement element)
{
XmlConfigurator.Configure(LogManager.GetRepository(Assembly.GetCallingAssembly()), element);
}
@@ -132,7 +132,7 @@
/// <param name="repository">The repository to configure.</param>
/// <param name="element">The element to parse.</param>
[Obsolete("Use XmlConfigurator.Configure instead of DOMConfigurator.Configure")]
- public static void Configure(ILoggerRepository repository, XmlElement element)
+ public static void Configure(ILoggerRepository repository, XmlElement element)
{
XmlConfigurator.Configure(repository, element);
}
diff --git a/src/log4net/Config/PluginAttribute.cs b/src/log4net/Config/PluginAttribute.cs
index 229dad9..21bbad7 100644
--- a/src/log4net/Config/PluginAttribute.cs
+++ b/src/log4net/Config/PluginAttribute.cs
@@ -43,7 +43,7 @@
/// </remarks>
/// <author>Nicko Cadell</author>
/// <author>Gert Driesen</author>
- [AttributeUsage(AttributeTargets.Assembly,AllowMultiple=true)]
+ [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
[Serializable]
public sealed class PluginAttribute : Attribute, IPluginFactory
{
@@ -102,7 +102,7 @@
public Type Type
{
get { return m_type; }
- set { m_type = value ; }
+ set { m_type = value; }
}
/// <summary>
@@ -122,7 +122,7 @@
public string TypeName
{
get { return m_typeName; }
- set { m_typeName = value ; }
+ set { m_typeName = value; }
}
#endregion Public Instance Properties
diff --git a/src/log4net/Config/RepositoryAttribute.cs b/src/log4net/Config/RepositoryAttribute.cs
index 2bacd53..9f3b723 100644
--- a/src/log4net/Config/RepositoryAttribute.cs
+++ b/src/log4net/Config/RepositoryAttribute.cs
@@ -101,7 +101,7 @@
public string Name
{
get { return m_name; }
- set { m_name = value ; }
+ set { m_name = value; }
}
/// <summary>
@@ -127,7 +127,7 @@
public Type RepositoryType
{
get { return m_repositoryType; }
- set { m_repositoryType = value ; }
+ set { m_repositoryType = value; }
}
#endregion Public Instance Properties
diff --git a/src/log4net/Config/SecurityContextProviderAttribute.cs b/src/log4net/Config/SecurityContextProviderAttribute.cs
index c85c15f..5e76c1f 100644
--- a/src/log4net/Config/SecurityContextProviderAttribute.cs
+++ b/src/log4net/Config/SecurityContextProviderAttribute.cs
@@ -106,17 +106,17 @@
{
if (m_providerType == null)
{
- LogLog.Error(declaringType, "Attribute specified on assembly ["+sourceAssembly.FullName+"] with null ProviderType.");
+ LogLog.Error(declaringType, "Attribute specified on assembly [" + sourceAssembly.FullName + "] with null ProviderType.");
}
else
{
- LogLog.Debug(declaringType, "Creating provider of type ["+ m_providerType.FullName +"]");
+ LogLog.Debug(declaringType, "Creating provider of type [" + m_providerType.FullName + "]");
SecurityContextProvider provider = Activator.CreateInstance(m_providerType) as SecurityContextProvider;
if (provider == null)
{
- LogLog.Error(declaringType, "Failed to create SecurityContextProvider instance of type ["+m_providerType.Name+"].");
+ LogLog.Error(declaringType, "Failed to create SecurityContextProvider instance of type [" + m_providerType.Name + "].");
}
else
{
@@ -133,18 +133,18 @@
#endregion Private Instance Fields
- #region Private Static Fields
+ #region Private Static Fields
- /// <summary>
- /// The fully qualified type of the SecurityContextProviderAttribute class.
- /// </summary>
- /// <remarks>
- /// Used by the internal logger to record the Type of the
- /// log message.
- /// </remarks>
- private static readonly Type declaringType = typeof(SecurityContextProviderAttribute);
+ /// <summary>
+ /// The fully qualified type of the SecurityContextProviderAttribute class.
+ /// </summary>
+ /// <remarks>
+ /// Used by the internal logger to record the Type of the
+ /// log message.
+ /// </remarks>
+ private static readonly Type declaringType = typeof(SecurityContextProviderAttribute);
- #endregion Private Static Fields
+ #endregion Private Static Fields
}
}
diff --git a/src/log4net/Config/XmlConfigurator.cs b/src/log4net/Config/XmlConfigurator.cs
index e854e75..b11cda0 100644
--- a/src/log4net/Config/XmlConfigurator.cs
+++ b/src/log4net/Config/XmlConfigurator.cs
@@ -140,7 +140,7 @@
InternalConfigureFromXml(repository, configElement);
}
}
- catch(System.Configuration.ConfigurationException confEx)
+ catch (System.Configuration.ConfigurationException confEx)
{
if (confEx.BareMessage.IndexOf("Unrecognized element") >= 0)
{
@@ -532,14 +532,14 @@
FileStream fs = null;
// Try hard to open the file
- for(int retry = 5; --retry >= 0; )
+ for (int retry = 5; --retry >= 0;)
{
try
{
fs = configFile.Open(FileMode.Open, FileAccess.Read, FileShare.Read);
break;
}
- catch(IOException ex)
+ catch (IOException ex)
{
if (retry == 0)
{
@@ -605,7 +605,7 @@
private static void InternalConfigure(ILoggerRepository repository, Uri configUri)
{
- LogLog.Debug(declaringType, "configuring repository [" + repository.Name + "] using URI ["+configUri+"]");
+ LogLog.Debug(declaringType, "configuring repository [" + repository.Name + "] using URI [" + configUri + "]");
if (configUri == null)
{
@@ -627,9 +627,9 @@
{
configRequest = WebRequest.Create(configUri);
}
- catch(Exception ex)
+ catch (Exception ex)
{
- LogLog.Error(declaringType, "Failed to create WebRequest for URI ["+configUri+"]", ex);
+ LogLog.Error(declaringType, "Failed to create WebRequest for URI [" + configUri + "]", ex);
}
if (configRequest != null)
@@ -658,9 +658,9 @@
InternalConfigure(repository, configStream);
}
}
- catch(Exception ex)
+ catch (Exception ex)
{
- LogLog.Error(declaringType, "Failed to request config from URI ["+configUri+"]", ex);
+ LogLog.Error(declaringType, "Failed to request config from URI [" + configUri + "]", ex);
}
}
}
@@ -746,7 +746,7 @@
// load the data into the document
doc.Load(xmlReader);
}
- catch(Exception ex)
+ catch (Exception ex)
{
LogLog.Error(declaringType, "Error while loading XML configuration", ex);
@@ -890,9 +890,9 @@
m_repositoryName2ConfigAndWatchHandler[configFile.FullName] = handler;
}
}
- catch(Exception ex)
+ catch (Exception ex)
{
- LogLog.Error(declaringType, "Failed to initialize configuration file watcher for file ["+configFile.FullName+"]", ex);
+ LogLog.Error(declaringType, "Failed to initialize configuration file watcher for file [" + configFile.FullName + "]", ex);
}
}
}
@@ -1001,7 +1001,7 @@
/// </remarks>
private void ConfigureAndWatchHandler_OnChanged(object source, FileSystemEventArgs e)
{
- LogLog.Debug(declaringType, "ConfigureAndWatchHandler: "+e.ChangeType+" [" + m_configFile.FullName + "]");
+ LogLog.Debug(declaringType, "ConfigureAndWatchHandler: " + e.ChangeType + " [" + m_configFile.FullName + "]");
// Deliver the event in TimeoutMillis time
// timer will fire only once
diff --git a/src/log4net/Config/XmlConfiguratorAttribute.cs b/src/log4net/Config/XmlConfiguratorAttribute.cs
index 4fa93fa..bdc79a1 100644
--- a/src/log4net/Config/XmlConfiguratorAttribute.cs
+++ b/src/log4net/Config/XmlConfiguratorAttribute.cs
@@ -195,35 +195,35 @@
/// 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>
public override void Configure(Assembly sourceAssembly, ILoggerRepository targetRepository)
{
- IList configurationMessages = new ArrayList();
+ 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
- }
+ 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);
- }
- }
+ if (applicationBaseDirectory == null || (new Uri(applicationBaseDirectory)).IsFile)
+ {
+ ConfigureFromFile(sourceAssembly, targetRepository);
+ }
+ else
+ {
+ ConfigureFromUri(sourceAssembly, targetRepository);
+ }
+ }
- targetRepository.ConfigurationMessages = configurationMessages;
+ targetRepository.ConfigurationMessages = configurationMessages;
}
#endregion
@@ -237,7 +237,7 @@
{
// Work out the full path to the config file
string fullPath2ConfigFile = null;
-
+
// Select the config file
if (m_configFile == null || m_configFile.Length == 0)
{
@@ -248,7 +248,7 @@
{
fullPath2ConfigFile = SystemInfo.ConfigurationFileLocation;
}
- catch(Exception ex)
+ catch (Exception ex)
{
LogLog.Error(declaringType, "XmlConfiguratorAttribute: Exception getting ConfigurationFileLocation. Must be able to resolve ConfigurationFileLocation when ConfigFile and ConfigFileExtension properties are not set.", ex);
}
@@ -266,7 +266,7 @@
{
applicationBaseDirectory = SystemInfo.ApplicationBaseDirectory;
}
- catch(Exception ex)
+ catch (Exception ex)
{
LogLog.Error(declaringType, "Exception getting ApplicationBaseDirectory. Must be able to resolve ApplicationBaseDirectory and AssemblyFileName when ConfigFileExtension property is set.", ex);
}
@@ -284,9 +284,9 @@
{
applicationBaseDirectory = SystemInfo.ApplicationBaseDirectory;
}
- catch(Exception ex)
+ catch (Exception ex)
{
- LogLog.Warn(declaringType, "Exception getting ApplicationBaseDirectory. ConfigFile property path ["+m_configFile+"] will be treated as an absolute path.", ex);
+ LogLog.Warn(declaringType, "Exception getting ApplicationBaseDirectory. ConfigFile property path [" + m_configFile + "] will be treated as an absolute path.", ex);
}
if (applicationBaseDirectory != null)
@@ -341,7 +341,7 @@
{
// Work out the full path to the config file
Uri fullPath2ConfigFile = null;
-
+
// Select the config file
if (m_configFile == null || m_configFile.Length == 0)
{
@@ -352,7 +352,7 @@
{
systemConfigFilePath = SystemInfo.ConfigurationFileLocation;
}
- catch(Exception ex)
+ catch (Exception ex)
{
LogLog.Error(declaringType, "XmlConfiguratorAttribute: Exception getting ConfigurationFileLocation. Must be able to resolve ConfigurationFileLocation when ConfigFile and ConfigFileExtension properties are not set.", ex);
}
@@ -378,7 +378,7 @@
{
systemConfigFilePath = SystemInfo.ConfigurationFileLocation;
}
- catch(Exception ex)
+ catch (Exception ex)
{
LogLog.Error(declaringType, "XmlConfiguratorAttribute: Exception getting ConfigurationFileLocation. Must be able to resolve ConfigurationFileLocation when the ConfigFile property are not set.", ex);
}
@@ -408,9 +408,9 @@
{
applicationBaseDirectory = SystemInfo.ApplicationBaseDirectory;
}
- catch(Exception ex)
+ catch (Exception ex)
{
- LogLog.Warn(declaringType, "Exception getting ApplicationBaseDirectory. ConfigFile property path ["+m_configFile+"] will be treated as an absolute URI.", ex);
+ LogLog.Warn(declaringType, "Exception getting ApplicationBaseDirectory. ConfigFile property path [" + m_configFile + "] will be treated as an absolute URI.", ex);
}
if (applicationBaseDirectory != null)
@@ -451,18 +451,18 @@
#endregion Private Instance Fields
- #region Private Static Fields
+ #region Private Static Fields
- /// <summary>
- /// The fully qualified type of the XmlConfiguratorAttribute class.
- /// </summary>
- /// <remarks>
- /// Used by the internal logger to record the Type of the
- /// log message.
- /// </remarks>
- private static readonly Type declaringType = typeof(XmlConfiguratorAttribute);
+ /// <summary>
+ /// The fully qualified type of the XmlConfiguratorAttribute class.
+ /// </summary>
+ /// <remarks>
+ /// Used by the internal logger to record the Type of the
+ /// log message.
+ /// </remarks>
+ private static readonly Type declaringType = typeof(XmlConfiguratorAttribute);
- #endregion Private Static Fields
+ #endregion Private Static Fields
}
}
diff --git a/src/log4net/Core/CompactRepositorySelector.cs b/src/log4net/Core/CompactRepositorySelector.cs
index f97f107..6034315 100644
--- a/src/log4net/Core/CompactRepositorySelector.cs
+++ b/src/log4net/Core/CompactRepositorySelector.cs
@@ -81,14 +81,14 @@
}
// Check that the type is a repository
- if (! (typeof(ILoggerRepository).IsAssignableFrom(defaultRepositoryType)) )
+ if (!(typeof(ILoggerRepository).IsAssignableFrom(defaultRepositoryType)))
{
- throw log4net.Util.SystemInfo.CreateArgumentOutOfRangeException("defaultRepositoryType", (object)defaultRepositoryType, "Parameter: defaultRepositoryType, Value: ["+defaultRepositoryType+"] out of range. Argument must implement the ILoggerRepository interface");
+ throw log4net.Util.SystemInfo.CreateArgumentOutOfRangeException("defaultRepositoryType", (object)defaultRepositoryType, "Parameter: defaultRepositoryType, Value: [" + defaultRepositoryType + "] out of range. Argument must implement the ILoggerRepository interface");
}
m_defaultRepositoryType = defaultRepositoryType;
- LogLog.Debug(declaringType, "defaultRepositoryType ["+m_defaultRepositoryType+"]");
+ LogLog.Debug(declaringType, "defaultRepositoryType [" + m_defaultRepositoryType + "]");
}
#endregion
@@ -137,13 +137,13 @@
throw new ArgumentNullException("repositoryName");
}
- lock(this)
+ lock (this)
{
// Lookup in map
ILoggerRepository rep = m_name2repositoryMap[repositoryName] as ILoggerRepository;
if (rep == null)
{
- throw new LogException("Repository ["+repositoryName+"] is NOT defined.");
+ throw new LogException("Repository [" + repositoryName + "] is NOT defined.");
}
return rep;
}
@@ -177,7 +177,7 @@
repositoryType = m_defaultRepositoryType;
}
- lock(this)
+ lock (this)
{
// This method should not throw if the default repository already exists.
@@ -190,7 +190,7 @@
}
return rep;
- }
+ }
}
/// <summary>
@@ -229,7 +229,7 @@
repositoryType = m_defaultRepositoryType;
}
- lock(this)
+ lock (this)
{
ILoggerRepository rep = null;
@@ -237,11 +237,11 @@
rep = m_name2repositoryMap[repositoryName] as ILoggerRepository;
if (rep != null)
{
- throw new LogException("Repository ["+repositoryName+"] is already defined. Repositories cannot be redefined.");
+ throw new LogException("Repository [" + repositoryName + "] is already defined. Repositories cannot be redefined.");
}
else
{
- LogLog.Debug(declaringType, "Creating repository ["+repositoryName+"] using type ["+repositoryType+"]");
+ LogLog.Debug(declaringType, "Creating repository [" + repositoryName + "] using type [" + repositoryType + "]");
// Call the no arg constructor for the repositoryType
rep = (ILoggerRepository)Activator.CreateInstance(repositoryType);
@@ -274,7 +274,7 @@
/// </remarks>
public bool ExistsRepository(string repositoryName)
{
- lock(this)
+ lock (this)
{
return m_name2repositoryMap.ContainsKey(repositoryName);
}
@@ -291,7 +291,7 @@
/// </remarks>
public ILoggerRepository[] GetAllRepositories()
{
- lock(this)
+ lock (this)
{
ICollection reps = m_name2repositoryMap.Values;
ILoggerRepository[] all = new ILoggerRepository[reps.Count];
@@ -302,18 +302,18 @@
#endregion
- #region Private Static Fields
+ #region Private Static Fields
- /// <summary>
- /// The fully qualified type of the CompactRepositorySelector class.
- /// </summary>
- /// <remarks>
- /// Used by the internal logger to record the Type of the
- /// log message.
- /// </remarks>
- private static readonly Type declaringType = typeof(CompactRepositorySelector);
+ /// <summary>
+ /// The fully qualified type of the CompactRepositorySelector class.
+ /// </summary>
+ /// <remarks>
+ /// Used by the internal logger to record the Type of the
+ /// log message.
+ /// </remarks>
+ private static readonly Type declaringType = typeof(CompactRepositorySelector);
- #endregion Private Static Fields
+ #endregion Private Static Fields
/// <summary>
/// Event to notify that a logger repository has been created.
diff --git a/src/log4net/Core/DefaultRepositorySelector.cs b/src/log4net/Core/DefaultRepositorySelector.cs
index 3240813..913bfc8 100644
--- a/src/log4net/Core/DefaultRepositorySelector.cs
+++ b/src/log4net/Core/DefaultRepositorySelector.cs
@@ -66,7 +66,7 @@
/// holds the newly created <see cref="ILoggerRepository"/>.
/// </para>
/// </remarks>
- public event LoggerRepositoryCreationEventHandler LoggerRepositoryCreatedEvent
+ public event LoggerRepositoryCreationEventHandler LoggerRepositoryCreatedEvent
{
add { m_loggerRepositoryCreatedEvent += value; }
remove { m_loggerRepositoryCreatedEvent -= value; }
@@ -97,7 +97,7 @@
}
// Check that the type is a repository
- if (! (typeof(ILoggerRepository).IsAssignableFrom(defaultRepositoryType)) )
+ if (!(typeof(ILoggerRepository).IsAssignableFrom(defaultRepositoryType)))
{
throw log4net.Util.SystemInfo.CreateArgumentOutOfRangeException("defaultRepositoryType", defaultRepositoryType, "Parameter: defaultRepositoryType, Value: [" + defaultRepositoryType + "] out of range. Argument must implement the ILoggerRepository interface");
}
@@ -167,7 +167,7 @@
throw new ArgumentNullException("repositoryName");
}
- lock(this)
+ lock (this)
{
// Lookup in map
ILoggerRepository rep = m_name2repositoryMap[repositoryName] as ILoggerRepository;
@@ -271,7 +271,7 @@
repositoryType = m_defaultRepositoryType;
}
- lock(this)
+ lock (this)
{
// Lookup in map
ILoggerRepository rep = m_assembly2repositoryMap[repositoryAssembly] as ILoggerRepository;
@@ -370,7 +370,7 @@
repositoryType = m_defaultRepositoryType;
}
- lock(this)
+ lock (this)
{
ILoggerRepository rep = null;
@@ -401,7 +401,7 @@
else
{
// Invalid repository type for alias
- LogLog.Error(declaringType, "Failed to alias repository [" + repositoryName + "] to existing repository ["+aliasedRepository.Name+"]. Requested repository type ["+repositoryType.FullName+"] is not compatible with existing type [" + aliasedRepository.GetType().FullName + "]");
+ LogLog.Error(declaringType, "Failed to alias repository [" + repositoryName + "] to existing repository [" + aliasedRepository.Name + "]. Requested repository type [" + repositoryType.FullName + "] is not compatible with existing type [" + aliasedRepository.GetType().FullName + "]");
// We now drop through to create the repository without aliasing
}
@@ -444,7 +444,7 @@
/// </remarks>
public bool ExistsRepository(string repositoryName)
{
- lock(this)
+ lock (this)
{
return m_name2repositoryMap.ContainsKey(repositoryName);
}
@@ -461,7 +461,7 @@
/// </remarks>
public ILoggerRepository[] GetAllRepositories()
{
- lock(this)
+ lock (this)
{
ICollection reps = m_name2repositoryMap.Values;
ILoggerRepository[] all = new ILoggerRepository[reps.Count];
@@ -494,40 +494,40 @@
/// <para>-or-</para>
/// <para><paramref name="repositoryTarget" /> is <see langword="null" />.</para>
/// </exception>
- public void AliasRepository(string repositoryAlias, ILoggerRepository repositoryTarget)
+ public void AliasRepository(string repositoryAlias, ILoggerRepository repositoryTarget)
{
- if (repositoryAlias == null)
+ if (repositoryAlias == null)
{
throw new ArgumentNullException("repositoryAlias");
}
- if (repositoryTarget == null)
+ if (repositoryTarget == null)
{
throw new ArgumentNullException("repositoryTarget");
}
- lock(this)
+ lock (this)
{
// Check if the alias is already set
- if (m_alias2repositoryMap.Contains(repositoryAlias))
+ if (m_alias2repositoryMap.Contains(repositoryAlias))
{
// Check if this is a duplicate of the current alias
- if (repositoryTarget != ((ILoggerRepository)m_alias2repositoryMap[repositoryAlias]))
+ if (repositoryTarget != ((ILoggerRepository)m_alias2repositoryMap[repositoryAlias]))
{
// Cannot redefine existing alias
throw new InvalidOperationException("Repository [" + repositoryAlias + "] is already aliased to repository [" + ((ILoggerRepository)m_alias2repositoryMap[repositoryAlias]).Name + "]. Aliases cannot be redefined.");
}
}
- // Check if the alias is already mapped to a repository
- else if (m_name2repositoryMap.Contains(repositoryAlias))
+ // Check if the alias is already mapped to a repository
+ else if (m_name2repositoryMap.Contains(repositoryAlias))
{
// Check if this is a duplicate of the current mapping
- if ( repositoryTarget != ((ILoggerRepository)m_name2repositoryMap[repositoryAlias]) )
+ if (repositoryTarget != ((ILoggerRepository)m_name2repositoryMap[repositoryAlias]))
{
// Cannot define alias for already mapped repository
throw new InvalidOperationException("Repository [" + repositoryAlias + "] already exists and cannot be aliased to repository [" + repositoryTarget.Name + "].");
}
}
- else
+ else
{
// Set the alias
m_alias2repositoryMap[repositoryAlias] = repositoryTarget;
@@ -548,10 +548,10 @@
/// Raises the <see cref="LoggerRepositoryCreatedEvent"/> event.
/// </para>
/// </remarks>
- protected virtual void OnLoggerRepositoryCreatedEvent(ILoggerRepository repository)
+ protected virtual void OnLoggerRepositoryCreatedEvent(ILoggerRepository repository)
{
LoggerRepositoryCreationEventHandler handler = m_loggerRepositoryCreatedEvent;
- if (handler != null)
+ if (handler != null)
{
handler(this, new LoggerRepositoryCreationEventArgs(repository));
}
@@ -674,7 +674,7 @@
Array.Sort(configAttributes);
// Delegate to the attribute the job of configuring the repository
- foreach(log4net.Config.ConfiguratorAttribute configAttr in configAttributes)
+ foreach (log4net.Config.ConfiguratorAttribute configAttr in configAttributes)
{
if (configAttr != null)
{
@@ -684,7 +684,7 @@
}
catch (Exception ex)
{
- LogLog.Error(declaringType, "Exception calling ["+configAttr.GetType().FullName+"] .Configure method.", ex);
+ LogLog.Error(declaringType, "Exception calling [" + configAttr.GetType().FullName + "] .Configure method.", ex);
}
}
}
@@ -704,21 +704,21 @@
{
applicationBaseDirectory = SystemInfo.ApplicationBaseDirectory;
}
- catch(Exception ex)
+ catch (Exception ex)
{
- LogLog.Warn(declaringType, "Exception getting ApplicationBaseDirectory. appSettings log4net.Config path ["+repositoryConfigFile+"] will be treated as an absolute URI", ex);
+ LogLog.Warn(declaringType, "Exception getting ApplicationBaseDirectory. appSettings log4net.Config path [" + repositoryConfigFile + "] will be treated as an absolute URI", ex);
}
- string repositoryConfigFilePath = repositoryConfigFile;
- if (applicationBaseDirectory != null)
- {
- repositoryConfigFilePath = Path.Combine(applicationBaseDirectory, repositoryConfigFile);
- }
+ 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;
+ // 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 || NETSTANDARD
- Boolean.TryParse(SystemInfo.GetAppSetting("log4net.Config.Watch"), out watchRepositoryConfigFile);
+ Boolean.TryParse(SystemInfo.GetAppSetting("log4net.Config.Watch"), out watchRepositoryConfigFile);
#else
{
string watch = SystemInfo.GetAppSetting("log4net.Config.Watch");
@@ -738,8 +738,8 @@
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,48 +747,48 @@
}
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
- // URI and pass that to the Configurator
- Uri repositoryConfigUri = null;
- try
- {
- repositoryConfigUri = new Uri(repositoryConfigFilePath);
- }
- catch(Exception ex)
- {
- LogLog.Error(declaringType, "Exception while parsing log4net.Config file path ["+repositoryConfigFile+"]", ex);
- }
-
- if (repositoryConfigUri != null)
- {
- LogLog.Debug(declaringType, "Loading configuration for default repository from AppSettings specified Config URI ["+repositoryConfigUri.ToString()+"]");
-
+ // 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
{
- // TODO: Support other types of configurator
- XmlConfigurator.Configure(repository, repositoryConfigUri);
+ repositoryConfigUri = new Uri(repositoryConfigFilePath);
}
catch (Exception ex)
{
- LogLog.Error(declaringType, "Exception calling XmlConfigurator.Configure method with ConfigUri ["+repositoryConfigUri+"]", ex);
+ LogLog.Error(declaringType, "Exception while parsing log4net.Config file path [" + repositoryConfigFile + "]", ex);
+ }
+
+ if (repositoryConfigUri != null)
+ {
+ LogLog.Debug(declaringType, "Loading configuration for default repository from AppSettings specified Config URI [" + repositoryConfigUri.ToString() + "]");
+
+ try
+ {
+ // TODO: Support other types of configurator
+ XmlConfigurator.Configure(repository, repositoryConfigUri);
+ }
+ catch (Exception ex)
+ {
+ LogLog.Error(declaringType, "Exception calling XmlConfigurator.Configure method with ConfigUri [" + repositoryConfigUri + "]", ex);
+ }
}
}
- }
}
}
}
@@ -822,14 +822,14 @@
#endif
if (configAttributes != null && configAttributes.Length > 0)
{
- foreach(log4net.Plugin.IPluginFactory configAttr in configAttributes)
+ foreach (log4net.Plugin.IPluginFactory configAttr in configAttributes)
{
try
{
// Create the plugin and add it to the repository
repository.PluginMap.Add(configAttr.CreatePlugin());
}
- catch(Exception ex)
+ catch (Exception ex)
{
LogLog.Error(declaringType, "Failed to create plugin. Attribute [" + configAttr.ToString() + "]", ex);
}
@@ -866,13 +866,13 @@
#endif
if (configAttributes != null && configAttributes.Length > 0)
{
- foreach(log4net.Config.AliasRepositoryAttribute configAttr in configAttributes)
+ foreach (log4net.Config.AliasRepositoryAttribute configAttr in configAttributes)
{
try
{
AliasRepository(configAttr.Name, repository);
}
- catch(Exception ex)
+ catch (Exception ex)
{
LogLog.Error(declaringType, "Failed to alias repository [" + configAttr.Name + "]", ex);
}
@@ -884,14 +884,14 @@
#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 static readonly 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 static readonly Type declaringType = typeof(DefaultRepositorySelector);
private const string DefaultRepositoryName = "log4net-default-repository";
diff --git a/src/log4net/Core/FixFlags.cs b/src/log4net/Core/FixFlags.cs
index b2e9445..1853f44 100644
--- a/src/log4net/Core/FixFlags.cs
+++ b/src/log4net/Core/FixFlags.cs
@@ -2,103 +2,103 @@
namespace log4net.Core
{
+ /// <summary>
+ /// Flags passed to the <see cref="LoggingEvent.Fix"/> property
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Flags passed to the <see cref="LoggingEvent.Fix"/> property
+ /// </para>
+ /// </remarks>
+ /// <author>Nicko Cadell</author>
+ [Flags]
+ public enum FixFlags
+ {
/// <summary>
- /// Flags passed to the <see cref="LoggingEvent.Fix"/> property
+ /// Fix the MDC
+ /// </summary>
+ [Obsolete("Replaced by composite Properties")]
+ Mdc = 0x01,
+
+ /// <summary>
+ /// Fix the NDC
+ /// </summary>
+ Ndc = 0x02,
+
+ /// <summary>
+ /// Fix the rendered message
+ /// </summary>
+ Message = 0x04,
+
+ /// <summary>
+ /// Fix the thread name
+ /// </summary>
+ ThreadName = 0x08,
+
+ /// <summary>
+ /// Fix the callers location information
+ /// </summary>
+ /// <remarks>
+ /// CAUTION: Very slow to generate
+ /// </remarks>
+ LocationInfo = 0x10,
+
+ /// <summary>
+ /// Fix the callers windows user name
+ /// </summary>
+ /// <remarks>
+ /// CAUTION: Slow to generate
+ /// </remarks>
+ UserName = 0x20,
+
+ /// <summary>
+ /// Fix the domain friendly name
+ /// </summary>
+ Domain = 0x40,
+
+ /// <summary>
+ /// Fix the callers principal name
+ /// </summary>
+ /// <remarks>
+ /// CAUTION: May be slow to generate
+ /// </remarks>
+ Identity = 0x80,
+
+ /// <summary>
+ /// Fix the exception text
+ /// </summary>
+ Exception = 0x100,
+
+ /// <summary>
+ /// Fix the event properties. Active properties must implement <see cref="IFixingRequired"/> in order to be eligible for fixing.
+ /// </summary>
+ Properties = 0x200,
+
+ /// <summary>
+ /// No fields fixed
+ /// </summary>
+ None = 0x0,
+
+ /// <summary>
+ /// All fields fixed
+ /// </summary>
+ All = 0xFFFFFFF,
+
+ /// <summary>
+ /// Partial fields fixed
/// </summary>
/// <remarks>
/// <para>
- /// Flags passed to the <see cref="LoggingEvent.Fix"/> property
+ /// This set of partial fields gives good performance. The following fields are fixed:
/// </para>
+ /// <list type="bullet">
+ /// <item><description><see cref="Message"/></description></item>
+ /// <item><description><see cref="ThreadName"/></description></item>
+ /// <item><description><see cref="Exception"/></description></item>
+ /// <item><description><see cref="Domain"/></description></item>
+ /// <item><description><see cref="Properties"/></description></item>
+ /// </list>
/// </remarks>
- /// <author>Nicko Cadell</author>
- [Flags]
- public enum FixFlags
- {
- /// <summary>
- /// Fix the MDC
- /// </summary>
- [Obsolete("Replaced by composite Properties")]
- Mdc = 0x01,
-
- /// <summary>
- /// Fix the NDC
- /// </summary>
- Ndc = 0x02,
-
- /// <summary>
- /// Fix the rendered message
- /// </summary>
- Message = 0x04,
-
- /// <summary>
- /// Fix the thread name
- /// </summary>
- ThreadName = 0x08,
-
- /// <summary>
- /// Fix the callers location information
- /// </summary>
- /// <remarks>
- /// CAUTION: Very slow to generate
- /// </remarks>
- LocationInfo = 0x10,
-
- /// <summary>
- /// Fix the callers windows user name
- /// </summary>
- /// <remarks>
- /// CAUTION: Slow to generate
- /// </remarks>
- UserName = 0x20,
-
- /// <summary>
- /// Fix the domain friendly name
- /// </summary>
- Domain = 0x40,
-
- /// <summary>
- /// Fix the callers principal name
- /// </summary>
- /// <remarks>
- /// CAUTION: May be slow to generate
- /// </remarks>
- Identity = 0x80,
-
- /// <summary>
- /// Fix the exception text
- /// </summary>
- Exception = 0x100,
-
- /// <summary>
- /// Fix the event properties. Active properties must implement <see cref="IFixingRequired"/> in order to be eligible for fixing.
- /// </summary>
- Properties = 0x200,
-
- /// <summary>
- /// No fields fixed
- /// </summary>
- None = 0x0,
-
- /// <summary>
- /// All fields fixed
- /// </summary>
- All = 0xFFFFFFF,
-
- /// <summary>
- /// Partial fields fixed
- /// </summary>
- /// <remarks>
- /// <para>
- /// This set of partial fields gives good performance. The following fields are fixed:
- /// </para>
- /// <list type="bullet">
- /// <item><description><see cref="Message"/></description></item>
- /// <item><description><see cref="ThreadName"/></description></item>
- /// <item><description><see cref="Exception"/></description></item>
- /// <item><description><see cref="Domain"/></description></item>
- /// <item><description><see cref="Properties"/></description></item>
- /// </list>
- /// </remarks>
- Partial = Message | ThreadName | Exception | Domain | Properties,
- }
+ Partial = Message | ThreadName | Exception | Domain | Properties,
+ }
}
\ No newline at end of file
diff --git a/src/log4net/Core/IAppenderAttachable.cs b/src/log4net/Core/IAppenderAttachable.cs
index 43b50c1..3632765 100644
--- a/src/log4net/Core/IAppenderAttachable.cs
+++ b/src/log4net/Core/IAppenderAttachable.cs
@@ -61,7 +61,7 @@
/// collection rather than <c>null</c>.
/// </para>
/// </remarks>
- AppenderCollection Appenders {get;}
+ AppenderCollection Appenders { get; }
/// <summary>
/// Gets an attached appender with the specified name.
@@ -116,6 +116,6 @@
/// <see cref="IAppender.Close"/> on the appender removed.
/// </para>
/// </remarks>
- IAppender RemoveAppender(string name);
+ IAppender RemoveAppender(string name);
}
}
diff --git a/src/log4net/Core/ILogger.cs b/src/log4net/Core/ILogger.cs
index b7e4514..289a33f 100644
--- a/src/log4net/Core/ILogger.cs
+++ b/src/log4net/Core/ILogger.cs
@@ -70,7 +70,7 @@
/// </para>
/// </remarks>
void Log(Type callerStackBoundaryDeclaringType, Level level, object message, Exception exception);
-
+
/// <summary>
/// This is the most generic printing method that is intended to be used
/// by wrappers.
diff --git a/src/log4net/Core/Level.cs b/src/log4net/Core/Level.cs
index ced11f8..a200e2a 100644
--- a/src/log4net/Core/Level.cs
+++ b/src/log4net/Core/Level.cs
@@ -99,7 +99,7 @@
/// the specified level name and value.
/// </para>
/// </remarks>
- public Level(int level, string levelName, string displayName)
+ public Level(int level, string levelName, string displayName)
{
if (levelName == null)
{
@@ -202,7 +202,7 @@
/// Returns the level <see cref="Name"/>.
/// </para>
/// </remarks>
- public override string ToString()
+ public override string ToString()
{
return m_levelName;
}
@@ -321,7 +321,7 @@
/// Compares two levels.
/// </para>
/// </remarks>
- public static bool operator > (Level l, Level r)
+ public static bool operator >(Level l, Level r)
{
return l.m_levelValue > r.m_levelValue;
}
@@ -341,7 +341,7 @@
/// Compares two levels.
/// </para>
/// </remarks>
- public static bool operator < (Level l, Level r)
+ public static bool operator <(Level l, Level r)
{
return l.m_levelValue < r.m_levelValue;
}
@@ -361,7 +361,7 @@
/// Compares two levels.
/// </para>
/// </remarks>
- public static bool operator >= (Level l, Level r)
+ public static bool operator >=(Level l, Level r)
{
return l.m_levelValue >= r.m_levelValue;
}
@@ -381,7 +381,7 @@
/// Compares two levels.
/// </para>
/// </remarks>
- public static bool operator <= (Level l, Level r)
+ public static bool operator <=(Level l, Level r)
{
return l.m_levelValue <= r.m_levelValue;
}
@@ -401,7 +401,7 @@
/// Compares two levels.
/// </para>
/// </remarks>
- public static bool operator == (Level l, Level r)
+ public static bool operator ==(Level l, Level r)
{
if (((object)l) != null && ((object)r) != null)
{
@@ -409,7 +409,7 @@
}
else
{
- return ((object) l) == ((object) r);
+ return ((object)l) == ((object)r);
}
}
@@ -428,9 +428,9 @@
/// Compares two levels.
/// </para>
/// </remarks>
- public static bool operator != (Level l, Level r)
+ public static bool operator !=(Level l, Level r)
{
- return !(l==r);
+ return !(l == r);
}
#endregion Operators
@@ -502,11 +502,11 @@
/// </summary>
public static readonly Level Off = new Level(int.MaxValue, "OFF");
- /// <summary>
- /// The <see cref="Emergency" /> level designates very severe error events.
- /// System unusable, emergencies.
- /// </summary>
- public static readonly Level Log4Net_Debug = new Level(120000, "log4net:DEBUG");
+ /// <summary>
+ /// The <see cref="Emergency" /> level designates very severe error events.
+ /// System unusable, emergencies.
+ /// </summary>
+ public static readonly Level Log4Net_Debug = new Level(120000, "log4net:DEBUG");
/// <summary>
/// The <see cref="Emergency" /> level designates very severe error events.
@@ -547,19 +547,19 @@
/// The <see cref="Warn" /> level designates potentially harmful
/// situations.
/// </summary>
- public static readonly Level Warn = new Level(60000, "WARN");
+ public static readonly Level Warn = new Level(60000, "WARN");
/// <summary>
/// The <see cref="Notice" /> level designates informational messages
/// that highlight the progress of the application at the highest level.
/// </summary>
- public static readonly Level Notice = new Level(50000, "NOTICE");
+ public static readonly Level Notice = new Level(50000, "NOTICE");
/// <summary>
/// The <see cref="Info" /> level designates informational messages that
/// highlight the progress of the application at coarse-grained level.
/// </summary>
- public static readonly Level Info = new Level(40000, "INFO");
+ public static readonly Level Info = new Level(40000, "INFO");
/// <summary>
/// The <see cref="Debug" /> level designates fine-grained informational
diff --git a/src/log4net/Core/LevelCollection.cs b/src/log4net/Core/LevelCollection.cs
index 649eeca..4f35882 100644
--- a/src/log4net/Core/LevelCollection.cs
+++ b/src/log4net/Core/LevelCollection.cs
@@ -72,7 +72,7 @@
private int m_version = 0;
#endregion
-
+
#region Static Wrappers
/// <summary>
@@ -84,7 +84,7 @@
/// </returns>
public static LevelCollection ReadOnly(LevelCollection list)
{
- if(list==null) throw new ArgumentNullException("list");
+ if (list == null) throw new ArgumentNullException("list");
return new ReadOnlyLevelCollection(list);
}
@@ -101,7 +101,7 @@
{
m_array = new Level[DEFAULT_CAPACITY];
}
-
+
/// <summary>
/// Initializes a new instance of the <c>LevelCollection</c> class
/// that has the specified initial capacity.
@@ -146,12 +146,12 @@
m_array = new Level[col.Count];
AddRange(col);
}
-
+
/// <summary>
/// Type visible only to our subclasses
/// Used to access protected constructor
/// </summary>
- protected internal enum Tag
+ protected internal enum Tag
{
/// <summary>
/// A value
@@ -168,7 +168,7 @@
m_array = null;
}
#endregion
-
+
#region Operations (type-safe ICollection)
/// <summary>
@@ -201,8 +201,8 @@
{
throw new System.ArgumentException("Destination array was not long enough.");
}
-
- Array.Copy(m_array, 0, array, start, m_count);
+
+ Array.Copy(m_array, 0, array, start, m_count);
}
/// <summary>
@@ -223,7 +223,7 @@
}
#endregion
-
+
#region Operations (type-safe IList)
/// <summary>
@@ -240,13 +240,13 @@
get
{
ValidateIndex(index); // throws
- return m_array[index];
+ return m_array[index];
}
set
{
ValidateIndex(index); // throws
- ++m_version;
- m_array[index] = value;
+ ++m_version;
+ m_array[index] = value;
}
}
@@ -267,7 +267,7 @@
return m_count++;
}
-
+
/// <summary>
/// Removes all elements from the <c>LevelCollection</c>.
/// </summary>
@@ -277,7 +277,7 @@
m_array = new Level[DEFAULT_CAPACITY];
m_count = 0;
}
-
+
/// <summary>
/// Creates a shallow copy of the <see cref="LevelCollection"/>.
/// </summary>
@@ -299,7 +299,7 @@
/// <returns><c>true</c> if <paramref name="item"/> is found in the <c>LevelCollection</c>; otherwise, <c>false</c>.</returns>
public virtual bool Contains(Level item)
{
- for (int i=0; i != m_count; ++i)
+ for (int i = 0; i != m_count; ++i)
{
if (m_array[i].Equals(item))
{
@@ -320,7 +320,7 @@
/// </returns>
public virtual int IndexOf(Level item)
{
- for (int i=0; i != m_count; ++i)
+ for (int i = 0; i != m_count; ++i)
{
if (m_array[i].Equals(item))
{
@@ -343,7 +343,7 @@
public virtual void Insert(int index, Level item)
{
ValidateIndex(index, true); // throws
-
+
if (m_count == m_array.Length)
{
EnsureCapacity(m_count + 1);
@@ -367,13 +367,13 @@
/// The specified <see cref="Level"/> was not found in the <c>LevelCollection</c>.
/// </exception>
public virtual void Remove(Level item)
- {
+ {
int i = IndexOf(item);
if (i < 0)
{
throw new System.ArgumentException("Cannot remove the specified item because it was not found in the specified Collection.");
}
-
+
++m_version;
RemoveAt(i);
}
@@ -390,14 +390,14 @@
public virtual void RemoveAt(int index)
{
ValidateIndex(index); // throws
-
+
m_count--;
if (index < m_count)
{
Array.Copy(m_array, index + 1, m_array, index, m_count - index);
}
-
+
// We can't set the deleted entry equal to null, because it might be a value type.
// Instead, we'll create an empty single-element array of the right type and copy it
// over the entry we want to erase.
@@ -427,7 +427,7 @@
#endregion
#region Operations (type-safe IEnumerable)
-
+
/// <summary>
/// Returns an enumerator that can iterate through the <c>LevelCollection</c>.
/// </summary>
@@ -440,15 +440,15 @@
#endregion
#region Public helpers (just to mimic some nice features of ArrayList)
-
+
/// <summary>
/// Gets or sets the number of elements the <c>LevelCollection</c> can contain.
/// </summary>
public virtual int Capacity
{
- get
- {
- return m_array.Length;
+ get
+ {
+ return m_array.Length;
}
set
{
@@ -484,7 +484,7 @@
{
EnsureCapacity(m_count + x.Count);
}
-
+
Array.Copy(x.m_array, 0, m_array, m_count, x.Count);
m_count += x.Count;
m_version++;
@@ -523,14 +523,14 @@
EnsureCapacity(m_count + col.Count);
}
- foreach(object item in col)
+ foreach (object item in col)
{
Add((Level)item);
}
return m_count;
}
-
+
/// <summary>
/// Sets the capacity to the actual number of elements.
/// </summary>
@@ -560,7 +560,7 @@
/// </exception>
private void ValidateIndex(int i, bool allowEqualEnd)
{
- int max = (allowEqualEnd) ? (m_count) : (m_count-1);
+ int max = (allowEqualEnd) ? (m_count) : (m_count - 1);
if (i < 0 || i > max)
{
throw log4net.Util.SystemInfo.CreateArgumentOutOfRangeException("i", (object)i, "Index was out of range. Must be non-negative and less than the size of the collection. [" + (object)i + "] Specified argument was out of the range of valid values.");
@@ -579,7 +579,7 @@
}
#endregion
-
+
#region Implementation (ICollection)
void ICollection.CopyTo(Array array, int start)
@@ -646,15 +646,15 @@
private sealed class Enumerator : IEnumerator, ILevelCollectionEnumerator
{
#region Implementation (data)
-
+
private readonly LevelCollection m_collection;
private int m_index;
private int m_version;
-
+
#endregion
-
+
#region Construction
-
+
/// <summary>
/// Initializes a new instance of the <c>Enumerator</c> class.
/// </summary>
@@ -665,11 +665,11 @@
m_index = -1;
m_version = tc.m_version;
}
-
+
#endregion
-
+
#region Operations (type-safe IEnumerator)
-
+
/// <summary>
/// Gets the current element in the collection.
/// </summary>
@@ -708,14 +708,14 @@
}
#endregion
-
+
#region Implementation (IEnumerator)
-
+
object IEnumerator.Current
{
get { return this.Current; }
}
-
+
#endregion
}
@@ -749,7 +749,7 @@
public override void CopyTo(Level[] array, int start)
{
- m_collection.CopyTo(array,start);
+ m_collection.CopyTo(array, start);
}
public override int Count
{
@@ -802,7 +802,7 @@
}
public override void Remove(Level x)
- {
+ {
throw new NotSupportedException("This is a Read Only Collection and can not be modified");
}
diff --git a/src/log4net/Core/LevelEvaluator.cs b/src/log4net/Core/LevelEvaluator.cs
index d058cee..eac2d4e 100644
--- a/src/log4net/Core/LevelEvaluator.cs
+++ b/src/log4net/Core/LevelEvaluator.cs
@@ -35,7 +35,7 @@
/// </para>
/// </remarks>
/// <author>Nicko Cadell</author>
- public class LevelEvaluator : ITriggeringEventEvaluator
+ public class LevelEvaluator : ITriggeringEventEvaluator
{
/// <summary>
/// The threshold for triggering
@@ -120,14 +120,14 @@
/// level.
/// </para>
/// </remarks>
- public bool IsTriggeringEvent(LoggingEvent loggingEvent)
+ public bool IsTriggeringEvent(LoggingEvent loggingEvent)
{
if (loggingEvent == null)
{
throw new ArgumentNullException("loggingEvent");
}
- return (loggingEvent.Level >= m_threshold);
+ return (loggingEvent.Level >= m_threshold);
}
}
}
diff --git a/src/log4net/Core/LevelMap.cs b/src/log4net/Core/LevelMap.cs
index 7558d1a..75a2abb 100644
--- a/src/log4net/Core/LevelMap.cs
+++ b/src/log4net/Core/LevelMap.cs
@@ -95,7 +95,7 @@
throw new ArgumentNullException("name");
}
- lock(this)
+ lock (this)
{
return (Level)m_mapName2Level[name];
}
@@ -137,7 +137,7 @@
}
if (name.Length == 0)
{
- throw log4net.Util.SystemInfo.CreateArgumentOutOfRangeException("name", name, "Parameter: name, Value: ["+name+"] out of range. Level name must not be empty");
+ throw log4net.Util.SystemInfo.CreateArgumentOutOfRangeException("name", name, "Parameter: name, Value: [" + name + "] out of range. Level name must not be empty");
}
if (displayName == null || displayName.Length == 0)
@@ -163,7 +163,7 @@
{
throw new ArgumentNullException("level");
}
- lock(this)
+ lock (this)
{
m_mapName2Level[level.Name] = level;
}
@@ -182,7 +182,7 @@
{
get
{
- lock(this)
+ lock (this)
{
return new LevelCollection(m_mapName2Level.Values);
}
@@ -214,7 +214,7 @@
throw new ArgumentNullException("defaultLevel");
}
- lock(this)
+ lock (this)
{
Level level = (Level)m_mapName2Level[defaultLevel.Name];
if (level == null)
diff --git a/src/log4net/Core/LocationInfo.cs b/src/log4net/Core/LocationInfo.cs
index b240338..a3633fd 100644
--- a/src/log4net/Core/LocationInfo.cs
+++ b/src/log4net/Core/LocationInfo.cs
@@ -76,7 +76,7 @@
/// class based on the current thread.
/// </para>
/// </remarks>
- public LocationInfo(Type callerStackBoundaryDeclaringType)
+ public LocationInfo(Type callerStackBoundaryDeclaringType)
{
// Initialize all fields
m_className = NA;
@@ -92,7 +92,7 @@
{
StackTrace st = new StackTrace(true);
int frameIndex = 0;
-
+
// skip frames not from fqnOfCallingClass
while (frameIndex < st.FrameCount)
{
@@ -119,15 +119,15 @@
{
// 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++)
+ for (int i = frameIndex; i < st.FrameCount; i++)
{
stackFramesList.Add(new StackFrameItem(st.GetFrame(i)));
}
-
+
stackFramesList.CopyTo(m_stackFrames, 0);
-
+
// now frameIndex is the first 'user' caller frame
StackFrame locationFrame = st.GetFrame(frameIndex);
@@ -137,7 +137,7 @@
if (method != null)
{
- m_methodName = method.Name;
+ m_methodName = method.Name;
if (method.DeclaringType != null)
{
m_className = method.DeclaringType.FullName;
@@ -147,11 +147,11 @@
m_lineNumber = locationFrame.GetFileLineNumber().ToString(System.Globalization.NumberFormatInfo.InvariantInfo);
// Combine all location info
- m_fullInfo = m_className + '.' + m_methodName + '(' + m_fileName + ':' + m_lineNumber + ')';
+ m_fullInfo = m_className + '.' + m_methodName + '(' + m_fileName + ':' + m_lineNumber + ')';
}
}
}
- catch(System.Security.SecurityException)
+ catch (System.Security.SecurityException)
{
// This security exception will occur if the caller does not have
// some undefined set of SecurityPermission flags.
@@ -180,7 +180,7 @@
m_fileName = fileName;
m_lineNumber = lineNumber;
m_methodName = methodName;
- m_fullInfo = m_className + '.' + m_methodName + '(' + m_fileName +
+ m_fullInfo = m_className + '.' + m_methodName + '(' + m_fileName +
':' + m_lineNumber + ')';
}
@@ -272,7 +272,7 @@
{
get { return m_fullInfo; }
}
-
+
#if !NETCF && !NETSTANDARD1_3
/// <summary>
/// Gets the stack frames from the stack trace of the caller making the log request
@@ -300,14 +300,14 @@
#region Private Static Fields
- /// <summary>
- /// The fully qualified type of the LocationInfo class.
- /// </summary>
- /// <remarks>
- /// Used by the internal logger to record the Type of the
- /// log message.
- /// </remarks>
- private static readonly Type declaringType = typeof(LocationInfo);
+ /// <summary>
+ /// The fully qualified type of the LocationInfo class.
+ /// </summary>
+ /// <remarks>
+ /// Used by the internal logger to record the Type of the
+ /// log message.
+ /// </remarks>
+ private static readonly Type declaringType = typeof(LocationInfo);
/// <summary>
/// When location information is not available the constant
diff --git a/src/log4net/Core/LogException.cs b/src/log4net/Core/LogException.cs
index 8824389..f9b8e25 100644
--- a/src/log4net/Core/LogException.cs
+++ b/src/log4net/Core/LogException.cs
@@ -42,7 +42,7 @@
#if NETSTANDARD1_3
public class LogException : Exception
#else
- public class LogException : ApplicationException
+ public class LogException : ApplicationException
#endif
{
#region Public Instance Constructors
@@ -69,10 +69,10 @@
/// the specified message.
/// </para>
/// </remarks>
- public LogException(String message) : base(message)
+ public LogException(String message) : base(message)
{
}
-
+
/// <summary>
/// Constructor
/// </summary>
@@ -84,7 +84,7 @@
/// with the specified message and inner exception.
/// </para>
/// </remarks>
- public LogException(String message, Exception innerException) : base(message, innerException)
+ public LogException(String message, Exception innerException) : base(message, innerException)
{
}
@@ -104,7 +104,7 @@
/// with serialized data.
/// </para>
/// </remarks>
- protected LogException(SerializationInfo info, StreamingContext context) : base(info, context)
+ protected LogException(SerializationInfo info, StreamingContext context) : base(info, context)
{
}
#endif
diff --git a/src/log4net/Core/LogImpl.cs b/src/log4net/Core/LogImpl.cs
index 965b5aa..6eae4fa 100644
--- a/src/log4net/Core/LogImpl.cs
+++ b/src/log4net/Core/LogImpl.cs
@@ -165,7 +165,7 @@
/// <see cref="M:Debug(object,Exception)"/> form instead.
/// </para>
/// </remarks>
- public virtual void Debug(object message)
+ public virtual void Debug(object message)
{
Logger.Log(ThisDeclaringType, m_levelDebug, message, null);
}
@@ -186,7 +186,7 @@
/// </para>
/// </remarks>
/// <seealso cref="M:Debug(object)"/>
- public virtual void Debug(object message, Exception exception)
+ public virtual void Debug(object message, Exception exception)
{
Logger.Log(ThisDeclaringType, m_levelDebug, message, exception);
}
@@ -213,7 +213,7 @@
/// methods instead.
/// </para>
/// </remarks>
- public virtual void DebugFormat(string format, params object[] args)
+ public virtual void DebugFormat(string format, params object[] args)
{
if (IsDebugEnabled)
{
@@ -243,7 +243,7 @@
/// methods instead.
/// </para>
/// </remarks>
- public virtual void DebugFormat(string format, object arg0)
+ public virtual void DebugFormat(string format, object arg0)
{
if (IsDebugEnabled)
{
@@ -274,7 +274,7 @@
/// methods instead.
/// </para>
/// </remarks>
- public virtual void DebugFormat(string format, object arg0, object arg1)
+ public virtual void DebugFormat(string format, object arg0, object arg1)
{
if (IsDebugEnabled)
{
@@ -306,7 +306,7 @@
/// methods instead.
/// </para>
/// </remarks>
- public virtual void DebugFormat(string format, object arg0, object arg1, object arg2)
+ public virtual void DebugFormat(string format, object arg0, object arg1, object arg2)
{
if (IsDebugEnabled)
{
@@ -332,7 +332,7 @@
/// methods instead.
/// </para>
/// </remarks>
- public virtual void DebugFormat(IFormatProvider provider, string format, params object[] args)
+ public virtual void DebugFormat(IFormatProvider provider, string format, params object[] args)
{
if (IsDebugEnabled)
{
@@ -363,11 +363,11 @@
/// <see cref="M:Info(object,Exception)"/> form instead.
/// </para>
/// </remarks>
- public virtual void Info(object message)
+ public virtual void Info(object message)
{
Logger.Log(ThisDeclaringType, m_levelInfo, message, null);
}
-
+
/// <summary>
/// Logs a message object with the <c>INFO</c> level.
/// </summary>
@@ -384,7 +384,7 @@
/// </para>
/// </remarks>
/// <seealso cref="M:Info(object)"/>
- public virtual void Info(object message, Exception exception)
+ public virtual void Info(object message, Exception exception)
{
Logger.Log(ThisDeclaringType, m_levelInfo, message, exception);
}
@@ -411,7 +411,7 @@
/// methods instead.
/// </para>
/// </remarks>
- public virtual void InfoFormat(string format, params object[] args)
+ public virtual void InfoFormat(string format, params object[] args)
{
if (IsInfoEnabled)
{
@@ -441,7 +441,7 @@
/// methods instead.
/// </para>
/// </remarks>
- public virtual void InfoFormat(string format, object arg0)
+ public virtual void InfoFormat(string format, object arg0)
{
if (IsInfoEnabled)
{
@@ -472,7 +472,7 @@
/// methods instead.
/// </para>
/// </remarks>
- public virtual void InfoFormat(string format, object arg0, object arg1)
+ public virtual void InfoFormat(string format, object arg0, object arg1)
{
if (IsInfoEnabled)
{
@@ -504,7 +504,7 @@
/// methods instead.
/// </para>
/// </remarks>
- public virtual void InfoFormat(string format, object arg0, object arg1, object arg2)
+ public virtual void InfoFormat(string format, object arg0, object arg1, object arg2)
{
if (IsInfoEnabled)
{
@@ -530,7 +530,7 @@
/// methods instead.
/// </para>
/// </remarks>
- public virtual void InfoFormat(IFormatProvider provider, string format, params object[] args)
+ public virtual void InfoFormat(IFormatProvider provider, string format, params object[] args)
{
if (IsInfoEnabled)
{
@@ -561,11 +561,11 @@
/// <see cref="M:Warn(object,Exception)"/> form instead.
/// </para>
/// </remarks>
- public virtual void Warn(object message)
+ public virtual void Warn(object message)
{
Logger.Log(ThisDeclaringType, m_levelWarn, message, null);
}
-
+
/// <summary>
/// Logs a message object with the <c>WARN</c> level
/// </summary>
@@ -582,7 +582,7 @@
/// </para>
/// </remarks>
/// <seealso cref="M:Warn(object)"/>
- public virtual void Warn(object message, Exception exception)
+ public virtual void Warn(object message, Exception exception)
{
Logger.Log(ThisDeclaringType, m_levelWarn, message, exception);
}
@@ -609,7 +609,7 @@
/// methods instead.
/// </para>
/// </remarks>
- public virtual void WarnFormat(string format, params object[] args)
+ public virtual void WarnFormat(string format, params object[] args)
{
if (IsWarnEnabled)
{
@@ -639,7 +639,7 @@
/// methods instead.
/// </para>
/// </remarks>
- public virtual void WarnFormat(string format, object arg0)
+ public virtual void WarnFormat(string format, object arg0)
{
if (IsWarnEnabled)
{
@@ -670,7 +670,7 @@
/// methods instead.
/// </para>
/// </remarks>
- public virtual void WarnFormat(string format, object arg0, object arg1)
+ public virtual void WarnFormat(string format, object arg0, object arg1)
{
if (IsWarnEnabled)
{
@@ -702,7 +702,7 @@
/// methods instead.
/// </para>
/// </remarks>
- public virtual void WarnFormat(string format, object arg0, object arg1, object arg2)
+ public virtual void WarnFormat(string format, object arg0, object arg1, object arg2)
{
if (IsWarnEnabled)
{
@@ -728,7 +728,7 @@
/// methods instead.
/// </para>
/// </remarks>
- public virtual void WarnFormat(IFormatProvider provider, string format, params object[] args)
+ public virtual void WarnFormat(IFormatProvider provider, string format, params object[] args)
{
if (IsWarnEnabled)
{
@@ -759,7 +759,7 @@
/// <see cref="M:Error(object,Exception)"/> form instead.
/// </para>
/// </remarks>
- public virtual void Error(object message)
+ public virtual void Error(object message)
{
Logger.Log(ThisDeclaringType, m_levelError, message, null);
}
@@ -780,7 +780,7 @@
/// </para>
/// </remarks>
/// <seealso cref="M:Error(object)"/>
- public virtual void Error(object message, Exception exception)
+ public virtual void Error(object message, Exception exception)
{
Logger.Log(ThisDeclaringType, m_levelError, message, exception);
}
@@ -807,7 +807,7 @@
/// methods instead.
/// </para>
/// </remarks>
- public virtual void ErrorFormat(string format, params object[] args)
+ public virtual void ErrorFormat(string format, params object[] args)
{
if (IsErrorEnabled)
{
@@ -837,7 +837,7 @@
/// methods instead.
/// </para>
/// </remarks>
- public virtual void ErrorFormat(string format, object arg0)
+ public virtual void ErrorFormat(string format, object arg0)
{
if (IsErrorEnabled)
{
@@ -868,7 +868,7 @@
/// methods instead.
/// </para>
/// </remarks>
- public virtual void ErrorFormat(string format, object arg0, object arg1)
+ public virtual void ErrorFormat(string format, object arg0, object arg1)
{
if (IsErrorEnabled)
{
@@ -900,7 +900,7 @@
/// methods instead.
/// </para>
/// </remarks>
- public virtual void ErrorFormat(string format, object arg0, object arg1, object arg2)
+ public virtual void ErrorFormat(string format, object arg0, object arg1, object arg2)
{
if (IsErrorEnabled)
{
@@ -926,7 +926,7 @@
/// methods instead.
/// </para>
/// </remarks>
- public virtual void ErrorFormat(IFormatProvider provider, string format, params object[] args)
+ public virtual void ErrorFormat(IFormatProvider provider, string format, params object[] args)
{
if (IsErrorEnabled)
{
@@ -957,11 +957,11 @@
/// <see cref="M:Fatal(object,Exception)"/> form instead.
/// </para>
/// </remarks>
- public virtual void Fatal(object message)
+ public virtual void Fatal(object message)
{
Logger.Log(ThisDeclaringType, m_levelFatal, message, null);
}
-
+
/// <summary>
/// Logs a message object with the <c>FATAL</c> level
/// </summary>
@@ -978,7 +978,7 @@
/// </para>
/// </remarks>
/// <seealso cref="M:Fatal(object)"/>
- public virtual void Fatal(object message, Exception exception)
+ public virtual void Fatal(object message, Exception exception)
{
Logger.Log(ThisDeclaringType, m_levelFatal, message, exception);
}
@@ -1005,7 +1005,7 @@
/// methods instead.
/// </para>
/// </remarks>
- public virtual void FatalFormat(string format, params object[] args)
+ public virtual void FatalFormat(string format, params object[] args)
{
if (IsFatalEnabled)
{
@@ -1035,7 +1035,7 @@
/// methods instead.
/// </para>
/// </remarks>
- public virtual void FatalFormat(string format, object arg0)
+ public virtual void FatalFormat(string format, object arg0)
{
if (IsFatalEnabled)
{
@@ -1066,7 +1066,7 @@
/// methods instead.
/// </para>
/// </remarks>
- public virtual void FatalFormat(string format, object arg0, object arg1)
+ public virtual void FatalFormat(string format, object arg0, object arg1)
{
if (IsFatalEnabled)
{
@@ -1098,7 +1098,7 @@
/// methods instead.
/// </para>
/// </remarks>
- public virtual void FatalFormat(string format, object arg0, object arg1, object arg2)
+ public virtual void FatalFormat(string format, object arg0, object arg1, object arg2)
{
if (IsFatalEnabled)
{
@@ -1124,7 +1124,7 @@
/// methods instead.
/// </para>
/// </remarks>
- public virtual void FatalFormat(IFormatProvider provider, string format, params object[] args)
+ public virtual void FatalFormat(IFormatProvider provider, string format, params object[] args)
{
if (IsFatalEnabled)
{
@@ -1179,7 +1179,7 @@
{
get { return Logger.IsEnabledFor(m_levelDebug); }
}
-
+
/// <summary>
/// Checks if this logger is enabled for the <c>INFO</c> level.
/// </summary>
diff --git a/src/log4net/Core/LoggerManager.cs b/src/log4net/Core/LoggerManager.cs
index 8fb38c8..565cd6a 100644
--- a/src/log4net/Core/LoggerManager.cs
+++ b/src/log4net/Core/LoggerManager.cs
@@ -61,7 +61,7 @@
/// Private constructor to prevent instances. Only static methods should be used.
/// </para>
/// </remarks>
- private LoggerManager()
+ private LoggerManager()
{
}
@@ -88,16 +88,16 @@
// makes a LinkDemand which throws the exception during the JIT phase.
RegisterAppDomainEvents();
}
- catch(System.Security.SecurityException)
+ catch (System.Security.SecurityException)
{
- LogLog.Debug(declaringType, "Security Exception (ControlAppDomain LinkDemand) while trying "+
- "to register Shutdown handler with the AppDomain. LoggerManager.Shutdown() "+
- "will not be called automatically when the AppDomain exits. It must be called "+
+ LogLog.Debug(declaringType, "Security Exception (ControlAppDomain LinkDemand) while trying " +
+ "to register Shutdown handler with the AppDomain. LoggerManager.Shutdown() " +
+ "will not be called automatically when the AppDomain exits. It must be called " +
"programmatically.");
}
// Dump out our assembly version into the log if debug is enabled
- LogLog.Debug(declaringType, GetVersionInfo());
+ LogLog.Debug(declaringType, GetVersionInfo());
// Set the default repository selector
#if NETCF
@@ -114,9 +114,9 @@
{
appRepositorySelectorType = SystemInfo.GetTypeFromString(appRepositorySelectorTypeName, false, true);
}
- catch(Exception ex)
+ catch (Exception ex)
{
- LogLog.Error(declaringType, "Exception while resolving RepositorySelector Type ["+appRepositorySelectorTypeName+"]", ex);
+ LogLog.Error(declaringType, "Exception while resolving RepositorySelector Type [" + appRepositorySelectorTypeName + "]", ex);
}
if (appRepositorySelectorType != null)
@@ -127,9 +127,9 @@
{
appRepositorySelectorObj = Activator.CreateInstance(appRepositorySelectorType);
}
- catch(Exception ex)
+ catch (Exception ex)
{
- LogLog.Error(declaringType, "Exception while creating RepositorySelector ["+appRepositorySelectorType.FullName+"]", ex);
+ LogLog.Error(declaringType, "Exception while creating RepositorySelector [" + appRepositorySelectorType.FullName + "]", ex);
}
if (appRepositorySelectorObj != null && appRepositorySelectorObj is IRepositorySelector)
@@ -138,7 +138,7 @@
}
else
{
- LogLog.Error(declaringType, "RepositorySelector Type ["+appRepositorySelectorType.FullName+"] is not an IRepositorySelector");
+ LogLog.Error(declaringType, "RepositorySelector Type [" + appRepositorySelectorType.FullName + "] is not an IRepositorySelector");
}
}
}
@@ -260,7 +260,7 @@
/// <c>null</c>.
/// </para>
/// </remarks>
- public static ILogger Exists(string repository, string name)
+ public static ILogger Exists(string repository, string name)
{
if (repository == null)
{
@@ -289,7 +289,7 @@
/// <c>null</c>.
/// </para>
/// </remarks>
- public static ILogger Exists(Assembly repositoryAssembly, string name)
+ public static ILogger Exists(Assembly repositoryAssembly, string name)
{
if (repositoryAssembly == null)
{
@@ -402,7 +402,7 @@
throw new ArgumentNullException("name");
}
return RepositorySelector.GetRepository(repositoryAssembly).GetLogger(name);
- }
+ }
/// <summary>
/// Shorthand for <see cref="M:LogManager.GetLogger(string)"/>.
@@ -415,7 +415,7 @@
/// Gets the logger for the fully qualified name of the type specified.
/// </para>
/// </remarks>
- public static ILogger GetLogger(string repository, Type type)
+ public static ILogger GetLogger(string repository, Type type)
{
if (repository == null)
{
@@ -439,7 +439,7 @@
/// Gets the logger for the fully qualified name of the type specified.
/// </para>
/// </remarks>
- public static ILogger GetLogger(Assembly repositoryAssembly, Type type)
+ public static ILogger GetLogger(Assembly repositoryAssembly, Type type)
{
if (repositoryAssembly == null)
{
@@ -450,7 +450,7 @@
throw new ArgumentNullException("type");
}
return RepositorySelector.GetRepository(repositoryAssembly).GetLogger(type.FullName);
- }
+ }
/// <summary>
/// Shuts down the log4net system.
@@ -472,9 +472,9 @@
/// and again to a nested appender.
/// </para>
/// </remarks>
- public static void Shutdown()
+ public static void Shutdown()
{
- foreach(ILoggerRepository repository in GetAllRepositories())
+ foreach (ILoggerRepository repository in GetAllRepositories())
{
repository.Shutdown();
}
@@ -501,7 +501,7 @@
/// and again to a nested appender.
/// </para>
/// </remarks>
- public static void ShutdownRepository(string repository)
+ public static void ShutdownRepository(string repository)
{
if (repository == null)
{
@@ -532,7 +532,7 @@
/// and again to a nested appender.
/// </para>
/// </remarks>
- public static void ShutdownRepository(Assembly repositoryAssembly)
+ public static void ShutdownRepository(Assembly repositoryAssembly)
{
if (repositoryAssembly == null)
{
@@ -555,7 +555,7 @@
/// message disabling is set its default "off" value.
/// </para>
/// </remarks>
- public static void ResetConfiguration(string repository)
+ public static void ResetConfiguration(string repository)
{
if (repository == null)
{
@@ -578,7 +578,7 @@
/// message disabling is set its default "off" value.
/// </para>
/// </remarks>
- public static void ResetConfiguration(Assembly repositoryAssembly)
+ public static void ResetConfiguration(Assembly repositoryAssembly)
{
if (repositoryAssembly == null)
{
@@ -810,7 +810,7 @@
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(")");
@@ -859,14 +859,14 @@
#region Private Static Fields
- /// <summary>
- /// The fully qualified type of the LoggerManager class.
- /// </summary>
- /// <remarks>
- /// Used by the internal logger to record the Type of the
- /// log message.
- /// </remarks>
- private static readonly Type declaringType = typeof(LoggerManager);
+ /// <summary>
+ /// The fully qualified type of the LoggerManager class.
+ /// </summary>
+ /// <remarks>
+ /// Used by the internal logger to record the Type of the
+ /// log message.
+ /// </remarks>
+ private static readonly Type declaringType = typeof(LoggerManager);
/// <summary>
/// Initialize the default repository selector
diff --git a/src/log4net/Core/LoggerWrapperImpl.cs b/src/log4net/Core/LoggerWrapperImpl.cs
index fbc49a4..61e19eb 100644
--- a/src/log4net/Core/LoggerWrapperImpl.cs
+++ b/src/log4net/Core/LoggerWrapperImpl.cs
@@ -42,7 +42,7 @@
/// Constructs a new wrapper for the specified logger.
/// </para>
/// </remarks>
- protected LoggerWrapperImpl(ILogger logger)
+ protected LoggerWrapperImpl(ILogger logger)
{
m_logger = logger;
}
@@ -79,8 +79,8 @@
/// <summary>
/// The logger that this object is wrapping
/// </summary>
- private readonly ILogger m_logger;
-
+ private readonly ILogger m_logger;
+
#endregion Private Instance Fields
}
}
diff --git a/src/log4net/Core/LoggingEvent.cs b/src/log4net/Core/LoggingEvent.cs
index 4d73ddb..b4d2a00 100644
--- a/src/log4net/Core/LoggingEvent.cs
+++ b/src/log4net/Core/LoggingEvent.cs
@@ -32,186 +32,1187 @@
namespace log4net.Core
{
+ /// <summary>
+ /// Portable data structure used by <see cref="LoggingEvent"/>
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Portable data structure used by <see cref="LoggingEvent"/>
+ /// </para>
+ /// </remarks>
+ /// <author>Nicko Cadell</author>
+ public struct LoggingEventData
+ {
+ #region Public Instance Fields
+
/// <summary>
- /// Portable data structure used by <see cref="LoggingEvent"/>
+ /// The logger name.
/// </summary>
/// <remarks>
/// <para>
- /// Portable data structure used by <see cref="LoggingEvent"/>
+ /// The logger name.
/// </para>
/// </remarks>
- /// <author>Nicko Cadell</author>
- public struct LoggingEventData
- {
- #region Public Instance Fields
+ public string LoggerName;
- /// <summary>
- /// The logger name.
- /// </summary>
- /// <remarks>
- /// <para>
- /// The logger name.
- /// </para>
- /// </remarks>
- public string LoggerName;
+ /// <summary>
+ /// Level of logging event.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Level of logging event. Level cannot be Serializable
+ /// because it is a flyweight. Due to its special serialization it
+ /// cannot be declared final either.
+ /// </para>
+ /// </remarks>
+ public Level Level;
- /// <summary>
- /// Level of logging event.
- /// </summary>
- /// <remarks>
- /// <para>
- /// Level of logging event. Level cannot be Serializable
- /// because it is a flyweight. Due to its special serialization it
- /// cannot be declared final either.
- /// </para>
- /// </remarks>
- public Level Level;
+ /// <summary>
+ /// The application supplied message.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// The application supplied message of logging event.
+ /// </para>
+ /// </remarks>
+ public string Message;
- /// <summary>
- /// The application supplied message.
- /// </summary>
- /// <remarks>
- /// <para>
- /// The application supplied message of logging event.
- /// </para>
- /// </remarks>
- public string Message;
+ /// <summary>
+ /// The name of thread
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// The name of thread in which this logging event was generated
+ /// </para>
+ /// </remarks>
+ public string ThreadName;
- /// <summary>
- /// The name of thread
- /// </summary>
- /// <remarks>
- /// <para>
- /// The name of thread in which this logging event was generated
- /// </para>
- /// </remarks>
- public string ThreadName;
+ /// <summary>
+ /// 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>
+ /// </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 local time the event was logged
- /// </summary>
- /// <remarks>
- /// <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>
+ /// <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
+ public DateTime TimeStampUtc
+ {
+ get
+ {
+ if (TimeStamp != default(DateTime) &&
+ _timeStampUtc == default(DateTime))
{
- 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();
- }
+ // TimeStamp field has been set explicitly but TimeStampUtc hasn't
+ // => use TimeStamp
+ return TimeStamp.ToUniversalTime();
}
- private DateTime _timeStampUtc;
+ return _timeStampUtc;
+ }
+ set
+ {
+ _timeStampUtc = value;
+ // For backwards compatibility
+ TimeStamp = _timeStampUtc.ToLocalTime();
+ }
+ }
+
+ private DateTime _timeStampUtc;
#pragma warning restore 618
- /// <summary>
- /// Location information for the caller.
- /// </summary>
- /// <remarks>
- /// <para>
- /// Location information for the caller.
- /// </para>
- /// </remarks>
- public LocationInfo LocationInfo;
+ /// <summary>
+ /// Location information for the caller.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Location information for the caller.
+ /// </para>
+ /// </remarks>
+ public LocationInfo LocationInfo;
- /// <summary>
- /// String representation of the user
- /// </summary>
- /// <remarks>
- /// <para>
- /// String representation of the user's windows name,
- /// like DOMAIN\username
- /// </para>
- /// </remarks>
- public string UserName;
+ /// <summary>
+ /// String representation of the user
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// String representation of the user's windows name,
+ /// like DOMAIN\username
+ /// </para>
+ /// </remarks>
+ public string UserName;
- /// <summary>
- /// String representation of the identity.
- /// </summary>
- /// <remarks>
- /// <para>
- /// String representation of the current thread's principal identity.
- /// </para>
- /// </remarks>
- public string Identity;
+ /// <summary>
+ /// String representation of the identity.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// String representation of the current thread's principal identity.
+ /// </para>
+ /// </remarks>
+ public string Identity;
- /// <summary>
- /// The string representation of the exception
- /// </summary>
- /// <remarks>
- /// <para>
- /// The string representation of the exception
- /// </para>
- /// </remarks>
- public string ExceptionString;
+ /// <summary>
+ /// The string representation of the exception
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// The string representation of the exception
+ /// </para>
+ /// </remarks>
+ public string ExceptionString;
- /// <summary>
- /// String representation of the AppDomain.
- /// </summary>
- /// <remarks>
- /// <para>
- /// String representation of the AppDomain.
- /// </para>
- /// </remarks>
- public string Domain;
+ /// <summary>
+ /// String representation of the AppDomain.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// String representation of the AppDomain.
+ /// </para>
+ /// </remarks>
+ public string Domain;
- /// <summary>
- /// Additional event specific properties
- /// </summary>
- /// <remarks>
- /// <para>
- /// A logger or an appender may attach additional
- /// properties to specific events. These properties
- /// have a string key and an object value.
- /// </para>
- /// </remarks>
- public PropertiesDictionary Properties;
+ /// <summary>
+ /// Additional event specific properties
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// A logger or an appender may attach additional
+ /// properties to specific events. These properties
+ /// have a string key and an object value.
+ /// </para>
+ /// </remarks>
+ public PropertiesDictionary Properties;
- #endregion Public Instance Fields
+ #endregion Public Instance Fields
+ }
+
+ /// <summary>
+ /// The internal representation of logging events.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// When an affirmative decision is made to log then a
+ /// <see cref="LoggingEvent"/> instance is created. This instance
+ /// is passed around to the different log4net components.
+ /// </para>
+ /// <para>
+ /// This class is of concern to those wishing to extend log4net.
+ /// </para>
+ /// <para>
+ /// Some of the values in instances of <see cref="LoggingEvent"/>
+ /// are considered volatile, that is the values are correct at the
+ /// time the event is delivered to appenders, but will not be consistent
+ /// at any time afterwards. If an event is to be stored and then processed
+ /// at a later time these volatile values must be fixed by calling
+ /// <see cref="M:FixVolatileData()"/>. There is a performance penalty
+ /// for incurred by calling <see cref="M:FixVolatileData()"/> but it
+ /// is essential to maintaining data consistency.
+ /// </para>
+ /// </remarks>
+ /// <author>Nicko Cadell</author>
+ /// <author>Gert Driesen</author>
+ /// <author>Douglas de la Torre</author>
+ /// <author>Daniel Cazzulino</author>
+#if !NETCF
+ [Serializable]
+#endif
+ public class LoggingEvent
+#if !NETCF
+ : ISerializable
+#endif
+ {
+ private static readonly Type declaringType = typeof(LoggingEvent);
+
+ #region Public Instance Constructors
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="LoggingEvent" /> class
+ /// from the supplied parameters.
+ /// </summary>
+ /// <param name="callerStackBoundaryDeclaringType">The declaring type of the method that is
+ /// the stack boundary into the logging system for this call.</param>
+ /// <param name="repository">The repository this event is logged in.</param>
+ /// <param name="loggerName">The name of the logger of this event.</param>
+ /// <param name="level">The level of this event.</param>
+ /// <param name="message">The message of this event.</param>
+ /// <param name="exception">The exception for this event.</param>
+ /// <remarks>
+ /// <para>
+ /// Except <see cref="TimeStamp"/>, <see cref="Level"/> and <see cref="LoggerName"/>,
+ /// all fields of <c>LoggingEvent</c> are filled when actually needed. Call
+ /// <see cref="M:FixVolatileData()"/> to cache all data locally
+ /// to prevent inconsistencies.
+ /// </para>
+ /// <para>This method is called by the log4net framework
+ /// to create a logging event.
+ /// </para>
+ /// </remarks>
+ public LoggingEvent(Type callerStackBoundaryDeclaringType,
+ log4net.Repository.ILoggerRepository repository,
+ string loggerName,
+ Level level,
+ object message,
+ Exception exception)
+ {
+ m_callerStackBoundaryDeclaringType = callerStackBoundaryDeclaringType;
+ m_message = message;
+ m_repository = repository;
+ m_thrownException = exception;
+
+ m_data.LoggerName = loggerName;
+ m_data.Level = level;
+
+ // Store the event creation time
+ m_data.TimeStampUtc = DateTime.UtcNow;
}
/// <summary>
- /// The internal representation of logging events.
+ /// Initializes a new instance of the <see cref="LoggingEvent" /> class
+ /// using specific data.
+ /// </summary>
+ /// <param name="callerStackBoundaryDeclaringType">The declaring type of the method that is
+ /// the stack boundary into the logging system for this call.</param>
+ /// <param name="repository">The repository this event is logged in.</param>
+ /// <param name="data">Data used to initialize the logging event.</param>
+ /// <param name="fixedData">The fields in the <paranref name="data"/> struct that have already been fixed.</param>
+ /// <remarks>
+ /// <para>
+ /// This constructor is provided to allow a <see cref="LoggingEvent" />
+ /// to be created independently of the log4net framework. This can
+ /// be useful if you require a custom serialization scheme.
+ /// </para>
+ /// <para>
+ /// Use the <see cref="M:GetLoggingEventData(FixFlags)"/> method to obtain an
+ /// instance of the <see cref="LoggingEventData"/> class.
+ /// </para>
+ /// <para>
+ /// The <paramref name="fixedData"/> parameter should be used to specify which fields in the
+ /// <paramref name="data"/> struct have been preset. Fields not specified in the <paramref name="fixedData"/>
+ /// will be captured from the environment if requested or fixed.
+ /// </para>
+ /// </remarks>
+ public LoggingEvent(Type callerStackBoundaryDeclaringType,
+ log4net.Repository.ILoggerRepository repository,
+ LoggingEventData data,
+ FixFlags fixedData)
+ {
+ m_callerStackBoundaryDeclaringType = callerStackBoundaryDeclaringType;
+ m_repository = repository;
+
+ m_data = data;
+ m_fixFlags = fixedData;
+ }
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="LoggingEvent" /> class
+ /// using specific data.
+ /// </summary>
+ /// <param name="callerStackBoundaryDeclaringType">The declaring type of the method that is
+ /// the stack boundary into the logging system for this call.</param>
+ /// <param name="repository">The repository this event is logged in.</param>
+ /// <param name="data">Data used to initialize the logging event.</param>
+ /// <remarks>
+ /// <para>
+ /// This constructor is provided to allow a <see cref="LoggingEvent" />
+ /// to be created independently of the log4net framework. This can
+ /// be useful if you require a custom serialization scheme.
+ /// </para>
+ /// <para>
+ /// Use the <see cref="M:GetLoggingEventData(FixFlags)"/> method to obtain an
+ /// instance of the <see cref="LoggingEventData"/> class.
+ /// </para>
+ /// <para>
+ /// This constructor sets this objects <see cref="Fix"/> flags to <see cref="FixFlags.All"/>,
+ /// this assumes that all the data relating to this event is passed in via the <paramref name="data"/>
+ /// parameter and no other data should be captured from the environment.
+ /// </para>
+ /// </remarks>
+ public LoggingEvent(Type callerStackBoundaryDeclaringType,
+ log4net.Repository.ILoggerRepository repository,
+ LoggingEventData data) : this(callerStackBoundaryDeclaringType, repository, data, FixFlags.All)
+ {
+ }
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="LoggingEvent" /> class
+ /// using specific data.
+ /// </summary>
+ /// <param name="data">Data used to initialize the logging event.</param>
+ /// <remarks>
+ /// <para>
+ /// This constructor is provided to allow a <see cref="LoggingEvent" />
+ /// to be created independently of the log4net framework. This can
+ /// be useful if you require a custom serialization scheme.
+ /// </para>
+ /// <para>
+ /// Use the <see cref="M:GetLoggingEventData(FixFlags)"/> method to obtain an
+ /// instance of the <see cref="LoggingEventData"/> class.
+ /// </para>
+ /// <para>
+ /// This constructor sets this objects <see cref="Fix"/> flags to <see cref="FixFlags.All"/>,
+ /// this assumes that all the data relating to this event is passed in via the <paramref name="data"/>
+ /// parameter and no other data should be captured from the environment.
+ /// </para>
+ /// </remarks>
+ public LoggingEvent(LoggingEventData data) : this(null, null, data)
+ {
+ }
+
+ #endregion Public Instance Constructors
+
+ #region Protected Instance Constructors
+
+#if !NETCF
+
+ /// <summary>
+ /// Serialization constructor
+ /// </summary>
+ /// <param name="info">The <see cref="SerializationInfo" /> that holds the serialized object data.</param>
+ /// <param name="context">The <see cref="StreamingContext" /> that contains contextual information about the source or destination.</param>
+ /// <remarks>
+ /// <para>
+ /// Initializes a new instance of the <see cref="LoggingEvent" /> class
+ /// with serialized data.
+ /// </para>
+ /// </remarks>
+ protected LoggingEvent(SerializationInfo info, StreamingContext context)
+ {
+ m_data.LoggerName = info.GetString("LoggerName");
+
+ // Note we are deserializing the whole level object. That is the
+ // name and the value. This value is correct for the source
+ // hierarchy but may not be for the target hierarchy that this
+ // event may be re-logged into. If it is to be re-logged it may
+ // be necessary to re-lookup the level based only on the name.
+ m_data.Level = (Level)info.GetValue("Level", typeof(Level));
+
+ m_data.Message = info.GetString("Message");
+ m_data.ThreadName = info.GetString("ThreadName");
+ m_data.TimeStampUtc = info.GetDateTime("TimeStamp").ToUniversalTime();
+ m_data.LocationInfo = (LocationInfo)info.GetValue("LocationInfo", typeof(LocationInfo));
+ m_data.UserName = info.GetString("UserName");
+ m_data.ExceptionString = info.GetString("ExceptionString");
+ m_data.Properties = (PropertiesDictionary)info.GetValue("Properties", typeof(PropertiesDictionary));
+ m_data.Domain = info.GetString("Domain");
+ m_data.Identity = info.GetString("Identity");
+
+ // We have restored all the values of this instance, i.e. all the values are fixed
+ // Set the fix flags otherwise the data values may be overwritten from the current environment.
+ m_fixFlags = FixFlags.All;
+ }
+
+#endif
+
+ #endregion Protected Instance Constructors
+
+ #region Public Instance Properties
+
+ /// <summary>
+ /// Gets the time when the current process started.
+ /// </summary>
+ /// <value>
+ /// This is the time when this process started.
+ /// </value>
+ /// <remarks>
+ /// <para>
+ /// The TimeStamp is stored internally in UTC and converted to the local time zone for this computer.
+ /// </para>
+ /// <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 StartTime
+ {
+ 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 <see cref="Level" /> of the logging event.
+ /// </summary>
+ /// <value>
+ /// The <see cref="Level" /> of the logging event.
+ /// </value>
+ /// <remarks>
+ /// <para>
+ /// Gets the <see cref="Level" /> of the logging event.
+ /// </para>
+ /// </remarks>
+ public Level Level
+ {
+ get { return m_data.Level; }
+ }
+
+ /// <summary>
+ /// Gets the time of the logging event.
+ /// </summary>
+ /// <value>
+ /// The time of the logging event.
+ /// </value>
+ /// <remarks>
+ /// <para>
+ /// The TimeStamp is stored in UTC and converted to the local time zone for this computer.
+ /// </para>
+ /// </remarks>
+ public DateTime TimeStamp
+ {
+ 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 the name of the logger that logged the event.
+ /// </summary>
+ /// <value>
+ /// The name of the logger that logged the event.
+ /// </value>
+ /// <remarks>
+ /// <para>
+ /// Gets the name of the logger that logged the event.
+ /// </para>
+ /// </remarks>
+ public string LoggerName
+ {
+ get { return m_data.LoggerName; }
+ }
+
+ /// <summary>
+ /// Gets the location information for this logging event.
+ /// </summary>
+ /// <value>
+ /// The location information for this logging event.
+ /// </value>
+ /// <remarks>
+ /// <para>
+ /// The collected information is cached for future use.
+ /// </para>
+ /// <para>
+ /// See the <see cref="LocationInfo"/> class for more information on
+ /// supported frameworks and the different behavior in Debug and
+ /// Release builds.
+ /// </para>
+ /// </remarks>
+ public LocationInfo LocationInformation
+ {
+ get
+ {
+ if (m_data.LocationInfo == null && this.m_cacheUpdatable)
+ {
+ m_data.LocationInfo = new LocationInfo(m_callerStackBoundaryDeclaringType);
+ }
+
+ return m_data.LocationInfo;
+ }
+ }
+
+ /// <summary>
+ /// Gets the message object used to initialize this event.
+ /// </summary>
+ /// <value>
+ /// The message object used to initialize this event.
+ /// </value>
+ /// <remarks>
+ /// <para>
+ /// Gets the message object used to initialize this event.
+ /// Note that this event may not have a valid message object.
+ /// If the event is serialized the message object will not
+ /// be transferred. To get the text of the message the
+ /// <see cref="RenderedMessage"/> property must be used
+ /// not this property.
+ /// </para>
+ /// <para>
+ /// If there is no defined message object for this event then
+ /// null will be returned.
+ /// </para>
+ /// </remarks>
+ public object MessageObject
+ {
+ get { return m_message; }
+ protected set { m_message = value; }
+ }
+
+ /// <summary>
+ /// Gets the exception object used to initialize this event.
+ /// </summary>
+ /// <value>
+ /// The exception object used to initialize this event.
+ /// </value>
+ /// <remarks>
+ /// <para>
+ /// Gets the exception object used to initialize this event.
+ /// Note that this event may not have a valid exception object.
+ /// If the event is serialized the exception object will not
+ /// be transferred. To get the text of the exception the
+ /// <see cref="GetExceptionString"/> method must be used
+ /// not this property.
+ /// </para>
+ /// <para>
+ /// If there is no defined exception object for this event then
+ /// null will be returned.
+ /// </para>
+ /// </remarks>
+ public Exception ExceptionObject
+ {
+ get { return m_thrownException; }
+ }
+
+ /// <summary>
+ /// The <see cref="ILoggerRepository"/> that this event was created in.
/// </summary>
/// <remarks>
/// <para>
- /// When an affirmative decision is made to log then a
- /// <see cref="LoggingEvent"/> instance is created. This instance
- /// is passed around to the different log4net components.
+ /// The <see cref="ILoggerRepository"/> that this event was created in.
+ /// </para>
+ /// </remarks>
+ public ILoggerRepository Repository
+ {
+ get { return m_repository; }
+ }
+
+ /// <summary>
+ /// Ensure that the repository is set.
+ /// </summary>
+ /// <param name="repository">the value for the repository</param>
+ internal void EnsureRepository(ILoggerRepository repository)
+ {
+ if (repository != null)
+ {
+ m_repository = repository;
+ }
+ }
+
+ /// <summary>
+ /// Gets the message, rendered through the <see cref="ILoggerRepository.RendererMap" />.
+ /// </summary>
+ /// <value>
+ /// The message rendered through the <see cref="ILoggerRepository.RendererMap" />.
+ /// </value>
+ /// <remarks>
+ /// <para>
+ /// The collected information is cached for future use.
+ /// </para>
+ /// </remarks>
+ public virtual string RenderedMessage
+ {
+ get
+ {
+ if (m_data.Message == null && this.m_cacheUpdatable)
+ {
+ if (m_message == null)
+ {
+ m_data.Message = "";
+ }
+ else if (m_message is string)
+ {
+ m_data.Message = (m_message as string);
+ }
+ else if (m_repository != null)
+ {
+ m_data.Message = m_repository.RendererMap.FindAndRender(m_message);
+ }
+ else
+ {
+ // Very last resort
+ m_data.Message = m_message.ToString();
+ }
+ }
+
+ return m_data.Message;
+ }
+ }
+
+ /// <summary>
+ /// Write the rendered message to a TextWriter
+ /// </summary>
+ /// <param name="writer">the writer to write the message to</param>
+ /// <remarks>
+ /// <para>
+ /// Unlike the <see cref="RenderedMessage"/> property this method
+ /// does store the message data in the internal cache. Therefore
+ /// if called only once this method should be faster than the
+ /// <see cref="RenderedMessage"/> property, however if the message is
+ /// to be accessed multiple times then the property will be more efficient.
+ /// </para>
+ /// </remarks>
+ public virtual void WriteRenderedMessage(TextWriter writer)
+ {
+ if (m_data.Message != null)
+ {
+ writer.Write(m_data.Message);
+ }
+ else
+ {
+ if (m_message != null)
+ {
+ if (m_message is string)
+ {
+ writer.Write(m_message as string);
+ }
+ else if (m_repository != null)
+ {
+ m_repository.RendererMap.FindAndRender(m_message, writer);
+ }
+ else
+ {
+ // Very last resort
+ writer.Write(m_message.ToString());
+ }
+ }
+ }
+ }
+
+ /// <summary>
+ /// Gets the name of the current thread.
+ /// </summary>
+ /// <value>
+ /// The name of the current thread, or the thread ID when
+ /// the name is not available.
+ /// </value>
+ /// <remarks>
+ /// <para>
+ /// The collected information is cached for future use.
+ /// </para>
+ /// </remarks>
+ public string ThreadName
+ {
+ get
+ {
+ if (m_data.ThreadName == null && this.m_cacheUpdatable)
+ {
+#if NETCF
+ // Get thread ID only
+ m_data.ThreadName =
+ SystemInfo.CurrentThreadId.ToString(System.Globalization.NumberFormatInfo.InvariantInfo);
+#else
+ // '.NET ThreadPool Worker' appears as a default thread name in the .NET 6-7 thread pool.
+ // '.NET TP Worker' is the default thread name in the .NET 8+ thread pool.
+ // Prefer the numeric thread ID instead.
+ string threadName = System.Threading.Thread.CurrentThread.Name;
+ if (!string.IsNullOrEmpty(threadName) && threadName != ".NET TP Worker" && threadName != ".NET ThreadPool Worker")
+ {
+ m_data.ThreadName = threadName;
+ }
+ else
+ {
+ // The thread name is not available or unsuitable. Therefore we
+ // go to the AppDomain to get the ID of the
+ // current thread. (Why don't Threads know their own ID?)
+ try
+ {
+ m_data.ThreadName =
+ SystemInfo.CurrentThreadId.ToString(System.Globalization.NumberFormatInfo
+ .InvariantInfo);
+ }
+ catch (SecurityException)
+ {
+ // This security exception will occur if the caller does not have
+ // some undefined set of SecurityPermission flags.
+ LogLog.Debug(declaringType,
+ "Security exception while trying to get current thread ID. Error Ignored. Empty thread name.");
+
+ // As a last resort use the hash code of the Thread object
+ m_data.ThreadName = System.Threading.Thread.CurrentThread.GetHashCode()
+ .ToString(System.Globalization.CultureInfo.InvariantCulture);
+ }
+ }
+#endif
+ }
+
+ return m_data.ThreadName;
+ }
+ }
+
+ /// <summary>
+ /// Gets the name of the current user.
+ /// </summary>
+ /// <value>
+ /// The name of the current user, or <c>NOT AVAILABLE</c> when the
+ /// underlying runtime has no support for retrieving the name of the
+ /// current user.
+ /// </value>
+ /// <remarks>
+ /// <para>
+ /// Calls <c>WindowsIdentity.GetCurrent().Name</c> to get the name of
+ /// the current windows user.
/// </para>
/// <para>
- /// This class is of concern to those wishing to extend log4net.
+ /// To improve performance, we could cache the string representation of
+ /// the name, and reuse that as long as the identity stayed constant.
+ /// Once the identity changed, we would need to re-assign and re-render
+ /// the string.
/// </para>
/// <para>
+ /// However, the <c>WindowsIdentity.GetCurrent()</c> call seems to
+ /// return different objects every time, so the current implementation
+ /// doesn't do this type of caching.
+ /// </para>
+ /// <para>
+ /// Timing for these operations:
+ /// </para>
+ /// <list type="table">
+ /// <listheader>
+ /// <term>Method</term>
+ /// <description>Results</description>
+ /// </listheader>
+ /// <item>
+ /// <term><c>WindowsIdentity.GetCurrent()</c></term>
+ /// <description>10000 loops, 00:00:00.2031250 seconds</description>
+ /// </item>
+ /// <item>
+ /// <term><c>WindowsIdentity.GetCurrent().Name</c></term>
+ /// <description>10000 loops, 00:00:08.0468750 seconds</description>
+ /// </item>
+ /// </list>
+ /// <para>
+ /// This means we could speed things up almost 40 times by caching the
+ /// value of the <c>WindowsIdentity.GetCurrent().Name</c> property, since
+ /// this takes (8.04-0.20) = 7.84375 seconds.
+ /// </para>
+ /// </remarks>
+ public string UserName =>
+ m_data.UserName ??= TryGetCurrentUserName() ?? SystemInfo.NotAvailableText;
+
+ private string TryGetCurrentUserName()
+ {
+#if (NETCF || SSCLI || NETSTANDARD1_3)
+ // On compact framework there's no notion of current Windows user
+ return SystemInfo.NotAvailableText;
+#else
+ if (_platformDoesNotSupportWindowsIdentity)
+ {
+ // we've already received one PlatformNotSupportedException
+ // and it's highly unlikely that will change
+ return Environment.UserName;
+ }
+
+ try
+ {
+ return _cachedWindowsIdentityUserName ??=
+ TryReadWindowsIdentityUserName();
+ }
+ catch (PlatformNotSupportedException)
+ {
+ _platformDoesNotSupportWindowsIdentity = true;
+ return Environment.UserName;
+ }
+ catch (SecurityException)
+ {
+ // This security exception will occur if the caller does not have
+ // some undefined set of SecurityPermission flags.
+ LogLog.Debug(
+ declaringType,
+ "Security exception while trying to get current windows identity. Error Ignored."
+ );
+ return Environment.UserName;
+ }
+ catch
+ {
+ return null;
+ }
+#endif
+ }
+
+#if (NETCF || SSCLI || NETSTANDARD1_3)
+#else
+ private string _cachedWindowsIdentityUserName;
+ private static string TryReadWindowsIdentityUserName()
+ {
+ using var identity = WindowsIdentity.GetCurrent();
+ return identity?.Name ?? "";
+ }
+#endif
+
+#if (NETCF || SSCLI || NETSTANDARD1_3)
+#else
+ private static bool _platformDoesNotSupportWindowsIdentity;
+#endif
+
+ /// <summary>
+ /// Gets the identity of the current thread principal.
+ /// </summary>
+ /// <value>
+ /// The string name of the identity of the current thread principal.
+ /// </value>
+ /// <remarks>
+ /// <para>
+ /// Calls <c>System.Threading.Thread.CurrentPrincipal.Identity.Name</c> to get
+ /// the name of the current thread principal.
+ /// </para>
+ /// </remarks>
+ public string Identity
+ {
+ get
+ {
+ if (m_data.Identity == null && this.m_cacheUpdatable)
+ {
+#if (NETCF || SSCLI || NETSTANDARD1_3)
+ // On compact framework there's no notion of current thread principals
+ m_data.Identity = SystemInfo.NotAvailableText;
+#else
+ try
+ {
+ if (System.Threading.Thread.CurrentPrincipal != null &&
+ System.Threading.Thread.CurrentPrincipal.Identity != null &&
+ System.Threading.Thread.CurrentPrincipal.Identity.Name != null)
+ {
+ m_data.Identity = System.Threading.Thread.CurrentPrincipal.Identity.Name;
+ }
+ else
+ {
+ m_data.Identity = "";
+ }
+ }
+ catch (ObjectDisposedException)
+ {
+ // This exception will occur if System.Threading.Thread.CurrentPrincipal.Identity is not null but
+ // the getter of the property Name tries to access disposed objects.
+ // Seen to happen on IIS 7 or greater with windows authentication.
+ LogLog.Debug(declaringType,
+ "Object disposed exception while trying to get current thread principal. Error Ignored. Empty identity name.");
+
+ m_data.Identity = "";
+ }
+ catch (System.Security.SecurityException)
+ {
+ // This security exception will occur if the caller does not have
+ // some undefined set of SecurityPermission flags.
+ LogLog.Debug(declaringType,
+ "Security exception while trying to get current thread principal. Error Ignored. Empty identity name.");
+
+ m_data.Identity = "";
+ }
+#endif
+ }
+
+ return m_data.Identity;
+ }
+ }
+
+ /// <summary>
+ /// Gets the AppDomain friendly name.
+ /// </summary>
+ /// <value>
+ /// The AppDomain friendly name.
+ /// </value>
+ /// <remarks>
+ /// <para>
+ /// Gets the AppDomain friendly name.
+ /// </para>
+ /// </remarks>
+ public string Domain
+ {
+ get
+ {
+ if (m_data.Domain == null && this.m_cacheUpdatable)
+ {
+ m_data.Domain = SystemInfo.ApplicationFriendlyName;
+ }
+
+ return m_data.Domain;
+ }
+ }
+
+ /// <summary>
+ /// Additional event specific properties.
+ /// </summary>
+ /// <value>
+ /// Additional event specific properties.
+ /// </value>
+ /// <remarks>
+ /// <para>
+ /// A logger or an appender may attach additional
+ /// properties to specific events. These properties
+ /// have a string key and an object value.
+ /// </para>
+ /// <para>
+ /// This property is for events that have been added directly to
+ /// this event. The aggregate properties (which include these
+ /// event properties) can be retrieved using <see cref="LookupProperty"/>
+ /// and <see cref="GetProperties"/>.
+ /// </para>
+ /// <para>
+ /// Once the properties have been fixed <see cref="Fix"/> this property
+ /// returns the combined cached properties. This ensures that updates to
+ /// this property are always reflected in the underlying storage. When
+ /// returning the combined properties there may be more keys in the
+ /// Dictionary than expected.
+ /// </para>
+ /// </remarks>
+ public PropertiesDictionary Properties
+ {
+ get
+ {
+ // If we have cached properties then return that otherwise changes will be lost
+ if (m_data.Properties != null)
+ {
+ return m_data.Properties;
+ }
+
+ if (m_eventProperties == null)
+ {
+ m_eventProperties = new PropertiesDictionary();
+ }
+
+ return m_eventProperties;
+ }
+ }
+
+ /// <summary>
+ /// The fixed fields in this event
+ /// </summary>
+ /// <value>
+ /// The set of fields that are fixed in this event
+ /// </value>
+ /// <remarks>
+ /// <para>
+ /// Fields will not be fixed if they have previously been fixed.
+ /// It is not possible to 'unfix' a field.
+ /// </para>
+ /// </remarks>
+ public FixFlags Fix
+ {
+ get { return m_fixFlags; }
+ set { this.FixVolatileData(value); }
+ }
+
+ #endregion Public Instance Properties
+
+ #region Implementation of ISerializable
+
+#if !NETCF
+
+ /// <summary>
+ /// Serializes this object into the <see cref="SerializationInfo" /> provided.
+ /// </summary>
+ /// <param name="info">The <see cref="SerializationInfo" /> to populate with data.</param>
+ /// <param name="context">The destination for this serialization.</param>
+ /// <remarks>
+ /// <para>
+ /// The data in this event must be fixed before it can be serialized.
+ /// </para>
+ /// <para>
+ /// The <see cref="M:FixVolatileData()"/> method must be called during the
+ /// <see cref="log4net.Appender.IAppender.DoAppend"/> method call if this event
+ /// is to be used outside that method.
+ /// </para>
+ /// </remarks>
+#if NET_4_0 || MONO_4_0 || NETSTANDARD
+ [System.Security.SecurityCritical]
+#endif
+#if !NETCF && !NETSTANDARD1_3
+ [System.Security.Permissions.SecurityPermission(System.Security.Permissions.SecurityAction.Demand,
+ SerializationFormatter = true)]
+#endif
+ public virtual void GetObjectData(SerializationInfo info, StreamingContext context)
+ {
+ // The caller must call FixVolatileData before this object
+ // can be serialized.
+
+ info.AddValue("LoggerName", m_data.LoggerName);
+ 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);
+#pragma warning disable 618
+ info.AddValue("TimeStamp", m_data.TimeStamp);
+#pragma warning restore 618
+ info.AddValue("LocationInfo", m_data.LocationInfo);
+ info.AddValue("UserName", m_data.UserName);
+ info.AddValue("ExceptionString", m_data.ExceptionString);
+ info.AddValue("Properties", m_data.Properties);
+ info.AddValue("Domain", m_data.Domain);
+ info.AddValue("Identity", m_data.Identity);
+ }
+
+#endif
+
+ #endregion Implementation of ISerializable
+
+ #region Public Instance Methods
+
+ /// <summary>
+ /// Gets the portable data for this <see cref="LoggingEvent" />.
+ /// </summary>
+ /// <returns>The <see cref="LoggingEventData"/> for this event.</returns>
+ /// <remarks>
+ /// <para>
+ /// A new <see cref="LoggingEvent"/> can be constructed using a
+ /// <see cref="LoggingEventData"/> instance.
+ /// </para>
+ /// <para>
+ /// Does a <see cref="FixFlags.Partial"/> fix of the data
+ /// in the logging event before returning the event data.
+ /// </para>
+ /// </remarks>
+ public LoggingEventData GetLoggingEventData()
+ {
+ return GetLoggingEventData(FixFlags.Partial);
+ }
+
+ /// <summary>
+ /// Gets the portable data for this <see cref="LoggingEvent" />.
+ /// </summary>
+ /// <param name="fixFlags">The set of data to ensure is fixed in the LoggingEventData</param>
+ /// <returns>The <see cref="LoggingEventData"/> for this event.</returns>
+ /// <remarks>
+ /// <para>
+ /// A new <see cref="LoggingEvent"/> can be constructed using a
+ /// <see cref="LoggingEventData"/> instance.
+ /// </para>
+ /// </remarks>
+ public LoggingEventData GetLoggingEventData(FixFlags fixFlags)
+ {
+ Fix = fixFlags;
+ return m_data;
+ }
+
+ /// <summary>
+ /// Returns this event's exception's rendered using the
+ /// <see cref="ILoggerRepository.RendererMap" />.
+ /// </summary>
+ /// <returns>
+ /// This event's exception's rendered using the <see cref="ILoggerRepository.RendererMap" />.
+ /// </returns>
+ /// <remarks>
+ /// <para>
+ /// <b>Obsolete. Use <see cref="GetExceptionString"/> instead.</b>
+ /// </para>
+ /// </remarks>
+ [Obsolete("Use GetExceptionString instead")]
+ public string GetExceptionStrRep()
+ {
+ return GetExceptionString();
+ }
+
+ /// <summary>
+ /// Returns this event's exception's rendered using the
+ /// <see cref="ILoggerRepository.RendererMap" />.
+ /// </summary>
+ /// <returns>
+ /// This event's exception's rendered using the <see cref="ILoggerRepository.RendererMap" />.
+ /// </returns>
+ /// <remarks>
+ /// <para>
+ /// Returns this event's exception's rendered using the
+ /// <see cref="ILoggerRepository.RendererMap" />.
+ /// </para>
+ /// </remarks>
+ public string GetExceptionString()
+ {
+ if (m_data.ExceptionString == null && this.m_cacheUpdatable)
+ {
+ if (m_thrownException != null)
+ {
+ if (m_repository != null)
+ {
+ // Render exception using the repositories renderer map
+ m_data.ExceptionString = m_repository.RendererMap.FindAndRender(m_thrownException);
+ }
+ else
+ {
+ // Very last resort
+ m_data.ExceptionString = m_thrownException.ToString();
+ }
+ }
+ else
+ {
+ m_data.ExceptionString = "";
+ }
+ }
+
+ return m_data.ExceptionString;
+ }
+
+ /// <summary>
+ /// Fix instance fields that hold volatile data.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Some of the values in instances of <see cref="LoggingEvent"/>
+ /// are considered volatile, that is the values are correct at the
+ /// time the event is delivered to appenders, but will not be consistent
+ /// at any time afterwards. If an event is to be stored and then processed
+ /// at a later time these volatile values must be fixed by calling
+ /// <see cref="M:FixVolatileData()"/>. There is a performance penalty
+ /// incurred by calling <see cref="M:FixVolatileData()"/> but it
+ /// is essential to maintaining data consistency.
+ /// </para>
+ /// <para>
+ /// Calling <see cref="M:FixVolatileData()"/> is equivalent to
+ /// calling <see cref="M:FixVolatileData(bool)"/> passing the parameter
+ /// <c>false</c>.
+ /// </para>
+ /// <para>
+ /// See <see cref="M:FixVolatileData(bool)"/> for more
+ /// information.
+ /// </para>
+ /// </remarks>
+ [Obsolete("Use Fix property")]
+ public void FixVolatileData()
+ {
+ Fix = FixFlags.All;
+ }
+
+ /// <summary>
+ /// Fixes instance fields that hold volatile data.
+ /// </summary>
+ /// <param name="fastButLoose">Set to <c>true</c> to not fix data that takes a long time to fix.</param>
+ /// <remarks>
+ /// <para>
/// Some of the values in instances of <see cref="LoggingEvent"/>
/// are considered volatile, that is the values are correct at the
/// time the event is delivered to appenders, but will not be consistent
@@ -221,1384 +1222,383 @@
/// for incurred by calling <see cref="M:FixVolatileData()"/> but it
/// is essential to maintaining data consistency.
/// </para>
+ /// <para>
+ /// The <paramref name="fastButLoose"/> param controls the data that
+ /// is fixed. Some of the data that can be fixed takes a long time to
+ /// generate, therefore if you do not require those settings to be fixed
+ /// they can be ignored by setting the <paramref name="fastButLoose"/> param
+ /// to <c>true</c>. This setting will ignore the <see cref="LocationInformation"/>
+ /// and <see cref="UserName"/> settings.
+ /// </para>
+ /// <para>
+ /// Set <paramref name="fastButLoose"/> to <c>false</c> to ensure that all
+ /// settings are fixed.
+ /// </para>
/// </remarks>
- /// <author>Nicko Cadell</author>
- /// <author>Gert Driesen</author>
- /// <author>Douglas de la Torre</author>
- /// <author>Daniel Cazzulino</author>
-#if !NETCF
- [Serializable]
-#endif
- public class LoggingEvent
-#if !NETCF
- : ISerializable
-#endif
+ [Obsolete("Use Fix property")]
+ public void FixVolatileData(bool fastButLoose)
{
- private static readonly Type declaringType = typeof(LoggingEvent);
-
- #region Public Instance Constructors
-
- /// <summary>
- /// Initializes a new instance of the <see cref="LoggingEvent" /> class
- /// from the supplied parameters.
- /// </summary>
- /// <param name="callerStackBoundaryDeclaringType">The declaring type of the method that is
- /// the stack boundary into the logging system for this call.</param>
- /// <param name="repository">The repository this event is logged in.</param>
- /// <param name="loggerName">The name of the logger of this event.</param>
- /// <param name="level">The level of this event.</param>
- /// <param name="message">The message of this event.</param>
- /// <param name="exception">The exception for this event.</param>
- /// <remarks>
- /// <para>
- /// Except <see cref="TimeStamp"/>, <see cref="Level"/> and <see cref="LoggerName"/>,
- /// all fields of <c>LoggingEvent</c> are filled when actually needed. Call
- /// <see cref="M:FixVolatileData()"/> to cache all data locally
- /// to prevent inconsistencies.
- /// </para>
- /// <para>This method is called by the log4net framework
- /// to create a logging event.
- /// </para>
- /// </remarks>
- public LoggingEvent(Type callerStackBoundaryDeclaringType,
- log4net.Repository.ILoggerRepository repository,
- string loggerName,
- Level level,
- object message,
- Exception exception)
- {
- m_callerStackBoundaryDeclaringType = callerStackBoundaryDeclaringType;
- m_message = message;
- m_repository = repository;
- m_thrownException = exception;
-
- m_data.LoggerName = loggerName;
- m_data.Level = level;
-
- // Store the event creation time
- m_data.TimeStampUtc = DateTime.UtcNow;
- }
-
- /// <summary>
- /// Initializes a new instance of the <see cref="LoggingEvent" /> class
- /// using specific data.
- /// </summary>
- /// <param name="callerStackBoundaryDeclaringType">The declaring type of the method that is
- /// the stack boundary into the logging system for this call.</param>
- /// <param name="repository">The repository this event is logged in.</param>
- /// <param name="data">Data used to initialize the logging event.</param>
- /// <param name="fixedData">The fields in the <paranref name="data"/> struct that have already been fixed.</param>
- /// <remarks>
- /// <para>
- /// This constructor is provided to allow a <see cref="LoggingEvent" />
- /// to be created independently of the log4net framework. This can
- /// be useful if you require a custom serialization scheme.
- /// </para>
- /// <para>
- /// Use the <see cref="M:GetLoggingEventData(FixFlags)"/> method to obtain an
- /// instance of the <see cref="LoggingEventData"/> class.
- /// </para>
- /// <para>
- /// The <paramref name="fixedData"/> parameter should be used to specify which fields in the
- /// <paramref name="data"/> struct have been preset. Fields not specified in the <paramref name="fixedData"/>
- /// will be captured from the environment if requested or fixed.
- /// </para>
- /// </remarks>
- public LoggingEvent(Type callerStackBoundaryDeclaringType,
- log4net.Repository.ILoggerRepository repository,
- LoggingEventData data,
- FixFlags fixedData)
- {
- m_callerStackBoundaryDeclaringType = callerStackBoundaryDeclaringType;
- m_repository = repository;
-
- m_data = data;
- m_fixFlags = fixedData;
- }
-
- /// <summary>
- /// Initializes a new instance of the <see cref="LoggingEvent" /> class
- /// using specific data.
- /// </summary>
- /// <param name="callerStackBoundaryDeclaringType">The declaring type of the method that is
- /// the stack boundary into the logging system for this call.</param>
- /// <param name="repository">The repository this event is logged in.</param>
- /// <param name="data">Data used to initialize the logging event.</param>
- /// <remarks>
- /// <para>
- /// This constructor is provided to allow a <see cref="LoggingEvent" />
- /// to be created independently of the log4net framework. This can
- /// be useful if you require a custom serialization scheme.
- /// </para>
- /// <para>
- /// Use the <see cref="M:GetLoggingEventData(FixFlags)"/> method to obtain an
- /// instance of the <see cref="LoggingEventData"/> class.
- /// </para>
- /// <para>
- /// This constructor sets this objects <see cref="Fix"/> flags to <see cref="FixFlags.All"/>,
- /// this assumes that all the data relating to this event is passed in via the <paramref name="data"/>
- /// parameter and no other data should be captured from the environment.
- /// </para>
- /// </remarks>
- public LoggingEvent(Type callerStackBoundaryDeclaringType,
- log4net.Repository.ILoggerRepository repository,
- LoggingEventData data) : this(callerStackBoundaryDeclaringType, repository, data, FixFlags.All)
- {
- }
-
- /// <summary>
- /// Initializes a new instance of the <see cref="LoggingEvent" /> class
- /// using specific data.
- /// </summary>
- /// <param name="data">Data used to initialize the logging event.</param>
- /// <remarks>
- /// <para>
- /// This constructor is provided to allow a <see cref="LoggingEvent" />
- /// to be created independently of the log4net framework. This can
- /// be useful if you require a custom serialization scheme.
- /// </para>
- /// <para>
- /// Use the <see cref="M:GetLoggingEventData(FixFlags)"/> method to obtain an
- /// instance of the <see cref="LoggingEventData"/> class.
- /// </para>
- /// <para>
- /// This constructor sets this objects <see cref="Fix"/> flags to <see cref="FixFlags.All"/>,
- /// this assumes that all the data relating to this event is passed in via the <paramref name="data"/>
- /// parameter and no other data should be captured from the environment.
- /// </para>
- /// </remarks>
- public LoggingEvent(LoggingEventData data) : this(null, null, data)
- {
- }
-
- #endregion Public Instance Constructors
-
- #region Protected Instance Constructors
-
-#if !NETCF
-
- /// <summary>
- /// Serialization constructor
- /// </summary>
- /// <param name="info">The <see cref="SerializationInfo" /> that holds the serialized object data.</param>
- /// <param name="context">The <see cref="StreamingContext" /> that contains contextual information about the source or destination.</param>
- /// <remarks>
- /// <para>
- /// Initializes a new instance of the <see cref="LoggingEvent" /> class
- /// with serialized data.
- /// </para>
- /// </remarks>
- protected LoggingEvent(SerializationInfo info, StreamingContext context)
- {
- m_data.LoggerName = info.GetString("LoggerName");
-
- // Note we are deserializing the whole level object. That is the
- // name and the value. This value is correct for the source
- // hierarchy but may not be for the target hierarchy that this
- // event may be re-logged into. If it is to be re-logged it may
- // be necessary to re-lookup the level based only on the name.
- m_data.Level = (Level)info.GetValue("Level", typeof(Level));
-
- m_data.Message = info.GetString("Message");
- m_data.ThreadName = info.GetString("ThreadName");
- m_data.TimeStampUtc = info.GetDateTime("TimeStamp").ToUniversalTime();
- m_data.LocationInfo = (LocationInfo)info.GetValue("LocationInfo", typeof(LocationInfo));
- m_data.UserName = info.GetString("UserName");
- m_data.ExceptionString = info.GetString("ExceptionString");
- m_data.Properties = (PropertiesDictionary)info.GetValue("Properties", typeof(PropertiesDictionary));
- m_data.Domain = info.GetString("Domain");
- m_data.Identity = info.GetString("Identity");
-
- // We have restored all the values of this instance, i.e. all the values are fixed
- // Set the fix flags otherwise the data values may be overwritten from the current environment.
- m_fixFlags = FixFlags.All;
- }
-
-#endif
-
- #endregion Protected Instance Constructors
-
- #region Public Instance Properties
-
- /// <summary>
- /// Gets the time when the current process started.
- /// </summary>
- /// <value>
- /// This is the time when this process started.
- /// </value>
- /// <remarks>
- /// <para>
- /// The TimeStamp is stored internally in UTC and converted to the local time zone for this computer.
- /// </para>
- /// <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 StartTime
- {
- 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 <see cref="Level" /> of the logging event.
- /// </summary>
- /// <value>
- /// The <see cref="Level" /> of the logging event.
- /// </value>
- /// <remarks>
- /// <para>
- /// Gets the <see cref="Level" /> of the logging event.
- /// </para>
- /// </remarks>
- public Level Level
- {
- get { return m_data.Level; }
- }
-
- /// <summary>
- /// Gets the time of the logging event.
- /// </summary>
- /// <value>
- /// The time of the logging event.
- /// </value>
- /// <remarks>
- /// <para>
- /// The TimeStamp is stored in UTC and converted to the local time zone for this computer.
- /// </para>
- /// </remarks>
- public DateTime TimeStamp
- {
- 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 the name of the logger that logged the event.
- /// </summary>
- /// <value>
- /// The name of the logger that logged the event.
- /// </value>
- /// <remarks>
- /// <para>
- /// Gets the name of the logger that logged the event.
- /// </para>
- /// </remarks>
- public string LoggerName
- {
- get { return m_data.LoggerName; }
- }
-
- /// <summary>
- /// Gets the location information for this logging event.
- /// </summary>
- /// <value>
- /// The location information for this logging event.
- /// </value>
- /// <remarks>
- /// <para>
- /// The collected information is cached for future use.
- /// </para>
- /// <para>
- /// See the <see cref="LocationInfo"/> class for more information on
- /// supported frameworks and the different behavior in Debug and
- /// Release builds.
- /// </para>
- /// </remarks>
- public LocationInfo LocationInformation
- {
- get
- {
- if (m_data.LocationInfo == null && this.m_cacheUpdatable)
- {
- m_data.LocationInfo = new LocationInfo(m_callerStackBoundaryDeclaringType);
- }
-
- return m_data.LocationInfo;
- }
- }
-
- /// <summary>
- /// Gets the message object used to initialize this event.
- /// </summary>
- /// <value>
- /// The message object used to initialize this event.
- /// </value>
- /// <remarks>
- /// <para>
- /// Gets the message object used to initialize this event.
- /// Note that this event may not have a valid message object.
- /// If the event is serialized the message object will not
- /// be transferred. To get the text of the message the
- /// <see cref="RenderedMessage"/> property must be used
- /// not this property.
- /// </para>
- /// <para>
- /// If there is no defined message object for this event then
- /// null will be returned.
- /// </para>
- /// </remarks>
- public object MessageObject
- {
- get { return m_message; }
- protected set { m_message = value; }
- }
-
- /// <summary>
- /// Gets the exception object used to initialize this event.
- /// </summary>
- /// <value>
- /// The exception object used to initialize this event.
- /// </value>
- /// <remarks>
- /// <para>
- /// Gets the exception object used to initialize this event.
- /// Note that this event may not have a valid exception object.
- /// If the event is serialized the exception object will not
- /// be transferred. To get the text of the exception the
- /// <see cref="GetExceptionString"/> method must be used
- /// not this property.
- /// </para>
- /// <para>
- /// If there is no defined exception object for this event then
- /// null will be returned.
- /// </para>
- /// </remarks>
- public Exception ExceptionObject
- {
- get { return m_thrownException; }
- }
-
- /// <summary>
- /// The <see cref="ILoggerRepository"/> that this event was created in.
- /// </summary>
- /// <remarks>
- /// <para>
- /// The <see cref="ILoggerRepository"/> that this event was created in.
- /// </para>
- /// </remarks>
- public ILoggerRepository Repository
- {
- get { return m_repository; }
- }
-
- /// <summary>
- /// Ensure that the repository is set.
- /// </summary>
- /// <param name="repository">the value for the repository</param>
- internal void EnsureRepository(ILoggerRepository repository)
- {
- if (repository != null)
- {
- m_repository = repository;
- }
- }
-
- /// <summary>
- /// Gets the message, rendered through the <see cref="ILoggerRepository.RendererMap" />.
- /// </summary>
- /// <value>
- /// The message rendered through the <see cref="ILoggerRepository.RendererMap" />.
- /// </value>
- /// <remarks>
- /// <para>
- /// The collected information is cached for future use.
- /// </para>
- /// </remarks>
- public virtual string RenderedMessage
- {
- get
- {
- if (m_data.Message == null && this.m_cacheUpdatable)
- {
- if (m_message == null)
- {
- m_data.Message = "";
- }
- else if (m_message is string)
- {
- m_data.Message = (m_message as string);
- }
- else if (m_repository != null)
- {
- m_data.Message = m_repository.RendererMap.FindAndRender(m_message);
- }
- else
- {
- // Very last resort
- m_data.Message = m_message.ToString();
- }
- }
-
- return m_data.Message;
- }
- }
-
- /// <summary>
- /// Write the rendered message to a TextWriter
- /// </summary>
- /// <param name="writer">the writer to write the message to</param>
- /// <remarks>
- /// <para>
- /// Unlike the <see cref="RenderedMessage"/> property this method
- /// does store the message data in the internal cache. Therefore
- /// if called only once this method should be faster than the
- /// <see cref="RenderedMessage"/> property, however if the message is
- /// to be accessed multiple times then the property will be more efficient.
- /// </para>
- /// </remarks>
- public virtual void WriteRenderedMessage(TextWriter writer)
- {
- if (m_data.Message != null)
- {
- writer.Write(m_data.Message);
- }
- else
- {
- if (m_message != null)
- {
- if (m_message is string)
- {
- writer.Write(m_message as string);
- }
- else if (m_repository != null)
- {
- m_repository.RendererMap.FindAndRender(m_message, writer);
- }
- else
- {
- // Very last resort
- writer.Write(m_message.ToString());
- }
- }
- }
- }
-
- /// <summary>
- /// Gets the name of the current thread.
- /// </summary>
- /// <value>
- /// The name of the current thread, or the thread ID when
- /// the name is not available.
- /// </value>
- /// <remarks>
- /// <para>
- /// The collected information is cached for future use.
- /// </para>
- /// </remarks>
- public string ThreadName
- {
- get
- {
- if (m_data.ThreadName == null && this.m_cacheUpdatable)
- {
-#if NETCF
- // Get thread ID only
- m_data.ThreadName =
- SystemInfo.CurrentThreadId.ToString(System.Globalization.NumberFormatInfo.InvariantInfo);
-#else
- // '.NET ThreadPool Worker' appears as a default thread name in the .NET 6-7 thread pool.
- // '.NET TP Worker' is the default thread name in the .NET 8+ thread pool.
- // Prefer the numeric thread ID instead.
- string threadName = System.Threading.Thread.CurrentThread.Name;
- if (!string.IsNullOrEmpty(threadName) && threadName != ".NET TP Worker" && threadName != ".NET ThreadPool Worker")
- {
- m_data.ThreadName = threadName;
- }
- else
- {
- // The thread name is not available or unsuitable. Therefore we
- // go to the AppDomain to get the ID of the
- // current thread. (Why don't Threads know their own ID?)
- try
- {
- m_data.ThreadName =
- SystemInfo.CurrentThreadId.ToString(System.Globalization.NumberFormatInfo
- .InvariantInfo);
- }
- catch (SecurityException)
- {
- // This security exception will occur if the caller does not have
- // some undefined set of SecurityPermission flags.
- LogLog.Debug(declaringType,
- "Security exception while trying to get current thread ID. Error Ignored. Empty thread name.");
-
- // As a last resort use the hash code of the Thread object
- m_data.ThreadName = System.Threading.Thread.CurrentThread.GetHashCode()
- .ToString(System.Globalization.CultureInfo.InvariantCulture);
- }
- }
-#endif
- }
-
- return m_data.ThreadName;
- }
- }
-
- /// <summary>
- /// Gets the name of the current user.
- /// </summary>
- /// <value>
- /// The name of the current user, or <c>NOT AVAILABLE</c> when the
- /// underlying runtime has no support for retrieving the name of the
- /// current user.
- /// </value>
- /// <remarks>
- /// <para>
- /// Calls <c>WindowsIdentity.GetCurrent().Name</c> to get the name of
- /// the current windows user.
- /// </para>
- /// <para>
- /// To improve performance, we could cache the string representation of
- /// the name, and reuse that as long as the identity stayed constant.
- /// Once the identity changed, we would need to re-assign and re-render
- /// the string.
- /// </para>
- /// <para>
- /// However, the <c>WindowsIdentity.GetCurrent()</c> call seems to
- /// return different objects every time, so the current implementation
- /// doesn't do this type of caching.
- /// </para>
- /// <para>
- /// Timing for these operations:
- /// </para>
- /// <list type="table">
- /// <listheader>
- /// <term>Method</term>
- /// <description>Results</description>
- /// </listheader>
- /// <item>
- /// <term><c>WindowsIdentity.GetCurrent()</c></term>
- /// <description>10000 loops, 00:00:00.2031250 seconds</description>
- /// </item>
- /// <item>
- /// <term><c>WindowsIdentity.GetCurrent().Name</c></term>
- /// <description>10000 loops, 00:00:08.0468750 seconds</description>
- /// </item>
- /// </list>
- /// <para>
- /// This means we could speed things up almost 40 times by caching the
- /// value of the <c>WindowsIdentity.GetCurrent().Name</c> property, since
- /// this takes (8.04-0.20) = 7.84375 seconds.
- /// </para>
- /// </remarks>
- public string UserName =>
- m_data.UserName ??= TryGetCurrentUserName() ?? SystemInfo.NotAvailableText;
-
- private string TryGetCurrentUserName()
- {
-#if (NETCF || SSCLI || NETSTANDARD1_3)
- // On compact framework there's no notion of current Windows user
- return SystemInfo.NotAvailableText;
-#else
- if (_platformDoesNotSupportWindowsIdentity)
- {
- // we've already received one PlatformNotSupportedException
- // and it's highly unlikely that will change
- return Environment.UserName;
- }
-
- try
- {
- return _cachedWindowsIdentityUserName ??=
- TryReadWindowsIdentityUserName();
- }
- catch (PlatformNotSupportedException)
- {
- _platformDoesNotSupportWindowsIdentity = true;
- return Environment.UserName;
- }
- catch (SecurityException)
- {
- // This security exception will occur if the caller does not have
- // some undefined set of SecurityPermission flags.
- LogLog.Debug(
- declaringType,
- "Security exception while trying to get current windows identity. Error Ignored."
- );
- return Environment.UserName;
- }
- catch
- {
- return null;
- }
-#endif
- }
-
-#if (NETCF || SSCLI || NETSTANDARD1_3)
-#else
- private string _cachedWindowsIdentityUserName;
- private static string TryReadWindowsIdentityUserName()
- {
- using var identity = WindowsIdentity.GetCurrent();
- return identity?.Name ?? "";
- }
-#endif
-
-#if (NETCF || SSCLI || NETSTANDARD1_3)
-#else
- private static bool _platformDoesNotSupportWindowsIdentity;
-#endif
-
- /// <summary>
- /// Gets the identity of the current thread principal.
- /// </summary>
- /// <value>
- /// The string name of the identity of the current thread principal.
- /// </value>
- /// <remarks>
- /// <para>
- /// Calls <c>System.Threading.Thread.CurrentPrincipal.Identity.Name</c> to get
- /// the name of the current thread principal.
- /// </para>
- /// </remarks>
- public string Identity
- {
- get
- {
- if (m_data.Identity == null && this.m_cacheUpdatable)
- {
-#if (NETCF || SSCLI || NETSTANDARD1_3)
- // On compact framework there's no notion of current thread principals
- m_data.Identity = SystemInfo.NotAvailableText;
-#else
- try
- {
- if (System.Threading.Thread.CurrentPrincipal != null &&
- System.Threading.Thread.CurrentPrincipal.Identity != null &&
- System.Threading.Thread.CurrentPrincipal.Identity.Name != null)
- {
- m_data.Identity = System.Threading.Thread.CurrentPrincipal.Identity.Name;
- }
- else
- {
- m_data.Identity = "";
- }
- }
- catch (ObjectDisposedException)
- {
- // This exception will occur if System.Threading.Thread.CurrentPrincipal.Identity is not null but
- // the getter of the property Name tries to access disposed objects.
- // Seen to happen on IIS 7 or greater with windows authentication.
- LogLog.Debug(declaringType,
- "Object disposed exception while trying to get current thread principal. Error Ignored. Empty identity name.");
-
- m_data.Identity = "";
- }
- catch (System.Security.SecurityException)
- {
- // This security exception will occur if the caller does not have
- // some undefined set of SecurityPermission flags.
- LogLog.Debug(declaringType,
- "Security exception while trying to get current thread principal. Error Ignored. Empty identity name.");
-
- m_data.Identity = "";
- }
-#endif
- }
-
- return m_data.Identity;
- }
- }
-
- /// <summary>
- /// Gets the AppDomain friendly name.
- /// </summary>
- /// <value>
- /// The AppDomain friendly name.
- /// </value>
- /// <remarks>
- /// <para>
- /// Gets the AppDomain friendly name.
- /// </para>
- /// </remarks>
- public string Domain
- {
- get
- {
- if (m_data.Domain == null && this.m_cacheUpdatable)
- {
- m_data.Domain = SystemInfo.ApplicationFriendlyName;
- }
-
- return m_data.Domain;
- }
- }
-
- /// <summary>
- /// Additional event specific properties.
- /// </summary>
- /// <value>
- /// Additional event specific properties.
- /// </value>
- /// <remarks>
- /// <para>
- /// A logger or an appender may attach additional
- /// properties to specific events. These properties
- /// have a string key and an object value.
- /// </para>
- /// <para>
- /// This property is for events that have been added directly to
- /// this event. The aggregate properties (which include these
- /// event properties) can be retrieved using <see cref="LookupProperty"/>
- /// and <see cref="GetProperties"/>.
- /// </para>
- /// <para>
- /// Once the properties have been fixed <see cref="Fix"/> this property
- /// returns the combined cached properties. This ensures that updates to
- /// this property are always reflected in the underlying storage. When
- /// returning the combined properties there may be more keys in the
- /// Dictionary than expected.
- /// </para>
- /// </remarks>
- public PropertiesDictionary Properties
- {
- get
- {
- // If we have cached properties then return that otherwise changes will be lost
- if (m_data.Properties != null)
- {
- return m_data.Properties;
- }
-
- if (m_eventProperties == null)
- {
- m_eventProperties = new PropertiesDictionary();
- }
-
- return m_eventProperties;
- }
- }
-
- /// <summary>
- /// The fixed fields in this event
- /// </summary>
- /// <value>
- /// The set of fields that are fixed in this event
- /// </value>
- /// <remarks>
- /// <para>
- /// Fields will not be fixed if they have previously been fixed.
- /// It is not possible to 'unfix' a field.
- /// </para>
- /// </remarks>
- public FixFlags Fix
- {
- get { return m_fixFlags; }
- set { this.FixVolatileData(value); }
- }
-
- #endregion Public Instance Properties
-
- #region Implementation of ISerializable
-
-#if !NETCF
-
- /// <summary>
- /// Serializes this object into the <see cref="SerializationInfo" /> provided.
- /// </summary>
- /// <param name="info">The <see cref="SerializationInfo" /> to populate with data.</param>
- /// <param name="context">The destination for this serialization.</param>
- /// <remarks>
- /// <para>
- /// The data in this event must be fixed before it can be serialized.
- /// </para>
- /// <para>
- /// The <see cref="M:FixVolatileData()"/> method must be called during the
- /// <see cref="log4net.Appender.IAppender.DoAppend"/> method call if this event
- /// is to be used outside that method.
- /// </para>
- /// </remarks>
-#if NET_4_0 || MONO_4_0 || NETSTANDARD
- [System.Security.SecurityCritical]
-#endif
-#if !NETCF && !NETSTANDARD1_3
- [System.Security.Permissions.SecurityPermission(System.Security.Permissions.SecurityAction.Demand,
- SerializationFormatter = true)]
-#endif
- public virtual void GetObjectData(SerializationInfo info, StreamingContext context)
- {
- // The caller must call FixVolatileData before this object
- // can be serialized.
-
- info.AddValue("LoggerName", m_data.LoggerName);
- 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);
-#pragma warning disable 618
- info.AddValue("TimeStamp", m_data.TimeStamp);
-#pragma warning restore 618
- info.AddValue("LocationInfo", m_data.LocationInfo);
- info.AddValue("UserName", m_data.UserName);
- info.AddValue("ExceptionString", m_data.ExceptionString);
- info.AddValue("Properties", m_data.Properties);
- info.AddValue("Domain", m_data.Domain);
- info.AddValue("Identity", m_data.Identity);
- }
-
-#endif
-
- #endregion Implementation of ISerializable
-
- #region Public Instance Methods
-
- /// <summary>
- /// Gets the portable data for this <see cref="LoggingEvent" />.
- /// </summary>
- /// <returns>The <see cref="LoggingEventData"/> for this event.</returns>
- /// <remarks>
- /// <para>
- /// A new <see cref="LoggingEvent"/> can be constructed using a
- /// <see cref="LoggingEventData"/> instance.
- /// </para>
- /// <para>
- /// Does a <see cref="FixFlags.Partial"/> fix of the data
- /// in the logging event before returning the event data.
- /// </para>
- /// </remarks>
- public LoggingEventData GetLoggingEventData()
- {
- return GetLoggingEventData(FixFlags.Partial);
- }
-
- /// <summary>
- /// Gets the portable data for this <see cref="LoggingEvent" />.
- /// </summary>
- /// <param name="fixFlags">The set of data to ensure is fixed in the LoggingEventData</param>
- /// <returns>The <see cref="LoggingEventData"/> for this event.</returns>
- /// <remarks>
- /// <para>
- /// A new <see cref="LoggingEvent"/> can be constructed using a
- /// <see cref="LoggingEventData"/> instance.
- /// </para>
- /// </remarks>
- public LoggingEventData GetLoggingEventData(FixFlags fixFlags)
- {
- Fix = fixFlags;
- return m_data;
- }
-
- /// <summary>
- /// Returns this event's exception's rendered using the
- /// <see cref="ILoggerRepository.RendererMap" />.
- /// </summary>
- /// <returns>
- /// This event's exception's rendered using the <see cref="ILoggerRepository.RendererMap" />.
- /// </returns>
- /// <remarks>
- /// <para>
- /// <b>Obsolete. Use <see cref="GetExceptionString"/> instead.</b>
- /// </para>
- /// </remarks>
- [Obsolete("Use GetExceptionString instead")]
- public string GetExceptionStrRep()
- {
- return GetExceptionString();
- }
-
- /// <summary>
- /// Returns this event's exception's rendered using the
- /// <see cref="ILoggerRepository.RendererMap" />.
- /// </summary>
- /// <returns>
- /// This event's exception's rendered using the <see cref="ILoggerRepository.RendererMap" />.
- /// </returns>
- /// <remarks>
- /// <para>
- /// Returns this event's exception's rendered using the
- /// <see cref="ILoggerRepository.RendererMap" />.
- /// </para>
- /// </remarks>
- public string GetExceptionString()
- {
- if (m_data.ExceptionString == null && this.m_cacheUpdatable)
- {
- if (m_thrownException != null)
- {
- if (m_repository != null)
- {
- // Render exception using the repositories renderer map
- m_data.ExceptionString = m_repository.RendererMap.FindAndRender(m_thrownException);
- }
- else
- {
- // Very last resort
- m_data.ExceptionString = m_thrownException.ToString();
- }
- }
- else
- {
- m_data.ExceptionString = "";
- }
- }
-
- return m_data.ExceptionString;
- }
-
- /// <summary>
- /// Fix instance fields that hold volatile data.
- /// </summary>
- /// <remarks>
- /// <para>
- /// Some of the values in instances of <see cref="LoggingEvent"/>
- /// are considered volatile, that is the values are correct at the
- /// time the event is delivered to appenders, but will not be consistent
- /// at any time afterwards. If an event is to be stored and then processed
- /// at a later time these volatile values must be fixed by calling
- /// <see cref="M:FixVolatileData()"/>. There is a performance penalty
- /// incurred by calling <see cref="M:FixVolatileData()"/> but it
- /// is essential to maintaining data consistency.
- /// </para>
- /// <para>
- /// Calling <see cref="M:FixVolatileData()"/> is equivalent to
- /// calling <see cref="M:FixVolatileData(bool)"/> passing the parameter
- /// <c>false</c>.
- /// </para>
- /// <para>
- /// See <see cref="M:FixVolatileData(bool)"/> for more
- /// information.
- /// </para>
- /// </remarks>
- [Obsolete("Use Fix property")]
- public void FixVolatileData()
- {
- Fix = FixFlags.All;
- }
-
- /// <summary>
- /// Fixes instance fields that hold volatile data.
- /// </summary>
- /// <param name="fastButLoose">Set to <c>true</c> to not fix data that takes a long time to fix.</param>
- /// <remarks>
- /// <para>
- /// Some of the values in instances of <see cref="LoggingEvent"/>
- /// are considered volatile, that is the values are correct at the
- /// time the event is delivered to appenders, but will not be consistent
- /// at any time afterwards. If an event is to be stored and then processed
- /// at a later time these volatile values must be fixed by calling
- /// <see cref="M:FixVolatileData()"/>. There is a performance penalty
- /// for incurred by calling <see cref="M:FixVolatileData()"/> but it
- /// is essential to maintaining data consistency.
- /// </para>
- /// <para>
- /// The <paramref name="fastButLoose"/> param controls the data that
- /// is fixed. Some of the data that can be fixed takes a long time to
- /// generate, therefore if you do not require those settings to be fixed
- /// they can be ignored by setting the <paramref name="fastButLoose"/> param
- /// to <c>true</c>. This setting will ignore the <see cref="LocationInformation"/>
- /// and <see cref="UserName"/> settings.
- /// </para>
- /// <para>
- /// Set <paramref name="fastButLoose"/> to <c>false</c> to ensure that all
- /// settings are fixed.
- /// </para>
- /// </remarks>
- [Obsolete("Use Fix property")]
- public void FixVolatileData(bool fastButLoose)
- {
- if (fastButLoose)
- {
- Fix = FixFlags.Partial;
- }
- else
- {
- Fix = FixFlags.All;
- }
- }
-
- /// <summary>
- /// Fix the fields specified by the <see cref="FixFlags"/> parameter
- /// </summary>
- /// <param name="flags">the fields to fix</param>
- /// <remarks>
- /// <para>
- /// Only fields specified in the <paramref name="flags"/> will be fixed.
- /// Fields will not be fixed if they have previously been fixed.
- /// It is not possible to 'unfix' a field.
- /// </para>
- /// </remarks>
- protected virtual void FixVolatileData(FixFlags flags)
- {
- object forceCreation = null;
-
- //Unlock the cache so that new values can be stored
- //This may not be ideal if we are no longer in the correct context
- //and someone calls fix.
- m_cacheUpdatable = true;
-
- // determine the flags that we are actually fixing
- var updateFlags = (FixFlags)((flags ^ m_fixFlags) & flags);
-
- if (updateFlags > 0)
- {
- if ((updateFlags & FixFlags.Message) != 0)
- {
- // Force the message to be rendered
- forceCreation = this.RenderedMessage;
-
- m_fixFlags |= FixFlags.Message;
- }
-
- if ((updateFlags & FixFlags.ThreadName) != 0)
- {
- // Grab the thread name
- forceCreation = this.ThreadName;
-
- m_fixFlags |= FixFlags.ThreadName;
- }
-
- if ((updateFlags & FixFlags.LocationInfo) != 0)
- {
- // Force the location information to be loaded
- forceCreation = this.LocationInformation;
-
- m_fixFlags |= FixFlags.LocationInfo;
- }
-
- if ((updateFlags & FixFlags.UserName) != 0)
- {
- // Grab the user name
- forceCreation = this.UserName;
-
- m_fixFlags |= FixFlags.UserName;
- }
-
- if ((updateFlags & FixFlags.Domain) != 0)
- {
- // Grab the domain name
- forceCreation = this.Domain;
-
- m_fixFlags |= FixFlags.Domain;
- }
-
- if ((updateFlags & FixFlags.Identity) != 0)
- {
- // Grab the identity
- forceCreation = this.Identity;
-
- m_fixFlags |= FixFlags.Identity;
- }
-
- if ((updateFlags & FixFlags.Exception) != 0)
- {
- // Force the exception text to be loaded
- forceCreation = GetExceptionString();
-
- m_fixFlags |= FixFlags.Exception;
- }
-
- if ((updateFlags & FixFlags.Properties) != 0)
- {
- CacheProperties();
-
- m_fixFlags |= FixFlags.Properties;
- }
- }
-
- // avoid warning CS0219
- if (forceCreation != null)
- {
- }
-
- //Finaly lock everything we've cached.
- m_cacheUpdatable = false;
- }
-
- #endregion Public Instance Methods
-
- #region Protected Instance Methods
-
- private void CreateCompositeProperties()
- {
- var compositeProperties = new CompositeProperties();
-
- if (m_eventProperties != null)
- {
- compositeProperties.Add(m_eventProperties);
- }
-#if !NETCF
- var logicalThreadProperties = LogicalThreadContext.Properties.GetProperties(false);
- if (logicalThreadProperties != null)
- {
- compositeProperties.Add(logicalThreadProperties);
- }
-#endif
- var threadProperties = ThreadContext.Properties.GetProperties(false);
- if (threadProperties != null)
- {
- compositeProperties.Add(threadProperties);
- }
-
- // TODO: Add Repository Properties
-
- // event properties
- var shouldFixUserName = (m_fixFlags & FixFlags.UserName) != 0;
- var shouldFixIdentity = (m_fixFlags & FixFlags.Identity) != 0;
- if (shouldFixIdentity || shouldFixUserName)
- {
- var eventProperties = new PropertiesDictionary();
- if (shouldFixUserName)
- {
- eventProperties[UserNameProperty] = UserName;
- }
-
- if (shouldFixIdentity)
- {
- eventProperties[IdentityProperty] = Identity;
- }
-
- compositeProperties.Add(eventProperties);
- }
-
- compositeProperties.Add(GlobalContext.Properties.GetReadOnlyProperties());
- m_compositeProperties = compositeProperties;
- }
-
- private void CacheProperties()
- {
- if (m_data.Properties == null && this.m_cacheUpdatable)
- {
- if (m_compositeProperties == null)
- {
- CreateCompositeProperties();
- }
-
- var flattenedProperties = m_compositeProperties.Flatten();
-
- var fixedProperties = new PropertiesDictionary();
-
- // Validate properties
- foreach (DictionaryEntry entry in flattenedProperties)
- {
- var key = entry.Key as string;
-
- if (key != null)
- {
- var val = entry.Value;
-
- // Fix any IFixingRequired objects
- var fixingRequired = val as IFixingRequired;
- if (fixingRequired != null)
- {
- val = fixingRequired.GetFixedObject();
- }
-
- // Strip keys with null values
- if (val != null)
- {
- fixedProperties[key] = val;
- }
- }
- }
-
- m_data.Properties = fixedProperties;
- }
- }
-
- /// <summary>
- /// Lookup a composite property in this event
- /// </summary>
- /// <param name="key">the key for the property to lookup</param>
- /// <returns>the value for the property</returns>
- /// <remarks>
- /// <para>
- /// This event has composite properties that combine together properties from
- /// several different contexts in the following order:
- /// <list type="definition">
- /// <item>
- /// <term>this events properties</term>
- /// <description>
- /// This event has <see cref="Properties"/> that can be set. These
- /// properties are specific to this event only.
- /// </description>
- /// </item>
- /// <item>
- /// <term>the thread properties</term>
- /// <description>
- /// The <see cref="ThreadContext.Properties"/> that are set on the current
- /// thread. These properties are shared by all events logged on this thread.
- /// </description>
- /// </item>
- /// <item>
- /// <term>the global properties</term>
- /// <description>
- /// The <see cref="GlobalContext.Properties"/> that are set globally. These
- /// properties are shared by all the threads in the AppDomain.
- /// </description>
- /// </item>
- /// </list>
- /// </para>
- /// </remarks>
- public object LookupProperty(string key)
- {
- if (m_data.Properties != null)
- {
- return m_data.Properties[key];
- }
-
- if (m_compositeProperties == null)
- {
- CreateCompositeProperties();
- }
-
- return m_compositeProperties[key];
- }
-
- /// <summary>
- /// Get all the composite properties in this event
- /// </summary>
- /// <returns>the <see cref="PropertiesDictionary"/> containing all the properties</returns>
- /// <remarks>
- /// <para>
- /// See <see cref="LookupProperty"/> for details of the composite properties
- /// stored by the event.
- /// </para>
- /// <para>
- /// This method returns a single <see cref="PropertiesDictionary"/> containing all the
- /// properties defined for this event.
- /// </para>
- /// </remarks>
- public PropertiesDictionary GetProperties()
- {
- if (m_data.Properties != null)
- {
- return m_data.Properties;
- }
-
- if (m_compositeProperties == null)
- {
- CreateCompositeProperties();
- }
-
- return m_compositeProperties.Flatten();
- }
-
- #endregion Public Instance Methods
-
- #region Private Instance Fields
-
- /// <summary>
- /// The internal logging event data.
- /// </summary>
- private LoggingEventData m_data;
-
- /// <summary>
- /// The internal logging event data.
- /// </summary>
- private CompositeProperties m_compositeProperties;
-
- /// <summary>
- /// The internal logging event data.
- /// </summary>
- private PropertiesDictionary m_eventProperties;
-
- /// <summary>
- /// The fully qualified Type of the calling
- /// logger class in the stack frame (i.e. the declaring type of the method).
- /// </summary>
- private readonly Type m_callerStackBoundaryDeclaringType;
-
- /// <summary>
- /// The application supplied message of logging event.
- /// </summary>
- private object m_message;
-
- /// <summary>
- /// The exception that was thrown.
- /// </summary>
- /// <remarks>
- /// This is not serialized. The string representation
- /// is serialized instead.
- /// </remarks>
- private readonly Exception m_thrownException;
-
- /// <summary>
- /// The repository that generated the logging event
- /// </summary>
- /// <remarks>
- /// This is not serialized.
- /// </remarks>
- private ILoggerRepository m_repository = null;
-
- /// <summary>
- /// The fix state for this event
- /// </summary>
- /// <remarks>
- /// These flags indicate which fields have been fixed.
- /// Not serialized.
- /// </remarks>
- private FixFlags m_fixFlags = FixFlags.None;
-
- /// <summary>
- /// Indicated that the internal cache is updateable (ie not fixed)
- /// </summary>
- /// <remarks>
- /// This is a seperate flag to m_fixFlags as it allows incrementel fixing and simpler
- /// changes in the caching strategy.
- /// </remarks>
- private bool m_cacheUpdatable = true;
-
- #endregion Private Instance Fields
-
- #region Constants
-
- /// <summary>
- /// The key into the Properties map for the host name value.
- /// </summary>
- public const string HostNameProperty = "log4net:HostName";
-
- /// <summary>
- /// The key into the Properties map for the thread identity value.
- /// </summary>
- public const string IdentityProperty = "log4net:Identity";
-
- /// <summary>
- /// The key into the Properties map for the user name value.
- /// </summary>
- public const string UserNameProperty = "log4net:UserName";
-
- #endregion
+ if (fastButLoose)
+ {
+ Fix = FixFlags.Partial;
+ }
+ else
+ {
+ Fix = FixFlags.All;
+ }
}
+
+ /// <summary>
+ /// Fix the fields specified by the <see cref="FixFlags"/> parameter
+ /// </summary>
+ /// <param name="flags">the fields to fix</param>
+ /// <remarks>
+ /// <para>
+ /// Only fields specified in the <paramref name="flags"/> will be fixed.
+ /// Fields will not be fixed if they have previously been fixed.
+ /// It is not possible to 'unfix' a field.
+ /// </para>
+ /// </remarks>
+ protected virtual void FixVolatileData(FixFlags flags)
+ {
+ object forceCreation = null;
+
+ //Unlock the cache so that new values can be stored
+ //This may not be ideal if we are no longer in the correct context
+ //and someone calls fix.
+ m_cacheUpdatable = true;
+
+ // determine the flags that we are actually fixing
+ var updateFlags = (FixFlags)((flags ^ m_fixFlags) & flags);
+
+ if (updateFlags > 0)
+ {
+ if ((updateFlags & FixFlags.Message) != 0)
+ {
+ // Force the message to be rendered
+ forceCreation = this.RenderedMessage;
+
+ m_fixFlags |= FixFlags.Message;
+ }
+
+ if ((updateFlags & FixFlags.ThreadName) != 0)
+ {
+ // Grab the thread name
+ forceCreation = this.ThreadName;
+
+ m_fixFlags |= FixFlags.ThreadName;
+ }
+
+ if ((updateFlags & FixFlags.LocationInfo) != 0)
+ {
+ // Force the location information to be loaded
+ forceCreation = this.LocationInformation;
+
+ m_fixFlags |= FixFlags.LocationInfo;
+ }
+
+ if ((updateFlags & FixFlags.UserName) != 0)
+ {
+ // Grab the user name
+ forceCreation = this.UserName;
+
+ m_fixFlags |= FixFlags.UserName;
+ }
+
+ if ((updateFlags & FixFlags.Domain) != 0)
+ {
+ // Grab the domain name
+ forceCreation = this.Domain;
+
+ m_fixFlags |= FixFlags.Domain;
+ }
+
+ if ((updateFlags & FixFlags.Identity) != 0)
+ {
+ // Grab the identity
+ forceCreation = this.Identity;
+
+ m_fixFlags |= FixFlags.Identity;
+ }
+
+ if ((updateFlags & FixFlags.Exception) != 0)
+ {
+ // Force the exception text to be loaded
+ forceCreation = GetExceptionString();
+
+ m_fixFlags |= FixFlags.Exception;
+ }
+
+ if ((updateFlags & FixFlags.Properties) != 0)
+ {
+ CacheProperties();
+
+ m_fixFlags |= FixFlags.Properties;
+ }
+ }
+
+ // avoid warning CS0219
+ if (forceCreation != null)
+ {
+ }
+
+ //Finaly lock everything we've cached.
+ m_cacheUpdatable = false;
+ }
+
+ #endregion Public Instance Methods
+
+ #region Protected Instance Methods
+
+ private void CreateCompositeProperties()
+ {
+ var compositeProperties = new CompositeProperties();
+
+ if (m_eventProperties != null)
+ {
+ compositeProperties.Add(m_eventProperties);
+ }
+#if !NETCF
+ var logicalThreadProperties = LogicalThreadContext.Properties.GetProperties(false);
+ if (logicalThreadProperties != null)
+ {
+ compositeProperties.Add(logicalThreadProperties);
+ }
+#endif
+ var threadProperties = ThreadContext.Properties.GetProperties(false);
+ if (threadProperties != null)
+ {
+ compositeProperties.Add(threadProperties);
+ }
+
+ // TODO: Add Repository Properties
+
+ // event properties
+ var shouldFixUserName = (m_fixFlags & FixFlags.UserName) != 0;
+ var shouldFixIdentity = (m_fixFlags & FixFlags.Identity) != 0;
+ if (shouldFixIdentity || shouldFixUserName)
+ {
+ var eventProperties = new PropertiesDictionary();
+ if (shouldFixUserName)
+ {
+ eventProperties[UserNameProperty] = UserName;
+ }
+
+ if (shouldFixIdentity)
+ {
+ eventProperties[IdentityProperty] = Identity;
+ }
+
+ compositeProperties.Add(eventProperties);
+ }
+
+ compositeProperties.Add(GlobalContext.Properties.GetReadOnlyProperties());
+ m_compositeProperties = compositeProperties;
+ }
+
+ private void CacheProperties()
+ {
+ if (m_data.Properties == null && this.m_cacheUpdatable)
+ {
+ if (m_compositeProperties == null)
+ {
+ CreateCompositeProperties();
+ }
+
+ var flattenedProperties = m_compositeProperties.Flatten();
+
+ var fixedProperties = new PropertiesDictionary();
+
+ // Validate properties
+ foreach (DictionaryEntry entry in flattenedProperties)
+ {
+ var key = entry.Key as string;
+
+ if (key != null)
+ {
+ var val = entry.Value;
+
+ // Fix any IFixingRequired objects
+ var fixingRequired = val as IFixingRequired;
+ if (fixingRequired != null)
+ {
+ val = fixingRequired.GetFixedObject();
+ }
+
+ // Strip keys with null values
+ if (val != null)
+ {
+ fixedProperties[key] = val;
+ }
+ }
+ }
+
+ m_data.Properties = fixedProperties;
+ }
+ }
+
+ /// <summary>
+ /// Lookup a composite property in this event
+ /// </summary>
+ /// <param name="key">the key for the property to lookup</param>
+ /// <returns>the value for the property</returns>
+ /// <remarks>
+ /// <para>
+ /// This event has composite properties that combine together properties from
+ /// several different contexts in the following order:
+ /// <list type="definition">
+ /// <item>
+ /// <term>this events properties</term>
+ /// <description>
+ /// This event has <see cref="Properties"/> that can be set. These
+ /// properties are specific to this event only.
+ /// </description>
+ /// </item>
+ /// <item>
+ /// <term>the thread properties</term>
+ /// <description>
+ /// The <see cref="ThreadContext.Properties"/> that are set on the current
+ /// thread. These properties are shared by all events logged on this thread.
+ /// </description>
+ /// </item>
+ /// <item>
+ /// <term>the global properties</term>
+ /// <description>
+ /// The <see cref="GlobalContext.Properties"/> that are set globally. These
+ /// properties are shared by all the threads in the AppDomain.
+ /// </description>
+ /// </item>
+ /// </list>
+ /// </para>
+ /// </remarks>
+ public object LookupProperty(string key)
+ {
+ if (m_data.Properties != null)
+ {
+ return m_data.Properties[key];
+ }
+
+ if (m_compositeProperties == null)
+ {
+ CreateCompositeProperties();
+ }
+
+ return m_compositeProperties[key];
+ }
+
+ /// <summary>
+ /// Get all the composite properties in this event
+ /// </summary>
+ /// <returns>the <see cref="PropertiesDictionary"/> containing all the properties</returns>
+ /// <remarks>
+ /// <para>
+ /// See <see cref="LookupProperty"/> for details of the composite properties
+ /// stored by the event.
+ /// </para>
+ /// <para>
+ /// This method returns a single <see cref="PropertiesDictionary"/> containing all the
+ /// properties defined for this event.
+ /// </para>
+ /// </remarks>
+ public PropertiesDictionary GetProperties()
+ {
+ if (m_data.Properties != null)
+ {
+ return m_data.Properties;
+ }
+
+ if (m_compositeProperties == null)
+ {
+ CreateCompositeProperties();
+ }
+
+ return m_compositeProperties.Flatten();
+ }
+
+ #endregion Public Instance Methods
+
+ #region Private Instance Fields
+
+ /// <summary>
+ /// The internal logging event data.
+ /// </summary>
+ private LoggingEventData m_data;
+
+ /// <summary>
+ /// The internal logging event data.
+ /// </summary>
+ private CompositeProperties m_compositeProperties;
+
+ /// <summary>
+ /// The internal logging event data.
+ /// </summary>
+ private PropertiesDictionary m_eventProperties;
+
+ /// <summary>
+ /// The fully qualified Type of the calling
+ /// logger class in the stack frame (i.e. the declaring type of the method).
+ /// </summary>
+ private readonly Type m_callerStackBoundaryDeclaringType;
+
+ /// <summary>
+ /// The application supplied message of logging event.
+ /// </summary>
+ private object m_message;
+
+ /// <summary>
+ /// The exception that was thrown.
+ /// </summary>
+ /// <remarks>
+ /// This is not serialized. The string representation
+ /// is serialized instead.
+ /// </remarks>
+ private readonly Exception m_thrownException;
+
+ /// <summary>
+ /// The repository that generated the logging event
+ /// </summary>
+ /// <remarks>
+ /// This is not serialized.
+ /// </remarks>
+ private ILoggerRepository m_repository = null;
+
+ /// <summary>
+ /// The fix state for this event
+ /// </summary>
+ /// <remarks>
+ /// These flags indicate which fields have been fixed.
+ /// Not serialized.
+ /// </remarks>
+ private FixFlags m_fixFlags = FixFlags.None;
+
+ /// <summary>
+ /// Indicated that the internal cache is updateable (ie not fixed)
+ /// </summary>
+ /// <remarks>
+ /// This is a seperate flag to m_fixFlags as it allows incrementel fixing and simpler
+ /// changes in the caching strategy.
+ /// </remarks>
+ private bool m_cacheUpdatable = true;
+
+ #endregion Private Instance Fields
+
+ #region Constants
+
+ /// <summary>
+ /// The key into the Properties map for the host name value.
+ /// </summary>
+ public const string HostNameProperty = "log4net:HostName";
+
+ /// <summary>
+ /// The key into the Properties map for the thread identity value.
+ /// </summary>
+ public const string IdentityProperty = "log4net:Identity";
+
+ /// <summary>
+ /// The key into the Properties map for the user name value.
+ /// </summary>
+ public const string UserNameProperty = "log4net:UserName";
+
+ #endregion
+ }
}
\ No newline at end of file
diff --git a/src/log4net/Core/MethodItem.cs b/src/log4net/Core/MethodItem.cs
index f76ccdb..113cd37 100644
--- a/src/log4net/Core/MethodItem.cs
+++ b/src/log4net/Core/MethodItem.cs
@@ -65,13 +65,13 @@
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
diff --git a/src/log4net/Core/StackFrameItem.cs b/src/log4net/Core/StackFrameItem.cs
index 778703b..abad979 100644
--- a/src/log4net/Core/StackFrameItem.cs
+++ b/src/log4net/Core/StackFrameItem.cs
@@ -24,28 +24,28 @@
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>
+ /// 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>
+ /// 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
{
@@ -56,7 +56,7 @@
MethodBase method = frame.GetMethod();
if (method != null)
{
- if(method.DeclaringType != null)
+ if (method.DeclaringType != null)
m_className = method.DeclaringType.FullName;
m_method = new MethodItem(method);
}
@@ -66,130 +66,130 @@
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 + ')';
- }
+ // set full info
+ m_fullInfo = m_className + '.' + m_method.Name + '(' + m_fileName + ':' + m_lineNumber + ')';
+ }
- #endregion
+ #endregion
- #region Public Instance Properties
+ #region Public Instance Properties
- /// <summary>
- /// Gets the fully qualified class name of the caller making the logging
- /// request.
- /// </summary>
- /// <value>
- /// The fully qualified class name of the caller making the logging
- /// request.
- /// </value>
- /// <remarks>
- /// <para>
- /// Gets the fully qualified class name of the caller making the logging
- /// request.
- /// </para>
- /// </remarks>
- public string ClassName
- {
- get { return m_className; }
- }
+ /// <summary>
+ /// Gets the fully qualified class name of the caller making the logging
+ /// request.
+ /// </summary>
+ /// <value>
+ /// The fully qualified class name of the caller making the logging
+ /// request.
+ /// </value>
+ /// <remarks>
+ /// <para>
+ /// Gets the fully qualified class name of the caller making the logging
+ /// request.
+ /// </para>
+ /// </remarks>
+ public string ClassName
+ {
+ get { return m_className; }
+ }
- /// <summary>
- /// Gets the file name of the caller.
- /// </summary>
- /// <value>
- /// The file name of the caller.
- /// </value>
- /// <remarks>
- /// <para>
- /// Gets the file name of the caller.
- /// </para>
- /// </remarks>
- public string FileName
- {
- get { return m_fileName; }
- }
+ /// <summary>
+ /// Gets the file name of the caller.
+ /// </summary>
+ /// <value>
+ /// The file name of the caller.
+ /// </value>
+ /// <remarks>
+ /// <para>
+ /// Gets the file name of the caller.
+ /// </para>
+ /// </remarks>
+ public string FileName
+ {
+ get { return m_fileName; }
+ }
- /// <summary>
- /// Gets the line number of the caller.
- /// </summary>
- /// <value>
- /// The line number of the caller.
- /// </value>
- /// <remarks>
- /// <para>
- /// Gets the line number of the caller.
- /// </para>
- /// </remarks>
- public string LineNumber
- {
- get { return m_lineNumber; }
- }
+ /// <summary>
+ /// Gets the line number of the caller.
+ /// </summary>
+ /// <value>
+ /// The line number of the caller.
+ /// </value>
+ /// <remarks>
+ /// <para>
+ /// Gets the line number of the caller.
+ /// </para>
+ /// </remarks>
+ public string LineNumber
+ {
+ get { return m_lineNumber; }
+ }
- /// <summary>
- /// Gets the method name of the caller.
- /// </summary>
- /// <value>
- /// The method name of the caller.
- /// </value>
- /// <remarks>
- /// <para>
- /// Gets the method name of the caller.
- /// </para>
- /// </remarks>
- public MethodItem Method
- {
- get { return m_method; }
- }
+ /// <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; }
- }
+ /// <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
+ #endregion Public Instance Properties
- #region Private Instance Fields
+ #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 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 static readonly 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 static readonly 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
diff --git a/src/log4net/Core/TimeEvaluator.cs b/src/log4net/Core/TimeEvaluator.cs
index 3067f56..af93e55 100644
--- a/src/log4net/Core/TimeEvaluator.cs
+++ b/src/log4net/Core/TimeEvaluator.cs
@@ -21,128 +21,128 @@
namespace log4net.Core
{
+ /// <summary>
+ /// An evaluator that triggers after specified number of seconds.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// This evaluator will trigger if the specified time period
+ /// <see cref="Interval"/> has passed since last check.
+ /// </para>
+ /// </remarks>
+ /// <author>Robert Sevcik</author>
+ public class TimeEvaluator : ITriggeringEventEvaluator
+ {
/// <summary>
- /// An evaluator that triggers after specified number of seconds.
+ /// The time threshold for triggering in seconds. Zero means it won't trigger at all.
/// </summary>
+ private int m_interval;
+
+ /// <summary>
+ /// The UTC time of last check. This gets updated when the object is created and when the evaluator triggers.
+ /// </summary>
+ private DateTime m_lastTimeUtc;
+
+ /// <summary>
+ /// The default time threshold for triggering in seconds. Zero means it won't trigger at all.
+ /// </summary>
+ const int DEFAULT_INTERVAL = 0;
+
+ /// <summary>
+ /// Create a new evaluator using the <see cref="DEFAULT_INTERVAL"/> time threshold in seconds.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Create a new evaluator using the <see cref="DEFAULT_INTERVAL"/> time threshold in seconds.
+ /// </para>
+ /// <para>
+ /// This evaluator will trigger if the specified time period
+ /// <see cref="Interval"/> has passed since last check.
+ /// </para>
+ /// </remarks>
+ public TimeEvaluator()
+ : this(DEFAULT_INTERVAL)
+ {
+ }
+
+ /// <summary>
+ /// Create a new evaluator using the specified time threshold in seconds.
+ /// </summary>
+ /// <param name="interval">
+ /// The time threshold in seconds to trigger after.
+ /// Zero means it won't trigger at all.
+ /// </param>
+ /// <remarks>
+ /// <para>
+ /// Create a new evaluator using the specified time threshold in seconds.
+ /// </para>
+ /// <para>
+ /// This evaluator will trigger if the specified time period
+ /// <see cref="Interval"/> has passed since last check.
+ /// </para>
+ /// </remarks>
+ public TimeEvaluator(int interval)
+ {
+ m_interval = interval;
+ m_lastTimeUtc = DateTime.UtcNow;
+ }
+
+ /// <summary>
+ /// The time threshold in seconds to trigger after
+ /// </summary>
+ /// <value>
+ /// The time threshold in seconds to trigger after.
+ /// Zero means it won't trigger at all.
+ /// </value>
/// <remarks>
/// <para>
/// This evaluator will trigger if the specified time period
/// <see cref="Interval"/> has passed since last check.
/// </para>
/// </remarks>
- /// <author>Robert Sevcik</author>
- public class TimeEvaluator : ITriggeringEventEvaluator
+ public int Interval
{
- /// <summary>
- /// The time threshold for triggering in seconds. Zero means it won't trigger at all.
- /// </summary>
- private int m_interval;
-
- /// <summary>
- /// The UTC time of last check. This gets updated when the object is created and when the evaluator triggers.
- /// </summary>
- private DateTime m_lastTimeUtc;
-
- /// <summary>
- /// The default time threshold for triggering in seconds. Zero means it won't trigger at all.
- /// </summary>
- const int DEFAULT_INTERVAL = 0;
-
- /// <summary>
- /// Create a new evaluator using the <see cref="DEFAULT_INTERVAL"/> time threshold in seconds.
- /// </summary>
- /// <remarks>
- /// <para>
- /// Create a new evaluator using the <see cref="DEFAULT_INTERVAL"/> time threshold in seconds.
- /// </para>
- /// <para>
- /// This evaluator will trigger if the specified time period
- /// <see cref="Interval"/> has passed since last check.
- /// </para>
- /// </remarks>
- public TimeEvaluator()
- : this(DEFAULT_INTERVAL)
- {
- }
-
- /// <summary>
- /// Create a new evaluator using the specified time threshold in seconds.
- /// </summary>
- /// <param name="interval">
- /// The time threshold in seconds to trigger after.
- /// Zero means it won't trigger at all.
- /// </param>
- /// <remarks>
- /// <para>
- /// Create a new evaluator using the specified time threshold in seconds.
- /// </para>
- /// <para>
- /// This evaluator will trigger if the specified time period
- /// <see cref="Interval"/> has passed since last check.
- /// </para>
- /// </remarks>
- public TimeEvaluator(int interval)
- {
- m_interval = interval;
- m_lastTimeUtc = DateTime.UtcNow;
- }
-
- /// <summary>
- /// The time threshold in seconds to trigger after
- /// </summary>
- /// <value>
- /// The time threshold in seconds to trigger after.
- /// Zero means it won't trigger at all.
- /// </value>
- /// <remarks>
- /// <para>
- /// This evaluator will trigger if the specified time period
- /// <see cref="Interval"/> has passed since last check.
- /// </para>
- /// </remarks>
- public int Interval
- {
- get { return m_interval; }
- set { m_interval = value; }
- }
-
- /// <summary>
- /// Is this <paramref name="loggingEvent"/> the triggering event?
- /// </summary>
- /// <param name="loggingEvent">The event to check</param>
- /// <returns>This method returns <c>true</c>, if the specified time period
- /// <see cref="Interval"/> has passed since last check..
- /// Otherwise it returns <c>false</c></returns>
- /// <remarks>
- /// <para>
- /// This evaluator will trigger if the specified time period
- /// <see cref="Interval"/> has passed since last check.
- /// </para>
- /// </remarks>
- public bool IsTriggeringEvent(LoggingEvent loggingEvent)
- {
- if (loggingEvent == null)
- {
- throw new ArgumentNullException("loggingEvent");
- }
-
- // disable the evaluator if threshold is zero
- if (m_interval == 0) return false;
-
- lock (this) // avoid triggering multiple times
- {
- TimeSpan passed = DateTime.UtcNow.Subtract(m_lastTimeUtc);
-
- if (passed.TotalSeconds > m_interval)
- {
- m_lastTimeUtc = DateTime.UtcNow;
- return true;
- }
- else
- {
- return false;
- }
- }
- }
+ get { return m_interval; }
+ set { m_interval = value; }
}
+
+ /// <summary>
+ /// Is this <paramref name="loggingEvent"/> the triggering event?
+ /// </summary>
+ /// <param name="loggingEvent">The event to check</param>
+ /// <returns>This method returns <c>true</c>, if the specified time period
+ /// <see cref="Interval"/> has passed since last check..
+ /// Otherwise it returns <c>false</c></returns>
+ /// <remarks>
+ /// <para>
+ /// This evaluator will trigger if the specified time period
+ /// <see cref="Interval"/> has passed since last check.
+ /// </para>
+ /// </remarks>
+ public bool IsTriggeringEvent(LoggingEvent loggingEvent)
+ {
+ if (loggingEvent == null)
+ {
+ throw new ArgumentNullException("loggingEvent");
+ }
+
+ // disable the evaluator if threshold is zero
+ if (m_interval == 0) return false;
+
+ lock (this) // avoid triggering multiple times
+ {
+ TimeSpan passed = DateTime.UtcNow.Subtract(m_lastTimeUtc);
+
+ if (passed.TotalSeconds > m_interval)
+ {
+ m_lastTimeUtc = DateTime.UtcNow;
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ }
+ }
+ }
}
diff --git a/src/log4net/Core/WrapperMap.cs b/src/log4net/Core/WrapperMap.cs
index e9d6cad..b2b30e5 100644
--- a/src/log4net/Core/WrapperMap.cs
+++ b/src/log4net/Core/WrapperMap.cs
@@ -78,7 +78,7 @@
/// the specified handler to create the wrapper objects.
/// </para>
/// </remarks>
- public WrapperMap(WrapperCreationHandler createWrapperHandler)
+ public WrapperMap(WrapperCreationHandler createWrapperHandler)
{
m_createWrapperHandler = createWrapperHandler;
@@ -113,7 +113,7 @@
return null;
}
- lock(this)
+ lock (this)
{
// Lookup hierarchy in map.
Hashtable wrappersMap = (Hashtable)m_repositories[logger.Repository];
@@ -139,7 +139,7 @@
// Create a new wrapper wrapping the logger
wrapperObject = CreateNewWrapperObject(logger);
-
+
// Store wrapper logger in map
wrappersMap[logger] = wrapperObject;
}
@@ -165,7 +165,7 @@
/// value being the corresponding <see cref="ILoggerWrapper"/>.
/// </para>
/// </remarks>
- protected Hashtable Repositories
+ protected Hashtable Repositories
{
get { return this.m_repositories; }
}
@@ -210,7 +210,7 @@
/// </remarks>
protected virtual void RepositoryShutdown(ILoggerRepository repository)
{
- lock(this)
+ lock (this)
{
// Remove the repository from map
m_repositories.Remove(repository);
@@ -253,7 +253,7 @@
/// Internal reference to the delegate used to register for repository shutdown events.
/// </summary>
private readonly LoggerRepositoryShutdownEventHandler m_shutdownHandler;
-
+
#endregion Private Instance Variables
}
}
diff --git a/src/log4net/DateFormatter/AbsoluteTimeDateFormatter.cs b/src/log4net/DateFormatter/AbsoluteTimeDateFormatter.cs
index b19a1e0..d510c56 100644
--- a/src/log4net/DateFormatter/AbsoluteTimeDateFormatter.cs
+++ b/src/log4net/DateFormatter/AbsoluteTimeDateFormatter.cs
@@ -54,7 +54,7 @@
protected virtual void FormatDateWithoutMillis(DateTime dateToFormat, StringBuilder buffer)
{
int hour = dateToFormat.Hour;
- if (hour < 10)
+ if (hour < 10)
{
buffer.Append('0');
}
@@ -62,15 +62,15 @@
buffer.Append(':');
int mins = dateToFormat.Minute;
- if (mins < 10)
+ if (mins < 10)
{
buffer.Append('0');
}
buffer.Append(mins);
buffer.Append(':');
-
+
int secs = dateToFormat.Second;
- if (secs < 10)
+ if (secs < 10)
{
buffer.Append('0');
}
@@ -101,71 +101,71 @@
/// </remarks>
public virtual void FormatDate(DateTime dateToFormat, TextWriter writer)
{
- lock (s_lastTimeStrings)
+ lock (s_lastTimeStrings)
+ {
+ // Calculate the current time precise only to the second
+ long currentTimeToTheSecond = (dateToFormat.Ticks - (dateToFormat.Ticks % TimeSpan.TicksPerSecond));
+
+ string timeString = null;
+ // Compare this time with the stored last time
+ // If we are in the same second then append
+ // the previously calculated time string
+ if (s_lastTimeToTheSecond != currentTimeToTheSecond)
{
- // Calculate the current time precise only to the second
- long currentTimeToTheSecond = (dateToFormat.Ticks - (dateToFormat.Ticks % TimeSpan.TicksPerSecond));
-
- string timeString = null;
- // Compare this time with the stored last time
- // If we are in the same second then append
- // the previously calculated time string
- if (s_lastTimeToTheSecond != currentTimeToTheSecond)
- {
- s_lastTimeStrings.Clear();
- }
- else
- {
- timeString = (string) s_lastTimeStrings[GetType()];
- }
-
- if (timeString == null)
- {
- // lock so that only one thread can use the buffer and
- // update the s_lastTimeToTheSecond and s_lastTimeStrings
-
- // PERF: Try removing this lock and using a new StringBuilder each time
- lock(s_lastTimeBuf)
+ s_lastTimeStrings.Clear();
+ }
+ else
{
- timeString = (string) s_lastTimeStrings[GetType()];
+ timeString = (string)s_lastTimeStrings[GetType()];
+ }
- if (timeString == null)
- {
- // We are in a new second.
- s_lastTimeBuf.Length = 0;
+ if (timeString == null)
+ {
+ // lock so that only one thread can use the buffer and
+ // update the s_lastTimeToTheSecond and s_lastTimeStrings
- // Calculate the new string for this second
- FormatDateWithoutMillis(dateToFormat, s_lastTimeBuf);
+ // PERF: Try removing this lock and using a new StringBuilder each time
+ lock (s_lastTimeBuf)
+ {
+ timeString = (string)s_lastTimeStrings[GetType()];
- // Render the string buffer to a string
- timeString = s_lastTimeBuf.ToString();
+ if (timeString == null)
+ {
+ // We are in a new second.
+ s_lastTimeBuf.Length = 0;
+
+ // Calculate the new string for this second
+ FormatDateWithoutMillis(dateToFormat, s_lastTimeBuf);
+
+ // Render the string buffer to a string
+ timeString = s_lastTimeBuf.ToString();
#if NET_1_1
// Ensure that the above string is written into the variable NOW on all threads.
// This is only required on multiprocessor machines with weak memeory models
System.Threading.Thread.MemoryBarrier();
#endif
- // Store the time as a string (we only have to do this once per second)
- s_lastTimeStrings[GetType()] = timeString;
- s_lastTimeToTheSecond = currentTimeToTheSecond;
+ // Store the time as a string (we only have to do this once per second)
+ s_lastTimeStrings[GetType()] = timeString;
+ s_lastTimeToTheSecond = currentTimeToTheSecond;
+ }
}
}
+ writer.Write(timeString);
+
+ // Append the current millisecond info
+ writer.Write(',');
+ int millis = dateToFormat.Millisecond;
+ if (millis < 100)
+ {
+ writer.Write('0');
+ }
+ if (millis < 10)
+ {
+ writer.Write('0');
+ }
+ writer.Write(millis);
}
- writer.Write(timeString);
-
- // Append the current millisecond info
- writer.Write(',');
- int millis = dateToFormat.Millisecond;
- if (millis < 100)
- {
- writer.Write('0');
- }
- if (millis < 10)
- {
- writer.Write('0');
- }
- writer.Write(millis);
- }
}
#endregion Implementation of IDateFormatter
diff --git a/src/log4net/DateFormatter/DateTimeDateFormatter.cs b/src/log4net/DateFormatter/DateTimeDateFormatter.cs
index 90d529c..4a9364b 100644
--- a/src/log4net/DateFormatter/DateTimeDateFormatter.cs
+++ b/src/log4net/DateFormatter/DateTimeDateFormatter.cs
@@ -75,15 +75,15 @@
protected override void FormatDateWithoutMillis(DateTime dateToFormat, StringBuilder buffer)
{
int day = dateToFormat.Day;
- if (day < 10)
+ if (day < 10)
{
buffer.Append('0');
}
buffer.Append(day);
- buffer.Append(' ');
+ buffer.Append(' ');
buffer.Append(m_dateTimeFormatInfo.GetAbbreviatedMonthName(dateToFormat.Month));
- buffer.Append(' ');
+ buffer.Append(' ');
buffer.Append(dateToFormat.Year);
buffer.Append(' ');
diff --git a/src/log4net/DateFormatter/Iso8601DateFormatter.cs b/src/log4net/DateFormatter/Iso8601DateFormatter.cs
index 1ff299f..a78dbb7 100644
--- a/src/log4net/DateFormatter/Iso8601DateFormatter.cs
+++ b/src/log4net/DateFormatter/Iso8601DateFormatter.cs
@@ -80,7 +80,7 @@
buffer.Append('-');
int day = dateToFormat.Day;
- if (day < 10)
+ if (day < 10)
{
buffer.Append('0');
}
diff --git a/src/log4net/Filter/DenyAllFilter.cs b/src/log4net/Filter/DenyAllFilter.cs
index 35c1138..562fbc1 100644
--- a/src/log4net/Filter/DenyAllFilter.cs
+++ b/src/log4net/Filter/DenyAllFilter.cs
@@ -65,7 +65,7 @@
/// as any further filters will be ignored!
/// </para>
/// </remarks>
- public override FilterDecision Decide(LoggingEvent loggingEvent)
+ public override FilterDecision Decide(LoggingEvent loggingEvent)
{
return FilterDecision.Deny;
}
diff --git a/src/log4net/Filter/FilterDecision.cs b/src/log4net/Filter/FilterDecision.cs
index c81a156..9164eea 100644
--- a/src/log4net/Filter/FilterDecision.cs
+++ b/src/log4net/Filter/FilterDecision.cs
@@ -38,7 +38,7 @@
/// consulting with the remaining filters, if any, in the chain.
/// </summary>
Deny = -1,
-
+
/// <summary>
/// This filter is neutral with respect to the log event.
/// The remaining filters, if any, should be consulted for a final decision.
diff --git a/src/log4net/Filter/FilterSkeleton.cs b/src/log4net/Filter/FilterSkeleton.cs
index 158d635..3bab116 100644
--- a/src/log4net/Filter/FilterSkeleton.cs
+++ b/src/log4net/Filter/FilterSkeleton.cs
@@ -104,7 +104,7 @@
/// however this method must still be called.
/// </para>
/// </remarks>
- public virtual void ActivateOptions()
+ public virtual void ActivateOptions()
{
}
diff --git a/src/log4net/Filter/LevelMatchFilter.cs b/src/log4net/Filter/LevelMatchFilter.cs
index 50d291f..e257286 100644
--- a/src/log4net/Filter/LevelMatchFilter.cs
+++ b/src/log4net/Filter/LevelMatchFilter.cs
@@ -122,14 +122,14 @@
/// the result will be <see cref="FilterDecision.Neutral"/>.
/// </para>
/// </remarks>
- public override FilterDecision Decide(LoggingEvent loggingEvent)
+ public override FilterDecision Decide(LoggingEvent loggingEvent)
{
if (loggingEvent == null)
{
throw new ArgumentNullException("loggingEvent");
}
- if (m_levelToMatch != null && m_levelToMatch == loggingEvent.Level)
+ if (m_levelToMatch != null && m_levelToMatch == loggingEvent.Level)
{
// Found match
return m_acceptOnMatch ? FilterDecision.Accept : FilterDecision.Deny;
diff --git a/src/log4net/Filter/LevelRangeFilter.cs b/src/log4net/Filter/LevelRangeFilter.cs
index e2bb676..f29c7fa 100644
--- a/src/log4net/Filter/LevelRangeFilter.cs
+++ b/src/log4net/Filter/LevelRangeFilter.cs
@@ -142,38 +142,38 @@
/// <see cref="FilterDecision.Neutral"/> is returned.
/// </para>
/// </remarks>
- public override FilterDecision Decide(LoggingEvent loggingEvent)
+ public override FilterDecision Decide(LoggingEvent loggingEvent)
{
if (loggingEvent == null)
{
throw new ArgumentNullException("loggingEvent");
}
- if (m_levelMin != null)
+ if (m_levelMin != null)
{
- if (loggingEvent.Level < m_levelMin)
+ if (loggingEvent.Level < m_levelMin)
{
// level of event is less than minimum
return FilterDecision.Deny;
}
}
- if (m_levelMax != null)
+ if (m_levelMax != null)
{
- if (loggingEvent.Level > m_levelMax)
+ if (loggingEvent.Level > m_levelMax)
{
// level of event is greater than maximum
return FilterDecision.Deny;
}
}
- if (m_acceptOnMatch)
+ if (m_acceptOnMatch)
{
// this filter set up to bypass later filters and always return
// accept if level in range
return FilterDecision.Accept;
}
- else
+ else
{
// event is ok for this filter; allow later filters to have a look..
return FilterDecision.Neutral;
diff --git a/src/log4net/Filter/LoggerMatchFilter.cs b/src/log4net/Filter/LoggerMatchFilter.cs
index 0bc5e65..8f57744 100644
--- a/src/log4net/Filter/LoggerMatchFilter.cs
+++ b/src/log4net/Filter/LoggerMatchFilter.cs
@@ -129,7 +129,7 @@
/// <see cref="FilterDecision.Deny"/> is returned.
/// </para>
/// </remarks>
- public override FilterDecision Decide(LoggingEvent loggingEvent)
+ public override FilterDecision Decide(LoggingEvent loggingEvent)
{
if (loggingEvent == null)
{
@@ -137,14 +137,14 @@
}
// Check if we have been setup to filter
- if ((m_loggerToMatch != null && m_loggerToMatch.Length != 0) &&
+ if ((m_loggerToMatch != null && m_loggerToMatch.Length != 0) &&
loggingEvent.LoggerName.StartsWith(m_loggerToMatch))
{
// we've got a match
- if (m_acceptOnMatch)
+ if (m_acceptOnMatch)
{
return FilterDecision.Accept;
- }
+ }
return FilterDecision.Deny;
}
else
diff --git a/src/log4net/Filter/PropertyFilter.cs b/src/log4net/Filter/PropertyFilter.cs
index b8815d1..c443807 100644
--- a/src/log4net/Filter/PropertyFilter.cs
+++ b/src/log4net/Filter/PropertyFilter.cs
@@ -94,7 +94,7 @@
/// <see cref="FilterDecision.Deny"/> is returned.
/// </para>
/// </remarks>
- public override FilterDecision Decide(LoggingEvent loggingEvent)
+ public override FilterDecision Decide(LoggingEvent loggingEvent)
{
if (loggingEvent == null)
{
@@ -123,7 +123,7 @@
// to continue processing
return FilterDecision.Neutral;
}
-
+
// Firstly check if we are matching using a regex
if (m_regexToMatch != null)
{
@@ -132,29 +132,29 @@
{
// No match, continue processing
return FilterDecision.Neutral;
- }
+ }
// we've got a match
- if (m_acceptOnMatch)
+ if (m_acceptOnMatch)
{
return FilterDecision.Accept;
- }
+ }
return FilterDecision.Deny;
}
else if (m_stringToMatch != null)
{
// Check substring match
- if (msg.IndexOf(m_stringToMatch) == -1)
+ if (msg.IndexOf(m_stringToMatch) == -1)
{
// No match, continue processing
return FilterDecision.Neutral;
- }
+ }
// we've got a match
- if (m_acceptOnMatch)
+ if (m_acceptOnMatch)
{
return FilterDecision.Accept;
- }
+ }
return FilterDecision.Deny;
}
return FilterDecision.Neutral;
diff --git a/src/log4net/Filter/StringMatchFilter.cs b/src/log4net/Filter/StringMatchFilter.cs
index b269586..0c4bb7e 100644
--- a/src/log4net/Filter/StringMatchFilter.cs
+++ b/src/log4net/Filter/StringMatchFilter.cs
@@ -91,7 +91,7 @@
/// <see cref="ActivateOptions"/> must be called again.
/// </para>
/// </remarks>
- public override void ActivateOptions()
+ public override void ActivateOptions()
{
if (m_stringRegexToMatch != null)
{
@@ -186,7 +186,7 @@
/// <see cref="FilterDecision.Deny"/> is returned.
/// </para>
/// </remarks>
- public override FilterDecision Decide(LoggingEvent loggingEvent)
+ public override FilterDecision Decide(LoggingEvent loggingEvent)
{
if (loggingEvent == null)
{
@@ -202,7 +202,7 @@
// to continue processing
return FilterDecision.Neutral;
}
-
+
// Firstly check if we are matching using a regex
if (m_regexToMatch != null)
{
@@ -211,29 +211,29 @@
{
// No match, continue processing
return FilterDecision.Neutral;
- }
+ }
// we've got a match
- if (m_acceptOnMatch)
+ if (m_acceptOnMatch)
{
return FilterDecision.Accept;
- }
+ }
return FilterDecision.Deny;
}
else if (m_stringToMatch != null)
{
// Check substring match
- if (msg.IndexOf(m_stringToMatch) == -1)
+ if (msg.IndexOf(m_stringToMatch) == -1)
{
// No match, continue processing
return FilterDecision.Neutral;
- }
+ }
// we've got a match
- if (m_acceptOnMatch)
+ if (m_acceptOnMatch)
{
return FilterDecision.Accept;
- }
+ }
return FilterDecision.Deny;
}
return FilterDecision.Neutral;
diff --git a/src/log4net/ILog.cs b/src/log4net/ILog.cs
index ed39c16..5558b79 100644
--- a/src/log4net/ILog.cs
+++ b/src/log4net/ILog.cs
@@ -91,7 +91,7 @@
/// <seealso cref="M:Debug(object,Exception)"/>
/// <seealso cref="IsDebugEnabled"/>
void Debug(object message);
-
+
/// <summary>
/// Log a message object with the <see cref="Level.Debug"/> level including
/// the stack trace of the <see cref="Exception"/> passed
@@ -128,7 +128,7 @@
/// </remarks>
/// <seealso cref="M:Debug(object)"/>
/// <seealso cref="IsDebugEnabled"/>
- void DebugFormat(string format, params object[] args);
+ void DebugFormat(string format, params object[] args);
/// <summary>
/// Logs a formatted message string with the <see cref="Level.Debug"/> level.
@@ -149,7 +149,7 @@
/// </remarks>
/// <seealso cref="M:Debug(object)"/>
/// <seealso cref="IsDebugEnabled"/>
- void DebugFormat(string format, object arg0);
+ void DebugFormat(string format, object arg0);
/// <summary>
/// Logs a formatted message string with the <see cref="Level.Debug"/> level.
@@ -171,7 +171,7 @@
/// </remarks>
/// <seealso cref="M:Debug(object)"/>
/// <seealso cref="IsDebugEnabled"/>
- void DebugFormat(string format, object arg0, object arg1);
+ void DebugFormat(string format, object arg0, object arg1);
/// <summary>
/// Logs a formatted message string with the <see cref="Level.Debug"/> level.
@@ -194,7 +194,7 @@
/// </remarks>
/// <seealso cref="M:Debug(object)"/>
/// <seealso cref="IsDebugEnabled"/>
- void DebugFormat(string format, object arg0, object arg1, object arg2);
+ void DebugFormat(string format, object arg0, object arg1, object arg2);
/// <summary>
/// Logs a formatted message string with the <see cref="Level.Debug"/> level.
@@ -244,7 +244,7 @@
/// <seealso cref="M:Info(object,Exception)"/>
/// <seealso cref="IsInfoEnabled"/>
void Info(object message);
-
+
/// <summary>
/// Logs a message object with the <c>INFO</c> level including
/// the stack trace of the <see cref="Exception"/> passed
@@ -302,7 +302,7 @@
/// </remarks>
/// <seealso cref="M:Info(object)"/>
/// <seealso cref="IsInfoEnabled"/>
- void InfoFormat(string format, object arg0);
+ void InfoFormat(string format, object arg0);
/// <summary>
/// Logs a formatted message string with the <see cref="Level.Info"/> level.
@@ -324,7 +324,7 @@
/// </remarks>
/// <seealso cref="M:Info(object)"/>
/// <seealso cref="IsInfoEnabled"/>
- void InfoFormat(string format, object arg0, object arg1);
+ void InfoFormat(string format, object arg0, object arg1);
/// <summary>
/// Logs a formatted message string with the <see cref="Level.Info"/> level.
@@ -347,7 +347,7 @@
/// </remarks>
/// <seealso cref="M:Info(object)"/>
/// <seealso cref="IsInfoEnabled"/>
- void InfoFormat(string format, object arg0, object arg1, object arg2);
+ void InfoFormat(string format, object arg0, object arg1, object arg2);
/// <summary>
/// Logs a formatted message string with the <see cref="Level.Info"/> level.
@@ -397,7 +397,7 @@
/// <seealso cref="M:Warn(object,Exception)"/>
/// <seealso cref="IsWarnEnabled"/>
void Warn(object message);
-
+
/// <summary>
/// Log a message object with the <see cref="Level.Warn"/> level including
/// the stack trace of the <see cref="Exception"/> passed
@@ -455,7 +455,7 @@
/// </remarks>
/// <seealso cref="M:Warn(object)"/>
/// <seealso cref="IsWarnEnabled"/>
- void WarnFormat(string format, object arg0);
+ void WarnFormat(string format, object arg0);
/// <summary>
/// Logs a formatted message string with the <see cref="Level.Warn"/> level.
@@ -477,7 +477,7 @@
/// </remarks>
/// <seealso cref="M:Warn(object)"/>
/// <seealso cref="IsWarnEnabled"/>
- void WarnFormat(string format, object arg0, object arg1);
+ void WarnFormat(string format, object arg0, object arg1);
/// <summary>
/// Logs a formatted message string with the <see cref="Level.Warn"/> level.
@@ -500,7 +500,7 @@
/// </remarks>
/// <seealso cref="M:Warn(object)"/>
/// <seealso cref="IsWarnEnabled"/>
- void WarnFormat(string format, object arg0, object arg1, object arg2);
+ void WarnFormat(string format, object arg0, object arg1, object arg2);
/// <summary>
/// Logs a formatted message string with the <see cref="Level.Warn"/> level.
@@ -608,7 +608,7 @@
/// </remarks>
/// <seealso cref="M:Error(object)"/>
/// <seealso cref="IsErrorEnabled"/>
- void ErrorFormat(string format, object arg0);
+ void ErrorFormat(string format, object arg0);
/// <summary>
/// Logs a formatted message string with the <see cref="Level.Error"/> level.
@@ -630,7 +630,7 @@
/// </remarks>
/// <seealso cref="M:Error(object)"/>
/// <seealso cref="IsErrorEnabled"/>
- void ErrorFormat(string format, object arg0, object arg1);
+ void ErrorFormat(string format, object arg0, object arg1);
/// <summary>
/// Logs a formatted message string with the <see cref="Level.Error"/> level.
@@ -653,7 +653,7 @@
/// </remarks>
/// <seealso cref="M:Error(object)"/>
/// <seealso cref="IsErrorEnabled"/>
- void ErrorFormat(string format, object arg0, object arg1, object arg2);
+ void ErrorFormat(string format, object arg0, object arg1, object arg2);
/// <summary>
/// Logs a formatted message string with the <see cref="Level.Error"/> level.
@@ -703,7 +703,7 @@
/// <seealso cref="M:Fatal(object,Exception)"/>
/// <seealso cref="IsFatalEnabled"/>
void Fatal(object message);
-
+
/// <summary>
/// Log a message object with the <see cref="Level.Fatal"/> level including
/// the stack trace of the <see cref="Exception"/> passed
@@ -761,7 +761,7 @@
/// </remarks>
/// <seealso cref="M:Fatal(object)"/>
/// <seealso cref="IsFatalEnabled"/>
- void FatalFormat(string format, object arg0);
+ void FatalFormat(string format, object arg0);
/// <summary>
/// Logs a formatted message string with the <see cref="Level.Fatal"/> level.
@@ -783,7 +783,7 @@
/// </remarks>
/// <seealso cref="M:Fatal(object)"/>
/// <seealso cref="IsFatalEnabled"/>
- void FatalFormat(string format, object arg0, object arg1);
+ void FatalFormat(string format, object arg0, object arg1);
/// <summary>
/// Logs a formatted message string with the <see cref="Level.Fatal"/> level.
@@ -806,7 +806,7 @@
/// </remarks>
/// <seealso cref="M:Fatal(object)"/>
/// <seealso cref="IsFatalEnabled"/>
- void FatalFormat(string format, object arg0, object arg1, object arg2);
+ void FatalFormat(string format, object arg0, object arg1, object arg2);
/// <summary>
/// Logs a formatted message string with the <see cref="Level.Fatal"/> level.
@@ -900,7 +900,7 @@
/// <seealso cref="M:Debug(object)"/>
/// <seealso cref="M:DebugFormat(IFormatProvider, string, object[])"/>
bool IsDebugEnabled { get; }
-
+
/// <summary>
/// Checks if this logger is enabled for the <see cref="Level.Info"/> level.
/// </summary>
diff --git a/src/log4net/Layout/DynamicPatternLayout.cs b/src/log4net/Layout/DynamicPatternLayout.cs
index 2f3e002..ef6c4bc 100644
--- a/src/log4net/Layout/DynamicPatternLayout.cs
+++ b/src/log4net/Layout/DynamicPatternLayout.cs
@@ -50,7 +50,7 @@
/// </layout>
/// </example>
/// </remarks>
- public class DynamicPatternLayout: PatternLayout
+ public class DynamicPatternLayout : PatternLayout
{
#region Member Variables
/// <summary>
@@ -61,7 +61,7 @@
/// <summary>
/// The footer PatternString
/// </summary>
- private PatternString m_footerPatternString = new PatternString("");
+ private PatternString m_footerPatternString = new PatternString("");
#endregion
#region Constructors
@@ -84,7 +84,7 @@
/// <param name="pattern">the pattern to use</param>
/// <remarks>
/// </remarks>
- public DynamicPatternLayout (string pattern)
+ public DynamicPatternLayout(string pattern)
: base(pattern)
{
}
diff --git a/src/log4net/Layout/ExceptionLayout.cs b/src/log4net/Layout/ExceptionLayout.cs
index 2748b0d..05c111a 100644
--- a/src/log4net/Layout/ExceptionLayout.cs
+++ b/src/log4net/Layout/ExceptionLayout.cs
@@ -58,7 +58,7 @@
}
#endregion
-
+
#region Implementation of IOptionHandler
/// <summary>
@@ -73,7 +73,7 @@
/// This method does nothing as options become effective immediately.
/// </para>
/// </remarks>
- public override void ActivateOptions()
+ public override void ActivateOptions()
{
// nothing to do.
}
@@ -93,7 +93,7 @@
/// The exception string is retrieved from <see cref="M:LoggingEvent.GetExceptionString()"/>.
/// </para>
/// </remarks>
- public override void Format(TextWriter writer, LoggingEvent loggingEvent)
+ public override void Format(TextWriter writer, LoggingEvent loggingEvent)
{
if (loggingEvent == null)
{
diff --git a/src/log4net/Layout/LayoutSkeleton.cs b/src/log4net/Layout/LayoutSkeleton.cs
index e61374d..348eb07 100644
--- a/src/log4net/Layout/LayoutSkeleton.cs
+++ b/src/log4net/Layout/LayoutSkeleton.cs
@@ -221,8 +221,8 @@
/// value is <c>true</c>, this layout does not handle the exception.
/// </para>
/// </remarks>
- public virtual bool IgnoresException
- {
+ public virtual bool IgnoresException
+ {
get { return m_ignoresException; }
set { m_ignoresException = value; }
}
diff --git a/src/log4net/Layout/Pattern/AppDomainPatternConverter.cs b/src/log4net/Layout/Pattern/AppDomainPatternConverter.cs
index 83eb2d5..79c7322 100644
--- a/src/log4net/Layout/Pattern/AppDomainPatternConverter.cs
+++ b/src/log4net/Layout/Pattern/AppDomainPatternConverter.cs
@@ -35,7 +35,7 @@
/// </remarks>
/// <author>Daniel Cazzulino</author>
/// <author>Nicko Cadell</author>
- internal sealed class AppDomainPatternConverter : PatternLayoutConverter
+ internal sealed class AppDomainPatternConverter : PatternLayoutConverter
{
/// <summary>
/// Write the event appdomain name to the output
diff --git a/src/log4net/Layout/Pattern/AspNetRequestPatternConverter.cs b/src/log4net/Layout/Pattern/AspNetRequestPatternConverter.cs
index 2be5043..01b203e 100644
--- a/src/log4net/Layout/Pattern/AspNetRequestPatternConverter.cs
+++ b/src/log4net/Layout/Pattern/AspNetRequestPatternConverter.cs
@@ -55,15 +55,18 @@
/// </remarks>
protected override void Convert(TextWriter writer, LoggingEvent loggingEvent, HttpContext httpContext)
{
- HttpRequest request = null;
- try {
- request = httpContext.Request;
- } catch (HttpException) {
- // likely a case of running in IIS integrated mode
- // when inside an Application_Start event.
- // treat it like a case of the Request
- // property returning null
- }
+ HttpRequest request = null;
+ try
+ {
+ request = httpContext.Request;
+ }
+ catch (HttpException)
+ {
+ // likely a case of running in IIS integrated mode
+ // when inside an Application_Start event.
+ // treat it like a case of the Request
+ // property returning null
+ }
if (request != null)
{
diff --git a/src/log4net/Layout/Pattern/DatePatternConverter.cs b/src/log4net/Layout/Pattern/DatePatternConverter.cs
index a111b8f..7f24bbb 100644
--- a/src/log4net/Layout/Pattern/DatePatternConverter.cs
+++ b/src/log4net/Layout/Pattern/DatePatternConverter.cs
@@ -92,7 +92,7 @@
/// </para>
/// </remarks>
protected IDateFormatter m_dateFormatter;
-
+
#region Implementation of IOptionHandler
/// <summary>
@@ -133,15 +133,15 @@
}
else
{
- try
+ try
{
m_dateFormatter = new SimpleDateFormatter(dateFormatStr);
}
- catch (Exception e)
+ catch (Exception e)
{
- LogLog.Error(declaringType, "Could not instantiate SimpleDateFormatter with ["+dateFormatStr+"]", e);
+ LogLog.Error(declaringType, "Could not instantiate SimpleDateFormatter with [" + dateFormatStr + "]", e);
m_dateFormatter = new Iso8601DateFormatter();
- }
+ }
}
}
@@ -163,27 +163,27 @@
/// </remarks>
protected override void Convert(TextWriter writer, LoggingEvent loggingEvent)
{
- try
+ try
{
m_dateFormatter.FormatDate(loggingEvent.TimeStamp, writer);
}
- catch (Exception ex)
+ catch (Exception ex)
{
LogLog.Error(declaringType, "Error occurred while converting date.", ex);
}
}
- #region Private Static Fields
+ #region Private Static Fields
- /// <summary>
- /// The fully qualified type of the DatePatternConverter class.
- /// </summary>
- /// <remarks>
- /// Used by the internal logger to record the Type of the
- /// log message.
- /// </remarks>
- private static readonly Type declaringType = typeof(DatePatternConverter);
+ /// <summary>
+ /// The fully qualified type of the DatePatternConverter class.
+ /// </summary>
+ /// <remarks>
+ /// Used by the internal logger to record the Type of the
+ /// log message.
+ /// </remarks>
+ private static readonly Type declaringType = typeof(DatePatternConverter);
- #endregion Private Static Fields
+ #endregion Private Static Fields
}
}
diff --git a/src/log4net/Layout/Pattern/ExceptionPatternConverter.cs b/src/log4net/Layout/Pattern/ExceptionPatternConverter.cs
index 275959b..b2262d4 100644
--- a/src/log4net/Layout/Pattern/ExceptionPatternConverter.cs
+++ b/src/log4net/Layout/Pattern/ExceptionPatternConverter.cs
@@ -40,7 +40,7 @@
/// </para>
/// </remarks>
/// <author>Nicko Cadell</author>
- internal sealed class ExceptionPatternConverter : PatternLayoutConverter
+ internal sealed class ExceptionPatternConverter : PatternLayoutConverter
{
/// <summary>
/// Default constructor
@@ -123,7 +123,7 @@
else
{
string exceptionString = loggingEvent.GetExceptionString();
- if (exceptionString != null && exceptionString.Length > 0)
+ if (exceptionString != null && exceptionString.Length > 0)
{
writer.WriteLine(exceptionString);
}
diff --git a/src/log4net/Layout/Pattern/FileLocationPatternConverter.cs b/src/log4net/Layout/Pattern/FileLocationPatternConverter.cs
index 7f87e75..a1d818d 100644
--- a/src/log4net/Layout/Pattern/FileLocationPatternConverter.cs
+++ b/src/log4net/Layout/Pattern/FileLocationPatternConverter.cs
@@ -35,7 +35,7 @@
/// </para>
/// </remarks>
/// <author>Nicko Cadell</author>
- internal sealed class FileLocationPatternConverter : PatternLayoutConverter
+ internal sealed class FileLocationPatternConverter : PatternLayoutConverter
{
/// <summary>
/// Write the caller location file name to the output
diff --git a/src/log4net/Layout/Pattern/FullLocationPatternConverter.cs b/src/log4net/Layout/Pattern/FullLocationPatternConverter.cs
index bb39c0d..1da7519 100644
--- a/src/log4net/Layout/Pattern/FullLocationPatternConverter.cs
+++ b/src/log4net/Layout/Pattern/FullLocationPatternConverter.cs
@@ -34,7 +34,7 @@
/// </para>
/// </remarks>
/// <author>Nicko Cadell</author>
- internal sealed class FullLocationPatternConverter : PatternLayoutConverter
+ internal sealed class FullLocationPatternConverter : PatternLayoutConverter
{
/// <summary>
/// Write the caller location info to the output
@@ -48,7 +48,7 @@
/// </remarks>
protected override void Convert(TextWriter writer, LoggingEvent loggingEvent)
{
- writer.Write( loggingEvent.LocationInformation.FullInfo );
+ writer.Write(loggingEvent.LocationInformation.FullInfo);
}
}
}
diff --git a/src/log4net/Layout/Pattern/IdentityPatternConverter.cs b/src/log4net/Layout/Pattern/IdentityPatternConverter.cs
index c13a788..62db1c3 100644
--- a/src/log4net/Layout/Pattern/IdentityPatternConverter.cs
+++ b/src/log4net/Layout/Pattern/IdentityPatternConverter.cs
@@ -36,7 +36,7 @@
/// </remarks>
/// <author>Daniel Cazzulino</author>
/// <author>Nicko Cadell</author>
- internal sealed class IdentityPatternConverter : PatternLayoutConverter
+ internal sealed class IdentityPatternConverter : PatternLayoutConverter
{
/// <summary>
/// Writes the event identity to the output
diff --git a/src/log4net/Layout/Pattern/LevelPatternConverter.cs b/src/log4net/Layout/Pattern/LevelPatternConverter.cs
index 75b57ec..2e75693 100644
--- a/src/log4net/Layout/Pattern/LevelPatternConverter.cs
+++ b/src/log4net/Layout/Pattern/LevelPatternConverter.cs
@@ -35,7 +35,7 @@
/// </para>
/// </remarks>
/// <author>Nicko Cadell</author>
- internal sealed class LevelPatternConverter : PatternLayoutConverter
+ internal sealed class LevelPatternConverter : PatternLayoutConverter
{
/// <summary>
/// Write the event level to the output
@@ -50,7 +50,7 @@
/// </remarks>
protected override void Convert(TextWriter writer, LoggingEvent loggingEvent)
{
- writer.Write( loggingEvent.Level.DisplayName );
+ writer.Write(loggingEvent.Level.DisplayName);
}
}
}
diff --git a/src/log4net/Layout/Pattern/LineLocationPatternConverter.cs b/src/log4net/Layout/Pattern/LineLocationPatternConverter.cs
index b9ce0a3..d1f3e3a 100644
--- a/src/log4net/Layout/Pattern/LineLocationPatternConverter.cs
+++ b/src/log4net/Layout/Pattern/LineLocationPatternConverter.cs
@@ -35,7 +35,7 @@
/// </para>
/// </remarks>
/// <author>Nicko Cadell</author>
- internal sealed class LineLocationPatternConverter : PatternLayoutConverter
+ internal sealed class LineLocationPatternConverter : PatternLayoutConverter
{
/// <summary>
/// Write the caller location line number to the output
diff --git a/src/log4net/Layout/Pattern/LoggerPatternConverter.cs b/src/log4net/Layout/Pattern/LoggerPatternConverter.cs
index 087ab01..fe5845a 100644
--- a/src/log4net/Layout/Pattern/LoggerPatternConverter.cs
+++ b/src/log4net/Layout/Pattern/LoggerPatternConverter.cs
@@ -34,7 +34,7 @@
/// </para>
/// </remarks>
/// <author>Nicko Cadell</author>
- internal sealed class LoggerPatternConverter : NamedPatternConverter
+ internal sealed class LoggerPatternConverter : NamedPatternConverter
{
/// <summary>
/// Gets the fully qualified name of the logger
@@ -46,7 +46,7 @@
/// Returns the <see cref="LoggingEvent.LoggerName"/> of the <paramref name="loggingEvent"/>.
/// </para>
/// </remarks>
- protected override string GetFullyQualifiedName(LoggingEvent loggingEvent)
+ protected override string GetFullyQualifiedName(LoggingEvent loggingEvent)
{
return loggingEvent.LoggerName;
}
diff --git a/src/log4net/Layout/Pattern/MessagePatternConverter.cs b/src/log4net/Layout/Pattern/MessagePatternConverter.cs
index 25fc421..d9cf372 100644
--- a/src/log4net/Layout/Pattern/MessagePatternConverter.cs
+++ b/src/log4net/Layout/Pattern/MessagePatternConverter.cs
@@ -35,7 +35,7 @@
/// </para>
/// </remarks>
/// <author>Nicko Cadell</author>
- internal sealed class MessagePatternConverter : PatternLayoutConverter
+ internal sealed class MessagePatternConverter : PatternLayoutConverter
{
/// <summary>
/// Writes the event message to the output
diff --git a/src/log4net/Layout/Pattern/MethodLocationPatternConverter.cs b/src/log4net/Layout/Pattern/MethodLocationPatternConverter.cs
index cbbbc6d..3c935d5 100644
--- a/src/log4net/Layout/Pattern/MethodLocationPatternConverter.cs
+++ b/src/log4net/Layout/Pattern/MethodLocationPatternConverter.cs
@@ -35,7 +35,7 @@
/// </para>
/// </remarks>
/// <author>Nicko Cadell</author>
- internal sealed class MethodLocationPatternConverter : PatternLayoutConverter
+ internal sealed class MethodLocationPatternConverter : PatternLayoutConverter
{
/// <summary>
/// Write the method name to the output
diff --git a/src/log4net/Layout/Pattern/NamedPatternConverter.cs b/src/log4net/Layout/Pattern/NamedPatternConverter.cs
index 2fba1f5..8512a9a 100644
--- a/src/log4net/Layout/Pattern/NamedPatternConverter.cs
+++ b/src/log4net/Layout/Pattern/NamedPatternConverter.cs
@@ -68,7 +68,7 @@
{
m_precision = 0;
- if (Option != null)
+ if (Option != null)
{
string optStr = Option.Trim();
if (optStr.Length > 0)
@@ -76,7 +76,7 @@
int precisionVal;
if (SystemInfo.TryParse(optStr, out precisionVal))
{
- if (precisionVal <= 0)
+ if (precisionVal <= 0)
{
LogLog.Error(declaringType, "NamedPatternConverter: Precision option (" + optStr + ") isn't a positive integer.");
}
@@ -84,7 +84,7 @@
{
m_precision = precisionVal;
}
- }
+ }
else
{
LogLog.Error(declaringType, "NamedPatternConverter: Precision option \"" + optStr + "\" not a decimal integer.");
@@ -110,7 +110,7 @@
/// </para>
/// </remarks>
protected abstract string GetFullyQualifiedName(LoggingEvent loggingEvent);
-
+
/// <summary>
/// Convert the pattern to the rendered message
/// </summary>
@@ -127,45 +127,45 @@
{
writer.Write(name);
}
- else
+ else
{
int len = name.Length;
- string trailingDot = string.Empty;
- if (name.EndsWith(DOT))
- {
- trailingDot = DOT;
- name = name.Substring(0, len - 1);
- len--;
- }
-
- int end = name.LastIndexOf(DOT);
- for(int i = 1; end > 0 && i < m_precision; i++)
+ string trailingDot = string.Empty;
+ if (name.EndsWith(DOT))
{
- end = name.LastIndexOf('.', end - 1);
- }
- if (end == -1)
- {
- writer.Write(name + trailingDot);
- }
- else
- {
- writer.Write(name.Substring(end + 1, len - end - 1) + trailingDot);
- }
- }
+ trailingDot = DOT;
+ name = name.Substring(0, len - 1);
+ len--;
+ }
+
+ int end = name.LastIndexOf(DOT);
+ for (int i = 1; end > 0 && i < m_precision; i++)
+ {
+ end = name.LastIndexOf('.', end - 1);
+ }
+ if (end == -1)
+ {
+ writer.Write(name + trailingDot);
+ }
+ else
+ {
+ writer.Write(name.Substring(end + 1, len - end - 1) + trailingDot);
+ }
+ }
}
- #region Private Static Fields
+ #region Private Static Fields
- /// <summary>
- /// The fully qualified type of the NamedPatternConverter class.
- /// </summary>
- /// <remarks>
- /// Used by the internal logger to record the Type of the
- /// log message.
- /// </remarks>
- private static readonly Type declaringType = typeof(NamedPatternConverter);
+ /// <summary>
+ /// The fully qualified type of the NamedPatternConverter class.
+ /// </summary>
+ /// <remarks>
+ /// Used by the internal logger to record the Type of the
+ /// log message.
+ /// </remarks>
+ private static readonly Type declaringType = typeof(NamedPatternConverter);
- private const string DOT = ".";
- #endregion Private Static Fields
+ private const string DOT = ".";
+ #endregion Private Static Fields
}
}
diff --git a/src/log4net/Layout/Pattern/NdcPatternConverter.cs b/src/log4net/Layout/Pattern/NdcPatternConverter.cs
index edf1ff1..a64dbb9 100644
--- a/src/log4net/Layout/Pattern/NdcPatternConverter.cs
+++ b/src/log4net/Layout/Pattern/NdcPatternConverter.cs
@@ -37,7 +37,7 @@
/// </para>
/// </remarks>
/// <author>Nicko Cadell</author>
- internal sealed class NdcPatternConverter : PatternLayoutConverter
+ internal sealed class NdcPatternConverter : PatternLayoutConverter
{
/// <summary>
/// Write the event NDC to the output
diff --git a/src/log4net/Layout/Pattern/PatternLayoutConverter.cs b/src/log4net/Layout/Pattern/PatternLayoutConverter.cs
index 4886f7f..2337149 100644
--- a/src/log4net/Layout/Pattern/PatternLayoutConverter.cs
+++ b/src/log4net/Layout/Pattern/PatternLayoutConverter.cs
@@ -45,8 +45,8 @@
/// <summary>
/// Initializes a new instance of the <see cref="PatternLayoutConverter" /> class.
/// </summary>
- protected PatternLayoutConverter()
- {
+ protected PatternLayoutConverter()
+ {
}
#endregion Protected Instance Constructors
@@ -69,8 +69,8 @@
/// value is <c>true</c>, this converter does not handle the exception.
/// </para>
/// </remarks>
- public virtual bool IgnoresException
- {
+ public virtual bool IgnoresException
+ {
get { return m_ignoresException; }
set { m_ignoresException = value; }
}
@@ -106,7 +106,7 @@
}
else
{
- throw new ArgumentException("state must be of type ["+typeof(LoggingEvent).FullName+"]", "state");
+ throw new ArgumentException("state must be of type [" + typeof(LoggingEvent).FullName + "]", "state");
}
}
diff --git a/src/log4net/Layout/Pattern/PropertyPatternConverter.cs b/src/log4net/Layout/Pattern/PropertyPatternConverter.cs
index 1857f03..bb66c96 100644
--- a/src/log4net/Layout/Pattern/PropertyPatternConverter.cs
+++ b/src/log4net/Layout/Pattern/PropertyPatternConverter.cs
@@ -42,7 +42,7 @@
/// </para>
/// </remarks>
/// <author>Nicko Cadell</author>
- internal sealed class PropertyPatternConverter : PatternLayoutConverter
+ internal sealed class PropertyPatternConverter : PatternLayoutConverter
{
/// <summary>
/// Write the property value to the output
diff --git a/src/log4net/Layout/Pattern/RelativeTimePatternConverter.cs b/src/log4net/Layout/Pattern/RelativeTimePatternConverter.cs
index 7020400..29f7982 100644
--- a/src/log4net/Layout/Pattern/RelativeTimePatternConverter.cs
+++ b/src/log4net/Layout/Pattern/RelativeTimePatternConverter.cs
@@ -34,7 +34,7 @@
/// </para>
/// </remarks>
/// <author>Nicko Cadell</author>
- internal sealed class RelativeTimePatternConverter : PatternLayoutConverter
+ internal sealed class RelativeTimePatternConverter : PatternLayoutConverter
{
/// <summary>
/// Write the relative time to the output
@@ -50,7 +50,7 @@
/// </remarks>
protected override void Convert(TextWriter writer, LoggingEvent loggingEvent)
{
- writer.Write( TimeDifferenceInMillis(LoggingEvent.StartTimeUtc, loggingEvent.TimeStampUtc).ToString(System.Globalization.NumberFormatInfo.InvariantInfo) );
+ writer.Write(TimeDifferenceInMillis(LoggingEvent.StartTimeUtc, loggingEvent.TimeStampUtc).ToString(System.Globalization.NumberFormatInfo.InvariantInfo));
}
/// <summary>
diff --git a/src/log4net/Layout/Pattern/StackTraceDetailPatternConverter.cs b/src/log4net/Layout/Pattern/StackTraceDetailPatternConverter.cs
index 9e020cb..a97a1b5 100644
--- a/src/log4net/Layout/Pattern/StackTraceDetailPatternConverter.cs
+++ b/src/log4net/Layout/Pattern/StackTraceDetailPatternConverter.cs
@@ -28,63 +28,63 @@
namespace log4net.Layout.Pattern
{
- /// <summary>
- /// Write the caller stack frames to the output
- /// </summary>
- /// <remarks>
- /// <para>
- /// Writes the <see cref="LocationInfo.StackFrames"/> to the output writer, using format:
- /// type3.MethodCall3(type param,...) > type2.MethodCall2(type param,...) > type1.MethodCall1(type param,...)
- /// </para>
- /// </remarks>
- /// <author>Adam Davies</author>
- internal class StackTraceDetailPatternConverter : StackTracePatternConverter
+ /// <summary>
+ /// Write the caller stack frames to the output
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Writes the <see cref="LocationInfo.StackFrames"/> to the output writer, using format:
+ /// type3.MethodCall3(type param,...) > type2.MethodCall2(type param,...) > type1.MethodCall1(type param,...)
+ /// </para>
+ /// </remarks>
+ /// <author>Adam Davies</author>
+ internal class StackTraceDetailPatternConverter : StackTracePatternConverter
+ {
+ internal override string GetMethodInformation(MethodItem method)
{
- internal override string GetMethodInformation(MethodItem method)
+ string returnValue = "";
+
+ try
+ {
+ string param = "";
+ string[] names = method.Parameters;
+ StringBuilder sb = new StringBuilder();
+ if (names != null && names.GetUpperBound(0) > 0)
{
- string returnValue="";
-
- try
- {
- string param = "";
- string[] names = method.Parameters;
- StringBuilder sb = new StringBuilder();
- if (names != null && names.GetUpperBound(0) > 0)
- {
- for (int i = 0; i <= names.GetUpperBound(0); i++)
- {
- sb.AppendFormat("{0}, ", names[i]);
- }
- }
-
- if (sb.Length > 0)
- {
- sb.Remove(sb.Length - 2, 2);
- param = sb.ToString();
- }
-
- returnValue=base.GetMethodInformation(method) + "(" + param + ")";
- }
- catch (Exception ex)
- {
- LogLog.Error(declaringType, "An exception ocurred while retreiving method information.", ex);
- }
-
- return returnValue;
+ for (int i = 0; i <= names.GetUpperBound(0); i++)
+ {
+ sb.AppendFormat("{0}, ", names[i]);
+ }
}
- #region Private Static Fields
+ if (sb.Length > 0)
+ {
+ sb.Remove(sb.Length - 2, 2);
+ param = sb.ToString();
+ }
- /// <summary>
- /// The fully qualified type of the StackTraceDetailPatternConverter class.
- /// </summary>
- /// <remarks>
- /// Used by the internal logger to record the Type of the
- /// log message.
- /// </remarks>
- private static readonly Type declaringType = typeof(StackTracePatternConverter);
+ returnValue = base.GetMethodInformation(method) + "(" + param + ")";
+ }
+ catch (Exception ex)
+ {
+ LogLog.Error(declaringType, "An exception ocurred while retreiving method information.", ex);
+ }
- #endregion Private Static Fields
+ return returnValue;
}
+
+ #region Private Static Fields
+
+ /// <summary>
+ /// The fully qualified type of the StackTraceDetailPatternConverter class.
+ /// </summary>
+ /// <remarks>
+ /// Used by the internal logger to record the Type of the
+ /// log message.
+ /// </remarks>
+ private static readonly Type declaringType = typeof(StackTracePatternConverter);
+
+ #endregion Private Static Fields
+ }
}
#endif // !NETCF && NET_2_0
\ No newline at end of file
diff --git a/src/log4net/Layout/Pattern/StackTracePatternConverter.cs b/src/log4net/Layout/Pattern/StackTracePatternConverter.cs
index 022113c..df3ccb5 100644
--- a/src/log4net/Layout/Pattern/StackTracePatternConverter.cs
+++ b/src/log4net/Layout/Pattern/StackTracePatternConverter.cs
@@ -38,7 +38,7 @@
internal class StackTracePatternConverter : PatternLayoutConverter, IOptionHandler
{
private int m_stackFrameLevel = 1;
-
+
/// <summary>
/// Initialize the converter
/// </summary>
@@ -59,14 +59,14 @@
{
if (Option == null)
return;
-
+
string optStr = Option.Trim();
if (optStr.Length != 0)
{
int stackLevelVal;
if (SystemInfo.TryParse(optStr, out stackLevelVal))
{
- if (stackLevelVal <= 0)
+ if (stackLevelVal <= 0)
{
LogLog.Error(declaringType, "StackTracePatternConverter: StackeFrameLevel option (" + optStr + ") isn't a positive integer.");
}
@@ -74,14 +74,14 @@
{
m_stackFrameLevel = stackLevelVal;
}
- }
+ }
else
{
LogLog.Error(declaringType, "StackTracePatternConverter: StackFrameLevel option \"" + optStr + "\" not a decimal integer.");
}
}
}
-
+
/// <summary>
/// Write the strack frames to the output
/// </summary>
@@ -100,7 +100,7 @@
LogLog.Error(declaringType, "loggingEvent.LocationInformation.StackFrames was null or empty.");
return;
}
-
+
int stackFrameIndex = m_stackFrameLevel - 1;
while (stackFrameIndex >= 0)
{
@@ -109,41 +109,41 @@
stackFrameIndex--;
continue;
}
-
+
StackFrameItem stackFrame = stackframes[stackFrameIndex];
- writer.Write("{0}.{1}", stackFrame.ClassName, GetMethodInformation(stackFrame.Method));
+ writer.Write("{0}.{1}", stackFrame.ClassName, GetMethodInformation(stackFrame.Method));
if (stackFrameIndex > 0)
{
- // TODO: make this user settable?
+ // TODO: make this user settable?
writer.Write(" > ");
}
stackFrameIndex--;
}
}
- /// <summary>
- /// Returns the Name of the method
- /// </summary>
- /// <param name="method"></param>
- /// <remarks>This method was created, so this class could be used as a base class for StackTraceDetailPatternConverter</remarks>
- /// <returns>string</returns>
- internal virtual string GetMethodInformation(MethodItem method)
- {
- return method.Name;
- }
-
+ /// <summary>
+ /// Returns the Name of the method
+ /// </summary>
+ /// <param name="method"></param>
+ /// <remarks>This method was created, so this class could be used as a base class for StackTraceDetailPatternConverter</remarks>
+ /// <returns>string</returns>
+ internal virtual string GetMethodInformation(MethodItem method)
+ {
+ return method.Name;
+ }
+
#region Private Static Fields
- /// <summary>
- /// The fully qualified type of the StackTracePatternConverter class.
- /// </summary>
- /// <remarks>
- /// Used by the internal logger to record the Type of the
- /// log message.
- /// </remarks>
- private static readonly Type declaringType = typeof(StackTracePatternConverter);
+ /// <summary>
+ /// The fully qualified type of the StackTracePatternConverter class.
+ /// </summary>
+ /// <remarks>
+ /// Used by the internal logger to record the Type of the
+ /// log message.
+ /// </remarks>
+ private static readonly Type declaringType = typeof(StackTracePatternConverter);
- #endregion Private Static Fields
+ #endregion Private Static Fields
}
}
#endif // !NETCF && NET_2_0
diff --git a/src/log4net/Layout/Pattern/ThreadPatternConverter.cs b/src/log4net/Layout/Pattern/ThreadPatternConverter.cs
index faae9a9..4d5ce45 100644
--- a/src/log4net/Layout/Pattern/ThreadPatternConverter.cs
+++ b/src/log4net/Layout/Pattern/ThreadPatternConverter.cs
@@ -34,7 +34,7 @@
/// </para>
/// </remarks>
/// <author>Nicko Cadell</author>
- internal sealed class ThreadPatternConverter : PatternLayoutConverter
+ internal sealed class ThreadPatternConverter : PatternLayoutConverter
{
/// <summary>
/// Write the ThreadName to the output
diff --git a/src/log4net/Layout/Pattern/TypeNamePatternConverter.cs b/src/log4net/Layout/Pattern/TypeNamePatternConverter.cs
index faa47d2..e65b1a5 100644
--- a/src/log4net/Layout/Pattern/TypeNamePatternConverter.cs
+++ b/src/log4net/Layout/Pattern/TypeNamePatternConverter.cs
@@ -34,7 +34,7 @@
/// </para>
/// </remarks>
/// <author>Nicko Cadell</author>
- internal sealed class TypeNamePatternConverter : NamedPatternConverter
+ internal sealed class TypeNamePatternConverter : NamedPatternConverter
{
/// <summary>
/// Gets the fully qualified name of the class
@@ -46,18 +46,18 @@
/// Returns the <see cref="LocationInfo.ClassName"/> of the <paramref name="loggingEvent"/>.
/// </para>
/// </remarks>
- protected override string GetFullyQualifiedName(LoggingEvent loggingEvent)
+ protected override string GetFullyQualifiedName(LoggingEvent loggingEvent)
{
if (loggingEvent == null)
{
return string.Empty;
}
-
+
if (loggingEvent.LocationInformation == null)
{
return string.Empty;
}
-
+
return loggingEvent.LocationInformation.ClassName;
}
}
diff --git a/src/log4net/Layout/Pattern/UserNamePatternConverter.cs b/src/log4net/Layout/Pattern/UserNamePatternConverter.cs
index 932f40d..1b2c49a 100644
--- a/src/log4net/Layout/Pattern/UserNamePatternConverter.cs
+++ b/src/log4net/Layout/Pattern/UserNamePatternConverter.cs
@@ -30,7 +30,7 @@
/// </summary>
/// <author>Douglas de la Torre</author>
/// <author>Nicko Cadell</author>
- internal sealed class UserNamePatternConverter : PatternLayoutConverter
+ internal sealed class UserNamePatternConverter : PatternLayoutConverter
{
/// <summary>
/// Convert the pattern to the rendered message
@@ -39,7 +39,7 @@
/// <param name="loggingEvent">the event being logged</param>
protected override void Convert(TextWriter writer, LoggingEvent loggingEvent)
{
- writer.Write( loggingEvent.UserName );
+ writer.Write(loggingEvent.UserName);
}
}
}
diff --git a/src/log4net/Layout/Pattern/UtcDatePatternConverter.cs b/src/log4net/Layout/Pattern/UtcDatePatternConverter.cs
index 5e6b912..c4ba2d1 100644
--- a/src/log4net/Layout/Pattern/UtcDatePatternConverter.cs
+++ b/src/log4net/Layout/Pattern/UtcDatePatternConverter.cs
@@ -65,27 +65,27 @@
/// <seealso cref="DatePatternConverter"/>
protected override void Convert(TextWriter writer, LoggingEvent loggingEvent)
{
- try
+ try
{
m_dateFormatter.FormatDate(loggingEvent.TimeStampUtc, writer);
}
- catch (Exception ex)
+ catch (Exception ex)
{
LogLog.Error(declaringType, "Error occurred while converting date.", ex);
}
}
- #region Private Static Fields
+ #region Private Static Fields
- /// <summary>
- /// The fully qualified type of the UtcDatePatternConverter class.
- /// </summary>
- /// <remarks>
- /// Used by the internal logger to record the Type of the
- /// log message.
- /// </remarks>
- private static readonly Type declaringType = typeof(UtcDatePatternConverter);
+ /// <summary>
+ /// The fully qualified type of the UtcDatePatternConverter class.
+ /// </summary>
+ /// <remarks>
+ /// Used by the internal logger to record the Type of the
+ /// log message.
+ /// </remarks>
+ private static readonly Type declaringType = typeof(UtcDatePatternConverter);
- #endregion Private Static Fields
+ #endregion Private Static Fields
}
}
diff --git a/src/log4net/Layout/PatternLayout.cs b/src/log4net/Layout/PatternLayout.cs
index 60a1495..bbf131c 100644
--- a/src/log4net/Layout/PatternLayout.cs
+++ b/src/log4net/Layout/PatternLayout.cs
@@ -25,12 +25,12 @@
using log4net.Layout.Pattern;
using log4net.Util;
using log4net.Util.PatternStringConverters;
-using AppDomainPatternConverter=log4net.Layout.Pattern.AppDomainPatternConverter;
-using DatePatternConverter=log4net.Layout.Pattern.DatePatternConverter;
-using IdentityPatternConverter=log4net.Layout.Pattern.IdentityPatternConverter;
-using PropertyPatternConverter=log4net.Layout.Pattern.PropertyPatternConverter;
-using UserNamePatternConverter=log4net.Layout.Pattern.UserNamePatternConverter;
-using UtcDatePatternConverter=log4net.Layout.Pattern.UtcDatePatternConverter;
+using AppDomainPatternConverter = log4net.Layout.Pattern.AppDomainPatternConverter;
+using DatePatternConverter = log4net.Layout.Pattern.DatePatternConverter;
+using IdentityPatternConverter = log4net.Layout.Pattern.IdentityPatternConverter;
+using PropertyPatternConverter = log4net.Layout.Pattern.PropertyPatternConverter;
+using UserNamePatternConverter = log4net.Layout.Pattern.UserNamePatternConverter;
+using UtcDatePatternConverter = log4net.Layout.Pattern.UtcDatePatternConverter;
namespace log4net.Layout
{
@@ -106,46 +106,46 @@
/// <item>
/// <term>aspnet-cache</term>
/// <description>
- /// <para>
- /// Used to output all cache items in the case of <b>%aspnet-cache</b> or just one named item if used as <b>%aspnet-cache{key}</b>
- /// </para>
- /// <para>
- /// This pattern is not available for Compact Framework or Client Profile assemblies.
- /// </para>
+ /// <para>
+ /// Used to output all cache items in the case of <b>%aspnet-cache</b> or just one named item if used as <b>%aspnet-cache{key}</b>
+ /// </para>
+ /// <para>
+ /// This pattern is not available for Compact Framework or Client Profile assemblies.
+ /// </para>
/// </description>
/// </item>
/// <item>
/// <term>aspnet-context</term>
/// <description>
- /// <para>
- /// Used to output all context items in the case of <b>%aspnet-context</b> or just one named item if used as <b>%aspnet-context{key}</b>
- /// </para>
- /// <para>
- /// This pattern is not available for Compact Framework or Client Profile assemblies.
- /// </para>
- /// </description>
+ /// <para>
+ /// Used to output all context items in the case of <b>%aspnet-context</b> or just one named item if used as <b>%aspnet-context{key}</b>
+ /// </para>
+ /// <para>
+ /// This pattern is not available for Compact Framework or Client Profile assemblies.
+ /// </para>
+ /// </description>
/// </item>
/// <item>
/// <term>aspnet-request</term>
/// <description>
- /// <para>
- /// Used to output all request parameters in the case of <b>%aspnet-request</b> or just one named param if used as <b>%aspnet-request{key}</b>
- /// </para>
- /// <para>
- /// This pattern is not available for Compact Framework or Client Profile assemblies.
- /// </para>
- /// </description>
+ /// <para>
+ /// Used to output all request parameters in the case of <b>%aspnet-request</b> or just one named param if used as <b>%aspnet-request{key}</b>
+ /// </para>
+ /// <para>
+ /// This pattern is not available for Compact Framework or Client Profile assemblies.
+ /// </para>
+ /// </description>
/// </item>
/// <item>
/// <term>aspnet-session</term>
/// <description>
- /// <para>
- /// Used to output all session items in the case of <b>%aspnet-session</b> or just one named item if used as <b>%aspnet-session{key}</b>
- /// </para>
- /// <para>
- /// This pattern is not available for Compact Framework or Client Profile assemblies.
- /// </para>
- /// </description>
+ /// <para>
+ /// Used to output all session items in the case of <b>%aspnet-session</b> or just one named item if used as <b>%aspnet-session{key}</b>
+ /// </para>
+ /// <para>
+ /// This pattern is not available for Compact Framework or Client Profile assemblies.
+ /// </para>
+ /// </description>
/// </item>
/// <item>
/// <term>c</term>
@@ -466,34 +466,34 @@
/// between braces. For example, <b>%stacktrace{level}</b>.
/// If no stack trace level specifier is given then 1 is assumed
/// </para>
- /// <para>
- /// Output uses the format:
- /// type3.MethodCall3 > type2.MethodCall2 > type1.MethodCall1
- /// </para>
- /// <para>
- /// This pattern is not available for Compact Framework assemblies.
- /// </para>
- /// </description>
+ /// <para>
+ /// Output uses the format:
+ /// type3.MethodCall3 > type2.MethodCall2 > type1.MethodCall1
+ /// </para>
+ /// <para>
+ /// This pattern is not available for Compact Framework assemblies.
+ /// </para>
+ /// </description>
/// </item>
- /// <item>
- /// <term>stacktracedetail</term>
- /// <description>
- /// <para>
- /// Used to output the stack trace of the logging event
- /// The stack trace level specifier may be enclosed
- /// between braces. For example, <b>%stacktracedetail{level}</b>.
- /// If no stack trace level specifier is given then 1 is assumed
- /// </para>
- /// <para>
- /// Output uses the format:
- /// type3.MethodCall3(type param,...) > type2.MethodCall2(type param,...) > type1.MethodCall1(type param,...)
- /// </para>
- /// <para>
- /// This pattern is not available for Compact Framework assemblies.
- /// </para>
- /// </description>
- /// </item>
- /// <item>
+ /// <item>
+ /// <term>stacktracedetail</term>
+ /// <description>
+ /// <para>
+ /// Used to output the stack trace of the logging event
+ /// The stack trace level specifier may be enclosed
+ /// between braces. For example, <b>%stacktracedetail{level}</b>.
+ /// If no stack trace level specifier is given then 1 is assumed
+ /// </para>
+ /// <para>
+ /// Output uses the format:
+ /// type3.MethodCall3(type param,...) > type2.MethodCall2(type param,...) > type1.MethodCall1(type param,...)
+ /// </para>
+ /// <para>
+ /// This pattern is not available for Compact Framework assemblies.
+ /// </para>
+ /// </description>
+ /// </item>
+ /// <item>
/// <term>t</term>
/// <description>Equivalent to <b>thread</b></description>
/// </item>
@@ -793,7 +793,7 @@
/// which just prints the application supplied message.
/// </para>
/// </remarks>
- public const string DefaultConversionPattern ="%message%newline";
+ public const string DefaultConversionPattern = "%message%newline";
/// <summary>
/// A detailed conversion pattern
@@ -823,12 +823,12 @@
#endregion Static Fields
#region Member Variables
-
+
/// <summary>
/// the pattern
/// </summary>
private string m_pattern;
-
+
/// <summary>
/// the head of the pattern converter chain
/// </summary>
@@ -859,8 +859,8 @@
s_globalRulesRegistry.Add("newline", typeof(NewLinePatternConverter));
s_globalRulesRegistry.Add("n", typeof(NewLinePatternConverter));
-// .NET Compact Framework 1.0 has no support for ASP.NET
-// SSCLI 1.0 has no support for ASP.NET
+ // .NET Compact Framework 1.0 has no support for ASP.NET
+ // SSCLI 1.0 has no support for ASP.NET
#if !NETCF && !SSCLI && !CLIENT_PROFILE && !NETSTANDARD
s_globalRulesRegistry.Add("aspnet-cache", typeof(AspNetCachePatternConverter));
s_globalRulesRegistry.Add("aspnet-context", typeof(AspNetContextPatternConverter));
@@ -904,10 +904,10 @@
s_globalRulesRegistry.Add("r", typeof(RelativeTimePatternConverter));
s_globalRulesRegistry.Add("timestamp", typeof(RelativeTimePatternConverter));
-
+
#if !NETCF && !NETSTANDARD1_3
s_globalRulesRegistry.Add("stacktrace", typeof(StackTracePatternConverter));
- s_globalRulesRegistry.Add("stacktracedetail", typeof(StackTraceDetailPatternConverter));
+ s_globalRulesRegistry.Add("stacktracedetail", typeof(StackTraceDetailPatternConverter));
#endif
s_globalRulesRegistry.Add("t", typeof(ThreadPatternConverter));
@@ -976,7 +976,7 @@
/// need not be called. This may not be the case when using a subclass.
/// </para>
/// </remarks>
- public PatternLayout(string pattern)
+ public PatternLayout(string pattern)
{
// By default we do not process the exception
IgnoresException = true;
@@ -991,7 +991,7 @@
}
#endregion
-
+
/// <summary>
/// The pattern formatting string
/// </summary>
@@ -1004,7 +1004,7 @@
/// </remarks>
public string ConversionPattern
{
- get { return m_pattern; }
+ get { return m_pattern; }
set { m_pattern = value; }
}
@@ -1019,27 +1019,27 @@
/// global and instance rules on the <see cref="PatternParser"/>.
/// </para>
/// </remarks>
- protected virtual PatternParser CreatePatternParser(string pattern)
+ protected virtual PatternParser CreatePatternParser(string pattern)
{
PatternParser patternParser = new PatternParser(pattern);
// Add all the builtin patterns
- foreach(DictionaryEntry entry in s_globalRulesRegistry)
+ foreach (DictionaryEntry entry in s_globalRulesRegistry)
{
- ConverterInfo converterInfo = new ConverterInfo();
- converterInfo.Name = (string)entry.Key;
- converterInfo.Type = (Type)entry.Value;
- patternParser.PatternConverters[entry.Key] = converterInfo;
+ ConverterInfo converterInfo = new ConverterInfo();
+ converterInfo.Name = (string)entry.Key;
+ converterInfo.Type = (Type)entry.Value;
+ patternParser.PatternConverters[entry.Key] = converterInfo;
}
// Add the instance patterns
- foreach(DictionaryEntry entry in m_instanceRulesRegistry)
+ foreach (DictionaryEntry entry in m_instanceRulesRegistry)
{
patternParser.PatternConverters[entry.Key] = entry.Value;
}
return patternParser;
}
-
+
#region Implementation of IOptionHandler
/// <summary>
@@ -1058,12 +1058,12 @@
/// <see cref="ActivateOptions"/> must be called again.
/// </para>
/// </remarks>
- public override void ActivateOptions()
+ public override void ActivateOptions()
{
m_head = CreatePatternParser(m_pattern).Parse();
PatternConverter curConverter = m_head;
- while(curConverter != null)
+ while (curConverter != null)
{
PatternLayoutConverter layoutConverter = curConverter as PatternLayoutConverter;
if (layoutConverter != null)
@@ -1095,7 +1095,7 @@
/// specified in the <see cref="ConversionPattern"/> property.
/// </para>
/// </remarks>
- public override void Format(TextWriter writer, LoggingEvent loggingEvent)
+ public override void Format(TextWriter writer, LoggingEvent loggingEvent)
{
if (writer == null)
{
@@ -1109,7 +1109,7 @@
PatternConverter c = m_head;
// loop through the chain of pattern converters
- while(c != null)
+ while (c != null)
{
c.Format(writer, loggingEvent);
c = c.Next;
@@ -1130,13 +1130,13 @@
/// </remarks>
public void AddConverter(ConverterInfo converterInfo)
{
- if (converterInfo == null) throw new ArgumentNullException("converterInfo");
+ if (converterInfo == null) throw new ArgumentNullException("converterInfo");
- if (!typeof(PatternConverter).IsAssignableFrom(converterInfo.Type))
- {
- throw new ArgumentException("The converter type specified [" + converterInfo.Type + "] must be a subclass of log4net.Util.PatternConverter", "converterInfo");
- }
- m_instanceRulesRegistry[converterInfo.Name] = converterInfo;
+ if (!typeof(PatternConverter).IsAssignableFrom(converterInfo.Type))
+ {
+ throw new ArgumentException("The converter type specified [" + converterInfo.Type + "] must be a subclass of log4net.Util.PatternConverter", "converterInfo");
+ }
+ m_instanceRulesRegistry[converterInfo.Name] = converterInfo;
}
/// <summary>
@@ -1157,14 +1157,14 @@
/// </remarks>
public void AddConverter(string name, Type type)
{
- if (name == null) throw new ArgumentNullException("name");
- if (type == null) throw new ArgumentNullException("type");
+ if (name == null) throw new ArgumentNullException("name");
+ if (type == null) throw new ArgumentNullException("type");
- ConverterInfo converterInfo = new ConverterInfo();
- converterInfo.Name = name;
- converterInfo.Type = type;
+ ConverterInfo converterInfo = new ConverterInfo();
+ converterInfo.Name = name;
+ converterInfo.Type = type;
- AddConverter(converterInfo);
+ AddConverter(converterInfo);
}
}
}
diff --git a/src/log4net/Layout/RawLayoutConverter.cs b/src/log4net/Layout/RawLayoutConverter.cs
index 3667f81..905d684 100644
--- a/src/log4net/Layout/RawLayoutConverter.cs
+++ b/src/log4net/Layout/RawLayoutConverter.cs
@@ -51,7 +51,7 @@
/// as the <paramref name="sourceType"/>.
/// </para>
/// </remarks>
- public bool CanConvertFrom(Type sourceType)
+ public bool CanConvertFrom(Type sourceType)
{
// Accept an ILayout object
return (typeof(ILayout).IsAssignableFrom(sourceType));
@@ -71,10 +71,10 @@
/// exception is thrown.
/// </para>
/// </remarks>
- public object ConvertFrom(object source)
+ public object ConvertFrom(object source)
{
ILayout layout = source as ILayout;
- if (layout != null)
+ if (layout != null)
{
return new Layout2RawLayoutAdapter(layout);
}
diff --git a/src/log4net/Layout/RawPropertyLayout.cs b/src/log4net/Layout/RawPropertyLayout.cs
index 6c4303e..60b2c6b 100644
--- a/src/log4net/Layout/RawPropertyLayout.cs
+++ b/src/log4net/Layout/RawPropertyLayout.cs
@@ -65,7 +65,7 @@
get { return m_key; }
set { m_key = value; }
}
-
+
#region Implementation of IRawLayout
/// <summary>
diff --git a/src/log4net/Layout/RawTimeStampLayout.cs b/src/log4net/Layout/RawTimeStampLayout.cs
index 81c37b4..e8921dd 100644
--- a/src/log4net/Layout/RawTimeStampLayout.cs
+++ b/src/log4net/Layout/RawTimeStampLayout.cs
@@ -47,7 +47,7 @@
}
#endregion
-
+
#region Implementation of IRawLayout
/// <summary>
diff --git a/src/log4net/Layout/RawUtcTimeStampLayout.cs b/src/log4net/Layout/RawUtcTimeStampLayout.cs
index 55bec72..7694140 100644
--- a/src/log4net/Layout/RawUtcTimeStampLayout.cs
+++ b/src/log4net/Layout/RawUtcTimeStampLayout.cs
@@ -47,7 +47,7 @@
}
#endregion
-
+
#region Implementation of IRawLayout
/// <summary>
diff --git a/src/log4net/Layout/SimpleLayout.cs b/src/log4net/Layout/SimpleLayout.cs
index 8d4640a..99f1138 100644
--- a/src/log4net/Layout/SimpleLayout.cs
+++ b/src/log4net/Layout/SimpleLayout.cs
@@ -53,7 +53,7 @@
}
#endregion
-
+
#region Implementation of IOptionHandler
/// <summary>
@@ -72,7 +72,7 @@
/// <see cref="ActivateOptions"/> must be called again.
/// </para>
/// </remarks>
- public override void ActivateOptions()
+ public override void ActivateOptions()
{
// nothing to do.
}
@@ -93,7 +93,7 @@
/// output is terminated by a newline.
/// </para>
/// </remarks>
- public override void Format(TextWriter writer, LoggingEvent loggingEvent)
+ public override void Format(TextWriter writer, LoggingEvent loggingEvent)
{
if (loggingEvent == null)
{
diff --git a/src/log4net/Layout/XmlLayout.cs b/src/log4net/Layout/XmlLayout.cs
index 15c925e..b30686a 100644
--- a/src/log4net/Layout/XmlLayout.cs
+++ b/src/log4net/Layout/XmlLayout.cs
@@ -97,7 +97,7 @@
/// appender as well.
/// </para>
/// </remarks>
- public XmlLayout(bool locationInfo) : base(locationInfo)
+ public XmlLayout(bool locationInfo) : base(locationInfo)
{
}
@@ -121,7 +121,7 @@
set { m_prefix = value; }
}
-
+
/// <summary>
/// Set whether or not to base64 encode the message.
/// </summary>
@@ -137,8 +137,8 @@
/// </remarks>
public bool Base64EncodeMessage
{
- get {return m_base64Message;}
- set {m_base64Message=value;}
+ get { return m_base64Message; }
+ set { m_base64Message = value; }
}
/// <summary>
@@ -156,8 +156,8 @@
/// </remarks>
public bool Base64EncodeProperties
{
- get {return m_base64Properties;}
- set {m_base64Properties=value;}
+ get { return m_base64Properties; }
+ set { m_base64Properties = value; }
}
#endregion Public Instance Properties
@@ -183,7 +183,7 @@
/// Builds a cache of the element names
/// </para>
/// </remarks>
- public override void ActivateOptions()
+ public override void ActivateOptions()
{
base.ActivateOptions();
@@ -198,7 +198,7 @@
m_elmLocation = m_prefix + ":" + ELM_LOCATION;
}
}
-
+
#endregion Implementation of IOptionHandler
#region Override implementation of XMLLayoutBase
@@ -216,12 +216,12 @@
/// </remarks>
protected override void FormatXml(XmlWriter writer, LoggingEvent loggingEvent)
{
- #if NETSTANDARD
+#if NETSTANDARD
writer.WriteStartElement(m_prefix, ELM_EVENT, m_prefix);
// writer.WriteAttributeString("xmlns", "log4net", null, "http://logging.apache.org/log4net/schemas/log4net-events-1.2");
- #else
+#else
writer.WriteStartElement(m_elmEvent);
- #endif
+#endif
writer.WriteAttributeString(ATTR_LOGGER, loggingEvent.LoggerName);
#if NET_2_0 || NETCF_2_0 || MONO_2_0 || NETSTANDARD
@@ -245,13 +245,13 @@
{
writer.WriteAttributeString(ATTR_USERNAME, loggingEvent.UserName);
}
-
+
// Append the message text
- #if NETSTANDARD
+#if NETSTANDARD
writer.WriteStartElement(m_prefix, ELM_MESSAGE, m_prefix);
- #else
+#else
writer.WriteStartElement(m_elmMessage);
- #endif
+#endif
if (!this.Base64EncodeMessage)
{
Transform.WriteEscapedXmlString(writer, loggingEvent.RenderedMessage, this.InvalidCharReplacement);
@@ -260,7 +260,7 @@
{
byte[] messageBytes = Encoding.UTF8.GetBytes(loggingEvent.RenderedMessage);
string base64Message = Convert.ToBase64String(messageBytes, 0, messageBytes.Length);
- Transform.WriteEscapedXmlString(writer, base64Message,this.InvalidCharReplacement);
+ Transform.WriteEscapedXmlString(writer, base64Message, this.InvalidCharReplacement);
}
writer.WriteEndElement();
@@ -269,25 +269,25 @@
// Append the properties text
if (properties.Count > 0)
{
- #if NETSTANDARD
+#if NETSTANDARD
writer.WriteStartElement(m_prefix, ELM_PROPERTIES, m_prefix);
- #else
+#else
writer.WriteStartElement(m_elmProperties);
- #endif
- foreach(System.Collections.DictionaryEntry entry in properties)
+#endif
+ foreach (System.Collections.DictionaryEntry entry in properties)
{
- #if NETSTANDARD
+#if NETSTANDARD
writer.WriteStartElement(m_prefix, ELM_DATA, m_prefix);
- #else
+#else
writer.WriteStartElement(m_elmData);
- #endif
- writer.WriteAttributeString(ATTR_NAME, Transform.MaskXmlInvalidCharacters((string)entry.Key,this.InvalidCharReplacement));
+#endif
+ writer.WriteAttributeString(ATTR_NAME, Transform.MaskXmlInvalidCharacters((string)entry.Key, this.InvalidCharReplacement));
// Use an ObjectRenderer to convert the object to a string
- string valueStr =null;
+ string valueStr = null;
if (!this.Base64EncodeProperties)
{
- valueStr = Transform.MaskXmlInvalidCharacters(loggingEvent.Repository.RendererMap.FindAndRender(entry.Value),this.InvalidCharReplacement);
+ valueStr = Transform.MaskXmlInvalidCharacters(loggingEvent.Repository.RendererMap.FindAndRender(entry.Value), this.InvalidCharReplacement);
}
else
{
@@ -305,24 +305,24 @@
if (exceptionStr != null && exceptionStr.Length > 0)
{
// Append the stack trace line
- #if NETSTANDARD
+#if NETSTANDARD
writer.WriteStartElement(m_prefix, ELM_EXCEPTION, m_prefix);
- #else
+#else
writer.WriteStartElement(m_elmException);
- #endif
- Transform.WriteEscapedXmlString(writer, exceptionStr,this.InvalidCharReplacement);
+#endif
+ Transform.WriteEscapedXmlString(writer, exceptionStr, this.InvalidCharReplacement);
writer.WriteEndElement();
}
if (LocationInfo)
- {
+ {
LocationInfo locationInfo = loggingEvent.LocationInformation;
- #if NETSTANDARD
+#if NETSTANDARD
writer.WriteStartElement(m_prefix, ELM_LOCATION, m_prefix);
- #else
+#else
writer.WriteStartElement(m_elmLocation);
- #endif
+#endif
writer.WriteAttributeString(ATTR_CLASS, locationInfo.ClassName);
writer.WriteAttributeString(ATTR_METHOD, locationInfo.MethodName);
writer.WriteAttributeString(ATTR_FILE, locationInfo.FileName);
@@ -336,7 +336,7 @@
#endregion Override implementation of XMLLayoutBase
#region Private Instance Fields
-
+
/// <summary>
/// The prefix to use for all generated element names
/// </summary>
@@ -349,8 +349,8 @@
private string m_elmException = ELM_EXCEPTION;
private string m_elmLocation = ELM_LOCATION;
- private bool m_base64Message=false;
- private bool m_base64Properties=false;
+ private bool m_base64Message = false;
+ private bool m_base64Properties = false;
#endregion Private Instance Fields
diff --git a/src/log4net/Layout/XmlLayoutBase.cs b/src/log4net/Layout/XmlLayoutBase.cs
index 3bee490..eb57228 100644
--- a/src/log4net/Layout/XmlLayoutBase.cs
+++ b/src/log4net/Layout/XmlLayoutBase.cs
@@ -126,8 +126,8 @@
/// </summary>
public string InvalidCharReplacement
{
- get {return m_invalidCharReplacement;}
- set {m_invalidCharReplacement=value;}
+ get { return m_invalidCharReplacement; }
+ set { m_invalidCharReplacement = value; }
}
#endregion
@@ -149,7 +149,7 @@
/// <see cref="ActivateOptions"/> must be called again.
/// </para>
/// </remarks>
- public override void ActivateOptions()
+ public override void ActivateOptions()
{
// nothing to do
}
@@ -190,7 +190,7 @@
/// <see cref="FormatXml"/> method rather than this method.
/// </para>
/// </remarks>
- public override void Format(TextWriter writer, LoggingEvent loggingEvent)
+ public override void Format(TextWriter writer, LoggingEvent loggingEvent)
{
if (loggingEvent == null)
{
@@ -238,7 +238,7 @@
#endregion Protected Instance Methods
#region Private Instance Fields
-
+
/// <summary>
/// Flag to indicate if location information should be included in
/// the XML events.
@@ -248,7 +248,7 @@
/// <summary>
/// The string to replace invalid chars with
/// </summary>
- private string m_invalidCharReplacement="?";
+ private string m_invalidCharReplacement = "?";
#endregion Private Instance Fields
}
diff --git a/src/log4net/Layout/XmlLayoutSchemaLog4j.cs b/src/log4net/Layout/XmlLayoutSchemaLog4j.cs
index db6fb5a..448b145 100644
--- a/src/log4net/Layout/XmlLayoutSchemaLog4j.cs
+++ b/src/log4net/Layout/XmlLayoutSchemaLog4j.cs
@@ -73,7 +73,7 @@
/// appender as well.
/// </para>
/// </remarks>
- public XmlLayoutSchemaLog4j(bool locationInfo) : base(locationInfo)
+ public XmlLayoutSchemaLog4j(bool locationInfo) : base(locationInfo)
{
}
@@ -92,8 +92,8 @@
public string Version
{
get { return "1.2"; }
- set
- {
+ set
+ {
if (value != "1.2")
{
throw new ArgumentException("Only version 1.2 of the log4j schema is currently supported");
@@ -141,42 +141,42 @@
// Translate logging events for log4j
// Translate hostname property
- if (loggingEvent.LookupProperty(LoggingEvent.HostNameProperty) != null &&
+ if (loggingEvent.LookupProperty(LoggingEvent.HostNameProperty) != null &&
loggingEvent.LookupProperty("log4jmachinename") == null)
{
loggingEvent.GetProperties()["log4jmachinename"] = loggingEvent.LookupProperty(LoggingEvent.HostNameProperty);
}
// translate appdomain name
- if (loggingEvent.LookupProperty("log4japp") == null &&
- loggingEvent.Domain != null &&
+ if (loggingEvent.LookupProperty("log4japp") == null &&
+ loggingEvent.Domain != null &&
loggingEvent.Domain.Length > 0)
{
loggingEvent.GetProperties()["log4japp"] = loggingEvent.Domain;
}
// translate identity name
- if (loggingEvent.Identity != null &&
- loggingEvent.Identity.Length > 0 &&
+ if (loggingEvent.Identity != null &&
+ loggingEvent.Identity.Length > 0 &&
loggingEvent.LookupProperty(LoggingEvent.IdentityProperty) == null)
{
loggingEvent.GetProperties()[LoggingEvent.IdentityProperty] = loggingEvent.Identity;
}
// translate user name
- if (loggingEvent.UserName != null &&
- loggingEvent.UserName.Length > 0 &&
+ if (loggingEvent.UserName != null &&
+ loggingEvent.UserName.Length > 0 &&
loggingEvent.LookupProperty(LoggingEvent.UserNameProperty) == null)
{
loggingEvent.GetProperties()[LoggingEvent.UserNameProperty] = loggingEvent.UserName;
}
// Write the start element
- #if NETSTANDARD
+#if NETSTANDARD
writer.WriteStartElement("log4j", "event", "log4net");
- #else
+#else
writer.WriteStartElement("log4j:event");
- #endif
+#endif
writer.WriteAttributeString("logger", loggingEvent.LoggerName);
// Calculate the timestamp as the number of milliseconds since january 1970
@@ -189,14 +189,14 @@
writer.WriteAttributeString("timestamp", XmlConvert.ToString((long)timeSince1970.TotalMilliseconds));
writer.WriteAttributeString("level", loggingEvent.Level.DisplayName);
writer.WriteAttributeString("thread", loggingEvent.ThreadName);
-
+
// Append the message text
- #if NETSTANDARD
+#if NETSTANDARD
writer.WriteStartElement("log4j", "message", "log4net");
- #else
+#else
writer.WriteStartElement("log4j:message");
- #endif
- Transform.WriteEscapedXmlString(writer, loggingEvent.RenderedMessage,this.InvalidCharReplacement);
+#endif
+ Transform.WriteEscapedXmlString(writer, loggingEvent.RenderedMessage, this.InvalidCharReplacement);
writer.WriteEndElement();
object ndcObj = loggingEvent.LookupProperty("NDC");
@@ -207,12 +207,12 @@
if (valueStr != null && valueStr.Length > 0)
{
// Append the NDC text
- #if NETSTANDARD
+#if NETSTANDARD
writer.WriteStartElement("log4j", "NDC", "log4net");
- #else
+#else
writer.WriteStartElement("log4j:NDC");
- #endif
- Transform.WriteEscapedXmlString(writer, valueStr,this.InvalidCharReplacement);
+#endif
+ Transform.WriteEscapedXmlString(writer, valueStr, this.InvalidCharReplacement);
writer.WriteEndElement();
}
}
@@ -221,18 +221,18 @@
PropertiesDictionary properties = loggingEvent.GetProperties();
if (properties.Count > 0)
{
- #if NETSTANDARD
+#if NETSTANDARD
writer.WriteStartElement("log4j", "properties", "log4net");
- #else
+#else
writer.WriteStartElement("log4j:properties");
- #endif
- foreach(System.Collections.DictionaryEntry entry in properties)
+#endif
+ foreach (System.Collections.DictionaryEntry entry in properties)
{
- #if NETSTANDARD
+#if NETSTANDARD
writer.WriteStartElement("log4j", "data", "log4net");
- #else
+#else
writer.WriteStartElement("log4j:data");
- #endif
+#endif
writer.WriteAttributeString("name", (string)entry.Key);
// Use an ObjectRenderer to convert the object to a string
@@ -248,24 +248,24 @@
if (exceptionStr != null && exceptionStr.Length > 0)
{
// Append the stack trace line
- #if NETSTANDARD
+#if NETSTANDARD
writer.WriteStartElement("log4j", "throwable", "log4net");
- #else
+#else
writer.WriteStartElement("log4j:throwable");
- #endif
- Transform.WriteEscapedXmlString(writer, exceptionStr,this.InvalidCharReplacement);
+#endif
+ Transform.WriteEscapedXmlString(writer, exceptionStr, this.InvalidCharReplacement);
writer.WriteEndElement();
}
if (LocationInfo)
- {
+ {
LocationInfo locationInfo = loggingEvent.LocationInformation;
- #if NETSTANDARD
+#if NETSTANDARD
writer.WriteStartElement("log4j", "locationInfo", "log4net");
- #else
+#else
writer.WriteStartElement("log4j:locationInfo");
- #endif
+#endif
writer.WriteAttributeString("class", locationInfo.ClassName);
writer.WriteAttributeString("method", locationInfo.MethodName);
writer.WriteAttributeString("file", locationInfo.FileName);
diff --git a/src/log4net/LogManager.cs b/src/log4net/LogManager.cs
index 664d39c..0eb25ce 100644
--- a/src/log4net/LogManager.cs
+++ b/src/log4net/LogManager.cs
@@ -86,11 +86,11 @@
/// </remarks>
/// <param name="name">The fully qualified logger name to look for.</param>
/// <returns>The logger found, or <c>null</c> if no logger could be found.</returns>
- public static ILog Exists(string name)
+ public static ILog Exists(string name)
{
return Exists(Assembly.GetCallingAssembly(), name);
}
-
+
/// <overloads>Get the currently defined loggers.</overloads>
/// <summary>
/// Returns all the currently defined loggers in the default repository.
@@ -103,7 +103,7 @@
{
return GetCurrentLoggers(Assembly.GetCallingAssembly());
}
-
+
/// <overloads>Get or create a logger.</overloads>
/// <summary>
/// Retrieves or creates a named logger.
@@ -128,23 +128,23 @@
}
#endif // !NETSTANDARD1_3
- /// <summary>
- /// Returns the named logger if it exists.
- /// </summary>
- /// <remarks>
- /// <para>
- /// If the named logger exists (in the specified repository) then it
- /// returns a reference to the logger, otherwise it returns
- /// <c>null</c>.
- /// </para>
- /// </remarks>
- /// <param name="repository">The repository to lookup in.</param>
- /// <param name="name">The fully qualified logger name to look for.</param>
- /// <returns>
- /// The logger found, or <c>null</c> if the logger doesn't exist in the specified
- /// repository.
- /// </returns>
- public static ILog Exists(string repository, string name)
+ /// <summary>
+ /// Returns the named logger if it exists.
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// If the named logger exists (in the specified repository) then it
+ /// returns a reference to the logger, otherwise it returns
+ /// <c>null</c>.
+ /// </para>
+ /// </remarks>
+ /// <param name="repository">The repository to lookup in.</param>
+ /// <param name="name">The fully qualified logger name to look for.</param>
+ /// <returns>
+ /// The logger found, or <c>null</c> if the logger doesn't exist in the specified
+ /// repository.
+ /// </returns>
+ public static ILog Exists(string repository, string name)
{
return WrapLogger(LoggerManager.Exists(repository, name));
}
@@ -165,7 +165,7 @@
/// The logger, or <c>null</c> if the logger doesn't exist in the specified
/// assembly's repository.
/// </returns>
- public static ILog Exists(Assembly repositoryAssembly, string name)
+ public static ILog Exists(Assembly repositoryAssembly, string name)
{
return WrapLogger(LoggerManager.Exists(repositoryAssembly, name));
}
@@ -242,7 +242,7 @@
public static ILog GetLogger(Assembly repositoryAssembly, string name)
{
return WrapLogger(LoggerManager.GetLogger(repositoryAssembly, name));
- }
+ }
/// <summary>
/// Shorthand for <see cref="M:LogManager.GetLogger(string)"/>.
@@ -252,7 +252,7 @@
/// </remarks>
/// <param name="type">The full name of <paramref name="type"/> will be used as the name of the logger to retrieve.</param>
/// <returns>The logger with the name specified.</returns>
- public static ILog GetLogger(Type type)
+ public static ILog GetLogger(Type type)
{
#if NETSTANDARD1_3
return GetLogger(type.GetTypeInfo().Assembly, type.FullName);
@@ -270,7 +270,7 @@
/// <param name="repository">The repository to lookup in.</param>
/// <param name="type">The full name of <paramref name="type"/> will be used as the name of the logger to retrieve.</param>
/// <returns>The logger with the name specified.</returns>
- public static ILog GetLogger(string repository, Type type)
+ public static ILog GetLogger(string repository, Type type)
{
return WrapLogger(LoggerManager.GetLogger(repository, type));
}
@@ -284,7 +284,7 @@
/// <param name="repositoryAssembly">The assembly to use to lookup the repository.</param>
/// <param name="type">The full name of <paramref name="type"/> will be used as the name of the logger to retrieve.</param>
/// <returns>The logger with the name specified.</returns>
- public static ILog GetLogger(Assembly repositoryAssembly, Type type)
+ public static ILog GetLogger(Assembly repositoryAssembly, Type type)
{
return WrapLogger(LoggerManager.GetLogger(repositoryAssembly, type));
}
@@ -312,7 +312,7 @@
/// and again to a nested appender.
/// </para>
/// </remarks>
- public static void Shutdown()
+ public static void Shutdown()
{
LoggerManager.Shutdown();
}
@@ -337,7 +337,7 @@
/// and again to a nested appender.
/// </para>
/// </remarks>
- public static void ShutdownRepository()
+ public static void ShutdownRepository()
{
ShutdownRepository(Assembly.GetCallingAssembly());
}
@@ -363,7 +363,7 @@
/// </para>
/// </remarks>
/// <param name="repository">The repository to shutdown.</param>
- public static void ShutdownRepository(string repository)
+ public static void ShutdownRepository(string repository)
{
LoggerManager.ShutdownRepository(repository);
}
@@ -390,7 +390,7 @@
/// </para>
/// </remarks>
/// <param name="repositoryAssembly">The assembly to use to lookup the repository.</param>
- public static void ShutdownRepository(Assembly repositoryAssembly)
+ public static void ShutdownRepository(Assembly repositoryAssembly)
{
LoggerManager.ShutdownRepository(repositoryAssembly);
}
@@ -410,7 +410,7 @@
/// message disabling is set to its default "off" value.
/// </para>
/// </remarks>
- public static void ResetConfiguration()
+ public static void ResetConfiguration()
{
ResetConfiguration(Assembly.GetCallingAssembly());
}
@@ -430,7 +430,7 @@
/// </para>
/// </remarks>
/// <param name="repository">The repository to reset.</param>
- public static void ResetConfiguration(string repository)
+ public static void ResetConfiguration(string repository)
{
LoggerManager.ResetConfiguration(repository);
}
@@ -449,7 +449,7 @@
/// </para>
/// </remarks>
/// <param name="repositoryAssembly">The assembly to use to lookup the repository to reset.</param>
- public static void ResetConfiguration(Assembly repositoryAssembly)
+ public static void ResetConfiguration(Assembly repositoryAssembly)
{
LoggerManager.ResetConfiguration(repositoryAssembly);
}
@@ -751,27 +751,27 @@
return LoggerManager.GetAllRepositories();
}
- /// <summary>
- /// Flushes logging events buffered in all configured appenders in the default repository.
- /// </summary>
- /// <param name="millisecondsTimeout">The maximum time in milliseconds to wait for logging events from asycnhronous appenders to be flushed.</param>
- /// <returns><c>True</c> if all logging events were flushed successfully, else <c>false</c>.</returns>
- public static bool Flush(int millisecondsTimeout)
- {
+ /// <summary>
+ /// Flushes logging events buffered in all configured appenders in the default repository.
+ /// </summary>
+ /// <param name="millisecondsTimeout">The maximum time in milliseconds to wait for logging events from asycnhronous appenders to be flushed.</param>
+ /// <returns><c>True</c> if all logging events were flushed successfully, else <c>false</c>.</returns>
+ public static bool Flush(int millisecondsTimeout)
+ {
#if !NETSTANDARD1_3 // Excluded because GetCallingAssembly() is not available in CoreFX (https://github.com/dotnet/corefx/issues/2221).
- Appender.IFlushable flushableRepository = LoggerManager.GetRepository(Assembly.GetCallingAssembly()) as Appender.IFlushable;
- if (flushableRepository == null)
- {
- return false;
- }
- else
- {
- return flushableRepository.Flush(millisecondsTimeout);
- }
+ Appender.IFlushable flushableRepository = LoggerManager.GetRepository(Assembly.GetCallingAssembly()) as Appender.IFlushable;
+ if (flushableRepository == null)
+ {
+ return false;
+ }
+ else
+ {
+ return flushableRepository.Flush(millisecondsTimeout);
+ }
#else
return false;
#endif
- }
+ }
#endregion Domain & Repository Manager Methods
@@ -795,7 +795,7 @@
private static ILog[] WrapLoggers(ILogger[] loggers)
{
ILog[] results = new ILog[loggers.Length];
- for(int i=0; i<loggers.Length; i++)
+ for (int i = 0; i < loggers.Length; i++)
{
results[i] = WrapLogger(loggers[i]);
}
diff --git a/src/log4net/NDC.cs b/src/log4net/NDC.cs
index 1c4c7b1..c1ded53 100644
--- a/src/log4net/NDC.cs
+++ b/src/log4net/NDC.cs
@@ -129,7 +129,7 @@
/// </para>
/// </remarks>
/*[Obsolete("NDC has been replaced by ThreadContext.Stacks")]*/
- public static void Clear()
+ public static void Clear()
{
ThreadContext.Stacks["NDC"].Clear();
}
@@ -152,7 +152,7 @@
/// </para>
/// </remarks>
/*[Obsolete("NDC has been replaced by ThreadContext.Stacks")]*/
- public static Stack CloneStack()
+ public static Stack CloneStack()
{
return ThreadContext.Stacks["NDC"].InternalStack;
}
@@ -179,7 +179,7 @@
/// </para>
/// </remarks>
/*[Obsolete("NDC has been replaced by ThreadContext.Stacks", true)]*/
- public static void Inherit(Stack stack)
+ public static void Inherit(Stack stack)
{
ThreadContext.Stacks["NDC"].InternalStack = stack;
}
@@ -205,7 +205,7 @@
/// </para>
/// </remarks>
/*[Obsolete("NDC has been replaced by ThreadContext.Stacks")]*/
- public static string Pop()
+ public static string Pop()
{
return ThreadContext.Stacks["NDC"].Pop();
}
@@ -241,7 +241,7 @@
/// </code>
/// </example>
/*[Obsolete("NDC has been replaced by ThreadContext.Stacks")]*/
- public static IDisposable Push(string message)
+ public static IDisposable Push(string message)
{
return ThreadContext.Stacks["NDC"].Push(message);
}
@@ -300,7 +300,7 @@
/// </para>
/// </remarks>
/*[Obsolete("NDC has been replaced by ThreadContext.Stacks")]*/
- public static void Remove()
+ public static void Remove()
{
}
@@ -324,7 +324,7 @@
/// </para>
/// </remarks>
/*[Obsolete("NDC has been replaced by ThreadContext.Stacks")]*/
- public static void SetMaxDepth(int maxDepth)
+ public static void SetMaxDepth(int maxDepth)
{
if (maxDepth >= 0)
{
@@ -336,7 +336,7 @@
}
else
{
- while(stack.Count > maxDepth)
+ while (stack.Count > maxDepth)
{
stack.Pop();
}
diff --git a/src/log4net/ObjectRenderer/DefaultRenderer.cs b/src/log4net/ObjectRenderer/DefaultRenderer.cs
index 73add46..ff23b19 100644
--- a/src/log4net/ObjectRenderer/DefaultRenderer.cs
+++ b/src/log4net/ObjectRenderer/DefaultRenderer.cs
@@ -157,7 +157,7 @@
writer.Write(SystemInfo.NullText);
return;
}
-
+
Array objArray = obj as Array;
if (objArray != null)
{
@@ -177,7 +177,7 @@
writer.Write("{}");
return;
}
-
+
// This is a special check to allow us to get the enumerator from the IDictionary
// interface as this guarantees us DictionaryEntry objects. Note that in .NET 2.0
// the generic IDictionary<> interface enumerates KeyValuePair objects rather than
@@ -200,7 +200,7 @@
RenderEnumerator(rendererMap, objEnumerator, writer);
return;
}
-
+
if (obj is DictionaryEntry)
{
RenderDictionaryEntry(rendererMap, (DictionaryEntry)obj, writer);
@@ -208,7 +208,7 @@
}
string str = obj.ToString();
- writer.Write( (str==null) ? SystemInfo.NullText : str );
+ writer.Write((str == null) ? SystemInfo.NullText : str);
}
#endregion
@@ -246,7 +246,7 @@
if (len > 0)
{
rendererMap.FindAndRender(array.GetValue(0), writer);
- for(int i=1; i<len; i++)
+ for (int i = 1; i < len; i++)
{
writer.Write(", ");
rendererMap.FindAndRender(array.GetValue(i), writer);
@@ -305,6 +305,6 @@
rendererMap.FindAndRender(entry.Key, writer);
writer.Write("=");
rendererMap.FindAndRender(entry.Value, writer);
- }
+ }
}
}
diff --git a/src/log4net/ObjectRenderer/RendererMap.cs b/src/log4net/ObjectRenderer/RendererMap.cs
index c3ba590..0e4284d 100644
--- a/src/log4net/ObjectRenderer/RendererMap.cs
+++ b/src/log4net/ObjectRenderer/RendererMap.cs
@@ -96,13 +96,13 @@
/// as a <see cref="string"/>.
/// </para>
/// </remarks>
- public void FindAndRender(object obj, TextWriter writer)
+ public void FindAndRender(object obj, TextWriter writer)
{
if (obj == null)
{
writer.Write(SystemInfo.NullText);
}
- else
+ else
{
// Optimisation for strings
string str = obj as string;
@@ -117,10 +117,10 @@
{
Get(obj.GetType()).RenderObject(this, obj, writer);
}
- catch(Exception ex)
+ catch (Exception ex)
{
// Exception rendering the object
- LogLog.Error(declaringType, "Exception while rendering object of type ["+obj.GetType().FullName+"]", ex);
+ LogLog.Error(declaringType, "Exception while rendering object of type [" + obj.GetType().FullName + "]", ex);
// return default message
string objectTypeName = "";
@@ -129,7 +129,7 @@
objectTypeName = obj.GetType().FullName;
}
- writer.Write("<log4net.Error>Exception rendering object type ["+objectTypeName+"]");
+ writer.Write("<log4net.Error>Exception rendering object type [" + objectTypeName + "]");
if (ex != null)
{
string exceptionText = null;
@@ -165,9 +165,9 @@
/// with the type of the object parameter.
/// </param>
/// </remarks>
- public IObjectRenderer Get(Object obj)
+ public IObjectRenderer Get(Object obj)
{
- if (obj == null)
+ if (obj == null)
{
return null;
}
@@ -176,7 +176,7 @@
return Get(obj.GetType());
}
}
-
+
/// <summary>
/// Gets the renderer for the specified type
/// </summary>
@@ -189,7 +189,7 @@
/// <see cref="DefaultRenderer"/> will be returned.
/// </para>
/// </remarks>
- public IObjectRenderer Get(Type type)
+ public IObjectRenderer Get(Type type)
{
if (type == null)
{
@@ -206,7 +206,7 @@
#if NETSTANDARD1_3
for (Type cur = type; cur != null; cur = cur.GetTypeInfo().BaseType)
#else
- for(Type cur = type; cur != null; cur = cur.BaseType)
+ for (Type cur = type; cur != null; cur = cur.BaseType)
#endif
{
// Search the type's interfaces
@@ -231,28 +231,28 @@
}
return result;
- }
+ }
/// <summary>
/// Internal function to recursively search interfaces
/// </summary>
/// <param name="type">the type to lookup the renderer for</param>
/// <returns>the renderer for the specified type</returns>
- private IObjectRenderer SearchTypeAndInterfaces(Type type)
+ private IObjectRenderer SearchTypeAndInterfaces(Type type)
{
IObjectRenderer r = (IObjectRenderer)m_map[type];
- if (r != null)
+ if (r != null)
{
return r;
- }
- else
+ }
+ else
{
- foreach(Type t in type.GetInterfaces())
+ foreach (Type t in type.GetInterfaces())
{
r = SearchTypeAndInterfaces(t);
if (r != null)
{
- return r;
+ return r;
}
}
}
@@ -283,7 +283,7 @@
/// cannot be removed.
/// </para>
/// </remarks>
- public void Clear()
+ public void Clear()
{
lock (m_map)
{
@@ -308,7 +308,7 @@
/// specifying the same <paramref name="typeToRender"/> as an argument.
/// </para>
/// </remarks>
- public void Put(Type typeToRender, IObjectRenderer renderer)
+ public void Put(Type typeToRender, IObjectRenderer renderer)
{
lock (m_cache)
{
@@ -328,6 +328,6 @@
{
m_map[typeToRender] = renderer;
}
- }
+ }
}
}
diff --git a/src/log4net/Plugin/PluginCollection.cs b/src/log4net/Plugin/PluginCollection.cs
index c3c28e7..4019d67 100644
--- a/src/log4net/Plugin/PluginCollection.cs
+++ b/src/log4net/Plugin/PluginCollection.cs
@@ -73,7 +73,7 @@
private int m_version = 0;
#endregion Implementation (data)
-
+
#region Static Wrappers
/// <summary>
@@ -85,7 +85,7 @@
/// </returns>
public static PluginCollection ReadOnly(PluginCollection list)
{
- if(list == null) throw new ArgumentNullException("list");
+ if (list == null) throw new ArgumentNullException("list");
return new ReadOnlyPluginCollection(list);
}
@@ -102,7 +102,7 @@
{
m_array = new IPlugin[DEFAULT_CAPACITY];
}
-
+
/// <summary>
/// Initializes a new instance of the <c>PluginCollection</c> class
/// that has the specified initial capacity.
@@ -136,7 +136,7 @@
m_array = new IPlugin[a.Length];
AddRange(a);
}
-
+
/// <summary>
/// Initializes a new instance of the <c>PluginCollection</c> class
/// that contains elements copied from the specified <see cref="IPlugin"/> collection.
@@ -153,7 +153,7 @@
/// Used to access protected constructor
/// </summary>
/// <exclude/>
- protected internal enum Tag
+ protected internal enum Tag
{
/// <summary>
/// A value
@@ -172,7 +172,7 @@
}
#endregion
-
+
#region Operations (type-safe ICollection)
/// <summary>
@@ -205,8 +205,8 @@
{
throw new System.ArgumentException("Destination array was not long enough.");
}
-
- Array.Copy(m_array, 0, array, start, m_count);
+
+ Array.Copy(m_array, 0, array, start, m_count);
}
/// <summary>
@@ -230,7 +230,7 @@
}
#endregion
-
+
#region Operations (type-safe IList)
/// <summary>
@@ -250,13 +250,13 @@
get
{
ValidateIndex(index); // throws
- return m_array[index];
+ return m_array[index];
}
set
{
ValidateIndex(index); // throws
- ++m_version;
- m_array[index] = value;
+ ++m_version;
+ m_array[index] = value;
}
}
@@ -277,7 +277,7 @@
return m_count++;
}
-
+
/// <summary>
/// Removes all elements from the <c>PluginCollection</c>.
/// </summary>
@@ -287,7 +287,7 @@
m_array = new IPlugin[DEFAULT_CAPACITY];
m_count = 0;
}
-
+
/// <summary>
/// Creates a shallow copy of the <see cref="PluginCollection"/>.
/// </summary>
@@ -309,7 +309,7 @@
/// <returns><c>true</c> if <paramref name="item"/> is found in the <c>PluginCollection</c>; otherwise, <c>false</c>.</returns>
public virtual bool Contains(IPlugin item)
{
- for (int i=0; i != m_count; ++i)
+ for (int i = 0; i != m_count; ++i)
{
if (m_array[i].Equals(item))
{
@@ -330,7 +330,7 @@
/// </returns>
public virtual int IndexOf(IPlugin item)
{
- for (int i=0; i != m_count; ++i)
+ for (int i = 0; i != m_count; ++i)
{
if (m_array[i].Equals(item))
{
@@ -353,7 +353,7 @@
public virtual void Insert(int index, IPlugin item)
{
ValidateIndex(index, true); // throws
-
+
if (m_count == m_array.Length)
{
EnsureCapacity(m_count + 1);
@@ -377,7 +377,7 @@
/// The specified <see cref="IPlugin"/> was not found in the <c>PluginCollection</c>.
/// </exception>
public virtual void Remove(IPlugin item)
- {
+ {
int i = IndexOf(item);
if (i < 0)
{
@@ -399,14 +399,14 @@
public virtual void RemoveAt(int index)
{
ValidateIndex(index); // throws
-
+
m_count--;
if (index < m_count)
{
Array.Copy(m_array, index + 1, m_array, index, m_count - index);
}
-
+
// We can't set the deleted entry equal to null, because it might be a value type.
// Instead, we'll create an empty single-element array of the right type and copy it
// over the entry we want to erase.
@@ -436,7 +436,7 @@
#endregion
#region Operations (type-safe IEnumerable)
-
+
/// <summary>
/// Returns an enumerator that can iterate through the <c>PluginCollection</c>.
/// </summary>
@@ -449,7 +449,7 @@
#endregion
#region Public helpers (just to mimic some nice features of ArrayList)
-
+
/// <summary>
/// Gets or sets the number of elements the <c>PluginCollection</c> can contain.
/// </summary>
@@ -458,9 +458,9 @@
/// </value>
public virtual int Capacity
{
- get
- {
- return m_array.Length;
+ get
+ {
+ return m_array.Length;
}
set
{
@@ -496,7 +496,7 @@
{
EnsureCapacity(m_count + x.Count);
}
-
+
Array.Copy(x.m_array, 0, m_array, m_count, x.Count);
m_count += x.Count;
m_version++;
@@ -535,14 +535,14 @@
EnsureCapacity(m_count + col.Count);
}
- foreach(object item in col)
+ foreach (object item in col)
{
Add((IPlugin)item);
}
return m_count;
}
-
+
/// <summary>
/// Sets the capacity to the actual number of elements.
/// </summary>
@@ -572,7 +572,7 @@
/// </exception>
private void ValidateIndex(int i, bool allowEqualEnd)
{
- int max = (allowEqualEnd) ? (m_count) : (m_count-1);
+ int max = (allowEqualEnd) ? (m_count) : (m_count - 1);
if (i < 0 || i > max)
{
throw log4net.Util.SystemInfo.CreateArgumentOutOfRangeException("i", (object)i, "Index was out of range. Must be non-negative and less than the size of the collection. [" + (object)i + "] Specified argument was out of the range of valid values.");
@@ -591,7 +591,7 @@
}
#endregion
-
+
#region Implementation (ICollection)
void ICollection.CopyTo(Array array, int start)
@@ -659,15 +659,15 @@
private sealed class Enumerator : IEnumerator, IPluginCollectionEnumerator
{
#region Implementation (data)
-
+
private readonly PluginCollection m_collection;
private int m_index;
private int m_version;
-
+
#endregion Implementation (data)
-
+
#region Construction
-
+
/// <summary>
/// Initializes a new instance of the <c>Enumerator</c> class.
/// </summary>
@@ -678,11 +678,11 @@
m_index = -1;
m_version = tc.m_version;
}
-
+
#endregion
-
+
#region Operations (type-safe IEnumerator)
-
+
/// <summary>
/// Gets the current element in the collection.
/// </summary>
@@ -724,14 +724,14 @@
}
#endregion
-
+
#region Implementation (IEnumerator)
-
+
object IEnumerator.Current
{
get { return this.Current; }
}
-
+
#endregion
}
@@ -766,7 +766,7 @@
public override void CopyTo(IPlugin[] array, int start)
{
- m_collection.CopyTo(array,start);
+ m_collection.CopyTo(array, start);
}
public override int Count
{
@@ -797,7 +797,7 @@
{
throw new NotSupportedException("This is a Read Only Collection and can not be modified");
}
-
+
public override void Clear()
{
throw new NotSupportedException("This is a Read Only Collection and can not be modified");
@@ -819,7 +819,7 @@
}
public override void Remove(IPlugin x)
- {
+ {
throw new NotSupportedException("This is a Read Only Collection and can not be modified");
}
diff --git a/src/log4net/Plugin/PluginMap.cs b/src/log4net/Plugin/PluginMap.cs
index 5c818d3..9908f36 100644
--- a/src/log4net/Plugin/PluginMap.cs
+++ b/src/log4net/Plugin/PluginMap.cs
@@ -82,7 +82,7 @@
throw new ArgumentNullException("name");
}
- lock(this)
+ lock (this)
{
return (IPlugin)m_mapName2Plugin[name];
}
@@ -102,13 +102,13 @@
{
get
{
- lock(this)
+ lock (this)
{
return new PluginCollection(m_mapName2Plugin.Values);
}
}
}
-
+
#endregion Public Instance Properties
#region Public Instance Methods
@@ -137,7 +137,7 @@
IPlugin curPlugin = null;
- lock(this)
+ lock (this)
{
// Get the current plugin if it exists
curPlugin = m_mapName2Plugin[plugin.Name] as IPlugin;
@@ -171,7 +171,7 @@
{
throw new ArgumentNullException("plugin");
}
- lock(this)
+ lock (this)
{
m_mapName2Plugin.Remove(plugin.Name);
}
diff --git a/src/log4net/Plugin/PluginSkeleton.cs b/src/log4net/Plugin/PluginSkeleton.cs
index 2c3d0f9..df263e1 100644
--- a/src/log4net/Plugin/PluginSkeleton.cs
+++ b/src/log4net/Plugin/PluginSkeleton.cs
@@ -70,8 +70,8 @@
/// plugin has been attached to a repository.
/// </para>
/// </remarks>
- public virtual string Name
- {
+ public virtual string Name
+ {
get { return m_name; }
set { m_name = value; }
}
@@ -123,9 +123,9 @@
/// attached to.
/// </para>
/// </remarks>
- protected virtual ILoggerRepository LoggerRepository
+ protected virtual ILoggerRepository LoggerRepository
{
- get { return this.m_repository; }
+ get { return this.m_repository; }
set { this.m_repository = value; }
}
diff --git a/src/log4net/Plugin/RemoteLoggingServerPlugin.cs b/src/log4net/Plugin/RemoteLoggingServerPlugin.cs
index ec05978..bee95b4 100644
--- a/src/log4net/Plugin/RemoteLoggingServerPlugin.cs
+++ b/src/log4net/Plugin/RemoteLoggingServerPlugin.cs
@@ -77,7 +77,7 @@
/// with specified name.
/// </para>
/// </remarks>
- public RemoteLoggingServerPlugin(string sinkUri) : base("RemoteLoggingServerPlugin:"+sinkUri)
+ public RemoteLoggingServerPlugin(string sinkUri) : base("RemoteLoggingServerPlugin:" + sinkUri)
{
m_sinkUri = sinkUri;
}
@@ -98,8 +98,8 @@
/// <see cref="M:RemotingServices.Marshal(MarshalByRefObject,String,Type)"/>
/// </para>
/// </remarks>
- public virtual string SinkUri
- {
+ public virtual string SinkUri
+ {
get { return m_sinkUri; }
set { m_sinkUri = value; }
}
@@ -128,13 +128,13 @@
base.Attach(repository);
// Create the sink and marshal it
- m_sink = new RemoteLoggingSinkImpl(repository);
+ m_sink = new RemoteLoggingSinkImpl(repository);
try
{
- RemotingServices.Marshal(m_sink, m_sinkUri, typeof(IRemoteLoggingSink));
+ RemotingServices.Marshal(m_sink, m_sinkUri, typeof(IRemoteLoggingSink));
}
- catch(Exception ex)
+ catch (Exception ex)
{
LogLog.Error(declaringType, "Failed to Marshal remoting sink", ex);
}
@@ -152,7 +152,7 @@
#if NET_4_0 || MONO_4_0
[System.Security.SecuritySafeCritical]
#endif
- public override void Shutdown()
+ public override void Shutdown()
{
// Stops the sink from receiving messages
RemotingServices.Disconnect(m_sink);
@@ -170,18 +170,18 @@
#endregion Private Instance Fields
- #region Private Static Fields
+ #region Private Static Fields
- /// <summary>
- /// The fully qualified type of the RemoteLoggingServerPlugin class.
- /// </summary>
- /// <remarks>
- /// Used by the internal logger to record the Type of the
- /// log message.
- /// </remarks>
- private static readonly Type declaringType = typeof(RemoteLoggingServerPlugin);
+ /// <summary>
+ /// The fully qualified type of the RemoteLoggingServerPlugin class.
+ /// </summary>
+ /// <remarks>
+ /// Used by the internal logger to record the Type of the
+ /// log message.
+ /// </remarks>
+ private static readonly Type declaringType = typeof(RemoteLoggingServerPlugin);
- #endregion Private Static Fields
+ #endregion Private Static Fields
/// <summary>
/// Delivers <see cref="LoggingEvent"/> objects to a remote sink.
@@ -228,7 +228,7 @@
{
if (events != null)
{
- foreach(LoggingEvent logEvent in events)
+ foreach (LoggingEvent logEvent in events)
{
if (logEvent != null)
{
@@ -257,7 +257,7 @@
#if NET_4_0 || MONO_4_0
[System.Security.SecurityCritical]
#endif
- public override object InitializeLifetimeService()
+ public override object InitializeLifetimeService()
{
return null;
}
diff --git a/src/log4net/Repository/ConfigurationChangedEventArgs.cs b/src/log4net/Repository/ConfigurationChangedEventArgs.cs
index 77df7d4..f20f1c0 100644
--- a/src/log4net/Repository/ConfigurationChangedEventArgs.cs
+++ b/src/log4net/Repository/ConfigurationChangedEventArgs.cs
@@ -24,28 +24,28 @@
namespace log4net.Repository
{
+ /// <summary>
+ ///
+ /// </summary>
+ public class ConfigurationChangedEventArgs : EventArgs
+ {
+ private readonly ICollection configurationMessages;
+
/// <summary>
///
/// </summary>
- public class ConfigurationChangedEventArgs : EventArgs
+ /// <param name="configurationMessages"></param>
+ public ConfigurationChangedEventArgs(ICollection configurationMessages)
{
- private readonly ICollection configurationMessages;
-
- /// <summary>
- ///
- /// </summary>
- /// <param name="configurationMessages"></param>
- public ConfigurationChangedEventArgs(ICollection configurationMessages)
- {
- this.configurationMessages = configurationMessages;
- }
-
- /// <summary>
- ///
- /// </summary>
- public ICollection ConfigurationMessages
- {
- get { return configurationMessages; }
- }
+ this.configurationMessages = configurationMessages;
}
+
+ /// <summary>
+ ///
+ /// </summary>
+ public ICollection ConfigurationMessages
+ {
+ get { return configurationMessages; }
+ }
+ }
}
diff --git a/src/log4net/Repository/Hierarchy/DefaultLoggerFactory.cs b/src/log4net/Repository/Hierarchy/DefaultLoggerFactory.cs
index 9bb079b..2f55243 100644
--- a/src/log4net/Repository/Hierarchy/DefaultLoggerFactory.cs
+++ b/src/log4net/Repository/Hierarchy/DefaultLoggerFactory.cs
@@ -73,7 +73,7 @@
/// must be returned.
/// </para>
/// </remarks>
- public Logger CreateLogger(ILoggerRepository repository, string name)
+ public Logger CreateLogger(ILoggerRepository repository, string name)
{
if (name == null)
{
diff --git a/src/log4net/Repository/Hierarchy/Hierarchy.cs b/src/log4net/Repository/Hierarchy/Hierarchy.cs
index ce215be..144b5c4 100644
--- a/src/log4net/Repository/Hierarchy/Hierarchy.cs
+++ b/src/log4net/Repository/Hierarchy/Hierarchy.cs
@@ -232,11 +232,11 @@
/// </remarks>
public Logger Root
{
- get
- {
+ get
+ {
if (m_root == null)
{
- lock(this)
+ lock (this)
{
if (m_root == null)
{
@@ -249,7 +249,7 @@
}
}
}
- return m_root;
+ return m_root;
}
}
@@ -290,14 +290,14 @@
/// its reference, otherwise returns <c>null</c>.
/// </para>
/// </remarks>
- public override ILogger Exists(string name)
- {
+ public override ILogger Exists(string name)
+ {
if (name == null)
{
throw new ArgumentNullException("name");
}
- lock(m_ht)
+ lock (m_ht)
{
return m_ht[new LoggerKey(name)] as Logger;
}
@@ -314,19 +314,19 @@
/// enumeration.
/// </para>
/// </remarks>
- public override ILogger[] GetCurrentLoggers()
+ public override ILogger[] GetCurrentLoggers()
{
// The accumulation in loggers is necessary because not all elements in
// ht are Logger objects as there might be some ProvisionNodes
// as well.
- lock(m_ht)
+ lock (m_ht)
{
System.Collections.ArrayList loggers = new System.Collections.ArrayList(m_ht.Count);
-
+
// Iterate through m_ht values
- foreach(object node in m_ht.Values)
+ foreach (object node in m_ht.Values)
{
- if (node is Logger)
+ if (node is Logger)
{
loggers.Add(node);
}
@@ -352,7 +352,7 @@
/// </remarks>
/// <param name="name">The name of the logger to retrieve</param>
/// <returns>The logger object with the name specified</returns>
- public override ILogger GetLogger(string name)
+ public override ILogger GetLogger(string name)
{
if (name == null)
{
@@ -383,18 +383,18 @@
/// and again to a nested appender.
/// </para>
/// </remarks>
- public override void Shutdown()
+ public override void Shutdown()
{
- LogLog.Debug(declaringType, "Shutdown called on Hierarchy ["+this.Name+"]");
+ LogLog.Debug(declaringType, "Shutdown called on Hierarchy [" + this.Name + "]");
// begin by closing nested appenders
Root.CloseNestedAppenders();
- lock(m_ht)
+ lock (m_ht)
{
ILogger[] currentLoggers = this.GetCurrentLoggers();
- foreach(Logger logger in currentLoggers)
+ foreach (Logger logger in currentLoggers)
{
logger.CloseNestedAppenders();
}
@@ -402,7 +402,7 @@
// then, remove all appenders
Root.RemoveAllAppenders();
- foreach(Logger logger in currentLoggers)
+ foreach (Logger logger in currentLoggers)
{
logger.RemoveAllAppenders();
}
@@ -431,17 +431,17 @@
/// block all logging until it is completed.
/// </para>
/// </remarks>
- public override void ResetConfiguration()
+ public override void ResetConfiguration()
{
Root.Level = LevelMap.LookupWithDefault(Level.Debug);
Threshold = LevelMap.LookupWithDefault(Level.All);
-
+
// the synchronization is needed to prevent hashtable surprises
- lock(m_ht)
- {
+ lock (m_ht)
+ {
Shutdown(); // nested locks are OK
-
- foreach(Logger l in this.GetCurrentLoggers())
+
+ foreach (Logger l in this.GetCurrentLoggers())
{
l.Level = null;
l.Additivity = true;
@@ -500,7 +500,7 @@
CollectAppenders(appenderList, Root);
- foreach(Logger logger in GetCurrentLoggers())
+ foreach (Logger logger in GetCurrentLoggers())
{
CollectAppenders(appenderList, logger);
}
@@ -510,9 +510,9 @@
#endregion Override Implementation of LoggerRepositorySkeleton
- #region Private Static Methods
+ #region Private Static Methods
- /// <summary>
+ /// <summary>
/// Collect the appenders from an <see cref="IAppenderAttachable"/>.
/// The appender may also be a container.
/// </summary>
@@ -539,17 +539,17 @@
/// <param name="container"></param>
private static void CollectAppenders(System.Collections.ArrayList appenderList, IAppenderAttachable container)
{
- foreach(Appender.IAppender appender in container.Appenders)
+ foreach (Appender.IAppender appender in container.Appenders)
{
CollectAppender(appenderList, appender);
}
- }
+ }
- #endregion
+ #endregion
- #region Implementation of IBasicRepositoryConfigurator
+ #region Implementation of IBasicRepositoryConfigurator
- /// <summary>
+ /// <summary>
/// Initialize the log4net system using the specified appender
/// </summary>
/// <param name="appender">the appender to use to log all logging events</param>
@@ -558,14 +558,14 @@
BasicRepositoryConfigure(appender);
}
- /// <summary>
- /// Initialize the log4net system using the specified appenders
- /// </summary>
- /// <param name="appenders">the appenders to use to log all logging events</param>
- void IBasicRepositoryConfigurator.Configure(params IAppender[] appenders)
- {
- BasicRepositoryConfigure(appenders);
- }
+ /// <summary>
+ /// Initialize the log4net system using the specified appenders
+ /// </summary>
+ /// <param name="appenders">the appenders to use to log all logging events</param>
+ void IBasicRepositoryConfigurator.Configure(params IAppender[] appenders)
+ {
+ BasicRepositoryConfigure(appenders);
+ }
/// <summary>
/// Initialize the log4net system using the specified appenders
@@ -580,25 +580,25 @@
/// </remarks>
protected void BasicRepositoryConfigure(params IAppender[] appenders)
{
- ArrayList configurationMessages = new ArrayList();
+ ArrayList configurationMessages = new ArrayList();
- using (new LogLog.LogReceivedAdapter(configurationMessages))
- {
- foreach (IAppender appender in appenders)
- {
- Root.AddAppender(appender);
- }
- }
+ using (new LogLog.LogReceivedAdapter(configurationMessages))
+ {
+ foreach (IAppender appender in appenders)
+ {
+ Root.AddAppender(appender);
+ }
+ }
- Configured = true;
+ Configured = true;
- ConfigurationMessages = configurationMessages;
+ ConfigurationMessages = configurationMessages;
// Notify listeners
- OnConfigurationChanged(new ConfigurationChangedEventArgs(configurationMessages));
+ OnConfigurationChanged(new ConfigurationChangedEventArgs(configurationMessages));
}
- #endregion Implementation of IBasicRepositoryConfigurator
+ #endregion Implementation of IBasicRepositoryConfigurator
#region Implementation of IXmlRepositoryConfigurator
@@ -624,20 +624,20 @@
/// </remarks>
protected void XmlRepositoryConfigure(System.Xml.XmlElement element)
{
- ArrayList configurationMessages = new ArrayList();
+ ArrayList configurationMessages = new ArrayList();
- using (new LogLog.LogReceivedAdapter(configurationMessages))
- {
- XmlHierarchyConfigurator config = new XmlHierarchyConfigurator(this);
- config.Configure(element);
- }
+ using (new LogLog.LogReceivedAdapter(configurationMessages))
+ {
+ XmlHierarchyConfigurator config = new XmlHierarchyConfigurator(this);
+ config.Configure(element);
+ }
- Configured = true;
+ Configured = true;
- ConfigurationMessages = configurationMessages;
+ ConfigurationMessages = configurationMessages;
// Notify listeners
- OnConfigurationChanged(new ConfigurationChangedEventArgs(configurationMessages));
+ OnConfigurationChanged(new ConfigurationChangedEventArgs(configurationMessages));
}
#endregion Implementation of IXmlRepositoryConfigurator
@@ -665,7 +665,7 @@
/// See also the <see cref="ILoggerRepository.Threshold"/> property.
/// </para>
/// </remarks>
- public bool IsDisabled(Level level)
+ public bool IsDisabled(Level level)
{
// Cast level to object for performance
if ((object)level == null)
@@ -698,9 +698,9 @@
/// invoking this method.
/// </para>
/// </remarks>
- public void Clear()
+ public void Clear()
{
- lock(m_ht)
+ lock (m_ht)
{
m_ht.Clear();
}
@@ -721,7 +721,7 @@
/// ancestors as well as children.
/// </para>
/// </remarks>
- public Logger GetLogger(string name, ILoggerFactory factory)
+ public Logger GetLogger(string name, ILoggerFactory factory)
{
if (name == null)
{
@@ -732,41 +732,41 @@
throw new ArgumentNullException("factory");
}
- LoggerKey key = new LoggerKey(name);
-
+ LoggerKey key = new LoggerKey(name);
+
// Synchronize to prevent write conflicts. Read conflicts (in
// GetEffectiveLevel() method) are possible only if variable
// assignments are non-atomic.
- lock(m_ht)
+ lock (m_ht)
{
Logger logger = null;
Object node = m_ht[key];
- if (node == null)
+ if (node == null)
{
logger = factory.CreateLogger(this, name);
logger.Hierarchy = this;
- m_ht[key] = logger;
+ m_ht[key] = logger;
UpdateParents(logger);
OnLoggerCreationEvent(logger);
return logger;
- }
-
+ }
+
Logger nodeLogger = node as Logger;
- if (nodeLogger != null)
+ if (nodeLogger != null)
{
return nodeLogger;
- }
-
+ }
+
ProvisionNode nodeProvisionNode = node as ProvisionNode;
- if (nodeProvisionNode != null)
+ if (nodeProvisionNode != null)
{
logger = factory.CreateLogger(this, name);
- logger.Hierarchy = this;
+ logger.Hierarchy = this;
m_ht[key] = logger;
UpdateChildren(nodeProvisionNode, logger);
- UpdateParents(logger);
+ UpdateParents(logger);
OnLoggerCreationEvent(logger);
return logger;
}
@@ -787,7 +787,7 @@
/// <remarks>
/// Raises the logger creation event.
/// </remarks>
- protected virtual void OnLoggerCreationEvent(Logger logger)
+ protected virtual void OnLoggerCreationEvent(Logger logger)
{
LoggerCreationEventHandler handler = m_loggerCreatedEvent;
if (handler != null)
@@ -835,25 +835,25 @@
/// </item>
/// </list>
/// </remarks>
- private void UpdateParents(Logger log)
+ private void UpdateParents(Logger log)
{
string name = log.Name;
int length = name.Length;
bool parentFound = false;
-
+
// if name = "w.x.y.z", loop through "w.x.y", "w.x" and "w", but not "w.x.y.z"
- for(int i = name.LastIndexOf('.', length-1); i >= 0; i = name.LastIndexOf('.', i-1))
+ for (int i = name.LastIndexOf('.', length - 1); i >= 0; i = name.LastIndexOf('.', i - 1))
{
string substr = name.Substring(0, i);
LoggerKey key = new LoggerKey(substr); // simple constructor
Object node = m_ht[key];
// Create a provision node for a future parent.
- if (node == null)
+ if (node == null)
{
ProvisionNode pn = new ProvisionNode(log);
m_ht[key] = pn;
- }
+ }
else
{
Logger nodeLogger = node as Logger;
@@ -872,19 +872,20 @@
}
else
{
- LogLog.Error(declaringType, "Unexpected object type ["+node.GetType()+"] in ht.", new LogException());
+ LogLog.Error(declaringType, "Unexpected object type [" + node.GetType() + "] in ht.", new LogException());
}
- }
+ }
}
- if (i == 0) {
- // logger name starts with a dot
- // and we've hit the start
- break;
+ if (i == 0)
+ {
+ // logger name starts with a dot
+ // and we've hit the start
+ break;
}
}
// If we could not find any existing parents, then link with root.
- if (!parentFound)
+ if (!parentFound)
{
log.Parent = this.Root;
}
@@ -914,18 +915,18 @@
/// c's parent field to log.
/// </para>
/// </remarks>
- private static void UpdateChildren(ProvisionNode pn, Logger log)
+ private static void UpdateChildren(ProvisionNode pn, Logger log)
{
- for(int i = 0; i < pn.Count; i++)
+ for (int i = 0; i < pn.Count; i++)
{
Logger childLogger = (Logger)pn[i];
// Unless this child already points to a correct (lower) parent,
// make log.Parent point to childLogger.Parent and childLogger.Parent to log.
- if (!childLogger.Parent.Name.StartsWith(log.Name))
+ if (!childLogger.Parent.Name.StartsWith(log.Name))
{
log.Parent = childLogger.Parent;
- childLogger.Parent = log;
+ childLogger.Parent = log;
}
}
}
@@ -953,7 +954,7 @@
Level previousLevel = LevelMap[levelEntry.Name];
if (previousLevel == null)
{
- throw new InvalidOperationException("Cannot redefine level ["+levelEntry.Name+"] because it is not defined in the LevelMap. To define the level supply the level value.");
+ throw new InvalidOperationException("Cannot redefine level [" + levelEntry.Name + "] because it is not defined in the LevelMap. To define the level supply the level value.");
}
levelEntry.Value = previousLevel.Value;
@@ -1031,7 +1032,7 @@
/// <returns>string info about this object</returns>
public override string ToString()
{
- return "LevelEntry(Value="+m_levelValue+", Name="+m_levelName+", DisplayName="+m_levelDisplayName+")";
+ return "LevelEntry(Value=" + m_levelValue + ", Name=" + m_levelName + ", DisplayName=" + m_levelDisplayName + ")";
}
}
@@ -1063,24 +1064,24 @@
private System.Collections.Hashtable m_ht;
private Logger m_root;
-
+
private bool m_emittedNoAppenderWarning = false;
- private event LoggerCreationEventHandler m_loggerCreatedEvent;
+ private event LoggerCreationEventHandler m_loggerCreatedEvent;
#endregion Private Instance Fields
- #region Private Static Fields
+ #region Private Static Fields
- /// <summary>
- /// The fully qualified type of the Hierarchy class.
- /// </summary>
- /// <remarks>
- /// Used by the internal logger to record the Type of the
- /// log message.
- /// </remarks>
- private static readonly Type declaringType = typeof(Hierarchy);
+ /// <summary>
+ /// The fully qualified type of the Hierarchy class.
+ /// </summary>
+ /// <remarks>
+ /// Used by the internal logger to record the Type of the
+ /// log message.
+ /// </remarks>
+ private static readonly Type declaringType = typeof(Hierarchy);
- #endregion Private Static Fields
+ #endregion Private Static Fields
}
}
diff --git a/src/log4net/Repository/Hierarchy/Logger.cs b/src/log4net/Repository/Hierarchy/Logger.cs
index dbeab32..0ec41db 100644
--- a/src/log4net/Repository/Hierarchy/Logger.cs
+++ b/src/log4net/Repository/Hierarchy/Logger.cs
@@ -70,7 +70,7 @@
/// logger creator.
/// </para>
/// </remarks>
- protected Logger(string name)
+ protected Logger(string name)
{
#if NETCF || NETSTANDARD1_3
// NETCF: String.Intern causes Native Exception
@@ -140,14 +140,14 @@
/// </remarks>
public virtual Level EffectiveLevel
{
- get
+ get
{
- for(Logger c = this; c != null; c = c.m_parent)
+ for (Logger c = this; c != null; c = c.m_parent)
{
Level level = c.m_level;
// Casting level to Object for performance, otherwise the overloaded operator is called
- if ((object)level != null)
+ if ((object)level != null)
{
return level;
}
@@ -208,7 +208,7 @@
/// appenders, then it won't be added again.
/// </para>
/// </remarks>
- public virtual void AddAppender(IAppender newAppender)
+ public virtual void AddAppender(IAppender newAppender)
{
if (newAppender == null)
{
@@ -218,7 +218,7 @@
m_appenderLock.AcquireWriterLock();
try
{
- if (m_appenderAttachedImpl == null)
+ if (m_appenderAttachedImpl == null)
{
m_appenderAttachedImpl = new log4net.Util.AppenderAttachedImpl();
}
@@ -242,7 +242,7 @@
/// can be found, then a <see cref="EmptyCollection"/> is returned.
/// </para>
/// </remarks>
- public virtual AppenderCollection Appenders
+ public virtual AppenderCollection Appenders
{
get
{
@@ -253,7 +253,7 @@
{
return AppenderCollection.EmptyCollection;
}
- else
+ else
{
return m_appenderAttachedImpl.Appenders;
}
@@ -275,7 +275,7 @@
/// Returns the named appender, or null if the appender is not found.
/// </para>
/// </remarks>
- public virtual IAppender GetAppender(string name)
+ public virtual IAppender GetAppender(string name)
{
m_appenderLock.AcquireReaderLock();
try
@@ -304,12 +304,12 @@
/// This is useful when re-reading configuration information.
/// </para>
/// </remarks>
- public virtual void RemoveAllAppenders()
+ public virtual void RemoveAllAppenders()
{
m_appenderLock.AcquireWriterLock();
try
{
- if (m_appenderAttachedImpl != null)
+ if (m_appenderAttachedImpl != null)
{
m_appenderAttachedImpl.RemoveAllAppenders();
m_appenderAttachedImpl = null;
@@ -334,12 +334,12 @@
/// <see cref="IAppender.Close"/> on the appender removed.
/// </para>
/// </remarks>
- public virtual IAppender RemoveAppender(IAppender appender)
+ public virtual IAppender RemoveAppender(IAppender appender)
{
m_appenderLock.AcquireWriterLock();
try
{
- if (appender != null && m_appenderAttachedImpl != null)
+ if (appender != null && m_appenderAttachedImpl != null)
{
return m_appenderAttachedImpl.RemoveAppender(appender);
}
@@ -364,7 +364,7 @@
/// <see cref="IAppender.Close"/> on the appender removed.
/// </para>
/// </remarks>
- public virtual IAppender RemoveAppender(string name)
+ public virtual IAppender RemoveAppender(string name)
{
m_appenderLock.AcquireWriterLock();
try
@@ -380,7 +380,7 @@
}
return null;
}
-
+
#endregion
#region Implementation of ILogger
@@ -418,13 +418,13 @@
/// This method must not throw any exception to the caller.
/// </para>
/// </remarks>
- public virtual void Log(Type callerStackBoundaryDeclaringType, Level level, object message, Exception exception)
+ public virtual void Log(Type callerStackBoundaryDeclaringType, Level level, object message, Exception exception)
{
try
{
if (IsEnabledFor(level))
{
- ForcedLog((callerStackBoundaryDeclaringType != null) ? callerStackBoundaryDeclaringType : declaringType, level, message, exception);
+ ForcedLog((callerStackBoundaryDeclaringType != null) ? callerStackBoundaryDeclaringType : declaringType, level, message, exception);
}
}
catch (Exception ex)
@@ -531,11 +531,11 @@
/// </para>
/// </remarks>
public ILoggerRepository Repository
- {
+ {
get { return m_hierarchy; }
}
- #endregion Implementation of ILogger
+ #endregion Implementation of ILogger
/// <summary>
/// Deliver the <see cref="LoggingEvent"/> to the attached appenders.
@@ -553,7 +553,7 @@
/// to log the particular log request.
/// </para>
/// </remarks>
- protected virtual void CallAppenders(LoggingEvent loggingEvent)
+ protected virtual void CallAppenders(LoggingEvent loggingEvent)
{
if (loggingEvent == null)
{
@@ -562,15 +562,15 @@
int writes = 0;
- for(Logger c=this; c != null; c=c.m_parent)
+ for (Logger c = this; c != null; c = c.m_parent)
{
- if (c.m_appenderAttachedImpl != null)
+ if (c.m_appenderAttachedImpl != null)
{
// Protected against simultaneous call to addAppender, removeAppender,...
c.m_appenderLock.AcquireReaderLock();
try
{
- if (c.m_appenderAttachedImpl != null)
+ if (c.m_appenderAttachedImpl != null)
{
writes += c.m_appenderAttachedImpl.AppendLoopOnAppenders(loggingEvent);
}
@@ -581,12 +581,12 @@
}
}
- if (!c.m_additive)
+ if (!c.m_additive)
{
break;
}
}
-
+
// No appenders in hierarchy, warn user only once.
//
// Note that by including the AppDomain values for the currently running
@@ -596,7 +596,7 @@
// or impossible to determine which .config file is missing appender
// definitions.
//
- if (!m_hierarchy.EmittedNoAppenderWarning && writes == 0)
+ if (!m_hierarchy.EmittedNoAppenderWarning && writes == 0)
{
m_hierarchy.EmittedNoAppenderWarning = true;
LogLog.Debug(declaringType, "No appenders could be found for logger [" + Name + "] repository [" + Repository.Name + "]");
@@ -610,7 +610,7 @@
LogLog.Debug(declaringType, " DynamicDirectory: " + AppDomain.CurrentDomain.DynamicDirectory);
#endif
}
- catch(System.Security.SecurityException)
+ catch (System.Security.SecurityException)
{
// Insufficient permissions to display info from the AppDomain
}
@@ -625,7 +625,7 @@
/// Used to ensure that the appenders are correctly shutdown.
/// </para>
/// </remarks>
- public virtual void CloseNestedAppenders()
+ public virtual void CloseNestedAppenders()
{
m_appenderLock.AcquireWriterLock();
try
@@ -633,7 +633,7 @@
if (m_appenderAttachedImpl != null)
{
AppenderCollection appenders = m_appenderAttachedImpl.Appenders;
- foreach(IAppender appender in appenders)
+ foreach (IAppender appender in appenders)
{
if (appender is IAppenderAttachable)
{
@@ -660,11 +660,11 @@
/// the <paramref name="message"/>.
/// </para>
/// </remarks>
- public virtual void Log(Level level, object message, Exception exception)
+ public virtual void Log(Level level, object message, Exception exception)
{
if (IsEnabledFor(level))
{
- ForcedLog(declaringType, level, message, exception);
+ ForcedLog(declaringType, level, message, exception);
}
}
@@ -682,7 +682,7 @@
/// appenders.
/// </para>
/// </remarks>
- protected virtual void ForcedLog(Type callerStackBoundaryDeclaringType, Level level, object message, Exception exception)
+ protected virtual void ForcedLog(Type callerStackBoundaryDeclaringType, Level level, object message, Exception exception)
{
CallAppenders(new LoggingEvent(callerStackBoundaryDeclaringType, this.Hierarchy, this.Name, level, message, exception));
}
@@ -696,7 +696,7 @@
/// Delivers the logging event to the attached appenders.
/// </para>
/// </remarks>
- protected virtual void ForcedLog(LoggingEvent logEvent)
+ protected virtual void ForcedLog(LoggingEvent logEvent)
{
// The logging event may not have been created by this logger
// the Repository may not be correctly set on the event. This
@@ -708,10 +708,10 @@
#region Private Static Fields
- /// <summary>
- /// The fully qualified type of the Logger class.
- /// </summary>
- private static readonly Type declaringType = typeof(Logger);
+ /// <summary>
+ /// The fully qualified type of the Logger class.
+ /// </summary>
+ private static readonly Type declaringType = typeof(Logger);
#endregion Private Static Fields
@@ -720,7 +720,7 @@
/// <summary>
/// The name of this logger.
/// </summary>
- private readonly string m_name;
+ private readonly string m_name;
/// <summary>
/// The assigned level of this logger.
@@ -782,7 +782,7 @@
/// Lock to protect AppenderAttachedImpl variable m_appenderAttachedImpl
/// </summary>
private readonly ReaderWriterLock m_appenderLock = new ReaderWriterLock();
-
+
#endregion
}
}
diff --git a/src/log4net/Repository/Hierarchy/LoggerKey.cs b/src/log4net/Repository/Hierarchy/LoggerKey.cs
index 0067152..7d74ad8 100644
--- a/src/log4net/Repository/Hierarchy/LoggerKey.cs
+++ b/src/log4net/Repository/Hierarchy/LoggerKey.cs
@@ -62,7 +62,7 @@
/// </note>
/// </remarks>
/// <param name="name">The name of the logger.</param>
- internal LoggerKey(string name)
+ internal LoggerKey(string name)
{
#if NETCF || NETSTANDARD1_3
// NETCF: String.Intern causes Native Exception
@@ -86,7 +86,7 @@
/// Returns the cached hashcode.
/// </para>
/// </remarks>
- public override int GetHashCode()
+ public override int GetHashCode()
{
return m_hashCache;
}
@@ -104,22 +104,22 @@
/// Compares the references of the interned strings.
/// </para>
/// </remarks>
- public override bool Equals(object obj)
+ public override bool Equals(object obj)
{
// Compare reference type of this against argument
if (((object)this) == obj)
{
return true;
}
-
+
LoggerKey objKey = obj as LoggerKey;
- if (objKey != null)
+ if (objKey != null)
{
#if NETCF || NETSTANDARD1_3
return ( m_name == objKey.m_name );
#else
// Compare reference types rather than string's overloaded ==
- return ( ((object)m_name) == ((object)objKey.m_name) );
+ return (((object)m_name) == ((object)objKey.m_name));
#endif
}
return false;
@@ -129,10 +129,10 @@
#region Private Instance Fields
- private readonly string m_name;
+ private readonly string m_name;
private readonly int m_hashCache;
#endregion Private Instance Fields
- }
+ }
}
diff --git a/src/log4net/Repository/Hierarchy/RootLogger.cs b/src/log4net/Repository/Hierarchy/RootLogger.cs
index dae8aa9..10cb878 100644
--- a/src/log4net/Repository/Hierarchy/RootLogger.cs
+++ b/src/log4net/Repository/Hierarchy/RootLogger.cs
@@ -79,9 +79,9 @@
/// value of <see cref="Logger.Level"/>.
/// </para>
/// </remarks>
- public override Level EffectiveLevel
+ public override Level EffectiveLevel
{
- get
+ get
{
return base.Level;
}
@@ -104,11 +104,11 @@
get { return base.Level; }
set
{
- if (value == null)
+ if (value == null)
{
LogLog.Error(declaringType, "You have tried to set a null level to root.", new LogException());
}
- else
+ else
{
base.Level = value;
}
@@ -117,17 +117,17 @@
#endregion Override implementation of Logger
- #region Private Static Fields
+ #region Private Static Fields
- /// <summary>
- /// The fully qualified type of the RootLogger class.
- /// </summary>
- /// <remarks>
- /// Used by the internal logger to record the Type of the
- /// log message.
- /// </remarks>
- private static readonly Type declaringType = typeof(RootLogger);
+ /// <summary>
+ /// The fully qualified type of the RootLogger class.
+ /// </summary>
+ /// <remarks>
+ /// Used by the internal logger to record the Type of the
+ /// log message.
+ /// </remarks>
+ private static readonly Type declaringType = typeof(RootLogger);
- #endregion Private Static Fields
+ #endregion Private Static Fields
}
}
diff --git a/src/log4net/Repository/Hierarchy/XmlHierarchyConfigurator.cs b/src/log4net/Repository/Hierarchy/XmlHierarchyConfigurator.cs
index b7bb605..164933f 100644
--- a/src/log4net/Repository/Hierarchy/XmlHierarchyConfigurator.cs
+++ b/src/log4net/Repository/Hierarchy/XmlHierarchyConfigurator.cs
@@ -44,7 +44,7 @@
{
private enum ConfigUpdateMode
{
- Merge,
+ Merge,
Overwrite
}
@@ -60,7 +60,7 @@
/// with the specified <see cref="Hierarchy" />.
/// </para>
/// </remarks>
- public XmlHierarchyConfigurator(Hierarchy hierarchy)
+ public XmlHierarchyConfigurator(Hierarchy hierarchy)
{
m_hierarchy = hierarchy;
m_appenderBag = new Hashtable();
@@ -79,11 +79,11 @@
/// Configure the hierarchy by parsing a DOM tree of XML elements.
/// </para>
/// </remarks>
- public void Configure(XmlElement element)
+ public void Configure(XmlElement element)
{
if (element == null || m_hierarchy == null)
{
- return;
+ return;
}
string rootElementName = element.LocalName;
@@ -91,43 +91,43 @@
if (rootElementName != CONFIGURATION_TAG)
{
LogLog.Error(declaringType, "Xml element is - not a <" + CONFIGURATION_TAG + "> element.");
- return;
+ return;
}
- if (!LogLog.EmitInternalMessages)
- {
- // Look for a emitDebug attribute to enable internal debug
- string emitDebugAttribute = element.GetAttribute(EMIT_INTERNAL_DEBUG_ATTR);
- LogLog.Debug(declaringType, EMIT_INTERNAL_DEBUG_ATTR + " attribute [" + emitDebugAttribute + "].");
+ if (!LogLog.EmitInternalMessages)
+ {
+ // Look for a emitDebug attribute to enable internal debug
+ string emitDebugAttribute = element.GetAttribute(EMIT_INTERNAL_DEBUG_ATTR);
+ LogLog.Debug(declaringType, EMIT_INTERNAL_DEBUG_ATTR + " attribute [" + emitDebugAttribute + "].");
- if (emitDebugAttribute.Length > 0 && emitDebugAttribute != "null")
- {
- LogLog.EmitInternalMessages = OptionConverter.ToBoolean(emitDebugAttribute, true);
- }
- else
- {
- LogLog.Debug(declaringType, "Ignoring " + EMIT_INTERNAL_DEBUG_ATTR + " attribute.");
- }
- }
+ if (emitDebugAttribute.Length > 0 && emitDebugAttribute != "null")
+ {
+ LogLog.EmitInternalMessages = OptionConverter.ToBoolean(emitDebugAttribute, true);
+ }
+ else
+ {
+ LogLog.Debug(declaringType, "Ignoring " + EMIT_INTERNAL_DEBUG_ATTR + " attribute.");
+ }
+ }
- if (!LogLog.InternalDebugging)
+ if (!LogLog.InternalDebugging)
{
// Look for a debug attribute to enable internal debug
string debugAttribute = element.GetAttribute(INTERNAL_DEBUG_ATTR);
- LogLog.Debug(declaringType, INTERNAL_DEBUG_ATTR+" attribute [" + debugAttribute + "].");
+ LogLog.Debug(declaringType, INTERNAL_DEBUG_ATTR + " attribute [" + debugAttribute + "].");
- if (debugAttribute.Length>0 && debugAttribute != "null")
- {
+ if (debugAttribute.Length > 0 && debugAttribute != "null")
+ {
LogLog.InternalDebugging = OptionConverter.ToBoolean(debugAttribute, true);
}
- else
+ else
{
LogLog.Debug(declaringType, "Ignoring " + INTERNAL_DEBUG_ATTR + " attribute.");
}
string confDebug = element.GetAttribute(CONFIG_DEBUG_ATTR);
- if (confDebug.Length>0 && confDebug != "null")
- {
+ if (confDebug.Length > 0 && confDebug != "null")
+ {
LogLog.Warn(declaringType, "The \"" + CONFIG_DEBUG_ATTR + "\" attribute is deprecated.");
LogLog.Warn(declaringType, "Use the \"" + INTERNAL_DEBUG_ATTR + "\" attribute instead.");
LogLog.InternalDebugging = OptionConverter.ToBoolean(confDebug, true);
@@ -170,23 +170,23 @@
foreach (XmlNode currentNode in element.ChildNodes)
{
- if (currentNode.NodeType == XmlNodeType.Element)
+ if (currentNode.NodeType == XmlNodeType.Element)
{
XmlElement currentElement = (XmlElement)currentNode;
if (currentElement.LocalName == LOGGER_TAG)
{
ParseLogger(currentElement);
- }
+ }
else if (currentElement.LocalName == CATEGORY_TAG)
{
// TODO: deprecated use of category
ParseLogger(currentElement);
- }
+ }
else if (currentElement.LocalName == ROOT_TAG)
{
ParseRoot(currentElement);
- }
+ }
else if (currentElement.LocalName == RENDERER_TAG)
{
ParseRenderer(currentElement);
@@ -207,9 +207,9 @@
// Lastly set the hierarchy threshold
string thresholdStr = element.GetAttribute(THRESHOLD_ATTR);
LogLog.Debug(declaringType, "Hierarchy Threshold [" + thresholdStr + "]");
- if (thresholdStr.Length > 0 && thresholdStr != "null")
+ if (thresholdStr.Length > 0 && thresholdStr != "null")
{
- Level thresholdLevel = (Level) ConvertStringTo(typeof(Level), thresholdStr);
+ Level thresholdLevel = (Level)ConvertStringTo(typeof(Level), thresholdStr);
if (thresholdLevel != null)
{
m_hierarchy.Threshold = thresholdLevel;
@@ -223,7 +223,7 @@
// Done reading config
}
- #endregion Public Instance Methods
+ #endregion Public Instance Methods
#region Protected Instance Methods
@@ -238,16 +238,16 @@
/// the appender.
/// </para>
/// </remarks>
- protected IAppender FindAppenderByReference(XmlElement appenderRef)
- {
+ protected IAppender FindAppenderByReference(XmlElement appenderRef)
+ {
string appenderName = appenderRef.GetAttribute(REF_ATTR);
IAppender appender = (IAppender)m_appenderBag[appenderName];
- if (appender != null)
+ if (appender != null)
{
return appender;
- }
- else
+ }
+ else
{
// Find the element with that id
XmlElement element = null;
@@ -264,11 +264,11 @@
}
}
- if (element == null)
+ if (element == null)
{
- LogLog.Error(declaringType, "XmlHierarchyConfigurator: No appender named [" + appenderName + "] could be found.");
+ LogLog.Error(declaringType, "XmlHierarchyConfigurator: No appender named [" + appenderName + "] could be found.");
return null;
- }
+ }
else
{
appender = ParseAppender(element);
@@ -278,7 +278,7 @@
}
return appender;
}
- }
+ }
}
/// <summary>
@@ -292,13 +292,13 @@
/// the appender instance.
/// </para>
/// </remarks>
- protected IAppender ParseAppender(XmlElement appenderElement)
+ protected IAppender ParseAppender(XmlElement appenderElement)
{
string appenderName = appenderElement.GetAttribute(NAME_ATTR);
string typeName = appenderElement.GetAttribute(TYPE_ATTR);
LogLog.Debug(declaringType, "Loading Appender [" + appenderName + "] type: [" + typeName + "]");
- try
+ try
{
#if NETSTANDARD1_3
IAppender appender = (IAppender)Activator.CreateInstance(SystemInfo.GetTypeFromString(this.GetType().GetTypeInfo().Assembly, typeName, true, true));
@@ -310,7 +310,7 @@
foreach (XmlNode currentNode in appenderElement.ChildNodes)
{
/* We're only interested in Elements */
- if (currentNode.NodeType == XmlNodeType.Element)
+ if (currentNode.NodeType == XmlNodeType.Element)
{
XmlElement currentElement = (XmlElement)currentNode;
@@ -320,7 +320,7 @@
string refName = currentElement.GetAttribute(REF_ATTR);
IAppenderAttachable appenderContainer = appender as IAppenderAttachable;
- if (appenderContainer != null)
+ if (appenderContainer != null)
{
LogLog.Debug(declaringType, "Attaching appender named [" + refName + "] to appender named [" + appender.Name + "].");
@@ -329,10 +329,10 @@
{
appenderContainer.AddAppender(referencedAppender);
}
- }
- else
+ }
+ else
{
- LogLog.Error(declaringType, "Requesting attachment of appender named ["+refName+ "] to appender named [" + appender.Name + "] which does not implement log4net.Core.IAppenderAttachable.");
+ LogLog.Error(declaringType, "Requesting attachment of appender named [" + refName + "] to appender named [" + appender.Name + "] which does not implement log4net.Core.IAppenderAttachable.");
}
}
else
@@ -344,15 +344,15 @@
}
IOptionHandler optionHandler = appender as IOptionHandler;
- if (optionHandler != null)
+ if (optionHandler != null)
{
optionHandler.ActivateOptions();
}
- LogLog.Debug(declaringType, "Created Appender [" + appenderName + "]");
+ LogLog.Debug(declaringType, "Created Appender [" + appenderName + "]");
return appender;
}
- catch (Exception ex)
+ catch (Exception ex)
{
// Yes, it's ugly. But all exceptions point to the same problem: we can't create an Appender
@@ -370,7 +370,7 @@
/// Parse an XML element that represents a logger.
/// </para>
/// </remarks>
- protected void ParseLogger(XmlElement loggerElement)
+ protected void ParseLogger(XmlElement loggerElement)
{
// Create a new log4net.Logger object from the <logger> element.
string loggerName = loggerElement.GetAttribute(NAME_ATTR);
@@ -381,10 +381,10 @@
// Setting up a logger needs to be an atomic operation, in order
// to protect potential log operations while logger
// configuration is in progress.
- lock(log)
+ lock (log)
{
bool additivity = OptionConverter.ToBoolean(loggerElement.GetAttribute(ADDITIVITY_ATTR), true);
-
+
LogLog.Debug(declaringType, "Setting [" + log.Name + "] additivity to [" + additivity + "].");
log.Additivity = additivity;
ParseChildrenOfLoggerElement(loggerElement, log, false);
@@ -400,12 +400,12 @@
/// Parse an XML element that represents the root logger.
/// </para>
/// </remarks>
- protected void ParseRoot(XmlElement rootElement)
+ protected void ParseRoot(XmlElement rootElement)
{
Logger root = m_hierarchy.Root;
// logger configuration needs to be atomic
- lock(root)
- {
+ lock (root)
+ {
ParseChildrenOfLoggerElement(rootElement, root, true);
}
}
@@ -421,7 +421,7 @@
/// Parse the child elements of a <logger> element.
/// </para>
/// </remarks>
- protected void ParseChildrenOfLoggerElement(XmlElement catElement, Logger log, bool isRoot)
+ protected void ParseChildrenOfLoggerElement(XmlElement catElement, Logger log, bool isRoot)
{
// Remove all existing appenders from log. They will be
// reconstructed if need be.
@@ -429,28 +429,28 @@
foreach (XmlNode currentNode in catElement.ChildNodes)
{
- if (currentNode.NodeType == XmlNodeType.Element)
+ if (currentNode.NodeType == XmlNodeType.Element)
{
- XmlElement currentElement = (XmlElement) currentNode;
-
+ XmlElement currentElement = (XmlElement)currentNode;
+
if (currentElement.LocalName == APPENDER_REF_TAG)
{
IAppender appender = FindAppenderByReference(currentElement);
- string refName = currentElement.GetAttribute(REF_ATTR);
+ string refName = currentElement.GetAttribute(REF_ATTR);
if (appender != null)
{
LogLog.Debug(declaringType, "Adding appender named [" + refName + "] to logger [" + log.Name + "].");
log.AddAppender(appender);
}
- else
+ else
{
LogLog.Error(declaringType, "Appender named [" + refName + "] not found.");
}
- }
- else if (currentElement.LocalName == LEVEL_TAG || currentElement.LocalName == PRIORITY_TAG)
+ }
+ else if (currentElement.LocalName == LEVEL_TAG || currentElement.LocalName == PRIORITY_TAG)
{
- ParseLevel(currentElement, log, isRoot);
- }
+ ParseLevel(currentElement, log, isRoot);
+ }
else
{
SetParameter(currentElement, log);
@@ -459,7 +459,7 @@
}
IOptionHandler optionHandler = log as IOptionHandler;
- if (optionHandler != null)
+ if (optionHandler != null)
{
optionHandler.ActivateOptions();
}
@@ -474,29 +474,29 @@
/// Parse an XML element that represents a renderer.
/// </para>
/// </remarks>
- protected void ParseRenderer(XmlElement element)
+ protected void ParseRenderer(XmlElement element)
{
string renderingClassName = element.GetAttribute(RENDERING_TYPE_ATTR);
string renderedClassName = element.GetAttribute(RENDERED_TYPE_ATTR);
LogLog.Debug(declaringType, "Rendering class [" + renderingClassName + "], Rendered class [" + renderedClassName + "].");
IObjectRenderer renderer = (IObjectRenderer)OptionConverter.InstantiateByClassName(renderingClassName, typeof(IObjectRenderer), null);
- if (renderer == null)
+ if (renderer == null)
{
LogLog.Error(declaringType, "Could not instantiate renderer [" + renderingClassName + "].");
return;
- }
- else
+ }
+ else
{
- try
+ try
{
#if NETSTANDARD1_3
m_hierarchy.RendererMap.Put(SystemInfo.GetTypeFromString(this.GetType().GetTypeInfo().Assembly, renderedClassName, true, true), renderer);
#else
m_hierarchy.RendererMap.Put(SystemInfo.GetTypeFromString(renderedClassName, true, true), renderer);
#endif
- }
- catch(Exception e)
+ }
+ catch (Exception e)
{
LogLog.Error(declaringType, "Could not find class [" + renderedClassName + "].", e);
}
@@ -514,30 +514,30 @@
/// Parse an XML element that represents a level.
/// </para>
/// </remarks>
- protected void ParseLevel(XmlElement element, Logger log, bool isRoot)
+ protected void ParseLevel(XmlElement element, Logger log, bool isRoot)
{
string loggerName = log.Name;
- if (isRoot)
+ if (isRoot)
{
loggerName = "root";
}
string levelStr = element.GetAttribute(VALUE_ATTR);
LogLog.Debug(declaringType, "Logger [" + loggerName + "] Level string is [" + levelStr + "].");
-
- if (INHERITED == levelStr)
+
+ if (INHERITED == levelStr)
{
- if (isRoot)
+ if (isRoot)
{
LogLog.Error(declaringType, "Root level cannot be inherited. Ignoring directive.");
- }
- else
+ }
+ else
{
- LogLog.Debug(declaringType, "Logger [" + loggerName + "] level set to inherit from parent.");
+ LogLog.Debug(declaringType, "Logger [" + loggerName + "] level set to inherit from parent.");
log.Level = null;
}
- }
- else
+ }
+ else
{
log.Level = log.Hierarchy.LevelMap[levelStr];
if (log.Level == null)
@@ -546,7 +546,7 @@
}
else
{
- LogLog.Debug(declaringType, "Logger [" + loggerName + "] level set to [name=\"" + log.Level.Name + "\",value=" + log.Level.Value + "].");
+ LogLog.Debug(declaringType, "Logger [" + loggerName + "] level set to [name=\"" + log.Level.Name + "\",value=" + log.Level.Value + "].");
}
}
}
@@ -567,7 +567,7 @@
/// string argument and return a value that can be used to
/// set the property.
/// </remarks>
- protected void SetParameter(XmlElement element, object target)
+ protected void SetParameter(XmlElement element, object target)
{
// Get the property name
string name = element.GetAttribute(NAME_ATTR);
@@ -620,7 +620,7 @@
else if (element.HasChildNodes)
{
// Concatenate the CDATA and Text nodes together
- foreach(XmlNode childNode in element.ChildNodes)
+ foreach (XmlNode childNode in element.ChildNodes)
{
if (childNode.NodeType == XmlNodeType.CDATA || childNode.NodeType == XmlNodeType.Text)
{
@@ -636,19 +636,20 @@
}
}
- if(propertyValue != null)
+ if (propertyValue != null)
{
#if !NETCF && !NETSTANDARD1_3 // NETSTANDARD1_3: System.Runtime.InteropServices.RuntimeInformation not available on desktop 4.6
try
{
// Expand environment variables in the string.
- IDictionary environmentVariables = Environment.GetEnvironmentVariables();
- if (HasCaseInsensitiveEnvironment) {
- environmentVariables = CreateCaseInsensitiveWrapper(environmentVariables);
- }
+ IDictionary environmentVariables = Environment.GetEnvironmentVariables();
+ if (HasCaseInsensitiveEnvironment)
+ {
+ environmentVariables = CreateCaseInsensitiveWrapper(environmentVariables);
+ }
propertyValue = OptionConverter.SubstituteVariables(propertyValue, environmentVariables);
}
- catch(System.Security.SecurityException)
+ catch (System.Security.SecurityException)
{
// This security exception will occur if the caller does not have
// unrestricted environment permission. If this occurs the expansion
@@ -672,7 +673,7 @@
Type subType = SystemInfo.GetTypeFromString(subTypeString, true, true);
#endif
- LogLog.Debug(declaringType, "Parameter ["+name+"] specified subtype ["+subType.FullName+"]");
+ LogLog.Debug(declaringType, "Parameter [" + name + "] specified subtype [" + subType.FullName + "]");
if (!propertyType.IsAssignableFrom(subType))
{
@@ -687,7 +688,7 @@
}
else
{
- LogLog.Error(declaringType, "subtype ["+subType.FullName+"] set on ["+name+"] is not a subclass of property type ["+propertyType.FullName+"] and there are no acceptable type conversions.");
+ LogLog.Error(declaringType, "subtype [" + subType.FullName + "] set on [" + name + "] is not a subclass of property type [" + propertyType.FullName + "] and there are no acceptable type conversions.");
}
}
else
@@ -697,9 +698,9 @@
propertyType = subType;
}
}
- catch(Exception ex)
+ catch (Exception ex)
{
- LogLog.Error(declaringType, "Failed to find type ["+subTypeString+"] set on ["+name+"]", ex);
+ LogLog.Error(declaringType, "Failed to find type [" + subTypeString + "] set on [" + name + "]", ex);
}
}
@@ -707,7 +708,7 @@
// to pass to this property.
object convertedValue = ConvertStringTo(propertyType, propertyValue);
-
+
// Check if we need to do an additional conversion
if (convertedValue != null && parsedObjectConversionTargetType != null)
{
@@ -731,7 +732,7 @@
propInfo.SetValue(target, convertedValue, BindingFlags.SetProperty, null, null, CultureInfo.InvariantCulture);
#endif
}
- catch(TargetInvocationException targetInvocationEx)
+ catch (TargetInvocationException targetInvocationEx)
{
LogLog.Error(declaringType, "Failed to set parameter [" + propInfo.Name + "] on object [" + target + "] using value [" + convertedValue + "]", targetInvocationEx.InnerException);
}
@@ -747,10 +748,10 @@
#if NETSTANDARD1_3 // TODO BindingFlags is available for netstandard1.5
methInfo.Invoke(target, new[] { convertedValue });
#else
- methInfo.Invoke(target, BindingFlags.InvokeMethod, null, new object[] {convertedValue}, CultureInfo.InvariantCulture);
+ methInfo.Invoke(target, BindingFlags.InvokeMethod, null, new object[] { convertedValue }, CultureInfo.InvariantCulture);
#endif
}
- catch(TargetInvocationException targetInvocationEx)
+ catch (TargetInvocationException targetInvocationEx)
{
LogLog.Error(declaringType, "Failed to set parameter [" + name + "] on object [" + target + "] using value [" + convertedValue + "]", targetInvocationEx.InnerException);
}
@@ -788,14 +789,14 @@
if (createdObject == null)
{
- LogLog.Error(declaringType, "Failed to create object to set param: "+name);
+ LogLog.Error(declaringType, "Failed to create object to set param: " + name);
}
else
{
if (propInfo != null)
{
// Got a converted result
- LogLog.Debug(declaringType, "Setting Property ["+ propInfo.Name +"] to object ["+ createdObject +"]");
+ LogLog.Debug(declaringType, "Setting Property [" + propInfo.Name + "] to object [" + createdObject + "]");
try
{
@@ -806,7 +807,7 @@
propInfo.SetValue(target, createdObject, BindingFlags.SetProperty, null, null, CultureInfo.InvariantCulture);
#endif
}
- catch(TargetInvocationException targetInvocationEx)
+ catch (TargetInvocationException targetInvocationEx)
{
LogLog.Error(declaringType, "Failed to set parameter [" + propInfo.Name + "] on object [" + target + "] using value [" + createdObject + "]", targetInvocationEx.InnerException);
}
@@ -814,7 +815,7 @@
else if (methInfo != null)
{
// Got a converted result
- LogLog.Debug(declaringType, "Setting Collection Property ["+ methInfo.Name +"] to object ["+ createdObject +"]");
+ LogLog.Debug(declaringType, "Setting Collection Property [" + methInfo.Name + "] to object [" + createdObject + "]");
try
{
@@ -822,10 +823,10 @@
#if NETSTANDARD1_3 // TODO BindingFlags is available for netstandard1.5
methInfo.Invoke(target, new[] { createdObject });
#else
- methInfo.Invoke(target, BindingFlags.InvokeMethod, null, new object[] {createdObject}, CultureInfo.InvariantCulture);
+ methInfo.Invoke(target, BindingFlags.InvokeMethod, null, new object[] { createdObject }, CultureInfo.InvariantCulture);
#endif
}
- catch(TargetInvocationException targetInvocationEx)
+ catch (TargetInvocationException targetInvocationEx)
{
LogLog.Error(declaringType, "Failed to set parameter [" + methInfo.Name + "] on object [" + target + "] using value [" + createdObject + "]", targetInvocationEx.InnerException);
}
@@ -842,7 +843,7 @@
/// <returns><c>true</c> if the element has any attributes or child elements, <c>false</c> otherwise</returns>
private bool HasAttributesOrElements(XmlElement element)
{
- foreach(XmlNode node in element.ChildNodes)
+ foreach (XmlNode node in element.ChildNodes)
{
if (node.NodeType == XmlNodeType.Attribute || node.NodeType == XmlNodeType.Element)
{
@@ -895,7 +896,7 @@
MethodInfo[] methods = targetType.GetMethods(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
- foreach(MethodInfo methInfo in methods)
+ foreach (MethodInfo methInfo in methods)
{
if (!methInfo.IsStatic)
{
@@ -939,7 +940,7 @@
if (levelValue == null)
{
- LogLog.Error(declaringType, "XmlHierarchyConfigurator: Unknown Level Specified ["+ value +"]");
+ LogLog.Error(declaringType, "XmlHierarchyConfigurator: Unknown Level Specified [" + value + "]");
}
return levelValue;
@@ -966,7 +967,7 @@
/// <paramref name="typeConstraint"/> type.
/// </para>
/// </remarks>
- protected object CreateObjectFromXml(XmlElement element, Type defaultTargetType, Type typeConstraint)
+ protected object CreateObjectFromXml(XmlElement element, Type defaultTargetType, Type typeConstraint)
{
Type objectType = null;
@@ -976,7 +977,7 @@
{
if (defaultTargetType == null)
{
- LogLog.Error(declaringType, "Object type not specified. Cannot create object of type ["+typeConstraint.FullName+"]. Missing Value or Type.");
+ LogLog.Error(declaringType, "Object type not specified. Cannot create object of type [" + typeConstraint.FullName + "]. Missing Value or Type.");
return null;
}
else
@@ -996,9 +997,9 @@
objectType = SystemInfo.GetTypeFromString(objectTypeString, true, true);
#endif
}
- catch(Exception ex)
+ catch (Exception ex)
{
- LogLog.Error(declaringType, "Failed to find type ["+objectTypeString+"]", ex);
+ LogLog.Error(declaringType, "Failed to find type [" + objectTypeString + "]", ex);
return null;
}
}
@@ -1017,7 +1018,7 @@
}
else
{
- LogLog.Error(declaringType, "Object type ["+objectType.FullName+"] is not assignable to type ["+typeConstraint.FullName+"]. There are no acceptable type conversions.");
+ LogLog.Error(declaringType, "Object type [" + objectType.FullName + "] is not assignable to type [" + typeConstraint.FullName + "]. There are no acceptable type conversions.");
return null;
}
}
@@ -1029,15 +1030,15 @@
{
createdObject = Activator.CreateInstance(objectType);
}
- catch(Exception createInstanceEx)
+ catch (Exception createInstanceEx)
{
- LogLog.Error(declaringType, "XmlHierarchyConfigurator: Failed to construct object of type [" + objectType.FullName + "] Exception: "+createInstanceEx.ToString());
+ LogLog.Error(declaringType, "XmlHierarchyConfigurator: Failed to construct object of type [" + objectType.FullName + "] Exception: " + createInstanceEx.ToString());
}
// Set any params on object
foreach (XmlNode currentNode in element.ChildNodes)
{
- if (currentNode.NodeType == XmlNodeType.Element)
+ if (currentNode.NodeType == XmlNodeType.Element)
{
SetParameter((XmlElement)currentNode, createdObject);
}
@@ -1068,9 +1069,9 @@
#if !NETCF && !NETSTANDARD1_3 // NETSTANDARD1_3: System.Runtime.InteropServices.RuntimeInformation not available on desktop 4.6
private bool HasCaseInsensitiveEnvironment
- {
- get
- {
+ {
+ get
+ {
#if NET_1_0 || NET_1_1 || CLI_1_0
// actually there is no guarantee, but we don't know better
return true;
@@ -1078,55 +1079,56 @@
// see above
return false;
#else
- PlatformID platform = Environment.OSVersion.Platform;
- return platform != PlatformID.Unix && platform != PlatformID.MacOSX;
+ PlatformID platform = Environment.OSVersion.Platform;
+ return platform != PlatformID.Unix && platform != PlatformID.MacOSX;
#endif
- }
+ }
}
- private IDictionary CreateCaseInsensitiveWrapper(IDictionary dict)
- {
- if (dict == null)
- {
- return dict;
- }
- Hashtable hash = SystemInfo.CreateCaseInsensitiveHashtable();
- foreach (DictionaryEntry entry in dict) {
- hash[entry.Key] = entry.Value;
- }
- return hash;
+ private IDictionary CreateCaseInsensitiveWrapper(IDictionary dict)
+ {
+ if (dict == null)
+ {
+ return dict;
+ }
+ Hashtable hash = SystemInfo.CreateCaseInsensitiveHashtable();
+ foreach (DictionaryEntry entry in dict)
+ {
+ hash[entry.Key] = entry.Value;
+ }
+ return hash;
}
#endif
#region Private Constants
// String constants used while parsing the XML data
- private const string CONFIGURATION_TAG = "log4net";
- private const string RENDERER_TAG = "renderer";
- private const string APPENDER_TAG = "appender";
- private const string APPENDER_REF_TAG = "appender-ref";
- private const string PARAM_TAG = "param";
+ private const string CONFIGURATION_TAG = "log4net";
+ private const string RENDERER_TAG = "renderer";
+ private const string APPENDER_TAG = "appender";
+ private const string APPENDER_REF_TAG = "appender-ref";
+ private const string PARAM_TAG = "param";
// TODO: Deprecate use of category tags
- private const string CATEGORY_TAG = "category";
+ private const string CATEGORY_TAG = "category";
// TODO: Deprecate use of priority tag
- private const string PRIORITY_TAG = "priority";
+ private const string PRIORITY_TAG = "priority";
- private const string LOGGER_TAG = "logger";
- private const string NAME_ATTR = "name";
- private const string TYPE_ATTR = "type";
- private const string VALUE_ATTR = "value";
- private const string ROOT_TAG = "root";
- private const string LEVEL_TAG = "level";
- private const string REF_ATTR = "ref";
- private const string ADDITIVITY_ATTR = "additivity";
- private const string THRESHOLD_ATTR = "threshold";
- private const string CONFIG_DEBUG_ATTR = "configDebug";
- private const string INTERNAL_DEBUG_ATTR = "debug";
- private const string EMIT_INTERNAL_DEBUG_ATTR = "emitDebug";
- private const string CONFIG_UPDATE_MODE_ATTR = "update";
- private const string RENDERING_TYPE_ATTR = "renderingClass";
- private const string RENDERED_TYPE_ATTR = "renderedClass";
+ private const string LOGGER_TAG = "logger";
+ private const string NAME_ATTR = "name";
+ private const string TYPE_ATTR = "type";
+ private const string VALUE_ATTR = "value";
+ private const string ROOT_TAG = "root";
+ private const string LEVEL_TAG = "level";
+ private const string REF_ATTR = "ref";
+ private const string ADDITIVITY_ATTR = "additivity";
+ private const string THRESHOLD_ATTR = "threshold";
+ private const string CONFIG_DEBUG_ATTR = "configDebug";
+ private const string INTERNAL_DEBUG_ATTR = "debug";
+ private const string EMIT_INTERNAL_DEBUG_ATTR = "emitDebug";
+ private const string CONFIG_UPDATE_MODE_ATTR = "update";
+ private const string RENDERING_TYPE_ATTR = "renderingClass";
+ private const string RENDERED_TYPE_ATTR = "renderedClass";
// flag used on the level element
private const string INHERITED = "inherited";
@@ -1147,17 +1149,17 @@
#endregion Private Instance Fields
- #region Private Static Fields
+ #region Private Static Fields
- /// <summary>
- /// The fully qualified type of the XmlHierarchyConfigurator class.
- /// </summary>
- /// <remarks>
- /// Used by the internal logger to record the Type of the
- /// log message.
- /// </remarks>
- private static readonly Type declaringType = typeof(XmlHierarchyConfigurator);
+ /// <summary>
+ /// The fully qualified type of the XmlHierarchyConfigurator class.
+ /// </summary>
+ /// <remarks>
+ /// Used by the internal logger to record the Type of the
+ /// log message.
+ /// </remarks>
+ private static readonly Type declaringType = typeof(XmlHierarchyConfigurator);
- #endregion Private Static Fields
+ #endregion Private Static Fields
}
}
diff --git a/src/log4net/Repository/IBasicRepositoryConfigurator.cs b/src/log4net/Repository/IBasicRepositoryConfigurator.cs
index b6196f7..a0bfb2f 100644
--- a/src/log4net/Repository/IBasicRepositoryConfigurator.cs
+++ b/src/log4net/Repository/IBasicRepositoryConfigurator.cs
@@ -46,18 +46,18 @@
/// specified appender.
/// </para>
/// </remarks>
- void Configure(Appender.IAppender appender);
+ void Configure(Appender.IAppender appender);
- /// <summary>
- /// Initialize the repository using the specified appenders
- /// </summary>
- /// <param name="appenders">the appenders to use to log all logging events</param>
- /// <remarks>
- /// <para>
- /// Configure the repository to route all logging events to the
- /// specified appenders.
- /// </para>
- /// </remarks>
- void Configure(params Appender.IAppender[] appenders);
+ /// <summary>
+ /// Initialize the repository using the specified appenders
+ /// </summary>
+ /// <param name="appenders">the appenders to use to log all logging events</param>
+ /// <remarks>
+ /// <para>
+ /// Configure the repository to route all logging events to the
+ /// specified appenders.
+ /// </para>
+ /// </remarks>
+ void Configure(params Appender.IAppender[] appenders);
}
}
diff --git a/src/log4net/Repository/ILoggerRepository.cs b/src/log4net/Repository/ILoggerRepository.cs
index 9ea0fd4..29d64ea 100644
--- a/src/log4net/Repository/ILoggerRepository.cs
+++ b/src/log4net/Repository/ILoggerRepository.cs
@@ -74,8 +74,8 @@
/// </remarks>
public delegate void LoggerRepositoryConfigurationChangedEventHandler(object sender, EventArgs e);
- #endregion
-
+ #endregion
+
/// <summary>
/// Interface implemented by logger repositories.
/// </summary>
@@ -276,11 +276,11 @@
/// </remarks>
bool Configured { get; set; }
- /// <summary>
- /// Collection of internal messages captured during the most
- /// recent configuration process.
- /// </summary>
- ICollection ConfigurationMessages { get; set; }
+ /// <summary>
+ /// Collection of internal messages captured during the most
+ /// recent configuration process.
+ /// </summary>
+ ICollection ConfigurationMessages { get; set; }
/// <summary>
/// Event to notify that the repository has been shutdown.
diff --git a/src/log4net/Repository/LoggerRepositorySkeleton.cs b/src/log4net/Repository/LoggerRepositorySkeleton.cs
index 7a69a24..11afa00 100644
--- a/src/log4net/Repository/LoggerRepositorySkeleton.cs
+++ b/src/log4net/Repository/LoggerRepositorySkeleton.cs
@@ -51,7 +51,7 @@
private LevelMap m_levelMap;
private Level m_threshold;
private bool m_configured;
- private ICollection m_configurationMessages;
+ private ICollection m_configurationMessages;
private event LoggerRepositoryShutdownEventHandler m_shutdownEvent;
private event LoggerRepositoryConfigurationResetEventHandler m_configurationResetEvent;
private event LoggerRepositoryConfigurationChangedEventHandler m_configurationChangedEvent;
@@ -88,7 +88,7 @@
m_rendererMap = new RendererMap();
m_pluginMap = new PluginMap(this);
m_levelMap = new LevelMap();
- m_configurationMessages = EmptyCollection.Instance;
+ m_configurationMessages = EmptyCollection.Instance;
m_configured = false;
AddBuiltinLevels();
@@ -135,10 +135,10 @@
{
get { return m_threshold; }
set
- {
+ {
if (value != null)
{
- m_threshold = value;
+ m_threshold = value;
}
else
{
@@ -255,10 +255,10 @@
/// listeners and all attached plugins of the shutdown event.
/// </para>
/// </remarks>
- public virtual void Shutdown()
+ public virtual void Shutdown()
{
// Shutdown attached plugins
- foreach(IPlugin plugin in PluginMap.AllPlugins)
+ foreach (IPlugin plugin in PluginMap.AllPlugins)
{
plugin.Shutdown();
}
@@ -283,12 +283,12 @@
/// block all logging until it is completed.
/// </para>
/// </remarks>
- public virtual void ResetConfiguration()
+ public virtual void ResetConfiguration()
{
// Clear internal data structures
m_rendererMap.Clear();
m_levelMap.Clear();
- m_configurationMessages = EmptyCollection.Instance;
+ m_configurationMessages = EmptyCollection.Instance;
// Add the predefined levels to the map
AddBuiltinLevels();
@@ -328,23 +328,23 @@
/// Flag indicates if this repository has been configured.
/// </para>
/// </remarks>
- public virtual bool Configured
- {
+ public virtual bool Configured
+ {
get { return m_configured; }
set { m_configured = value; }
}
- /// <summary>
- /// Contains a list of internal messages captures during the
- /// last configuration.
- /// </summary>
- public virtual ICollection ConfigurationMessages
- {
- get { return m_configurationMessages; }
- set { m_configurationMessages = value; }
- }
+ /// <summary>
+ /// Contains a list of internal messages captures during the
+ /// last configuration.
+ /// </summary>
+ public virtual ICollection ConfigurationMessages
+ {
+ get { return m_configurationMessages; }
+ set { m_configurationMessages = value; }
+ }
- /// <summary>
+ /// <summary>
/// Event to notify that the repository has been shutdown.
/// </summary>
/// <value>
@@ -405,9 +405,9 @@
/// <remarks>
/// These properties can be specified on a repository specific basis
/// </remarks>
- public PropertiesDictionary Properties
- {
- get { return m_properties; }
+ public PropertiesDictionary Properties
+ {
+ get { return m_properties; }
}
/// <summary>
@@ -423,18 +423,18 @@
#endregion
- #region Private Static Fields
+ #region Private Static Fields
- /// <summary>
- /// The fully qualified type of the LoggerRepositorySkeleton class.
- /// </summary>
- /// <remarks>
- /// Used by the internal logger to record the Type of the
- /// log message.
- /// </remarks>
- private static readonly Type declaringType = typeof(LoggerRepositorySkeleton);
+ /// <summary>
+ /// The fully qualified type of the LoggerRepositorySkeleton class.
+ /// </summary>
+ /// <remarks>
+ /// Used by the internal logger to record the Type of the
+ /// log message.
+ /// </remarks>
+ private static readonly Type declaringType = typeof(LoggerRepositorySkeleton);
- #endregion Private Static Fields
+ #endregion Private Static Fields
private void AddBuiltinLevels()
{
@@ -444,17 +444,17 @@
// Unrecoverable errors
m_levelMap.Add(Level.Emergency);
m_levelMap.Add(Level.Fatal);
- m_levelMap.Add(Level.Alert);
+ m_levelMap.Add(Level.Alert);
// Recoverable errors
- m_levelMap.Add(Level.Critical);
- m_levelMap.Add(Level.Severe);
- m_levelMap.Add(Level.Error);
+ m_levelMap.Add(Level.Critical);
+ m_levelMap.Add(Level.Severe);
+ m_levelMap.Add(Level.Error);
m_levelMap.Add(Level.Warn);
// Information
- m_levelMap.Add(Level.Notice);
- m_levelMap.Add(Level.Info);
+ m_levelMap.Add(Level.Notice);
+ m_levelMap.Add(Level.Info);
// Debug
m_levelMap.Add(Level.Debug);
@@ -477,7 +477,7 @@
/// Adds an object renderer for a specific class.
/// </para>
/// </remarks>
- public virtual void AddRenderer(Type typeToRender, IObjectRenderer rendererInstance)
+ public virtual void AddRenderer(Type typeToRender, IObjectRenderer rendererInstance)
{
if (typeToRender == null)
{
@@ -575,58 +575,58 @@
OnConfigurationChanged(e);
}
- private static int GetWaitTime(DateTime startTimeUtc, int millisecondsTimeout)
+ private static int GetWaitTime(DateTime startTimeUtc, int millisecondsTimeout)
+ {
+ if (millisecondsTimeout == Timeout.Infinite) return Timeout.Infinite;
+ if (millisecondsTimeout == 0) return 0;
+
+ int elapsedMilliseconds = (int)(DateTime.UtcNow - startTimeUtc).TotalMilliseconds;
+ int timeout = millisecondsTimeout - elapsedMilliseconds;
+ if (timeout < 0) timeout = 0;
+ return timeout;
+ }
+
+ /// <summary>
+ /// Flushes all configured Appenders that implement <see cref="log4net.Appender.IFlushable"/>.
+ /// </summary>
+ /// <param name="millisecondsTimeout">The maximum time in milliseconds to wait for logging events from asycnhronous appenders to be flushed,
+ /// or <see cref="Timeout.Infinite"/> to wait indefinitely.</param>
+ /// <returns><c>True</c> if all logging events were flushed successfully, else <c>false</c>.</returns>
+ public bool Flush(int millisecondsTimeout)
+ {
+ if (millisecondsTimeout < -1) throw new ArgumentOutOfRangeException("millisecondsTimeout", "Timeout must be -1 (Timeout.Infinite) or non-negative");
+
+ // Assume success until one of the appenders fails
+ bool result = true;
+
+ // Use DateTime.UtcNow rather than a System.Diagnostics.Stopwatch for compatibility with .NET 1.x
+ DateTime startTimeUtc = DateTime.UtcNow;
+
+ // Do buffering appenders first. These may be forwarding to other appenders
+ foreach (log4net.Appender.IAppender appender in GetAppenders())
+ {
+ log4net.Appender.IFlushable flushable = appender as log4net.Appender.IFlushable;
+ if (flushable == null) continue;
+ if (appender is Appender.BufferingAppenderSkeleton)
{
- if (millisecondsTimeout == Timeout.Infinite) return Timeout.Infinite;
- if (millisecondsTimeout == 0) return 0;
-
- int elapsedMilliseconds = (int)(DateTime.UtcNow - startTimeUtc).TotalMilliseconds;
- int timeout = millisecondsTimeout - elapsedMilliseconds;
- if (timeout < 0) timeout = 0;
- return timeout;
+ int timeout = GetWaitTime(startTimeUtc, millisecondsTimeout);
+ if (!flushable.Flush(timeout)) result = false;
}
+ }
- /// <summary>
- /// Flushes all configured Appenders that implement <see cref="log4net.Appender.IFlushable"/>.
- /// </summary>
- /// <param name="millisecondsTimeout">The maximum time in milliseconds to wait for logging events from asycnhronous appenders to be flushed,
- /// or <see cref="Timeout.Infinite"/> to wait indefinitely.</param>
- /// <returns><c>True</c> if all logging events were flushed successfully, else <c>false</c>.</returns>
- public bool Flush(int millisecondsTimeout)
+ // Do non-buffering appenders.
+ foreach (log4net.Appender.IAppender appender in GetAppenders())
+ {
+ log4net.Appender.IFlushable flushable = appender as log4net.Appender.IFlushable;
+ if (flushable == null) continue;
+ if (!(appender is Appender.BufferingAppenderSkeleton))
{
- if (millisecondsTimeout < -1) throw new ArgumentOutOfRangeException("millisecondsTimeout", "Timeout must be -1 (Timeout.Infinite) or non-negative");
-
- // Assume success until one of the appenders fails
- bool result = true;
-
- // Use DateTime.UtcNow rather than a System.Diagnostics.Stopwatch for compatibility with .NET 1.x
- DateTime startTimeUtc = DateTime.UtcNow;
-
- // Do buffering appenders first. These may be forwarding to other appenders
- foreach(log4net.Appender.IAppender appender in GetAppenders())
- {
- log4net.Appender.IFlushable flushable = appender as log4net.Appender.IFlushable;
- if (flushable == null) continue;
- if (appender is Appender.BufferingAppenderSkeleton)
- {
- int timeout = GetWaitTime(startTimeUtc, millisecondsTimeout);
- if (!flushable.Flush(timeout)) result = false;
- }
- }
-
- // Do non-buffering appenders.
- foreach (log4net.Appender.IAppender appender in GetAppenders())
- {
- log4net.Appender.IFlushable flushable = appender as log4net.Appender.IFlushable;
- if (flushable == null) continue;
- if (!(appender is Appender.BufferingAppenderSkeleton))
- {
- int timeout = GetWaitTime(startTimeUtc, millisecondsTimeout);
- if (!flushable.Flush(timeout)) result = false;
- }
- }
-
- return result;
+ int timeout = GetWaitTime(startTimeUtc, millisecondsTimeout);
+ if (!flushable.Flush(timeout)) result = false;
}
+ }
+
+ return result;
+ }
}
}
diff --git a/src/log4net/Util/AppenderAttachedImpl.cs b/src/log4net/Util/AppenderAttachedImpl.cs
index b6fc0fd..f638f2b 100644
--- a/src/log4net/Util/AppenderAttachedImpl.cs
+++ b/src/log4net/Util/AppenderAttachedImpl.cs
@@ -67,7 +67,7 @@
/// attached appenders.
/// </para>
/// </remarks>
- public int AppendLoopOnAppenders(LoggingEvent loggingEvent)
+ public int AppendLoopOnAppenders(LoggingEvent loggingEvent)
{
if (loggingEvent == null)
{
@@ -75,7 +75,7 @@
}
// m_appenderList is null when empty
- if (m_appenderList == null)
+ if (m_appenderList == null)
{
return 0;
}
@@ -85,13 +85,13 @@
m_appenderArray = m_appenderList.ToArray();
}
- foreach(IAppender appender in m_appenderArray)
+ foreach (IAppender appender in m_appenderArray)
{
try
{
appender.DoAppend(loggingEvent);
}
- catch(Exception ex)
+ catch (Exception ex)
{
LogLog.Error(declaringType, "Failed to append to appender [" + appender.Name + "]", ex);
}
@@ -110,7 +110,7 @@
/// attached appenders.
/// </para>
/// </remarks>
- public int AppendLoopOnAppenders(LoggingEvent[] loggingEvents)
+ public int AppendLoopOnAppenders(LoggingEvent[] loggingEvents)
{
if (loggingEvents == null)
{
@@ -127,7 +127,7 @@
}
// m_appenderList is null when empty
- if (m_appenderList == null)
+ if (m_appenderList == null)
{
return 0;
}
@@ -137,13 +137,13 @@
m_appenderArray = m_appenderList.ToArray();
}
- foreach(IAppender appender in m_appenderArray)
+ foreach (IAppender appender in m_appenderArray)
{
try
{
CallAppend(appender, loggingEvents);
}
- catch(Exception ex)
+ catch (Exception ex)
{
LogLog.Error(declaringType, "Failed to append to appender [" + appender.Name + "]", ex);
}
@@ -153,9 +153,9 @@
#endregion Public Instance Methods
- #region Private Static Methods
+ #region Private Static Methods
- /// <summary>
+ /// <summary>
/// Calls the DoAppende method on the <see cref="IAppender"/> with
/// the <see cref="LoggingEvent"/> objects supplied.
/// </summary>
@@ -178,18 +178,18 @@
}
else
{
- foreach(LoggingEvent loggingEvent in loggingEvents)
+ foreach (LoggingEvent loggingEvent in loggingEvents)
{
appender.DoAppend(loggingEvent);
}
}
- }
+ }
- #endregion
+ #endregion
- #region Implementation of IAppenderAttachable
+ #region Implementation of IAppenderAttachable
- /// <summary>
+ /// <summary>
/// Attaches an appender.
/// </summary>
/// <param name="newAppender">The appender to add.</param>
@@ -198,16 +198,16 @@
/// If the appender is already in the list it won't be added again.
/// </para>
/// </remarks>
- public void AddAppender(IAppender newAppender)
+ public void AddAppender(IAppender newAppender)
{
// Null values for newAppender parameter are strictly forbidden.
if (newAppender == null)
{
throw new ArgumentNullException("newAppender");
}
-
+
m_appenderArray = null;
- if (m_appenderList == null)
+ if (m_appenderList == null)
{
m_appenderList = new AppenderCollection(1);
}
@@ -229,7 +229,7 @@
/// The read only collection of all currently attached appenders.
/// </para>
/// </remarks>
- public AppenderCollection Appenders
+ public AppenderCollection Appenders
{
get
{
@@ -238,7 +238,7 @@
// We must always return a valid collection
return AppenderCollection.EmptyCollection;
}
- else
+ else
{
return AppenderCollection.ReadOnly(m_appenderList);
}
@@ -258,11 +258,11 @@
/// Lookup an attached appender by name.
/// </para>
/// </remarks>
- public IAppender GetAppender(string name)
+ public IAppender GetAppender(string name)
{
if (m_appenderList != null && name != null)
{
- foreach(IAppender appender in m_appenderList)
+ foreach (IAppender appender in m_appenderList)
{
if (name == appender.Name)
{
@@ -270,7 +270,7 @@
}
}
}
- return null;
+ return null;
}
/// <summary>
@@ -281,22 +281,22 @@
/// Removes and closes all attached appenders
/// </para>
/// </remarks>
- public void RemoveAllAppenders()
+ public void RemoveAllAppenders()
{
- if (m_appenderList != null)
+ if (m_appenderList != null)
{
- foreach(IAppender appender in m_appenderList)
+ foreach (IAppender appender in m_appenderList)
{
try
{
appender.Close();
}
- catch(Exception ex)
+ catch (Exception ex)
{
- LogLog.Error(declaringType, "Failed to Close appender ["+appender.Name+"]", ex);
+ LogLog.Error(declaringType, "Failed to Close appender [" + appender.Name + "]", ex);
}
}
- m_appenderList = null;
+ m_appenderList = null;
m_appenderArray = null;
}
}
@@ -313,9 +313,9 @@
/// <see cref="IAppender.Close"/> on the appender removed.
/// </para>
/// </remarks>
- public IAppender RemoveAppender(IAppender appender)
+ public IAppender RemoveAppender(IAppender appender)
{
- if (appender != null && m_appenderList != null)
+ if (appender != null && m_appenderList != null)
{
m_appenderList.Remove(appender);
if (m_appenderList.Count == 0)
@@ -339,7 +339,7 @@
/// <see cref="IAppender.Close"/> on the appender removed.
/// </para>
/// </remarks>
- public IAppender RemoveAppender(string name)
+ public IAppender RemoveAppender(string name)
{
return RemoveAppender(GetAppender(name));
}
@@ -360,17 +360,17 @@
#endregion Private Instance Fields
- #region Private Static Fields
+ #region Private Static Fields
- /// <summary>
- /// The fully qualified type of the AppenderAttachedImpl class.
- /// </summary>
- /// <remarks>
- /// Used by the internal logger to record the Type of the
- /// log message.
- /// </remarks>
- private static readonly Type declaringType = typeof(AppenderAttachedImpl);
+ /// <summary>
+ /// The fully qualified type of the AppenderAttachedImpl class.
+ /// </summary>
+ /// <remarks>
+ /// Used by the internal logger to record the Type of the
+ /// log message.
+ /// </remarks>
+ private static readonly Type declaringType = typeof(AppenderAttachedImpl);
- #endregion Private Static Fields
+ #endregion Private Static Fields
}
}
diff --git a/src/log4net/Util/CompositeProperties.cs b/src/log4net/Util/CompositeProperties.cs
index 987661c..66ac7b7 100644
--- a/src/log4net/Util/CompositeProperties.cs
+++ b/src/log4net/Util/CompositeProperties.cs
@@ -80,7 +80,7 @@
/// </remarks>
public object this[string key]
{
- get
+ get
{
// Look in the flattened properties first
if (m_flattened != null)
@@ -89,7 +89,7 @@
}
// Look for the key in all the nested properties
- foreach(ReadOnlyPropertiesDictionary cur in m_nestedProperties)
+ foreach (ReadOnlyPropertiesDictionary cur in m_nestedProperties)
{
if (cur.Contains(key))
{
@@ -136,11 +136,11 @@
{
m_flattened = new PropertiesDictionary();
- for(int i=m_nestedProperties.Count; --i>=0; )
+ for (int i = m_nestedProperties.Count; --i >= 0;)
{
ReadOnlyPropertiesDictionary cur = (ReadOnlyPropertiesDictionary)m_nestedProperties[i];
- foreach(DictionaryEntry entry in cur)
+ foreach (DictionaryEntry entry in cur)
{
m_flattened[(string)entry.Key] = entry.Value;
}
diff --git a/src/log4net/Util/ConverterInfo.cs b/src/log4net/Util/ConverterInfo.cs
index b64edc9..31b189e 100644
--- a/src/log4net/Util/ConverterInfo.cs
+++ b/src/log4net/Util/ConverterInfo.cs
@@ -23,72 +23,72 @@
namespace log4net.Util
{
+ /// <summary>
+ /// Wrapper class used to map converter names to converter types
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Pattern converter info class used during configuration by custom
+ /// PatternString and PatternLayer converters.
+ /// </para>
+ /// </remarks>
+ public sealed class ConverterInfo
+ {
+ private string m_name;
+ private Type m_type;
+ private readonly PropertiesDictionary properties = new PropertiesDictionary();
+
/// <summary>
- /// Wrapper class used to map converter names to converter types
+ /// default constructor
+ /// </summary>
+ public ConverterInfo()
+ {
+ }
+
+ /// <summary>
+ /// Gets or sets the name of the conversion pattern
/// </summary>
/// <remarks>
/// <para>
- /// Pattern converter info class used during configuration by custom
- /// PatternString and PatternLayer converters.
+ /// The name of the pattern in the format string
/// </para>
/// </remarks>
- public sealed class ConverterInfo
+ public string Name
{
- private string m_name;
- private Type m_type;
- private readonly PropertiesDictionary properties = new PropertiesDictionary();
-
- /// <summary>
- /// default constructor
- /// </summary>
- public ConverterInfo()
- {
- }
-
- /// <summary>
- /// Gets or sets the name of the conversion pattern
- /// </summary>
- /// <remarks>
- /// <para>
- /// The name of the pattern in the format string
- /// </para>
- /// </remarks>
- public string Name
- {
- get { return m_name; }
- set { m_name = value; }
- }
-
- /// <summary>
- /// Gets or sets the type of the converter
- /// </summary>
- /// <remarks>
- /// <para>
- /// The value specified must extend the
- /// <see cref="PatternConverter"/> type.
- /// </para>
- /// </remarks>
- public Type Type
- {
- get { return m_type; }
- set { m_type = value; }
- }
-
- /// <summary>
- ///
- /// </summary>
- /// <param name="entry"></param>
- public void AddProperty(PropertyEntry entry)
- {
- properties[entry.Key] = entry.Value;
- }
-
- /// <summary>
- ///
- /// </summary>
- public PropertiesDictionary Properties
- {
- get { return properties; }
- }
+ get { return m_name; }
+ set { m_name = value; }
}
+
+ /// <summary>
+ /// Gets or sets the type of the converter
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// The value specified must extend the
+ /// <see cref="PatternConverter"/> type.
+ /// </para>
+ /// </remarks>
+ public Type Type
+ {
+ get { return m_type; }
+ set { m_type = value; }
+ }
+
+ /// <summary>
+ ///
+ /// </summary>
+ /// <param name="entry"></param>
+ public void AddProperty(PropertyEntry entry)
+ {
+ properties[entry.Key] = entry.Value;
+ }
+
+ /// <summary>
+ ///
+ /// </summary>
+ public PropertiesDictionary Properties
+ {
+ get { return properties; }
+ }
+ }
}
diff --git a/src/log4net/Util/CountingQuietTextWriter.cs b/src/log4net/Util/CountingQuietTextWriter.cs
index 505163a..97bdaa4 100644
--- a/src/log4net/Util/CountingQuietTextWriter.cs
+++ b/src/log4net/Util/CountingQuietTextWriter.cs
@@ -35,7 +35,7 @@
/// </remarks>
/// <author>Nicko Cadell</author>
/// <author>Gert Driesen</author>
- public class CountingQuietTextWriter : QuietTextWriter
+ public class CountingQuietTextWriter : QuietTextWriter
{
#region Public Instance Constructors
@@ -58,7 +58,7 @@
#endregion Public Instance Constructors
#region Override implementation of QuietTextWriter
-
+
/// <summary>
/// Writes a character to the underlying writer and counts the number of bytes written.
/// </summary>
@@ -69,22 +69,22 @@
/// the number of bytes written.
/// </para>
/// </remarks>
- public override void Write(char value)
+ public override void Write(char value)
{
- try
+ try
{
base.Write(value);
// get the number of bytes needed to represent the
// char using the supplied encoding.
m_countBytes += this.Encoding.GetByteCount(new char[] { value });
- }
- catch(Exception e)
+ }
+ catch (Exception e)
{
this.ErrorHandler.Error("Failed to write [" + value + "].", e, ErrorCode.WriteFailure);
}
}
-
+
/// <summary>
/// Writes a buffer to the underlying writer and counts the number of bytes written.
/// </summary>
@@ -97,19 +97,19 @@
/// the number of bytes written.
/// </para>
/// </remarks>
- public override void Write(char[] buffer, int index, int count)
+ public override void Write(char[] buffer, int index, int count)
{
if (count > 0)
{
- try
+ try
{
base.Write(buffer, index, count);
// get the number of bytes needed to represent the
// char array using the supplied encoding.
m_countBytes += this.Encoding.GetByteCount(buffer, index, count);
- }
- catch(Exception e)
+ }
+ catch (Exception e)
{
this.ErrorHandler.Error("Failed to write buffer.", e, ErrorCode.WriteFailure);
}
@@ -126,11 +126,11 @@
/// the number of bytes written.
/// </para>
/// </remarks>
- public override void Write(string str)
+ public override void Write(string str)
{
if (str != null && str.Length > 0)
{
- try
+ try
{
base.Write(str);
@@ -138,13 +138,13 @@
// string using the supplied encoding.
m_countBytes += this.Encoding.GetByteCount(str);
}
- catch(Exception e)
+ catch (Exception e)
{
this.ErrorHandler.Error("Failed to write [" + str + "].", e, ErrorCode.WriteFailure);
}
}
}
-
+
#endregion Override implementation of QuietTextWriter
#region Public Instance Properties
@@ -160,14 +160,14 @@
/// Gets or sets the total number of bytes written.
/// </para>
/// </remarks>
- public long Count
+ public long Count
{
get { return m_countBytes; }
set { m_countBytes = value; }
}
#endregion Public Instance Properties
-
+
#region Private Instance Fields
/// <summary>
diff --git a/src/log4net/Util/CyclicBuffer.cs b/src/log4net/Util/CyclicBuffer.cs
index ca5ca70..f99fb48 100644
--- a/src/log4net/Util/CyclicBuffer.cs
+++ b/src/log4net/Util/CyclicBuffer.cs
@@ -48,9 +48,9 @@
/// </para>
/// </remarks>
/// <exception cref="ArgumentOutOfRangeException">The <paramref name="maxSize"/> argument is not a positive integer.</exception>
- public CyclicBuffer(int maxSize)
+ public CyclicBuffer(int maxSize)
{
- if (maxSize < 1)
+ if (maxSize < 1)
{
throw SystemInfo.CreateArgumentOutOfRangeException("maxSize", (object)maxSize, "Parameter: maxSize, Value: [" + maxSize + "] out of range. Non zero positive integer required");
}
@@ -65,7 +65,7 @@
#endregion Public Instance Constructors
#region Public Instance Methods
-
+
/// <summary>
/// Appends a <paramref name="loggingEvent"/> to the buffer.
/// </summary>
@@ -79,19 +79,19 @@
/// </para>
/// </remarks>
public LoggingEvent Append(LoggingEvent loggingEvent)
- {
+ {
if (loggingEvent == null)
{
throw new ArgumentNullException("loggingEvent");
}
- lock(this)
+ lock (this)
{
// save the discarded event
LoggingEvent discardedLoggingEvent = m_events[m_last];
// overwrite the last event position
- m_events[m_last] = loggingEvent;
+ m_events[m_last] = loggingEvent;
if (++m_last == m_maxSize)
{
m_last = 0;
@@ -129,12 +129,12 @@
/// from the buffer.
/// </para>
/// </remarks>
- public LoggingEvent PopOldest()
+ public LoggingEvent PopOldest()
{
- lock(this)
+ lock (this)
{
LoggingEvent ret = null;
- if (m_numElems > 0)
+ if (m_numElems > 0)
{
m_numElems--;
ret = m_events[m_first];
@@ -143,7 +143,7 @@
{
m_first = 0;
}
- }
+ }
return ret;
}
}
@@ -159,7 +159,7 @@
/// </remarks>
public LoggingEvent[] PopAll()
{
- lock(this)
+ lock (this)
{
LoggingEvent[] ret = new LoggingEvent[m_numElems];
@@ -192,7 +192,7 @@
/// </remarks>
public void Clear()
{
- lock(this)
+ lock (this)
{
// Set all the elements to null
Array.Clear(m_events, 0, m_events.Length);
@@ -276,11 +276,11 @@
/// currently in the buffer, then <c>null</c> is returned.
/// </para>
/// </remarks>
- public LoggingEvent this[int i]
+ public LoggingEvent this[int i]
{
get
{
- lock(this)
+ lock (this)
{
if (i < 0 || i >= m_numElems)
{
@@ -301,13 +301,13 @@
/// Gets the maximum size of the buffer
/// </para>
/// </remarks>
- public int MaxSize
+ public int MaxSize
{
- get
- {
- lock(this)
+ get
+ {
+ lock (this)
{
- return m_maxSize;
+ return m_maxSize;
}
}
#if RESIZABLE_CYCLIC_BUFFER
@@ -331,13 +331,13 @@
/// </remarks>
public int Length
{
- get
- {
- lock(this)
- {
- return m_numElems;
+ get
+ {
+ lock (this)
+ {
+ return m_numElems;
}
- }
+ }
}
#endregion Public Instance Properties
@@ -345,8 +345,8 @@
#region Private Instance Fields
private LoggingEvent[] m_events;
- private int m_first;
- private int m_last;
+ private int m_first;
+ private int m_last;
private int m_numElems;
private int m_maxSize;
diff --git a/src/log4net/Util/EmptyCollection.cs b/src/log4net/Util/EmptyCollection.cs
index 2f019dd..ab36d94 100644
--- a/src/log4net/Util/EmptyCollection.cs
+++ b/src/log4net/Util/EmptyCollection.cs
@@ -53,7 +53,7 @@
}
#endregion Private Instance Constructors
-
+
#region Public Static Properties
/// <summary>
@@ -107,7 +107,7 @@
/// </remarks>
public bool IsSynchronized
{
- get { return true; }
+ get { return true; }
}
/// <summary>
@@ -172,7 +172,7 @@
/// The singleton instance of the empty collection.
/// </summary>
private static readonly EmptyCollection s_instance = new EmptyCollection();
-
+
#endregion Private Static Fields
}
}
diff --git a/src/log4net/Util/EmptyDictionary.cs b/src/log4net/Util/EmptyDictionary.cs
index 1ccb67e..a35d3f9 100644
--- a/src/log4net/Util/EmptyDictionary.cs
+++ b/src/log4net/Util/EmptyDictionary.cs
@@ -53,7 +53,7 @@
}
#endregion Private Instance Constructors
-
+
#region Public Static Properties
/// <summary>
@@ -107,7 +107,7 @@
/// </remarks>
public bool IsSynchronized
{
- get { return true; }
+ get { return true; }
}
/// <summary>
@@ -275,7 +275,7 @@
/// </remarks>
public bool IsReadOnly
{
- get { return true; }
+ get { return true; }
}
/// <summary>
@@ -333,7 +333,7 @@
/// The singleton instance of the empty dictionary.
/// </summary>
private static readonly EmptyDictionary s_instance = new EmptyDictionary();
-
+
#endregion Private Static Fields
}
}
diff --git a/src/log4net/Util/FormattingInfo.cs b/src/log4net/Util/FormattingInfo.cs
index 6e8ed63..6a6be4d 100644
--- a/src/log4net/Util/FormattingInfo.cs
+++ b/src/log4net/Util/FormattingInfo.cs
@@ -47,7 +47,7 @@
/// Initializes a new instance of the <see cref="FormattingInfo" /> class.
/// </para>
/// </remarks>
- public FormattingInfo()
+ public FormattingInfo()
{
}
@@ -60,7 +60,7 @@
/// with the specified parameters.
/// </para>
/// </remarks>
- public FormattingInfo(int min, int max, bool leftAlign)
+ public FormattingInfo(int min, int max, bool leftAlign)
{
m_min = min;
m_max = max;
diff --git a/src/log4net/Util/GlobalContextProperties.cs b/src/log4net/Util/GlobalContextProperties.cs
index c7c504f..cfebd22 100644
--- a/src/log4net/Util/GlobalContextProperties.cs
+++ b/src/log4net/Util/GlobalContextProperties.cs
@@ -95,13 +95,13 @@
/// </remarks>
public override object this[string key]
{
- get
- {
+ get
+ {
return m_readOnlyProperties[key];
}
set
{
- lock(m_syncRoot)
+ lock (m_syncRoot)
{
PropertiesDictionary mutableProps = new PropertiesDictionary(m_readOnlyProperties);
@@ -128,7 +128,7 @@
/// </remarks>
public void Remove(string key)
{
- lock(m_syncRoot)
+ lock (m_syncRoot)
{
if (m_readOnlyProperties.Contains(key))
{
@@ -146,7 +146,7 @@
/// </summary>
public void Clear()
{
- lock(m_syncRoot)
+ lock (m_syncRoot)
{
m_readOnlyProperties = new ReadOnlyPropertiesDictionary();
}
diff --git a/src/log4net/Util/LevelMapping.cs b/src/log4net/Util/LevelMapping.cs
index aee83b2..674ec3d 100644
--- a/src/log4net/Util/LevelMapping.cs
+++ b/src/log4net/Util/LevelMapping.cs
@@ -46,14 +46,14 @@
/// Initialise a new instance of <see cref="LevelMapping"/>.
/// </para>
/// </remarks>
- public LevelMapping()
+ public LevelMapping()
{
}
#endregion // Public Instance Constructors
#region Public Instance Methods
-
+
/// <summary>
/// Add a <see cref="LevelMappingEntry"/> to this mapping
/// </summary>
@@ -93,7 +93,7 @@
{
if (m_entries != null)
{
- foreach(LevelMappingEntry entry in m_entries)
+ foreach (LevelMappingEntry entry in m_entries)
{
if (level >= entry.Level)
{
@@ -130,12 +130,12 @@
// Reverse list so that highest level is first
Array.Reverse(sortValues, 0, sortValues.Length);
- foreach(LevelMappingEntry entry in sortValues)
+ foreach (LevelMappingEntry entry in sortValues)
{
entry.ActivateOptions();
}
- m_entries = sortValues;
+ m_entries = sortValues;
}
#endregion // IOptionHandler Members
diff --git a/src/log4net/Util/LevelMappingEntry.cs b/src/log4net/Util/LevelMappingEntry.cs
index 4bbe004..00901a5 100644
--- a/src/log4net/Util/LevelMappingEntry.cs
+++ b/src/log4net/Util/LevelMappingEntry.cs
@@ -46,7 +46,7 @@
/// Default protected constructor
/// </para>
/// </remarks>
- protected LevelMappingEntry()
+ protected LevelMappingEntry()
{
}
@@ -93,7 +93,7 @@
#region Private Instance Fields
- private Level m_level;
+ private Level m_level;
#endregion // Private Instance Fields
}
diff --git a/src/log4net/Util/LogLog.cs b/src/log4net/Util/LogLog.cs
index 8c0f0a7..a54f010 100644
--- a/src/log4net/Util/LogLog.cs
+++ b/src/log4net/Util/LogLog.cs
@@ -23,12 +23,12 @@
namespace log4net.Util
{
- /// <summary>
- ///
- /// </summary>
- /// <param name="source"></param>
- /// <param name="e"></param>
- public delegate void LogReceivedEventHandler(object source, LogReceivedEventArgs e);
+ /// <summary>
+ ///
+ /// </summary>
+ /// <param name="source"></param>
+ /// <param name="e"></param>
+ public delegate void LogReceivedEventHandler(object source, LogReceivedEventArgs e);
/// <summary>
/// Outputs log statements from within the log4net assembly.
@@ -49,101 +49,101 @@
/// <author>Gert Driesen</author>
public sealed class LogLog
{
- /// <summary>
- /// The event raised when an internal message has been received.
- /// </summary>
- public static event LogReceivedEventHandler LogReceived;
+ /// <summary>
+ /// The event raised when an internal message has been received.
+ /// </summary>
+ public static event LogReceivedEventHandler LogReceived;
- private readonly Type source;
- private readonly DateTime timeStampUtc;
- private readonly string prefix;
- private readonly string message;
- private readonly Exception exception;
+ private readonly Type source;
+ private readonly DateTime timeStampUtc;
+ private readonly string prefix;
+ private readonly string message;
+ private readonly Exception exception;
- /// <summary>
- /// The Type that generated the internal message.
- /// </summary>
- public Type Source
- {
- get { return source; }
- }
+ /// <summary>
+ /// The Type that generated the internal message.
+ /// </summary>
+ public Type Source
+ {
+ get { return source; }
+ }
- /// <summary>
- /// The DateTime stamp of when the internal message was received.
- /// </summary>
- public DateTime TimeStamp
- {
- get { return timeStampUtc.ToLocalTime(); }
- }
+ /// <summary>
+ /// The DateTime stamp of when the internal message was received.
+ /// </summary>
+ public DateTime TimeStamp
+ {
+ get { return timeStampUtc.ToLocalTime(); }
+ }
- /// <summary>
- /// The UTC DateTime stamp of when the internal message was received.
- /// </summary>
- public DateTime TimeStampUtc
- {
- get { return timeStampUtc; }
- }
+ /// <summary>
+ /// The UTC DateTime stamp of when the internal message was received.
+ /// </summary>
+ public DateTime TimeStampUtc
+ {
+ get { return timeStampUtc; }
+ }
- /// <summary>
- /// A string indicating the severity of the internal message.
- /// </summary>
- /// <remarks>
- /// "log4net: ",
- /// "log4net:ERROR ",
- /// "log4net:WARN "
- /// </remarks>
- public string Prefix
- {
- get { return prefix; }
- }
+ /// <summary>
+ /// A string indicating the severity of the internal message.
+ /// </summary>
+ /// <remarks>
+ /// "log4net: ",
+ /// "log4net:ERROR ",
+ /// "log4net:WARN "
+ /// </remarks>
+ public string Prefix
+ {
+ get { return prefix; }
+ }
- /// <summary>
- /// The internal log message.
- /// </summary>
- public string Message
- {
- get { return message; }
- }
+ /// <summary>
+ /// The internal log message.
+ /// </summary>
+ public string Message
+ {
+ get { return message; }
+ }
- /// <summary>
- /// The Exception related to the message.
- /// </summary>
- /// <remarks>
- /// Optional. Will be null if no Exception was passed.
- /// </remarks>
- public Exception Exception
- {
- get { return exception; }
- }
+ /// <summary>
+ /// The Exception related to the message.
+ /// </summary>
+ /// <remarks>
+ /// Optional. Will be null if no Exception was passed.
+ /// </remarks>
+ public Exception Exception
+ {
+ get { return exception; }
+ }
- /// <summary>
- /// Formats Prefix, Source, and Message in the same format as the value
- /// sent to Console.Out and Trace.Write.
- /// </summary>
- /// <returns></returns>
- public override string ToString()
- {
- return Prefix + Source.Name + ": " + Message;
- }
+ /// <summary>
+ /// Formats Prefix, Source, and Message in the same format as the value
+ /// sent to Console.Out and Trace.Write.
+ /// </summary>
+ /// <returns></returns>
+ public override string ToString()
+ {
+ return Prefix + Source.Name + ": " + Message;
+ }
- #region Private Instance Constructors
+ #region Private Instance Constructors
- /// <summary>
- /// Initializes a new instance of the <see cref="LogLog" /> class.
- /// </summary>
- /// <param name="source"></param>
- /// <param name="prefix"></param>
- /// <param name="message"></param>
- /// <param name="exception"></param>
- public LogLog(Type source, string prefix, string message, Exception exception)
- {
- timeStampUtc = DateTime.UtcNow;
-
- this.source = source;
- this.prefix = prefix;
- this.message = message;
- this.exception = exception;
- }
+ /// <summary>
+ /// Initializes a new instance of the <see cref="LogLog" /> class.
+ /// </summary>
+ /// <param name="source"></param>
+ /// <param name="prefix"></param>
+ /// <param name="message"></param>
+ /// <param name="exception"></param>
+ public LogLog(Type source, string prefix, string message, Exception exception)
+ {
+ timeStampUtc = DateTime.UtcNow;
+
+ this.source = source;
+ this.prefix = prefix;
+ this.message = message;
+ this.exception = exception;
+ }
#endregion Private Instance Constructors
@@ -175,7 +175,7 @@
QuietMode = OptionConverter.ToBoolean(SystemInfo.GetAppSetting("log4net.Internal.Quiet"), false);
EmitInternalMessages = OptionConverter.ToBoolean(SystemInfo.GetAppSetting("log4net.Internal.Emit"), true);
}
- catch(Exception ex)
+ catch (Exception ex)
{
// If an exception is thrown here then it looks like the config file does not
// parse correctly.
@@ -272,35 +272,35 @@
set { s_quietMode = value; }
}
- /// <summary>
- ///
- /// </summary>
- public static bool EmitInternalMessages
- {
- get { return s_emitInternalMessages; }
- set { s_emitInternalMessages = value; }
- }
+ /// <summary>
+ ///
+ /// </summary>
+ public static bool EmitInternalMessages
+ {
+ get { return s_emitInternalMessages; }
+ set { s_emitInternalMessages = value; }
+ }
#endregion Public Static Properties
#region Public Static Methods
- /// <summary>
- /// Raises the LogReceived event when an internal messages is received.
- /// </summary>
- /// <param name="source"></param>
- /// <param name="prefix"></param>
- /// <param name="message"></param>
- /// <param name="exception"></param>
- public static void OnLogReceived(Type source, string prefix, string message, Exception exception)
- {
- if (LogReceived != null)
- {
- LogReceived(null, new LogReceivedEventArgs(new LogLog(source, prefix, message, exception)));
- }
- }
+ /// <summary>
+ /// Raises the LogReceived event when an internal messages is received.
+ /// </summary>
+ /// <param name="source"></param>
+ /// <param name="prefix"></param>
+ /// <param name="message"></param>
+ /// <param name="exception"></param>
+ public static void OnLogReceived(Type source, string prefix, string message, Exception exception)
+ {
+ if (LogReceived != null)
+ {
+ LogReceived(null, new LogReceivedEventArgs(new LogLog(source, prefix, message, exception)));
+ }
+ }
- /// <summary>
+ /// <summary>
/// Test if LogLog.Debug is enabled for output.
/// </summary>
/// <value>
@@ -320,7 +320,7 @@
/// Writes log4net internal debug messages to the
/// standard output stream.
/// </summary>
- /// <param name="source"></param>
+ /// <param name="source"></param>
/// <param name="message">The message to log.</param>
/// <remarks>
/// <para>
@@ -328,16 +328,16 @@
/// the string "log4net: ".
/// </para>
/// </remarks>
- public static void Debug(Type source, string message)
+ public static void Debug(Type source, string message)
{
- if (IsDebugEnabled)
+ if (IsDebugEnabled)
{
- if (EmitInternalMessages)
- {
- EmitOutLine(PREFIX + message);
- }
+ if (EmitInternalMessages)
+ {
+ EmitOutLine(PREFIX + message);
+ }
- OnLogReceived(source, PREFIX, message, null);
+ OnLogReceived(source, PREFIX, message, null);
}
}
@@ -345,7 +345,7 @@
/// Writes log4net internal debug messages to the
/// standard output stream.
/// </summary>
- /// <param name="source">The Type that generated this message.</param>
+ /// <param name="source">The Type that generated this message.</param>
/// <param name="message">The message to log.</param>
/// <param name="exception">An exception to log.</param>
/// <remarks>
@@ -354,23 +354,23 @@
/// the string "log4net: ".
/// </para>
/// </remarks>
- public static void Debug(Type source, string message, Exception exception)
+ public static void Debug(Type source, string message, Exception exception)
{
- if (IsDebugEnabled)
+ if (IsDebugEnabled)
{
- if (EmitInternalMessages)
- {
- EmitOutLine(PREFIX + message);
- if (exception != null)
- {
- EmitOutLine(exception.ToString());
- }
- }
+ if (EmitInternalMessages)
+ {
+ EmitOutLine(PREFIX + message);
+ if (exception != null)
+ {
+ EmitOutLine(exception.ToString());
+ }
+ }
- OnLogReceived(source, PREFIX, message, exception);
+ OnLogReceived(source, PREFIX, message, exception);
}
}
-
+
/// <summary>
/// Test if LogLog.Warn is enabled for output.
/// </summary>
@@ -391,7 +391,7 @@
/// Writes log4net internal warning messages to the
/// standard error stream.
/// </summary>
- /// <param name="source">The Type that generated this message.</param>
+ /// <param name="source">The Type that generated this message.</param>
/// <param name="message">The message to log.</param>
/// <remarks>
/// <para>
@@ -399,24 +399,24 @@
/// the string "log4net:WARN ".
/// </para>
/// </remarks>
- public static void Warn(Type source, string message)
+ public static void Warn(Type source, string message)
{
if (IsWarnEnabled)
{
- if (EmitInternalMessages)
- {
- EmitErrorLine(WARN_PREFIX + message);
- }
+ if (EmitInternalMessages)
+ {
+ EmitErrorLine(WARN_PREFIX + message);
+ }
- OnLogReceived(source, WARN_PREFIX, message, null);
+ OnLogReceived(source, WARN_PREFIX, message, null);
}
- }
+ }
/// <summary>
/// Writes log4net internal warning messages to the
/// standard error stream.
/// </summary>
- /// <param name="source">The Type that generated this message.</param>
+ /// <param name="source">The Type that generated this message.</param>
/// <param name="message">The message to log.</param>
/// <param name="exception">An exception to log.</param>
/// <remarks>
@@ -425,22 +425,22 @@
/// the string "log4net:WARN ".
/// </para>
/// </remarks>
- public static void Warn(Type source, string message, Exception exception)
+ public static void Warn(Type source, string message, Exception exception)
{
if (IsWarnEnabled)
{
- if (EmitInternalMessages)
- {
- EmitErrorLine(WARN_PREFIX + message);
- if (exception != null)
- {
- EmitErrorLine(exception.ToString());
- }
- }
+ if (EmitInternalMessages)
+ {
+ EmitErrorLine(WARN_PREFIX + message);
+ if (exception != null)
+ {
+ EmitErrorLine(exception.ToString());
+ }
+ }
- OnLogReceived(source, WARN_PREFIX, message, exception);
+ OnLogReceived(source, WARN_PREFIX, message, exception);
}
- }
+ }
/// <summary>
/// Test if LogLog.Error is enabled for output.
@@ -462,7 +462,7 @@
/// Writes log4net internal error messages to the
/// standard error stream.
/// </summary>
- /// <param name="source">The Type that generated this message.</param>
+ /// <param name="source">The Type that generated this message.</param>
/// <param name="message">The message to log.</param>
/// <remarks>
/// <para>
@@ -470,24 +470,24 @@
/// the string "log4net:ERROR ".
/// </para>
/// </remarks>
- public static void Error(Type source, string message)
+ public static void Error(Type source, string message)
{
if (IsErrorEnabled)
{
- if (EmitInternalMessages)
- {
- EmitErrorLine(ERR_PREFIX + message);
- }
+ if (EmitInternalMessages)
+ {
+ EmitErrorLine(ERR_PREFIX + message);
+ }
- OnLogReceived(source, ERR_PREFIX, message, null);
+ OnLogReceived(source, ERR_PREFIX, message, null);
}
- }
+ }
/// <summary>
/// Writes log4net internal error messages to the
/// standard error stream.
/// </summary>
- /// <param name="source">The Type that generated this message.</param>
+ /// <param name="source">The Type that generated this message.</param>
/// <param name="message">The message to log.</param>
/// <param name="exception">An exception to log.</param>
/// <remarks>
@@ -496,22 +496,22 @@
/// the string "log4net:ERROR ".
/// </para>
/// </remarks>
- public static void Error(Type source, string message, Exception exception)
+ public static void Error(Type source, string message, Exception exception)
{
if (IsErrorEnabled)
{
- if (EmitInternalMessages)
- {
- EmitErrorLine(ERR_PREFIX + message);
- if (exception != null)
- {
- EmitErrorLine(exception.ToString());
- }
- }
+ if (EmitInternalMessages)
+ {
+ EmitErrorLine(ERR_PREFIX + message);
+ if (exception != null)
+ {
+ EmitErrorLine(exception.ToString());
+ }
+ }
- OnLogReceived(source, ERR_PREFIX, message, exception);
+ OnLogReceived(source, ERR_PREFIX, message, exception);
}
- }
+ }
#endregion Public Static Methods
@@ -595,81 +595,81 @@
/// </summary>
private static bool s_quietMode = false;
- private static bool s_emitInternalMessages = true;
+ private static bool s_emitInternalMessages = true;
- private const string PREFIX = "log4net: ";
- private const string ERR_PREFIX = "log4net:ERROR ";
- private const string WARN_PREFIX = "log4net:WARN ";
+ private const string PREFIX = "log4net: ";
+ private const string ERR_PREFIX = "log4net:ERROR ";
+ private const string WARN_PREFIX = "log4net:WARN ";
#endregion Private Static Fields
- /// <summary>
- /// Subscribes to the LogLog.LogReceived event and stores messages
- /// to the supplied IList instance.
- /// </summary>
- public class LogReceivedAdapter : IDisposable
- {
- private readonly IList items;
- private readonly LogReceivedEventHandler handler;
+ /// <summary>
+ /// Subscribes to the LogLog.LogReceived event and stores messages
+ /// to the supplied IList instance.
+ /// </summary>
+ public class LogReceivedAdapter : IDisposable
+ {
+ private readonly IList items;
+ private readonly LogReceivedEventHandler handler;
- /// <summary>
- ///
- /// </summary>
- /// <param name="items"></param>
- public LogReceivedAdapter(IList items)
- {
- this.items = items;
+ /// <summary>
+ ///
+ /// </summary>
+ /// <param name="items"></param>
+ public LogReceivedAdapter(IList items)
+ {
+ this.items = items;
- handler = new LogReceivedEventHandler(LogLog_LogReceived);
+ handler = new LogReceivedEventHandler(LogLog_LogReceived);
- LogReceived += handler;
- }
+ LogReceived += handler;
+ }
- void LogLog_LogReceived(object source, LogReceivedEventArgs e)
- {
- items.Add(e.LogLog);
- }
+ void LogLog_LogReceived(object source, LogReceivedEventArgs e)
+ {
+ items.Add(e.LogLog);
+ }
- /// <summary>
- ///
- /// </summary>
- public IList Items
- {
- get { return items; }
- }
+ /// <summary>
+ ///
+ /// </summary>
+ public IList Items
+ {
+ get { return items; }
+ }
- /// <summary>
- ///
- /// </summary>
- public void Dispose()
- {
- LogReceived -= handler;
- }
- }
+ /// <summary>
+ ///
+ /// </summary>
+ public void Dispose()
+ {
+ LogReceived -= handler;
+ }
+ }
}
+ /// <summary>
+ ///
+ /// </summary>
+ public class LogReceivedEventArgs : EventArgs
+ {
+ private readonly LogLog loglog;
+
/// <summary>
///
/// </summary>
- public class LogReceivedEventArgs : EventArgs
+ /// <param name="loglog"></param>
+ public LogReceivedEventArgs(LogLog loglog)
{
- private readonly LogLog loglog;
-
- /// <summary>
- ///
- /// </summary>
- /// <param name="loglog"></param>
- public LogReceivedEventArgs(LogLog loglog)
- {
- this.loglog = loglog;
- }
-
- /// <summary>
- ///
- /// </summary>
- public LogLog LogLog
- {
- get { return loglog; }
- }
+ this.loglog = loglog;
}
+
+ /// <summary>
+ ///
+ /// </summary>
+ public LogLog LogLog
+ {
+ get { return loglog; }
+ }
+ }
}
diff --git a/src/log4net/Util/LogicalThreadContextProperties.cs b/src/log4net/Util/LogicalThreadContextProperties.cs
index 8a93894..2104220 100644
--- a/src/log4net/Util/LogicalThreadContextProperties.cs
+++ b/src/log4net/Util/LogicalThreadContextProperties.cs
@@ -64,12 +64,12 @@
#else
private const string c_SlotName = "log4net.Util.LogicalThreadContextProperties";
#endif
-
+
/// <summary>
/// Flag used to disable this context if we don't have permission to access the CallContext.
/// </summary>
private bool m_disabled = false;
-
+
#region Public Instance Constructors
/// <summary>
@@ -101,17 +101,17 @@
/// </remarks>
public override object this[string key]
{
- get
- {
+ get
+ {
// Don't create the dictionary if it does not already exist
PropertiesDictionary dictionary = GetProperties(false);
if (dictionary != null)
{
- return dictionary[key];
+ return dictionary[key];
}
return null;
}
- set
+ set
{
// Force the dictionary to be created
PropertiesDictionary props = GetProperties(true);
@@ -198,12 +198,12 @@
catch (SecurityException secEx)
{
m_disabled = true;
-
+
// Thrown if we don't have permission to read or write the CallContext
LogLog.Warn(declaringType, "SecurityException while accessing CallContext. Disabling LogicalThreadContextProperties", secEx);
}
}
-
+
// Only get here is we are disabled because of a security exception
if (create)
{
@@ -214,9 +214,9 @@
#endregion Internal Instance Methods
- #region Private Static Methods
+ #region Private Static Methods
- /// <summary>
+ /// <summary>
/// Gets the call context get data.
/// </summary>
/// <returns>The peroperties dictionary stored in the call context</returns>
@@ -228,12 +228,12 @@
#if NET_4_0 || MONO_4_0 || NETSTANDARD
[System.Security.SecuritySafeCritical]
#endif
- private static PropertiesDictionary GetLogicalProperties()
+ private static PropertiesDictionary GetLogicalProperties()
{
#if NETSTANDARD
return AsyncLocalDictionary.Value;
#elif NET_2_0 || MONO_2_0 || MONO_3_5 || MONO_4_0
- return CallContext.LogicalGetData(c_SlotName) as PropertiesDictionary;
+ return CallContext.LogicalGetData(c_SlotName) as PropertiesDictionary;
#else
return CallContext.GetData(c_SlotName) as PropertiesDictionary;
#endif
@@ -251,7 +251,7 @@
#if NET_4_0 || MONO_4_0 || NETSTANDARD
[System.Security.SecuritySafeCritical]
#endif
- private static void SetLogicalProperties(PropertiesDictionary properties)
+ private static void SetLogicalProperties(PropertiesDictionary properties)
{
#if NETSTANDARD
AsyncLocalDictionary.Value = properties;
@@ -260,23 +260,23 @@
#else
CallContext.SetData(c_SlotName, properties);
#endif
- }
-
- #endregion
-
- #region Private Static Fields
-
- /// <summary>
- /// The fully qualified type of the LogicalThreadContextProperties class.
- /// </summary>
- /// <remarks>
- /// Used by the internal logger to record the Type of the
- /// log message.
- /// </remarks>
- private static readonly Type declaringType = typeof(LogicalThreadContextProperties);
-
- #endregion Private Static Fields
}
+
+ #endregion
+
+ #region Private Static Fields
+
+ /// <summary>
+ /// The fully qualified type of the LogicalThreadContextProperties class.
+ /// </summary>
+ /// <remarks>
+ /// Used by the internal logger to record the Type of the
+ /// log message.
+ /// </remarks>
+ private static readonly Type declaringType = typeof(LogicalThreadContextProperties);
+
+ #endregion Private Static Fields
+ }
}
#endif
diff --git a/src/log4net/Util/LogicalThreadContextStack.cs b/src/log4net/Util/LogicalThreadContextStack.cs
index 45993eb..bd7b0ab 100644
--- a/src/log4net/Util/LogicalThreadContextStack.cs
+++ b/src/log4net/Util/LogicalThreadContextStack.cs
@@ -29,11 +29,11 @@
/// <summary>
/// Delegate type used for LogicalThreadContextStack's callbacks.
/// </summary>
- #if NET_2_0 || MONO_2_0 || NETSTANDARD
+#if NET_2_0 || MONO_2_0 || NETSTANDARD
public delegate void TwoArgAction<T1, T2>(T1 t1, T2 t2);
- #else
+#else
public delegate void TwoArgAction(string t1, LogicalThreadContextStack t2);
- #endif
+#endif
/// <summary>
/// Implementation of Stack for the <see cref="log4net.LogicalThreadContext"/>
@@ -63,11 +63,11 @@
/// The callback used to let the <see cref="log4net.Util.LogicalThreadContextStacks"/> register a
/// new instance of a <see cref="log4net.Util.LogicalThreadContextStack"/>.
/// </summary>
- #if NET_2_0 || MONO_2_0 || NETSTANDARD
+#if NET_2_0 || MONO_2_0 || NETSTANDARD
private TwoArgAction<string, LogicalThreadContextStack> m_registerNew;
- #else
+#else
private TwoArgAction m_registerNew;
- #endif
+#endif
#endregion Private Instance Fields
@@ -81,11 +81,11 @@
/// Initializes a new instance of the <see cref="LogicalThreadContextStack" /> class.
/// </para>
/// </remarks>
- #if NET_2_0 || MONO_2_0 || NETSTANDARD
+#if NET_2_0 || MONO_2_0 || NETSTANDARD
internal LogicalThreadContextStack(string propertyKey, TwoArgAction<string, LogicalThreadContextStack> registerNew)
- #else
+#else
internal LogicalThreadContextStack(string propertyKey, TwoArgAction registerNew)
- #endif
+#endif
{
m_propertyKey = propertyKey;
m_registerNew = registerNew;
diff --git a/src/log4net/Util/NativeError.cs b/src/log4net/Util/NativeError.cs
index a17a40c..e93cef1 100644
--- a/src/log4net/Util/NativeError.cs
+++ b/src/log4net/Util/NativeError.cs
@@ -28,7 +28,7 @@
using System.Globalization;
using System.Runtime.InteropServices;
-namespace log4net.Util
+namespace log4net.Util
{
/// <summary>
/// Represents a native error code and message.
@@ -40,7 +40,7 @@
/// </remarks>
/// <author>Nicko Cadell</author>
/// <author>Gert Driesen</author>
- public sealed class NativeError
+ public sealed class NativeError
{
#region Protected Instance Constructors
@@ -56,7 +56,7 @@
/// error number and message.
/// </para>
/// </remarks>
- private NativeError(int number, string message)
+ private NativeError(int number, string message)
{
m_number = number;
m_message = message;
@@ -77,7 +77,7 @@
/// Gets the number of the native error.
/// </para>
/// </remarks>
- public int Number
+ public int Number
{
get { return m_number; }
}
@@ -93,7 +93,7 @@
/// </para>
/// Gets the message of the native error.
/// </remarks>
- public string Message
+ public string Message
{
get { return m_message; }
}
@@ -118,9 +118,9 @@
[System.Security.SecuritySafeCritical]
#endif
#if !NETCF && !NETSTANDARD1_3
- [System.Security.Permissions.SecurityPermission(System.Security.Permissions.SecurityAction.Demand, UnmanagedCode = true)]
+ [System.Security.Permissions.SecurityPermission(System.Security.Permissions.SecurityAction.Demand, UnmanagedCode = true)]
#endif
- public static NativeError GetLastError()
+ public static NativeError GetLastError()
{
int number = Marshal.GetLastWin32Error();
return new NativeError(number, NativeError.GetErrorMessage(number));
@@ -140,7 +140,7 @@
/// native Win32 <c>FormatMessage</c> function.
/// </para>
/// </remarks>
- public static NativeError GetError(int number)
+ public static NativeError GetError(int number)
{
return new NativeError(number, NativeError.GetErrorMessage(number));
}
@@ -162,43 +162,43 @@
[System.Security.SecuritySafeCritical]
#endif
#if !NETCF && !NETSTANDARD1_3
- [System.Security.Permissions.SecurityPermission(System.Security.Permissions.SecurityAction.Demand, UnmanagedCode = true)]
+ [System.Security.Permissions.SecurityPermission(System.Security.Permissions.SecurityAction.Demand, UnmanagedCode = true)]
#endif
- public static string GetErrorMessage(int messageId)
+ public static string GetErrorMessage(int messageId)
{
// Win32 constants
int FORMAT_MESSAGE_ALLOCATE_BUFFER = 0x00000100; // The function should allocates a buffer large enough to hold the formatted message
int FORMAT_MESSAGE_IGNORE_INSERTS = 0x00000200; // Insert sequences in the message definition are to be ignored
- int FORMAT_MESSAGE_FROM_SYSTEM = 0x00001000; // The function should search the system message-table resource(s) for the requested message
+ int FORMAT_MESSAGE_FROM_SYSTEM = 0x00001000; // The function should search the system message-table resource(s) for the requested message
string msgBuf = ""; // buffer that will receive the message
IntPtr sourcePtr = new IntPtr(); // Location of the message definition, will be ignored
IntPtr argumentsPtr = new IntPtr(); // Pointer to array of values to insert, not supported as it requires unsafe code
- if (messageId != 0)
+ if (messageId != 0)
{
// If the function succeeds, the return value is the number of TCHARs stored in the output buffer, excluding the terminating null character
int messageSize = FormatMessage(
- FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
- ref sourcePtr,
- messageId,
- 0,
- ref msgBuf,
- 255,
+ FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
+ ref sourcePtr,
+ messageId,
+ 0,
+ ref msgBuf,
+ 255,
argumentsPtr);
- if (messageSize > 0)
+ if (messageSize > 0)
{
// Remove trailing null-terminating characters (\r\n) from the message
- msgBuf = msgBuf.TrimEnd(new char[] {'\r', '\n'});
+ msgBuf = msgBuf.TrimEnd(new char[] { '\r', '\n' });
}
- else
+ else
{
// A message could not be located.
msgBuf = null;
}
- }
- else
+ }
+ else
{
msgBuf = null;
}
@@ -219,7 +219,7 @@
/// Return error information string
/// </para>
/// </remarks>
- public override string ToString()
+ public override string ToString()
{
return string.Format(CultureInfo.InvariantCulture, "0x{0:x8}", this.Number) + (this.Message != null ? ": " + this.Message : "");
}
@@ -265,14 +265,14 @@
#if NETCF || NETSTANDARD
[DllImport("CoreDll.dll", SetLastError=true, CharSet=CharSet.Unicode)]
#else
- [DllImport("Kernel32.dll", SetLastError=true, CharSet=CharSet.Auto)]
+ [DllImport("Kernel32.dll", SetLastError = true, CharSet = CharSet.Auto)]
#endif
private static extern int FormatMessage(
- int dwFlags,
- ref IntPtr lpSource,
+ int dwFlags,
+ ref IntPtr lpSource,
int dwMessageId,
- int dwLanguageId,
- ref String lpBuffer,
+ int dwLanguageId,
+ ref String lpBuffer,
int nSize,
IntPtr Arguments);
diff --git a/src/log4net/Util/NullDictionaryEnumerator.cs b/src/log4net/Util/NullDictionaryEnumerator.cs
index 53d1526..5f1d055 100644
--- a/src/log4net/Util/NullDictionaryEnumerator.cs
+++ b/src/log4net/Util/NullDictionaryEnumerator.cs
@@ -52,7 +52,7 @@
#endregion Private Instance Constructors
#region Public Static Properties
-
+
/// <summary>
/// Gets the singleton instance of the <see cref="NullDictionaryEnumerator" />.
/// </summary>
@@ -87,11 +87,11 @@
/// </remarks>
/// <exception cref="InvalidOperationException">The collection is empty and <see cref="Current"/>
/// cannot be positioned over a valid location.</exception>
- public object Current
+ public object Current
{
- get { throw new InvalidOperationException(); }
+ get { throw new InvalidOperationException(); }
}
-
+
/// <summary>
/// Test if the enumerator can advance, if so advance.
/// </summary>
@@ -107,7 +107,7 @@
{
return false;
}
-
+
/// <summary>
/// Resets the enumerator back to the start.
/// </summary>
@@ -116,7 +116,7 @@
/// As the enumerator is over an empty collection <see cref="Reset"/> does nothing.
/// </para>
/// </remarks>
- public void Reset()
+ public void Reset()
{
}
@@ -140,9 +140,9 @@
/// </remarks>
/// <exception cref="InvalidOperationException">The collection is empty and <see cref="Current"/>
/// cannot be positioned over a valid location.</exception>
- public object Key
+ public object Key
{
- get { throw new InvalidOperationException(); }
+ get { throw new InvalidOperationException(); }
}
/// <summary>
@@ -162,9 +162,9 @@
/// </remarks>
/// <exception cref="InvalidOperationException">The collection is empty and <see cref="Current"/>
/// cannot be positioned over a valid location.</exception>
- public object Value
+ public object Value
{
- get { throw new InvalidOperationException(); }
+ get { throw new InvalidOperationException(); }
}
/// <summary>
@@ -183,11 +183,11 @@
/// </remarks>
/// <exception cref="InvalidOperationException">The collection is empty and <see cref="Current"/>
/// cannot be positioned over a valid location.</exception>
- public DictionaryEntry Entry
+ public DictionaryEntry Entry
{
- get { throw new InvalidOperationException(); }
+ get { throw new InvalidOperationException(); }
}
-
+
#endregion Implementation of IDictionaryEnumerator
#region Private Static Fields
@@ -196,7 +196,7 @@
/// The singleton instance of the <see cref="NullDictionaryEnumerator" />.
/// </summary>
private static readonly NullDictionaryEnumerator s_instance = new NullDictionaryEnumerator();
-
+
#endregion Private Static Fields
}
}
diff --git a/src/log4net/Util/NullEnumerator.cs b/src/log4net/Util/NullEnumerator.cs
index 05351f2..4c57d11 100644
--- a/src/log4net/Util/NullEnumerator.cs
+++ b/src/log4net/Util/NullEnumerator.cs
@@ -50,7 +50,7 @@
}
#endregion Private Instance Constructors
-
+
#region Public Static Properties
/// <summary>
@@ -87,11 +87,11 @@
/// </remarks>
/// <exception cref="InvalidOperationException">The collection is empty and <see cref="Current"/>
/// cannot be positioned over a valid location.</exception>
- public object Current
+ public object Current
{
- get { throw new InvalidOperationException(); }
+ get { throw new InvalidOperationException(); }
}
-
+
/// <summary>
/// Test if the enumerator can advance, if so advance
/// </summary>
@@ -107,7 +107,7 @@
{
return false;
}
-
+
/// <summary>
/// Resets the enumerator back to the start.
/// </summary>
@@ -116,7 +116,7 @@
/// As the enumerator is over an empty collection <see cref="Reset"/> does nothing.
/// </para>
/// </remarks>
- public void Reset()
+ public void Reset()
{
}
@@ -128,7 +128,7 @@
/// The singleton instance of the <see cref="NullEnumerator" />.
/// </summary>
private static readonly NullEnumerator s_instance = new NullEnumerator();
-
+
#endregion Private Static Fields
}
}
diff --git a/src/log4net/Util/OnlyOnceErrorHandler.cs b/src/log4net/Util/OnlyOnceErrorHandler.cs
index ba4f0d1..f593607 100644
--- a/src/log4net/Util/OnlyOnceErrorHandler.cs
+++ b/src/log4net/Util/OnlyOnceErrorHandler.cs
@@ -101,48 +101,50 @@
/// Invokes <see cref="FirstError"/> if and only if this is the first error or the first error after <see cref="Reset"/> has been called.
/// </para>
/// </remarks>
- public void Error(string message, Exception e, ErrorCode errorCode)
+ public void Error(string message, Exception e, ErrorCode errorCode)
{
if (m_firstTime)
{
- FirstError(message, e, errorCode);
+ FirstError(message, e, errorCode);
}
}
- /// <summary>
- /// Log the very first error
- /// </summary>
- /// <param name="message">The error message.</param>
- /// <param name="e">The exception.</param>
- /// <param name="errorCode">The internal error code.</param>
- /// <remarks>
- /// <para>
- /// Sends the error information to <see cref="LogLog"/>'s Error method.
- /// </para>
- /// </remarks>
- public virtual void FirstError(string message, Exception e, ErrorCode errorCode) {
- m_enabledDateUtc = DateTime.UtcNow;
- m_errorCode = errorCode;
- m_exception = e;
- m_message = message;
- m_firstTime = false;
+ /// <summary>
+ /// Log the very first error
+ /// </summary>
+ /// <param name="message">The error message.</param>
+ /// <param name="e">The exception.</param>
+ /// <param name="errorCode">The internal error code.</param>
+ /// <remarks>
+ /// <para>
+ /// Sends the error information to <see cref="LogLog"/>'s Error method.
+ /// </para>
+ /// </remarks>
+ public virtual void FirstError(string message, Exception e, ErrorCode errorCode)
+ {
+ m_enabledDateUtc = DateTime.UtcNow;
+ m_errorCode = errorCode;
+ m_exception = e;
+ m_message = message;
+ m_firstTime = false;
- if (LogLog.InternalDebugging && !LogLog.QuietMode) {
- LogLog.Error(declaringType, "[" + m_prefix + "] ErrorCode: " + errorCode.ToString() + ". " + message, e);
- }
- }
+ if (LogLog.InternalDebugging && !LogLog.QuietMode)
+ {
+ LogLog.Error(declaringType, "[" + m_prefix + "] ErrorCode: " + errorCode.ToString() + ". " + message, e);
+ }
+ }
- /// <summary>
+ /// <summary>
/// Log an Error
/// </summary>
/// <param name="message">The error message.</param>
/// <param name="e">The exception.</param>
/// <remarks>
- /// <para>
- /// Invokes <see cref="FirstError"/> if and only if this is the first error or the first error after <see cref="Reset"/> has been called.
- /// </para>
- /// </remarks>
- public void Error(string message, Exception e)
+ /// <para>
+ /// Invokes <see cref="FirstError"/> if and only if this is the first error or the first error after <see cref="Reset"/> has been called.
+ /// </para>
+ /// </remarks>
+ public void Error(string message, Exception e)
{
Error(message, e, ErrorCode.GenericFailure);
}
@@ -152,11 +154,11 @@
/// </summary>
/// <param name="message">The error message.</param>
/// <remarks>
- /// <para>
- /// Invokes <see cref="FirstError"/> if and only if this is the first error or the first error after <see cref="Reset"/> has been called.
- /// </para>
- /// </remarks>
- public void Error(string message)
+ /// <para>
+ /// Invokes <see cref="FirstError"/> if and only if this is the first error or the first error after <see cref="Reset"/> has been called.
+ /// </para>
+ /// </remarks>
+ public void Error(string message)
{
Error(message, null, ErrorCode.GenericFailure);
}
@@ -186,20 +188,20 @@
/// </summary>
public DateTime EnabledDate
{
- get
- {
- if (m_enabledDateUtc == DateTime.MinValue) return DateTime.MinValue;
- return m_enabledDateUtc.ToLocalTime();
- }
+ get
+ {
+ if (m_enabledDateUtc == DateTime.MinValue) return DateTime.MinValue;
+ return m_enabledDateUtc.ToLocalTime();
+ }
}
- /// <summary>
- /// The UTC date the first error that trigged this error handler occured, or <see cref="DateTime.MinValue"/> if it has not been triggered.
- /// </summary>
- public DateTime EnabledDateUtc
- {
- get { return m_enabledDateUtc; }
- }
+ /// <summary>
+ /// The UTC date the first error that trigged this error handler occured, or <see cref="DateTime.MinValue"/> if it has not been triggered.
+ /// </summary>
+ public DateTime EnabledDateUtc
+ {
+ get { return m_enabledDateUtc; }
+ }
/// <summary>
/// The message from the first error that trigged this error handler.
@@ -269,13 +271,13 @@
#region Private Static Fields
- /// <summary>
- /// The fully qualified type of the OnlyOnceErrorHandler class.
- /// </summary>
- /// <remarks>
- /// Used by the internal logger to record the Type of the
- /// log message.
- /// </remarks>
+ /// <summary>
+ /// The fully qualified type of the OnlyOnceErrorHandler class.
+ /// </summary>
+ /// <remarks>
+ /// Used by the internal logger to record the Type of the
+ /// log message.
+ /// </remarks>
private static readonly Type declaringType = typeof(OnlyOnceErrorHandler);
#endregion
diff --git a/src/log4net/Util/OptionConverter.cs b/src/log4net/Util/OptionConverter.cs
index 77075b7..8f4bcc7 100644
--- a/src/log4net/Util/OptionConverter.cs
+++ b/src/log4net/Util/OptionConverter.cs
@@ -70,7 +70,7 @@
/// Otherwise, <paramref name="defaultValue"/> is returned.
/// </para>
/// </remarks>
- public static bool ToBoolean(string argValue, bool defaultValue)
+ public static bool ToBoolean(string argValue, bool defaultValue)
{
if (argValue != null && argValue.Length > 0)
{
@@ -78,7 +78,7 @@
{
return bool.Parse(argValue);
}
- catch(Exception e)
+ catch (Exception e)
{
LogLog.Error(declaringType, "[" + argValue + "] is not in proper bool form.", e);
}
@@ -102,37 +102,37 @@
/// cannot be converted to a <see cref="long" /> value.
/// </para>
/// </remarks>
- public static long ToFileSize(string argValue, long defaultValue)
+ public static long ToFileSize(string argValue, long defaultValue)
{
if (argValue == null)
{
return defaultValue;
}
-
+
string s = argValue.Trim().ToUpperInvariant();
long multiplier = 1;
int index;
-
- if ((index = s.IndexOf("KB")) != -1)
- {
+
+ if ((index = s.IndexOf("KB")) != -1)
+ {
multiplier = 1024;
s = s.Substring(0, index);
}
- else if ((index = s.IndexOf("MB")) != -1)
+ else if ((index = s.IndexOf("MB")) != -1)
{
multiplier = 1024 * 1024;
s = s.Substring(0, index);
}
- else if ((index = s.IndexOf("GB")) != -1)
+ else if ((index = s.IndexOf("GB")) != -1)
{
multiplier = 1024 * 1024 * 1024;
s = s.Substring(0, index);
- }
- if (s != null)
+ }
+ if (s != null)
{
// Try again to remove whitespace between the number and the size specifier
s = s.Trim();
-
+
long longVal;
if (SystemInfo.TryParse(s, out longVal))
{
@@ -140,7 +140,7 @@
}
else
{
- LogLog.Error(declaringType, "OptionConverter: ["+ s +"] is not in the correct file size syntax.");
+ LogLog.Error(declaringType, "OptionConverter: [" + s + "] is not in the correct file size syntax.");
}
}
return defaultValue;
@@ -200,14 +200,14 @@
// to an arbitrary type T there will be a static method defined on type T called Parse
// that will take an argument of type string. i.e. T.Parse(string)->T we call this
// method to convert the string to the type required by the property.
- System.Reflection.MethodInfo meth = target.GetMethod("Parse", new Type[] {typeof(string)});
+ System.Reflection.MethodInfo meth = target.GetMethod("Parse", new Type[] { typeof(string) });
if (meth != null)
{
// Call the Parse method
#if NETSTANDARD1_3
return meth.Invoke(target, new[] { txt });
#else
- return meth.Invoke(null, BindingFlags.InvokeMethod, null, new object[] {txt}, CultureInfo.InvariantCulture);
+ return meth.Invoke(null, BindingFlags.InvokeMethod, null, new object[] { txt }, CultureInfo.InvariantCulture);
#endif
}
else
@@ -219,20 +219,20 @@
return null;
}
-// /// <summary>
-// /// Looks up the <see cref="IConvertFrom"/> for the target type.
-// /// </summary>
-// /// <param name="target">The type to lookup the converter for.</param>
-// /// <returns>The converter for the specified type.</returns>
-// public static IConvertFrom GetTypeConverter(Type target)
-// {
-// IConvertFrom converter = ConverterRegistry.GetConverter(target);
-// if (converter == null)
-// {
-// throw new InvalidOperationException("No type converter defined for [" + target + "]");
-// }
-// return converter;
-// }
+ // /// <summary>
+ // /// Looks up the <see cref="IConvertFrom"/> for the target type.
+ // /// </summary>
+ // /// <param name="target">The type to lookup the converter for.</param>
+ // /// <returns>The converter for the specified type.</returns>
+ // public static IConvertFrom GetTypeConverter(Type target)
+ // {
+ // IConvertFrom converter = ConverterRegistry.GetConverter(target);
+ // if (converter == null)
+ // {
+ // throw new InvalidOperationException("No type converter defined for [" + target + "]");
+ // }
+ // return converter;
+ // }
/// <summary>
/// Checks if there is an appropriate type conversion from the source type to the target type.
@@ -325,37 +325,37 @@
throw new ArgumentException("Cannot convert source object [" + sourceInstance.ToString() + "] to target type [" + targetType.Name + "]", "sourceInstance");
}
-// /// <summary>
-// /// Finds the value corresponding to <paramref name="key"/> in
-// /// <paramref name="props"/> and then perform variable substitution
-// /// on the found value.
-// /// </summary>
-// /// <param name="key">The key to lookup.</param>
-// /// <param name="props">The association to use for lookups.</param>
-// /// <returns>The substituted result.</returns>
-// public static string FindAndSubst(string key, System.Collections.IDictionary props)
-// {
-// if (props == null)
-// {
-// throw new ArgumentNullException("props");
-// }
-//
-// string v = props[key] as string;
-// if (v == null)
-// {
-// return null;
-// }
-//
-// try
-// {
-// return SubstituteVariables(v, props);
-// }
-// catch(Exception e)
-// {
-// LogLog.Error(declaringType, "OptionConverter: Bad option value [" + v + "].", e);
-// return v;
-// }
-// }
+ // /// <summary>
+ // /// Finds the value corresponding to <paramref name="key"/> in
+ // /// <paramref name="props"/> and then perform variable substitution
+ // /// on the found value.
+ // /// </summary>
+ // /// <param name="key">The key to lookup.</param>
+ // /// <param name="props">The association to use for lookups.</param>
+ // /// <returns>The substituted result.</returns>
+ // public static string FindAndSubst(string key, System.Collections.IDictionary props)
+ // {
+ // if (props == null)
+ // {
+ // throw new ArgumentNullException("props");
+ // }
+ //
+ // string v = props[key] as string;
+ // if (v == null)
+ // {
+ // return null;
+ // }
+ //
+ // try
+ // {
+ // return SubstituteVariables(v, props);
+ // }
+ // catch(Exception e)
+ // {
+ // LogLog.Error(declaringType, "OptionConverter: Bad option value [" + v + "].", e);
+ // return v;
+ // }
+ // }
/// <summary>
/// Instantiates an object given a class name.
@@ -374,30 +374,30 @@
/// not be instantiated, then <paramref name="defaultValue"/> is returned.
/// </para>
/// </remarks>
- public static object InstantiateByClassName(string className, Type superClass, object defaultValue)
+ public static object InstantiateByClassName(string className, Type superClass, object defaultValue)
{
- if (className != null)
+ if (className != null)
{
- try
+ try
{
#if NETSTANDARD1_3
Type classObj = SystemInfo.GetTypeFromString(superClass.GetTypeInfo().Assembly, className, true, true);
#else
Type classObj = SystemInfo.GetTypeFromString(className, true, true);
#endif
- if (!superClass.IsAssignableFrom(classObj))
+ if (!superClass.IsAssignableFrom(classObj))
{
LogLog.Error(declaringType, "OptionConverter: A [" + className + "] object is not assignable to a [" + superClass.FullName + "] variable.");
- return defaultValue;
+ return defaultValue;
}
return Activator.CreateInstance(classObj);
}
- catch (Exception e)
+ catch (Exception e)
{
LogLog.Error(declaringType, "Could not instantiate class [" + className + "].", e);
}
}
- return defaultValue;
+ return defaultValue;
}
/// <summary>
@@ -443,48 +443,48 @@
/// delimiter "${" which is not balanced by a stop delimiter "}".
/// </para>
/// </remarks>
- public static string SubstituteVariables(string value, System.Collections.IDictionary props)
+ public static string SubstituteVariables(string value, System.Collections.IDictionary props)
{
StringBuilder buf = new StringBuilder();
int i = 0;
int j, k;
-
- while(true)
+
+ while (true)
{
j = value.IndexOf(DELIM_START, i);
- if (j == -1)
+ if (j == -1)
{
if (i == 0)
{
return value;
}
- else
+ else
{
buf.Append(value.Substring(i, value.Length - i));
return buf.ToString();
}
}
- else
+ else
{
buf.Append(value.Substring(i, j - i));
k = value.IndexOf(DELIM_STOP, j);
- if (k == -1)
+ if (k == -1)
{
throw new LogException("[" + value + "] has no closing brace. Opening brace at position [" + j + "]");
}
- else
+ else
{
j += DELIM_START_LEN;
string key = value.Substring(j, k - j);
string replacement = props[key] as string;
- if (replacement != null)
+ if (replacement != null)
{
buf.Append(replacement);
}
- i = k + DELIM_STOP_LEN;
+ i = k + DELIM_STOP_LEN;
}
}
}
@@ -502,7 +502,7 @@
/// <param name="value">The enum string value.</param>
/// <param name="ignoreCase">If <c>true</c>, ignore case; otherwise, regard case.</param>
/// <returns>An object of type <paramref name="enumType" /> whose value is represented by <paramref name="value" />.</returns>
- private static object ParseEnum(System.Type enumType, string value, bool ignoreCase)
+ private static object ParseEnum(System.Type enumType, string value, bool ignoreCase)
{
#if !NETCF
return Enum.Parse(enumType, value, ignoreCase);
@@ -543,25 +543,25 @@
}
return Enum.ToObject(enumType, retVal);
#endif
- }
+ }
#endregion Private Static Methods
#region Private Static Fields
- /// <summary>
- /// The fully qualified type of the OptionConverter class.
- /// </summary>
- /// <remarks>
- /// Used by the internal logger to record the Type of the
- /// log message.
- /// </remarks>
- private static readonly Type declaringType = typeof(OptionConverter);
+ /// <summary>
+ /// The fully qualified type of the OptionConverter class.
+ /// </summary>
+ /// <remarks>
+ /// Used by the internal logger to record the Type of the
+ /// log message.
+ /// </remarks>
+ private static readonly Type declaringType = typeof(OptionConverter);
private const string DELIM_START = "${";
- private const char DELIM_STOP = '}';
+ private const char DELIM_STOP = '}';
private const int DELIM_START_LEN = 2;
- private const int DELIM_STOP_LEN = 1;
+ private const int DELIM_STOP_LEN = 1;
#endregion Private Static Fields
}
diff --git a/src/log4net/Util/PatternConverter.cs b/src/log4net/Util/PatternConverter.cs
index 295a749..8403ddd 100644
--- a/src/log4net/Util/PatternConverter.cs
+++ b/src/log4net/Util/PatternConverter.cs
@@ -51,8 +51,8 @@
/// Initializes a new instance of the <see cref="PatternConverter" /> class.
/// </para>
/// </remarks>
- protected PatternConverter()
- {
+ protected PatternConverter()
+ {
}
#endregion Protected Instance Constructors
@@ -165,7 +165,7 @@
/// apply those formattings before writing the output.
/// </para>
/// </remarks>
- public virtual void Format(TextWriter writer, object state)
+ public virtual void Format(TextWriter writer, object state)
{
if (m_min < 0 && m_max == int.MaxValue)
{
@@ -174,35 +174,35 @@
}
else
{
- string msg = null;
- int len;
- lock (m_formatWriter)
- {
- m_formatWriter.Reset(c_renderBufferMaxCapacity, c_renderBufferSize);
-
- Convert(m_formatWriter, state);
-
- StringBuilder buf = m_formatWriter.GetStringBuilder();
- len = buf.Length;
- if (len > m_max)
- {
- msg = buf.ToString(len - m_max, m_max);
- len = m_max;
- }
- else
- {
- msg = buf.ToString();
- }
- }
-
- if (len < m_min)
+ string msg = null;
+ int len;
+ lock (m_formatWriter)
{
- if (m_leftAlign)
- {
+ m_formatWriter.Reset(c_renderBufferMaxCapacity, c_renderBufferSize);
+
+ Convert(m_formatWriter, state);
+
+ StringBuilder buf = m_formatWriter.GetStringBuilder();
+ len = buf.Length;
+ if (len > m_max)
+ {
+ msg = buf.ToString(len - m_max, m_max);
+ len = m_max;
+ }
+ else
+ {
+ msg = buf.ToString();
+ }
+ }
+
+ if (len < m_min)
+ {
+ if (m_leftAlign)
+ {
writer.Write(msg);
SpacePad(writer, m_min - len);
}
- else
+ else
{
SpacePad(writer, m_min - len);
writer.Write(msg);
@@ -213,7 +213,7 @@
writer.Write(msg);
}
}
- }
+ }
private static readonly string[] SPACES = { " ", " ", " ", " ", // 1,2,4,8 spaces
" ", // 16 spaces
@@ -229,22 +229,22 @@
/// Fast space padding method.
/// </para>
/// </remarks>
- protected static void SpacePad(TextWriter writer, int length)
+ protected static void SpacePad(TextWriter writer, int length)
{
- while(length >= 32)
+ while (length >= 32)
{
writer.Write(SPACES[5]);
length -= 32;
}
-
- for(int i = 4; i >= 0; i--)
- {
- if ((length & (1<<i)) != 0)
+
+ for (int i = 4; i >= 0; i--)
+ {
+ if ((length & (1 << i)) != 0)
{
writer.Write(SPACES[i]);
}
}
- }
+ }
#endregion Public Instance Methods
@@ -372,26 +372,26 @@
// Don't have a repository to render with so just have to rely on ToString
if (value == null)
{
- writer.Write( SystemInfo.NullText );
+ writer.Write(SystemInfo.NullText);
}
else
{
- writer.Write( value.ToString() );
+ writer.Write(value.ToString());
}
}
}
#endregion
- private PropertiesDictionary properties;
+ private PropertiesDictionary properties;
- /// <summary>
- ///
- /// </summary>
- public PropertiesDictionary Properties
- {
- get { return properties; }
- set { properties = value; }
- }
+ /// <summary>
+ ///
+ /// </summary>
+ public PropertiesDictionary Properties
+ {
+ get { return properties; }
+ set { properties = value; }
+ }
}
}
diff --git a/src/log4net/Util/PatternParser.cs b/src/log4net/Util/PatternParser.cs
index fc4c40b..c639d5a 100644
--- a/src/log4net/Util/PatternParser.cs
+++ b/src/log4net/Util/PatternParser.cs
@@ -52,7 +52,7 @@
/// with the specified pattern string.
/// </para>
/// </remarks>
- public PatternParser(string pattern)
+ public PatternParser(string pattern)
{
m_pattern = pattern;
}
@@ -164,7 +164,7 @@
return s2.Length.CompareTo(s1.Length);
}
-
+
#endregion
}
@@ -183,7 +183,7 @@
private void ParseInternal(string pattern, string[] matches)
{
int offset = 0;
- while(offset < pattern.Length)
+ while (offset < pattern.Length)
{
int i = pattern.IndexOf('%', offset);
if (i < 0 || i == pattern.Length - 1)
@@ -193,7 +193,7 @@
}
else
{
- if (pattern[i+1] == '%')
+ if (pattern[i + 1] == '%')
{
// Escaped
ProcessLiteral(pattern.Substring(offset, i - offset + 1));
@@ -257,7 +257,7 @@
int remainingStringLength = pattern.Length - offset;
// Look for pattern
- for(int m=0; m<matches.Length; m++)
+ for (int m = 0; m < matches.Length; m++)
{
string key = matches[m];
@@ -277,7 +277,7 @@
{
// Seen option start
offset++;
-
+
int optEnd = pattern.IndexOf('}', offset);
if (optEnd < 0)
{
@@ -322,13 +322,13 @@
/// <param name="formattingInfo">the formatting info for the converter</param>
private void ProcessConverter(string converterName, string option, FormattingInfo formattingInfo)
{
- LogLog.Debug(declaringType, "Converter ["+converterName+"] Option ["+option+"] Format [min="+formattingInfo.Min+",max="+formattingInfo.Max+",leftAlign="+formattingInfo.LeftAlign+"]");
+ LogLog.Debug(declaringType, "Converter [" + converterName + "] Option [" + option + "] Format [min=" + formattingInfo.Min + ",max=" + formattingInfo.Max + ",leftAlign=" + formattingInfo.LeftAlign + "]");
// Lookup the converter type
- ConverterInfo converterInfo = (ConverterInfo)m_patternConverters[converterName];
+ ConverterInfo converterInfo = (ConverterInfo)m_patternConverters[converterName];
if (converterInfo == null)
{
- LogLog.Error(declaringType, "Unknown converter name ["+converterName+"] in conversion pattern.");
+ LogLog.Error(declaringType, "Unknown converter name [" + converterName + "] in conversion pattern.");
}
else
{
@@ -336,20 +336,20 @@
PatternConverter pc = null;
try
{
- pc = (PatternConverter)Activator.CreateInstance(converterInfo.Type);
+ pc = (PatternConverter)Activator.CreateInstance(converterInfo.Type);
}
- catch(Exception createInstanceEx)
+ catch (Exception createInstanceEx)
{
- LogLog.Error(declaringType, "Failed to create instance of Type [" + converterInfo.Type.FullName + "] using default constructor. Exception: " + createInstanceEx.ToString());
+ LogLog.Error(declaringType, "Failed to create instance of Type [" + converterInfo.Type.FullName + "] using default constructor. Exception: " + createInstanceEx.ToString());
}
// formattingInfo variable is an instance variable, occasionally reset
// and used over and over again
pc.FormattingInfo = formattingInfo;
pc.Option = option;
- pc.Properties = converterInfo.Properties;
+ pc.Properties = converterInfo.Properties;
- IOptionHandler optionHandler = pc as IOptionHandler;
+ IOptionHandler optionHandler = pc as IOptionHandler;
if (optionHandler != null)
{
optionHandler.ActivateOptions();
@@ -364,15 +364,15 @@
/// to the chain.
/// </summary>
/// <param name="pc">The pattern converter to add.</param>
- private void AddConverter(PatternConverter pc)
+ private void AddConverter(PatternConverter pc)
{
// Add the pattern converter to the list.
- if (m_head == null)
+ if (m_head == null)
{
m_head = m_tail = pc;
}
- else
+ else
{
// Set the next converter on the tail
// Update the tail reference
@@ -387,7 +387,7 @@
#region Private Constants
private const char ESCAPE_CHAR = '%';
-
+
#endregion Private Constants
#region Private Instance Fields
@@ -419,17 +419,17 @@
#endregion Private Instance Fields
- #region Private Static Fields
+ #region Private Static Fields
- /// <summary>
- /// The fully qualified type of the PatternParser class.
- /// </summary>
- /// <remarks>
- /// Used by the internal logger to record the Type of the
- /// log message.
- /// </remarks>
- private static readonly Type declaringType = typeof(PatternParser);
+ /// <summary>
+ /// The fully qualified type of the PatternParser class.
+ /// </summary>
+ /// <remarks>
+ /// Used by the internal logger to record the Type of the
+ /// log message.
+ /// </remarks>
+ private static readonly Type declaringType = typeof(PatternParser);
- #endregion Private Static Fields
+ #endregion Private Static Fields
}
}
diff --git a/src/log4net/Util/PatternString.cs b/src/log4net/Util/PatternString.cs
index cb5c446..d844b63 100644
--- a/src/log4net/Util/PatternString.cs
+++ b/src/log4net/Util/PatternString.cs
@@ -265,12 +265,12 @@
#endregion Static Fields
#region Member Variables
-
+
/// <summary>
/// the pattern
/// </summary>
private string m_pattern;
-
+
/// <summary>
/// the head of the pattern converter chain
/// </summary>
@@ -352,7 +352,7 @@
}
#endregion
-
+
/// <summary>
/// Gets or sets the pattern formatting string
/// </summary>
@@ -368,7 +368,7 @@
/// </remarks>
public string ConversionPattern
{
- get { return m_pattern; }
+ get { return m_pattern; }
set { m_pattern = value; }
}
@@ -390,7 +390,7 @@
/// <see cref="ActivateOptions"/> must be called again.
/// </para>
/// </remarks>
- public virtual void ActivateOptions()
+ public virtual void ActivateOptions()
{
m_head = CreatePatternParser(m_pattern).Parse();
}
@@ -409,27 +409,27 @@
/// custom conversion pattern name.
/// </para>
/// </remarks>
- private PatternParser CreatePatternParser(string pattern)
+ private PatternParser CreatePatternParser(string pattern)
{
PatternParser patternParser = new PatternParser(pattern);
// Add all the builtin patterns
- foreach(DictionaryEntry entry in s_globalRulesRegistry)
+ foreach (DictionaryEntry entry in s_globalRulesRegistry)
{
- ConverterInfo converterInfo = new ConverterInfo();
- converterInfo.Name = (string)entry.Key;
- converterInfo.Type = (Type)entry.Value;
- patternParser.PatternConverters.Add(entry.Key, converterInfo);
+ ConverterInfo converterInfo = new ConverterInfo();
+ converterInfo.Name = (string)entry.Key;
+ converterInfo.Type = (Type)entry.Value;
+ patternParser.PatternConverters.Add(entry.Key, converterInfo);
}
// Add the instance patterns
- foreach(DictionaryEntry entry in m_instanceRulesRegistry)
+ foreach (DictionaryEntry entry in m_instanceRulesRegistry)
{
patternParser.PatternConverters[entry.Key] = entry.Value;
}
return patternParser;
}
-
+
/// <summary>
/// Produces a formatted string as specified by the conversion pattern.
/// </summary>
@@ -439,7 +439,7 @@
/// Format the pattern to the <paramref name="writer"/>.
/// </para>
/// </remarks>
- public void Format(TextWriter writer)
+ public void Format(TextWriter writer)
{
if (writer == null)
{
@@ -449,7 +449,7 @@
PatternConverter c = m_head;
// loop through the chain of pattern converters
- while(c != null)
+ while (c != null)
{
c.Format(writer, null);
c = c.Next;
@@ -465,7 +465,7 @@
/// Format the pattern to a string.
/// </para>
/// </remarks>
- public string Format()
+ public string Format()
{
using StringWriter writer = new StringWriter(System.Globalization.CultureInfo.InvariantCulture);
Format(writer);
@@ -484,13 +484,13 @@
/// </remarks>
public void AddConverter(ConverterInfo converterInfo)
{
- if (converterInfo == null) throw new ArgumentNullException("converterInfo");
+ if (converterInfo == null) throw new ArgumentNullException("converterInfo");
- if (!typeof(PatternConverter).IsAssignableFrom(converterInfo.Type))
- {
- throw new ArgumentException("The converter type specified [" + converterInfo.Type + "] must be a subclass of log4net.Util.PatternConverter", "converterInfo");
- }
- m_instanceRulesRegistry[converterInfo.Name] = converterInfo;
+ if (!typeof(PatternConverter).IsAssignableFrom(converterInfo.Type))
+ {
+ throw new ArgumentException("The converter type specified [" + converterInfo.Type + "] must be a subclass of log4net.Util.PatternConverter", "converterInfo");
+ }
+ m_instanceRulesRegistry[converterInfo.Name] = converterInfo;
}
/// <summary>
@@ -508,11 +508,11 @@
if (name == null) throw new ArgumentNullException("name");
if (type == null) throw new ArgumentNullException("type");
- ConverterInfo converterInfo = new ConverterInfo();
- converterInfo.Name = name;
- converterInfo.Type = type;
+ ConverterInfo converterInfo = new ConverterInfo();
+ converterInfo.Name = name;
+ converterInfo.Type = type;
- AddConverter(converterInfo);
+ AddConverter(converterInfo);
}
}
}
diff --git a/src/log4net/Util/PatternStringConverters/AppDomainPatternConverter.cs b/src/log4net/Util/PatternStringConverters/AppDomainPatternConverter.cs
index a874299..4168df1 100644
--- a/src/log4net/Util/PatternStringConverters/AppDomainPatternConverter.cs
+++ b/src/log4net/Util/PatternStringConverters/AppDomainPatternConverter.cs
@@ -34,7 +34,7 @@
/// </para>
/// </remarks>
/// <author>Nicko Cadell</author>
- internal sealed class AppDomainPatternConverter : PatternConverter
+ internal sealed class AppDomainPatternConverter : PatternConverter
{
/// <summary>
/// Write the name of the current AppDomain to the output
@@ -46,9 +46,9 @@
/// Writes name of the current AppDomain to the output <paramref name="writer"/>.
/// </para>
/// </remarks>
- protected override void Convert(TextWriter writer, object state)
+ protected override void Convert(TextWriter writer, object state)
{
- writer.Write( SystemInfo.ApplicationFriendlyName );
+ writer.Write(SystemInfo.ApplicationFriendlyName);
}
}
}
diff --git a/src/log4net/Util/PatternStringConverters/AppSettingPatternConverter.cs b/src/log4net/Util/PatternStringConverters/AppSettingPatternConverter.cs
index 75d5fb0..b3487ff 100644
--- a/src/log4net/Util/PatternStringConverters/AppSettingPatternConverter.cs
+++ b/src/log4net/Util/PatternStringConverters/AppSettingPatternConverter.cs
@@ -26,83 +26,83 @@
namespace log4net.Util.PatternStringConverters
{
+ /// <summary>
+ /// AppSetting pattern converter
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// This pattern converter reads appSettings from the application configuration file.
+ /// </para>
+ /// <para>
+ /// If the <see cref="PatternConverter.Option"/> is specified then that will be used to
+ /// lookup a single appSettings value. If no <see cref="PatternConverter.Option"/> is specified
+ /// then all appSettings will be dumped as a list of key value pairs.
+ /// </para>
+ /// <para>
+ /// A typical use is to specify a base directory for log files, e.g.
+ /// <example>
+ /// <![CDATA[
+ /// <log4net>
+ /// <appender name="MyAppender" type="log4net.Appender.RollingFileAppender">
+ /// <file type="log4net.Util.PatternString" value="appsetting{LogDirectory}MyApp.log"/>
+ /// ...
+ /// </appender>
+ /// </log4net>
+ /// ]]>
+ /// </example>
+ /// </para>
+ /// </remarks>
+ internal sealed class AppSettingPatternConverter : PatternConverter
+ {
+ private static IDictionary AppSettingsDictionary
+ {
+ get
+ {
+ if (_appSettingsHashTable == null)
+ {
+ Hashtable h = new Hashtable();
+ foreach (string key in ConfigurationManager.AppSettings)
+ {
+ h.Add(key, ConfigurationManager.AppSettings[key]);
+ }
+ _appSettingsHashTable = h;
+ }
+ return _appSettingsHashTable;
+ }
+
+ }
+ private static Hashtable _appSettingsHashTable;
+
/// <summary>
- /// AppSetting pattern converter
+ /// Write the property value to the output
/// </summary>
+ /// <param name="writer"><see cref="TextWriter" /> that will receive the formatted result.</param>
+ /// <param name="state">null, state is not set</param>
/// <remarks>
/// <para>
- /// This pattern converter reads appSettings from the application configuration file.
+ /// Writes out the value of a named property. The property name
+ /// should be set in the <see cref="log4net.Util.PatternConverter.Option"/>
+ /// property.
/// </para>
/// <para>
- /// If the <see cref="PatternConverter.Option"/> is specified then that will be used to
- /// lookup a single appSettings value. If no <see cref="PatternConverter.Option"/> is specified
- /// then all appSettings will be dumped as a list of key value pairs.
- /// </para>
- /// <para>
- /// A typical use is to specify a base directory for log files, e.g.
- /// <example>
- /// <![CDATA[
- /// <log4net>
- /// <appender name="MyAppender" type="log4net.Appender.RollingFileAppender">
- /// <file type="log4net.Util.PatternString" value="appsetting{LogDirectory}MyApp.log"/>
- /// ...
- /// </appender>
- /// </log4net>
- /// ]]>
- /// </example>
+ /// If the <see cref="log4net.Util.PatternConverter.Option"/> is set to <c>null</c>
+ /// then all the properties are written as key value pairs.
/// </para>
/// </remarks>
- internal sealed class AppSettingPatternConverter : PatternConverter
+ protected override void Convert(TextWriter writer, object state)
{
- private static IDictionary AppSettingsDictionary
- {
- get
- {
- if (_appSettingsHashTable == null)
- {
- Hashtable h = new Hashtable();
- foreach(string key in ConfigurationManager.AppSettings)
- {
- h.Add(key, ConfigurationManager.AppSettings[key]);
- }
- _appSettingsHashTable = h;
- }
- return _appSettingsHashTable;
- }
- }
- private static Hashtable _appSettingsHashTable;
-
- /// <summary>
- /// Write the property value to the output
- /// </summary>
- /// <param name="writer"><see cref="TextWriter" /> that will receive the formatted result.</param>
- /// <param name="state">null, state is not set</param>
- /// <remarks>
- /// <para>
- /// Writes out the value of a named property. The property name
- /// should be set in the <see cref="log4net.Util.PatternConverter.Option"/>
- /// property.
- /// </para>
- /// <para>
- /// If the <see cref="log4net.Util.PatternConverter.Option"/> is set to <c>null</c>
- /// then all the properties are written as key value pairs.
- /// </para>
- /// </remarks>
- protected override void Convert(TextWriter writer, object state)
- {
-
- if (Option != null)
- {
- // Write the value for the specified key
- WriteObject(writer, null, ConfigurationManager.AppSettings[Option]);
- }
- else
- {
- // Write all the key value pairs
- WriteDictionary(writer, null, AppSettingsDictionary);
- }
- }
+ if (Option != null)
+ {
+ // Write the value for the specified key
+ WriteObject(writer, null, ConfigurationManager.AppSettings[Option]);
+ }
+ else
+ {
+ // Write all the key value pairs
+ WriteDictionary(writer, null, AppSettingsDictionary);
+ }
}
+ }
}
#endif // !NETCF && NET_2_0
diff --git a/src/log4net/Util/PatternStringConverters/DatePatternConverter.cs b/src/log4net/Util/PatternStringConverters/DatePatternConverter.cs
index 315ce0a..8f77b5f 100644
--- a/src/log4net/Util/PatternStringConverters/DatePatternConverter.cs
+++ b/src/log4net/Util/PatternStringConverters/DatePatternConverter.cs
@@ -91,7 +91,7 @@
/// </para>
/// </remarks>
protected IDateFormatter m_dateFormatter;
-
+
#region Implementation of IOptionHandler
/// <summary>
@@ -118,7 +118,7 @@
{
dateFormatStr = AbsoluteTimeDateFormatter.Iso8601TimeDateFormat;
}
-
+
if (SystemInfo.EqualsIgnoringCase(dateFormatStr, AbsoluteTimeDateFormatter.Iso8601TimeDateFormat))
{
m_dateFormatter = new Iso8601DateFormatter();
@@ -133,15 +133,15 @@
}
else
{
- try
+ try
{
m_dateFormatter = new SimpleDateFormatter(dateFormatStr);
}
- catch (Exception e)
+ catch (Exception e)
{
- LogLog.Error(declaringType, "Could not instantiate SimpleDateFormatter with ["+dateFormatStr+"]", e);
+ LogLog.Error(declaringType, "Could not instantiate SimpleDateFormatter with [" + dateFormatStr + "]", e);
m_dateFormatter = new Iso8601DateFormatter();
- }
+ }
}
}
@@ -161,29 +161,29 @@
/// The date and time passed is in the local time zone.
/// </para>
/// </remarks>
- protected override void Convert(TextWriter writer, object state)
+ protected override void Convert(TextWriter writer, object state)
{
- try
+ try
{
m_dateFormatter.FormatDate(DateTime.Now, writer);
}
- catch (Exception ex)
+ catch (Exception ex)
{
LogLog.Error(declaringType, "Error occurred while converting date.", ex);
}
}
- #region Private Static Fields
+ #region Private Static Fields
- /// <summary>
- /// The fully qualified type of the DatePatternConverter class.
- /// </summary>
- /// <remarks>
- /// Used by the internal logger to record the Type of the
- /// log message.
- /// </remarks>
- private static readonly Type declaringType = typeof(DatePatternConverter);
+ /// <summary>
+ /// The fully qualified type of the DatePatternConverter class.
+ /// </summary>
+ /// <remarks>
+ /// Used by the internal logger to record the Type of the
+ /// log message.
+ /// </remarks>
+ private static readonly Type declaringType = typeof(DatePatternConverter);
- #endregion Private Static Fields
+ #endregion Private Static Fields
}
}
diff --git a/src/log4net/Util/PatternStringConverters/EnvironmentFolderPathPatternConverter.cs b/src/log4net/Util/PatternStringConverters/EnvironmentFolderPathPatternConverter.cs
index bd8d4b5..a66cdce 100644
--- a/src/log4net/Util/PatternStringConverters/EnvironmentFolderPathPatternConverter.cs
+++ b/src/log4net/Util/PatternStringConverters/EnvironmentFolderPathPatternConverter.cs
@@ -24,75 +24,75 @@
namespace log4net.Util.PatternStringConverters
{
+ /// <summary>
+ /// Write an <see cref="System.Environment.SpecialFolder" /> folder path to the output
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// Write an special path environment folder path to the output writer.
+ /// The value of the <see cref="log4net.Util.PatternConverter.Option"/> determines
+ /// the name of the variable to output. <see cref="log4net.Util.PatternConverter.Option"/>
+ /// should be a value in the <see cref="System.Environment.SpecialFolder" /> enumeration.
+ /// </para>
+ /// </remarks>
+ /// <author>Ron Grabowski</author>
+ internal sealed class EnvironmentFolderPathPatternConverter : PatternConverter
+ {
/// <summary>
- /// Write an <see cref="System.Environment.SpecialFolder" /> folder path to the output
+ /// Write an special path environment folder path to the output
/// </summary>
+ /// <param name="writer">the writer to write to</param>
+ /// <param name="state">null, state is not set</param>
/// <remarks>
/// <para>
- /// Write an special path environment folder path to the output writer.
- /// The value of the <see cref="log4net.Util.PatternConverter.Option"/> determines
- /// the name of the variable to output. <see cref="log4net.Util.PatternConverter.Option"/>
- /// should be a value in the <see cref="System.Environment.SpecialFolder" /> enumeration.
+ /// Writes the special path environment folder path to the output <paramref name="writer"/>.
+ /// The name of the special path environment folder path to output must be set
+ /// using the <see cref="log4net.Util.PatternConverter.Option"/>
+ /// property.
/// </para>
/// </remarks>
- /// <author>Ron Grabowski</author>
- internal sealed class EnvironmentFolderPathPatternConverter : PatternConverter
+ protected override void Convert(TextWriter writer, object state)
{
- /// <summary>
- /// Write an special path environment folder path to the output
- /// </summary>
- /// <param name="writer">the writer to write to</param>
- /// <param name="state">null, state is not set</param>
- /// <remarks>
- /// <para>
- /// Writes the special path environment folder path to the output <paramref name="writer"/>.
- /// The name of the special path environment folder path to output must be set
- /// using the <see cref="log4net.Util.PatternConverter.Option"/>
- /// property.
- /// </para>
- /// </remarks>
- protected override void Convert(TextWriter writer, object state)
+ try
+ {
+ if (Option != null && Option.Length > 0)
{
- try
- {
- if (Option != null && Option.Length > 0)
- {
- Environment.SpecialFolder specialFolder =
- (Environment.SpecialFolder)Enum.Parse(typeof(Environment.SpecialFolder), Option, true);
+ Environment.SpecialFolder specialFolder =
+ (Environment.SpecialFolder)Enum.Parse(typeof(Environment.SpecialFolder), Option, true);
- string envFolderPathValue = Environment.GetFolderPath(specialFolder);
- if (envFolderPathValue != null && envFolderPathValue.Length > 0)
- {
- writer.Write(envFolderPathValue);
- }
- }
- }
- catch (System.Security.SecurityException secEx)
- {
- // This security exception will occur if the caller does not have
- // unrestricted environment permission. If this occurs the expansion
- // will be skipped with the following warning message.
- LogLog.Debug(declaringType, "Security exception while trying to expand environment variables. Error Ignored. No Expansion.", secEx);
- }
- catch (Exception ex)
- {
- LogLog.Error(declaringType, "Error occurred while converting environment variable.", ex);
- }
+ string envFolderPathValue = Environment.GetFolderPath(specialFolder);
+ if (envFolderPathValue != null && envFolderPathValue.Length > 0)
+ {
+ writer.Write(envFolderPathValue);
+ }
}
-
- #region Private Static Fields
-
- /// <summary>
- /// The fully qualified type of the EnvironmentFolderPathPatternConverter class.
- /// </summary>
- /// <remarks>
- /// Used by the internal logger to record the Type of the
- /// log message.
- /// </remarks>
- private static readonly Type declaringType = typeof(EnvironmentFolderPathPatternConverter);
-
- #endregion Private Static Fields
+ }
+ catch (System.Security.SecurityException secEx)
+ {
+ // This security exception will occur if the caller does not have
+ // unrestricted environment permission. If this occurs the expansion
+ // will be skipped with the following warning message.
+ LogLog.Debug(declaringType, "Security exception while trying to expand environment variables. Error Ignored. No Expansion.", secEx);
+ }
+ catch (Exception ex)
+ {
+ LogLog.Error(declaringType, "Error occurred while converting environment variable.", ex);
+ }
}
+
+ #region Private Static Fields
+
+ /// <summary>
+ /// The fully qualified type of the EnvironmentFolderPathPatternConverter class.
+ /// </summary>
+ /// <remarks>
+ /// Used by the internal logger to record the Type of the
+ /// log message.
+ /// </remarks>
+ private static readonly Type declaringType = typeof(EnvironmentFolderPathPatternConverter);
+
+ #endregion Private Static Fields
+ }
}
#endif // !NETCF && NET_2_0
\ No newline at end of file
diff --git a/src/log4net/Util/PatternStringConverters/EnvironmentPatternConverter.cs b/src/log4net/Util/PatternStringConverters/EnvironmentPatternConverter.cs
index 8b011a5..7efb2a2 100644
--- a/src/log4net/Util/PatternStringConverters/EnvironmentPatternConverter.cs
+++ b/src/log4net/Util/PatternStringConverters/EnvironmentPatternConverter.cs
@@ -51,9 +51,9 @@
/// property.
/// </para>
/// </remarks>
- protected override void Convert(TextWriter writer, object state)
+ protected override void Convert(TextWriter writer, object state)
{
- try
+ try
{
if (this.Option != null && this.Option.Length > 0)
{
@@ -61,17 +61,17 @@
string envValue = Environment.GetEnvironmentVariable(this.Option);
#if NET_2_0 || NETSTANDARD2_0
- // If we didn't see it for the process, try a user level variable.
- if (envValue == null)
- {
- envValue = Environment.GetEnvironmentVariable(this.Option, EnvironmentVariableTarget.User);
- }
+ // If we didn't see it for the process, try a user level variable.
+ if (envValue == null)
+ {
+ envValue = Environment.GetEnvironmentVariable(this.Option, EnvironmentVariableTarget.User);
+ }
- // If we still didn't find it, try a system level one.
- if (envValue == null)
- {
- envValue = Environment.GetEnvironmentVariable(this.Option, EnvironmentVariableTarget.Machine);
- }
+ // If we still didn't find it, try a system level one.
+ if (envValue == null)
+ {
+ envValue = Environment.GetEnvironmentVariable(this.Option, EnvironmentVariableTarget.Machine);
+ }
#endif
if (envValue != null && envValue.Length > 0)
@@ -80,31 +80,31 @@
}
}
}
- catch(System.Security.SecurityException secEx)
+ catch (System.Security.SecurityException secEx)
{
// This security exception will occur if the caller does not have
// unrestricted environment permission. If this occurs the expansion
// will be skipped with the following warning message.
LogLog.Debug(declaringType, "Security exception while trying to expand environment variables. Error Ignored. No Expansion.", secEx);
}
- catch (Exception ex)
+ catch (Exception ex)
{
LogLog.Error(declaringType, "Error occurred while converting environment variable.", ex);
}
}
- #region Private Static Fields
+ #region Private Static Fields
- /// <summary>
- /// The fully qualified type of the EnvironmentPatternConverter class.
- /// </summary>
- /// <remarks>
- /// Used by the internal logger to record the Type of the
- /// log message.
- /// </remarks>
- private static readonly Type declaringType = typeof(EnvironmentPatternConverter);
+ /// <summary>
+ /// The fully qualified type of the EnvironmentPatternConverter class.
+ /// </summary>
+ /// <remarks>
+ /// Used by the internal logger to record the Type of the
+ /// log message.
+ /// </remarks>
+ private static readonly Type declaringType = typeof(EnvironmentPatternConverter);
- #endregion Private Static Fields
+ #endregion Private Static Fields
}
}
diff --git a/src/log4net/Util/PatternStringConverters/IdentityPatternConverter.cs b/src/log4net/Util/PatternStringConverters/IdentityPatternConverter.cs
index f31ca0d..8f6b926 100644
--- a/src/log4net/Util/PatternStringConverters/IdentityPatternConverter.cs
+++ b/src/log4net/Util/PatternStringConverters/IdentityPatternConverter.cs
@@ -34,7 +34,7 @@
/// </para>
/// </remarks>
/// <author>Nicko Cadell</author>
- internal sealed class IdentityPatternConverter : PatternConverter
+ internal sealed class IdentityPatternConverter : PatternConverter
{
/// <summary>
/// Write the current thread identity to the output
@@ -46,7 +46,7 @@
/// Writes the current thread identity to the output <paramref name="writer"/>.
/// </para>
/// </remarks>
- protected override void Convert(TextWriter writer, object state)
+ protected override void Convert(TextWriter writer, object state)
{
#if (NETCF || SSCLI || NETSTANDARD1_3)
// On compact framework there's no notion of current thread principals
@@ -54,35 +54,35 @@
#else
try
{
- if (System.Threading.Thread.CurrentPrincipal != null &&
+ if (System.Threading.Thread.CurrentPrincipal != null &&
System.Threading.Thread.CurrentPrincipal.Identity != null &&
System.Threading.Thread.CurrentPrincipal.Identity.Name != null)
{
- writer.Write( System.Threading.Thread.CurrentPrincipal.Identity.Name );
+ writer.Write(System.Threading.Thread.CurrentPrincipal.Identity.Name);
}
}
- catch(System.Security.SecurityException)
+ catch (System.Security.SecurityException)
{
// This security exception will occur if the caller does not have
// some undefined set of SecurityPermission flags.
LogLog.Debug(declaringType, "Security exception while trying to get current thread principal. Error Ignored.");
- writer.Write( SystemInfo.NotAvailableText );
+ writer.Write(SystemInfo.NotAvailableText);
}
#endif
}
- #region Private Static Fields
+ #region Private Static Fields
- /// <summary>
- /// The fully qualified type of the IdentityPatternConverter class.
- /// </summary>
- /// <remarks>
- /// Used by the internal logger to record the Type of the
- /// log message.
- /// </remarks>
- private static readonly Type declaringType = typeof(IdentityPatternConverter);
+ /// <summary>
+ /// The fully qualified type of the IdentityPatternConverter class.
+ /// </summary>
+ /// <remarks>
+ /// Used by the internal logger to record the Type of the
+ /// log message.
+ /// </remarks>
+ private static readonly Type declaringType = typeof(IdentityPatternConverter);
- #endregion Private Static Fields
+ #endregion Private Static Fields
}
}
diff --git a/src/log4net/Util/PatternStringConverters/LiteralPatternConverter.cs b/src/log4net/Util/PatternStringConverters/LiteralPatternConverter.cs
index bcdf7e4..c1adfb9 100644
--- a/src/log4net/Util/PatternStringConverters/LiteralPatternConverter.cs
+++ b/src/log4net/Util/PatternStringConverters/LiteralPatternConverter.cs
@@ -36,7 +36,7 @@
/// </para>
/// </remarks>
/// <author>Nicko Cadell</author>
- internal class LiteralPatternConverter : PatternConverter
+ internal class LiteralPatternConverter : PatternConverter
{
/// <summary>
/// Set the next converter in the chain
@@ -84,7 +84,7 @@
/// to the output <paramref name="writer"/>.
/// </para>
/// </remarks>
- public override void Format(TextWriter writer, object state)
+ public override void Format(TextWriter writer, object state)
{
writer.Write(Option);
}
@@ -99,7 +99,7 @@
/// This method is not used.
/// </para>
/// </remarks>
- protected override void Convert(TextWriter writer, object state)
+ protected override void Convert(TextWriter writer, object state)
{
throw new InvalidOperationException("Should never get here because of the overridden Format method");
}
diff --git a/src/log4net/Util/PatternStringConverters/ProcessIdPatternConverter.cs b/src/log4net/Util/PatternStringConverters/ProcessIdPatternConverter.cs
index d4e197e..55dbeeb 100644
--- a/src/log4net/Util/PatternStringConverters/ProcessIdPatternConverter.cs
+++ b/src/log4net/Util/PatternStringConverters/ProcessIdPatternConverter.cs
@@ -31,7 +31,7 @@
/// </para>
/// </remarks>
/// <author>Nicko Cadell</author>
- internal sealed class ProcessIdPatternConverter : PatternConverter
+ internal sealed class ProcessIdPatternConverter : PatternConverter
{
/// <summary>
/// Write the current process ID to the output
@@ -46,7 +46,7 @@
#if NET_4_0 || MONO_4_0 || NETSTANDARD
[System.Security.SecuritySafeCritical]
#endif
- protected override void Convert(TextWriter writer, object state)
+ protected override void Convert(TextWriter writer, object state)
{
#if (NETCF || SSCLI)
// On compact framework there is no System.Diagnostics.Process class
@@ -54,30 +54,30 @@
#else
try
{
- writer.Write( System.Diagnostics.Process.GetCurrentProcess().Id );
+ writer.Write(System.Diagnostics.Process.GetCurrentProcess().Id);
}
- catch(System.Security.SecurityException)
+ catch (System.Security.SecurityException)
{
// This security exception will occur if the caller does not have
// some undefined set of SecurityPermission flags.
LogLog.Debug(declaringType, "Security exception while trying to get current process id. Error Ignored.");
- writer.Write( SystemInfo.NotAvailableText );
+ writer.Write(SystemInfo.NotAvailableText);
}
#endif
}
- #region Private Static Fields
+ #region Private Static Fields
- /// <summary>
- /// The fully qualified type of the ProcessIdPatternConverter class.
- /// </summary>
- /// <remarks>
- /// Used by the internal logger to record the Type of the
- /// log message.
- /// </remarks>
- private static readonly Type declaringType = typeof(ProcessIdPatternConverter);
+ /// <summary>
+ /// The fully qualified type of the ProcessIdPatternConverter class.
+ /// </summary>
+ /// <remarks>
+ /// Used by the internal logger to record the Type of the
+ /// log message.
+ /// </remarks>
+ private static readonly Type declaringType = typeof(ProcessIdPatternConverter);
- #endregion Private Static Fields
+ #endregion Private Static Fields
}
}
diff --git a/src/log4net/Util/PatternStringConverters/PropertyPatternConverter.cs b/src/log4net/Util/PatternStringConverters/PropertyPatternConverter.cs
index 76f4239..9955116 100644
--- a/src/log4net/Util/PatternStringConverters/PropertyPatternConverter.cs
+++ b/src/log4net/Util/PatternStringConverters/PropertyPatternConverter.cs
@@ -39,7 +39,7 @@
/// </para>
/// </remarks>
/// <author>Nicko Cadell</author>
- internal sealed class PropertyPatternConverter : PatternConverter
+ internal sealed class PropertyPatternConverter : PatternConverter
{
/// <summary>
/// Write the property value to the output
@@ -57,7 +57,7 @@
/// then all the properties are written as key value pairs.
/// </para>
/// </remarks>
- protected override void Convert(TextWriter writer, object state)
+ protected override void Convert(TextWriter writer, object state)
{
CompositeProperties compositeProperties = new CompositeProperties();
diff --git a/src/log4net/Util/PatternStringConverters/RandomStringPatternConverter.cs b/src/log4net/Util/PatternStringConverters/RandomStringPatternConverter.cs
index 8b11c45..0502dfc 100644
--- a/src/log4net/Util/PatternStringConverters/RandomStringPatternConverter.cs
+++ b/src/log4net/Util/PatternStringConverters/RandomStringPatternConverter.cs
@@ -87,8 +87,8 @@
}
else
{
- LogLog.Error(declaringType, "RandomStringPatternConverter: Could not convert Option ["+optionStr+"] to Length Int32");
- }
+ LogLog.Error(declaringType, "RandomStringPatternConverter: Could not convert Option [" + optionStr + "] to Length Int32");
+ }
}
}
@@ -104,13 +104,13 @@
/// Write a randoim string to the output <paramref name="writer"/>.
/// </para>
/// </remarks>
- protected override void Convert(TextWriter writer, object state)
+ protected override void Convert(TextWriter writer, object state)
{
- try
+ try
{
- lock(s_random)
+ lock (s_random)
{
- for(int i=0; i<m_length; i++)
+ for (int i = 0; i < m_length; i++)
{
int randValue = s_random.Next(36);
@@ -134,23 +134,23 @@
}
}
}
- catch (Exception ex)
+ catch (Exception ex)
{
LogLog.Error(declaringType, "Error occurred while converting.", ex);
}
}
- #region Private Static Fields
+ #region Private Static Fields
- /// <summary>
- /// The fully qualified type of the RandomStringPatternConverter class.
- /// </summary>
- /// <remarks>
- /// Used by the internal logger to record the Type of the
- /// log message.
- /// </remarks>
- private static readonly Type declaringType = typeof(RandomStringPatternConverter);
+ /// <summary>
+ /// The fully qualified type of the RandomStringPatternConverter class.
+ /// </summary>
+ /// <remarks>
+ /// Used by the internal logger to record the Type of the
+ /// log message.
+ /// </remarks>
+ private static readonly Type declaringType = typeof(RandomStringPatternConverter);
- #endregion Private Static Fields
+ #endregion Private Static Fields
}
}
diff --git a/src/log4net/Util/PatternStringConverters/UserNamePatternConverter.cs b/src/log4net/Util/PatternStringConverters/UserNamePatternConverter.cs
index 896e51d..a0f4789 100644
--- a/src/log4net/Util/PatternStringConverters/UserNamePatternConverter.cs
+++ b/src/log4net/Util/PatternStringConverters/UserNamePatternConverter.cs
@@ -31,7 +31,7 @@
/// </para>
/// </remarks>
/// <author>Nicko Cadell</author>
- internal sealed class UserNamePatternConverter : PatternConverter
+ internal sealed class UserNamePatternConverter : PatternConverter
{
/// <summary>
/// Write the current threads username to the output
@@ -43,7 +43,7 @@
/// Write the current threads username to the output <paramref name="writer"/>.
/// </para>
/// </remarks>
- protected override void Convert(TextWriter writer, object state)
+ protected override void Convert(TextWriter writer, object state)
{
#if (NETCF || SSCLI || NETSTANDARD1_3)
// On compact framework there's no notion of current Windows user
@@ -55,31 +55,31 @@
windowsIdentity = System.Security.Principal.WindowsIdentity.GetCurrent();
if (windowsIdentity != null && windowsIdentity.Name != null)
{
- writer.Write( windowsIdentity.Name );
+ writer.Write(windowsIdentity.Name);
}
}
- catch(System.Security.SecurityException)
+ catch (System.Security.SecurityException)
{
// This security exception will occur if the caller does not have
// some undefined set of SecurityPermission flags.
LogLog.Debug(declaringType, "Security exception while trying to get current windows identity. Error Ignored.");
- writer.Write( SystemInfo.NotAvailableText );
+ writer.Write(SystemInfo.NotAvailableText);
}
#endif
}
- #region Private Static Fields
+ #region Private Static Fields
- /// <summary>
- /// The fully qualified type of the UserNamePatternConverter class.
- /// </summary>
- /// <remarks>
- /// Used by the internal logger to record the Type of the
- /// log message.
- /// </remarks>
- private static readonly Type declaringType = typeof(UserNamePatternConverter);
+ /// <summary>
+ /// The fully qualified type of the UserNamePatternConverter class.
+ /// </summary>
+ /// <remarks>
+ /// Used by the internal logger to record the Type of the
+ /// log message.
+ /// </remarks>
+ private static readonly Type declaringType = typeof(UserNamePatternConverter);
- #endregion Private Static Fields
+ #endregion Private Static Fields
}
}
diff --git a/src/log4net/Util/PatternStringConverters/UtcDatePatternConverter.cs b/src/log4net/Util/PatternStringConverters/UtcDatePatternConverter.cs
index 6c59484..3a04450 100644
--- a/src/log4net/Util/PatternStringConverters/UtcDatePatternConverter.cs
+++ b/src/log4net/Util/PatternStringConverters/UtcDatePatternConverter.cs
@@ -60,27 +60,27 @@
/// <seealso cref="DatePatternConverter"/>
protected override void Convert(TextWriter writer, object state)
{
- try
+ try
{
m_dateFormatter.FormatDate(DateTime.UtcNow, writer);
}
- catch (Exception ex)
+ catch (Exception ex)
{
LogLog.Error(declaringType, "Error occurred while converting date.", ex);
}
}
- #region Private Static Fields
+ #region Private Static Fields
- /// <summary>
- /// The fully qualified type of the UtcDatePatternConverter class.
- /// </summary>
- /// <remarks>
- /// Used by the internal logger to record the Type of the
- /// log message.
- /// </remarks>
- private static readonly Type declaringType = typeof(UtcDatePatternConverter);
+ /// <summary>
+ /// The fully qualified type of the UtcDatePatternConverter class.
+ /// </summary>
+ /// <remarks>
+ /// Used by the internal logger to record the Type of the
+ /// log message.
+ /// </remarks>
+ private static readonly Type declaringType = typeof(UtcDatePatternConverter);
- #endregion Private Static Fields
+ #endregion Private Static Fields
}
}
diff --git a/src/log4net/Util/PropertiesDictionary.cs b/src/log4net/Util/PropertiesDictionary.cs
index ce72e98..6a37b60 100644
--- a/src/log4net/Util/PropertiesDictionary.cs
+++ b/src/log4net/Util/PropertiesDictionary.cs
@@ -35,7 +35,7 @@
/// </remarks>
/// <author>Nicko Cadell</author>
/// <author>Gert Driesen</author>
-#if NETCF
+#if NETCF
public sealed class PropertiesDictionary : ReadOnlyPropertiesDictionary, IDictionary
#else
[Serializable]
diff --git a/src/log4net/Util/PropertyEntry.cs b/src/log4net/Util/PropertyEntry.cs
index 3357d98..379a285 100644
--- a/src/log4net/Util/PropertyEntry.cs
+++ b/src/log4net/Util/PropertyEntry.cs
@@ -21,60 +21,60 @@
namespace log4net.Util
{
+ /// <summary>
+ /// A class to hold the key and data for a property set in the config file
+ /// </summary>
+ /// <remarks>
+ /// <para>
+ /// A class to hold the key and data for a property set in the config file
+ /// </para>
+ /// </remarks>
+ public class PropertyEntry
+ {
+ private string m_key = null;
+ private object m_value = null;
+
/// <summary>
- /// A class to hold the key and data for a property set in the config file
+ /// Property Key
/// </summary>
+ /// <value>
+ /// Property Key
+ /// </value>
/// <remarks>
/// <para>
- /// A class to hold the key and data for a property set in the config file
+ /// Property Key.
/// </para>
/// </remarks>
- public class PropertyEntry
+ public string Key
{
- private string m_key = null;
- private object m_value = null;
-
- /// <summary>
- /// Property Key
- /// </summary>
- /// <value>
- /// Property Key
- /// </value>
- /// <remarks>
- /// <para>
- /// Property Key.
- /// </para>
- /// </remarks>
- public string Key
- {
- get { return m_key; }
- set { m_key = value; }
- }
-
- /// <summary>
- /// Property Value
- /// </summary>
- /// <value>
- /// Property Value
- /// </value>
- /// <remarks>
- /// <para>
- /// Property Value.
- /// </para>
- /// </remarks>
- public object Value
- {
- get { return m_value; }
- set { m_value = value; }
- }
-
- /// <summary>
- /// Override <c>Object.ToString</c> to return sensible debug info
- /// </summary>
- /// <returns>string info about this object</returns>
- public override string ToString()
- {
- return "PropertyEntry(Key=" + m_key + ", Value=" + m_value + ")";
- }
+ get { return m_key; }
+ set { m_key = value; }
}
+
+ /// <summary>
+ /// Property Value
+ /// </summary>
+ /// <value>
+ /// Property Value
+ /// </value>
+ /// <remarks>
+ /// <para>
+ /// Property Value.
+ /// </para>
+ /// </remarks>
+ public object Value
+ {
+ get { return m_value; }
+ set { m_value = value; }
+ }
+
+ /// <summary>
+ /// Override <c>Object.ToString</c> to return sensible debug info
+ /// </summary>
+ /// <returns>string info about this object</returns>
+ public override string ToString()
+ {
+ return "PropertyEntry(Key=" + m_key + ", Value=" + m_value + ")";
+ }
+ }
}
diff --git a/src/log4net/Util/QuietTextWriter.cs b/src/log4net/Util/QuietTextWriter.cs
index f74c9c0..884ce4b 100644
--- a/src/log4net/Util/QuietTextWriter.cs
+++ b/src/log4net/Util/QuietTextWriter.cs
@@ -85,7 +85,7 @@
}
m_errorHandler = value;
}
- }
+ }
/// <summary>
/// Gets a value indicating whether this writer is closed.
@@ -116,18 +116,18 @@
/// Writes a character to the underlying writer
/// </para>
/// </remarks>
- public override void Write(char value)
+ public override void Write(char value)
{
- try
+ try
{
base.Write(value);
- }
- catch(Exception e)
+ }
+ catch (Exception e)
{
m_errorHandler.Error("Failed to write [" + value + "].", e, ErrorCode.WriteFailure);
}
}
-
+
/// <summary>
/// Writes a buffer to the underlying writer
/// </summary>
@@ -139,18 +139,18 @@
/// Writes a buffer to the underlying writer
/// </para>
/// </remarks>
- public override void Write(char[] buffer, int index, int count)
+ public override void Write(char[] buffer, int index, int count)
{
- try
+ try
{
base.Write(buffer, index, count);
- }
- catch(Exception e)
+ }
+ catch (Exception e)
{
m_errorHandler.Error("Failed to write buffer.", e, ErrorCode.WriteFailure);
}
}
-
+
/// <summary>
/// Writes a string to the output.
/// </summary>
@@ -160,13 +160,13 @@
/// Writes a string to the output.
/// </para>
/// </remarks>
- public override void Write(string value)
+ public override void Write(string value)
{
- try
+ try
{
base.Write(value);
- }
- catch(Exception e)
+ }
+ catch (Exception e)
{
m_errorHandler.Error("Failed to write [" + value + "].", e, ErrorCode.WriteFailure);
}
diff --git a/src/log4net/Util/ReadOnlyPropertiesDictionary.cs b/src/log4net/Util/ReadOnlyPropertiesDictionary.cs
index 632ce8c..c59be90 100644
--- a/src/log4net/Util/ReadOnlyPropertiesDictionary.cs
+++ b/src/log4net/Util/ReadOnlyPropertiesDictionary.cs
@@ -45,7 +45,8 @@
#if NETCF
public class ReadOnlyPropertiesDictionary : IDictionary
#else
- [Serializable] public class ReadOnlyPropertiesDictionary : ISerializable, IDictionary
+ [Serializable]
+ public class ReadOnlyPropertiesDictionary : ISerializable, IDictionary
#endif
{
#region Private Instance Fields
@@ -82,7 +83,7 @@
/// </remarks>
public ReadOnlyPropertiesDictionary(ReadOnlyPropertiesDictionary propertiesDictionary)
{
- foreach(DictionaryEntry entry in propertiesDictionary)
+ foreach (DictionaryEntry entry in propertiesDictionary)
{
InnerHashtable.Add(entry.Key, entry.Value);
}
@@ -106,7 +107,7 @@
/// </remarks>
protected ReadOnlyPropertiesDictionary(SerializationInfo info, StreamingContext context)
{
- foreach(var entry in info)
+ foreach (var entry in info)
{
// The keys are stored as Xml encoded names
InnerHashtable[XmlConvert.DecodeName(entry.Name)] = entry.Value;
@@ -210,9 +211,9 @@
#if !NETCF && !NETSTANDARD1_3
[System.Security.Permissions.SecurityPermission(System.Security.Permissions.SecurityAction.Demand, SerializationFormatter = true)]
#endif
- public virtual void GetObjectData(SerializationInfo info, StreamingContext context)
+ public virtual void GetObjectData(SerializationInfo info, StreamingContext context)
{
- foreach(DictionaryEntry entry in InnerHashtable.Clone() as IDictionary)
+ foreach (DictionaryEntry entry in InnerHashtable.Clone() as IDictionary)
{
var entryKey = entry.Key as string;
if (entryKey is null)
@@ -222,11 +223,11 @@
var entryValue = entry.Value;
- // If value is serializable then we add it to the list
+ // If value is serializable then we add it to the list
#if NETSTANDARD1_3
var isSerializable = entryValue?.GetType().GetTypeInfo().IsSerializable ?? false;
#else
- var isSerializable = entryValue?.GetType().IsSerializable ?? false;
+ var isSerializable = entryValue?.GetType().IsSerializable ?? false;
#endif
if (!isSerializable)
{
diff --git a/src/log4net/Util/ReaderWriterLock.cs b/src/log4net/Util/ReaderWriterLock.cs
index 7654d39..abac458 100644
--- a/src/log4net/Util/ReaderWriterLock.cs
+++ b/src/log4net/Util/ReaderWriterLock.cs
@@ -72,7 +72,7 @@
}
#endregion Private Instance Constructors
-
+
#region Public Methods
/// <summary>
diff --git a/src/log4net/Util/ReusableStringWriter.cs b/src/log4net/Util/ReusableStringWriter.cs
index 3a7edee..f335e2c 100644
--- a/src/log4net/Util/ReusableStringWriter.cs
+++ b/src/log4net/Util/ReusableStringWriter.cs
@@ -46,7 +46,7 @@
/// Create an instance of <see cref="ReusableStringWriter"/>
/// </para>
/// </remarks>
- public ReusableStringWriter(IFormatProvider formatProvider) : base(formatProvider)
+ public ReusableStringWriter(IFormatProvider formatProvider) : base(formatProvider)
{
}
@@ -83,12 +83,12 @@
StringBuilder sb = this.GetStringBuilder();
sb.Length = 0;
-
+
// Check if over max size
- if (sb.Capacity > maxCapacity)
+ if (sb.Capacity > maxCapacity)
{
sb.Capacity = defaultSize;
- }
+ }
}
}
}
diff --git a/src/log4net/Util/SystemStringFormat.cs b/src/log4net/Util/SystemStringFormat.cs
index 9b558f3..0d75e89 100644
--- a/src/log4net/Util/SystemStringFormat.cs
+++ b/src/log4net/Util/SystemStringFormat.cs
@@ -112,9 +112,9 @@
// Try to format the string
return String.Format(provider, format, args);
}
- catch(Exception ex)
+ catch (Exception ex)
{
- log4net.Util.LogLog.Warn(declaringType, "Exception while rendering format ["+format+"]", ex);
+ log4net.Util.LogLog.Warn(declaringType, "Exception while rendering format [" + format + "]", ex);
return StringFormatError(ex, format, args);
}
#if !NET_2_0 && !MONO_2_0 && !MONO_3_5 && !MONO_4_0 && !NETSTANDARD
@@ -151,7 +151,7 @@
return buf.ToString();
}
- catch(Exception ex)
+ catch (Exception ex)
{
log4net.Util.LogLog.Error(declaringType, "INTERNAL ERROR during StringFormat error handling", ex);
return "<log4net.Error>Exception during StringFormat. See Internal Log.</log4net.Error>";
@@ -214,7 +214,7 @@
{
buffer.Append(obj);
}
- catch(Exception ex)
+ catch (Exception ex)
{
buffer.Append("<Exception: ").Append(ex.Message).Append(">");
}
@@ -229,17 +229,17 @@
#endregion StringFormat
- #region Private Static Fields
+ #region Private Static Fields
- /// <summary>
- /// The fully qualified type of the SystemStringFormat class.
- /// </summary>
- /// <remarks>
- /// Used by the internal logger to record the Type of the
- /// log message.
- /// </remarks>
- private static readonly Type declaringType = typeof(SystemStringFormat);
+ /// <summary>
+ /// The fully qualified type of the SystemStringFormat class.
+ /// </summary>
+ /// <remarks>
+ /// Used by the internal logger to record the Type of the
+ /// log message.
+ /// </remarks>
+ private static readonly Type declaringType = typeof(SystemStringFormat);
- #endregion Private Static Fields
+ #endregion Private Static Fields
}
}
diff --git a/src/log4net/Util/TextWriterAdapter.cs b/src/log4net/Util/TextWriterAdapter.cs
index e130e58..24304f0 100644
--- a/src/log4net/Util/TextWriterAdapter.cs
+++ b/src/log4net/Util/TextWriterAdapter.cs
@@ -59,7 +59,7 @@
/// messages to a <see cref="TextWriter"/>.
/// </para>
/// </remarks>
- protected TextWriterAdapter(TextWriter writer) : base(CultureInfo.InvariantCulture)
+ protected TextWriterAdapter(TextWriter writer) : base(CultureInfo.InvariantCulture)
{
m_writer = writer;
}
@@ -79,7 +79,7 @@
/// Gets or sets the underlying <see cref="TextWriter" />.
/// </para>
/// </remarks>
- protected TextWriter Writer
+ protected TextWriter Writer
{
get { return m_writer; }
set { m_writer = value; }
@@ -88,7 +88,7 @@
#endregion Protected Instance Properties
#region Public Properties
-
+
/// <summary>
/// The Encoding in which the output is written
/// </summary>
@@ -100,7 +100,7 @@
/// The Encoding in which the output is written
/// </para>
/// </remarks>
- public override Encoding Encoding
+ public override Encoding Encoding
{
get { return m_writer.Encoding; }
}
@@ -116,7 +116,7 @@
/// Gets an object that controls formatting
/// </para>
/// </remarks>
- public override IFormatProvider FormatProvider
+ public override IFormatProvider FormatProvider
{
get { return m_writer.FormatProvider; }
}
@@ -132,7 +132,7 @@
/// Gets or sets the line terminator string used by the TextWriter
/// </para>
/// </remarks>
- public override String NewLine
+ public override String NewLine
{
get { return m_writer.NewLine; }
set { m_writer.NewLine = value; }
@@ -154,7 +154,7 @@
#else
virtual
#endif
- public void Close()
+ public void Close()
{
m_writer.Close();
}
@@ -185,7 +185,7 @@
/// to the underlying device
/// </para>
/// </remarks>
- public override void Flush()
+ public override void Flush()
{
m_writer.Flush();
}
@@ -199,11 +199,11 @@
/// Writes a character to the wrapped TextWriter
/// </para>
/// </remarks>
- public override void Write(char value)
+ public override void Write(char value)
{
m_writer.Write(value);
}
-
+
/// <summary>
/// Writes a character buffer to the wrapped TextWriter
/// </summary>
@@ -215,11 +215,11 @@
/// Writes a character buffer to the wrapped TextWriter
/// </para>
/// </remarks>
- public override void Write(char[] buffer, int index, int count)
+ public override void Write(char[] buffer, int index, int count)
{
m_writer.Write(buffer, index, count);
}
-
+
/// <summary>
/// Writes a string to the wrapped TextWriter
/// </summary>
@@ -229,7 +229,7 @@
/// Writes a string to the wrapped TextWriter
/// </para>
/// </remarks>
- public override void Write(String value)
+ public override void Write(String value)
{
m_writer.Write(value);
}
diff --git a/src/log4net/Util/ThreadContextProperties.cs b/src/log4net/Util/ThreadContextProperties.cs
index a35697b..0fbeef6 100644
--- a/src/log4net/Util/ThreadContextProperties.cs
+++ b/src/log4net/Util/ThreadContextProperties.cs
@@ -186,7 +186,7 @@
#endif
if (_dictionary == null && create)
{
- _dictionary = new PropertiesDictionary();
+ _dictionary = new PropertiesDictionary();
#if NETCF
System.Threading.Thread.SetData(s_threadLocalSlot, _dictionary);
#endif
diff --git a/src/log4net/Util/ThreadContextStack.cs b/src/log4net/Util/ThreadContextStack.cs
index 2d51b81..37ed907 100644
--- a/src/log4net/Util/ThreadContextStack.cs
+++ b/src/log4net/Util/ThreadContextStack.cs
@@ -102,7 +102,7 @@
/// syntax.
/// </para>
/// </remarks>
- public void Clear()
+ public void Clear()
{
m_stack.Clear();
}
@@ -118,7 +118,7 @@
/// empty string (not <see langword="null"/>) is returned.
/// </para>
/// </remarks>
- public string Pop()
+ public string Pop()
{
Stack stack = m_stack;
if (stack.Count > 0)
@@ -151,10 +151,10 @@
/// }
/// </code>
/// </example>
- public IDisposable Push(string message)
+ public IDisposable Push(string message)
{
Stack stack = m_stack;
- stack.Push(new StackFrame(message, (stack.Count>0) ? (StackFrame)stack.Peek() : null));
+ stack.Push(new StackFrame(message, (stack.Count > 0) ? (StackFrame)stack.Peek() : null));
return new AutoPopStackFrame(stack, stack.Count - 1);
}
@@ -187,7 +187,7 @@
/// Gets the current context information for this stack.
/// </summary>
/// <returns>The current context information.</returns>
- internal string GetFullMessage()
+ internal string GetFullMessage()
{
Stack stack = m_stack;
if (stack.Count > 0)
@@ -213,7 +213,7 @@
get { return m_stack; }
set { m_stack = value; }
}
-
+
#endregion Internal Methods
/// <summary>
@@ -252,14 +252,14 @@
/// Inner class used to represent a single context frame in the stack.
/// </para>
/// </remarks>
- private sealed class StackFrame
+ private sealed class StackFrame
{
#region Private Instance Fields
private readonly string m_message;
private readonly StackFrame m_parent;
private string m_fullMessage = null;
-
+
#endregion
#region Internal Instance Constructors
@@ -275,15 +275,15 @@
/// with the specified message and parent context.
/// </para>
/// </remarks>
- internal StackFrame(string message, StackFrame parent)
+ internal StackFrame(string message, StackFrame parent)
{
m_message = message;
m_parent = parent;
- if (parent == null)
+ if (parent == null)
{
m_fullMessage = message;
- }
+ }
}
#endregion Internal Instance Constructors
@@ -317,13 +317,13 @@
/// </remarks>
internal string FullMessage
{
- get
+ get
{
if (m_fullMessage == null && m_parent != null)
{
m_fullMessage = string.Concat(m_parent.FullMessage, " ", m_message);
}
- return m_fullMessage;
+ return m_fullMessage;
}
}
@@ -390,7 +390,7 @@
{
if (m_frameDepth >= 0 && m_frameStack != null)
{
- while(m_frameStack.Count > m_frameDepth)
+ while (m_frameStack.Count > m_frameDepth)
{
m_frameStack.Pop();
}
diff --git a/src/log4net/Util/ThreadContextStacks.cs b/src/log4net/Util/ThreadContextStacks.cs
index 20219da..6997636 100644
--- a/src/log4net/Util/ThreadContextStacks.cs
+++ b/src/log4net/Util/ThreadContextStacks.cs
@@ -67,7 +67,7 @@
/// </remarks>
public ThreadContextStack this[string key]
{
- get
+ get
{
ThreadContextStack stack = null;
@@ -95,7 +95,7 @@
{
}
- LogLog.Error(declaringType, "ThreadContextStacks: Request for stack named ["+key+"] failed because a property with the same name exists which is a ["+propertyValue.GetType().Name+"] with value ["+propertyValueString+"]");
+ LogLog.Error(declaringType, "ThreadContextStacks: Request for stack named [" + key + "] failed because a property with the same name exists which is a [" + propertyValue.GetType().Name + "] with value [" + propertyValueString + "]");
stack = new ThreadContextStack();
}
@@ -107,18 +107,18 @@
#endregion Public Instance Properties
- #region Private Static Fields
+ #region Private Static Fields
- /// <summary>
- /// The fully qualified type of the ThreadContextStacks class.
- /// </summary>
- /// <remarks>
- /// Used by the internal logger to record the Type of the
- /// log message.
- /// </remarks>
- private static readonly Type declaringType = typeof(ThreadContextStacks);
+ /// <summary>
+ /// The fully qualified type of the ThreadContextStacks class.
+ /// </summary>
+ /// <remarks>
+ /// Used by the internal logger to record the Type of the
+ /// log message.
+ /// </remarks>
+ private static readonly Type declaringType = typeof(ThreadContextStacks);
- #endregion Private Static Fields
+ #endregion Private Static Fields
}
}
diff --git a/src/log4net/Util/Transform.cs b/src/log4net/Util/Transform.cs
index 1689b34..662720c 100644
--- a/src/log4net/Util/Transform.cs
+++ b/src/log4net/Util/Transform.cs
@@ -72,7 +72,7 @@
// Write either escaped text or CDATA sections
int weightCData = 12 * (1 + CountSubstrings(stringData, CDATA_END));
- int weightStringEscapes = 3*(CountSubstrings(stringData, "<") + CountSubstrings(stringData, ">")) + 4*CountSubstrings(stringData, "&");
+ int weightStringEscapes = 3 * (CountSubstrings(stringData, "<") + CountSubstrings(stringData, ">")) + 4 * CountSubstrings(stringData, "&");
if (weightStringEscapes <= weightCData)
{
@@ -84,15 +84,15 @@
// Write string using CDATA section
int end = stringData.IndexOf(CDATA_END);
-
- if (end < 0)
+
+ if (end < 0)
{
writer.WriteCData(stringData);
}
else
{
int start = 0;
- while (end > -1)
+ while (end > -1)
{
writer.WriteCData(stringData.Substring(start, end - start));
if (end == stringData.Length - 3)
@@ -108,7 +108,7 @@
end = stringData.IndexOf(CDATA_END, start);
}
}
-
+
if (start < stringData.Length)
{
writer.WriteCData(stringData.Substring(start));
@@ -169,7 +169,7 @@
return 0;
}
- while(offset < length)
+ while (offset < length)
{
int index = text.IndexOf(substring, offset);
@@ -188,13 +188,13 @@
#region Private Static Fields
- private const string CDATA_END = "]]>";
- private const string CDATA_UNESCAPABLE_TOKEN = "]]";
+ private const string CDATA_END = "]]>";
+ private const string CDATA_UNESCAPABLE_TOKEN = "]]";
- /// <summary>
- /// Characters illegal in XML 1.0
- /// </summary>
- private static Regex INVALIDCHARS=new Regex(@"[^\x09\x0A\x0D\x20-\uD7FF\uE000-\uFFFD]",RegexOptions.Compiled);
+ /// <summary>
+ /// Characters illegal in XML 1.0
+ /// </summary>
+ private static Regex INVALIDCHARS = new Regex(@"[^\x09\x0A\x0D\x20-\uD7FF\uE000-\uFFFD]", RegexOptions.Compiled);
#endregion Private Static Fields
}
}
diff --git a/src/log4net/Util/TypeConverters/BooleanConverter.cs b/src/log4net/Util/TypeConverters/BooleanConverter.cs
index 7ca6496..ca50001 100644
--- a/src/log4net/Util/TypeConverters/BooleanConverter.cs
+++ b/src/log4net/Util/TypeConverters/BooleanConverter.cs
@@ -65,11 +65,11 @@
/// <see cref="String"/> argument to a <see cref="Boolean"/>.
/// </para>
/// </remarks>
- /// <exception cref="ConversionNotSupportedException">
- /// The <paramref name="source"/> object cannot be converted to the
- /// target type. To check for this condition use the <see cref="CanConvertFrom"/>
- /// method.
- /// </exception>
+ /// <exception cref="ConversionNotSupportedException">
+ /// The <paramref name="source"/> object cannot be converted to the
+ /// target type. To check for this condition use the <see cref="CanConvertFrom"/>
+ /// method.
+ /// </exception>
public object ConvertFrom(object source)
{
string str = source as string;
diff --git a/src/log4net/Util/TypeConverters/ConversionNotSupportedException.cs b/src/log4net/Util/TypeConverters/ConversionNotSupportedException.cs
index ea59d98..61bd750 100644
--- a/src/log4net/Util/TypeConverters/ConversionNotSupportedException.cs
+++ b/src/log4net/Util/TypeConverters/ConversionNotSupportedException.cs
@@ -42,7 +42,7 @@
#if NETSTANDARD1_3
public class ConversionNotSupportedException : Exception
#else
- public class ConversionNotSupportedException : ApplicationException
+ public class ConversionNotSupportedException : ApplicationException
#endif
{
#region Public Instance Constructors
@@ -69,10 +69,10 @@
/// with the specified message.
/// </para>
/// </remarks>
- public ConversionNotSupportedException(String message) : base(message)
+ public ConversionNotSupportedException(String message) : base(message)
{
}
-
+
/// <summary>
/// Constructor
/// </summary>
@@ -84,7 +84,7 @@
/// with the specified message and inner exception.
/// </para>
/// </remarks>
- public ConversionNotSupportedException(String message, Exception innerException) : base(message, innerException)
+ public ConversionNotSupportedException(String message, Exception innerException) : base(message, innerException)
{
}
@@ -104,7 +104,7 @@
/// with serialized data.
/// </para>
/// </remarks>
- protected ConversionNotSupportedException(SerializationInfo info, StreamingContext context) : base(info, context)
+ protected ConversionNotSupportedException(SerializationInfo info, StreamingContext context) : base(info, context)
{
}
#endif
@@ -145,11 +145,11 @@
{
if (sourceValue == null)
{
- return new ConversionNotSupportedException("Cannot convert value [null] to type ["+destinationType+"]", innerException);
+ return new ConversionNotSupportedException("Cannot convert value [null] to type [" + destinationType + "]", innerException);
}
else
{
- return new ConversionNotSupportedException("Cannot convert from type ["+sourceValue.GetType()+"] value ["+sourceValue+"] to type ["+destinationType+"]", innerException);
+ return new ConversionNotSupportedException("Cannot convert from type [" + sourceValue.GetType() + "] value [" + sourceValue + "] to type [" + destinationType + "]", innerException);
}
}
diff --git a/src/log4net/Util/TypeConverters/ConverterRegistry.cs b/src/log4net/Util/TypeConverters/ConverterRegistry.cs
index bc0fa10..ec3e59b 100644
--- a/src/log4net/Util/TypeConverters/ConverterRegistry.cs
+++ b/src/log4net/Util/TypeConverters/ConverterRegistry.cs
@@ -54,7 +54,7 @@
/// <remarks>
/// Initializes a new instance of the <see cref="ConverterRegistry" /> class.
/// </remarks>
- private ConverterRegistry()
+ private ConverterRegistry()
{
}
@@ -99,7 +99,7 @@
{
if (destinationType != null && converter != null)
{
- lock(s_type2converter)
+ lock (s_type2converter)
{
s_type2converter[destinationType] = converter;
}
@@ -142,7 +142,7 @@
// TODO: Is destinationType required? We don't use it for anything.
- lock(s_type2converter)
+ lock (s_type2converter)
{
// Lookup in the static registry
IConvertTo converter = s_type2converter[sourceType] as IConvertTo;
@@ -181,7 +181,7 @@
// TODO: Support inheriting type converters.
// i.e. getting a type converter for a base of destinationType
- lock(s_type2converter)
+ lock (s_type2converter)
{
// Lookup in the static registry
IConvertFrom converter = s_type2converter[destinationType] as IConvertFrom;
@@ -201,7 +201,7 @@
return converter;
}
}
-
+
/// <summary>
/// Lookups the type converter to use as specified by the attributes on the
/// destination type.
@@ -269,14 +269,14 @@
// Create the type converter
return Activator.CreateInstance(converterType);
}
- catch(Exception ex)
+ catch (Exception ex)
{
- LogLog.Error(declaringType, "Cannot CreateConverterInstance of type ["+converterType.FullName+"], Exception in call to Activator.CreateInstance", ex);
+ LogLog.Error(declaringType, "Cannot CreateConverterInstance of type [" + converterType.FullName + "], Exception in call to Activator.CreateInstance", ex);
}
}
else
{
- LogLog.Error(declaringType, "Cannot CreateConverterInstance of type ["+converterType.FullName+"], type does not implement IConvertFrom or IConvertTo");
+ LogLog.Error(declaringType, "Cannot CreateConverterInstance of type [" + converterType.FullName + "], type does not implement IConvertFrom or IConvertTo");
}
return null;
}
@@ -285,14 +285,14 @@
#region Private Static Fields
- /// <summary>
- /// The fully qualified type of the ConverterRegistry class.
- /// </summary>
- /// <remarks>
- /// Used by the internal logger to record the Type of the
- /// log message.
- /// </remarks>
- private static readonly Type declaringType = typeof(ConverterRegistry);
+ /// <summary>
+ /// The fully qualified type of the ConverterRegistry class.
+ /// </summary>
+ /// <remarks>
+ /// Used by the internal logger to record the Type of the
+ /// log message.
+ /// </remarks>
+ private static readonly Type declaringType = typeof(ConverterRegistry);
/// <summary>
/// Mapping from <see cref="Type" /> to type converter.
diff --git a/src/log4net/Util/TypeConverters/EncodingConverter.cs b/src/log4net/Util/TypeConverters/EncodingConverter.cs
index 27dd4bb..45d5438 100644
--- a/src/log4net/Util/TypeConverters/EncodingConverter.cs
+++ b/src/log4net/Util/TypeConverters/EncodingConverter.cs
@@ -35,7 +35,7 @@
/// <seealso cref="IConvertTo"/>
/// <author>Nicko Cadell</author>
/// <author>Gert Driesen</author>
- internal class EncodingConverter : IConvertFrom
+ internal class EncodingConverter : IConvertFrom
{
#region Implementation of IConvertFrom
@@ -50,7 +50,7 @@
/// the <see cref="String"/> type.
/// </para>
/// </remarks>
- public bool CanConvertFrom(Type sourceType)
+ public bool CanConvertFrom(Type sourceType)
{
return (sourceType == typeof(string));
}
@@ -71,10 +71,10 @@
/// target type. To check for this condition use the <see cref="CanConvertFrom"/>
/// method.
/// </exception>
- public object ConvertFrom(object source)
+ public object ConvertFrom(object source)
{
string str = source as string;
- if (str != null)
+ if (str != null)
{
return Encoding.GetEncoding(str);
}
diff --git a/src/log4net/Util/TypeConverters/IPAddressConverter.cs b/src/log4net/Util/TypeConverters/IPAddressConverter.cs
index 2c133a4..60c7bf6 100644
--- a/src/log4net/Util/TypeConverters/IPAddressConverter.cs
+++ b/src/log4net/Util/TypeConverters/IPAddressConverter.cs
@@ -33,7 +33,7 @@
/// <seealso cref="ConverterRegistry"/>
/// <seealso cref="IConvertFrom"/>
/// <author>Nicko Cadell</author>
- internal class IPAddressConverter : IConvertFrom
+ internal class IPAddressConverter : IConvertFrom
{
#region Implementation of IConvertFrom
@@ -48,7 +48,7 @@
/// the <see cref="String"/> type.
/// </para>
/// </remarks>
- public bool CanConvertFrom(Type sourceType)
+ public bool CanConvertFrom(Type sourceType)
{
return (sourceType == typeof(string));
}
@@ -70,10 +70,10 @@
/// target type. To check for this condition use the <see cref="CanConvertFrom"/>
/// method.
/// </exception>
- public object ConvertFrom(object source)
+ public object ConvertFrom(object source)
{
string str = source as string;
- if (str != null && str.Length > 0)
+ if (str != null && str.Length > 0)
{
try
{
@@ -91,8 +91,8 @@
// Try to resolve via DNS. This is a blocking call.
// GetHostEntry works with either an IPAddress string or a host name
IPHostEntry host = Dns.GetHostEntry(str);
- if (host != null &&
- host.AddressList != null &&
+ if (host != null &&
+ host.AddressList != null &&
host.AddressList.Length > 0 &&
host.AddressList[0] != null)
{
@@ -130,7 +130,7 @@
}
#endif
}
- catch(Exception ex)
+ catch (Exception ex)
{
throw ConversionNotSupportedException.Create(typeof(IPAddress), source, ex);
}
@@ -143,6 +143,6 @@
/// <summary>
/// Valid characters in an IPv4 or IPv6 address string. (Does not support subnets)
/// </summary>
- private static readonly char[] validIpAddressChars = {'0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f','A','B','C','D','E','F','x','X','.',':','%'};
+ private static readonly char[] validIpAddressChars = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f', 'A', 'B', 'C', 'D', 'E', 'F', 'x', 'X', '.', ':', '%' };
}
}
diff --git a/src/log4net/Util/TypeConverters/PatternLayoutConverter.cs b/src/log4net/Util/TypeConverters/PatternLayoutConverter.cs
index a3f594c..4c342e8 100644
--- a/src/log4net/Util/TypeConverters/PatternLayoutConverter.cs
+++ b/src/log4net/Util/TypeConverters/PatternLayoutConverter.cs
@@ -77,7 +77,7 @@
/// target type. To check for this condition use the <see cref="CanConvertFrom"/>
/// method.
/// </exception>
- public object ConvertFrom(object source)
+ public object ConvertFrom(object source)
{
string str = source as string;
if (str != null)
diff --git a/src/log4net/Util/TypeConverters/PatternStringConverter.cs b/src/log4net/Util/TypeConverters/PatternStringConverter.cs
index c414b63..2352aa9 100644
--- a/src/log4net/Util/TypeConverters/PatternStringConverter.cs
+++ b/src/log4net/Util/TypeConverters/PatternStringConverter.cs
@@ -122,7 +122,7 @@
/// target type. To check for this condition use the <see cref="CanConvertFrom"/>
/// method.
/// </exception>
- public object ConvertFrom(object source)
+ public object ConvertFrom(object source)
{
string str = source as string;
if (str != null)
diff --git a/src/log4net/Util/TypeConverters/TypeConverter.cs b/src/log4net/Util/TypeConverters/TypeConverter.cs
index 606abf0..c5136e4 100644
--- a/src/log4net/Util/TypeConverters/TypeConverter.cs
+++ b/src/log4net/Util/TypeConverters/TypeConverter.cs
@@ -36,7 +36,7 @@
/// <seealso cref="IConvertFrom"/>
/// <seealso cref="IConvertTo"/>
/// <author>Nicko Cadell</author>
- internal class TypeConverter : IConvertFrom
+ internal class TypeConverter : IConvertFrom
{
#region Implementation of IConvertFrom
@@ -51,7 +51,7 @@
/// the <see cref="String"/> type.
/// </para>
/// </remarks>
- public bool CanConvertFrom(Type sourceType)
+ public bool CanConvertFrom(Type sourceType)
{
return (sourceType == typeof(string));
}
@@ -74,7 +74,7 @@
/// target type. To check for this condition use the <see cref="CanConvertFrom"/>
/// method.
/// </exception>
- public object ConvertFrom(object source)
+ public object ConvertFrom(object source)
{
string str = source as string;
if (str != null)
diff --git a/src/log4net/Util/TypeConverters/TypeConverterAttribute.cs b/src/log4net/Util/TypeConverters/TypeConverterAttribute.cs
index d7f40fa..137336a 100644
--- a/src/log4net/Util/TypeConverters/TypeConverterAttribute.cs
+++ b/src/log4net/Util/TypeConverters/TypeConverterAttribute.cs
@@ -37,7 +37,7 @@
/// </remarks>
/// <author>Nicko Cadell</author>
/// <author>Gert Driesen</author>
- [AttributeUsage(AttributeTargets.Class|AttributeTargets.Interface|AttributeTargets.Enum)]
+ [AttributeUsage(AttributeTargets.Class | AttributeTargets.Interface | AttributeTargets.Enum)]
public sealed class TypeConverterAttribute : Attribute
{
#region Member Variables
@@ -110,7 +110,7 @@
public string ConverterTypeName
{
get { return m_typeName; }
- set { m_typeName = value ; }
+ set { m_typeName = value; }
}
}
}
diff --git a/src/log4net/Util/WindowsSecurityContext.cs b/src/log4net/Util/WindowsSecurityContext.cs
index d58f47f..bed14bc 100644
--- a/src/log4net/Util/WindowsSecurityContext.cs
+++ b/src/log4net/Util/WindowsSecurityContext.cs
@@ -279,8 +279,8 @@
#if NET_4_0 || MONO_4_0
[System.Security.SecuritySafeCritical]
#endif
- [System.Security.Permissions.SecurityPermission(System.Security.Permissions.SecurityAction.Demand, UnmanagedCode = true)]
- private static WindowsIdentity LogonUser(string userName, string domainName, string password)
+ [System.Security.Permissions.SecurityPermission(System.Security.Permissions.SecurityAction.Demand, UnmanagedCode = true)]
+ private static WindowsIdentity LogonUser(string userName, string domainName, string password)
{
const int LOGON32_PROVIDER_DEFAULT = 0;
//This parameter causes LogonUser to create a primary token.
@@ -288,15 +288,15 @@
// Call LogonUser to obtain a handle to an access token.
IntPtr tokenHandle = IntPtr.Zero;
- if(!LogonUser(userName, domainName, password, LOGON32_LOGON_INTERACTIVE, LOGON32_PROVIDER_DEFAULT, ref tokenHandle))
+ if (!LogonUser(userName, domainName, password, LOGON32_LOGON_INTERACTIVE, LOGON32_PROVIDER_DEFAULT, ref tokenHandle))
{
NativeError error = NativeError.GetLastError();
- throw new Exception("Failed to LogonUser ["+userName+"] in Domain ["+domainName+"]. Error: "+ error.ToString());
+ throw new Exception("Failed to LogonUser [" + userName + "] in Domain [" + domainName + "]. Error: " + error.ToString());
}
const int SecurityImpersonation = 2;
IntPtr dupeTokenHandle = IntPtr.Zero;
- if(!DuplicateToken(tokenHandle, SecurityImpersonation, ref dupeTokenHandle))
+ if (!DuplicateToken(tokenHandle, SecurityImpersonation, ref dupeTokenHandle))
{
NativeError error = NativeError.GetLastError();
if (tokenHandle != IntPtr.Zero)
@@ -309,7 +309,7 @@
WindowsIdentity identity = new WindowsIdentity(dupeTokenHandle);
// Free the tokens.
- if (dupeTokenHandle != IntPtr.Zero)
+ if (dupeTokenHandle != IntPtr.Zero)
{
CloseHandle(dupeTokenHandle);
}
@@ -323,13 +323,13 @@
#region Native Method Stubs
- [DllImport("advapi32.dll", SetLastError=true)]
+ [DllImport("advapi32.dll", SetLastError = true)]
private static extern bool LogonUser(String lpszUsername, String lpszDomain, String lpszPassword, int dwLogonType, int dwLogonProvider, ref IntPtr phToken);
- [DllImport("kernel32.dll", CharSet=CharSet.Auto)]
+ [DllImport("kernel32.dll", CharSet = CharSet.Auto)]
private static extern bool CloseHandle(IntPtr handle);
- [DllImport("advapi32.dll", CharSet=CharSet.Auto, SetLastError=true)]
+ [DllImport("advapi32.dll", CharSet = CharSet.Auto, SetLastError = true)]
private static extern bool DuplicateToken(IntPtr ExistingTokenHandle, int SECURITY_IMPERSONATION_LEVEL, ref IntPtr DuplicateTokenHandle);
#endregion