log_min_duration_statement
Açıklaması şöyle
log_min_duration_statement: just logging the statements whose duration is more than this value in milliseconds. This is very useful for detecting slow queries.
Açıklaması şöyle
It sets the minimum execution time in milliseconds (ms) above which all statements will be logged.The default value for the log_min_duration_statement parameter is -1, which disables logging statements.Setting the PostgreSQL parameter log_min_duration_statement to 0 will print all statements' durations.
Örnek
Şöyle yaparız
# set log_min_duration_statement=1;SET # show log_min_duration_statement; log_min_duration_statement ---------------------------- 1ms (1 row)
PostgreSQL log dosyalarındaki statement log cümleleri şöyledir
LOG: duration: 5.477 ms statement: insert into abc values(1); LOG: duration: 8.656 ms statement: insert into abc values(2);
log_statement
ALL, MOD,DDL değerlerini alabilir
Açıklaması şöyle
Most fintech companies, who are required to log all user and application activities, set the most verbose option log_statement=all. This is the easiest way to bloat the log files and invite storage issues if storage consumption is not monitored. Pg_audit can be a smarter way of logging user activities, where you can specify which class of activities you want to log, such as READ, WRITE, DDL, or FUNCTION.
log_statement_sample_rate
Açıklama yaz
log_destination
Bu alanlar için Audit Trails yazısına bakabilirsiniz
PostgreSQL 15 için açıklama şöyle
PostgreSQL supports several methods for logging server messages, including stderr (default), csvlog, and syslog. With this release, jsonlog is also supported which is convenient for exporting logs and debugging. In order to enable this, add the jsonlog under the log_destination inside the postgresql.conf file.
This will be a nice feature to have with exports to logging and monitoring tools like HoneyComb and DataDog etc.