----- Original Message -----
Sent: Thursday, September 27, 2001 1:32
PM
Subject: Re: log4J in Cactus
----- Original Message -----
Sent: Thursday, September 27, 2001
8:34 AM
Subject: log4J in Cactus
Hi,
I am trying to use logging feature in
my sample code using Cactus. The sample code goes like this:
What's the package of TestJspTestCase ?
Default package ?
import java.util.*;
import
java.text.*;
import javax.servlet.*;
import
javax.servlet.http.*;
import java.net.*;
import java.io.*;
import
junit.framework.*;
import org.apache.cactus.*;
import
org.apache.cactus.util.*;
import
org.apache.cactus.util.log.*; // For Logging
public class TestJspTestCase extends
JspTestCase {
public TestJspTestCase(String theName)
{
super(theName);
}
public static void main(String[]
theArgs) {
junit.ui.TestRunner.main(new String[]
{TestJspTestCase.class.getName()});
}
public static Test suite()
{
return new
TestSuite(TestJspTestCase.class);
}
public void testOut() throws
IOException, ServletException {
logger.debug("Beginning of
testOut()"); //
Logging Functionality
good, that's the correct way of doing
it! :)
session.setAttribute("name" ,
"BLUE" )
;
pageContext.forward("/hello.jsp");
logger.debug("End
of testOut()");
// Logging functionality
}
public void endOut(HttpURLConnection
huc )throws IOException , ServletException
{
System.out.println( AssertUtils.getResponseAsString(huc)
);
}
}
The log_server.properties goes like
this:
log4j.appender.cactus = org.apache.log4j.FileAppender
log4j.appender.cactus.File = cactus_server.log
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
log4j.category.org.apache.cactus = DEBUG, cactus
log4j.category.my.package = DEBUG, cactus
look good except maybe the "my.package" package. What you can do
if you want to log everything is to remove the 2 lines "log4.category" and
instead add the following line :
log4j.rootCategory = DEBUG, cactus
I add the the path to the log_server.properties to the classpath before
adding the cactus.jar. This file is the there in
D:\bea\wlserver6.0sp2\config\examples\serverclasses
When I run the sample by typing 'java TestJspTestCase' from
D:\bea\wlserver6.0sp2\config\examples\clientclasses I get the following
error in the java console
log4j:ERROR No appenders could be found for category
(TestJspTestCase).
seems to me it is what it says : there is no appender defined for
the default package (otherwise it would have said
"my.package.TestJspTestCase").
log4j:ERROR Please initialize the log4j system
properly.
<html>
<body>
Name: BLUE
</body>
</html>
Can anybody tell me why I get this error?
-Vincent