Debug log file with rolling datestamp in filename?

Well, yes – there is such way. And you even have the solution already in your code…

Even more – you almost solved it yourself…

This line decides, where the log will be located:

@ini_set( 'error_log', dirname(__FILE__) . '/wp-content/debug.log' );

So all you need is to add date in that file name. Like this:

@ini_set( 'error_log', dirname(__FILE__) . '/wp-content/' . date('Y-m-d') . '-debug.log' );

As you can see no cron is needed to achieve this 😉