Repository navigation
Logging
Arun Prakash edited this page Oct 25, 2026
·
1 revision
LoggingMiddleware writes one line per request to a sink of your choice. Credentials never reach the log.
final client = WordpressClient.forSite(
siteUrl: siteUrl,
bootstrapper: (b) => b.withMiddleware(LoggingMiddleware(sink: myLogger.info)).build(),
);The output looks like this:
GET https://example.com/wp-json/wp/v2/posts?per_page=5 -> 200 in 143 ms
POST https://example.com/wp-json/wp/v2/posts -> ERR connectionFailed in 12 ms
| Option | Default | |
|---|---|---|
sink |
print |
Receives each formatted line |
logRequests |
false |
Also log when a request starts |
logHeaders |
false |
Request and response headers |
logBodies |
false |
Bodies, cut at maxBodyLength (500) |
redactedHeaders |
authorization, cookie, set-cookie, x-api-key, proxy-authorization
|
Values shown as ***
|
redactedQueryKeys |
password, token, key, secret
|
Values shown as ***
|
Transport failures (timeouts, connection errors, cancellations) reach onResponse too, with a negative code, so they are logged as well, as ERR <RequestErrorType>. The duration is the full round trip including retries; with retries the line shows the attempt count.
For raw network traces use a Dio interceptor instead (b.withDioInterceptor(LogInterceptor())), and for verbose library logging b.withDebugMode(true). See also Events and Statistics.
Getting started
- Usage
- Bootstrap and Configuration
- Authorization
- Browser Sign-In
- WordPress.com and Jetpack
- Multisite
- Supported REST Methods
Requests and data
- Sending Requests
- Error Handling and Responses
- Fluent Queries
- Interfaces and Extensions
- Custom Post Types
- Model Generator
- Meta and ACF
- Concurrent Edits
- Batch Requests
- Embed and Fields
- Pagination and Finders
- Parallel Requests
- Streaming and Polling
- Pattern Directory Items
Behaviour
- Retries
- Caching
- Request De-duplication and Concurrency
- Middlewares
- Logging
- Offline Write Queue
- Events and Statistics
Other APIs
Extend and test
Reference