I'm looking to get thorough logs of user activity attributable back to users from the official docker image of Postgres. I'm running my docker image like so:
docker run --name pg -e POSTGRES_PASSWORD=password -p 54320:5432 postgres -c log_statement=all -c log_line_prefix=`t=%m u=%u db=%d pid=[%p]:
But I'm getting logs that look like:
PostgreSQL init process complete; ready for start up.
LOG: starting PostgreSQL 13.1 (Debian 13.1-1.pgdg100+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 8.3.0-6) 8.3.0, 64-bit
LOG: listening on IPv4 address "0.0.0.0", port 5432
LOG: listening on IPv6 address "::", port 5432
LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
LOG: database system was shut down at 2021-01-24 11:58:13 UTC
LOG: database system is ready to accept connections
FATAL: database "test" does not exist
LOG: statement: SELECT VERSION()
LOG: statement: SHOW ALL
LOG: statement: SELECT datName FROM pg_database WHERE datAllowConn ORDER BY datName
LOG: statement: CREATE DATABASE "test"
LOG: statement: /* setup database */
CREATE TABLE IF NOT EXISTS users (
id SERIAL PRIMARY KEY,
name varchar(255) NOT NULL,
email varchar(255) NOT NULL,
password_hash varchar(255) NOT NULL
);
/* fill with seed data */
INSERT INTO users
(name, email, password_hash) VALUES
('Robert', '[email protected]', 'hash'),
('Bob', '[email protected]', 'new_hash'),
('Rob', '[email protected]', 'another hash');
/* read data, write data using good user */
/* read data, write data */
LOG: statement: SELECT name, setting FROM pg_settings WHERE source = 'session';
Which doesn't give me a good timestamp or attribute the activity to a user. What am I doing wrong?