You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by dp...@apache.org on 2015/11/01 17:30:07 UTC

svn commit: r1711830 - /logging/log4net/trunk/src/Appender/FileAppender.cs

Author: dpsenner
Date: Sun Nov  1 16:30:06 2015
New Revision: 1711830

URL: http://svn.apache.org/viewvc?rev=1711830&view=rev
Log:
Refactoring

Reformatted the entire document to fix indentations and others.

Modified:
    logging/log4net/trunk/src/Appender/FileAppender.cs

Modified: logging/log4net/trunk/src/Appender/FileAppender.cs
URL: http://svn.apache.org/viewvc/logging/log4net/trunk/src/Appender/FileAppender.cs?rev=1711830&r1=1711829&r2=1711830&view=diff
==============================================================================
--- logging/log4net/trunk/src/Appender/FileAppender.cs (original)
+++ logging/log4net/trunk/src/Appender/FileAppender.cs Sun Nov  1 16:30:06 2015
@@ -57,19 +57,19 @@ namespace log4net.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>
+	/// <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>
@@ -125,7 +125,7 @@ namespace log4net.Appender
 	/// <author>Douglas de la Torre</author>
 	/// <author>Niall Daley</author>
 #endif
-    public class FileAppender : TextWriterAppender 
+	public class FileAppender : TextWriterAppender
 	{
 		#region LockingStream Inner Class
 
@@ -137,23 +137,25 @@ namespace log4net.Appender
 		{
 			public sealed class LockStateException : LogException
 			{
-				public LockStateException(string message): base(message)
+				public LockStateException(string message)
+					: base(message)
 				{
 				}
 			}
 
-			private Stream m_realStream=null;
-			private LockingModelBase m_lockingModel=null;
-			private int m_readTotal=-1;
-			private int m_lockLevel=0;
+			private Stream m_realStream = null;
+			private LockingModelBase m_lockingModel = null;
+			private int m_readTotal = -1;
+			private int m_lockLevel = 0;
 
-			public LockingStream(LockingModelBase locking) : base()
+			public LockingStream(LockingModelBase locking)
+				: base()
 			{
-				if (locking==null)
+				if (locking == null)
 				{
-					throw new ArgumentException("Locking model may not be null","locking");
+					throw new ArgumentException("Locking model may not be null", "locking");
 				}
-				m_lockingModel=locking;
+				m_lockingModel = locking;
 			}
 
 			#region Override Implementation of Stream
@@ -162,8 +164,8 @@ namespace log4net.Appender
 			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);
+				IAsyncResult ret = m_realStream.BeginRead(buffer, offset, count, callback, state);
+				m_readTotal = EndRead(ret);
 				return ret;
 			}
 
@@ -173,104 +175,104 @@ namespace log4net.Appender
 			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);
+				IAsyncResult ret = m_realStream.BeginWrite(buffer, offset, count, callback, state);
 				EndWrite(ret);
 				return ret;
 			}
 
-			public override void Close() 
+			public override void Close()
 			{
 				m_lockingModel.CloseFile();
 			}
 
-			public override int EndRead(IAsyncResult asyncResult) 
+			public override int EndRead(IAsyncResult asyncResult)
 			{
 				AssertLocked();
 				return m_readTotal;
 			}
-			public override void EndWrite(IAsyncResult asyncResult) 
+			public override void EndWrite(IAsyncResult asyncResult)
 			{
 				//No-op, it has already been handled
 			}
-			public override void Flush() 
+			public override void Flush()
 			{
 				AssertLocked();
 				m_realStream.Flush();
 			}
-			public override int Read(byte[] buffer, int offset, int count) 
+			public override int Read(byte[] buffer, int offset, int count)
 			{
-				return m_realStream.Read(buffer,offset,count);
+				return m_realStream.Read(buffer, offset, count);
 			}
-			public override int ReadByte() 
+			public override int ReadByte()
 			{
 				return m_realStream.ReadByte();
 			}
-			public override long Seek(long offset, SeekOrigin origin) 
+			public override long Seek(long offset, SeekOrigin origin)
 			{
 				AssertLocked();
-				return m_realStream.Seek(offset,origin);
+				return m_realStream.Seek(offset, origin);
 			}
-			public override void SetLength(long value) 
+			public override void SetLength(long value)
 			{
 				AssertLocked();
 				m_realStream.SetLength(value);
 			}
