You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Paul Holding <pa...@pholding.co.uk> on 2012/04/12 14:59:01 UTC

[logging] Specify the Log4J configuration file from commons-logging.properties

Is it possible to specify the name of the Log4J configuration file from
within the commons-logging.properties file?

In the Commons Logging user guide it suggests that this can be done by
setting the "log4j.configuration" parameter in the
commons-logging.properties file and that a default of log4j.properties will
be used if not specified.

I have tried setting "log4j.configuration=log4j-myapp.properties" in
commons-logging.properties however Log4J throws an error saying that it
hasn't been configured. The only way I can specify the name of the Log4J
configuration file seems be using the -Dlog4j.configuration=<your_file> at
the command line or using System.setProperty("log4j.configuration",
"<your_file>");

Have I misinterpreted the text in the Commons Logging user guide regarding
Log4J or is there something I'm missing?

Re: [logging] Specify the Log4J configuration file from commons-logging.properties

Posted by Konstantin Kolinko <kn...@gmail.com>.
2012/4/12 Paul Holding <pa...@pholding.co.uk>:
> Is it possible to specify the name of the Log4J configuration file from
> within the commons-logging.properties file?
>
> In the Commons Logging user guide it suggests that this can be done by
> setting the "log4j.configuration" parameter in the
> commons-logging.properties file and that a default of log4j.properties will
> be used if not specified.
>
> I have tried setting "log4j.configuration=log4j-myapp.properties" in
> commons-logging.properties however Log4J throws an error saying that it
> hasn't been configured. The only way I can specify the name of the Log4J
> configuration file seems be using the -Dlog4j.configuration=<your_file> at
> the command line or using System.setProperty("log4j.configuration",
> "<your_file>");
>
> Have I misinterpreted the text in the Commons Logging user guide regarding
> Log4J or is there something I'm missing?

The user guide (1.1.1) says literally:
"log4j.configuration=log4j.properties Use this system property to
specify the name of a Log4J configuration file."

Nowhere it says that commons-logging.properties file has any influence
on the system properties.


So, I disagree with Christian.

I'd say it is Log4J matter how it finds its own configuration file.
>From responsibilities point of view it has nothing to do with Commons
Logging. (Just guessing, without looking at the sources).

The rest of setting mentioned in that section ("log4j.rootCategory"
and below)  are set in log4j.properties file.  This explains for me
the words written above the options list (note the "and"):

"Configure Log4J using system properties and/or a properties file:" (...)


[1] http://commons.apache.org/logging/commons-logging-1.1.1/guide.html#Configuring%20Log4J

Best regards,
Konstantin Kolinko

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


Re: [logging] Specify the Log4J configuration file from commons-logging.properties

Posted by Christian Grobmeier <gr...@gmail.com>.
Hello Paul,

On Thu, Apr 12, 2012 at 2:59 PM, Paul Holding <pa...@pholding.co.uk> wrote:
> Is it possible to specify the name of the Log4J configuration file from
> within the commons-logging.properties file?

it should be possible, say the docs.

> I have tried setting "log4j.configuration=log4j-myapp.properties" in
> commons-logging.properties however Log4J throws an error saying that it
> hasn't been configured. The only way I can specify the name of the Log4J
> configuration file seems be using the -Dlog4j.configuration=<your_file> at
> the command line or using System.setProperty("log4j.configuration",
> "<your_file>");

Can you tell us about your folder structure (where do your files
reside)? It might help to look at this issue a bit more in detail.

> Have I misinterpreted the text in the Commons Logging user guide regarding
> Log4J or is there something I'm missing?

I just read the docs, I would have done it like you have.

Cheers
Christian



-- 
http://www.grobmeier.de
https://www.timeandbill.de

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