logging-log4j-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Mihhail Lapushkin (JIRA)" <j...@apache.org>
Subject [jira] [Updated] (LOG4J2-1842) Expand SystemPropertiesLookup syntax
Date Thu, 09 Mar 2017 18:24:38 GMT

     [ https://issues.apache.org/jira/browse/LOG4J2-1842?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Mihhail Lapushkin updated LOG4J2-1842:
--------------------------------------
    Description: 
I've been using a modified version of {{SystemPropertiesLookup}} in my project. Maybe it could
be part of the library.

The idea is to allow a series of property keys to be specified. If one of the properties is
present, then it is used. If none are present, then the default value is used. For example:
{code}
<Logger name="com.myapp.dao" level="${sys:myapp.log.level|myapp.log.level.dao|warn}"/>

<Logger name="com.myapp.service" level="${sys:myapp.log.level|myapp.log.level.service|warn}"/>

<Logger name="com.myapp.controller" level="${sys:myapp.log.level|myapp.log.level.controller|warn}"/>
{code}
This allows me to quickly rerun the app with different log levels without fiddling with the
configuration file or JConsole. Defaults represent production settings, so that nothing extra
needs to be specified to run the app.
This work nice in other places as well:
{code}
<PatternLayout disableAnsi="${sys:myapp.log.nocolor|true}">
{code}
Disables colors by default (for production build), but leaves an easy way to turn them on
for development.

When no pipes are present in the expression, then the standard property lookup is used, so
the change is backwards-compatible.
Can be a separate lookup if needed.

  was:
https://github.com/apache/logging-log4j2/pull/64

I've been using a modified version of {{SystemPropertiesLookup}} in my project. Maybe it could
be part of the library.

The idea is to allow a series of property keys to be specified. If one of the properties is
present, then it is used. If none are present, then the default value is used. For example:
{code}
<Logger name="com.myapp.dao" level="${sys:myapp.log.level|myapp.log.level.dao|warn}"/>

<Logger name="com.myapp.service" level="${sys:myapp.log.level|myapp.log.level.service|warn}"/>

<Logger name="com.myapp.controller" level="${sys:myapp.log.level|myapp.log.level.controller|warn}"/>
{code}
This allows me to quickly rerun the app with different log levels without fiddling with the
configuration file or JConsole. Defaults represent production settings, so that nothing extra
needs to be specified to run the app.
This work nice in other places as well:
{code}
<PatternLayout disableAnsi="${sys:myapp.log.nocolor|true}">
{code}
Disables colors by default (for production build), but leaves an easy way to turn them on
for development.

When no pipes are present in the expression, then the standard property lookup is used, so
the change is backwards-compatible.
Can be a separate lookup if needed.


> Expand SystemPropertiesLookup syntax
> ------------------------------------
>
>                 Key: LOG4J2-1842
>                 URL: https://issues.apache.org/jira/browse/LOG4J2-1842
>             Project: Log4j 2
>          Issue Type: Improvement
>          Components: Lookups
>            Reporter: Mihhail Lapushkin
>            Priority: Minor
>
> I've been using a modified version of {{SystemPropertiesLookup}} in my project. Maybe
it could be part of the library.
> The idea is to allow a series of property keys to be specified. If one of the properties
is present, then it is used. If none are present, then the default value is used. For example:
> {code}
> <Logger name="com.myapp.dao" level="${sys:myapp.log.level|myapp.log.level.dao|warn}"/>
> <Logger name="com.myapp.service" level="${sys:myapp.log.level|myapp.log.level.service|warn}"/>
> <Logger name="com.myapp.controller" level="${sys:myapp.log.level|myapp.log.level.controller|warn}"/>
> {code}
> This allows me to quickly rerun the app with different log levels without fiddling with
the configuration file or JConsole. Defaults represent production settings, so that nothing
extra needs to be specified to run the app.
> This work nice in other places as well:
> {code}
> <PatternLayout disableAnsi="${sys:myapp.log.nocolor|true}">
> {code}
> Disables colors by default (for production build), but leaves an easy way to turn them
on for development.
> When no pipes are present in the expression, then the standard property lookup is used,
so the change is backwards-compatible.
> Can be a separate lookup if needed.



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-dev-help@logging.apache.org


Mime
View raw message