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

Add appSetting conversion pattern to PatternString

    Details

    • Type: New Feature
    • Status: Resolved
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 1.2.15
    • Fix Version/s: 2.0.6
    • Component/s: Core
    • Labels:
      None

      Description

      A common requirement is to be able to define a base directory for log files that can be used by multiple FileAppenders. In this way, the directory only needs to be changed in one place.

      Today the typical solution is to use a PatternString with a property that is set in code before log4net is configured, e.g.

      <file type="log4net.Util.PatternString" value="%property

      {LogDIr}MyFile.log"/>

      Suggested feature is to allow a conversion pattern that reads the base directory name from an appSetting, e.g.:

      <file type="log4net.Util.PatternString" value="%appSetting{LogDIr}

      MyFile.log"/>

        Issue Links

          Activity

          Hide
          githubbot ASF GitHub Bot added a comment -

          GitHub user JJoe2 opened a pull request:

          https://github.com/apache/log4net/pull/35

          Wip/app settings

          Implementation for LOG4NET-526

          You can merge this pull request into a Git repository by running:

          $ git pull https://github.com/JJoe2/log4net wip/AppSettings

          Alternatively you can review and apply these changes as the patch at:

          https://github.com/apache/log4net/pull/35.patch

          To close this pull request, make a commit to your master/trunk branch
          with (at least) the following in the commit message:

          This closes #35


          commit a66d2fc61c4a1cfd8317aee41385ef6c43373ffc
          Author: JoeJoe <jocularjoe@hotmail.com>
          Date: 2016-04-22T19:21:07Z

          Use UTC internally to avoid ambiguous times

          commit 9e9f1759d6a80594cd2d12bd54a9e3af9e7cfaa0
          Author: JoeJoe <jocularjoe@hotmail.com>
          Date: 2016-04-23T19:58:36Z

          Implement flushing of appenders that buffer data

          commit 38fdfbaa7e9cd30e8a84fe90aa0ab12641b4db5f
          Author: JoeJoe <jocularjoe@hotmail.com>
          Date: 2016-10-02T17:12:33Z

          Added AppSettingPatterConverter


          Show
          githubbot ASF GitHub Bot added a comment - GitHub user JJoe2 opened a pull request: https://github.com/apache/log4net/pull/35 Wip/app settings Implementation for LOG4NET-526 You can merge this pull request into a Git repository by running: $ git pull https://github.com/JJoe2/log4net wip/AppSettings Alternatively you can review and apply these changes as the patch at: https://github.com/apache/log4net/pull/35.patch To close this pull request, make a commit to your master/trunk branch with (at least) the following in the commit message: This closes #35 commit a66d2fc61c4a1cfd8317aee41385ef6c43373ffc Author: JoeJoe <jocularjoe@hotmail.com> Date: 2016-04-22T19:21:07Z Use UTC internally to avoid ambiguous times commit 9e9f1759d6a80594cd2d12bd54a9e3af9e7cfaa0 Author: JoeJoe <jocularjoe@hotmail.com> Date: 2016-04-23T19:58:36Z Implement flushing of appenders that buffer data commit 38fdfbaa7e9cd30e8a84fe90aa0ab12641b4db5f Author: JoeJoe <jocularjoe@hotmail.com> Date: 2016-10-02T17:12:33Z Added AppSettingPatterConverter
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user bodewig commented on the issue:

          https://github.com/apache/log4net/pull/35

          I've added your converter, many thanks.

          Tests would be good and we need documentation before we can close LOG4NET-526.

          Show
          githubbot ASF GitHub Bot added a comment - Github user bodewig commented on the issue: https://github.com/apache/log4net/pull/35 I've added your converter, many thanks. Tests would be good and we need documentation before we can close LOG4NET-526 .
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user asfgit closed the pull request at:

          https://github.com/apache/log4net/pull/35

          Show
          githubbot ASF GitHub Bot added a comment - Github user asfgit closed the pull request at: https://github.com/apache/log4net/pull/35
          Hide
          githubbot ASF GitHub Bot added a comment -

          Github user JJoe2 commented on the issue:

          https://github.com/apache/log4net/pull/35

          I’ll be happy to do the unit tests and possibly the doc. Are suitable XML comments enough?

          Now this is added, I’ll also be thinking about the next step, which is to allow the PatternString converter to be used in the XML configuration file for properties of types other than strings.
          So that I can do something like:

          <root>
          <level type=”log4net.Util.PatternString” value="%appsetting

          {Logging. Level}

          " />
          </root>

          Should be possible: basically be applying the PatternString conversion before converting to the target type of the property.

          From: Stefan Bodewig notifications@github.com
          Sent: 26 October 2016 20:43
          To: apache/log4net
          Cc: JJoe2; Author
          Subject: Re: [apache/log4net] Wip/app settings (#35)

          I've added your converter, many thanks.

          Tests would be good and we need documentation before we can close LOG4NET-526.


          You are receiving this because you authored the thread.
          Reply to this email directly, view it on GitHub<https://github.com/apache/log4net/pull/35#issuecomment-256440366>, or mute the thread<https://github.com/notifications/unsubscribe-auth/AFY0uybBZ6IZdXI75BhcToQlNLFlHQY3ks5q359EgaJpZM4KMD7s>.

          Show
          githubbot ASF GitHub Bot added a comment - Github user JJoe2 commented on the issue: https://github.com/apache/log4net/pull/35 I’ll be happy to do the unit tests and possibly the doc. Are suitable XML comments enough? Now this is added, I’ll also be thinking about the next step, which is to allow the PatternString converter to be used in the XML configuration file for properties of types other than strings. So that I can do something like: <root> <level type=”log4net.Util.PatternString” value="%appsetting {Logging. Level} " /> </root> Should be possible: basically be applying the PatternString conversion before converting to the target type of the property. From: Stefan Bodewig notifications@github.com Sent: 26 October 2016 20:43 To: apache/log4net Cc: JJoe2; Author Subject: Re: [apache/log4net] Wip/app settings (#35) I've added your converter, many thanks. Tests would be good and we need documentation before we can close LOG4NET-526 . — You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub< https://github.com/apache/log4net/pull/35#issuecomment-256440366 >, or mute the thread< https://github.com/notifications/unsubscribe-auth/AFY0uybBZ6IZdXI75BhcToQlNLFlHQY3ks5q359EgaJpZM4KMD7s >.
          Hide
          bodewig Stefan Bodewig added a comment -

          Test added, many thanks Joe.

          Show
          bodewig Stefan Bodewig added a comment - Test added, many thanks Joe.

            People

            • Assignee:
              Unassigned
              Reporter:
              JoeJoe Joe
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development