-
-
Notifications
You must be signed in to change notification settings - Fork 124
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
config.rails_semantic_logger.filter doesn't apply to initialized Loggers #134
Comments
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: From what I can see, it looks like you have the syntax correct for the filter argument to |
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: |
@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. Consider rails_semantic_logger/lib/rails_semantic_logger/engine.rb Lines 45 to 71 in c94ae1f
When 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:
I have a Rails app running on Heroku using the Papertrail service for logs. My Rails app is integrated with a GitHub app, so I receive GitHub webhooks. I store the webhook payloads in the database for processing in a background job, and they are large and often, so they fill up my logging bucket fairly easily. I am trying to exclude the logs of the GitHub webhook requests. You can see the
filter
I am trying to use above, but I still see the webhook requests in my logs.How can I exclude logs in Heroku production that match my regex?
The text was updated successfully, but these errors were encountered: