Re: Set the file name based on command line args

2014-08-08 Thread Matt Sicker
Here's an idea for an addition to 2.1: use this? http://docs.oracle.com/javase/6/docs/platform/jvmti/jvmti.html On 8 August 2014 20:54, Remko Popma wrote: > > > On 2014/08/09, at 10:36, Gary Gregory wrote: > > > >> On Fri, Aug 8, 2014 at 9:19 PM, Remko Popma > wrote: > >> > >> It would have b

Re: Set the file name based on command line args

2014-08-08 Thread Remko Popma
> On 2014/08/09, at 10:36, Gary Gregory wrote: > >> On Fri, Aug 8, 2014 at 9:19 PM, Remko Popma wrote: >> >> It would have been nice to have a fully automatic solution, and it's too >> bad that the JMX idea doesn't work, but bringing in new dependencies for >> this seems a bit overkill to me..

Re: Set the file name based on command line args

2014-08-08 Thread Gary Gregory
On Fri, Aug 8, 2014 at 9:19 PM, Remko Popma wrote: > It would have been nice to have a fully automatic solution, and it's too > bad that the JMX idea doesn't work, but bringing in new dependencies for > this seems a bit overkill to me... > Well, the JMX works to pickup JVM arguments but not main

Re: how to change logging level for a class at runtime [I]

2014-08-08 Thread Matt Sicker
Is this not what you're looking for? http://logging.apache.org/log4j/2.x/log4j-core/apidocs/org/apache/logging/log4j/core/jmx/LoggerConfigAdminMBean.html On 6 August 2014 22:44, Matt Sicker wrote: > I may take a look at this soon as I've been getting into JMX lately at > work in order to autom

Re: Set the file name based on command line args

2014-08-08 Thread Remko Popma
It would have been nice to have a fully automatic solution, and it's too bad that the JMX idea doesn't work, but bringing in new dependencies for this seems a bit overkill to me... I actually think Gary's solution to ask the user to add one line of code will be hard to beat for simplicity and e

Re: Multiple configuration files?

2014-08-08 Thread Remko Popma
Do applications A and B run in separate processes, or does B call some function in A without starting a new process for A? Log4j initializes only once in a given process. If A and B are in separate processes they can have separate configurations. If they run in the same process, they'll share

Re: Multiple configuration files?

2014-08-08 Thread Matt Sicker
Only one file is used. If you want to combine multiple ones, you could use XInclude or create a custom ConfigurationFactory. On 8 August 2014 13:28, Arwen Pond wrote: > I have multiple applications that use log4j. Some depend on others. For > example application A can be run independently and

Re: Set the file name based on command line args

2014-08-08 Thread Matt Sicker
I was thinking it would be easier to create a main() method wrapper or use byte code weaving to automatically wrap it. However, I realized that this wouldn't be useful for applications running in server containers like Tomcat without modifying that source. On 8 August 2014 07:56, Remko Popma wro

Multiple configuration files?

2014-08-08 Thread Arwen Pond
I have multiple applications that use log4j. Some depend on others. For example application A can be run independently and has a log4j config file under src/main/resources/log4j2.xml. Application B invokes application A but it has a different log4j config file in its resource directory. When

Re: Set the file name based on command line args

2014-08-08 Thread Remko Popma
Ouch! On Fri, Aug 8, 2014 at 9:24 PM, Gary Gregory wrote: > It's worse than that, the JMX look up does not provide access to the main > args. The other lookup I created and attached to the jira needs to be > initialized by the user. > > Gary > > > On Fri, Aug 8, 2014 at 7:41 AM, Remko Popma wr

Re: Set the file name based on command line args

2014-08-08 Thread Gary Gregory
It's worse than that, the JMX look up does not provide access to the main args. The other lookup I created and attached to the jira needs to be initialized by the user. Gary On Fri, Aug 8, 2014 at 7:41 AM, Remko Popma wrote: > Note that log4j will only invoke this logic if the application has

Re: Set the file name based on command line args

2014-08-08 Thread Remko Popma
Note that log4j will only invoke this logic if the application has a lookup of the form ${main:} in its configuration. In environments without JMX the app may even need to explicitly initialize the main arguments map. This doesn't happen without being requested by the app, so I don't share th

Re: Set the file name based on command line args

2014-08-08 Thread Mikael Ståldal
To me, it seems conceptually wrong for a library (like Log4j) to read command line arguments behind the scenes without involvement from the application. Command line arguments are for the application to parse. System properties is the proper way to configure a library without involvement from the