Coding⏱️ 3 min read📅 2026-06-11

How to Fix: Coloured output when tailing php error log

PHP error log color output issue on Ubuntu 12.04

Quick Answer: Use ANSI escape codes or a library like PHP-ColoredOutput to display colored lines in the error log.

A coloured output when tailing php error log can be frustrating and may indicate an issue with the PHP configuration or logging settings. This guide aims to help you identify the root cause of this issue and provide a primary fix method using escape characters.

Displaying coloured lines in your php error log can be achieved through various means, including using escape characters or software. However, due to compatibility issues with PHP 5.3 on Ubuntu 12.04, some methods may not work as expected.

⚠️ Common Causes

  • The primary root cause of this issue is the lack of support for ANSI escape codes in PHP 5.3 on Ubuntu 12.04. This means that even if you use escape characters to change the colour, it will not be displayed correctly.
  • Another possible root cause is the logging configuration settings. If the error log is configured to display only plain text, coloured output may not be possible.

✅ Best Solutions to Fix It

Enabling ANSI Escape Codes

  1. Step 1: Open your terminal and run the following command: `export PS1='%s'` This will enable ANSI escape codes for red text.
  2. Step 2: Alternatively, you can add the following line to your shell configuration file (e.g., `~/.bashrc`) to enable ANSI escape codes: `PS1='%s'`
  3. Step 3: After enabling ANSI escape codes, try using the `error_log()` function with colour codes to display coloured lines in your php error log.

Using a Third-Party Logging Library

  1. Step 1: Install a third-party logging library that supports displaying coloured output, such as the `loggly` library. You can install it using Composer: `composer require loggly/loggly-php`
  2. Step 2: Configure the logging library to display coloured output by setting the `color` option in your configuration file.
  3. Step 3: Use the logging library's `error_log()` function to display coloured lines in your php error log.

✨ Wrapping Up

By enabling ANSI escape codes or using a third-party logging library, you should be able to display coloured lines in your php error log. If you are still experiencing issues, please check your logging configuration settings and ensure that the error log is configured to display plain text.

Did this fix your problem?

If not, try searching for specific error codes.

🔍 Search Error Database

❓ Frequently Asked Questions