reidmorrison / semantic_logger

Semantic Logger is a feature rich logging framework, and replacement for existing Ruby & Rails loggers.
https://logger.rocketjob.io/
Apache License 2.0
873 stars 124 forks source link

undefined method `add_appender' for an instance of SemanticLogger::Logger #289

Open rgaufman opened 4 months ago

rgaufman commented 4 months ago

Both ChatGPT and Claude seem to suggest this syntax whenever you need to log only specific things to a separate file:

# Global logger
@logger = SemanticLogger['global']
SemanticLogger.add_appender(io: $stdout, formatter: :color)
SemanticLogger.add_appender(file_name: 'server.log', formatter: :default)

# Specific Logger
email_logger = SemanticLogger['specific']
email_logger.add_appender(file_name: 'emails.log', formatter: :default, level: :info)
email_logger.log("email contents")

It seems like something that would be useful to add? - otherwise, how would one achieve something like this?

reidmorrison commented 3 months ago

Appenders are global, to control what appender receives what messages it uses filters: https://logger.rocketjob.io/filtering.html