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 Paul Ekeland <pe...@credm.com> on 2002/07/24 17:44:31 UTC

using log4J with JBoss and Cactus

Hello everyone,

I am currently writing a program to test my EJBs using Cactus. I created a
war file of the cactus tests and they run on a JBoss 3.0 platform. JBoss,
Cactus and my program are all using log4J... Here is how it is written so
far: I followed your recommandations and so I adapted the log4j.xml of JBoss
and inserted my own appenders and loggers as shown in appendix.

Now, Cactus also is using log4J and needs 2 configuration files,
log_client.properties and log_server.properties . log_client.properties is
described in the appendix too.

With this setup, here is what i get:

	* 2 empty logfiles cactus_client.log and cactus_server.log even though the
code requires some 	events to be written in them. At least, it seems it
reads correctly the configuration files 	from Cactus.

	* an appender error that should not have happened if the appenders i had
put in the 	configuration file of JBoss, log4J.xml, had been taken in
account:
	"------------ Standard Error -----------------
	log4j:WARN No appenders could be found for logger
(com.credm.babel.cactus.TestPropertyType).
	log4j:WARN Please initialize the log4j system properly.
	------------- ---------------- ---------------"

	* No files are created for the CACTUSTEST appender..

I'm a bit lost to be honest between all this, so if you could help me I
would greatly appreciate it.. I'm not sure but I think there could be some
issues with log4J's JBoss and log4J's war file being in different
classloaders...

Thanks!

Paul

==========
log4j.xml:
==========

<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/"
debug="true">
	<!-- ================================= -->
	<!-- Preserve messages in a local file -->
	<!-- ================================= -->
	<!-- A time/date based rolling appender -->
	<appender name="FILE"
class="org.jboss.logging.appender.DailyRollingFileAppender">
		<param name="File" value="${jboss.server.home.dir}/log/server.log"/>
		<param name="Append" value="false"/>
		<param name="DatePattern" value="'.'yyyy-MM-dd"/>
		<layout class="org.apache.log4j.PatternLayout">
			<!-- The default pattern: Date Priority [Category] Message\n -->
			<param name="ConversionPattern" value="%d %-5p [%c] %m%n"/>
		</layout>
	</appender>

	<!-- ============================== -->
	<!-- Append messages to the console -->
	<!-- ============================== -->
	<appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
		<param name="Threshold" value="INFO"/>
		<param name="Target" value="${jboss.server.home.dir}/log/system.out"/>
		<layout class="org.apache.log4j.PatternLayout">
			<!-- The default pattern: Date Priority [Category] Message\n -->
			<param name="ConversionPattern" value="%d{ABSOLUTE} %-5p [%c{1}] %m%n"/>
		</layout>

	<!-- ============================== -->
	<!-- My appenders				-->
	<!-- ============================== -->
	<appender name="CACTUSTEST" class="org.apache.log4j.FileAppender">
		<param name="File" value="${jboss.server.home.dir}/log/cactusTest.log"/>
		<!--param name="threshold" value="INFO"/-->
		<layout class="org.apache.log4j.PatternLayout">
			<param name="ConversionPattern" value="=(%-35c{2} %-4L) %m%n"/>
		</layout>
	</appender>

	<appender name="RUNTIME" class="org.apache.log4j.FileAppender">
		<param name="File" value="${jboss.server.home.dir}/log/runtime.log"/>
		<param name="threshold" value="INFO"/>
		<layout class="org.apache.log4j.PatternLayout">
			<param name="ConversionPattern" value="=(%-35c{2} %-4L) %m%n"/>
		</layout>
	</appender>


	<!-- ======================= -->
	<!-- Setup the loggers 		-->
	<!-- ======================= -->
	<logger name="com.credm.babel.cactus">
		<level value="DEBUG"/>
		<appender-ref ref="CACTUSTEST"/>
	</logger>
	<logger name="com.credm" additivity="false">
		<level value="WARN"/>
		<appender-ref ref="RUNTIME"/>
	</logger>
	<!-- ======================= -->
	<!-- Setup the Root category -->
	<!-- ======================= -->
	<root>
		<appender-ref ref="CONSOLE"/>
		<appender-ref ref="FILE"/>
	</root>
