# Error log in OpenCart: where to find logs and errors and how to read them in 3.0 and 4.1

> Where OpenCart 3.0 and 4.1 write the error log, what gets logged and what doesn't, how to read Notice, SQL and exception entries, and how to set up logging on a live site.

Джерело: https://opencartcode.com/en/wiki/dev-practice/error-log-opencart
OpenCart: 3.0, 4.1
Оновлено: 2026-11-25

[Error log](https://opencartcode.com/en/wiki/glossary/e-commerce-glossary#error-log) in [OpenCart](https://opencartcode.com/en/wiki/glossary/e-commerce-glossary#opencart) is the file `error.log` in the logs directory (`DIR_LOGS`, by default `system/storage/logs/`). It is visible in the admin under "System → Maintenance → Error Logs" (System → Maintenance → Error Logs). PHP warnings, some SQL errors, and, in 4.1, exceptions with full stack traces are written there. But the most serious failures (out of memory, time limit) never end up in this file. You have to look for them in the PHP log on the server. A syntax error in a module file in 4.1 goes to error.log as a ParseError, while in 3.0, which has no exception handler, it goes to the server's PHP log. Below is a breakdown of what gets written where in 3.0 and 4.1 and how to read the entries.

Examples are for OpenCart 4.1; in 4.0.x, model triggers and event handling differ.

## Where are the logs and how do I open them?

The path to the logs directory is set by the constant `DIR_LOGS` in `config.php` of the [storefront](https://opencartcode.com/en/wiki/glossary/e-commerce-glossary#storefront) and admin. The installer of both versions writes it as `DIR_STORAGE . 'logs/'`, and `DIR_STORAGE` points to `system/storage/` by default. If the storage directory has been moved outside the public folder (which is worth doing), the logs move with it. For what else is stored in storage, see the article about the [storage directory](https://opencartcode.com/en/wiki/dev-architecture/opencart-storage), and for the `config.php` constants, see the article about [file configs](https://opencartcode.com/en/wiki/dev-architecture/opencart-config-php).

The name of the main file comes from the Error Log Filename setting on the "Server" tab in "System → Settings" (System → Settings). After installation it is `error.log`. The same place has the Display Errors (show errors on the page) and Log Errors (write to file) toggles.

Server tab: showing errors, writing to the log, and the log file name · OpenCart 4.1.0.4

### Error log in the admin

- **OpenCart 3.0:** the page shows only the file from the setting. If it is 5 MB or larger, a warning with the size appears instead of the contents, and the log can only be viewed via the download button. The clear button empties the file.
- **OpenCart 4.1:** the page shows all `*.log` files from the logs directory as separate tabs, so your module's logs are there too. The first 3 MB of each file are read. For a large file you see the oldest entries rather than the newest, and a file size warning appears next to it.

Error log: tabs with log files and the download and clear buttons · OpenCart 4.1.0.4

A practical rule for both versions: clear the log before reproducing the error, repeat the action, and only then look. This way the file contains only what is relevant to your case, not thousands of old Notices.

### Other logs

In 3.0, next to it lies `ocmod.log`: it is written by the "Refresh" button on the "[Extensions](https://opencartcode.com/en/wiki/glossary/e-commerce-glossary#extensions) → Modifications" page, and it shows which OCMOD operation failed to find its line. How to read it is covered in the article about a [non-working OCMOD](https://opencartcode.com/en/wiki/dev-events-ocmod/ocmod-not-working). Modules often write their own files (`mypay.log`, `import.log`) into the same directory via the `Log` class.

## What goes into error.log and what doesn't?

This is the most important thing to understand when "the log is empty but the site is down." OpenCart sets its own handler via `set_error_handler()`. It catches what PHP passes to such handlers: Notice, Warning, Deprecated and similar. Fatal errors of the `E_ERROR` level and parse errors (`E_PARSE`) are not passed by PHP to such handlers, and the core does not register `register_shutdown_function` for them in either 3.0 or 4.1.

| What happened | OpenCart 3.0 | OpenCart 4.1 |
| --- | --- | --- |
| Notice, Warning, Deprecated | error.log | error.log |
| Unhandled exception (including SQL error, TypeError, call to a nonexistent method) | no exception handler in the core: server PHP log or screen, depending on php.ini | error.log with the text, file, line and stack trace |
| Out of memory, exceeding `max_execution_time` | server PHP log only | server PHP log only |
| Syntax error in a module file (controller, model) | server PHP log | error.log as ParseError with stack trace |

In 3.0, an SQL error usually leaves two traces. The mysqli driver works with `mysqli_report(MYSQLI_REPORT_ERROR)`, so PHP issues a warning with the MySQL error text, and it goes to error.log. After that the driver throws an exception with the error text and the query itself, which the 3.0 core does not catch. It goes wherever PHP writes unhandled errors.

The server PHP log is the file set by the `error_log` directive in php.ini, or the error log of the web server or PHP-FPM. On hosting, the control panel usually shows it. If you can't find it, temporarily set `ini_set('error_log', DIR_LOGS . 'php.log')` in `index.php` right after `config.php` is loaded (the `DIR_LOGS` constant is not yet defined at that point). Then in 4.1 it will also appear as a separate tab in the admin log.

## How do I read the entries?

The line format is set by the `Log` class: date, hyphen, message. It differs slightly between versions.

OpenCart 3.0.5.1

OpenCart 4.1.0.4

`system/library/log.php` · OpenCart 3.0.5.1 · lines 30–32

```php
	public function write($message) {
		fwrite($this->handle, date('Y-m-d G:i:s') . ' - ' . print_r($message, true) . "\n");
	}
```

`system/library/log.php` · OpenCart 4.1.0.4 · lines 45–47

```php
	public function write($message): void {
		file_put_contents($this->file, date('Y-m-d H:i:s') . ' - ' . print_r($message, true) . "\n", FILE_APPEND | LOCK_EX);
	}
```

Two details. In 3.0 the hour is written via `G`, that is, without a leading zero (`2026-11-25 9:05:12`), while in 4.1 it is written via `H` (`09:05:12`). If you filter the log by time using `grep`, keep this in mind. The second detail: 4.1 appends using `LOCK_EX`, so lines from parallel requests don't get mixed together. In 3.0 the file is opened once per request and written without locking.

The time is taken from the current PHP timezone in the request, so it may not match the time in the web server log. When comparing entries from different logs, check the timezone.

### Typical entries and what they mean

- `PHP Notice:  Undefined index: telephone in .../catalog/model/account/customer.php on line ...`: the array passed by the module is missing a key. Look not at the core file but at whoever called it: the core model only read what it was given.
- `PHP Warning:  Undefined array key ...`: the same for PHP 8. In PHP 8 some former Notices became Warnings, so an old module suddenly floods the log after a PHP upgrade.
- `PHP Deprecated: ...`: the code works but uses something removed in newer PHP versions. This is a signal to update the module, not the cause of the current failure.
- `Error: Unknown column ... Error No: 1054` (4.1, with SQL and stack trace): the module's query references a column that does not exist in this version of the schema. Typical after moving a module from 3.0 to 4.1.

The path in the entry shows where the error surfaced. In 3.0, files changed by OCMOD are executed from `storage/modification/`, so a path like `.../storage/modification/catalog/controller/...` means the line could have been added not by the core author but by one of the modifications. The line number corresponds to the modified copy, not the original.

## How do I configure display and logging on a production site?

After installation, both versions have both error display and logging enabled. In `system/config/default.php` in 4.1, next to `error_display` there is even a comment saying it should be turned off on a production site. Showing errors is harmful for three reasons:

- customers see server file paths and fragments of SQL;
- warning text ends up in JSON responses of AJAX, payment gateway callbacks and custom endpoints, and they break (details in the article about [diagnosing payment callbacks](https://opencartcode.com/en/wiki/dev-flows/opencart-callback-not-updating-order-status));
- warnings output before headers break redirects and cookies.

Recommendation: on a production site, Display Errors is off and Log Errors is on. On a development copy, both are on. But even with display turned off, 4.1 behaves in a [special](https://opencartcode.com/en/wiki/glossary/e-commerce-glossary#special) way: on an unhandled exception, the handler redirects to `error.html`. So the customer sees an error page instead of a white screen, while the stack trace goes to the log.

One more point: before the settings are loaded from the database, the handler from `system/framework.php` is in effect. It takes the values of `error_display` and `error_log` from the file configs `system/config/`, where both are `true`. In 4.1, an error at the very start (for example, an unavailable database) will be shown on screen even when display is off in the admin. In 3.0, `framework.php` only sets `set_error_handler()`, and an unavailable database produces an exception from the DB driver. That is handled by PHP itself, and what the visitor sees depends on `display_errors` in php.ini. The request path up to the point where `startup/error` triggers is described in the article about [framework.php](https://opencartcode.com/en/wiki/dev-architecture/opencart-framework-php).

> The error log grows without rotation: neither 3.0 nor 4.1 trims or archives it. A module that writes a Notice on every page can produce hundreds of megabytes in a week. Set up logrotate or periodic clearing, and fix the source rather than just cleaning the file.

## How do I write my own module log?

For module diagnostics, create a separate file through the same `Log` class, rather than writing everything to `$this->log`: this way your entries are easy to find and are not lost among other noise.

Example: a custom module log, enabled in settings (OpenCart 4.1)

```php
private function debug(string $message, array $context = []): void {
    if (!$this->config->get('module_mymodule_debug')) {
        return;
    }

    static $log = null;

    if ($log === null) {
        $log = new \Opencart\System\Library\Log('mymodule.log');
    }

    $log->write($message . ($context ? ' ' . json_encode($context, JSON_UNESCAPED_UNICODE) : ''));
}
```

In 3.0 the same creation line looks like `new Log('mymodule.log')`, because the class is global. The 3.0 constructor opens the file for appending right away, while 4.1 only creates it if the file doesn't exist.

- **Enable logging via a setting.** Permanent detailed logging on a production site means both disk space and personal data on disk.
- **Don't log secrets.** API keys, passwords, access tokens, and full card numbers must not end up in the log, even temporarily during debugging.
- **Add context.** `order_id`, route, response code from an external service. A record saying "Error" without context is useless.
- **Catch exceptions where you can continue.** For example, in an event handler, wrap the call to an external API in `try/catch (\Throwable $e)` and log `$e->getMessage()`. In 3.0, without this, the exception will not reach error.log at all.

## Summary

- The main log is `DIR_LOGS` + the name from the "Server" tab (after installation `error.log`), also found under "System → Maintenance → Error Logs."
- The 3.0 admin log shows only the main file up to 5 MB. 4.1 shows all `*.log`, but only the first 3 MB of each.
- Notice and Warning go to error.log in both versions. Unhandled exceptions reach it only in 4.1. Out of memory and timeouts go only to the server's PHP log. A syntax error in a module file goes to error.log as a ParseError in 4.1, and to the server's PHP log in 3.0.
- After installation, error display is enabled. On a production site, turn it off and keep logging on.
- The log is not rotated. Clean it up and eliminate the sources of repeated entries.
- For a module, keep a separate file with logging enabled via settings and without secrets.

Other materials on debugging, performance, and module code quality are collected in the section ["Debugging, Performance and Code Quality"](https://opencartcode.com/en/wiki/dev-practice).

## FAQ

**Why is the error log in the admin empty when the site shows a 500 error?**

A 500 error most often means a PHP fatal error, running out of memory, or a timeout, and these don't end up in OpenCart's error.log. Check the PHP or web server log in your hosting control panel.

**Is it safe to delete error.log?**

Yes, the file will simply be created again on the next write. But it's better to clear it with the button in the admin so you don't break the file's access permissions.

**How do I see errors only for myself without showing them to customers?**

Keep error display turned off and check error.log, or debug on a copy of the site. OpenCart's core can't show errors only for your IP; that requires a custom change to the error handler.

**Why does the log have thousands of identical Deprecated entries?**

The module or theme was written for an older PHP version. These entries don't break the site but clutter the log, so update the module or ask the author to fix compatibility with your PHP version.
