You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-user@logging.apache.org by Arwen Pond <ap...@book.com> on 2014/08/08 20:28:05 UTC

Multiple configuration files?

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 there are multiple  log4j2.xml files in the path how are they used/found?  Are they additive?  Does it just use the first one it finds?

Thanks,
Arwen



This electronic mail message contains information that (a) is or 
may be CONFIDENTIAL, PROPRIETARY IN NATURE, OR OTHERWISE 
PROTECTED 
BY LAW FROM DISCLOSURE, and (b) is intended only for the use of 
the addressee(s) named herein.  If you are not an intended 
recipient, please contact the sender immediately and take the 
steps necessary to delete the message completely from your 
computer system.

Not Intended as a Substitute for a Writing: Notwithstanding the 
Uniform Electronic Transaction Act or any other law of similar 
effect, absent an express statement to the contrary, this e-mail 
message, its contents, and any attachments hereto are not 
intended 
to represent an offer or acceptance to enter into a contract and 
are not otherwise intended to bind this sender, 
barnesandnoble.com 
llc, barnesandnoble.com inc. or any other person or entity.

Re: Multiple configuration files?

Posted by Remko Popma <re...@gmail.com>.
In your app, you can execute
System.out.println(getClass().getResource("/log4j2.xml"));
(assuming that the config file is in the classpath).

Also, if you set <Configuration status="trace" ...
in your log4j2 config file it will print the location of the config file that is used. 

Sent from my iPhone

> On 2014/08/12, at 1:24, Arwen Pond <ap...@book.com> wrote:
> 
> B calls A without setting a new process and passes the logger object to A.  It seems to me that both files will be on the classpath (lib directory).  How do I know which one it will find first?
> 
> -----Original Message-----
> From: Remko Popma [mailto:remko.popma@gmail.com] 
> Sent: Friday, August 08, 2014 5:58 PM
> To: Log4J Users List
> Subject: Re: Multiple configuration files?
> 
> 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 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 <ap...@book.com> wrote:
>> 
>> 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 there are multiple  log4j2.xml files in the path how are they used/found?  Are they additive?  Does it just use the first one it finds?
>> 
>> Thanks,
>> Arwen
>> 
>> 
>> 
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org


RE: Multiple configuration files?

Posted by Arwen Pond <ap...@book.com>.
B calls A without setting a new process and passes the logger object to A.  It seems to me that both files will be on the classpath (lib directory).  How do I know which one it will find first?

-----Original Message-----
From: Remko Popma [mailto:remko.popma@gmail.com] 
Sent: Friday, August 08, 2014 5:58 PM
To: Log4J Users List
Subject: Re: Multiple configuration files?

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 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 <ap...@book.com> wrote:
> 
> 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 there are multiple  log4j2.xml files in the path how are they used/found?  Are they additive?  Does it just use the first one it finds?
> 
> Thanks,
> Arwen
> 
> 
> 
> This electronic mail message contains information that (a) is or may 
> be CONFIDENTIAL, PROPRIETARY IN NATURE, OR OTHERWISE PROTECTED BY LAW 
> FROM DISCLOSURE, and (b) is intended only for the use of the 
> addressee(s) named herein.  If you are not an intended recipient, 
> please contact the sender immediately and take the steps necessary to 
> delete the message completely from your computer system.
> 
> Not Intended as a Substitute for a Writing: Notwithstanding the 
> Uniform Electronic Transaction Act or any other law of similar effect, 
> absent an express statement to the contrary, this e-mail message, its 
> contents, and any attachments hereto are not intended to represent an 
> offer or acceptance to enter into a contract and are not otherwise 
> intended to bind this sender, barnesandnoble.com llc, 
> barnesandnoble.com inc. or any other person or entity.

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org


This electronic mail message contains information that (a) is or 
may be CONFIDENTIAL, PROPRIETARY IN NATURE, OR OTHERWISE 
PROTECTED 
BY LAW FROM DISCLOSURE, and (b) is intended only for the use of 
the addressee(s) named herein.  If you are not an intended 
recipient, please contact the sender immediately and take the 
steps necessary to delete the message completely from your 
computer system.