</log4j:configuration>


======================
log_client.properties:
======================

# Properties for configuring Log4j
# This is the configuring for logging on the JUnit side (i.e. the client
side)

log4j.appender.cactus = org.apache.log4j.FileAppender
log4j.appender.cactus.File =
D:/applications/jboss-3.0.0_tomcat-4.0.3/server/default/log/cactus_client.lo
g
log4j.appender.cactus.Append = false
log4j.appender.cactus.layout = org.apache.log4j.PatternLayout
log4j.appender.cactus.layout.ConversionPattern = %d{ABSOLUTE} [%t] %-5p
%-30.30c{2} %x - %m %n

# Any application log which uses Log4J will be logged to the Cactus log file
# log4j.rootCategory=DEBUG, cactus
log4j.rootlogger=DEBUG, cactus

# By default we don't log at the DEBUG level for Cactus log, in order not to
generate too
# many logs. However, should a problem arise and logs need to be sent to the
Cactus dev team,
# then we will ask you to change this to DEBUG.
log4j.logger.org.apache.cactus = INFO, cactus
log4j.additivity.org.apache.cactus=false


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: using log4J with JBoss and Cactus

Posted by Paul Ekeland <pe...@credm.com>.
I had already enabled the internal logging of JBoss, with no success
unfortunately. This "log4j:WARN No appenders could be found for logger
com.credm.babel.cactus.TestPropertyType" is output on the console screen of
Ant when I try running the program.

And in the class com.credm.babel.cactus.TestPropertyType, here is how I
declare the logger:

"public class TestPropertyType extends ServletTestCase
{
	private PropertyTypeLocal propertyType;
	final static Logger logger = Logger.getLogger("org.apache.cactus");
...
}"

Nothing much to do with the error... And to add to that, I did declare a
"com.credm.babel.cactus" logger in my log4j.xml file of JBoss! This is
pretty confusing. The war file used with Cactus does not seem to see the
log4j configuration for JBoss. Would that be possible?

One last thing that would ease the development: is it possible to merge
log_client.properties and log_server.properties in the log4j.xml?

Thanks!

Paul

-----Message d'origine-----
De : Ceki Gulcu [mailto:ceki@qos.ch]
Envoye : jeudi 25 juillet 2002 16:39
A : Log4J Users List
Objet : RE: using log4J with JBoss and Cactus




The fact that log4j warns about not seeing the root logger is normal
because the log_server.properties file probably does not mention the
root logger (which is perfectly fine.) Log4j is suspicious about not
seeing the root logger mentioned in the config file and emits a
warning which you can safely ignore.

The "log4j:WARN No appenders could be found for logger
com.credm.babel.cactus.TestPropertyType" is more serious. You should
enable internal log4j debugging for the JBoss' log4j.xml file and see
what that gives.

At 16:12 25.07.2002 +0200, you wrote:
>Hello Ceki,
>
>Thanks for answering.
>So far, I have solved one of the problem: now my appenders do produce
files.
>In the log4j.xml of JBoss, my error was to make them derive from the
>"org.apache.log4j.FileAppender". The correct way is to make them derive
from
>JBoss' class.:
>         <appender name="cactus"
> class="org.jboss.logging.appender.FileAppender">
>
>Now, the problem with merging the contents of "log_client.properties" into
>"log4j.xml" is that cactus.jar is looking for a "log_client.properties" in
>the classpath. Same effect with "log_server.properties"... Is there a way
to
>bypass this?
>
>JBoss manages to start correctly its Log4J service, as you can see:

[snip]


--
Ceki

For complete log4j documentation please refer to
http://qos.ch/log4jBook.html


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: using log4J with JBoss and Cactus

Posted by Ceki Gülcü <ce...@qos.ch>.

The fact that log4j warns about not seeing the root logger is normal
because the log_server.properties file probably does not mention the
root logger (which is perfectly fine.) Log4j is suspicious about not
seeing the root logger mentioned in the config file and emits a
warning which you can safely ignore.

The "log4j:WARN No appenders could be found for logger
com.credm.babel.cactus.TestPropertyType" is more serious. You should
enable internal log4j debugging for the JBoss' log4j.xml file and see
what that gives.

