This page last changed on Apr 25, 2005 by vmassol.

Definition

Explain how to perform debugging when something doesn't work in Cargo. Indeed it can happen that the container does not start or stop as expected. Or that some deployable does not deploy fine. Or whatever else! Here is a short list of things you can do to try debugging the problem.

Redirecting container output to a file

The Container.setOutput(File) API allows you to redirect the container console (stdout) to a file. This is the first file you should check in case of problem.

Example using the Java API

Starting Tomcat 4.x specifying an output console log file:
Container container = new Tomcat4xContainer();
container.setHomeDir("c:/apps/jakarta-tomcat-4.1.30");

container.setOutput("target/output.log");

container.start();

Use the container.setAppend(true|false) method to decide whether the log file is recreated or whether it is appended to, keeping the previous execution logs (by default, the file is recreated at every container start or stop).

Example using the Ant API

Starting Tomcat 4.x specifying an output console log file:

<cargo-tomcat4x homeDir="c:/apps/jakarta-tomcat-4.1.30" action="start"
    output="target/output.log"/>

Use the append="true|false" attribute for controlling the log file creation behavior.

Generating Cargo logs

Some Cargo classes support generation of logs. This is implemented through the notion of Monitor.

For example to turn on logging monitoring on a Container class, you can use:

Monitor fileMonitor = new FileMonitor(new File("c:/tmp/cargo.log"), true); 
container.setMonitor(fileMonitor);

There are several Monitors that are readily available in the Cargo distribution:

Turning on container logs

Cargo is able to configure containers to generate various levels logs. There are 3 levels defined: "low", "medium" and "high" ("medium" is the default value). They represent the quantity of information you wish to have in the generated log file. You can tune container logging by using the following API:
container.setProperty(GeneralPropertySet.LOGGING, "medium");

The generated log files will then be found in the Working directory you have specified on the container (through the container.setWorkingDir() call).

When using the Ant tasks, you can specify the log file by using the log attribute. For example:
<cargo-resin3x [...] log="target/cargo.log"/>
Document generated by Confluence on Apr 30, 2005 12:52