问题:
有人在我的一个表中添加了一个垃圾列。我想从日志中找出执行此事件的时间和地点。
请帮助解决这个问题。
最佳答案
确保在 postgresql.conf 中启用日志记录
1.log_destination = 'stderr' #log_destination = 'stderr,csvlog,syslog'
2.logging_collector = on #need restart
3.log_directory = 'pg_log'
4.log_file_name = 'postgresql-%Y-%m-%d_%H%M%S.log'
5.log_rotation_age = 1d
6.log_rotation_size = 10MB
7.log_min_error_statement = error
8.log_min_duration_statement = 5000 # -1 = disable ; 0 = ALL ; 5000 = 5sec
9.log_line_prefix = '|%m|%r|%d|%u|%e|'
10.log_statment = 'ddl' # 'none' | 'ddl' | 'mod' | 'all'
#prefer 'ddl' because the log output will be 'ddl' and 'query min duration'
如果您不启用它,请确保现在启用它。
如果你没有日志,最后一次尝试是pg_xlogdump
你的 xlog 文件在 pg_xlog 下并寻找 DDL
关于database - 我怎样才能在 postgres DB 中获取过去几个月的日志。,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44945687/