Not Intended as a Substitute for a Writing: Notwithstanding the 
Uniform Electronic Transaction Act or any other law of similar 
effect, absent an express statement to the contrary, this e-mail 
message, its contents, and any attachments hereto are not 
intended 
to represent an offer or acceptance to enter into a contract and 
are not otherwise intended to bind this sender, 
barnesandnoble.com 
llc, barnesandnoble.com inc. or any other person or entity.

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org


Re: Multiple configuration files?

Posted by Remko Popma <re...@gmail.com>.
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 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 <ap...@book.com> wrote:
> 
> 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 there are multiple  log4j2.xml files in the path how are they used/found?  Are they additive?  Does it just use the first one it finds?
> 
> Thanks,
> Arwen
> 
> 
> 
> This electronic mail message contains information that (a) is or 
> may be CONFIDENTIAL, PROPRIETARY IN NATURE, OR OTHERWISE 
> PROTECTED 
> BY LAW FROM DISCLOSURE, and (b) is intended only for the use of 
> the addressee(s) named herein.  If you are not an intended 
> recipient, please contact the sender immediately and take the 
> steps necessary to delete the message completely from your 
> computer system.
> 
> Not Intended as a Substitute for a Writing: Notwithstanding the 
> Uniform Electronic Transaction Act or any other law of similar 
> effect, absent an express statement to the contrary, this e-mail 
> message, its contents, and any attachments hereto are not 
> intended 
> to represent an offer or acceptance to enter into a contract and 
> are not otherwise intended to bind this sender, 
> barnesandnoble.com 
> llc, barnesandnoble.com inc. or any other person or entity.

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org


Re: Multiple configuration files?

Posted by Matt Sicker <bo...@gmail.com>.
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 <ap...@book.com> wrote:

> 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 there are multiple  log4j2.xml files in the path how are they
> used/found?  Are they additive?  Does it just use the first one it finds?
>
> Thanks,
> Arwen
>
>
>
> This electronic mail message contains information that (a) is or
> may be CONFIDENTIAL, PROPRIETARY IN NATURE, OR OTHERWISE
> PROTECTED
> BY LAW FROM DISCLOSURE, and (b) is intended only for the use of
> the addressee(s) named herein.  If you are not an intended
> recipient, please contact the sender immediately and take the
> steps necessary to delete the message completely from your
> computer system.
>
> Not Intended as a Substitute for a Writing: Notwithstanding the
> Uniform Electronic Transaction Act or any other law of similar
> effect, absent an express statement to the contrary, this e-mail
> message, its contents, and any attachments hereto are not
> intended
> to represent an offer or acceptance to enter into a contract and
> are not otherwise intended to bind this sender,
> barnesandnoble.com
> llc, barnesandnoble.com inc. or any other person or entity.




-- 
Matt Sicker <bo...@gmail.com>

Re: Multiple configuration files?

Posted by Ralph Goers <ra...@dslextreme.com>.
Arwen,

Please note that the paragraphs below indicating the message is proprietary cannot apply to this message. This is a public mailing list and this message will be archived forever in at least 3 other places not under the control of the Apache Software Foundation.  Please make sure to remove these from future messages.

Ralph

On Aug 8, 2014, at 11:28 AM, Arwen Pond <ap...@book.com> wrote:

> 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 there are multiple  log4j2.xml files in the path how are they used/found?  Are they additive?  Does it just use the first one it finds?
> 
> Thanks,
> Arwen
> 
> 
> 
> This electronic mail message contains information that (a) is or
> may be CONFIDENTIAL, PROPRIETARY IN NATURE, OR OTHERWISE
> PROTECTED
> BY LAW FROM DISCLOSURE, and (b) is intended only for the use of
> the addressee(s) named herein.  If you are not an intended
> recipient, please contact the sender immediately and take the
> steps necessary to delete the message completely from your
> computer system.
> 
> Not Intended as a Substitute for a Writing: Notwithstanding the
> Uniform Electronic Transaction Act or any other law of similar
> effect, absent an express statement to the contrary, this e-mail
> message, its contents, and any attachments hereto are not
> intended
> to represent an offer or acceptance to enter into a contract and
> are not otherwise intended to bind this sender,
> barnesandnoble.com
> llc, barnesandnoble.com inc. or any other person or entity.


---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org