cocoon-docs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Apache Wiki <>
Subject [Cocoon Wiki] Update of "LogAction" by BertrandDelacretaz
Date Wed, 19 Oct 2005 07:04:12 GMT
Dear Wiki user,

You have subscribed to a wiki page or wiki category on "Cocoon Wiki" for change notification.

The following page has been changed by BertrandDelacretaz:

New page:
Here's the code of an Action which logs a message to a specific logger. 

This can be useful to keep track of visits to certain URLs in a separate logger than the application

= Code =

import org.apache.cocoon.environment.SourceResolver;
import org.apache.cocoon.environment.Redirector;
import org.apache.cocoon.acting.AbstractAction;
import org.apache.avalon.framework.parameters.Parameters;

import java.util.Map;

/** An Action which simply logs a message. */

public class LogAction extends AbstractAction {
    public Map act(Redirector redirector, SourceResolver resolver, Map objectModel, String
source, Parameters parameters)
    throws Exception {
        final String msg = parameters.getParameter("msg",null);
        if(msg!=null) {
            if(getLogger().isInfoEnabled()) {

        // don't execute what's inside this action, it's just here to log something
        return null;


= Sitemap declaration =

= Sitemap usage =
{{{<map:match pattern="something/*">
  <map:act type="log">
    <map:parameter name="msg" value="request to something/{1}"/>
  . . .

View raw message