YogeshChauhan.com
Where is the PHP log file located on Mac OS?
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.


<?php
// 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.

Syntax


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

One more example


<?php
// 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");
?>
dreamhost

Leave a Reply

Most Read

#1 How to check if radio button is checked or not using JavaScript? #2 How to set opacity or transparency using CSS? #3 Pagination in CSS with multiple examples #4 How to make HTML form interactive and using CSS? #5 Solution to “TypeError: ‘x’ is not iterable” in Angular 9 #6 How to uninstall Cocoapods from the Mac OS?

Recently Posted

Mar 3 How to embed YouTube or other video links in WordPress? Mar 3 How to change the Login Logo in WordPress? Mar 3 substring() Method in JavaScript Mar 3 Window setInterval() Method in JavaScript Mar 2 How to zoom an element on hover using CSS? Mar 2 the box-sizing property in CSS

You might also like these

How to use HTML Quotation and Citation?HTMLAll possible ways you can Insert Data in PostgresPostgresHow to create a Star Ratings using CSS?CSS3 Ways we can create URLSearchParams Objects in JavaScriptJavaScriptList of all Pseudo Elements in CSSCSSHow to remove special characters (dash, asterisk etc) from any string in PHP?PHP