postgresql.audit: 이 로그 파일은 세션 및 객체 액세스 감사 로그를 수집합니다. 감사 로그를 수집하려면 감사 로그를 사용 설정해야 합니다.
postgresql.log: 이 로그 파일은 PostgreSQL 서버 로그를 수집합니다. 이러한 로그는 항상 수집되며 사용 설정할 필요가 없습니다.
로그 파일이 순환되면 다음과 같은 결과가 발생합니다.
로그 파일이 /obs/diagnostic/archive/ 디렉터리로 복사됩니다. 같은 이름의 로그 파일이 해당 디렉터리에 있으면 덮어씁니다.
순환된 로그 파일 원본의 콘텐츠가 삭제되어 파일이 비게 됩니다.
로그 정보가 즉시 빈 순환 로그 파일에 기록되기 시작합니다.
파일이 크기 또는 기간 기준에 도달할 때까지 로그 정보가 로그 파일에 기록되며, 이 시점에서 다시 순환됩니다. 로그가 너무 커지지 않도록 순환됩니다.
기본적으로 순환 설정은 크기가 200MB에 도달하면 각 로그 파일이 순환되도록 설정되어 있습니다. 기본 순환에는 기간 설정이 포함되지 않습니다.
보관처리된 각 파일은 Gzip(.gz) 파일 형식을 사용하여 개별적으로 압축됩니다.
보관처리된 파일은 7일 동안 보관됩니다. 7일이 지난 보관처리된 파일은 이전 순환 중에 보관처리된 파일을 제외하고 자동으로 삭제됩니다. 예를 들어 log_rotation_age가 7일보다 오래된 경우, 현재 파일이 순환되기 전에 보관처리된 파일이 7일 기준점에 도달합니다. 이 경우 다음 순환에서 보관처리된 새 파일이 생성될 때까지 이 보관처리된 파일이 삭제되지 않습니다.
보관처리된 각 로그 파일 이름은 postgresql-%Y-%m-%d_%H%M%S.log.gz 형식을 따릅니다.
타임스탬프는 로그 순환 시에 결정되며 협정 세계시(UTC)로 표시됩니다. 예를 들어 2024년 12월 20일 13시 1분 2초(UTC)에 로그가 순환되면 보관처리된 파일 이름은 postgresql-2024-12-20_130102.log.gz입니다.
보관처리된 파일을 영구적으로 저장하려면 kubectl cp를 사용하여 데이터베이스 컨테이너에서 로컬 디렉터리로 복사하면 됩니다.
apiVersion:alloydbomni.dbadmin.goog/v1kind:DBClustermetadata:name:DB_CLUSTER_NAMEspec:...primarySpec:...parameters:log_rotation_size:"400000"# 400 MBlog_rotation_age:"0"# Set to 0 to disable
로그 순환 기간 예시
다음 샘플은 24시간마다 로그가 순환되도록 설정합니다.
apiVersion:alloydbomni.dbadmin.goog/v1kind:DBClustermetadata:name:DB_CLUSTER_NAMEspec:...primarySpec:...parameters:log_rotation_size:"0"# Set to 0 to disablelog_rotation_age:"1440"# 24 hours * 60 minutes = 1 day
[[["이해하기 쉬움","easyToUnderstand","thumb-up"],["문제가 해결됨","solvedMyProblem","thumb-up"],["기타","otherUp","thumb-up"]],[["이해하기 어려움","hardToUnderstand","thumb-down"],["잘못된 정보 또는 샘플 코드","incorrectInformationOrSampleCode","thumb-down"],["필요한 정보/샘플이 없음","missingTheInformationSamplesINeed","thumb-down"],["번역 문제","translationIssue","thumb-down"],["기타","otherDown","thumb-down"]],["최종 업데이트: 2025-09-04(UTC)"],[[["\u003cp\u003eThis guide outlines how to configure the rotation of diagnostic logs for AlloyDB Omni when using the Kubernetes operator, covering both \u003ccode\u003epostgresql.audit\u003c/code\u003e and \u003ccode\u003epostgresql.log\u003c/code\u003e files.\u003c/p\u003e\n"],["\u003cp\u003eLog rotation involves copying the current log file to an archive directory, clearing the original log, and beginning new log entries in the now-empty original log file, and by default, logs rotate when they reach 200 MB.\u003c/p\u003e\n"],["\u003cp\u003eArchived log files are compressed in Gzip format (\u003ccode\u003e.gz\u003c/code\u003e) and are retained for 7 days, with the exception of the file from the previous rotation, which is kept until the next rotation occurs.\u003c/p\u003e\n"],["\u003cp\u003eYou can customize log rotation by setting \u003ccode\u003elog_rotation_size\u003c/code\u003e and \u003ccode\u003elog_rotation_age\u003c/code\u003e parameters in the \u003ccode\u003eDBCluster\u003c/code\u003e manifest, or you can disable rotation by setting either parameter to \u003ccode\u003e"0"\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eTo enable the collection of session and object access audit logs, you need to enable the \u003ccode\u003epgaudit\u003c/code\u003e parameter by adding \u003ccode\u003ealloydb.enable_pgaudit: "on"\u003c/code\u003e to the \u003ccode\u003eparameters\u003c/code\u003e section of the \u003ccode\u003ev1_dbcluster_parameters.yaml\u003c/code\u003e file.\u003c/p\u003e\n"]]],[],null,["# Configure AlloyDB Omni log rotation\n\nSelect a documentation version: 15.7.0keyboard_arrow_down\n\n- [Current (16.8.0)](/alloydb/omni/current/docs/configure-log-rotation)\n- [16.8.0](/alloydb/omni/16.8.0/docs/configure-log-rotation)\n- [16.3.0](/alloydb/omni/16.3.0/docs/configure-log-rotation)\n- [15.12.0](/alloydb/omni/15.12.0/docs/configure-log-rotation)\n- [15.7.1](/alloydb/omni/15.7.1/docs/configure-log-rotation)\n- [15.7.0](/alloydb/omni/15.7.0/docs/configure-log-rotation)\n\n\u003cbr /\u003e\n\nThis document describes how to configure rotation of AlloyDB Omni diagnostic logs when you use the AlloyDB Omni Kubernetes operator.\n\n\u003cbr /\u003e\n\nThe following log files are located in the `/obs/diagnostic/`\ndirectory:\n\n- `postgresql.audit`: This log file collects session and object access audit\n logs. To collect audit logs, you need to\n [enable audit logs](#enable-audit-logs).\n\n- `postgresql.log`: This log file collects PostgreSQL server logs. These logs\n are always collected and don't need to be enabled.\n\nWhen a log file rotates, the following occurs:\n\n1. The log file is copied to the `/obs/diagnostic/archive/` directory. If a log\n file with the same name exists in that directory, then it's overwritten.\n\n2. The contents of the original rotated log file are deleted so that the file\n is empty.\n\n3. Log information immediately begins writing to the empty rotated log file.\n Log information is written to the log file until the file reaches a size or\n age threshold, at which point it rotates again. Logs rotate so that they\n don't become too large.\n\nBy default, the rotation setting is for each log file to rotate when its size\nreaches 200 MB. The default rotation doesn't include an age setting.\n\nEach archived file is individually compressed using the Gzip (`.gz`) file format.\n\nArchived files are retained for 7 days. Archived files that are older\nthan 7 days are automatically removed, except for the file that was archived\nduring the previous rotation. For example, if `log_rotation_age` is older than 7 days,\nthen the archived file reaches the 7-day threshold before the rotation of the\ncurrent file. In this case, this archived file isn't removed until the next\nrotation generates a new archived file.\n\nEach archived log filename follows this format: `postgresql-%Y-%m-%d_%H%M%S.log.gz`.\nThe timestamp is determined at the time of log rotation and is expressed in\nCoordinated Universal Time (UTC). For example, if the log is rotated at\n13:01:02 of 12/20/2024 UTC, the archived filename is\n`postgresql-2024-12-20_130102.log.gz`.\n\nTo save an archived file permanently, you can copy it from the database container\nto your local directory using [`kubectl cp`](https://kubernetes.io/docs/reference/kubectl/generated/kubectl_cp/).\n\nEnable audit logs\n-----------------\n\nFor session and object access logs to be collected in the `postgresql.audit`\nfile, you need to enable the [`pgaudit`](https://github.com/pgaudit/pgaudit)\ndatabase parameter. To enable [`pgaudit`](https://github.com/pgaudit/pgaudit),\nadd the following line to the `parameters` section of the\n[`v1_dbcluster_parameters.yaml`](https://github.com/GoogleCloudPlatform/alloydb-omni-samples/blob/main/samples/v1_dbcluster_parameters.yaml)\nfile under `Secret`: \n\n alloydb.enable_pgaudit: \"on\"\n\nThe following is an example of this might look like: \n\n apiVersion: v1\n kind: Secret\n ...\n apiVersion: alloydbomni.dbadmin.goog/v1\n kind: DBCluster\n metadata:\n name: \u003cvar translate=\"no\"\u003e\u003cspan class=\"devsite-syntax-l devsite-syntax-l-Scalar devsite-syntax-l-Scalar-Plain\"\u003eDB_CLUSTER_NAME\u003c/span\u003e\u003c/var\u003e\n spec:\n databaseVersion: \"15.7.0\"\n primarySpec:\n ...\n parameters:\n ...\n alloydb.enable_pgaudit: \"on\"\n\nFor more information, see `pgaudit` in\n[Supported database extensions](/alloydb/omni/15.7.0/docs/reference/extensions),\nand [PostgreSQL Auditing Extension](https://www.pgaudit.org/).\nPostgreSQL server logs are always collected in the `postgresql.log` file and\ndon't require enabling [`pgaudit`](https://github.com/pgaudit/pgaudit).\n\nConfigure log rotation\n----------------------\n\nIf you want more control over when logs rotate, configure a maximum file size, a\nduration between log rotations, or both. The duration between log rotations is\nalso called the age of the log. If you use both settings, then each log rotates\nwhen it reaches one of the thresholds.\n\nTo configure log rotation, you set one or both of the following parameters in\nthe `parameters` section of the `DBCluster` manifest:\n\n- `log_rotation_size`: \"\u003cvar translate=\"no\"\u003eSIZE_IN_KB\u003c/var\u003e\"\n- `log_rotation_age`: \"\u003cvar translate=\"no\"\u003eAGE_IN_MINUTES\u003c/var\u003e\"\n\nTo disable one of the log rotation settings, set it to zero (`\"0\"`).\nTo retain the default setting that rotates logs when their file size\nreaches 200 MB, don't set either parameter.\n\n### Log rotation maximum log size and duration example\n\nThe following sample sets logs to rotate when their file size reaches\n400 MB or when the time between log rotations reaches one day, whichever\nhappens first: \n\n apiVersion: alloydbomni.dbadmin.goog/v1\n kind: DBCluster\n metadata:\n name: \u003cvar translate=\"no\"\u003e\u003cspan class=\"devsite-syntax-l devsite-syntax-l-Scalar devsite-syntax-l-Scalar-Plain\"\u003eDB_CLUSTER_NAME\u003c/span\u003e\u003c/var\u003e\n spec:\n ...\n primarySpec:\n ...\n parameters:\n log_rotation_size: \"400000\" # 400 MB\n log_rotation_age: \"1440\" # 24 hours * 60 minutes = 1 day\n\n### Log rotation maximum log size example\n\nThe following sample sets logs to rotate when their file size reaches\n400 MB: \n\n apiVersion: alloydbomni.dbadmin.goog/v1\n kind: DBCluster\n metadata:\n name: \u003cvar translate=\"no\"\u003e\u003cspan class=\"devsite-syntax-l devsite-syntax-l-Scalar devsite-syntax-l-Scalar-Plain\"\u003eDB_CLUSTER_NAME\u003c/span\u003e\u003c/var\u003e\n spec:\n ...\n primarySpec:\n ...\n parameters:\n log_rotation_size: \"400000\" # 400 MB\n log_rotation_age: \"0\" # Set to 0 to disable\n\n### Log rotation duration example\n\nThe following sample sets logs to rotate once every 24 hours: \n\n apiVersion: alloydbomni.dbadmin.goog/v1\n kind: DBCluster\n metadata:\n name: \u003cvar translate=\"no\"\u003e\u003cspan class=\"devsite-syntax-l devsite-syntax-l-Scalar devsite-syntax-l-Scalar-Plain\"\u003eDB_CLUSTER_NAME\u003c/span\u003e\u003c/var\u003e\n spec:\n ...\n primarySpec:\n ...\n parameters:\n log_rotation_size: \"0\" # Set to 0 to disable\n log_rotation_age: \"1440\" # 24 hours * 60 minutes = 1 day\n\nWhat's next\n-----------\n\n- [Manage and monitor AlloyDB Omni](/alloydb/omni/15.7.0/docs/run-connect)\n- [Generate and diagnose AlloyDB Omni dump files](/alloydb/omni/15.7.0/docs/manage-dump-files)\n- [Learn about automatic memory management](/alloydb/omni/15.7.0/docs/automatic-memory-management)"]]