----- Original Message -----
From: "William Lee" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, September 19, 2001 1:57 AM
Subject: Logging using log4j
> Is there any documentation on how to use logging in a ServletTestCase.
> There is the LogService and BaseLog class, but I can't seem to figure
> out what to do. What should be the category that I put in?
>
LogService and BaseLog are logging classes for Cactus itself. If you wish
logging for your code under test or your test code, you can use whatever
logging mechanism you're used to ... That said, you could reuse the
mechanism provided by Cactus if you wish. For that you need to understand
Log4j first and then you should read the Configuration Howto on the Cactus
web site.
Here is an example of code :
import org.apache.cactus.util.log.*;
public class MyTestCase extends ServletTestCase
{
private Log logger =
LogService.getInstance().getLog(MyTestCase.class.getName());
[...]
public void testXXX()
{
logger.debug("something");
}
}
In this example, we've used the class name as the Log4j Category, so we need
to add this category to the Log4J configuration. You should either edit the
log_server.properties file in cactus.jar and add :
# Properties for configuring Log4j
# This is the configuring for logging on the server side
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
You can add an appender if you wish to have your logs generated in a
separate file.
The other option is not to touch at the cactus jar, create a
log_server.properties file and ensure it is put in the classpath *before*
the cactus.jar
-Vincent