# Set log_retention_days Greater Than 3 on Azure PostgreSQL Servers for Extended Log Retention

- Source: https://support.icompaas.com/support/solutions/articles/62000234797-set-log-retention-days-greater-than-3-on-azure-postgresql-servers-for-extended-log-retention
- Section: [Solutions](https://support.icompaas.com/support/solutions) › [Azure Database Services Benchmark v1.0.0](https://support.icompaas.com/support/solutions/62000112693) › [Azure Database Services Benchmark](https://support.icompaas.com/support/solutions/folders/62000169261)
- Last updated: 2026-05-29
- Publisher: iCompaas, Inc. (https://www.icompaas.com)

**Profile Applicability:**

-   **Level 1**  
    

**Description:** The log\_retention\_days parameter defines the number of days that PostgreSQL logs are retained. Ensuring that this parameter is set to a value greater than 3 days ensures that logs are available for troubleshooting, auditing, and performance analysis over a sufficient period.

**Rationale:** Logging is essential for identifying, troubleshooting, and analyzing database performance and security events. By keeping logs for a longer duration, you can track performance trends, detect anomalies, and comply with various auditing and security standards.

**Impact:**

-   Pros:  
    
    -   Logs are available for extended periods, aiding in diagnostics and security auditing.  
        
    -   Helps in meeting regulatory and internal compliance requirements for log retention.  
        
-   Cons:  
    
    -   Retaining logs for a longer period consumes additional storage space.  
        
    -   On high-traffic servers, the log files may grow quickly, potentially impacting disk space.  
        

**Default Value:**

The default value for log\_retention\_days is set to 3 days.

**Pre-requisites:** Ensure that log management solutions are in place to handle the growing log file sizes and that proper monitoring is established for log file retention.

**Remediation**

**Test Plan:**

**Using Azure Portal:**

1.  Log in to Azure Portal: [https://portal.azure.com](https://portal.azure.com/).  
    
2.  Navigate to Azure Database for PostgreSQL Servers.  
    
3.  Select the desired server.  
    
4.  Under Settings, click on Server parameters.  
    
5.  Ensure that the log\_retention\_days parameter is set to a value greater than 3.
    

**Using Azure CLI:**1\.  Run the following command to check the log\_retention\_days value:

az postgres server configuration show --resource-group <resource-group-name> --server-name <server-name> --name log\_retention\_days

-   The output should show a value greater than 3.  
    

**Implementation Plan:**

**Using Azure Portal:**

1.  Go to Azure Database for PostgreSQL Servers.  
    
2.  Select the PostgreSQL server and go to Server parameters.  
    
3.  Set the log\_retention\_days parameter to a value greater than 3 (preferably between 4 and 7).
    
4.  Save the changes.  
    

**Using Azure CLI:**1\.  To update log\_retention\_days, run the following command:

az postgres server configuration set --resource-group <resource-group-name> --server-name <server-name> --name log\_retention\_days --value <value-greater-than-3>

  

**Backout Plan:**

**Using Azure Portal:**

1.  Navigate to Azure Database for PostgreSQL Servers.  
    
2.  Under Settings, click on Server parameters.  
    
3.  Set the log\_retention\_days parameter back to 3 if necessary.
    

**Using Azure CLI:** 1. To revert the changes and set log\_retention\_days to 3, run:

az postgres server configuration set --resource-group <resource-group-name> --server-name <server-name> --name log\_retention\_days --value 3

  

**References:**

-   [Azure PostgreSQL Configuration Parameters  
    ](https://docs.microsoft.com/en-us/azure/postgresql/howto-configure-server-parameters-using-portal)
    
-   [Azure PostgreSQL Log Management](https://learn.microsoft.com/en-us/azure/postgresql/howto-configure-log-management)

## Related compliance guidance

- [SOC 2 compliance: a practical implementation guide for cloud-native SaaS teams](https://support.icompaas.com/compliance/soc-2-trust-services-criteria): Configuration checks like this one are the technical half of a SOC 2 / ISO 27001 programme — the guide shows where they fit, what else an auditor expects, and how to evidence them.
- [ISO/IEC 27001:2022 compliance: a practical implementation guide](https://support.icompaas.com/compliance/iso-27001-2022): ISO 27001 Annex A.8 (technological controls) is where cloud hardening evidence lands; the guide shows how to run the ISMS around it.
