It's all about the answers!

Ask a question

Filtering out "value provider" console log messages - is there a better way?


Green Elk (1319) | asked Mar 02 '17, 11:59 a.m.
edited Mar 03 '17, 3:22 a.m.

By adding this at the start of my jazz java client code

static {
        System.setProperty("org.apache.commons.logging.Log",
                "com.greenelk.WorkitemMessageFilterLogger");
     }
this Class will VERY CRUDELY catch all messages and ignore the irritating ones that spew out in my console
package com.greenelk;

import org.apache.commons.logging.impl.Jdk14Logger;

public class WorkitemMessageFilterLogger extends Jdk14Logger {

private static final long serialVersionUID = 1L;
private static final String filterName = "com.ibm.team.workitem.common";
private static final String[] filterMessagePrefixes = {
        "Value provider com.ibm.team.workitem.shared.common.internal.valueProviders.ScriptAttributeValueProvider for ",
        "Default value provider not found: com.ibm.team.workitem.shared.common.internal.valueProviders.ScriptAttributeValueProvider" };
private boolean filter = false;

public WorkitemMessageFilterLogger(String name) {
    super(name);
    if (name.compareTo(filterName) == 0) {
        filter = true;
    }

}

public void error(Object message) {
    if (passthrough(message)) {
        super.error(message);
    }
}

public void error(Object message, Throwable x) {
    if (passthrough(message)) {
        super.error(message, x);
    }
}

private boolean passthrough(Object message) {

    if (filter && message != null && message instanceof String) {
        String msg = (String) message;
        for (String prefix : filterMessagePrefixes) {
            if (msg.startsWith(prefix)) {
                return false;
            }
        }
    }
    return true;
}

}

I know it's an awful hack, but the messages drive me nuts. My question is : Is there a cleaner way of doing this?

Be the first one to answer this question!


Register or to post your answer.


Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.