/// <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?"); } }
public LockingStream(LockingModelBase locking) { if (locking == null) { throw new ArgumentException("Locking model may not be null", "locking"); } m_lockingModel = locking; }
public LockingStream(LockingModelBase locking) : base() { if (locking == null) { throw new ArgumentException("锁定对象为空", "locking"); } m_lockingModel = locking; }
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(); }
/// <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; }
public LockingStream(LockingModelBase locking) : base() { if (locking==null) { throw new ArgumentException("Locking model may not be null","locking"); } m_lockingModel=locking; }
public FileAppender() { this.m_appendToFile = true; this.m_encoding = System.Text.Encoding.Default; this.m_lockingModel = new ExclusiveLock(); }