Is there any possibility to use log back filters?

Is there any possibility to use log back filters ?

Right now, it’s not possible to plug in different logback filters/handlers. What do you need specifically?

1 Like

I need to add to logs client IP (some other technical info).

But I don’t want to add it in such way:
Log.debug(getSomeInfo() + "blabla bla")

Any suggestion how to use something like filters ?

I’ve checked http://felix.apache.org/documentation/subprojects/apache-felix-log.html and it seems that LogListener is what I need.

So I’ve added custom component to app:

` @Component(
immediate = true,
configurationPid = {“test.LogActivator”}
)

public final class LogActivator implements BundleActivator {

@Override
public void start(BundleContext context) throws Exception {

    ServiceReference logReference = context.getServiceReference(LogReaderService.class.getName());

    if (logReference == null)  
        System.out.println("null");  **  // it is allways null !**

}

}`

Maybe, you have any thought regarding this ?

It does not work in the way you describe above. We need to do some changes into our core product to facilitate this. The first we could do is to add some request values into the MDC (mapped diagnostic context) so it’s possible to log it using a simple pattern.

Will keep you notified on the progress.

What about addition jar with filter ?

I’m planing to create a small jar with log back filter, update config and put its: XP_HOME\lib\

Would it work ?

Yes, that should work.

Hi

Is there is any update in this scope?
I mean is its possible to use LogBack filter or something like this.

I’m using own work-around getClientInfo(), but its not comfortable and code is not brilliant in such case

LOGGER.error("{} Error. Step 1", getClientInfo(), e);

Maybe you can advice something?

Is there are any updates?

Hi. I am in the process of adding MDC for this stuff. Pluggable logging filters need a little more work, but I have created a spec for it. Will keep you notified in this thread.