views:

23

answers:

2

I am using Spring framework in my application and it is deployed on MULE server.

Based on debug or info level, the amount of logging and the percentage of logging will vary. Till date, I write the log statements explicitly in all my business logic.

Is there any way to do this through configuration, say configure at some point -

CLASS NAME - METHOD NAME - LOG AT ENTRY POINT WITH INPUT PARAMETERS - LOG AT EXIT POINT WITH RETURN

This way my code will not look very clutter.

A: 

I am not sure exactly what you are asking, but it sounds like you would like to automatically log entry and exit from methods along with parameters. If that is the case, you might consider some form of Aspect Oriented Programing (AOP). Here and here and here are some links to pages with good examples of implementing exactly this kind of logging with PostSharp. Since you are using Spring (.NET or just Spring?), you might know that Spring.NET has an AOP solution (or here for Spring). Here is a project from CodeProject that provides a log4net logging aspect already written for PostSharp (not sure if this is currently up to date or not). There are other AOP solutions out there, PostSharp is one of the more popular.

I answered with a .NET slant because that is what I am more familiar with and you didn't indicate a language preference (via the tags) in your question.

wageoghe
A: 

As wageoghe mentioned, using Spring AOP is an option.

Another one, since you're running in Mule, is to use component interceptors around your Spring beans.

David Dossot