At 16:12 25.07.2002 +0200, you wrote:
>Hello Ceki,
>
>Thanks for answering.
>So far, I have solved one of the problem: now my appenders do produce files.
>In the log4j.xml of JBoss, my error was to make them derive from the
>"org.apache.log4j.FileAppender". The correct way is to make them derive from
>JBoss' class.:
>         <appender name="cactus" 
> class="org.jboss.logging.appender.FileAppender">
>
>Now, the problem with merging the contents of "log_client.properties" into
>"log4j.xml" is that cactus.jar is looking for a "log_client.properties" in
>the classpath. Same effect with "log_server.properties"... Is there a way to
>bypass this?
>
>JBoss manages to start correctly its Log4J service, as you can see:

[snip]


--
Ceki

For complete log4j documentation please refer to http://qos.ch/log4jBook.html


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: using log4J with JBoss and Cactus

Posted by Paul Ekeland <pe...@credm.com>.
Hello Ceki,

Thanks for answering.
So far, I have solved one of the problem: now my appenders do produce files.
In the log4j.xml of JBoss, my error was to make them derive from the
"org.apache.log4j.FileAppender". The correct way is to make them derive from
JBoss' class.:
	<appender name="cactus" class="org.jboss.logging.appender.FileAppender">

Now, the problem with merging the contents of "log_client.properties" into
"log4j.xml" is that cactus.jar is looking for a "log_client.properties" in
the classpath. Same effect with "log_server.properties"... Is there a way to
bypass this?

JBoss manages to start correctly its Log4J service, as you can see:

"2002-07-25 13:05:34,149 DEBUG [org.jboss.logging.Log4jService] Installed
System.out adapter
2002-07-25 13:05:34,149 DEBUG [org.jboss.logging.Log4jService] Installed
System.err adapter
2002-07-25 13:05:34,159 DEBUG [org.jboss.logging.Log4jService] Added
ThrowableListener:
org.jboss.logging.Log4jService$ThrowableListenerLoggingAdapter@f0c85e
2002-07-25 13:05:34,159 INFO  [org.jboss.logging.Log4jService] Started"

and even to parse correctly the log_server.properties:

"2002-07-25 15:15:50,058 INFO  [STDOUT] log4j: Reading configuration from
URL
file:D:/applications/jboss-3.0.0_tomcat-4.0.3/catalina/work/localhost/babelt
est/WEB-INF/classes/log_server.properties
2002-07-25 15:15:50,058 INFO  [STDOUT] log4j: Could not find root logger
information. Is this OK?
2002-07-25 15:15:50,058 INFO  [STDOUT] log4j: Parsing for
[org.apache.cactus] with value=[INFO, cactus].
2002-07-25 15:15:50,058 INFO  [STDOUT] log4j: Level token is [INFO].
2002-07-25 15:15:50,058 INFO  [STDOUT] log4j: Category org.apache.cactus set
to INFO
2002-07-25 15:15:50,058 INFO  [STDOUT] log4j: Parsing appender named
"cactus".
2002-07-25 15:15:50,058 INFO  [STDOUT] log4j: Parsing layout options for
"cactus".
2002-07-25 15:15:50,439 INFO  [STDOUT] log4j: Setting property
[conversionPattern] to [%d{ABSOLUTE} [%t] %-5p %-30.30c{2} %x - %m %n].
2002-07-25 15:15:50,439 INFO  [STDOUT] log4j: End of parsing for "cactus".
2002-07-25 15:15:50,899 INFO  [STDOUT] log4j: Setting property [append] to
[false].
2002-07-25 15:15:50,899 INFO  [STDOUT] log4j: Setting property [file] to
[D:/applications/jboss-3.0.0_tomcat-4.0.3/server/default/log/cactus_server.l
og].
2002-07-25 15:15:50,909 INFO  [STDOUT] log4j: setFile called:
D:/applications/jboss-3.0.0_tomcat-4.0.3/server/default/log/cactus_server.lo
g, false
2002-07-25 15:15:50,909 INFO  [STDOUT] log4j: setFile ended
2002-07-25 15:15:50,909 INFO  [STDOUT] log4j: Parsed "cactus" options.
2002-07-25 15:15:50,909 INFO  [STDOUT] log4j: Handling
log4j.additivity.org.apache.cactus=[false]
2002-07-25 15:15:50,909 INFO  [STDOUT] log4j: Setting additivity for
"org.apache.cactus" to false
2002-07-25 15:15:50,909 INFO  [STDOUT] log4j: Finished configuring."