-			void IDisposable.Dispose() 
+			void IDisposable.Dispose()
 			{
 				Close();
 			}
-			public override void Write(byte[] buffer, int offset, int count) 
+			public override void Write(byte[] buffer, int offset, int count)
 			{
 				AssertLocked();
-				m_realStream.Write(buffer,offset,count);
+				m_realStream.Write(buffer, offset, count);
 			}
-			public override void WriteByte(byte value) 
+			public override void WriteByte(byte value)
 			{
 				AssertLocked();
 				m_realStream.WriteByte(value);
 			}
 
 			// Properties
-			public override bool CanRead 
-			{ 
-				get { return false; } 
-			}
-			public override bool CanSeek 
-			{ 
-				get 
+			public override bool CanRead
+			{
+				get { return false; }
+			}
+			public override bool CanSeek
+			{
+				get
 				{
 					AssertLocked();
 					return m_realStream.CanSeek;
-				} 
+				}
 			}
-			public override bool CanWrite 
-			{ 
-				get 
+			public override bool CanWrite
+			{
+				get
 				{
 					AssertLocked();
 					return m_realStream.CanWrite;
-				} 
+				}
 			}
-			public override long Length 
-			{ 
-				get 
+			public override long Length
+			{
+				get
 				{
 					AssertLocked();
 					return m_realStream.Length;
-				} 
+				}
 			}
-			public override long Position 
-			{ 
-				get 
+			public override long Position
+			{
+				get
 				{
 					AssertLocked();
 					return m_realStream.Position;
-				} 
-				set 
+				}
+				set
 				{
 					AssertLocked();
-					m_realStream.Position=value;
-				} 
+					m_realStream.Position = value;
+				}
 			}
 
 			#endregion Override Implementation of Stream
@@ -287,18 +289,18 @@ namespace log4net.Appender
 
 			public bool AcquireLock()
 			{
-				bool ret=false;
-				lock(this)
+				bool ret = false;
+				lock (this)
 				{
-					if (m_lockLevel==0)
+					if (m_lockLevel == 0)
 					{
 						// If lock is already acquired, nop
-						m_realStream=m_lockingModel.AcquireLock();
+						m_realStream = m_lockingModel.AcquireLock();
 					}
-					if (m_realStream!=null)
+					if (m_realStream != null)
 					{
 						m_lockLevel++;
-						ret=true;
+						ret = true;
 					}
 				}
 				return ret;
@@ -306,14 +308,14 @@ namespace log4net.Appender
 
 			public void ReleaseLock()
 			{
-				lock(this)
+				lock (this)
 				{
 					m_lockLevel--;
-					if (m_lockLevel==0)
+					if (m_lockLevel == 0)
 					{
 						// If already unlocked, nop
 						m_lockingModel.ReleaseLock();
-						m_realStream=null;
+						m_realStream = null;
 					}
 				}
 			}
@@ -335,7 +337,7 @@ namespace log4net.Appender
 		/// </remarks>
 		public abstract class LockingModelBase
 		{
-			private FileAppender m_appender=null;
+			private FileAppender m_appender = null;
 
 			/// <summary>
 			/// Open the output file
@@ -351,7 +353,7 @@ namespace log4net.Appender
 			/// <see cref="ReleaseLock"/> and <see cref="CloseFile"/>.
 			/// </para>
 			/// </remarks>
-			public abstract void OpenFile(string filename, bool append,Encoding encoding);
+			public abstract void OpenFile(string filename, bool append, Encoding encoding);
 
 			/// <summary>
 			/// Close the file
@@ -412,55 +414,55 @@ namespace log4net.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)
-            {
-                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.Close();
-                }
-           }
+			/// <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)
+			{
+				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.Close();
+				}
+			}
 		}
 
 		/// <summary>
@@ -490,15 +492,15 @@ namespace log4net.Appender
 			/// <see cref="ReleaseLock"/> and <see cref="CloseFile"/>.
 			/// </para>
 			/// </remarks>
-			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.Read);
+					m_stream = CreateStream(filename, append, FileShare.Read);
 				}
 				catch (Exception e1)
 				{
-					CurrentAppender.ErrorHandler.Error("Unable to acquire lock on file "+filename+". "+e1.Message);
+					CurrentAppender.ErrorHandler.Error("Unable to acquire lock on file " + filename + ". " + e1.Message);
 				}
 			}
 
