[logback-user] Setting MDCFilter values at runtime

ceki ceki at qos.ch
Fri Apr 13 09:14:36 CEST 2012


Hello Dan,

TurboFilters are added to the logger context. You can get hold of any 
installed tubo filter by searching in the list returned by 
LoggerContext.getTurboFilterList(). Once you have the turbo filter 
instance, you could reconfigure it as desired and invoke its start() 
method. You are done.

HTH,

-- 
Ceki
http://twitter.com/#!/ceki

On 13.04.2012 02:17, Dan Cripe wrote:
> Unfortunately that won't fly either. Config file is embedded in the
> package and the system is tightly locked down. We need to be able to
> change it via some remote mechanism - HTTP, JMX etc.
>
> Sent from my iPhone
>
> On Apr 12, 2012, at 17:37, Ralph Goers <rgoers at apache.org
> <mailto:rgoers at apache.org>> wrote:
>
>> You need to use Logback's ability to reconfigure itself to change the
>> value at runtime.  Just set scan="true" and change the file.
>>
>> Ralph
>>
>> On Apr 12, 2012, at 6:01 AM, Dan Cripe wrote:
>>
>>> Thanks Ralph, but after reading the user guide and java docs I'm not
>>> seeing how I can adjust this value at run time (only that I can set
>>> multiple values).  Basically, if there's a problem reported, I want
>>> to be able to use JMX or some other means to tell log back to start
>>> logging all messages for user X (an MDC value) at DEBUG and then
>>> later revert back to normal logging.
>>>
>>> Is it possible to get a reference to an existing turbo-filter and
>>> then set the value directly?  If so, I can create my own MBean that
>>> modifies the filter as needed.
>>> *
>>> *
>>>
>>> On Apr 11, 2012, at 6:52 PM, Ralph Goers wrote:
>>>
>>>> Use the DynamicThresholdFilter.
>>>>
>>>> Ralph
>>>>
>>>> On Apr 11, 2012, at 9:20 AM, Dan Cripe wrote:
>>>>
>>>>> Hi- I'd like to leverage the MDCFilter TurboFilter, but I need to
>>>>> be able to change the "value" element at runtime.  Basically, if a
>>>>> specific user is having trouble, I want to set their logs to show
>>>>> up as DEBUG while the remainder of the logs show up as INFO.  Is
>>>>> there a way (preferably using JMX) that this can be done via
>>>>> configuration?  If not, what's the best approach programatically?
>>>>>
>>>>> Thanks,
>>>>> Dan





More information about the Logback-user mailing list