Selective Logging
I have logging across a large project. While debugging I want to enable/disable logging for certain classes at runtime. I'm not really sure what's involved to make that happen. Any pointers?
As an example, I'd like to be able to disable the logger statements at runtime from a command without having to modify the Turkey or the Tesla classes below.
Turkey.as
logger.info( 'gobble, gobble' );
Tesla.as
logger.info( 'zoom zoom' );
Comments are currently closed for this discussion. You can start a new one.
Keyboard shortcuts
Generic
? | Show this help |
---|---|
ESC | Blurs the current field |
Comment Form
r | Focus the comment reply box |
---|---|
^ + ↩ | Submit the comment |
You can use Command ⌘
instead of Control ^
on Mac
1 Posted by matej on 14 Jun, 2014 04:48 AM
logger.logLevel = LogLevel.Error
Inject logger in your configuration for good placement :)
S poštovanjem,
Matej Šimunić
2 Posted by dan on 15 Jun, 2014 01:42 AM
Thanks but I have a mix of debug and info statements i want to disable for
a specific class yet still see info and debug from others. I was hoping to
do this from a command at runtime. Classes already have a logger
instance... maybe I just need a more powerful log file analyzer that can
filter those classes out.... Thought I might be able to check where the log
statements are sent and skip if they match a list of classes.
3 Posted by dan on 19 Jun, 2014 09:46 PM
Had some time to figure this out, here's what I did if someone else finds it useful. This only works if you grab loggers with your class type.
So to mute a class at runtime, just do the following:
TraceLogTarget2.mute( ClassName )
It'd be nice to disable an entire package but haven't had time for that yet.
Support Staff 4 Posted by Ondina D.F. on 20 Jun, 2014 06:25 AM
Cool! Thanks for sharing your solution with us.
Ondina D.F. closed this discussion on 02 Jul, 2014 07:20 AM.