Tania Rascia

Skip Navigation
How to Create an Error Log in PHP

How to Create an Error Log in PHP

 /  Leave a response

It was only recently that I realized you could send custom error logs to whatever file you want. I just create a logs directory and told PHP to write a message to that location when the script was hit. In the below code, the message “Error message” will get sent to error.log.


error_log("Error message\n", 3, "/Users/tania/logs/error.log");


Hi, my name is Tania Rascia. I've turned down every offer for advertisements or sponsored posts on this website. I write free resources that have helped thousands of people successfully transition into a web development career.

My committment is to no bullshit, no sponsored posts, no ads, and no paywalls. If you enjoy my content, please consider supporting what I do.

Support my work


New articles on web development every two weeks.

Write a response

Your email address will not be published.

All code will be displayed literally.