Class DefaultExchangeFormatter
- java.lang.Object
-
- org.apache.camel.support.processor.DefaultExchangeFormatter
-
- All Implemented Interfaces:
org.apache.camel.spi.ExchangeFormatter
@UriParams @Configurer public class DefaultExchangeFormatter extends Object implements org.apache.camel.spi.ExchangeFormatter
DefaultExchangeFormatter
that have fine grained options to configure what to include in the output.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
DefaultExchangeFormatter.OutputStyle
-
Constructor Summary
Constructors Constructor Description DefaultExchangeFormatter()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected Map<String,Object>
filterHeaderAndProperties(Map<String,Object> map)
Filters the headers or properties before formatting them.String
format(org.apache.camel.Exchange exchange)
protected String
getBodyAsString(org.apache.camel.Message message)
protected String
getBodyTypeAsString(org.apache.camel.Message message)
int
getMaxChars()
DefaultExchangeFormatter.OutputStyle
getStyle()
boolean
isMultiline()
boolean
isPlain()
boolean
isShowAll()
boolean
isShowAllProperties()
boolean
isShowBody()
boolean
isShowBodyType()
boolean
isShowCaughtException()
boolean
isShowException()
boolean
isShowExchangeId()
boolean
isShowExchangePattern()
boolean
isShowFiles()
boolean
isShowFuture()
boolean
isShowHeaders()
boolean
isShowProperties()
boolean
isShowStackTrace()
boolean
isShowStreams()
boolean
isSkipBodyLineSeparator()
void
setMaxChars(int maxChars)
Limits the number of characters logged per line.void
setMultiline(boolean multiline)
If enabled then each information is outputted on a newline.void
setPlain(boolean plain)
If enabled only the body will be printed outvoid
setShowAll(boolean showAll)
Quick option for turning all options on.void
setShowAllProperties(boolean showAllProperties)
Show all of the exchange properties (both internal and custom).void
setShowBody(boolean showBody)
void
setShowBodyType(boolean showBodyType)
Show the body Java type.void
setShowCaughtException(boolean showCaughtException)
If the exchange has a caught exception, show the exception message (no stack trace).void
setShowException(boolean showException)
If the exchange has an exception, show the exception message (no stacktrace)void
setShowExchangeId(boolean showExchangeId)
Show the unique exchange ID.void
setShowExchangePattern(boolean showExchangePattern)
Shows the Message Exchange Pattern (or MEP for short).void
setShowFiles(boolean showFiles)
If enabled Camel will output filesvoid
setShowFuture(boolean showFuture)
If enabled Camel will on Future objects wait for it to complete to obtain the payload to be logged.void
setShowHeaders(boolean showHeaders)
Show the message headers.void
setShowProperties(boolean showProperties)
Show the exchange properties (only custom).void
setShowStackTrace(boolean showStackTrace)
Show the stack trace, if an exchange has an exception.void
setShowStreams(boolean showStreams)
Whether Camel should show stream bodies or not (eg such as java.io.InputStream).void
setSkipBodyLineSeparator(boolean skipBodyLineSeparator)
Whether to skip line separators when logging the message body.void
setStyle(DefaultExchangeFormatter.OutputStyle style)
Sets the outputs style to use.
-
-
-
Field Detail
-
LS
protected static final String LS
-
-
Method Detail
-
format
public String format(org.apache.camel.Exchange exchange)
- Specified by:
format
in interfaceorg.apache.camel.spi.ExchangeFormatter
-
filterHeaderAndProperties
protected Map<String,Object> filterHeaderAndProperties(Map<String,Object> map)
Filters the headers or properties before formatting them. No default behavior, but can be overridden.
-
isShowExchangeId
public boolean isShowExchangeId()
-
setShowExchangeId
public void setShowExchangeId(boolean showExchangeId)
Show the unique exchange ID.
-
isShowProperties
public boolean isShowProperties()
-
setShowProperties
public void setShowProperties(boolean showProperties)
Show the exchange properties (only custom). Use showAllProperties to show both internal and custom properties.
-
isShowAllProperties
public boolean isShowAllProperties()
-
setShowAllProperties
public void setShowAllProperties(boolean showAllProperties)
Show all of the exchange properties (both internal and custom).
-
isShowHeaders
public boolean isShowHeaders()
-
setShowHeaders
public void setShowHeaders(boolean showHeaders)
Show the message headers.
-
isSkipBodyLineSeparator
public boolean isSkipBodyLineSeparator()
-
setSkipBodyLineSeparator
public void setSkipBodyLineSeparator(boolean skipBodyLineSeparator)
Whether to skip line separators when logging the message body. This allows to log the message body in one line, setting this option to false will preserve any line separators from the body, which then will log the body as is.
-
isShowBodyType
public boolean isShowBodyType()
-
setShowBodyType
public void setShowBodyType(boolean showBodyType)
Show the body Java type.
-
isShowBody
public boolean isShowBody()
-
setShowBody
public void setShowBody(boolean showBody)
-
isShowAll
public boolean isShowAll()
-
setShowAll
public void setShowAll(boolean showAll)
Quick option for turning all options on. (multiline, maxChars has to be manually set if to be used)
-
isShowException
public boolean isShowException()
-
setShowException
public void setShowException(boolean showException)
If the exchange has an exception, show the exception message (no stacktrace)
-
isShowStackTrace
public boolean isShowStackTrace()
-
setShowStackTrace
public void setShowStackTrace(boolean showStackTrace)
Show the stack trace, if an exchange has an exception. Only effective if one of showAll, showException or showCaughtException are enabled.
-
isShowCaughtException
public boolean isShowCaughtException()
-
setShowCaughtException
public void setShowCaughtException(boolean showCaughtException)
If the exchange has a caught exception, show the exception message (no stack trace). A caught exception is stored as a property on the exchange (using the keyExchange.EXCEPTION_CAUGHT
and for instance a doCatch can catch exceptions.
-
isMultiline
public boolean isMultiline()
-
getMaxChars
public int getMaxChars()
-
setMaxChars
public void setMaxChars(int maxChars)
Limits the number of characters logged per line.
-
setMultiline
public void setMultiline(boolean multiline)
If enabled then each information is outputted on a newline.
-
isShowFuture
public boolean isShowFuture()
-
setShowFuture
public void setShowFuture(boolean showFuture)
If enabled Camel will on Future objects wait for it to complete to obtain the payload to be logged.
-
isShowExchangePattern
public boolean isShowExchangePattern()
-
setShowExchangePattern
public void setShowExchangePattern(boolean showExchangePattern)
Shows the Message Exchange Pattern (or MEP for short).
-
isShowStreams
public boolean isShowStreams()
-
setShowStreams
public void setShowStreams(boolean showStreams)
Whether Camel should show stream bodies or not (eg such as java.io.InputStream). Beware if you enable this option then you may not be able later to access the message body as the stream have already been read by this logger. To remedy this you will have to use Stream Caching.
-
isShowFiles
public boolean isShowFiles()
-
setShowFiles
public void setShowFiles(boolean showFiles)
If enabled Camel will output files
-
getStyle
public DefaultExchangeFormatter.OutputStyle getStyle()
-
setStyle
public void setStyle(DefaultExchangeFormatter.OutputStyle style)
Sets the outputs style to use.
-
isPlain
public boolean isPlain()
-
setPlain
public void setPlain(boolean plain)
If enabled only the body will be printed out
-
getBodyAsString
protected String getBodyAsString(org.apache.camel.Message message)
-
getBodyTypeAsString
protected String getBodyTypeAsString(org.apache.camel.Message message)
-
-