PostgreSQL有3种日志,分别是pg_log(数据库运行日志)、pg_xlog(WAL 日志,即重做日志)、pg_clog(事务提交日志,记录的是事务的元数据)
pg_log默认是关闭的,需要设置参数启用此日志。pg_xlog和pg_clog都是强制打开的,无法关闭。logging_collector = on/off 是否将日志重定向至文件中,默认是off(修改后需重启DB)
把这个参数改成on后重新启动,可以查看日志:
root@scutech:/var/lib/postgresql/12/main# cat log/postgresql-2020-07-13_005901.log 2020-07-13 00:59:01.769 NDT [21075] LOG: database system was shut down at 2020-07-13 00:59:01 NDT 2020-07-13 00:59:01.800 NDT [21072] LOG: database system is ready to accept connections