@Before
public void startContainer() throws Exception {
// Start the server
container.start(CONTAINER);
final ModelControllerClient client = TestSuiteEnvironment.getModelControllerClient();
final ManagementClient managementClient = new ManagementClient(client, TestSuiteEnvironment.getServerAddress(), TestSuiteEnvironment.getServerPort(), "http-remoting");
try {
logFile = getAbsoluteLogFilePath(client);
// Create the custom handler
ModelNode op = Operations.createAddOperation(CUSTOM_HANDLER_ADDRESS);
op.get("class").set("org.apache.log4j.FileAppender");
op.get("module").set("org.apache.log4j");
ModelNode opProperties = op.get("properties").setEmptyObject();
opProperties.get("file").set(logFile.getAbsolutePath());
opProperties.get("immediateFlush").set(true);
client.execute(op);
// Add the handler to the root-logger
op = Operations.createOperation("add-handler", ROOT_LOGGER_ADDRESS);
op.get(ModelDescriptionConstants.NAME).set(CUSTOM_HANDLER_NAME);
client.execute(op);
// Stop the container
container.stop(CONTAINER);
// Start the server again
container.start(CONTAINER);
Assert.assertTrue("Container is not started", managementClient.isServerInRunningState());
// Deploy the servlet
deployer.deploy(DEPLOYMENT);
} finally {
safeClose(managementClient);