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?");
     }
 }