How to write different events from different functions in my file to a log file in WordPress

If you set the WP_DEBUG* constants in your wp-config.php file:

define( 'WP_DEBUG', true );
define( 'WP_DEBUG_LOG', true );
define( 'WP_DEBUG_DISPLAY', false );
// prevents debugging messages from appearing in the browser

…then you should be able to use error_log() in your code, and your debugging messages will be saved in wp-content/debug.log. (You’ll probably have to ensure that wp-content/debug.log exists and is writable by the server to make this work.)

See this answer: https://stackoverflow.com/a/55515556/1094518