# Ensure Server Parameter 'log_retention_days' is greater than 3 days for PostgreSQL Database Server

- Source: https://support.icompaas.com/support/solutions/articles/62000229893-ensure-server-parameter-log-retention-days-is-greater-than-3-days-for-postgresql-database-server
- Section: [Solutions](https://support.icompaas.com/support/solutions) › [General](https://support.icompaas.com/support/solutions/62000037933) › [Azure Compliance / Control / Check](https://support.icompaas.com/support/solutions/folders/62000168797)
- Last updated: 2026-05-29
- Publisher: iCompaas, Inc. (https://www.icompaas.com)

Description:

The PostgreSQL server parameter logfiles.retention\_days (log\_retention\_days) in Azure Database for PostgreSQL defines how long PostgreSQL server logs are retained before being automatically deleted. Ensuring this value is set to greater than 3 days ensures adequate retention of logs for auditing, troubleshooting, and forensic analysis.

  

Rationale:

-   Ensures sufficient retention of logs to support security investigations.
    
-   Helps meet regulatory requirements for log retention (GDPR, SOC 2, HIPAA, PCI-DSS, etc.).
    
-   Allows forensic teams to review connection, authentication, and error patterns over several days.
    
-   Protects against accidental loss of critical operational data.
    

  

Impact:

-   Enhanced auditability and visibility into database activity.
    
-   Sufficient historical logs for troubleshooting long-running incidents.
    
-   Supports compliance and security frameworks requiring multi-day log retention.
    
-   If not combined with proper storage monitoring, log storage could grow unexpectedly.
    
-   Higher log retention may slightly increase cost if logs are exported to Log Analytics.
    

  

Default Value:

-   For Azure Database for PostgreSQL Flexible Server, the default value for logfiles.retention\_days is 3 days.
    

  

Pre-requisites:

-   Global Administrator or Security Administrator permissions.
    
-   Must be Azure Database for PostgreSQL – Flexible Server (or Single Server if the parameter is supported).
    

  

Test Plan:

1.  Sign in to the Azure Portal at [https://portal.azure.com](https://portal.azure.com/)
    
2.  Search for and open Azure Database for PostgreSQL (Flexible Server)
    
3.  Select the target PostgreSQL server
    
4.  From the left menu, select Server parameters
    
5.  Search for the parameter logfiles.retention\_days
    
6.  Verify the parameter value is set to greater than 3 (for example, 4 or higher)
    
7.  If logfiles.retention\_days is set to 3 or less, follow the implementation steps
    

![](https://support.icompaas.com/assets/kb/ebb58f4b58dd2ef8.png)

  

  

Implementation Steps:

1.  Sign in to the Azure Portal at [https://portal.azure.com](https://portal.azure.com/)
    
2.  Search for your Azure Database for PostgreSQL server (Single or Flexible).
    
3.  On the left-hand menu, under the Settings section, select server parameters.
    

                                   ![](https://support.icompaas.com/assets/kb/eb1ef7f4b80361bb.png)

4.  Search for the parameter logfiles.retention\_days
    
5.  Set the value to greater than 3 (for example, 4 or higher)
    

![](https://support.icompaas.com/assets/kb/0e8fdb9d5d89fbf0.png)

6.  Click Save to apply the change
    

  

Backout Plan:

1.  Sign in to the Azure Portal at [https://portal.azure.com](https://portal.azure.com/)
    
2.  Search for and open Azure Database for PostgreSQL – Flexible Server
    
3.  Select the target PostgreSQL server
    
4.  From the left menu, select Server parameters
    
5.  Search for the parameter logfiles.retention\_days
    
6.  Change the value back to the previous or default setting (for example, 3)
    
7.  Click Save to apply the change
    

  

Reference:

-   [https://learn.microsoft.com/en-us/azure/postgresql/flexible-server/how-to-configure-server-logs?tabs=portal-enable-capture-of-logs%2Cportal-disable-capture-of-logs%2Cportal-list-captured-logs%2Cportal-download-captured-logs](https://learn.microsoft.com/en-us/azure/postgresql/flexible-server/how-to-configure-server-logs?tabs=portal-enable-capture-of-logs%2Cportal-disable-capture-of-logs%2Cportal-list-captured-logs%2Cportal-download-captured-logs)

## 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.