The problem is that it cannot see the root logger!!
Furthermore, I still have the following error when I start my program:

"------------ Standard Error -----------------
         log4j:WARN No appenders could be found for logger
com.credm.babel.cactus.TestPropertyType).
         log4j:WARN Please initialize the log4j system properly.
------------- ---------------- ---------------"

I hope someone knows what is going on... Any help is appreciated! Thanks!

Paul

-----Message d'origine-----
De : Ceki Gulcu [mailto:ceki@qos.ch]
Envoye : mercredi 24 juillet 2002 18:41
A : Log4J Users List
Objet : Re: using log4J with JBoss and Cactus



Paul,

What does log4j say when it reads log4j.xml? Second, you can merge the
contents of log_client.properties into log4j.xml. Do you know if
log_client.properties parsed at all?

At 17:44 24.07.2002 +0200, Paul Ekeland wrote:
>Hello everyone,
>
>I am currently writing a program to test my EJBs using Cactus. I created a
>war file of the cactus tests and they run on a JBoss 3.0 platform. JBoss,
>Cactus and my program are all using log4J... Here is how it is written so
>far: I followed your recommandations and so I adapted the log4j.xml of
JBoss
>and inserted my own appenders and loggers as shown in appendix.
>
>Now, Cactus also is using log4J and needs 2 configuration files,
>log_client.properties and log_server.properties . log_client.properties is
>described in the appendix too.
>
>With this setup, here is what i get:
>
>         * 2 empty logfiles cactus_client.log and cactus_server.log even
> though the
>code requires some      events to be written in them. At least, it seems it
>reads correctly the configuration files         from Cactus.
>
>         * an appender error that should not have happened if the
> appenders i had
>put in the      configuration file of JBoss, log4J.xml, had been taken in
>account:
>         "------------ Standard Error -----------------
>         log4j:WARN No appenders could be found for logger
>(com.credm.babel.cactus.TestPropertyType).
>         log4j:WARN Please initialize the log4j system properly.
>         ------------- ---------------- ---------------"
>
>         * No files are created for the CACTUSTEST appender..

[snip]

--

Ceki

For complete log4j documentation please refer to
http://qos.ch/log4jBook.html


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: using log4J with JBoss and Cactus

Posted by Ceki Gülcü <ce...@qos.ch>.
Paul,

What does log4j say when it reads log4j.xml? Second, you can merge the
contents of log_client.properties into log4j.xml. Do you know if
log_client.properties parsed at all?

At 17:44 24.07.2002 +0200, Paul Ekeland wrote:
>Hello everyone,
>
>I am currently writing a program to test my EJBs using Cactus. I created a
>war file of the cactus tests and they run on a JBoss 3.0 platform. JBoss,
>Cactus and my program are all using log4J... Here is how it is written so
>far: I followed your recommandations and so I adapted the log4j.xml of JBoss
>and inserted my own appenders and loggers as shown in appendix.
>
>Now, Cactus also is using log4J and needs 2 configuration files,
>log_client.properties and log_server.properties . log_client.properties is
>described in the appendix too.
>
>With this setup, here is what i get:
>
>         * 2 empty logfiles cactus_client.log and cactus_server.log even 
> though the
>code requires some      events to be written in them. At least, it seems it
>reads correctly the configuration files         from Cactus.
>
>         * an appender error that should not have happened if the 
> appenders i had
>put in the      configuration file of JBoss, log4J.xml, had been taken in
>account:
>         "------------ Standard Error -----------------
>         log4j:WARN No appenders could be found for logger
>(com.credm.babel.cactus.TestPropertyType).
>         log4j:WARN Please initialize the log4j system properly.
>         ------------- ---------------- ---------------"
>
>         * No files are created for the CACTUSTEST appender..

[snip]

--

Ceki

For complete log4j documentation please refer to http://qos.ch/log4jBook.html


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>