You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@apex.apache.org by Willet Vary <wi...@datatorrent.com> on 2016/10/21 18:00:15 UTC

APEX-CORE searchLoggersLevel and setLoggersLevel APIs

The current apex-core code supports two APIs:

1. searchLoggersLevel, which will search for existing log levels in the
executing application
2. setLoggersLevel, which will set log levels fro the executing application

With regard to searching existing log levels, the following search patterns
are valid:

.*
com.*
.*data.*
.*web.*|.*app.*
.*server

You can see the code in StramWebServices.java, function searchLoggersLevel.

However, when it comes to setting log levels, here are the results:

.*                 <<<< returns an incorrect logger settings
com.*              <<< is valid
.*data.*           <<<< returns an incorrect logger settings
.*web.*|.*app.*    <<<< returns an incorrect logger settings
.*server           <<<< returns an incorrect logger settings

The reason for this is when we set the log levels, we
call ConfigValidator.validateLoggersLevel to validate the regular
expressions before we set the levels.
The current code to test the input regular expression is as follow:

private static Pattern LOGGERS_PATTERN =
Pattern.compile("^(\\w+\\.?)+(\\*|\\w+)$");

According to this test, the specified expression must start with one an
alpha or number.  Followed by an optional period.  After that, an asterisk
or an alpha (or number) is required.

With that test, these are valid expressions:

a*
ab
a.*
a.b
a.b.*

So if we wanted to set log levels for all packages and classes with names
containing the word data, web or app, we can't.
I think we should expand the set log level regular expressions validation
to match the search regular expression validation, which is as long as it's
a valid regular expression, accept it.

If the suggestion is accepted, then these patterns should work when setting
log levels:

.*
com.*
org.*
com.*|org.*
.*data.*
.*web.*|.*app.*
.*server


Thanks,

Willet