Menu
Amazon Relational Database Service
User Guide (API Version 2014-10-31)

Amazon RDS Database Log Files

You can view, download, and watch database logs using the Amazon RDS console, the AWS Command Line Interface (AWS CLI), or the Amazon RDS API. Viewing, downloading, or watching transaction logs is not supported.

For engine-specific documentation, see the following.

Database Engine Relevant Documentation

MariaDB

You can access the error log, the slow query log, and the general log. For more information, see MariaDB Database Log Files.

Microsoft SQL Server

You can access SQL Server error logs, agent logs, and trace files. For more information, see Microsoft SQL Server Database Log Files.

MySQL

You can access the error log, the slow query log, and the general log. For more information, see MySQL Database Log Files.

Oracle

You can access Oracle alert logs, audit files, and trace files. For more information, see Oracle Database Log Files.

PostgreSQL

You can access query logs and error logs. Error logs can contain auto-vacuum and connection information, as well as rds_admin actions. For more information, see PostgreSQL Database Log Files.

Viewing and Listing Database Log Files

You can view database log files for your DB engine by using the Amazon RDS console. You can list what log files are available for download or monitoring by using the AWS CLI or Amazon RDS API.

Note

If you can't view the list of log files for an existing Oracle DB instance, reboot the instance to view the list.

AWS Management Console

To view a database log file

  1. Open the Amazon RDS console at https://console.aws.amazon.com/rds/.

  2. In the navigation pane, choose Instances.

  3. Choose the DB instance that has the log file that you want to view, and then choose Instance Actions, See Details.

  4. Scroll down to the Logs section.

  5. In the Logs section, choose the log you wish to view and then choose View.

CLI

To list the available database log files for a DB instance, use the AWS CLI describe-db-log-files command.

The following example returns a list of log files for a DB instance named my-db-instance.

Example

aws rds describe-db-log-files --db-instance-identifier my-db-instance

API

To list the available database log files for a DB instance, use the Amazon RDS API DescribeDBLogFiles action.

Downloading a Database Log File

You can use the Amazon RDS console, AWS CLI or API to download a database log file.

AWS Management Console

To download a database log file

  1. Open the Amazon RDS console at https://console.aws.amazon.com/rds/.

  2. In the navigation pane, choose Instances.

  3. Choose the DB instance that has the log file that you want to view, and then choose Instance actions, See details.

  4. Scroll down to the Logs section.

  5. In the Logs section, choose the button next to the log you want to download, and then choose Download.

  6. Open the context (right-click) menu for the link provided, and then choose Save Link As. Type the location where you want the log file to be saved, and then choose Save.

    
								viewing log file

CLI

To download a database log file, use the AWS CLI command download-db-log-file-portion. By default, this command will download only the latest portion of a log file; however, you can download an entire file by specifying the parameter --starting-token 0.

The following example shows how to download the entire contents of a log file called log/ERROR.4 and store it in a local file called errorlog.txt.

Example

For Linux, OS X, or Unix:

aws rds download-db-log-file-portion \ --db-instance-identifier myexampledb \ --starting-token 0 --output text \ --log-file-name log/ERROR.4 > errorlog.txt

For Windows:

aws rds download-db-log-file-portion ^ --db-instance-identifier myexampledb ^ --starting-token 0 --output text ^ --log-file-name log/ERROR.4 > errorlog.txt

API

To download a database log file, use the Amazon RDS API DownloadDBLogFilePortion action.

Watching a Database Log File

You can monitor the contents of a log file by using the Amazon RDS console.

AWS Management Console

To watch a database log file

  1. Open the Amazon RDS console at https://console.aws.amazon.com/rds/.

  2. In the navigation pane, choose Instances.

  3. Choose the DB instance that has the log file that you want to watch, and then choose Instance actions, See details.

  4. In the Logs pane, choose a log filem, and then choose Watch.

Publishing Database Logs to Amazon CloudWatch Logs

In addition to viewing and downloading DB instance logs, you can also publish logs to Amazon CloudWatch Logs for real-time analysis. With CloudWatch Logs, you can perform real-time analysis of the log data, and you can use CloudWatch to create alarms and view metrics. You can use CloudWatch Logs store your log data in highly durable storage, which you can manage with the CloudWatch Logs Agent.

AWS retains log data published to CloudWatch Logs for an indefinite time period unless you specify a retention period. For more information about setting a CloudWatch Log retention period, see Change Log Data Retention in CloudWatch Logs.

For more information about publishing database logs to CloudWatch Logs, see the following:

Reading Log File Contents Using REST

Amazon RDS provides a REST endpoint that allows access to DB instance log files. This is useful if you need to write an application to stream Amazon RDS log file contents.

The syntax is:

GET /v13/downloadCompleteLogFile/DBInstanceIdentifier/LogFileName HTTP/1.1 Content-type: application/json host: rds.region.amazonaws.com

The following parameters are required:

  • DBInstanceIdentifier—the name of the DB instance that contains the log file you want to download.

  • LogFileName—the name of the log file to be downloaded.

The response contains the contents of the requested log file, as a stream.

The following example downloads the log file named log/ERROR.6 for the DB instance named sample-sql in the us-west-2 region.

GET /v13/downloadCompleteLogFile/sample-sql/log/ERROR.6 HTTP/1.1 host: rds.us-west-2.amazonaws.com X-Amz-Security-Token: AQoDYXdzEIH//////////wEa0AIXLhngC5zp9CyB1R6abwKrXHVR5efnAVN3XvR7IwqKYalFSn6UyJuEFTft9nObglx4QJ+GXV9cpACkETq= X-Amz-Date: 20140903T233749Z X-Amz-Algorithm: AWS4-HMAC-SHA256 X-Amz-Credential: AKIADQKE4SARGYLE/20140903/us-west-2/rds/aws4_request X-Amz-SignedHeaders: host X-Amz-Content-SHA256: e3b0c44298fc1c229afbf4c8996fb92427ae41e4649b934de495991b7852b855 X-Amz-Expires: 86400 X-Amz-Signature: 353a4f14b3f250142d9afc34f9f9948154d46ce7d4ec091d0cdabbcf8b40c558

If you specify a nonexistent DB instance, the response consists of the following error:

  • DBInstanceNotFoundDBInstanceIdentifier does not refer to an existing DB instance. (HTTP status code: 404)