Skip to content

Logging

Logging is one of the core capabilities of vite-enhanced-proxy. LoggerConfig controls what gets printed, colors, levels, and WS/SSE details.

LoggerConfig

OptionTypeDefaultDescription
levelLogLevelLogLevel.INFOLog level (DEBUG/INFO/WARN/ERROR)
colorfulbooleantrueEnable colored output
timestampbooleantrueShow timestamps
showMethodbooleantrueShow HTTP method
showStatusbooleantrueShow status code
showErrorbooleantrueShow error details
prefixstring[Proxy]Custom log prefix
showRequestHeadersbooleanfalsePrint request headers
showRequestBodybooleanfalsePrint request body
showResponseHeadersbooleanfalsePrint response headers
showResponseBodybooleanfalsePrint response body
showQueryParamsbooleanfalsePrint query parameters
maxBodyLengthnumber1000Max length for request/response bodies
prettifyJsonbooleantrueBeautify JSON output
showWsConnectionsbooleanfalseShow WebSocket connection logs
showWsMessagesbooleanfalseShow WebSocket messages
maxWsMessageLengthnumber1000WS message truncate length
showSseConnectionsbooleanfalseShow SSE connection logs
showSseMessagesbooleanfalseShow SSE messages
maxSseMessageLengthnumber1000SSE message truncate length

Practical presets

Watch only errors

ts
createProxyPlugin({
  logger: {
    level: LogLevel.ERROR,
    colorful: false,
    showRequestBody: false,
    showResponseBody: false
  }
});

Debug mode: dump everything

ts
createProxyPlugin({
  logger: {
    level: LogLevel.DEBUG,
    showRequestHeaders: true,
    showRequestBody: true,
    showResponseHeaders: true,
    showResponseBody: true,
    showQueryParams: true,
    maxBodyLength: 10_000
  }
});

WebSocket / SSE visibility

ts
createProxyPlugin({
  logger: {
    showWsConnections: true,
    showWsMessages: true,
    maxWsMessageLength: 2_000,
    showSseConnections: true,
    showSseMessages: true,
    maxSseMessageLength: 2_000
  }
});

Performance tips

  1. Verbose logs consume more CPU/IO. In production, set level to ERROR and optionally devOnly: true.
  2. Use requestFilter / responseFilter to avoid noisy logs.
  3. Control output size with maxBodyLength, maxWsMessageLength, and maxSseMessageLength.

Sample output

text
2024-01-15 14:30:25 [Proxy] [GET   ] 🚀 Proxying to: http://localhost:8000/api/v3/backend/user
2024-01-15 14:30:25 [Proxy] [GET   ] ✅ 200 http://localhost:8000/api/v3/backend/user (156ms)

2024-01-15 14:30:26 [Proxy] [POST  ] ❌ 404 http://localhost:8000/api/v3/backend/login (89ms)

2024-01-15 14:30:28 [Proxy] [POST  ] 📤 Request details: http://localhost:8000/api/v3/backend/login
  Query: {"redirect": "/dashboard"}
  Headers:
    content-type: application/json
  Body: {...}

Released under the MIT License