port/context/namespace/someAction.action?profiling=true through code ActionContext.getContext().getParameters().put("profiling", "true); To use profiling activation through parameter, one will need to pass in through the 'profiling' parameter (which is the default) and could be changed through the param tag in the interceptor-ref.
Warning:
Profiling activation through a parameter requires the following:
- Profiling interceptor in interceptor stack
- dev mode on (struts.devMode=true in struts.properties)
One could filter out the profile logging by having a System property as follows. With this 'xwork.profile.mintime' property, one could only log profile information when its execution time exceed those specified in 'xwork.profile.mintime' system property. If no such property is specified, it will be assumed to be 0, hence all profile information will be logged.
-Dxwork.profile.mintime=10000
One could extend the profiling feature provided by Struts2 in their web application as well.
String logMessage = "Log message"; UtilTimerStack.push(logMessage); try { // do some code } finally { UtilTimerStack.pop(logMessage); // this needs to be the same text as above }
or
String result = UtilTimerStack.profile("purchaseItem: ", new UtilTimerStack.ProfilingBlock() { public String doProfiling() { // do some code return "Ok"; } });
Profiled result is logged using commons-logging under the logger named 'com.opensymphony.xwork2.util.profiling.UtilTimerStack'. Depending on the underlying logging implementation say if it is Log4j, one could direct the log to appear in a different file, being emailed to someone or have it stored in the db.
@version $Date$ $Id$