public class ShortenedThrowableConverter extends ThrowableHandlingConverter
ThrowableHandlingConverter
(similar to logback's ThrowableProxyConverter
)
that formats stacktraces by doing the following:
maxDepthPerThrowable
.maxLength
.shortenedClassNameLength
.
See shortenedClassNameLength
.excludes
.evaluators
.rootCauseFirst
.PatternLayout
, you must configure conversionRule
as described here.
Options can be specified in the pattern in the following order:
For example,
<conversionRule conversionWord="stack"
converterClass="net.logstash.logback.stacktrace.ShortenedThrowableConverter" />
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>[%thread] - %msg%n%stack{5,1024,10,rootFirst,regex1,regex2,evaluatorName}</pattern>
</encoder>
</appender>
Modifier and Type | Field and Description |
---|---|
static int |
DEFAULT_CLASS_NAME_LENGTH |
static String |
DEFAULT_INLINE_SEPARATOR
String sequence to use to delimit lines instead of
CoreConstants.LINE_SEPARATOR when inline is active |
static int |
DEFAULT_MAX_DEPTH_PER_THROWABLE |
static int |
DEFAULT_MAX_LENGTH |
static int |
FULL_CLASS_NAME_LENGTH |
static int |
FULL_MAX_DEPTH_PER_THROWABLE |
static int |
FULL_MAX_LENGTH |
static int |
SHORT_CLASS_NAME_LENGTH |
static int |
SHORT_MAX_DEPTH_PER_THROWABLE |
static int |
SHORT_MAX_LENGTH |
started
Constructor and Description |
---|
ShortenedThrowableConverter() |
Modifier and Type | Method and Description |
---|---|
void |
addEvaluator(EventEvaluator<ILoggingEvent> evaluator) |
void |
addExclude(String exclusionPattern) |
String |
convert(ILoggingEvent event) |
List<EventEvaluator<ILoggingEvent>> |
getEvaluators() |
List<String> |
getExcludes() |
String |
getLineSeparator() |
int |
getMaxDepthPerThrowable() |
int |
getMaxLength() |
int |
getShortenedClassNameLength() |
boolean |
isInlineHash() |
boolean |
isRootCauseFirst() |
void |
setEvaluators(List<EventEvaluator<ILoggingEvent>> evaluators) |
void |
setExcludes(List<String> exclusionPatterns) |
void |
setExclusions(String comaSeparatedPatterns)
Set exclusion patterns as a list of coma separated patterns
|
void |
setInlineHash(boolean inlineHash) |
void |
setLineSeparator(String lineSeparator)
Sets which lineSeparator to use between events.
|
void |
setMaxDepthPerThrowable(int maxDepthPerThrowable) |
void |
setMaxLength(int maxLength) |
void |
setRootCauseFirst(boolean rootCauseFirst) |
void |
setShortenedClassNameLength(int length) |
protected void |
setStackHasher(StackHasher stackHasher) |
void |
start() |
addError, addError, addInfo, addInfo, addStatus, addWarn, addWarn, getContext, getFirstOption, getOptionList, isStarted, setContext, setOptionList, stop
getFormattingInfo, setFormattingInfo, write
public static final int FULL_MAX_DEPTH_PER_THROWABLE
public static final int SHORT_MAX_DEPTH_PER_THROWABLE
public static final int DEFAULT_MAX_DEPTH_PER_THROWABLE
public static final int FULL_MAX_LENGTH
public static final int SHORT_MAX_LENGTH
public static final int DEFAULT_MAX_LENGTH
public static final int FULL_CLASS_NAME_LENGTH
public static final int SHORT_CLASS_NAME_LENGTH
public static final int DEFAULT_CLASS_NAME_LENGTH
public static final String DEFAULT_INLINE_SEPARATOR
CoreConstants.LINE_SEPARATOR
when inline is activepublic void start()
start
in interface LifeCycle
start
in class DynamicConverter<ILoggingEvent>
public String convert(ILoggingEvent event)
convert
in class Converter<ILoggingEvent>
public String getLineSeparator()
public void setLineSeparator(String lineSeparator)
The following values have special meaning:
null
or empty string = no new line.SYSTEM
" = operating system new line (default).UNIX
" = unix line ending (\n
).WINDOWS
" = windows line ending \r\n
).Any other value will be used as given as the lineSeparator.
lineSeparator
- the line separatorpublic int getShortenedClassNameLength()
public void setShortenedClassNameLength(int length)
public int getMaxDepthPerThrowable()
public void setMaxDepthPerThrowable(int maxDepthPerThrowable)
public void setMaxLength(int maxLength)
public int getMaxLength()
public boolean isRootCauseFirst()
public void setRootCauseFirst(boolean rootCauseFirst)
public boolean isInlineHash()
public void setInlineHash(boolean inlineHash)
protected void setStackHasher(StackHasher stackHasher)
public void addExclude(String exclusionPattern)
public void setExclusions(String comaSeparatedPatterns)
comaSeparatedPatterns
- list of coma separated patternspublic void addEvaluator(EventEvaluator<ILoggingEvent> evaluator)
public void setEvaluators(List<EventEvaluator<ILoggingEvent>> evaluators)
public List<EventEvaluator<ILoggingEvent>> getEvaluators()
Copyright © 2013–2022. All rights reserved.