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

Add lookup for application main arguments

    Details

    • Type: New Feature
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 2.1
    • Component/s: Core
    • Labels:
      None
    • Environment:

      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

          Activity

            People

            • Assignee:
              garydgregory Gary Gregory
              Reporter:
              garydgregory Gary Gregory
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: