You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-user@logging.apache.org by Thorsten Schöning <Th...@veda.net> on 2023/10/05 13:13:35 UTC
Are globs or regular expressions supported in logger names in config files?
Hi everyone,
I have many logger names following some naming convention like in the following examples:
* org.example.unique_phrase.foo
* org.example.unique_phrase.bar
* org.example.foo.unique_phrase.bar
* org.example.bar.unique_phrase.foo
The goal is to configure one file appender for all packages/logger names containing "unique_phrase". At the same time I would like to keep the possibility for more fine grained configs with possible different appenders for different packages of the above example. The only solution I know of is really configuring all individual (parent) logger names/packages with the same appender. Would be easier if logger names would support some concept of globs or regular expressions, so one might only use something like the following name:
* org.example.*.unique_phrase.*
Is something like that possible, either out-of-the-box or possibly some plugin or ...? Thanks!
PS: Kennen Sie schon VEDA Care Services? Interesse? Dann sprechen Sie uns gerne persönlich an. Weitere Infos finden Sie hier.
____________________________________________________________
Thorsten Schöning
Software Developer
VEDA GmbH
Carl-Zeiss-Straße 14
52477 Alsdorf
Tel.: +49 2404 5507-1345
Thorsten.Schoening@veda.net
www.veda.net
VEDA GmbH, Amtsgericht Aachen HRB 1501
Geschäftsführer: Dr. Ralf Gräßler
Sitz der Gesellschaft: Alsdorf
---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org
Re: Are globs or regular expressions supported in logger names in config files?
Posted by Ralph Goers <ra...@dslextreme.com>.
> On Oct 5, 2023, at 6:13 AM, Thorsten Schöning <Th...@veda.net> wrote:
>
> Hi everyone,
>
> I have many logger names following some naming convention like in the following examples:
>
> * org.example.unique_phrase.foo
> * org.example.unique_phrase.bar
> * org.example.foo.unique_phrase.bar
> * org.example.bar.unique_phrase.foo
>
> The goal is to configure one file appender for all packages/logger names containing "unique_phrase". At the same time I would like to keep the possibility for more fine grained configs with possible different appenders for different packages of the above example. The only solution I know of is really configuring all individual (parent) logger names/packages with the same appender. Would be easier if logger names would support some concept of globs or regular expressions, so one might only use something like the following name:
>
> * org.example.*.unique_phrase.*
>
> Is something like that possible, either out-of-the-box or possibly some plugin or ...? Thanks!
>
If this is what you really want then you could create a LoggerNamePatternFilter and configure it like
<Logger name=“org.example” level=“trace”>
<AppenderRef ref=“patternAppender”>
<LoggerNamePatternFilter pattern=“org.example.*.unique_phrase.*” onMatch=“NEUTRAL” onMisMatch=“DENY"/>
</AppenderRef>
</Logger>
Ralph
---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org
AW: Are globs or regular expressions supported in logger names in config files?
Posted by Thorsten Schöning <Th...@veda.net>.
Volkan Yazıcı <vo...@yazi.ci> wrote at Donnerstag, 5. Oktober 2023 15:47:
> Wouldn't it be possible to use an arbiter instead? For instance, you can
> use a `ScriptArbiter` that checks the package name, and if matches, passes
> the log event to your appender,
As I understand the docs, arbiters only return a boolean flag if to include some config nodes.
They don't seem to forward actual log messages or from my understanding don't even seem
able to access logger names of concrete log messages.
If I'm misunderstanding something, an example would be helpful.
PS: Kennen Sie schon VEDA Care Services? Interesse? Dann sprechen Sie uns gerne persönlich an. Weitere Infos finden Sie hier.
____________________________________________________________
Thorsten Schöning
Software Developer
VEDA GmbH
Carl-Zeiss-Straße 14
52477 Alsdorf
Tel.: +49 2404 5507-1345
Thorsten.Schoening@veda.net
www.veda.net
VEDA GmbH, Amtsgericht Aachen HRB 1501
Geschäftsführer: Dr. Ralf Gräßler
Sitz der Gesellschaft: Alsdorf
---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org
Re: Are globs or regular expressions supported in logger names in config files?
Posted by Volkan Yazıcı <vo...@yazi.ci>.
You're right. Then maybe using a `ScriptFilter`?
On Thu, Oct 5, 2023 at 10:43 PM Ralph Goers <ra...@dslextreme.com>
wrote:
>
>
> > On Oct 5, 2023, at 6:47 AM, Volkan Yazıcı <vo...@yazi.ci> wrote:
> >
> > Wouldn't it be possible to use an arbiter instead? For instance, you can
> > use a `ScriptArbiter` that checks the package name, and if matches,
> passes
> > the log event to your appender,
>
> I don’t see how this accomplishes what was asked. Arbiters are evaluated
> when the configuration is constructed, not when the application is running.
>
> Ralph
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
> For additional commands, e-mail: log4j-user-help@logging.apache.org
>
>
Re: Are globs or regular expressions supported in logger names in config files?
Posted by Ralph Goers <ra...@dslextreme.com>.
> On Oct 5, 2023, at 6:47 AM, Volkan Yazıcı <vo...@yazi.ci> wrote:
>
> Wouldn't it be possible to use an arbiter instead? For instance, you can
> use a `ScriptArbiter` that checks the package name, and if matches, passes
> the log event to your appender,
I don’t see how this accomplishes what was asked. Arbiters are evaluated when the configuration is constructed, not when the application is running.
Ralph
---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org
Re: Are globs or regular expressions supported in logger names in config files?
Posted by Volkan Yazıcı <vo...@yazi.ci>.
Wouldn't it be possible to use an arbiter instead? For instance, you can
use a `ScriptArbiter` that checks the package name, and if matches, passes
the log event to your appender,
On Thu, Oct 5, 2023 at 3:13 PM Thorsten Schöning <
Thorsten.Schoening@veda.net> wrote:
> Hi everyone,
>
> I have many logger names following some naming convention like in the
> following examples:
>
> * org.example.unique_phrase.foo
> * org.example.unique_phrase.bar
> * org.example.foo.unique_phrase.bar
> * org.example.bar.unique_phrase.foo
>
> The goal is to configure one file appender for all packages/logger names
> containing "unique_phrase". At the same time I would like to keep the
> possibility for more fine grained configs with possible different appenders
> for different packages of the above example. The only solution I know of is
> really configuring all individual (parent) logger names/packages with the
> same appender. Would be easier if logger names would support some concept
> of globs or regular expressions, so one might only use something like the
> following name:
>
> * org.example.*.unique_phrase.*
>
> Is something like that possible, either out-of-the-box or possibly some
> plugin or ...? Thanks!
>
>
> PS: Kennen Sie schon VEDA Care Services? Interesse? Dann sprechen Sie uns
> gerne persönlich an. Weitere Infos finden Sie hier.
> ____________________________________________________________
> Thorsten Schöning
> Software Developer
>
> VEDA GmbH
> Carl-Zeiss-Straße 14
> 52477 Alsdorf
> Tel.: +49 2404 5507-1345
> Thorsten.Schoening@veda.net
> www.veda.net
> VEDA GmbH, Amtsgericht Aachen HRB 1501
> Geschäftsführer: Dr. Ralf Gräßler
> Sitz der Gesellschaft: Alsdorf
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
> For additional commands, e-mail: log4j-user-help@logging.apache.org
>
>