Jazz Forum Welcome to the Jazz Community Forum Connect and collaborate with IBM Engineering experts and users

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

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?

0 votes


Be the first one to answer this question!

Register or log in 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.

Search context
Follow this question

By Email: 

Once you sign in you will be able to subscribe for any updates here.

By RSS:

Answers
Answers and Comments
Question details
× 10,938

Question asked: Mar 02 '17, 11:59 a.m.

Question was seen: 1,423 times

Last updated: Mar 03 '17, 3:22 a.m.

Confirmation Cancel Confirm