lulalala / multi_logger

Create multiple loggers in Rails
MIT License
59 stars 21 forks source link

Deployment #16

Open srochan opened 7 years ago

srochan commented 7 years ago

I am trying to deploy my rails app as a war on jboss. However, I keep getting an error saying that the logger I use in multi_logger is an undefined method of logger.

I use Rails.logger..info and I get an error saying Undefined method

lulalala commented 7 years ago

I assume this works in development and not in production?

Can you find the class name of Rails.logger?

srochan commented 7 years ago

This is not working even in development.

The classname is ActiveSupport::Logger is on rails console. How can I check the value on the deployed app?

lulalala commented 7 years ago

It should work if it is ActiveSupport::Logger. I think you may have forgotten to set it in an initializer.

For deployed app, just enter its production console, and puts Rails.logger.class

srochan commented 7 years ago

Here is my initializer formatter = Proc.new{|severity, time, progname, msg| formatted_severity = sprintf("%-5s",severity.to_s) formatted_time = time.strftime("%Y-%m-%d %H:%M:%S") caller_trace=caller.clone caller_trace.delete_if {|x| x.include?"logger" or x.include? "lgg"} callee = caller_trace[0].split("/").last "[#{formatted_severity} #{formatted_time} #{callee}] #{msg.to_s.strip}\n" }

MultiLogger.add_logger('my_app', formatter:formatter)

if Rails::env == 'production' Rails.logger.my_app.level = Logger::INFO end

I have used Rails.logger.my_app.info, etc in my code

I got an error saying that logger has no method called my_app