Ejemplo n.º 1
0
 /// <summary>
 /// Activate the options on the file appender.
 /// </summary>
 /// <remarks>
 /// <para>
 /// This is part of the <see cref="T:log4net.Core.IOptionHandler" /> delayed object
 /// activation scheme. The <see cref="M:log4net.Appender.FileAppender.ActivateOptions" /> method must
 /// be called on this object after the configuration properties have
 /// been set. Until <see cref="M:log4net.Appender.FileAppender.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="M:log4net.Appender.FileAppender.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 = new ExclusiveLock();
     }
     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 [" + base.Name + "].");
         LogLog.Warn(declaringType, "FileAppender: Are you using FileAppender instead of ConsoleAppender?");
     }
 }
Ejemplo n.º 2
0
 public LockingStream(LockingModelBase locking)
 {
     if (locking == null)
     {
         throw new ArgumentException("Locking model may not be null", "locking");
     }
     m_lockingModel = locking;
 }
Ejemplo n.º 3
0
 public LockingStream(LockingModelBase locking)
     : base()
 {
     if (locking == null)
     {
         throw new ArgumentException("锁定对象为空", "locking");
     }
     m_lockingModel = locking;
 }
Ejemplo n.º 4
0
 public FileAppender(ILayout layout, string filename, bool append)
 {
     this.m_appendToFile = true;
     this.m_encoding     = System.Text.Encoding.Default;
     this.m_lockingModel = new ExclusiveLock();
     this.Layout         = layout;
     this.File           = filename;
     this.AppendToFile   = append;
     this.ActivateOptions();
 }
Ejemplo n.º 5
0
            /// <summary>
            /// Constructor.
            /// </summary>
            /// <param name="locking">The locking model.</param>
            /// <param name="lockLevel">The lock level.</param>
            public LockingStream(LockingModelBase locking, int lockLevel)
            {
                if (locking == null)
                {
                    const string message = "Locking model may not be null";
                    throw new ArgumentException(message, "locking");
                }
                m_lockingModel = locking;

                m_lockLevel = lockLevel;
            }
Ejemplo n.º 6
0
			public LockingStream(LockingModelBase locking) : base()
			{
				if (locking==null)
				{
					throw new ArgumentException("Locking model may not be null","locking");
				}
				m_lockingModel=locking;
			}
Ejemplo n.º 7
0
            /// <summary>
            /// Constructor.
            /// </summary>
            /// <param name="locking">The locking model.</param>
            /// <param name="lockLevel">The lock level.</param>
            public LockingStream(LockingModelBase locking, int lockLevel)
            {
                if (locking == null)
                {
                    const string message = "Locking model may not be null";
                    throw new ArgumentException(message, "locking");
                }
                m_lockingModel = locking;

                m_lockLevel = lockLevel;
            }
Ejemplo n.º 8
0
 public FileAppender()
 {
     this.m_appendToFile = true;
     this.m_encoding     = System.Text.Encoding.Default;
     this.m_lockingModel = new ExclusiveLock();
 }