Uploaded image for project: 'Log4j 2'
  1. Log4j 2
  2. LOG4J2-771

Add lookup for application main arguments

    XMLWordPrintableJSON

Details

    • New Feature
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 2.1
    • Core
    • None

    Description

      As a user I want to use the following expression in configuration files:

      If my static void main String[] arguments are:
      --file foo.txt --verbose -x bar

      I should be able to say:

      • ${main:0} -> --file
      • ${main:1} -> foo.txt
      • ${main:2} -> --verbose
      • ${main:3} -> -x
      • ${main:4} -> bar
      • ${main:--file} -> foo.txt
      • ${main:-x} -> bar
      • ${main:bar} -> null

      For this to work, I have to call:

      import org.apache.logging.log4j.core.lookup.MapLookup;
      
      public static void main(String args[]) {
        //...
        MapLookup.setMainArguments(args);
        //...
      }
      

      Attachments

        1. mainlookup.diff
          12 kB
          Gary D. Gregory

        Activity

          People

            ggregory Gary D. Gregory
            ggregory Gary D. Gregory
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: