У меня в программе возникает ошибка, которая формирует stackTrace очень большой и с разными библиотеками. Если читать его сверху вниз, то можно увидеть лишь все вызывающие методы от самого начала вызова за исключением первых 2-3. То есть как-то так
//Псевдокод
method1_1(){
method2();
}
method1_2(){
method2();
}
method1_3(){
method2();
}
method2(){
method3();
}
method3(){
method4();
}
method4(){
method5();
}
method5(){
method6();
}
StackTrace отображает лишь 3-6 методы, а вот 2 и какой из первых методов вызывает этот 2 не понятно. Как это можно узнать? Программа большая и логи пишутся каждые 0.1-0.001 с. Поэтому ставить логгирование на каждый метод не вариант. Смоделировать ошибку не могу, она только случается, собственно для этого и нужно узнать какой из методов вызывает ошибку. В примере указано три первых метода, по факту их много.
P.S. трейс примерно в таком виде
INFO | 2019/04/11 14:23:20 | at com.company.smx.data.dao.impl.UserDaoServiceImpl.updateContractorCouponCount(UserDaoServiceImpl.java:418)
INFO | 2019/04/11 14:23:20 | at com.company.smx.data.dao.impl.UserDaoServiceImpl$$FastClassBySpringCGLIB$$8732584e.invoke(<generated>)
INFO | 2019/04/11 14:23:20 | at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204)
INFO | 2019/04/11 14:23:20 | at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:700)
INFO | 2019/04/11 14:23:20 | at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
INFO | 2019/04/11 14:23:20 | at org.springframework.transaction.interceptor.TransactionInterceptor$1.proceedWithInvocation(TransactionInterceptor.java:96)
INFO | 2019/04/11 14:23:20 | at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:260)
INFO | 2019/04/11 14:23:20 | at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:94)
INFO | 2019/04/11 14:23:20 | at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
INFO | 2019/04/11 14:23:20 | at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:633)
INFO | 2019/04/11 14:23:20 | at com.company.smx.data.dao.impl.UserDaoServiceImpl$$EnhancerBySpringCGLIB$$c376b217.updateContractorCouponCount(<generated>)
INFO | 2019/04/11 14:23:20 | at sun.reflect.GeneratedMethodAccessor936.invoke(Unknown Source)
INFO | 2019/04/11 14:23:20 | at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
INFO | 2019/04/11 14:23:20 | at java.lang.reflect.Method.invoke(Method.java:498)
INFO | 2019/04/11 14:23:20 | at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:317)
INFO | 2019/04/11 14:23:20 | at org.springframework.osgi.service.importer.support.internal.aop.ServiceInvoker.doInvoke(ServiceInvoker.java:58)
INFO | 2019/04/11 14:23:20 | at org.springframework.osgi.service.importer.support.internal.aop.ServiceInvoker.invoke(ServiceInvoker.java:62)
INFO | 2019/04/11 14:23:20 | at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
INFO | 2019/04/11 14:23:20 | at org.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:132)
INFO | 2019/04/11 14:23:20 | at org.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:120)
INFO | 2019/04/11 14:23:20 | at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
INFO | 2019/04/11 14:23:20 | at org.springframework.osgi.service.util.internal.aop.ServiceTCCLInterceptor.invokeUnprivileged(ServiceTCCLInterceptor.java:56)
INFO | 2019/04/11 14:23:20 | at org.springframework.osgi.service.util.internal.aop.ServiceTCCLInterceptor.invoke(ServiceTCCLInterceptor.java:39)
INFO | 2019/04/11 14:23:20 | at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
INFO | 2019/04/11 14:23:20 | at org.springframework.osgi.service.importer.support.LocalBundleContextAdvice.invoke(LocalBundleContextAdvice.java:59)
INFO | 2019/04/11 14:23:20 | at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
INFO | 2019/04/11 14:23:20 | at org.springframework.aop.support.DelegatingIntroductionInterceptor.doProceed(DelegatingIntroductionInterceptor.java:132)
INFO | 2019/04/11 14:23:20 | at org.springframework.aop.support.DelegatingIntroductionInterceptor.invoke(DelegatingIntroductionInterceptor.java:120)
INFO | 2019/04/11 14:23:20 | at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
INFO | 2019/04/11 14:23:20 | at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
INFO | 2019/04/11 14:23:20 | at com.sun.proxy.$Proxy564.updateContractorCouponCount(Unknown Source)
INFO | 2019/04/11 14:23:20 | at com.company.smx.data.mobile.json.feedunits.FeedCoupon.fillParams(FeedCoupon.java:96)
INFO | 2019/04/11 14:23:20 | at com.company.smx.data.mobile.utils.FeedCreationFactory.createBySkinType(FeedCreationFactory.java:181)
INFO | 2019/04/11 14:23:20 | at com.company.smx.data.mobile.utils.FeedCreationFactory.createBySkinTypeSafe(FeedCreationFactory.java:58)
INFO | 2019/04/11 14:23:20 | at com.company.smx.data.mobile.utils.beans.FeedUnitCollector.createFeedKnownSkinType(FeedUnitCollector.java:177)
INFO | 2019/04/11 14:23:20 | at com.company.smx.data.mobile.utils.beans.FeedUnitCollector.lambda$feedsUnfinishedCollector$57(FeedUnitCollector.java:117)
INFO | 2019/04/11 14:23:20 | at java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:184)
INFO | 2019/04/11 14:23:20 | at java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1382)
INFO | 2019/04/11 14:23:20 | at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:481)
INFO | 2019/04/11 14:23:20 | at java.util.stream.ForEachOps$ForEachTask.compute(ForEachOps.java:291)
INFO | 2019/04/11 14:23:20 | at java.util.concurrent.CountedCompleter.exec(CountedCompleter.java:731)
INFO | 2019/04/11 14:23:20 | at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289)
INFO | 2019/04/11 14:23:20 | at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1056)
INFO | 2019/04/11 14:23:20 | at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1692)
INFO | 2019/04/11 14:23:20 | at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:157)
FeedUnitCollector.lambda$feedsUnfinishedCollector$57(FeedUnitCollector.java:117) Это 3 метод из псевдокода, а какой 1 и 2-ой я не знаю
Это можно сделать так
static void printLongerTrace(Throwable t){
for(StackTraceElement e: t.getStackTrace())
System.out.println(e);
}
Подробности можно найти тут
Продвижение своими сайтами как стратегия роста и независимости