ctx.logger
A logging wrapper based on pino, providing high-performance structured JSON logs. It is recommended to use ctx.logger instead of console for easier log collection and analysis.
Scenarios
ctx.logger can be used in all RunJS scenarios for debugging, error tracking, performance analysis, etc.
Type Definition
ctx.logger is an instance of engine.logger.child({ module: 'flow-engine' }), which is a pino child logger with a module context.
Log Levels
pino supports the following levels (from highest to lowest):
Recommended Usage
The recommended format is level(msg, meta): the message comes first, followed by an optional metadata object.
pino also supports level(meta, msg) (object first) or level({ msg, ...meta }) (single object), which can be used as needed.
Examples
Basic Usage
Creating a Child Logger with child()
Relationship with console
It is recommended to use ctx.logger directly to obtain structured JSON logs. If you are accustomed to using console, the mappings are: console.log → ctx.logger.info, console.error → ctx.logger.error, console.warn → ctx.logger.warn.
Log Format
pino outputs structured JSON, where each log entry contains:
level: Log level (numeric)time: Timestamp (milliseconds)msg: Log messagemodule: Fixed asflow-engine- Other custom fields (passed via objects)
Notes
- Logs are structured JSON, making them easy to collect, search, and analyze.
- Child loggers created via
child()also follow thelevel(msg, meta)recommendation. - Some runtime environments (such as Workflows) may use different log output methods.
Related
- pino — The underlying logging library

