Set the log level based on command line args

2014-08-06 Thread Arwen Pond
I am investigating migrating from log4j 1 to log4j 2. A pattern that I have in many of my applications is setting the log level based on command line arguments. So if the -v (verbose) option is passed I set the log level to Info. The default is set to warn. if (line.hasOption("v")) {

RE: Set the log level based on command line args

2014-08-06 Thread Arwen Pond
But I see duplicated lines in the output. INFO [main]: Hello World 11:36:18.191 [main] INFO verbose - Hello World What am I doing wrong? Thanks, Arwen -Original Message----- From: Arwen Pond Sent: Wednesday, August 06, 2014 10:42 AM To: log4j-user@logging.apache.org Subject: Set the log level b

RE: Set the log level based on command line args

2014-08-06 Thread Arwen Pond
Do you have to specify a root logger in the configuration? additivity="false" solved my issue. Thanks. -Original Message- From: Ralph Goers [mailto:ralph.go...@dslextreme.com] Sent: Wednesday, August 06, 2014 1:17 PM To: Log4J Users List Subject: Re: Set the log level based on command l

Set the file name based on command line args

2014-08-06 Thread Arwen Pond
My application takes a parameter where the user can specify the log file. I'd like to pass this parameter to the Logger which uses a FileAppender. I am not sure how to do this in log4j 2. Thanks, Arwen This electronic mail message contains information that (a) is or may be CONFIDENTIAL, PROP

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: Multiple configuration files?

2014-08-11 Thread Arwen Pond
have separate configurations. If they run in the same process, they'll share a config. Which config file is used depends on your classpath and system properties when you started that process. Sent from my iPhone > On 2014/08/09, at 3:28, Arwen Pond wrote: > > I have multiple app