title: Enterprise Library 6 - dynamically change log file name
body: <p>Is it possible to dynamically set log folder and file name in C# which overrides the config value(file name) in the Listeners section of logging configuration? 
  Tried to follow the below link but it is applicable only for EL 5
  <a href="https://stackoverflow.com/questions/17361077/log-messages-going-to-previously-created-log-file">Log messages going to previously created log file</a></p>
  
  <p>This is how i Initialize EL Logging:</p>
  
  <pre><code> IConfigurationSource configurationSource = ConfigurationSourceFactory.Create();
          LogWriterFactory logWriterFactory = new LogWriterFactory(configurationSource);
          Logger.SetLogWriter(logWriterFactory.Create(), false);
  
          ExceptionPolicyFactory factory = new ExceptionPolicyFactory(configurationSource);
          ExceptionPolicy.SetExceptionManager(factory.CreateManager());           
  </code></pre>
  
  <p>These are my web.config entries inside the listeners tag:</p>
  
  <pre><code> &lt;add name="RollingFlatFileTraceLog" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.RollingFlatFileTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
      listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.RollingFlatFileTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
      fileName="C:\logs\Trace.log" footer=""
      formatter="CustomRollingFlatFileLogFormatter"
      header="" rollFileExistsBehavior="Overwrite" rollInterval="Day"
      rollSizeKB="2048" maxArchivedFiles="52" /&gt;
    &lt;add name="RollingFlatFileErrorLog" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.RollingFlatFileTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
      listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.RollingFlatFileTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
      fileName="C:\logs\Error.log" footer="----------------------------------------"
      formatter=" CustomRollingFlatFileLogFormatter "
      header="----------------------------------------" rollFileExistsBehavior="Overwrite"
      rollInterval="Day" rollSizeKB="2048" maxArchivedFiles="52" /&gt;
  </code></pre>
  
  <p>I use Logger.Write and ExceptionPolicy.HandleException to write to the corresponding trace and error logs.</p>