Back to Top

Where are the LOG of PHP,MySQL and Apache

About the LOG of PHP,MySQL and Apache

Today I am going to write about log which will help you to understand the concept of log in PHP, MySQL, and APACHE.The error log is a text file saved on your server.Entry will be added in this file when any error occurs. This file mainly for tracking an errors or warnings generated in the system.

Generally Error log contains information about the errors and Information are like date/time, user IP address Error message and object the user was requesting.The error message is also contained in Apache Log and it is important to pull error log data out of access log.

The main purpose of the error log is to keep track of all of the errors that occurred when your PHP pages were being accessed.

Let’s see error logs of main three PHP, MySQL and APACHE

Error logs of PHP

PHP is logging error for us but default setting of php.ini file for logging error is OFF so you have to turn on it to enable error log feature and which we highly commended. Also, you need to specify the path of the file where you want to save your error log in your php.ini file.

The typical error log entry looks like this:

PHP Parse error: parse error, unexpected '}' in
C:Program FilesApache2testtest.php on line 14

In the above example, you can see that there was a parse error in the file test.php on line 14, which stops the execution of the particular page. Any user trying to see the contents of this file will see only the parse error until we get it fixed. So with the regular check of PHP error log, you will make sure there aren’t any errors in your code.

Error logs of MySQL

Like PHP, MySQL is also logging error and queries that happened with database transactions.By default, the error log is stored as hostname.err in the data directory of MySQL.Although You can specify other location where the error log is saved.

If you wanted to specify a different location for the error log, You can specify the [mysqld] section in my.ini file by using following the line of code.


MySQL also allows us to view every query sent to the server. To specify the location log for query, you need to type the following line of code:


NOTE: By default, Log file will be stored in the “data” directory with the name hostname.log file, unless you specify.Also Read about Types of Error Levels in PHP.

Error logs of Apache

Apache keeps both access logs and error logs.When Apache has been installed on your server, the default location for your log file is


Log Format of access log is

LogFormat "%h %l %u %t "%r" %>s %b "%{Referer}i"
"%{User-agent}i"" combined

Let’s see access log entry and its looks like this: - - [14/Nov/2011:23:32:47 +0530]
"GET /logo.gif?641e5f=19684125 HTTP/1.1" 404 206.

By Default, Access log stored in the file access.log in Apache/logs.All of this information is on one line of the log and which is built by Apache.

However, an error log is stored in error.log file which contain any errors or warnings.

Let’s see error log entry and its looks like this:

PHP Warning: PHP Startup: Unable to load dynamic
library 'C:\PHP\ext\php_apc.dll' -
The specified module could not be found.
rn in Unknown on line 0

Above Warning specifies that php_apc.dll file enables in PHP.ini file but it does not exist in PHP extension directory.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Most Popular Posts

How to use Short Hand Array in PHP

Posted on 4 years ago


To get Last auto increment id in WordPress

Posted on 4 years ago


Hello world

Updated 1 month ago

Nick Carter

In depth Understanding of Laravel Core

Updated 3 months ago


ECMAScript 6 New Features – 2

Updated 1 year ago


The Reader’s Poll – June 2015

Posted on 4 years ago


The Reader’s Poll – August 2014

Posted on 5 years ago


The Reader’s Poll – June 2014

Posted on 5 years ago


The Readers’ Poll – May 2014

Posted on 5 years ago


The Readers’ Poll – August 2013

Posted on 6 years ago