Re: Help on XML config files

2001-12-17 Thread Ceki Gulcu


The property name you are looking for is log4j.configuration.
Invoke your program as 

java -classpath `local_jars` -Dlog4j.configuration=log4j.xml -Dlog4j.debug test

HTH, Ceki

ps: Your XML file was never read. 

At 14:19 17.12.2001 -0800, you wrote:
I hope I'm posting this right!

I've dorked around all day trying to get an xml configuration file working.
It complains about not finding a root element.  The documentation on the XML
configuration file is weak at best.  (Only a few examples, all the same.)

I want to send output to stdout and to a log file (simple enough).

Below is what I get.  Any help would be greatly appreciated!

--Mark


Here's what I get:

root_ptkomni.printrak.com# java -classpath `local_jars`
-Dlog4jConfigFile=log4j.xml -Dlog4j.debug test
log4j: Trying to find [log4j.properties] using
sun.misc.Launcher$AppClassLoader@80045e0 class loader.
log4j: Using URL
[jar:file:/ActiveFiles/omnitrak_server/jboss/client/jbossmq-client.jar!/log4
j.properties] for automatic log4j configuration.
log4j: Reading configuration from URL
jar:file:/ActiveFiles/omnitrak_server/jboss/client/jbossmq-client.jar!/log4j
.properties
log4j: Parsing for [root] with value=[ERROR, stdout].
log4j: Priority token is [ERROR].
log4j: Category root set to ERROR
log4j: Parsing appender named stdout.
log4j: Parsing layout options for stdout.
log4j: Setting property [conversionPattern] to [%5p [%t] (%F:%L) - %m%n].
log4j: End of parsing for stdout.
log4j: Parsed stdout options.
log4j: Finished configuring.
log4j: Could not find root category information. Is this OK?  -- HERE'S
MY PROBLEM
log4j: Finished configuring.
hello
test()
x:stuff
Done.
# cat log4j.xml
?xml version=1.0 encoding=UTF-8 ?
!DOCTYPE log4j:configuration SYSTEM log4j.dtd

log4j:configuration xmlns:log4j='http://jakarta.apache.org/log4j/'

appender name=stdout class=org.apache.log4j.ConsoleAppender
layout class=org.apache.log4j.PatternLayout
param name=ConversionPattern value=%d [%t] %-5p
%c - %m%n/
/layout
/appender

appender name=A1 class=org.apache.log4j.FileAppender
param name=File value=log4j.log/
layout class=org.apache.log4j.PatternLayout
param name=ConversionPattern value=%d [%t] %-5p
%c - %m%n/
/layout
/appender

root
priority value =debug /
appender-ref ref=stdout /
appender-ref ref=A1 /
/root

/log4j:configuration


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


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




RE: Help on XML config files

2001-12-17 Thread Mark Evans (Anaheim)

Thanks for your quick response.  For the most part, I really like the log4j
library.  And, when I run the program with -Dlog4j.configuration=log4j.xml
it does indeed work.  (I was able to do this prior to the email.)  However,
rather than doing the log4j default initialization with
-Dlog4j.configuration, I'd like to be able to specify the file to the
program and call the PropertyConfigurator.configure() passing it the file
name -- a system that works fine with the old style configuration files.

Here's the code.  Can I pass an XML file to
PropertyConfigurator.configure()?  Do you see something else I'm doing
wrong?

Thanks again,
Mark




import org.apache.log4j.*;
import java.io.File;

public class test {

static Category logger = Category.getInstance(test);

public test(String x) {
this();
System.out.println(x: + x);
}

public test() {
System.out.println(test());
}

public static void main(String args[]) {

// Initialize Log4J.
String logConfig = null;
String log4jConfigFile =
System.getProperty(log4jConfigFile, log4j.config);
if (new File(log4jConfigFile).exists()) {
PropertyConfigurator.configure(log4jConfigFile);
-- HERE'S THE CALL TO CONFIGURE
}
else {
// No configuration file.  Set it up manually.
PatternLayout pl = new PatternLayout(%d [%t] %-5p
%c - %m%n);
ConsoleAppender ca = new ConsoleAppender(pl);
BasicConfigurator.configure(ca);
logger.setPriority(org.apache.log4j.Priority.DEBUG);
logger.warn(Log4j configuration file \ +
log4jConfigFile + \ not found.  Using BasicConfigurator.);
}



logger.debug(main);
System.out.println(hello);

test t = new test(stuff);

System.out.println(Done.);
}
}

-Original Message-
From: Ceki Gulcu [mailto:[EMAIL PROTECTED]]
Sent: Monday, December 17, 2001 2:59 PM
To: Log4J Users List
Subject: Re: Help on XML config files



The property name you are looking for is log4j.configuration.
Invoke your program as 

java -classpath `local_jars` -Dlog4j.configuration=log4j.xml -Dlog4j.debug
test

HTH, Ceki

ps: Your XML file was never read. 

At 14:19 17.12.2001 -0800, you wrote:
I hope I'm posting this right!

I've dorked around all day trying to get an xml configuration file working.
It complains about not finding a root element.  The documentation on the
XML
configuration file is weak at best.  (Only a few examples, all the same.)

I want to send output to stdout and to a log file (simple enough).

Below is what I get.  Any help would be greatly appreciated!

--Mark


Here's what I get:

root_ptkomni.printrak.com# java -classpath `local_jars`
-Dlog4jConfigFile=log4j.xml -Dlog4j.debug test
log4j: Trying to find [log4j.properties] using
sun.misc.Launcher$AppClassLoader@80045e0 class loader.
log4j: Using URL
[jar:file:/ActiveFiles/omnitrak_server/jboss/client/jbossmq-client.jar!/log
4
j.properties] for automatic log4j configuration.
log4j: Reading configuration from URL
jar:file:/ActiveFiles/omnitrak_server/jboss/client/jbossmq-client.jar!/log4
j
.properties
log4j: Parsing for [root] with value=[ERROR, stdout].
log4j: Priority token is [ERROR].
log4j: Category root set to ERROR
log4j: Parsing appender named stdout.
log4j: Parsing layout options for stdout.
log4j: Setting property [conversionPattern] to [%5p [%t] (%F:%L) - %m%n].
log4j: End of parsing for stdout.
log4j: Parsed stdout options.
log4j: Finished configuring.
log4j: Could not find root category information. Is this OK?  --
HERE'S
MY PROBLEM
log4j: Finished configuring.
hello
test()
x:stuff
Done.
# cat log4j.xml
?xml version=1.0 encoding=UTF-8 ?
!DOCTYPE log4j:configuration SYSTEM log4j.dtd

log4j:configuration xmlns:log4j='http://jakarta.apache.org/log4j/'

appender name=stdout class=org.apache.log4j.ConsoleAppender
layout class=org.apache.log4j.PatternLayout
param name=ConversionPattern value=%d [%t] %-5p
%c - %m%n/
/layout
/appender

appender name=A1 class=org.apache.log4j.FileAppender
param name=File value=log4j.log/
layout class=org.apache.log4j.PatternLayout
param name=ConversionPattern value=%d [%t] %-5p
%c - %m%n/
/layout
/appender

root
priority value =debug /
appender-ref ref=stdout /
appender-ref ref=A1 /
/root

/log4j:configuration


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


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