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:
- The Payload logger implementation doesn't fully support Pino's transport system
- There's an issue with module resolution in the Payload context
- 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.
Documentation Issue
The documentation for the
loggerconfiguration 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
transportoption directly in the Payload config (to enable pretty-printing logs), the following error occurs:Additional Details
When following the documentation and trying to configure the logger with Pino's transport option like this:
The application fails to start with the error mentioned above. This happens even after installing the
pino-prettypackage.However, creating a custom logger instance outside the Payload config works perfectly:
This suggests that either:
The documentation should be updated to either explain these limitations or provide the correct way to configure pretty-printing in Payload's logger.