如何获得完整的stackTrace

问题描述 投票:0回答:1

我有一个意外的错误,它创建了stackTrace,里面有很多行和不同的库。如果要从上到下阅读它,可以看到除2-3第一种方法之外的所有方法。看起来像

//Pseudo code
method1_1(){
method2();
}

method1_2(){
method2();
}

method1_3(){
method2();
}


method2(){
method3();
}

method3(){
method4();
}

method4(){
method5();
}

method5(){
method6();
}

StackTrace只显示3-6个方法,但它没有显示第二个方法,第一个方法中哪个方法调用了第二个方法?我怎么知道呢?程序很大,日志每写0-1-0,001秒。这就是为什么采取每种方法的记录是不好的。我无法模拟错误,只会发生。我需要知道什么方法抛出该错误。该示例中有6个第一种方法,但还有更多。

附:跟踪看起来像那样

INFO   | 2019/04/11 14:23:20 | 	at com.company.smx.data.dao.impl.UserDaoServiceImpl.updateUser(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.updateUser(<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.updateUser(Unknown Source)
INFO   | 2019/04/11 14:23:20 | 	at com.company.smx.data.mobile.utils.Class2.method3(Class2.java:58)
INFO   | 2019/04/11 14:23:20 | 	at com.company.smx.data.mobile.utils.beans.Class3.method2(Class3.java:177)
INFO   | 2019/04/11 14:23:20 | 	at com.company.smx.data.mobile.utils.beans.Class3.lambda$method1$57(Class3.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)

com.company.smx.data.mobile.utils.beans.Class3.lambda$method1$57(Class3.java:117)这是第三种伪代码方法,第一种和第二种方法,我需要知道

UPD我通过REST API调用我的第一个方法,所以它看起来像

public interface RestService {

@GET
@Produces("application/json; charset=utf-8")
@Path(value = "/rest/method1")
ResultResponse method1 (@PathParam("id") String id);
}

public class RestServiceImpl implements RestService {

method1_1(String id){
method2();
}
//and other pseudo code

}

正如我之前所说,我也可以找到@Common Man的帮助,直到第3种方法的唯一方法,因为之后我只有

at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
java stack-trace
1个回答
1
投票
static void printLongerTrace(Throwable t){
    for(StackTraceElement e: t.getStackTrace())
        System.out.println(e);
}

这将打印Stacktrace的每一行,将没有12...more

最有可能这可能不是答案,但值得一看:https://coderanch.com/t/442321/java/full-stacktrace

© www.soinside.com 2019 - 2024. All rights reserved.