-
-
Notifications
You must be signed in to change notification settings - Fork 136
How do I get named loggers with different sets of appenders? #200
-
Environment
Provide at least:
- Ruby 2.3.1
- Semantic Logger Version: master
- Application/framework names and versions: rails 4.2
Expected Behavior
I would like to use a named semantic logger, created by SAML_LOGGER = SemanticLogger['SAML'] and I would like to then add appenders to this SAML logger so it writes to Elasticseach with the proper type field (that's an option on the Elasticsearch appender). I'd like to then bring in semantic_logger_rails and configure its appender to use the standard log type. As the code stands today, I don't think I can reuse appenders in the same process as they are all registered with the singleton SemanticLogger@appenders concurrent array.
I can tell this will complicate the concurrency model, as there is a single background thread which processes all the logs and invokes the appenders.
SAML_LOGGER = SemanticLogger['SAML']
SAML_LOGGER.add_appender(:elasticsearch, type: 'saml', ...)
SemanticLogger.add_appender(:elasticserach, type: 'log', ...)
Rails.log.info("hi") # should create a 'log' type for Elasticsearch
SAML_LOGGER.info("hello") # should create a 'saml' type for Elasticsearch
Any possible workarounds without tearing through this library?
Beta Was this translation helpful? Give feedback.
All reactions
Correct, by design all log entries go to all appenders.
You can however add a filter to an appender so that it only logs messages from specific classes.
Replies: 1 comment
-
Correct, by design all log entries go to all appenders.
You can however add a filter to an appender so that it only logs messages from specific classes.
Beta Was this translation helpful? Give feedback.