You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-user@logging.apache.org by Vajrakumar Dindalakopp <va...@gmail.com> on 2013/01/19 22:12:36 UTC

Logging all the input parameters to all the methods in a webservice using DEBUG priority

Hello team,

Usually this is a quite common requirement I guss to log all the input
parameters to a method to a log with DEBUG modifier so that it can be
controlled.

I agree this we can achieve by writing logs using log4j with DEBUG priority
at the starting of all methods .
My question is :
" Is there a common way using which no need to write tgis line,
automatically when new method created it has this line. And you can control
wether to print or not these input parameters."

A code sample may be really helpfull.

Something like Log4E plugin for eclipse I need to do in Netbeans.

Thanking you in advance.
-- 
With Regards,
**
*Vajrakumar N. D*

Re: Logging all the input parameters to all the methods in a webservice using DEBUG priority

Posted by Vajrakumar Dindalakopp <va...@gmail.com>.
Thanks for reply Butt,

Actually I am totally new to this log4j, So I need a simple example to
implement this.
I couldnt refer to your links because they are removed.
And here I need to attach it to Netbeans 7.3 , but here examples are with
eclipse.
Even the resources with netbeans are not working for my badness.

Actually log4E is a simple plugin for eclipse environment for log4j,
anything similar will be much more helpful.

On Sun, Jan 20, 2013 at 8:23 AM, Brett Randall <ja...@gmail.com> wrote:

> Hi
>
> For this type of horizontal logging concern, an Aspect Oriented
> Programming (AOP) solution can be applied.  Choose an AOP library - I
> recommend AspectJ [1], then create pointcuts matching entry to all the
> methods/classes you are interested in.  You can capture the parameters
> and call the logging API from a simple aspect advising each method.
> You can choose between compile-time, post-compile-time (binary
> weaving) or runtime (load-time weaving) approaches to weave-in the
> logging advice.
>
> The advantage of an AOP approach is that you don't need to add any
> code to each method requiring log-on-entry (or return).  This also
> means you can easily remove any logging overhead at a later time.
>
> Take a look at the Perf4j [2] project if you are looking for examples
> of code which is advised to add logging statements - in this case it
> is capturing method-execution timings using around-advice.
>
> Best
> Brett
>
> [1] http://www.eclipse.org/aspectj/
> [2] http://perf4j.codehaus.org/
>
> On 20 January 2013 08:12, Vajrakumar Dindalakopp <va...@gmail.com>
> wrote:
> > Hello team,
> >
> > Usually this is a quite common requirement I guss to log all the input
> > parameters to a method to a log with DEBUG modifier so that it can be
> > controlled.
> >
> > I agree this we can achieve by writing logs using log4j with DEBUG
> priority
> > at the starting of all methods .
> > My question is :
> > " Is there a common way using which no need to write tgis line,
> > automatically when new method created it has this line. And you can
> control
> > wether to print or not these input parameters."
> >
> > A code sample may be really helpfull.
> >
> > Something like Log4E plugin for eclipse I need to do in Netbeans.
> >
> > Thanking you in advance.
> > --
> > With Regards,
> > **
> > *Vajrakumar N. D*
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
> For additional commands, e-mail: log4j-user-help@logging.apache.org
>
>


-- 
With Regards,
**
*Vajrakumar N. D*

Re: Logging all the input parameters to all the methods in a webservice using DEBUG priority

Posted by Brett Randall <ja...@gmail.com>.
Hi

For this type of horizontal logging concern, an Aspect Oriented
Programming (AOP) solution can be applied.  Choose an AOP library - I
recommend AspectJ [1], then create pointcuts matching entry to all the
methods/classes you are interested in.  You can capture the parameters
and call the logging API from a simple aspect advising each method.
You can choose between compile-time, post-compile-time (binary
weaving) or runtime (load-time weaving) approaches to weave-in the
logging advice.

The advantage of an AOP approach is that you don't need to add any
code to each method requiring log-on-entry (or return).  This also
means you can easily remove any logging overhead at a later time.

Take a look at the Perf4j [2] project if you are looking for examples
of code which is advised to add logging statements - in this case it
is capturing method-execution timings using around-advice.

Best
Brett

[1] http://www.eclipse.org/aspectj/
[2] http://perf4j.codehaus.org/

On 20 January 2013 08:12, Vajrakumar Dindalakopp <va...@gmail.com> wrote:
> Hello team,
>
> Usually this is a quite common requirement I guss to log all the input
> parameters to a method to a log with DEBUG modifier so that it can be
> controlled.
>
> I agree this we can achieve by writing logs using log4j with DEBUG priority
> at the starting of all methods .
> My question is :
> " Is there a common way using which no need to write tgis line,
> automatically when new method created it has this line. And you can control
> wether to print or not these input parameters."
>
> A code sample may be really helpfull.
>
> Something like Log4E plugin for eclipse I need to do in Netbeans.
>
> Thanking you in advance.
> --
> With Regards,
> **
> *Vajrakumar N. D*

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org