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 Marcos <ma...@softingsystems.com.br> on 2007/04/23 19:05:55 UTC

Log4J XML configuration file for a library on classpath

Hi all,

I'm reading for a couple of hours the log4j documentation and I think 
I'm missing something .... Below the scenario.:

- I have an application that uses a library (quartz.jar), this library 
uses the commons logging facility to log its messages :-)
When I put the log4j libraries (log4j-1.2.14.jar and log4jlogger.jar) on 
the classpath, the discovery process for the log4j.xml/ log4j.properties
is triggered for the library quartz.jar mentioned before, but no matter 
where I put the configuration files (log4j.xml/ log4j.properties) they are
never discovered and I end up with the following message.:

log4j: Trying to find [log4j.xml] using context classloader 
sun.misc.Launcher$AppClassLoader@a39137.
log4j: Trying to find [log4j.xml] using 
sun.misc.Launcher$AppClassLoader@a39137 class loader.
log4j: Trying to find [log4j.xml] using ClassLoader.getSystemResource().
log4j: Trying to find [log4j.properties] using context classloader 
sun.misc.Launcher$AppClassLoader@a39137.
log4j: Trying to find [log4j.properties] using 
sun.misc.Launcher$AppClassLoader@a39137 class loader.
log4j: Trying to find [log4j.properties] using 
ClassLoader.getSystemResource().
log4j: Could not find resource: [null].
log4j:WARN No appenders could be found for logger 
(org.quartz.core.QuartzScheduler).
log4j:WARN Please initialize the log4j system properly.

Q1. Could someone point me what's wrong or what should I read to 
overcome this message ?
Q2. Is possible to force the location for the configuration files 
(log4j.xml/ log4j.properties) through
       parameters passed to the VM ?

Thank you very much !!!

-- 
Marcos H. W.
Softing Systems
Systems Analyst
+55 11 38770360

/** 
 * @see https://jaxb2-commons.dev.java.net
 */

/**
 * "...Use the Force ...;-)" */
 *
 * @see http://www.gentoo.org/
 */


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


Re: Log4J XML configuration file for a library on classpath

Posted by Marcos <ma...@softingsystems.com.br>.
James Stauffer escreveu:

> Generally adding log4j.xml to a directory in the classpath will work.
> Did you try that?

Hi,

First of all thanks for answer :-)
I've added the log4j.xml to the classpath and it worked :-) as you 
recommended :-), but I made it in a "not so elegant way", I mean I've 
added the file below the folder "build\classes" 
(build\classes\log4j.xml) in my IDE.

I found a tip on the manual at 
http://logging.apache.org/log4j/docs/manual.html that states.:

"...Set the resource string variable to the value of the 
log4j.configuration system property. The preferred way to specify the 
default initialization file is through the log4j.configuration system 
property. In case the system property log4j.configuration is not 
defined, then set the string variable resource to its default value 
"log4j.properties"...."

So my own the question.:

>> Q2. Is possible to force the location for the configuration files
>> (log4j.xml/ log4j.properties) through
>>        parameters passed to the VM ?
>
Would be answered as "yes" :-)
You have just to pass the following args to the VM 
"-Dlog4j.configuration=path/to/your/configuration/file/log4j.xml"

Thank you very much !!!

-- 
Marcos H. W.
Softing Systems
Systems Analyst
+55 11 38770360

/** 
 * @see https://jaxb2-commons.dev.java.net
 */

/**
 * "...Use the Force ...;-)" */
 *
 * @see http://www.gentoo.org/
 */



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


Re: Log4J XML configuration file for a library on classpath

Posted by James Stauffer <st...@gmail.com>.
Generally adding log4j.xml to a directory in the classpath will work.
Did you try that?

On 4/23/07, Marcos <ma...@softingsystems.com.br> wrote:
> Hi all,
>
> I'm reading for a couple of hours the log4j documentation and I think
> I'm missing something .... Below the scenario.:
>
> - I have an application that uses a library (quartz.jar), this library
> uses the commons logging facility to log its messages :-)
> When I put the log4j libraries (log4j-1.2.14.jar and log4jlogger.jar) on
> the classpath, the discovery process for the log4j.xml/ log4j.properties
> is triggered for the library quartz.jar mentioned before, but no matter
> where I put the configuration files (log4j.xml/ log4j.properties) they are
> never discovered and I end up with the following message.:
>
> log4j: Trying to find [log4j.xml] using context classloader
> sun.misc.Launcher$AppClassLoader@a39137.
> log4j: Trying to find [log4j.xml] using
> sun.misc.Launcher$AppClassLoader@a39137 class loader.
> log4j: Trying to find [log4j.xml] using ClassLoader.getSystemResource().
> log4j: Trying to find [log4j.properties] using context classloader
> sun.misc.Launcher$AppClassLoader@a39137.
> log4j: Trying to find [log4j.properties] using
> sun.misc.Launcher$AppClassLoader@a39137 class loader.
> log4j: Trying to find [log4j.properties] using
> ClassLoader.getSystemResource().
> log4j: Could not find resource: [null].
> log4j:WARN No appenders could be found for logger
> (org.quartz.core.QuartzScheduler).
> log4j:WARN Please initialize the log4j system properly.
>
> Q1. Could someone point me what's wrong or what should I read to
> overcome this message ?
> Q2. Is possible to force the location for the configuration files
> (log4j.xml/ log4j.properties) through
>        parameters passed to the VM ?
>
> Thank you very much !!!
>
> --
> Marcos H. W.
> Softing Systems
> Systems Analyst
> +55 11 38770360
>
> /**
>  * @see https://jaxb2-commons.dev.java.net
>  */
>
> /**
>  * "...Use the Force ...;-)" */
>  *
>  * @see http://www.gentoo.org/
>  */
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
> For additional commands, e-mail: log4j-user-help@logging.apache.org
>
>


-- 
James Stauffer        http://www.geocities.com/stauffer_james/
Are you good? Take the test at http://www.livingwaters.com/good/

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