Open fractaledmind opened 3 years ago
Hello, I use Semantic Logger with Heroku and Papertrail - I don't know why the code you posted isn't working, but I can share what we do -- you may already be doing something like this.
We use the feature in Papertrail to filter out log messages matching certain regular expressions. It's in the Papertrail to menu > Settings > Account page and then the "Filter logs" button. From there you specify the regular expressions that should be omitted when matched, so you might be able to add "Webhooks::GithubController" as a rule.
Here are the docs: https://documentation.solarwinds.com/en/success_center/papertrail/content/kb/how-it-works/log-filtering.htm
From what I can see, it looks like you have the syntax correct for the filter argument to add_appender
; I'm looking at the documentation comment here:
Looking at the filter above, looks to me like you want to filter on the class name, not the message.
filter: Proc.new { |log| log.name != "Webhooks::GithubController" }
The log object has many elements that can be filtered on: https://github.com/reidmorrison/semantic_logger/blob/master/lib/semantic_logger/log.rb#L13
@reidmorrison: I have found the source of the problem. The filter that I set in my configuration is never passed to the initialised loggers when the Engine is mounted.
When SemanticLogger[Rails]
is called, there is no way or attempt at connecting the filter
created for config.rails_semantic_logger.filter
. It is only used if the config.rails_semantic_logger.add_file_appender
is passed and then the filter
is passed to the appender.
I currently am just brute force hacking around this with an initializer:
ObjectSpace.each_object(SemanticLogger::Logger).each do |logger|
logger.filter = Rails.application.config.rails_semantic_logger.filter
end
To clarify, because Heroku requires logging to STDOUT (https://logger.rocketjob.io/rails#log-to-standard-out) and thus requires disabling the file appender, currently any of the options passed and used to configure the appender are ignored
Environment
Provide at least:
The log level is usually set with the config setting config.log_level,
but Heroku also allows the log level to be set via the LOG_LEVEL env variable.
if ENV["LOG_LEVEL"].present? config.log_level = ENV["LOG_LEVEL"].downcase.strip.to_sym end