@@ -512,8 +514,8 @@ namespace log4net.Appender
 			/// </remarks>
 			public override void CloseFile()
 			{
-                CloseStream(m_stream);
-                m_stream = null;
+				CloseStream(m_stream);
+				m_stream = null;
 			}
 
 			/// <summary>
@@ -559,7 +561,7 @@ namespace log4net.Appender
 		{
 			private string m_filename;
 			private bool m_append;
-			private Stream m_stream=null;
+			private Stream m_stream = null;
 
 			/// <summary>
 			/// Prepares to open the file when the first message is logged.
@@ -577,8 +579,8 @@ namespace log4net.Appender
 			/// </remarks>
 			public override void OpenFile(string filename, bool append, Encoding encoding)
 			{
-				m_filename=filename;
-				m_append=append;
+				m_filename = filename;
+				m_append = append;
 			}
 
 			/// <summary>
@@ -607,16 +609,16 @@ namespace log4net.Appender
 			/// </remarks>
 			public override Stream AcquireLock()
 			{
-				if (m_stream==null)
+				if (m_stream == null)
 				{
 					try
 					{
-                        m_stream = CreateStream(m_filename, m_append, FileShare.Read);
-                        m_append = true;
+						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);
+						CurrentAppender.ErrorHandler.Error("Unable to acquire lock on file " + m_filename + ". " + e1.Message);
 					}
 				}
 				return m_stream;
@@ -633,122 +635,125 @@ namespace log4net.Appender
 			/// </remarks>
 			public override void ReleaseLock()
 			{
-                CloseStream(m_stream);
-                m_stream = null;
+				CloseStream(m_stream);
+				m_stream = null;
 			}
 		}
 
 #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;
-
-            /// <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>
+		/// 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;
+
+			/// <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
-            [System.Security.SecuritySafeCritical]
+			[System.Security.SecuritySafeCritical]
 #endif
