Uploaded image for project: 'Log4net'
  1. Log4net
  2. LOG4NET-219

RollingFileAppender with varying dynamic filenames not working

    Details

    • Type: Bug
    • Status: Open
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: 1.2.10
    • Component/s: Appenders
    • Labels:
      None
    • Environment:
      OS: Windows Server 2003, Sharepoint 2007

      Description

      The Log4Net configuration file is as below:
      <log4net>
      <appender name="RollingFile" type="log4net.Appender.RollingFileAppender">
      <file type="log4net.Util.PatternString" value="C:\ErrorLog%property

      {LogPath}

      "></file>
      <appendToFile value="true"></appendToFile>
      <maximumFileSize value="1024KB"></maximumFileSize>
      <maxSizeRollBackups value="2"></maxSizeRollBackups>
      <layout type="log4net.Layout.PatternLayout">
      <conversionpattern value="%newline%date - %message%newline"></conversionpattern>
      </layout>
      </appender>
      <logger name="File">
      <level value="All" />
      <appender-ref ref="RollingFile" />
      </logger>
      </log4net>

      In my application the debug method for logging the information will be called many times. Some messages should get stored in a file with name say xy.log and some messages should get stored in a file with name say ab.log.

      In Global.asax i have written the following code:

      log4net.Config.XmlConfigurator.ConfigureAndWatch(new System.IO.FileInfo(Server.MapPath("/Log4Net.config")));
      The above LOC is written in the Application_Start event

      Actual call to the debug method:

      log4net.GlobalContext.Properties["LogPath"] = String.Concat(FilePrefix,"_Debug.log");
      log4net.ILog filelogger = log4net.LogManager.GetLogger("File");
      filelogger.Debug(info);

      Issue: Although the property named LogPath is getting set properly, i dont see any file with the name specified through the code getting created in the path specified.

      Can you please look into this and let me know whether i am missing something or whether it is not supported?

      Thanks in advance.....

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                amar.g Amar G
              • Votes:
                1 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated: