Discussion:
[jira] [Created] (LOG4J2-771) Add lookup for application main arguments
Gary Gregory (JIRA)
2014-08-07 17:02:12 UTC
Permalink
Gary Gregory created LOG4J2-771:
-----------------------------------

Summary: Add lookup for application main arguments
Key: LOG4J2-771
URL: https://issues.apache.org/jira/browse/LOG4J2-771
Project: Log4j 2
Issue Type: New Feature
Components: Core
Environment: Apache Maven 3.2.2 (45f7c06d68e745d05611f7fd14efb6594181933e; 2014-06-17T09:51:42-04:00)
Maven home: C:\Java\apache-maven-3.2.2
Java version: 1.7.0_60, vendor: Oracle Corporation
Java home: C:\Program Files\Java\jdk1.7.0_60\jre
Default locale: en_US, platform encoding: Cp1252
OS name: "windows 7", version: "6.1", arch: "amd64", family: "windows"
Reporter: Gary Gregory
Assignee: Gary Gregory


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:
{code:java}
public static void main(String args[]) {
//...
MapLookup.setMainArguments(args);
//...
}
{code}



--
This message was sent by Atlassian JIRA
(v6.2#6252)
Gary Gregory (JIRA)
2014-08-07 17:04:11 UTC
Permalink
[ https://issues.apache.org/jira/browse/LOG4J2-771?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Gary Gregory updated LOG4J2-771:
--------------------------------

Attachment: mainlookup.diff

Proposal and some experiments:
# user sets main args
# JMX
# Stack
Post by Gary Gregory (JIRA)
Add lookup for application main arguments
-----------------------------------------
Key: LOG4J2-771
URL: https://issues.apache.org/jira/browse/LOG4J2-771
Project: Log4j 2
Issue Type: New Feature
Components: Core
Environment: Apache Maven 3.2.2 (45f7c06d68e745d05611f7fd14efb6594181933e; 2014-06-17T09:51:42-04:00)
Maven home: C:\Java\apache-maven-3.2.2
Java version: 1.7.0_60, vendor: Oracle Corporation
Java home: C:\Program Files\Java\jdk1.7.0_60\jre
Default locale: en_US, platform encoding: Cp1252
OS name: "windows 7", version: "6.1", arch: "amd64", family: "windows"
Reporter: Gary Gregory
Assignee: Gary Gregory
Attachments: mainlookup.diff
--file foo.txt --verbose -x bar
- ${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
{code:java}
public static void main(String args[]) {
//...
MapLookup.setMainArguments(args);
//...
}
{code}
--
This message was sent by Atlassian JIRA
(v6.2#6252)
Remko Popma (JIRA)
2014-08-08 01:02:22 UTC
Permalink
[ https://issues.apache.org/jira/browse/LOG4J2-771?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14090121#comment-14090121 ]

Remko Popma commented on LOG4J2-771:
------------------------------------

I haven't actually tried this, but just looking at the javadoc for [StackFrame.getArgumentValues()|http://docs.oracle.com/javase/7/docs/jdk/api/jpda/jdi/com/sun/jdi/StackFrame.html#getArgumentValues%28%29], it looks like it is only possible to get stack frame argument values while the thread is suspended.
Post by Gary Gregory (JIRA)
Add lookup for application main arguments
-----------------------------------------
Key: LOG4J2-771
URL: https://issues.apache.org/jira/browse/LOG4J2-771
Project: Log4j 2
Issue Type: New Feature
Components: Core
Environment: Apache Maven 3.2.2 (45f7c06d68e745d05611f7fd14efb6594181933e; 2014-06-17T09:51:42-04:00)
Maven home: C:\Java\apache-maven-3.2.2
Java version: 1.7.0_60, vendor: Oracle Corporation
Java home: C:\Program Files\Java\jdk1.7.0_60\jre
Default locale: en_US, platform encoding: Cp1252
OS name: "windows 7", version: "6.1", arch: "amd64", family: "windows"
Reporter: Gary Gregory
Assignee: Gary Gregory
Attachments: mainlookup.diff
--file foo.txt --verbose -x bar
- ${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
{code:java}
public static void main(String args[]) {
//...
MapLookup.setMainArguments(args);
//...
}
{code}
--
This message was sent by Atlassian JIRA
(v6.2#6252)
Gary Gregory (JIRA)
2014-08-20 13:36:25 UTC
Permalink
[ https://issues.apache.org/jira/browse/LOG4J2-771?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Gary Gregory resolved LOG4J2-771.
---------------------------------

Resolution: Fixed
Fix Version/s: 2.1
Post by Gary Gregory (JIRA)
Add lookup for application main arguments
-----------------------------------------
Key: LOG4J2-771
URL: https://issues.apache.org/jira/browse/LOG4J2-771
Project: Log4j 2
Issue Type: New Feature
Components: Core
Environment: Apache Maven 3.2.2 (45f7c06d68e745d05611f7fd14efb6594181933e; 2014-06-17T09:51:42-04:00)
Maven home: C:\Java\apache-maven-3.2.2
Java version: 1.7.0_60, vendor: Oracle Corporation
Java home: C:\Program Files\Java\jdk1.7.0_60\jre
Default locale: en_US, platform encoding: Cp1252
OS name: "windows 7", version: "6.1", arch: "amd64", family: "windows"
Reporter: Gary Gregory
Assignee: Gary Gregory
Fix For: 2.1
Attachments: mainlookup.diff
--file foo.txt --verbose -x bar
- ${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
{code:java}
public static void main(String args[]) {
//...
MapLookup.setMainArguments(args);
//...
}
{code}
--
This message was sent by Atlassian JIRA
(v6.2#6252)
Matt Sicker (JIRA)
2014-08-28 03:35:58 UTC
Permalink
[ https://issues.apache.org/jira/browse/LOG4J2-771?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14113293#comment-14113293 ]

Matt Sicker commented on LOG4J2-771:
------------------------------------

Do you wanna close this, or is there still work to be done on this?
Post by Gary Gregory (JIRA)
Add lookup for application main arguments
-----------------------------------------
Key: LOG4J2-771
URL: https://issues.apache.org/jira/browse/LOG4J2-771
Project: Log4j 2
Issue Type: New Feature
Components: Core
Environment: Apache Maven 3.2.2 (45f7c06d68e745d05611f7fd14efb6594181933e; 2014-06-17T09:51:42-04:00)
Maven home: C:\Java\apache-maven-3.2.2
Java version: 1.7.0_60, vendor: Oracle Corporation
Java home: C:\Program Files\Java\jdk1.7.0_60\jre
Default locale: en_US, platform encoding: Cp1252
OS name: "windows 7", version: "6.1", arch: "amd64", family: "windows"
Reporter: Gary Gregory
Assignee: Gary Gregory
Fix For: 2.1
Attachments: mainlookup.diff
--file foo.txt --verbose -x bar
- ${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
{code:java}
public static void main(String args[]) {
//...
MapLookup.setMainArguments(args);
//...
}
{code}
--
This message was sent by Atlassian JIRA
(v6.2#6252)
Gary Gregory (JIRA)
2014-09-27 13:47:34 UTC
Permalink
[ https://issues.apache.org/jira/browse/LOG4J2-771?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Gary Gregory updated LOG4J2-771:
--------------------------------
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:
{code:java}
import org.apache.logging.log4j.core.lookup.MapLookup;

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

was:
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:
{code:java}
public static void main(String args[]) {
//...
MapLookup.setMainArguments(args);
//...
}
{code}
Post by Gary Gregory (JIRA)
Add lookup for application main arguments
-----------------------------------------
Key: LOG4J2-771
URL: https://issues.apache.org/jira/browse/LOG4J2-771
Project: Log4j 2
Issue Type: New Feature
Components: Core
Environment: Apache Maven 3.2.2 (45f7c06d68e745d05611f7fd14efb6594181933e; 2014-06-17T09:51:42-04:00)
Maven home: C:\Java\apache-maven-3.2.2
Java version: 1.7.0_60, vendor: Oracle Corporation
Java home: C:\Program Files\Java\jdk1.7.0_60\jre
Default locale: en_US, platform encoding: Cp1252
OS name: "windows 7", version: "6.1", arch: "amd64", family: "windows"
Reporter: Gary Gregory
Assignee: Gary Gregory
Fix For: 2.1
Attachments: mainlookup.diff
--file foo.txt --verbose -x bar
- ${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
{code:java}
import org.apache.logging.log4j.core.lookup.MapLookup;
public static void main(String args[]) {
//...
MapLookup.setMainArguments(args);
//...
}
{code}
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)
Gary Gregory (JIRA)
2014-09-27 14:00:39 UTC
Permalink
[ https://issues.apache.org/jira/browse/LOG4J2-771?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Gary Gregory closed LOG4J2-771.
-------------------------------

Documentation added to the user manual.
Post by Gary Gregory (JIRA)
Add lookup for application main arguments
-----------------------------------------
Key: LOG4J2-771
URL: https://issues.apache.org/jira/browse/LOG4J2-771
Project: Log4j 2
Issue Type: New Feature
Components: Core
Environment: Apache Maven 3.2.2 (45f7c06d68e745d05611f7fd14efb6594181933e; 2014-06-17T09:51:42-04:00)
Maven home: C:\Java\apache-maven-3.2.2
Java version: 1.7.0_60, vendor: Oracle Corporation
Java home: C:\Program Files\Java\jdk1.7.0_60\jre
Default locale: en_US, platform encoding: Cp1252
OS name: "windows 7", version: "6.1", arch: "amd64", family: "windows"
Reporter: Gary Gregory
Assignee: Gary Gregory
Fix For: 2.1
Attachments: mainlookup.diff
--file foo.txt --verbose -x bar
- ${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
{code:java}
import org.apache.logging.log4j.core.lookup.MapLookup;
public static void main(String args[]) {
//...
MapLookup.setMainArguments(args);
//...
}
{code}
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)
Remko Popma (JIRA)
2014-09-27 14:10:35 UTC
Permalink
[ https://issues.apache.org/jira/browse/LOG4J2-771?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14150597#comment-14150597 ]

Remko Popma commented on LOG4J2-771:
------------------------------------

Nice! (Gentle reminder: you may also want an entry in the left-hand side navigation menu)
Post by Gary Gregory (JIRA)
Add lookup for application main arguments
-----------------------------------------
Key: LOG4J2-771
URL: https://issues.apache.org/jira/browse/LOG4J2-771
Project: Log4j 2
Issue Type: New Feature
Components: Core
Environment: Apache Maven 3.2.2 (45f7c06d68e745d05611f7fd14efb6594181933e; 2014-06-17T09:51:42-04:00)
Maven home: C:\Java\apache-maven-3.2.2
Java version: 1.7.0_60, vendor: Oracle Corporation
Java home: C:\Program Files\Java\jdk1.7.0_60\jre
Default locale: en_US, platform encoding: Cp1252
OS name: "windows 7", version: "6.1", arch: "amd64", family: "windows"
Reporter: Gary Gregory
Assignee: Gary Gregory
Fix For: 2.1
Attachments: mainlookup.diff
--file foo.txt --verbose -x bar
- ${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
{code:java}
import org.apache.logging.log4j.core.lookup.MapLookup;
public static void main(String args[]) {
//...
MapLookup.setMainArguments(args);
//...
}
{code}
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Loading...