From the course: PHP: Creating Secure Websites

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Smart logging

Smart logging - PHP Tutorial

From the course: PHP: Creating Secure Websites

Start my 1-month free trial

Smart logging

- [Instructor] Logging plays an important role in keeping your application secure. Logs can alert you to problems and provide clues when something goes wrong. There are three main things you want to be logging. You want to log errors. You want to log sensitive actions whenever they're performed, and you want to log possible attacks. PHP will log major errors for you already. In the configuration chapter, we learned how to configure which errors are shown and logged, but there could be application errors that aren't PHP errors. For example, a user might try to assign a blog post to a category that no longer exists in the database. Your application can write errors and other events to a database table or to a log file. I've created a simple file called logger.php that we can use for demonstration. The file errors.log is going to be a blank file where our log entries will go. I've made sure that errors.log is writable,…

Contents