-
Notifications
You must be signed in to change notification settings - Fork 38.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TraceInterceptor enhancements [SPR-601] #5329
Comments
Claus Ibsen commented The placeholders are documented in the class javadoc /**
<p/>
<p/>
<p/>
<br/>
|
Claus Ibsen commented The source file |
Claus Ibsen commented I don't need my name in the |
Claus Ibsen commented This is a new version of the TraceInterceptor - mind the package name in the top. |
Claus Ibsen commented I rewoked the interceptor.
|
Claus Ibsen commented Example from my console: 2005-04-04 22:22:06,687 DEBUG [org.dummy.MyDummyBean] - ENTER - foo() Using this spring configuration:
|
Claus Ibsen commented The same example again using the same configuration as the original Spring TraceInterceptor. 2005-04-04 22:26:57,078 DEBUG [org.dummy.TraceInterceptor] - Entering method 'foo' in class [org.dummy.MyDummyBean] <bean id="traceInterceptor" class="org.dummy.TraceInterceptor"/> |
Claus Ibsen commented See also #5586 |
Juergen Hoeller commented See #5586 |
Claus Ibsen opened SPR-601 and commented
I forked the org.springframework.aop.interceptors.TraceInterceptor as I needed several added functionality. I ended up adding a few more features and made it customizable so I could contribute it back to the Spring team.
I have attached a modified version of the TraceInterceptor.java with these enhancements:
Using the dynamic logname makes it possible to output logs as:
http8080-Processor4 07 jan 2005 11:22:58 DEBUG dk.netfragt.pbs.NetfragtPBSWebService - ENTER - accepterFaktura
dk.netfragt.pbs.NetfragtPBSWebService - EXIT - accepterFaktura. Time = 1656 msec.
Instead of the default:
http8080-Processor4 07 jan 2005 11:19:43 DEBUG org.springframework.aop.interceptor.TraceInterceptor - Entering method accepterFaktura in class [dk.netfragt.pbs.NetfragtPBSWebService]
And with the method arguments you can see what has been passed in as arguments (in this example 77777):
http8080-Processor4 07 jan 2005 11:19:43 DEBUG org.springframework.aop.interceptor.TraceInterceptor - Entering method accepterFaktura(77777) in class [dk.netfragt.pbs.NetfragtPBSWebService]
And you can change the formatting of the message using java.text.Format with {0} placeholders. The defaults are:
You can customize this in the spring .xml configuration:
Using the above will output:
http8080-Processor4 07 jan 2005 11:22:58 DEBUG dk.netfragt.pbs.NetfragtPBSWebService - ENTER - accepterFaktura(676767)
http8080-Processor4 07 jan 2005 11:23:00 DEBUG dk.netfragt.pbs.NetfragtPBSWebService - EXIT - accepterFaktura(676767). Time = 1656 msec.
As the example above illustrates that using dynamicLogName and customizing the log message it is possible to change it radically.
I hope the Spring team could accept these changes as the default version is the same as the existing one.
Affects: 1.1.3
Attachments:
Issue Links:
The text was updated successfully, but these errors were encountered: