I'm trying to register a new log
@@my_logger ||= Logger.new("#{Rails.root}/log/my.log")
but when I try to generate new folders , to put it inside
@@my_logger ||= Logger.new("#{Rails.root}/log/today.to_s/my.log")
it returns Errno::ENOENT: No such file or directory
May it be a permission problem? How to create a folder (if not present) with Logger.new?
You can also do this way
Try something like this.
Automatic creation of logging directories has been deprecated in rails. Here's a code snippet from the Logger.new code:
Accepted practice now is to make sure the log file (and directory) exist before creating the logger.
A way to make sure the directory exists ahead of time might be to use code similar to this: