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?
Use create Directory activity to create the folder. Create “Master Folder” using create Directory activity give the path as above. Again use create Directory to create sub folder . Hello Friends, Here some tips how to create folder locally in System by Uipath the may help some of your friends , Here we go!
Using Ruby's Mkdir Method To Create A New Directory If you want to create a new folder with Ruby you can use the Dir. mkdir method. If given a relative path, this directory is created under the current path ( Dir. pwd ).
Try something like this.
dir = File.dirname("#{Rails.root}/log/#{today}/my.log") FileUtils.mkdir_p(dir) unless File.directory?(dir) @@my_logger ||= Logger.new("#{Rails.root}/log/#{today}/my.log")
You can also do this way
directory_name = "name" Dir.mkdir(directory_name) unless File.exists?(directory_name)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With