De hecho, me escribió una biblioteca (https://github.com/michaelgantman/Mgnt/releases/tag/1.01) que contiene varias utilidades. Uno de ellos es un filtro stacktrace de uso general que utilicé ampliamente y lo encontré muy útil. La clase se llama TextUtils y tiene el método getStacktrace() con varias firmas anuladas. Toma una instancia Throwable y permite establecer un prefijo de paquete de los paquetes que sean relevantes.Digamos que el código de su empresa siempre reside en paquetes que comienzan con "com.plain. *" Así se establece un prefijo y hacer esto
logger.info(TextUtils.getStacktrace(e, true, "com.plain."));
este filtrará muy inteligentemente todas las partes inútiles de la traza dejando con stacktrace muy conciso. También me pareció muy conveniente para pre-configurado el prefijo y luego sólo tiene que utilizar el método de confort
TextUtils.getStacktrace(e);
Se hará lo mismo. Para preajustar el prefijo sólo tiene que utilizar el método
setRelevantPackage("com.plain.");
Además, si utiliza entorno de primavera se puede añadir el siguiente segmento a la configuración primavera y entonces todo listo:
<bean class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">
<property name="targetClass" value="com.mgnt.utils.TextUtils"/>
<property name="targetMethod" value="setRelevantPackage"/>
<property name="arguments" value="com.plain."/>
</bean>
La biblioteca viene con bien escrito (Espero) Javadoc que explica todo en detalle. Pero aquí es un poco bromista: obtendrá un siguiente StackTrace:
at com.plain.BookService.listBooks()
at com.plain.BookService$$FastClassByCGLIB$$e7645040.invoke()
at net.sf.cglib.proxy.MethodProxy.invoke()
...
at com.plain.LoggingAspect.logging()
at sun.reflect.NativeMethodAccessorImpl.invoke0()
...
at com.plain.BookService$$EnhancerByCGLIB$$7cb147e4.listBooks()
at com.plain.web.BookController.listBooks()
en lugar de
at com.plain.BookService.listBooks()
at com.plain.BookService$$FastClassByCGLIB$$e7645040.invoke()
at net.sf.cglib.proxy.MethodProxy.invoke()
at org.springframework.aop.framework.Cglib2AopProxy$CglibMethodInvocation.invokeJoinpoint()
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed()
at org.springframework.aop.aspectj.MethodInvocationProceedingJoinPoint.proceed()
at com.plain.LoggingAspect.logging()
at sun.reflect.NativeMethodAccessorImpl.invoke0()
at sun.reflect.NativeMethodAccessorImpl.invoke()
at sun.reflect.DelegatingMethodAccessorImpl.invoke()
at java.lang.reflect.Method.invoke()
at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethodWithGivenArgs()
at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethod()
at org.springframework.aop.aspectj.AspectJAroundAdvice.invoke()
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed()
at org.springframework.aop.interceptor.AbstractTraceInterceptor.invoke()
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed()
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke()
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed()
at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke()
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed()
at org.springframework.aop.framework.Cglib2AopProxy$DynamicAdvisedInterceptor.intercept()
at com.plain.BookService$$EnhancerByCGLIB$$7cb147e4.listBooks()
at com.plain.web.BookController.listBooks()
Ah sí, el "stack trace from hell" según Cay Horstmann: https://plus.google.com/+CayHorstmann/posts/YAwGCVpLXgH –