https://avo.cool logo
Hi all. We are currently experiencing a strange...
# avo-2
w
Hi all. We are currently experiencing a strange issue. When setting up Avo on our development branch everything works perfectly. However when building our docker image the initialization fails as the Avo logger cannot find the file /logs/avo.log, reluctantly we removed this log file from our gitignore just to investigate the problem further but we are still experiencing the same error. We do not want to commit log files to our repo, has anyone experienced the same problem or have any advice? The error message is as follows:
Copy code
rake aborted!
Errno::ENOENT: No such file or directory @ rb_sysopen - /application/log/avo.log (Errno::ENOENT)
Thank you advance
m
Thread automatically created by Catherine in #740893011994738751
l
Hello @wonderful-application-19261 what avo version are you using?
w
We're on Avo Pro 3.2
l
This should be related to the logger, the default avo logger code is:
Copy code
ruby
 file_logger = ActiveSupport::Logger.new(Rails.root.join("log", "avo.log"))

file_logger.datetime_format = "%Y-%m-%d %H:%M:%S"
file_logger.formatter = proc do |severity, time, progname, msg|
  "[Avo] #{time}: #{msg}\n".tap do |i|
    puts i
  end
end

file_logger
You can configure and change this default like explained here https://docs.avohq.io/3.0/customization.html#logger
For example you can change it to the stdout by replacing
Rails.root.join("log", "avo.log")
with
$stdout
w
We did have a look at this, and overriding the logger with an empty proc does seem to allow the docker image to build, however, it breaks in our local environment
We've also tried adding a switch for the different enviroments:
Copy code
## == Logger ==
  if Rails.env.development?
    config.logger = -> {
      file_logger = ActiveSupport::Logger.new(Rails.root.join("log", "avo.log"))
    
      file_logger.datetime_format = "%Y-%m-%d %H:%M:%S"
      file_logger.formatter = proc do |severity, time, progname, msg|
        "[Avo] #{time}: #{msg}\n".tap do |i|
          puts i
        end
      end
    
      file_logger
    }
  else
    config.logger = -> {}
  end
but this still breaks the docker image build
l
WDYT about keeping
Rails.root.join("log", "avo.log")
and changing it to
$stdout
in non-development?
Copy code
ruby
config.logger = -> {
  file = Rails.env.development? ? Rails.root.join("log", "avo.log") : $stdout
  file_logger = ActiveSupport::Logger.new(file)

  file_logger.datetime_format = "%Y-%m-%d %H:%M:%S"
  file_logger.formatter = proc do |severity, time, progname, msg|
    "[Avo] #{time}: #{msg}\n".tap do |i|
      puts i
    end
  end

  file_logger
}
w
could work, we'll give that a try
Seems like there's something weird going on with our Rails.env.development check, but setting to stdout regardless of environment works for now, thanks for the help 👍
l
Cool! Anytime! Thanks for confirming
a
FYI we are seeing the same thing on our new production deploy
Copy code
Errno::ENOENT: No such file or directory @ rb_sysopen - /var/deploy/ced-wil/web_head/releases/20250302003049/log/avo.log (Errno::ENOENT)
17:32:51
/var/deploy/ced-wil/web_head/shared/bundle/ruby/3.4.0/gems/logger-1.6.6/lib/logger/log_device.rb:127:in 'File#initialize'
17:32:51
/var/deploy/ced-wil/web_head/shared/bundle/ruby/3.4.0/gems/logger-1.6.6/lib/logger/log_device.rb:127:in 'IO.open'
17:32:51
/var/deploy/ced-wil/web_head/shared/bundle/ruby/3.4.0/gems/logger-1.6.6/lib/logger/log_device.rb:127:in 'Logger::LogDevice#create_logfile'
17:32:51
/var/deploy/ced-wil/web_head/shared/bundle/ruby/3.4.0/gems/logger-1.6.6/lib/logger/log_device.rb:116:in 'Logger::LogDevice#open_logfile'
17:32:51
/var/deploy/ced-wil/web_head/shared/bundle/ruby/3.4.0/gems/logger-1.6.6/lib/logger/log_device.rb:90:in 'Logger::LogDevice#set_dev'
17:32:51
/var/deploy/ced-wil/web_head/shared/bundle/ruby/3.4.0/gems/logger-1.6.6/lib/logger/log_device.rb:19:in 'Logger::LogDevice#initialize'
l
Hi @able-needle-51274 What are you using to deploy?
a
Cloud66. I think maybe it's an issue with the log folder not getting created on time. I've emailed their support.
Strange thing is that staging deployed fine. It's only an issue on production
l
It can also be about permissions, if no permission is granted to create the file and Avo attempts to use it Let us know how it goes, my suggestion from above should work, changing the avo logs to stdout, but then you don't have the logs stored on a separate file for history