Class CallLoggerRule.Builder

java.lang.Object
org.apache.juneau.BeanBuilder<CallLoggerRule>
org.apache.juneau.rest.logger.CallLoggerRule.Builder
Enclosing class:
CallLoggerRule

Builder class.
  • Constructor Details

    • Builder

      protected Builder(BeanStore beanStore)
      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 is null or is the default value.
      Overrides:
      buildDefault in class BeanBuilder<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, or null 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, or null 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, or null 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) and exceptionFilter(Predicate) methods are simply convenience response filters.

      Parameters:
      value - The predicate check, or null 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();

      Parameters:
      value - The enablement flag value, or null to inherit from the call logger whose default value is ALWAYS 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 to CONDITIONALLY.

      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, or null to inherit from the call logger whose default value is x -> false.
      Returns:
      This object.
    • disabled

      Shortcut for calling enabled(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, or null 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, or null 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, or null 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 the BeanBuilder.build() method.

      Use this method if you want this builder to return an already-instantiated bean.

      Overrides:
      impl in class BeanBuilder<CallLoggerRule>
      Parameters:
      value - The setting value.
      Returns:
      This object.
    • type

      public CallLoggerRule.Builder type(Class<?> value)
      Description copied from class: BeanBuilder
      Overrides the bean type produced by the BeanBuilder.build() method.

      Use this method if you want to instantiated a bean subclass.

      Overrides:
      type in class BeanBuilder<CallLoggerRule>
      Parameters:
      value - The setting value.
      Returns:
      This object.