How is logging handled in Craft 3? There's nothing mentioned in the docs at all.
None of the below exist.
I'm not seeing any logging in any of the other plugins I've got on this site.
Another perhaps simpler approach is to write to your own log file without using the Craft logger at all.
$file = Craft::getAlias('@storage/logs/pluginhandle.log'); $log = date('Y-m-d H:i:s').' '.$message."\n"; \craft\helpers\FileHelper::writeToFile($file, $log, ['append' => true]);
I released the Log To File Helper which provides a simple way for logging messages to a specific file and is intended to be used a helper class for modules and plugins.
web.log is incredibly verbose, I agree. I think Andrew Welch is right that you should use the Yii2 Debug Toolbar for elaborate stuff, but if you just need some one-line logs to get your bearings in a method, I'd set up the log statement like this:
That second parameter will categorize your call with the method you're calling the log function from. Then, to filter it out from all the rest of
web.log, you can run a tail command with a filter on it. Assuming you've got a Unix shell, something like this.
tail -f web.log | grep "YourMethodName"
So now as you execute your commands and trigger the log statements, you'll only see those that are coming from the method you're debugging.