List Info

Thread: Log each call to an JSF action method




Log each call to an JSF action method
user name
2007-08-29 10:51:46
For audit and debugging purposes I want to log the name of
action
method that is being called. Is it possible to hook
somewhere in JSF
lifecycle? Or should I use Aspect oriented approach?

Any ideas are appreciated?

-- 
Svilen Ivanov
http://svilen-onlin
e.blogspot.com

There is no dark side of the moon really.
Matter of fact it's all dark.

Re: Log each call to an JSF action method
user name
2007-08-29 11:15:04
If you can wait until after the action has been called, you
can use
the ActionListener of the JSF Application or the
NavigationHandler as
both have access to the action EL expression. BTW - the
myfaces
NavigationHandlerImpl already logs each call at debug
level.

-Andrew

On 8/29/07, Svilen Ivanov <svilen.ivanovgmail.com> wrote:
> For audit and debugging purposes I want to log the name
of action
> method that is being called. Is it possible to hook
somewhere in JSF
> lifecycle? Or should I use Aspect oriented approach?
>
> Any ideas are appreciated?
>
> --
> Svilen Ivanov
> http://svilen-onlin
e.blogspot.com
>
> There is no dark side of the moon really.
> Matter of fact it's all dark.
>

Re: Log each call to an JSF action method
user name
2007-08-29 15:13:48
Andrew,

I think it is fine to wait for the action to end. However,
if
NavigationHandlerImpl does it for me - all I have to do is
to enable
the log. Thank you for your reply - I'll give it a shot.

Regards,
Svilen

2007/8/29, Andrew Robinson <andrew.rw.robinsongmail.com>:
> If you can wait until after the action has been called,
you can use
> the ActionListener of the JSF Application or the
NavigationHandler as
> both have access to the action EL expression. BTW - the
myfaces
> NavigationHandlerImpl already logs each call at debug
level.
>
> -Andrew
>
> On 8/29/07, Svilen Ivanov <svilen.ivanovgmail.com> wrote:
> > For audit and debugging purposes I want to log the
name of action
> > method that is being called. Is it possible to
hook somewhere in JSF
> > lifecycle? Or should I use Aspect oriented
approach?
> >
> > Any ideas are appreciated?
> >
> > --
> > Svilen Ivanov
> > http://svilen-onlin
e.blogspot.com
> >
> > There is no dark side of the moon really.
> > Matter of fact it's all dark.
> >
>


-- 
Svilen Ivanov
http://svilen-onlin
e.blogspot.com

There is no dark side of the moon really.
Matter of fact it's all dark.

Re: Log each call to an JSF action method
user name
2007-08-29 20:28:12
I like to use spring's variable resolver + support for proxy
beans to
do this.  I guess the aspect oriented approach you were
referring to.


On 8/29/07, Svilen Ivanov <svilen.ivanovgmail.com> wrote:
> Andrew,
>
> I think it is fine to wait for the action to end.
However, if
> NavigationHandlerImpl does it for me - all I have to do
is to enable
> the log. Thank you for your reply - I'll give it a
shot.
>
> Regards,
> Svilen
>
> 2007/8/29, Andrew Robinson <andrew.rw.robinsongmail.com>:
> > If you can wait until after the action has been
called, you can use
> > the ActionListener of the JSF Application or the
NavigationHandler as
> > both have access to the action EL expression. BTW
- the myfaces
> > NavigationHandlerImpl already logs each call at
debug level.
> >
> > -Andrew
> >
> > On 8/29/07, Svilen Ivanov <svilen.ivanovgmail.com> wrote:
> > > For audit and debugging purposes I want to
log the name of action
> > > method that is being called. Is it possible
to hook somewhere in JSF
> > > lifecycle? Or should I use Aspect oriented
approach?
> > >
> > > Any ideas are appreciated?
> > >
> > > --
> > > Svilen Ivanov
> > > http://svilen-onlin
e.blogspot.com
> > >
> > > There is no dark side of the moon really.
> > > Matter of fact it's all dark.
> > >
> >
>
>
> --
> Svilen Ivanov
> http://svilen-onlin
e.blogspot.com
>
> There is no dark side of the moon really.
> Matter of fact it's all dark.
>

Re: Log each call to an JSF action method
country flaguser name
Austria
2007-08-30 09:41:43
Hello,

you could also use a custom ActionListener implementation if
the method 
expression being processed is sufficient (for example,
"Processing the 
action '#{actionBean.processAction}'."), as Andrew has
already mentioned.

///
import javax.faces.component.ActionSource;
import javax.faces.event.AbortProcessingException;
import javax.faces.event.ActionEvent;
import javax.faces.event.ActionListener;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

public class LoggingActionListener implements ActionListener
{

    private static final Log log = 
LogFactory.getLog(LoggingActionListener.class);
   
    private ActionListener delegate;
   
    public LoggingActionListener(ActionListener delegate) {
        this.delegate = delegate;
    }
   
    public void processAction(ActionEvent actionEvent)
            throws AbortProcessingException {
        if (log.isDebugEnabled()) {
            ActionSource actionSource = (ActionSource) 
actionEvent.getComponent();
            log.debug("Processing the action '" +

actionSource.getAction().getExpressionString() +
"'.");
        }

        delegate.processAction(actionEvent);
    }

}
\

///
// faces-config.xml
<?xml version="1.0"
encoding="ISO-8859-1"?>
<!DOCTYPE faces-config PUBLIC
    "-//Sun Microsystems, Inc.//DTD JavaServer Faces
Config 1.1//EN"
    "http://java.sun.com/dtd/web-facesconfig_1_1.dtd"&g
t;
<faces-config>
   
    <application>
       
<action-listener>demo.LoggingActionListener</action
-listener>
    </application>
   
</faces-config>
\

regards,
Bernhard

Svilen Ivanov wrote:
> Andrew,
>
> I think it is fine to wait for the action to end.
However, if
> NavigationHandlerImpl does it for me - all I have to do
is to enable
> the log. Thank you for your reply - I'll give it a
shot.
>
> Regards,
> Svilen
>
> 2007/8/29, Andrew Robinson <andrew.rw.robinsongmail.com>:
>   
>> If you can wait until after the action has been
called, you can use
>> the ActionListener of the JSF Application or the
NavigationHandler as
>> both have access to the action EL expression. BTW -
the myfaces
>> NavigationHandlerImpl already logs each call at
debug level.
>>
>> -Andrew
>>
>> On 8/29/07, Svilen Ivanov <svilen.ivanovgmail.com> wrote:
>>     
>>> For audit and debugging purposes I want to log
the name of action
>>> method that is being called. Is it possible to
hook somewhere in JSF
>>> lifecycle? Or should I use Aspect oriented
approach?
>>>
>>> Any ideas are appreciated?
>>>
>>> --
>>> Svilen Ivanov
>>> http://svilen-onlin
e.blogspot.com
>>>
>>> There is no dark side of the moon really.
>>> Matter of fact it's all dark.
>>>
>>>       
>
>
>   


[1-5]

about | contact  Other archives ( Real Estate discussion Medical topics )