Re: Default configuration not seeing my appender

2003-03-28 Thread Erik Price


Erik Price wrote:
Hi,

I'm having trouble with my first excursion into Log4J.  I'm using an Ant 
script to compile my project and then call JUnit tests.  I have no 
logging statements in the JUnit tests, but I do have logging statements 
in my application.  I have confirmed (via System.out.print) that there 
is a System Property whose key is log4j.configuration, and that this 
is a valid file on my Win2k/Cygwin filesystem, and the contents of that 
file are as follows:
[...]

Does anyone see some problem with my log4j.configuration Properties file 
that would cause the Default Initialization to fail with the message 
that it can't find an Appender?  It works fine when my Properties file 
is in my classpath, but according to the docs, this should work fine if 
I am passing in the log4j.configuration System Property, which I am.
Forgive me for responding to my own post, but I think I've found the 
answer and hopefully this might help someone else down the road. 
However, if I'm mistaken or someone can confirm for me that I'm -not- 
mistaken, that would be awesome.

It seems that it had nothing to do with my log4j.properties file, which 
makes sense since it worked fine if I just let the default 
initialization pick it up from the class loader's path (i.e., by not 
specifying a log4j.configuration System Property).  However, 
apparently on Windows a file path does not translate directly to a URL. 
 The short manual on the Log4J site explicitly states:

  quote
2. 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.
3. Attempt to convert the resource variable to a URL.
  /quote
What worked for me was changing the value of the log4j.configuration 
System Property from a simple Windows file path to file:// + a simple 
Windows file path.

Is this the way it's supposed to work?  I just want to make sure so that 
I don't continue to develop under a mistaken impression, because the 
above evaluates to an invalid URL (file://D:\User Profiles\eprice\My 
Documents\dev\java\projectname).

I can use Ant to manipulate that string to use proper (Unix/Java-style) 
path format, and will do so if anyone can clear me up on this.

Thanks,

Erik

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


RE: Default configuration not seeing my appender

2003-03-28 Thread Shapira, Yoav

Howdy,
Personally, I've encountered nothing but grief when attempting to work
with windows-style file paths.  (Or more general resource paths, e.g.
for JNDI).  I don't know if this is a shortcoming of java the language,
the File/URI/URL class implementations, the windows file system, or what
else, but I don't care.  Save yourself time and hassle and work
exclusively with unix style paths.

Yoav Shapira
Millennium ChemInformatics


-Original Message-
From: Erik Price [mailto:[EMAIL PROTECTED]
Sent: Friday, March 28, 2003 11:04 AM
To: Log4J Users List
Subject: Re: Default configuration not seeing my appender



Erik Price wrote:
 Hi,

 I'm having trouble with my first excursion into Log4J.  I'm using an
Ant
 script to compile my project and then call JUnit tests.  I have no
 logging statements in the JUnit tests, but I do have logging
statements
 in my application.  I have confirmed (via System.out.print) that
there
 is a System Property whose key is log4j.configuration, and that
this
 is a valid file on my Win2k/Cygwin filesystem, and the contents of
that
 file are as follows:

[...]

 Does anyone see some problem with my log4j.configuration Properties
file
 that would cause the Default Initialization to fail with the message
 that it can't find an Appender?  It works fine when my Properties
file
 is in my classpath, but according to the docs, this should work fine
if
 I am passing in the log4j.configuration System Property, which I am.

Forgive me for responding to my own post, but I think I've found the
answer and hopefully this might help someone else down the road.
However, if I'm mistaken or someone can confirm for me that I'm -not-
mistaken, that would be awesome.

It seems that it had nothing to do with my log4j.properties file, which
makes sense since it worked fine if I just let the default
initialization pick it up from the class loader's path (i.e., by not
specifying a log4j.configuration System Property).  However,
apparently on Windows a file path does not translate directly to a URL.
  The short manual on the Log4J site explicitly states:

   quote
 2. 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.

 3. Attempt to convert the resource variable to a URL.
   /quote

What worked for me was changing the value of the log4j.configuration
System Property from a simple Windows file path to file:// + a simple
Windows file path.

