Log4net
  1. Log4net
  2. LOG4NET-272

Problems in dynamic file naming with multiple appenders

    Details

    • Type: Task Task
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Won't Fix
    • Affects Version/s: 1.2.10
    • Fix Version/s: 1.2 Maintenance Release
    • Component/s: Appenders
    • Labels:
      None
    • Environment:
      OS: Windows XP
      Programming Environment: VB.NET
      .NET Framework 3.5
      Appender Type: RollingFileAppender

      Description

      I have 3 appenders in my config file for creating 3 different types of logs. I am using dynamic naming of file in each of the 3 appenders by setting the global context properties. In some cases, i need to set the log file name dynamically for just 1 appender. When i set the file name for just 1 appender, it creates another file named "null" with no data in addition to the actual logfile whose name has been set dynamically.

      <appender name="RollingFileAppenderV1" type="log4net.Appender.RollingFileAppender">
      <file type="log4net.Util.PatternString" value="Logs%property

      {applog}

      " />
      .
      .
      .
      <appender name="RollingFileAppenderV2" type="log4net.Appender.RollingFileAppender">
      <file type="log4net.Util.PatternString" value="Logs%property

      {dblog}

      " />
      .
      .
      <logger name="Logger1">
      <level value="DEBUG" />
      <appender-ref ref="RollingFileAppenderV1" />
      </logger>
      <logger name="Logger2">
      <level value="DEBUG" />
      <appender-ref ref="RollingFileAppenderV2" />
      </logger>

      In the VB.NET code i set the filename as :

      log4net.GlobalContext.Properties("applog") = "file1.log"
      Dim logobj as log4net.Ilog = LogManager.GetLogger("Logger1")
      logobj.debug("test")

      In this case it creates "file1.log" and also another empty file with name as "null". This happens only when i am setting either of the appenders filename at runtime.
      Could you please check and let me know the issue behind this.

        Activity

        Hide
        Dominik Psenner added a comment -

        Is this still important? Either way I would give this issue a month and then just close it as wont fix.

        Show
        Dominik Psenner added a comment - Is this still important? Either way I would give this issue a month and then just close it as wont fix.
        Hide
        Dominik Psenner added a comment -

        The month became a year, closing as won't fix now.

        Show
        Dominik Psenner added a comment - The month became a year, closing as won't fix now.
        Hide
        Joe added a comment -

        If you are using properties in the configuration file, you need to set all such properties in code before log4net is configured.

        The code you posted only sets one of the properties (applog) and doesn't set the other (dblog).

        You may find the new appsettings feature useful: see LOG4NET-526

        Show
        Joe added a comment - If you are using properties in the configuration file, you need to set all such properties in code before log4net is configured. The code you posted only sets one of the properties (applog) and doesn't set the other (dblog). You may find the new appsettings feature useful: see LOG4NET-526

          People

          • Assignee:
            Dominik Psenner
            Reporter:
            Ranjith Nair
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Time Tracking

              Estimated:
              Original Estimate - 48h
              48h
              Remaining:
              Remaining Estimate - 48h
              48h
              Logged:
              Time Spent - Not Specified
              Not Specified

                Development