reidmorrison / rails_semantic_logger

Rails Semantic Logger replaces the Rails default logger with Semantic Logger
https://logger.rocketjob.io/rails
Apache License 2.0
320 stars 114 forks source link

Respect the log level configured in Mongoid logger when overriding it with Semantic Logger #193

Open Shankar1598 opened 11 months ago

Shankar1598 commented 11 months ago

Environment

Provide at least:

Expected Behavior

  1. The debug level logs from Mongoid.logger should not be printed in the rails console.
  2. Running Mongoid.logger.level should return :info

Actual Behavior

  1. The debug level logs from Mongoid.logger are printed in the rails console
  2. Running Mongoid.logger.level is returning :debug

Workaround

I have fixed this using the following configuration

config.after_initialize do
  Mongoid.logger.level = Logger::INFO
end

PR

The override is happening here. Should be possible to read the configured log level from Mongoid.logger and reaint the value in SemanticLogger[Mongoid]. Open to reaising a PR after verifying this. Let me know your thoughts.

reidmorrison commented 2 months ago

Try this config:

config.log_level = :info
config.semantic_logger.add_appender(io: $stdout, formatter: :color)