Yogesh Chauhan's Blog

Where is the PHP log file located on Mac OS?

in PHP on April 30, 2020

Apache’s logs are located under /var/log/apache2

When a location isn’t specified in php.ini, the PHP error log does seem to be found in /var/log/apache2/error_log by default.

You can add all your errors to it by just adding failure else statement just like the following.

// Send error message to the server log if error connecting to the database
if (!mysqli_connect("localhost","bad_user","bad_password","my_db")) {
    error_log("Failed to connect to database!", 0);


The error_log() function sends an error message to a log, to a file, or to a mail account.


error_log ( string $message [, int $message_type = 0 [, string $destination [, string $extra_headers ]]] ) : bool

One more example

// Send notification through the server log if we can not
// connect to the database.
if (!Ora_Logon($username, $password)) {
    error_log("Oracle database not available!", 0);

// Notify administrator by email if we run out of FOO
if (!($foo = allocate_new_foo())) {
    error_log("Big trouble, we're all out of FOOs!", 1,
               "[email protected]");

// another way to call error_log():
error_log("You messed up!", 3, "/var/tmp/my-errors.log");

Most Read

#1 How to check if radio button is checked or not using JavaScript? #2 Solution to “TypeError: ‘x’ is not iterable” in Angular 9 #3 How to add Read More Read Less Button using JavaScript? #4 How to uninstall Cocoapods from the Mac OS? #5 PHP Login System using PDO Part 1: Create User Registration Page #6 How to Use SQL MAX() Function with Dates?

Recently Posted

#Aug 15 Is PHP still good for back-end programming? #Aug 10 How to create a multisite network in WordPress? #Aug 3 How to create a circle that follows a cursor using JavaScript and CSS? #Aug 3 How to make a curtain slider using jQuery and CSS? #Aug 2 How to progressively load images and add a blurry placeholder? #Aug 1 How to create a placeholder loader (throbber) using CSS?
You might also like these
Killing A Project Part 2: Who should make the decision to kill a project?MiscellaneousHow to show widgets on the Appearance tab in WordPress?WordPressSlider animation using CSS transform propertyCSSHow to add menu to your WordPress theme?WordPressVariables scope and shadowing in SCSS (Sass)SCSSHow to use a Subquery to Insert Multiple Rows in SQL Table?SQL/MySQL