Is this the way it's supposed to work?  I just want to make sure so
that
I don't continue to develop under a mistaken impression, because the
above evaluates to an invalid URL (file://D:\User Profiles\eprice\My
Documents\dev\java\projectname).

I can use Ant to manipulate that string to use proper (Unix/Java-style)
path format, and will do so if anyone can clear me up on this.

Thanks,

Erik


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




This e-mail, including any attachments, is a confidential business communication, and 
may contain information that is confidential, proprietary and/or privileged.  This 
e-mail is intended only for the individual(s) to whom it is addressed, and may not be 
saved, copied, printed, disclosed or used by anyone else.  If you are not the(an) 
intended recipient, please immediately delete this e-mail from your computer system 
and notify the sender.  Thank you.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Default configuration not seeing my appender

2003-03-28 Thread Jacob Kjome
You really don't have to worry about it.  Ant understands both and Java 
understands mixed use of / and \ when using file:///.

BTW, you can also do relative paths like this and it will work for both 
UNIX and Windows...

file:../WEB-INF/log4j.xml

Jake

At 11:14 AM 3/28/2003 -0500, you wrote:


Shapira, Yoav wrote:
Howdy,
Personally, I've encountered nothing but grief when attempting to work
with windows-style file paths.  (Or more general resource paths, e.g.
for JNDI).  I don't know if this is a shortcoming of java the language,
the File/URI/URL class implementations, the windows file system, or what
else, but I don't care.  Save yourself time and hassle and work
exclusively with unix style paths.
Yoav,

Thanks for your thoughts.  I am kind of new to using File I/O on Windows 
with Java because formerly my only deployment was to a Linux box.  I am 
running Cygwin on Windows, but I believe that only provides me with the 
convenience of Unix-style file paths in a shell.  Do you know of a way 
that I can force Ant to use Unix-style file paths even though it is 
technically a Windows machine?  Perhaps I should ask on ant-user.

At least in my Java code I can use Unix/Java-style file paths.

Erik

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Re: Another Default configuration not seeing my appender Question

2003-03-28 Thread Mark R. Diggory
In the same directory as the build.xml (ant) and gui.xml (jelly) files 
I'm working with (thats why I'm trying to keep it relative).

I've tried using the classpath to add the log4j.xml file but Ant's java 
task screams:

 [java] CLASSPATH component C:\eclipse\workspace\project\log4j.xml: 
java.util.zip.ZipException: error in opening zip file

But, I'm sure thats an issue that should be taken up on thier lists or Sun.

-Mark

Ceki Gülcü wrote:
Hi Mark,

Where is the log4j.xml file located?

At 01:04 PM 3/28/2003 -0500, you wrote:

Here's a similar question concerning an appenders error. I'm trying to 
launch a java program in Ant (Jelly) that uses log4j for logging. I do 
this via a target that looks somewhat like.

target depends=compile name=gui
  java classname=org.apache.commons.jelly.Jelly fork=true 
classpathref=classpath
 arg value=gui.xml/
 sysproperty key=log4j.configuration value=log4j.xml/
  /java
/target

I keep getting the errors that look like:

Buildfile: build.xml

gui:
 [java] log4j:WARN No appenders could be found for logger 
(org.apache.commons.jelly.parser.XMLParser).
 [java] log4j:WARN Please initialize the log4j system properly.

My config file looks like:

?xml version=1.0 encoding=UTF-8?
!DOCTYPE log4j:configuration SYSTEM log4j.dtd
log4j:configuration debug=true
   appender name=CONSOLE class=org.apache.log4j.ConsoleAppender
  layout class=org.apache.log4j.PatternLayout
 param name=ConversionPattern value=%-5p  - %m\n/
  /layout
   /appender
   logger name=org additivity=false
  level value=debug/
  appender-ref ref=CONSOLE/
   /logger
   root
  priority value=debug/
  appender-ref ref=CONSOLE/
   /root
/log4j:configuration
Is there something obvious that I'm missing here?

-Mark Diggory

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
--
Ceki
-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]