public class StackTraceFilter extends Object
/StackTraceFilter.packages
with the package prefixes if you want to
use a custom filter (one package per line).
# Packages to filter
org.h2
org.apache.catalina
org.apache.coyote
org.apache.tomcat
com.arjuna
org.apache.cxf
Original stack trace: java.lang.RuntimeException: entryMethod
at biz.paluch.logging.StackTraceFilterTest.entryMethod(StackTraceFilterTest.java:49)
at biz.paluch.logging.StackTraceFilterTest.printStackTrace(StackTraceFilterTest.java:35)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
at org.junit.runner.JUnitCore.run(JUnitCore.java:160)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:51)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:237)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:147)
Caused by: biz.paluch.logging.StackTraceFilterTest$MyException: Intermediate 2
at biz.paluch.logging.StackTraceFilterTest.intermediate2(StackTraceFilterTest.java:58)
at biz.paluch.logging.StackTraceFilterTest.intermediate1(StackTraceFilterTest.java:53)
... 30 more
Suppressed: java.lang.RuntimeException: surpressed
at biz.paluch.logging.StackTraceFilterTest.intermediate2(StackTraceFilterTest.java:59)
... 31 more
Suppressed: java.lang.RuntimeException: surpressed
at biz.paluch.logging.StackTraceFilterTest.intermediate2(StackTraceFilterTest.java:60)
... 31 more
Suppressed: java.lang.IllegalArgumentException: Failed to parse byte.
at org.jboss.common.beans.property.ByteEditor.setAsText(ByteEditor.java:48)
at biz.paluch.logging.StackTraceFilterTest.intermediate2(StackTraceFilterTest.java:65)
... 31 more
Caused by: java.lang.NumberFormatException: For input string: "adsd"
at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
at java.lang.Integer.parseInt(Integer.java:580)
at java.lang.Integer.valueOf(Integer.java:740)
at java.lang.Integer.decode(Integer.java:1197)
at java.lang.Byte.decode(Byte.java:277)
at org.jboss.common.beans.property.ByteEditor.setAsText(ByteEditor.java:45)
... 32 more
Caused by: biz.paluch.logging.StackTraceFilterTest$MyException: Message
at biz.paluch.logging.StackTraceFilterTest.intermediate3(StackTraceFilterTest.java:77)
... 32 more
Suppressed: java.lang.IllegalStateException: Some illegal state
at biz.paluch.logging.StackTraceFilterTest.cause(StackTraceFilterTest.java:84)
at biz.paluch.logging.StackTraceFilterTest.intermediate3(StackTraceFilterTest.java:78)
... 32 more
Suppressed: java.lang.IllegalStateException: Some illegal state
at biz.paluch.logging.StackTraceFilterTest.cause(StackTraceFilterTest.java:84)
at biz.paluch.logging.StackTraceFilterTest.intermediate3(StackTraceFilterTest.java:79)
... 32 more
Caused by: java.lang.IllegalStateException: Some illegal state
at biz.paluch.logging.StackTraceFilterTest.cause(StackTraceFilterTest.java:84)
... 33 more
Filtered stack trace: java.lang.RuntimeException: entryMethod
at biz.paluch.logging.StackTraceFilterTest.entryMethod(StackTraceFilterTest.java:49)
at biz.paluch.logging.StackTraceFilterTest.filterWholeStackTrace(StackTraceFilterTest.java:43)
19 lines skipped for [java.lang, sun., org.junit]
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:51)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:237)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
4 lines skipped for [java.lang, sun.]
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:147)
Caused by: biz.paluch.logging.StackTraceFilterTest$MyException: Intermediate 2
at biz.paluch.logging.StackTraceFilterTest.intermediate2(StackTraceFilterTest.java:58)
at biz.paluch.logging.StackTraceFilterTest.intermediate1(StackTraceFilterTest.java:53)
... 30 more
Suppressed: java.lang.RuntimeException: surpressed
at biz.paluch.logging.StackTraceFilterTest.intermediate2(StackTraceFilterTest.java:59)
... 31 more
Suppressed: java.lang.RuntimeException: surpressed
at biz.paluch.logging.StackTraceFilterTest.intermediate2(StackTraceFilterTest.java:60)
... 31 more
Suppressed: java.lang.IllegalArgumentException: Failed to parse byte.
at org.jboss.common.beans.property.ByteEditor.setAsText(ByteEditor.java:48)
at biz.paluch.logging.StackTraceFilterTest.intermediate2(StackTraceFilterTest.java:65)
... 31 more
Caused by: java.lang.NumberFormatException: For input string: "adsd"
6 lines skipped for [java.lang, org.jboss]
... 32 more
Caused by: biz.paluch.logging.StackTraceFilterTest$MyException: Message
at biz.paluch.logging.StackTraceFilterTest.intermediate3(StackTraceFilterTest.java:77)
... 32 more
Suppressed: java.lang.IllegalStateException: Some illegal state
at biz.paluch.logging.StackTraceFilterTest.cause(StackTraceFilterTest.java:84)
at biz.paluch.logging.StackTraceFilterTest.intermediate3(StackTraceFilterTest.java:78)
... 32 more
Suppressed: java.lang.IllegalStateException: Some illegal state
at biz.paluch.logging.StackTraceFilterTest.cause(StackTraceFilterTest.java:84)
at biz.paluch.logging.StackTraceFilterTest.intermediate3(StackTraceFilterTest.java:79)
... 32 more
Caused by: java.lang.IllegalStateException: Some illegal state
at biz.paluch.logging.StackTraceFilterTest.cause(StackTraceFilterTest.java:84)
... 33 more
Modifier and Type | Field and Description |
---|---|
static String |
FILTER_SETTINGS |
static String |
VERBOSE_LOGGING_PROPERTY |
Modifier and Type | Method and Description |
---|---|
static List<String> |
getDefaults() |
static String |
getFilteredStackTrace(Throwable t)
Get a filterered stack trace.
|
static String |
getFilteredStackTrace(Throwable t,
boolean shouldFilter)
Deprecated.
since 1.11.1. Use
getStackTrace(Throwable, int) to get the stack trace without filtering or
getFilteredStackTrace(Throwable) to get the filtered the stack trace. |
static String |
getFilteredStackTrace(Throwable t,
int ref)
Filter stack trace by selecting the
Throwable using a reference position. |
static String |
getStackTrace(Throwable t)
Get the
Throwable 's stack trace. |
static String |
getStackTrace(Throwable t,
int ref)
Get the stack trace by selecting the
Throwable using a reference position. |
static Throwable |
getThrowable(Throwable throwable,
int ref)
Return a
Throwable by its reference position. |
static void |
loadSetttings(String resourceName) |
public static final String VERBOSE_LOGGING_PROPERTY
public static final String FILTER_SETTINGS
public static void loadSetttings(String resourceName)
public static String getFilteredStackTrace(Throwable t)
t
- the throwable@Deprecated public static String getFilteredStackTrace(Throwable t, boolean shouldFilter)
getStackTrace(Throwable, int)
to get the stack trace without filtering or
getFilteredStackTrace(Throwable)
to get the filtered the stack trace.t
- the throwableshouldFilter
- true in case filtering should be performed. Else stack trace as string will be returned.public static String getFilteredStackTrace(Throwable t, int ref)
Throwable
using a reference position. Intermediate throwables will be printed
with just their header.t
- the throwableref
- throwable reference position, see getThrowable(List, int)
.public static String getStackTrace(Throwable t)
Throwable
's stack trace.t
- the throwablepublic static String getStackTrace(Throwable t, int ref)
Throwable
using a reference position. Intermediate throwables will be
printed with just their header.t
- the throwableref
- throwable reference position, see getThrowable(List, int)
.public static Throwable getThrowable(Throwable throwable, int ref)
Throwable
by its reference position.
This method extracts a Throwable
from the exception chain of causes
. A reference of
0
returns the original Throwable
, values greater zero will walk the cause chain up so a reference
1
returns t.getCause()
. Negative reference values will walk the causing exception from the root cause
side. A reference of -1
returns the root cause, -2
the exception that wraps the root cause and so on.
Copyright © 2013–2023. All rights reserved.