log_filename
| 버전 | 기본값 | context | 타입 |
|---|---|---|---|
| 14 | postgresql-%Y-%m-%d_%H%M%S | sighup | string |
| 15 | postgresql-%Y-%m-%d_%H%M%S | sighup | string |
| 16 | postgresql-%Y-%m-%d_%H%M%S | sighup | string |
| 17 | postgresql-%Y-%m-%d_%H%M%S | sighup | string |
| 18 | postgresql-%Y-%m-%d_%H%M%S | sighup | string |
| 19 | postgresql-%Y-%m-%d_%H%M%S | sighup | string |
logging_collector가 만드는 log 파일의 이름 패턴을 정한다.
값은 strftime 패턴으로 해석되어 %Y, %m, %d, %H 같은 % escape로 시간에 따라 변하는 파일 이름을 만들 수 있다. 시간대에 의존하는 escape는 log_timezone 기준으로 계산된다. 기본값은 postgresql-%Y-%m-%d_%H%M%S.log다. escape 없는 고정 이름을 지정하면 log가 한 파일에 계속 쌓이므로, 별도의 log rotation 유틸리티를 준비해야 디스크가 가득 차는 사태를 막을 수 있다.
log_destination에 CSV 형식 출력이 켜져 있으면 파일 이름 끝에 .csv가 붙고(이름이 .log로 끝나면 그 접미사를 치환), JSON 형식이면 같은 방식으로 .json이 붙는다. postgresql.conf 파일이나 서버 커맨드라인에서만 설정할 수 있다.
운영 노트: 7일 순환 보관이 필요하면
log_filename = 'postgresql-%a.log'(요일 이름)에 log_truncate_on_rotation = on, log_rotation_age = 1d를 조합하는 패턴이 널리 쓰인다.출처: PostgreSQL 18 문서