-            public override void OpenFile(string filename, bool append, Encoding encoding)
-            {
-                try
-                {
-                    m_stream = CreateStream(filename, append, FileShare.ReadWrite);
-
-                    string mutexFriendlyFilename = filename
-                            .Replace("\\", "_")
-                            .Replace(":", "_")
-                            .Replace("/", "_");
-
-                    m_mutex = new Mutex(false, mutexFriendlyFilename); 
-                }
-                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 {
+			public override void OpenFile(string filename, bool append, Encoding encoding)
+			{
+				try
+				{
+					m_stream = CreateStream(filename, append, FileShare.ReadWrite);
+
+					string mutexFriendlyFilename = filename
+							.Replace("\\", "_")
+							.Replace(":", "_")
+							.Replace("/", "_");
+
+					m_mutex = new Mutex(false, mutexFriendlyFilename);
+				}
+				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();
-                    m_mutex.Close();
+					m_mutex.Close();
 					m_mutex = 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()
+			{
+				if (m_mutex != null)
+				{
+					// TODO: add timeout?
+					m_mutex.WaitOne();
 
-            /// <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();
-
-                    // should always be true (and fast) for FileStream
-                    if (m_stream.CanSeek) {
-                        m_stream.Seek(0, SeekOrigin.End);
-                    }
+					// should always be true (and fast) for FileStream
+					if (m_stream.CanSeek)
+					{
+						m_stream.Seek(0, SeekOrigin.End);
+					}
 				}
 				else
 				{
 					CurrentAppender.ErrorHandler.Error("Programming error, no mutex available to acquire lock! From here on things will be dangerous!");
 				}
-                return m_stream;
-            }
+				return m_stream;
+			}
 
-            /// <summary>
-            /// Releases the lock and allows others to acquire a lock.
-            /// </summary>
-            public override void ReleaseLock()
-            {
-                if (m_mutex != null)
-                {
-                    m_mutex.ReleaseMutex();
+			/// <summary>
+			/// Releases the lock and allows others to acquire a lock.
+			/// </summary>
+			public override void ReleaseLock()
+			{
+				if (m_mutex != null)
+				{
+					m_mutex.ReleaseMutex();
 				}
 				else
 				{
 					CurrentAppender.ErrorHandler.Error("Programming error, no mutex available to release the lock!");
 				}
-            }
-        }
+			}
+		}
 #endif
 
 		#endregion Locking Models
@@ -779,7 +784,7 @@ namespace log4net.Appender
 		/// </para>
 		/// </remarks>
 		[Obsolete("Instead use the default constructor and set the Layout, File & AppendToFile properties")]
-		public FileAppender(ILayout layout, string filename, bool append) 
+		public FileAppender(ILayout layout, string filename, bool append)
 		{
 			Layout = layout;
 			File = filename;
@@ -799,7 +804,8 @@ namespace log4net.Appender
 		/// </para>
 		/// </remarks>
 		[Obsolete("Instead use the default constructor and set the Layout & File properties")]
-		public FileAppender(ILayout layout, string filename) : this(layout, filename, true)
+		public FileAppender(ILayout layout, string filename)
+			: this(layout, filename, true)
 		{
 		}
 
@@ -877,7 +883,7 @@ namespace log4net.Appender
 		/// of the current thread.
 		/// </para>
 		/// </remarks>
-		public SecurityContext SecurityContext 
+		public SecurityContext SecurityContext
 		{
 			get { return m_securityContext; }
 			set { m_securityContext = value; }
@@ -905,7 +911,7 @@ namespace log4net.Appender
 		/// </para>
 		/// </remarks>
 #else
-        /// <summary>
+		/// <summary>
 		/// Gets or sets the <see cref="FileAppender.LockingModel"/> used to handle locking of the file.
 		/// </summary>
 		/// <value>
@@ -916,10 +922,10 @@ namespace log4net.Appender
 		/// 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"/> .
+		/// 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.
+		/// and the last synchronizes processes using a named system wide Mutex.
 		/// </para>
 		/// <para>
 		/// The default locking model is the <see cref="FileAppender.ExclusiveLock"/>.
@@ -955,8 +961,8 @@ namespace log4net.Appender
 		/// This will cause the file to be opened.
 		/// </para>
 		/// </remarks>
-		override public void ActivateOptions() 
-		{	
+		override public void ActivateOptions()
+		{
 			base.ActivateOptions();
 
 			if (m_securityContext == null)
@@ -969,19 +975,19 @@ namespace log4net.Appender
 				m_lockingModel = new FileAppender.ExclusiveLock();
 			}
 
-			m_lockingModel.CurrentAppender=this;
-			
-			if (m_fileName != null) 
+			m_lockingModel.CurrentAppender = this;
+
+			if (m_fileName != null)
 			{
-				using(SecurityContext.Impersonate(this))
+				using (SecurityContext.Impersonate(this))
 				{
 					m_fileName = ConvertToFullPath(m_fileName.Trim());
 				}
 				SafeOpenFile(m_fileName, m_appendToFile);
-			} 
-			else 
+			}
+			else
 			{
-				LogLog.Warn(declaringType, "FileAppender: File option not set for appender ["+Name+"].");
+				LogLog.Warn(declaringType, "FileAppender: File option not set for appender [" + Name + "].");
 				LogLog.Warn(declaringType, "FileAppender: Are you using FileAppender instead of ConsoleAppender?");
 			}
 		}
@@ -998,25 +1004,25 @@ namespace log4net.Appender
 		/// Resets the filename and the file stream.
 		/// </para>
 		/// </remarks>
-		override protected void Reset() 
+		override protected void Reset()
 		{
 			base.Reset();
 			m_fileName = null;
 		}
 
- 		/// <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>
- 		override protected void PrepareWriter()
- 		{
+		/// <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>
+		override protected void PrepareWriter()
+		{
 			SafeOpenFile(m_fileName, m_appendToFile);
- 		}
+		}
 
 		/// <summary>
 		/// This method is called by the <see cref="M:AppenderSkeleton.DoAppend(LoggingEvent)"/>
@@ -1032,7 +1038,7 @@ namespace log4net.Appender
 		/// The format of the output will depend on the appender's layout.
 		/// </para>
 		/// </remarks>
-		override protected void Append(LoggingEvent loggingEvent) 
+		override protected void Append(LoggingEvent loggingEvent)
 		{
 			if (m_stream.AcquireLock())
 			{
@@ -1058,7 +1064,7 @@ namespace log4net.Appender
 		/// the stream.
 		/// </para>
 		/// </remarks>
-		override protected void Append(LoggingEvent[] loggingEvents) 
+		override protected void Append(LoggingEvent[] loggingEvents)
 		{
 			if (m_stream.AcquireLock())
 			{
@@ -1081,9 +1087,9 @@ namespace log4net.Appender
 		/// Writes a footer as produced by the embedded layout's <see cref="ILayout.Footer"/> property.
 		/// </para>
 		/// </remarks>
-		protected override void WriteFooter() 
+		protected override void WriteFooter()
 		{
-			if (m_stream!=null)
+			if (m_stream != null)
 			{
 				//WriteFooter can be called even before a file is opened
 				m_stream.AcquireLock();
@@ -1106,9 +1112,9 @@ namespace log4net.Appender
 		/// Writes a header produced by the embedded layout's <see cref="ILayout.Header"/> property.
 		/// </para>
 		/// </remarks>
-		protected override void WriteHeader() 
+		protected override void WriteHeader()
 		{
-			if (m_stream!=null)
+			if (m_stream != null)
 			{
 				if (m_stream.AcquireLock())
 				{
@@ -1132,9 +1138,9 @@ namespace log4net.Appender
 		/// Closes the underlying <see cref="TextWriter"/>.
 		/// </para>
 		/// </remarks>
-		protected override void CloseWriter() 
+		protected override void CloseWriter()
 		{
-			if (m_stream!=null)
+			if (m_stream != null)
 			{
 				m_stream.AcquireLock();
 				try
@@ -1161,7 +1167,7 @@ namespace log4net.Appender
 		/// closes the file.
 		/// </para>
 		/// </remarks>
-		protected void CloseFile() 
+		protected void CloseFile()
 		{
 			WriteFooterAndCloseWriter();
 		}
@@ -1183,13 +1189,13 @@ namespace log4net.Appender
 		/// </remarks>
 		virtual protected void SafeOpenFile(string fileName, bool append)
 		{
-			try 
+			try
 			{
 				OpenFile(fileName, append);
 			}
-			catch(Exception e) 
+			catch (Exception e)
 			{
-				ErrorHandler.Error("OpenFile("+fileName+","+append+") call failed.", e, ErrorCode.FileOpenFailure);
+				ErrorHandler.Error("OpenFile(" + fileName + "," + append + ") call failed.", e, ErrorCode.FileOpenFailure);
 			}
 		}
 
@@ -1214,29 +1220,29 @@ namespace log4net.Appender
 			{
 				// Internal check that the fileName passed in is a rooted path
 				bool isPathRooted = false;
-				using(SecurityContext.Impersonate(this))
+				using (SecurityContext.Impersonate(this))
 				{
 					isPathRooted = Path.IsPathRooted(fileName);
 				}
 				if (!isPathRooted)
 				{
-					LogLog.Error(declaringType, "INTERNAL ERROR. OpenFile("+fileName+"): File name is not fully qualified.");
+					LogLog.Error(declaringType, "INTERNAL ERROR. OpenFile(" + fileName + "): File name is not fully qualified.");
 				}
 			}
 
-			lock(this)
+			lock (this)
 			{
 				Reset();
 
-				LogLog.Debug(declaringType, "Opening file for writing ["+fileName+"] append ["+append+"]");
+				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);
+				LockingModel.CurrentAppender = this;
+				LockingModel.OpenFile(fileName, append, m_encoding);
+				m_stream = new LockingStream(LockingModel);
 
 				if (m_stream != null)
 				{
@@ -1271,7 +1277,7 @@ namespace log4net.Appender
 		/// data using a <c>System.Security.Cryptography.CryptoStream</c>.
 		/// </para>
 		/// </remarks>
-		virtual protected void SetQWForFiles(Stream fileStream) 
+		virtual protected void SetQWForFiles(Stream fileStream)
 		{
 			SetQWForFiles(new StreamWriter(fileStream, m_encoding));
 		}
@@ -1286,7 +1292,7 @@ namespace log4net.Appender
 		/// wrap the <see cref="TextWriter"/> in some way.
 		/// </para>
 		/// </remarks>
-		virtual protected void SetQWForFiles(TextWriter writer) 
+		virtual protected void SetQWForFiles(TextWriter writer)
 		{
 			QuietWriter = new QuietTextWriter(writer, ErrorHandler);
 		}
@@ -1350,17 +1356,17 @@ namespace log4net.Appender
 
 		#endregion Private Instance Fields
 
-	    #region Private Static 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 readonly static Type declaringType = typeof(FileAppender);
+		/// <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 readonly static Type declaringType = typeof(FileAppender);
 
-	    #endregion Private Static Fields
+		#endregion Private Static Fields
 	}
 }