Skip to content

payload.config.ts logger options not compatible with all pino options #11492

@MakoriSM

Description

@MakoriSM

Documentation Issue

The documentation for the logger configuration option in Payload is misleading regarding compatibility with Pino's API options. The docs state: "Logger options, logger options with a destination stream, or an instantiated logger instance. More details" which implies full compatibility with Pino's options API, but this is not the case.

Specifically, when attempting to use Pino's transport option directly in the Payload config (to enable pretty-printing logs), the following error occurs:

Error: unable to determine transport target for "pino-pretty"

Additional Details

When following the documentation and trying to configure the logger with Pino's transport option like this:

logger: {
  options: {
    level: 'debug',
    transport: {
      target: 'pino-pretty',
      options: {
        colorize: true,
        translateTime: true,
        // other options...
      }
    }
  }
}

The application fails to start with the error mentioned above. This happens even after installing the pino-pretty package.

However, creating a custom logger instance outside the Payload config works perfectly:

import pino from 'pino'
import pinoPretty from 'pino-pretty'

const prettyStream = pinoPretty({
  colorize: true,
  translateTime: true,
  // other options...
})

const logger = pino(
  {
    level: process.env.LOG_LEVEL || 'debug',
  },
  prettyStream
)

export default logger

// In payload.config.ts
import logger from './utils/logger'

export default buildConfig({
  // ...
  logger,
  // ...
})

This suggests that either:

  1. The Payload logger implementation doesn't fully support Pino's transport system
  2. There's an issue with module resolution in the Payload context
  3. The documentation should clarify the limitations of the logger configuration

The documentation should be updated to either explain these limitations or provide the correct way to configure pretty-printing in Payload's logger.

Metadata

Metadata

Assignees

Labels

area: docsImprovements or additions to documentation

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions