> ## Documentation Index
> Fetch the complete documentation index at: https://kb.hosting.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Optimizing Magento log settings

> Optimize Magento's log settings and clean your database to prevent performance issues from large database growth.

This article describes how to optimize log settings for Magento.

<Warning>
  **Important**

  The following information and procedures only apply to Magento 1.9. They do not apply to Magento 2.0.
</Warning>

## About Magento logging

Magento databases can grow very large for a variety of reasons, such as when a store has a lot of products. One of the most common causes of large databases and performance issues, however, is Magento's logging feature. Magento logs several items, such as customer and quote information, in the database. Over time, these logs can grow very large, affecting database performance.

By optimizing Magento's log settings and cleaning the database log tables, you can significantly reduce database sizes and improve site performance. To optimize log settings, you use Magento's administration interface. Magento also includes a PHP script that you can run from the command line to clean database log tables and view how large they are.

<Warning>
  **Important**

  Before you optimize log settings, make sure you have configured Magento's cron job correctly. For more information about how to do this, please see [this article](/docs/optimizing-magento-cron-jobs-on-shared-hosting-accounts).
</Warning>

## Optimizing log settings using the Magento administration interface

To optimize log settings for your Magento store, follow these steps:

1. Log in to Magento using your administrator account.

2. On the top menu bar, click **System**, and then click **Configuration**.

3. In the **Configuration** pane on the left side, scroll down the page, and then under **Advanced**, click **System**.

4. Click **Log Cleaning**. The log settings appear.

5. In the **Save Log Days** text box, type `60`.
   > 📘 Note
   >
   > If you have a busy site or a store with a lot of products, you may want to save logs for even fewer days (such as 30 or 15) to keep the database size manageable.

6. In the **Enable Log Cleaning** list box, select **Yes**.

7. In the **Start Time** text boxes, select when Magento cleans the logs.

8. Confirm that the **Freqeuncy** list box is set to **Daily**.

9. The following settings are optional:

* In the **Error Email Recipient** text box, you can specify an e-mail address that receives messages if any errors occur during log cleanup.

* In the **Error Email Sender** list box, you can select the contact name that appears as the sender for any error messages.

* In the **Error Email Template** list box, select the **Log cleanup Warnings** default template.

10. Click **Save Config**. The new settings take effect immediately.

## Cleaning database log tables using the command line

Magento includes a PHP script that you can run from the command line to view the status of Magento's logs, as well as clean them manually. To do this, follow these steps:

1. Log in to your account [using SSH](/docs/using-ssh-secure-shell).

2. At the command prompt, type the following command:

```bash theme={null}
cd ~/public_html/shell
```

<Note>
  The path in this command assumes that you installed Magento in the document root ( *public\_html* ) directory. If you installed Magento in a subdirectory, change to that directory instead. For example, if you installed Magento in the *public\_html/magento* directory, type **cd \~/public\_html/magento/shell** .
</Note>

3. To view the size of each log table in the database, type the following command:

```bash theme={null}
php -f log.php status
```

4. To clean the log tables, type the following command. Replace *X* with the number of days that you want to save in the log tables:

```bash theme={null}
php -f log.php clean --days X
```

For example, if you type `php -f log.php clean --days 10`, Magento keeps the last 10 days' worth of log information in the database and deletes the rest.

## More information

For more information about Magento, please visit [http://magento.com](http://magento.com).

## Related articles

* [Configuring Magento cron jobs on managed hosting accounts](/docs/optimizing-magento-cron-jobs-on-shared-hosting-accounts)
