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

Main Arguments Lookup not working

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.1
    • Fix Version/s: 2.4
    • Component/s: Lookups
    • Labels:
      None
    • Environment:

      Windows 7 x64, Java Batch Application

      Description

      It is not possible to use the Main Arguments Lookup in the current version. The "main" prefix is not present in the corresponding Interpolator object and thus the resolution of the variable is not working as advertised in the documentation, e.g. using the following variable in the log4j2.xml:

      ${main:0}

      As far as I can tell, the problem seems to stem from the PluginManger.collectPlugins-Method that does not acknowledge the existence of the Main Arguments Lookup.

      I'm following the documentation on the website with the following sample log4j2.xml:

      <File name="GLOBAL" fileName="${env:DATA_DIR}/log/${env:APP_NAME}.log" >
         <PatternLayout pattern="%m%n" header="File: ${main:0}" />
          ...
      

      ...and following code in my application:

      public static void main(String[] args) {
          MapLookup.setMainArguments(args);
          ...
      

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              johannes.siebel@debeka.de Johannes Siebel
            • Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: