Registry / database / pino-postgres

pino-postgres

JSON →
library0.0.41jsnpmunverified

pino-postgres is a pino transport that writes log entries to a PostgreSQL database. Version 0.0.41 is the latest stable release, last updated in 2020 with a low release cadence (no recent updates). It works as a command-line pipe transport, consuming pino NDJSON from stdin and inserting into a specified PostgreSQL table. Unlike other pino transports like pino-pretty (console output) or pino-elasticsearch (Elasticsearch), it targets PostgreSQL persistence without requiring a separate log shipper. It requires manual table creation with a jsonb column and offers configurable flush interval, buffer size, SSL support, and pass-through mode.

npm install pino-postgres
INSTALL
IMPORT
SIG · PINO-POSTGRES
P
pino-postgres
databasejavascriptv0.0.41
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

pino-postgres CLI
npm install -g pino-postgres node app.js | pino-postgres --connection postgres://localhost/mydb
pino-postgres is primarily used as a command-line transport piped from pino, not as a JavaScript API.

Demonstrates piping pino NDJSON logs to pino-postgres, requiring a pre-created PostgreSQL table with a jsonb column.

# Install pino and pino-postgres npm install pino pino-postgres # Create a logs table in PostgreSQL psql -U postgres -d mydb -c "CREATE TABLE logs (id SERIAL PRIMARY KEY, content JSONB NOT NULL, created_at TIMESTAMP DEFAULT NOW());" # Pipe pino logs to pino-postgres node -e "const pino = require('pino'); const logger = pino(); logger.info('hello'); logger.error('world');" | npx pino-postgres --connection postgres://postgres:password@localhost:5432/mydb --table logs --column content --flush-interval 1000 --buffer-size 100
Debug
Known issues
gotchapino-postgres does not create the database table automatically; you must create a table with a jsonb column before running the transport.
fix
Run a CREATE TABLE statement manually (e.g., CREATE TABLE logs (id SERIAL PRIMARY KEY, content JSONB, created_at TIMESTAMP DEFAULT NOW()));
affects: all
deprecatedThe package has not been updated since 2020 and the repository appears unmaintained. It may not support newer versions of pino or pg.
fix
Consider using alternative transports like pino-pretty, pino-roll, or writing a custom transport via pino.transport().
affects: latest
gotchaSSL must be explicitly enabled with --ssl flag; without it, the connection will fail if PostgreSQL requires SSL.
fix
Add --ssl to your pino-postgres command.
affects: all
gotchaThe transport uses a buffer that flushes every --flush-interval milliseconds or when buffer size exceeds --buffer-size. Logs may be lost if the process crashes before flush.
fix
Set --flush-interval and --buffer-size according to your reliability needs, or use a more robust transport.
affects: all
gotchaThe column name is 'content' by default; if you have a different column name, you must specify --column.
fix
Add --column <your_column_name> to the command line.
affects: all
Errors
Common errors & fixes
Error: getaddrinfo ENOTFOUND
Connection string hostname is incorrect or DNS resolution fails.
fix
Check the --connection string (e.g., postgres://user:pass@localhost:5432/mydb) and ensure PostgreSQL is accessible.
error: relation "logs" does not exist
The PostgreSQL table does not exist.
fix
Create the table in advance: CREATE TABLE logs (id SERIAL PRIMARY KEY, content JSONB, created_at TIMESTAMP DEFAULT NOW());
error: column "content" does not exist
The column name used (default 'content') is incorrect or table not created with that column.
fix
Either rename your column to 'content' or specify the correct column with --column <name>.
Error: self signed certificate
PostgreSQL requires SSL but the --ssl flag is not set.
fix
Add --ssl to the command line.
Upgrade
Version history
0.0.41latest on npm
Audit
Dependencies
pinorequiredpeer dependency - designed to work with pino logging library
pgrequiredruntime dependency - PostgreSQL client driver
pumprequiredruntime dependency - stream piping
split2requiredruntime dependency - splits NDJSON stream
Agent activity
2 hits · last 30 days
node
2
Resources
pino-postgres — npm install pino-postgres · libregistry