Skip to content

Logging can load initializers first? #21

@wbotelhos

Description

@wbotelhos

Gemfile:

gem 'logging-rails', require: 'logging/rails'

config/loggin.rb

The original.

config/initializers/logging.rb:

Rails.application.configure do
  if Rails.env.production?
    config.log_to                 = %w[file]
    config.show_log_configuration = false
  else
    config.log_to                 = %w[stdout]
    config.show_log_configuration = true
  end
end

Log configuration:

root  ............................................  *debug      -T
- <Appenders::RollingFile:0x18f397c name="file">
  ActionMailer::Base  ............................   debug  +A  -T
  ActiveRecord::Base  ............................   debug  +A  -T
  ActiveSupport::Cache::FileStore  ...............   debug  +A  -T
  ActiveSupport::Dependencies  ...................   debug  +A  -T
  Logging  .......................................    *off  -A  -T
  Rails  .........................................   debug  +A  -T

I tried to let the config on environments files, but the same effect, the Rails original logging was supressed, but I can't log. I tried:

Rails.logger.error 'foo' # true
Logging::Logger[::Rails].error 'foo' # true
::Logging::Logger[self].error 'foo' # true

The problem is that log?: Logging ....................................... *off -A -T
If yes, What I need more to re-enable Rails logging with my manual one?
How is the logging calling? Rails.logger.xyz?

Thanks you.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions