public class LogConfig extends Object implements Config
Note that only things known to REST Assured (i.e. the request- and response specifications) will be logged. If you need to log what's actually sent on the wire refer to the HTTP Client logging docs or use an external tool such as Wireshark.
Constructor and Description |
---|
LogConfig()
Configure the default stream to use the System.out stream (default).
|
LogConfig(PrintStream defaultPrintStream,
boolean prettyPrintingEnabled)
Configure pretty printing and the default stream where logs should be written if not specified explicitly by a filter.
|
Modifier and Type | Method and Description |
---|---|
LogConfig |
and()
Syntactic sugar.
|
PrintStream |
defaultStream() |
LogConfig |
defaultStream(PrintStream printStream)
Specify a new default stream to the print to.
|
LogConfig |
enableLoggingOfRequestAndResponseIfValidationFails()
Enable logging of both the request and the response if REST Assureds test validation fails.
|
LogConfig |
enableLoggingOfRequestAndResponseIfValidationFails(LogDetail logDetail)
Enable logging of both the request and the response if REST Assureds test validation fails with the specified log detail
|
LogConfig |
enablePrettyPrinting(boolean shouldEnable)
Specify a whether or not to enable pretty printing by default.
|
boolean |
isLoggingOfRequestAndResponseIfValidationFailsEnabled() |
boolean |
isPrettyPrintingEnabled() |
boolean |
isUserConfigured() |
static LogConfig |
logConfig() |
LogDetail |
logDetailOfRequestAndResponseIfValidationFails() |
boolean |
shouldUrlEncodeRequestUri() |
LogConfig |
urlEncodeRequestUri(boolean urlEncodeRequestUri)
Instruct REST Assured whether or not to URL encode the request URI when it's presented in the request specification log.
|
public LogConfig()
public LogConfig(PrintStream defaultPrintStream, boolean prettyPrintingEnabled)
given().log().all()...or
expect().log.ifError(). ..It will not override explicit streams defined by using the
RequestLoggingFilter
or the ResponseLoggingFilter
.defaultPrintStream
- The default print stream to use for the LogSpecification
's.prettyPrintingEnabled
- Enable or disable pretty printing when logging. Pretty printing is only possible when content-type is XML, JSON or HTML.public PrintStream defaultStream()
public LogConfig defaultStream(PrintStream printStream)
printStream
- The streampublic boolean isPrettyPrintingEnabled()
true
if pretty printing is enabled, false
otherwise.public boolean isLoggingOfRequestAndResponseIfValidationFailsEnabled()
true
if request and response logging is enabled if test validation fails, false
otherwise.public LogDetail logDetailOfRequestAndResponseIfValidationFails()
public LogConfig enablePrettyPrinting(boolean shouldEnable)
shouldEnable
- true
if pretty-printing should be enabled, false
otherwise.public LogConfig enableLoggingOfRequestAndResponseIfValidationFails()
public LogConfig enableLoggingOfRequestAndResponseIfValidationFails(LogDetail logDetail)
logDetail
- The log detail to show in the logpublic LogConfig urlEncodeRequestUri(boolean urlEncodeRequestUri)
urlEncodeRequestUri
to false
. Note that this only affects logging.urlEncodeRequestUri
- Whether or not to url encode the request uri when it's presented in the request logpublic boolean shouldUrlEncodeRequestUri()
true
is the request URI should be URL encoded in the request logpublic static LogConfig logConfig()
public LogConfig and()
public boolean isUserConfigured()
isUserConfigured
in interface Config
true
if this config instance has been explicitly configured by the user, false
if it has the default values.Copyright © 2010–2019. All rights reserved.