1

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.

suhkha
  • 121
  • 2

1 Answers1

1

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

Ben Croker
  • 7,341
  • 26
  • 55
  • 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!

    – suhkha Sep 19 '21 at 17:33
  • That can be anything, it will be used as the file name for the log file. – Ben Croker Sep 19 '21 at 18:23