I understand that Craft CMS generates a web.log file for you but is there a way to do a custom.log?

I have a module and a controller where I want to send specific information from my controller to a custom.log but I can't find any documentation about it.

Thank you very much for your help.


You can do this with the Log To File helper, which provides a simple way for logging messages to a specific file: https://github.com/putyourlightson/craft-log-to-file

This question has already been answered in detail at Craft 3 plugins - Logging in a separate *.log file

  • Thanks, in fact I tried to use the library but the log was never generated. I am probably using it wrong. For instance: LogToFile :: info ($ message, 'my-plugin-handle'); What is my-plugin-handle? Because in my case I am not using a plugin, I am using a module. So if my module is called: custommodule it is LogToFile :: info ($ message, 'custom-module'); Sorry for the questions but I did see the post but it was not clear to me where you indicate the new name of the .log Thanks!
    – SundayGirl
    Sep 19 at 17:33
  • That can be anything, it will be used as the file name for the log file.
    – Ben Croker
    Sep 19 at 18:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.