DEV Community

Sihar Simbolon
Sihar Simbolon

Posted on

Reporting dan logging di PostgreSQL

Tujuan

  • Log query yang berjalan mulai dari 2 detik (2000ms)
  • Memastikan file log berada di direktori /var/log/postgresql
  • File log tergenerate harian
  • Log mencatat kapan dijalankannya sebuah query

PostgreSQL yang digunakan versi 12

Create direktori /var/log/postgresql dan set user ownernya

# mkdir /var/log/postgresql
# chown -R postgres.postgres /var/log/postgresql
Enter fullscreen mode Exit fullscreen mode

Sesuaikan bagian logging di file /var/lib/pgsql/12/data/postgresql.conf

...
log_min_duration_statement = 2000
log_directory = '/var/log/postgresql'
log_filename = 'postgresql-%Y-%m-%d.log'
...
Enter fullscreen mode Exit fullscreen mode

Reload konfigurasi PostgreSQL

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay