Closed rful011 closed 2 years ago
The problem is that
Logging::Filters::Levels.new
is called beforeLogging.init
to set up the logging levels! May be an extra line in levels.new to make sure that LEVELS is initialised!
Good point - I added a check during Filter initialization to ensure that the Logging framework has been configured properly #238
Would you please add a example for setting up a filter, I suspect it would have saved me a lot of trial and error. On the up side I learned a bit more ruby from my hours peering at your code!
I'll add that to the list of examples to create.
Lastly is there a way of instantiating a logging instance with just my custom appender? Logging.logger needs a dev which it maps to one of the preconfigured appenders.
Yes! The Logging.logger()
method is designed to return a Logger that is configured as closely as possible to the core Ruby logger class.
You can get a plain Logger via Logging::Logger['example']
.
Hi
First off Thanks for a great gem! I am converting a lot of my stuff to using it.
I recently tried out filters on a new appender I have written using the supplied "levels" filter and found that the filter were not have any effect.
I already had my own wrapper around Logging so I overrode some of levels' methods so I could see what was going on. After a lot of fiddling I established that doing something like
gives output:
I.e @levels is an empty Set
The problem is that
Logging::Filters::Levels.new
is called beforeLogging.init
to set up the logging levels!May be an extra line in levels.new to make sure that LEVELS is initialised!
Having fixed that and moved the filter definition I spent more time debugging my custom appender and the with the filter. Almost all the problems were with getting parameters to various call right. I like hash parameters but if you get the keys wrong things fail silently.
Would you please add a example for setting up a filter, I suspect it would have saved me a lot of trial and error. On the up side I learned a bit more ruby from my hours peering at your code!
Lastly is there a way of instantiating a logging instance with just my custom appender? Logging.logger needs a
dev
which it maps to one of the preconfigured appenders.I have tried "removing" the appender I created first but it does not work:
not sure if this is a bug or a feature.
This isn't critical as I will normally have a default of syslog which gets everything and have the high priority stuff logged to elasicsearch where I have stuff set up to log calls into ServiceNow.