Package org.microproxy.extras
Class HttpLogger.Builder
java.lang.Object
org.microproxy.extras.HttpLogger.Builder
- Enclosing class:
HttpLogger
Configures an
HttpLogger.-
Method Summary
Modifier and TypeMethodDescriptionbuild()Creates the configured HTTP exchange logger.contentView(String name) The content view to render bodies with: "auto" (the default) for the best one for each body, or a view's name, such asgrpc.contentViews(ContentViews views) AtHttpLogger.Level.BODY, renders bodies throughviewswhere one applies (seecontentView(java.lang.String)): protobuf and gRPC message by message, JSON indented, form data, GraphQL, msgpack.format(HttpLogger.Format format) Readable blocks (default) or JSON lines.level(HttpLogger.Level level) How much to log (defaultHttpLogger.Level.HEADERS).maxBodyBytes(int maxBodyBytes) AtHttpLogger.Level.BODY, keeps at most this many bytes of each body (and of each WebSocket frame's text); the rest is counted but not kept.only(BiPredicate<HttpRequest, FlowContext> predicate) Logs only the exchanges whose request (as the client sent it) matches.Also replaces the values of these headers (any case) with "\u2588\u2588", on both sides of the proxy.Redacts nothing, not even the default headers; laterredactcalls add to that.redactQueryParams(String... names) Also replaces the values of these query parameters (any case) in logged URLs.Where each message goes, as one string (several lines inHttpLogger.Format.TEXT).webSocketFrames(boolean log) AtHttpLogger.Level.BODY, also logs WebSocket frames after an upgrade: text frames' text (up tomaxBodyBytes), other frames' sizes.
-
Method Details
-
level
How much to log (defaultHttpLogger.Level.HEADERS).- Parameters:
level- the amount of HTTP detail to log- Returns:
- this builder
-
format
Readable blocks (default) or JSON lines.- Parameters:
format- the log output format- Returns:
- this builder
-
redact
Also replaces the values of these headers (any case) with "\u2588\u2588", on both sides of the proxy.HttpLogger.DEFAULT_REDACTED_HEADERSare redacted already.- Parameters:
headerNames- the header names whose values to redact- Returns:
- this builder
-
redactQueryParams
Also replaces the values of these query parameters (any case) in logged URLs.- Parameters:
names- the query parameter names whose values to redact- Returns:
- this builder
-
redactNothing
Redacts nothing, not even the default headers; laterredactcalls add to that.- Returns:
- this builder
-
maxBodyBytes
AtHttpLogger.Level.BODY, keeps at most this many bytes of each body (and of each WebSocket frame's text); the rest is counted but not kept. Default 4096.- Parameters:
maxBodyBytes- the maximum body bytes to retain in each log entry- Returns:
- this builder
-
only
Logs only the exchanges whose request (as the client sent it) matches.- Parameters:
predicate- the predicate deciding which exchanges to log- Returns:
- this builder
-
sink
Where each message goes, as one string (several lines inHttpLogger.Format.TEXT). Default: theSystem.Logger"org.microproxy.http" at INFO.- Parameters:
sink- the consumer receiving each formatted log entry- Returns:
- this builder
-
webSocketFrames
AtHttpLogger.Level.BODY, also logs WebSocket frames after an upgrade: text frames' text (up tomaxBodyBytes), other frames' sizes. Off by default, since it makes the proxy parse every frame.- Parameters:
log- whether to log WebSocket frames- Returns:
- this builder
-
contentViews
AtHttpLogger.Level.BODY, renders bodies throughviewswhere one applies (seecontentView(java.lang.String)): protobuf and gRPC message by message, JSON indented, form data, GraphQL, msgpack. Bodies no view renders are shown as before. With views, gRPC'sgrpc-status,grpc-messageandgrpc-status-details-binfields are explained atHttpLogger.Level.HEADERSandHttpLogger.Level.BODY. Off by default.- Parameters:
views- the views, such asContentViews.defaults()or one with a schema- Returns:
- this builder
-
contentView
The content view to render bodies with: "auto" (the default) for the best one for each body, or a view's name, such asgrpc. Turns content views on withContentViews.defaults()ifcontentViews(org.microproxy.contentviews.ContentViews)was not called.- Parameters:
name- "auto" or a view's name- Returns:
- this builder
- Throws:
IllegalArgumentException- if there is no view of that name
-
build
Creates the configured HTTP exchange logger.- Returns:
- the configured exchange logger
-