Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Adding deeper logging to Webflow Exceptions

DZone's Guide to

Adding deeper logging to Webflow Exceptions

· Java Zone ·
Free Resource

How do you break a Monolith into Microservices at Scale? This ebook shows strategies and techniques for building scalable and resilient microservices.

If you've been using Roo and the JSPX views with WebFlow, you've probably noticed that you don't get the embedded stack trace in the errors that result.  You can fix this with a lifecycle listener:

First, define the class:

package mypackage;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.webflow.execution.FlowExecutionException;
import org.springframework.webflow.execution.FlowExecutionListenerAdapter;
import org.springframework.webflow.execution.RequestContext;

public class LoggingFlowExecutionListener extends FlowExecutionListenerAdapter {
Logger logger = LoggerFactory.getLogger(
@Override
public void exceptionThrown(RequestContext context,
FlowExecutionException exception) {
super.exceptionThrown(context, exception);
logger.error("Webflow " + context.getActiveFlow().getId() +
" threw exception in " + context.getCurrentState().getId(), exception);
}
}

Then, in webflow-config.xml, replace

<webflow:flow-executor id="flowExecutor" />

with

<webflow:flow-executor id="flowExecutor">
<webflow:flow-execution-listeners>
<webflow:listener ref="loggingListener"/>
</webflow:flow-execution-listeners>
</webflow:flow-executor>

<bean class="mypackage.LoggingFlowExecutionListener" id="loggingListener" />

Now you can enjoy useful logging from your Webflow exceptions.

From http://www.rimple.com/tech/2011/2/28/adding-deeper-logging-to-webflow-exceptions.html

How do you break a Monolith into Microservices at Scale? This ebook shows strategies and techniques for building scalable and resilient microservices.

Topics:

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}