Class CallLoggerRule.Builder
- Enclosing class:
CallLoggerRule
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected CallLoggerRule
Creates the bean when the bean type isnull or is the default value.disabled()
Shortcut for callingenabled( .NEVER )enabled
(Enablement value) Specifies whether logging is enabled when using this rule.enabledPredicate
(Predicate<jakarta.servlet.http.HttpServletRequest> value) Specifies the predicate test to use when the enabled setting is set toCONDITIONALLY
.exceptionFilter
(Predicate<Throwable> value) Apply a throwable-based predicate check for this rule to match against.Overrides the bean returned by theBeanBuilder.build()
method.The logging level to use for logging the request/response.Log a stack trace as part of the log entry.requestDetail
(CallLoggingDetail value) The level of detail to log on a request.requestFilter
(Predicate<jakarta.servlet.http.HttpServletRequest> value) Apply a request-based predicate check for this rule to match against.responseDetail
(CallLoggingDetail value) The level of detail to log on a response.responseFilter
(Predicate<jakarta.servlet.http.HttpServletResponse> value) Apply a response-based predicate check for this rule to match against.statusFilter
(Predicate<Integer> value) Apply a status-based predicate check for this rule to match against.Overrides the bean type produced by theBeanBuilder.build()
method.
-
Constructor Details
-
Builder
Constructor.- Parameters:
beanStore
- The bean store to use for creating beans.
-
-
Method Details
-
buildDefault
Description copied from class:BeanBuilder
Creates the bean when the bean type isnull or is the default value.- Overrides:
buildDefault
in classBeanBuilder<CallLoggerRule>
- Returns:
- A new bean.
-
statusFilter
Apply a status-based predicate check for this rule to match against.Example:
// Create a logger rule that only matches if the status code is greater than or equal to 500. RestLogger .createRule () .statusFilter(x ->x >= 500) .build();- Parameters:
value
- The predicate check, ornull to not use any filtering based on status code.- Returns:
- This object.
-
exceptionFilter
Apply a throwable-based predicate check for this rule to match against.Example:
// Create a logger rule that only matches if a NotFound exception was thrown. RestLogger .createRule () .exceptionFilter(x ->x instanceof NotFound) .build();This check is only performed if an actual throwable was thrown. Therefore it's not necessary to perform a null check in the predicate.
- Parameters:
value
- The predicate check, ornull to not use any filtering based on exceptions.- Returns:
- This object.
-
requestFilter
public CallLoggerRule.Builder requestFilter(Predicate<jakarta.servlet.http.HttpServletRequest> value) Apply a request-based predicate check for this rule to match against.Example:
// Create a logger rule that only matches if the servlet path contains "foobar". RestLogger .createRule () .requestFilter(x ->x .getServletPath().contains("foobar" )) .build();- Parameters:
value
- The predicate check, ornull to not use any filtering based on the request.- Returns:
- This object.
-
responseFilter
public CallLoggerRule.Builder responseFilter(Predicate<jakarta.servlet.http.HttpServletResponse> value) Apply a response-based predicate check for this rule to match against.Example:
// Create a logger rule that only matches if the servlet path contains "foobar". RestLogger .createRule () .responseFilter(x ->x .getStatus() >= 500) .build();Note that the
statusFilter(Predicate)
andexceptionFilter(Predicate)
methods are simply convenience response filters.- Parameters:
value
- The predicate check, ornull to not use any filtering based on the response.- Returns:
- This object.
-
enabled
Specifies whether logging is enabled when using this rule.Example:
// Create a logger rule where logging is only enabled if the query string contains "foobar". RestLogger .createRule () .enabled(CONDITIONALLY ) .enabledPredicate(x ->x .getQueryString().contains("foobar" )) .build();ALWAYS
- Logging is enabled.NEVER
- Logging is disabled.CONDITIONALLY
- Logging is enabled if it passes theenabledPredicate(Predicate)
test.
- Parameters:
value
- The enablement flag value, ornull to inherit from the call logger whose default value isALWAYS
unless overridden via a"juneau.restCallLogger.enabled" system property or"JUNEAU_RESTCALLLOGGER_ENABLED" environment variable.- Returns:
- This object.
-
enabledPredicate
public CallLoggerRule.Builder enabledPredicate(Predicate<jakarta.servlet.http.HttpServletRequest> value) Specifies the predicate test to use when the enabled setting is set toCONDITIONALLY
.This setting has no effect if the enablement value is not
CONDITIONALLY
.Example:
// Create a logger rule where logging is only enabled if the query string contains "foobar". RestLogger .createRule () .enabled(CONDITIONALLY ) .enabledPredicate(x ->x .getQueryString().contains("foobar" )) .build();- Parameters:
value
- The enablement predicate test, ornull to inherit from the call logger whose default value is .x ->false - Returns:
- This object.
-
disabled
Shortcut for callingenabled( .NEVER )- Returns:
- This object.
-
requestDetail
The level of detail to log on a request.STATUS_LINE
- Log only the status line.HEADER
- Log the status line and headers.ENTITY
- Log the status line and headers and content if available.
- Parameters:
value
- The new value for this property, ornull to inherit from the call logger.- Returns:
- This object.
-
responseDetail
The level of detail to log on a response.STATUS_LINE
- Log only the status line.HEADER
- Log the status line and headers.ENTITY
- Log the status line and headers and content if available.
- Parameters:
value
- The new value for this property, ornull to inherit from the call logger.- Returns:
- This object.
-
level
The logging level to use for logging the request/response.The default value is
Level.INFO
.- Parameters:
value
- The new value for this property, ornull to inherit from the call logger.- Returns:
- This object.
-
logStackTrace
Log a stack trace as part of the log entry.The default value is
false .- Returns:
- This object.
-
impl
Description copied from class:BeanBuilder
Overrides the bean returned by theBeanBuilder.build()
method.Use this method if you want this builder to return an already-instantiated bean.
- Overrides:
impl
in classBeanBuilder<CallLoggerRule>
- Parameters:
value
- The setting value.- Returns:
- This object.
-
type
Description copied from class:BeanBuilder
Overrides the bean type produced by theBeanBuilder.build()
method.Use this method if you want to instantiated a bean subclass.
- Overrides:
type
in classBeanBuilder<CallLoggerRule>
- Parameters:
value
- The setting value.- Returns:
- This object.
-