You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@logging.apache.org by "Evgeniy (JIRA)" <ji...@apache.org> on 2018/08/17 13:51:00 UTC

[jira] [Created] (LOG4J2-2414) RegexFilter GC-Free way

Evgeniy created LOG4J2-2414:
-------------------------------

             Summary: RegexFilter GC-Free way
                 Key: LOG4J2-2414
                 URL: https://issues.apache.org/jira/browse/LOG4J2-2414
             Project: Log4j 2
          Issue Type: Improvement
          Components: Filters
    Affects Versions: 2.11.0
            Reporter: Evgeniy


We are now trying to tune log4j2 to work in GC-Free mode.

One of the filters I'm trying to use is RegexFilter. Based on my observation it does produce garbage (when using with useRawMessage). Documentation ([https://logging.apache.org/log4j/2.x/manual/garbagefree.html)] states: 

_"Other filters like BurstFilter, *RegexFilter* and ScriptFilter are not trivial to make garbage free, and there is currently no plan to change them."_

However, I don't think it is difficult, in case if pattern is constant (which it is)

so instead of doing:
{code:java}
private Result filter(final String msg) {
    if (msg == null) {
        return onMismatch;
    }
    final Matcher m = pattern.matcher(msg);
    return m.matches() ? onMatch : onMismatch;
}

{code}
 



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)