You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@logging.apache.org by GitBox <gi...@apache.org> on 2022/01/29 11:18:53 UTC

[GitHub] [logging-log4j2] ppkarwasz opened a new pull request #735: Adds a shorthand method to specify components names

ppkarwasz opened a new pull request #735:
URL: https://github.com/apache/logging-log4j2/pull/735


   As an extension of #733, this PR allows to specify the name of any component in its key. Dots in components names are escaped using dashes `-`. Since this is not the only way to specify a components name, there is **no** shorthand for names with dashes.
   
   After this change, only one property is needed to specify a logger, e.g.:
   
   `logger.org-apache-logging-log4j=DEBUG, Console`
   
   Some changes were necessary in two helper functions in `PropertiesUtil`:
   
    - `extractSubset` didn't extract the property **equal** to the given prefix, although the Javadoc says it should,
    - `partitionOnCommonPrefixes` ignored properties that didn't contain a dot (or threw an exception before #729 ). Now it detects also dotless properties.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@logging.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [logging-log4j2] ppkarwasz commented on pull request #735: Adds a shorthand method to specify components names

Posted by GitBox <gi...@apache.org>.
ppkarwasz commented on pull request #735:
URL: https://github.com/apache/logging-log4j2/pull/735#issuecomment-1026545182


   @carterkozak: this could work, but maybe let's use another suffix for the condensed property. Is `.config` Ok?
   
   Basically it could work like this:
    - the implicit name of an appender is from `appender.` to the **first** dot. The same could apply to filters and internal components,
    - the implicit name of a property is the part following `property.` (this is already true),
    - the implicit name of a logger is from `logger`. to the **last** dot. We add `.config` to Matt's shorthand notation (#733)
   
   @jvz : what do you think?
   
   An example config file:
   
   ```
   property.log.file.name=myapp
   appender.ROLLING.type=RollingFile
   appender.ROLLING.fileName=logs/${log.file.name}.log
   appender.ROLLING.filePattern=logs/${log.file.name}.%i.log
   appender.ROLLING.SIZE=SizeBasedTriggeringPolicy
   logger.org.apache.logging.log4j.config=INFO, ROLLING
   ```
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@logging.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [logging-log4j2] carterkozak commented on pull request #735: Adds a shorthand method to specify components names

Posted by GitBox <gi...@apache.org>.
carterkozak commented on pull request #735:
URL: https://github.com/apache/logging-log4j2/pull/735#issuecomment-1026245393


   I could see something like this working:
   `logger.org.apache.foo.level = INFO, console`
   
   If the property name begins with a known value `logger.` and ends with `.level`, so there's no ambiguity about which components are part of the name. This avoids the `logger.X.name = org.apache.foo`. The `level = <level>, <appender...>` component may be a bit odd, I think it only creates ambiguity if level names can include commas, I haven't checked if that's allowed, but should be unlikely.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@logging.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [logging-log4j2] carterkozak commented on pull request #735: Adds a shorthand method to specify components names

Posted by GitBox <gi...@apache.org>.
carterkozak commented on pull request #735:
URL: https://github.com/apache/logging-log4j2/pull/735#issuecomment-1027030918


   It sounds like we're discussing improving several different parts of the properties configuration scheme at once -- It's great to have an idea of where we want to go before we get started, but I think it would also be helpful to decomp the pieces and approach them separately.
   
   1. Support logger configuration without a `.name = <NAME>` using `logger.<NAME>.<suffix> = <value>` e.g. `logger.org.apache.foo.level = INFO`
   2. Support setting logger level and appenderRef at the same time, perhaps with a new suffix e.g. `logger.myAppender.config = INFO, console`
   3. Similar improvements to other components (appenders/filters)
   
   I think **1** is the most complex, and we'll have to think a bit about interactions with components that can be nested within the logger config. Would we need to ban nested component references when this is used? I suppose it depends how the parser works. It is a substantial departure from all other node-based configurations, and may be difficult to support as features are added (since propertiesconfiguration may need to be aware of logger suffixes).
   
   **2** I don't have a strong opinion between `.level` and `.config` suffixes, the initial `level` suggestion might be easier for users to understand without spending a great deal of time reading the documentation. The `.config` shorthand suffix would be clearer though.
   
   I'd like to hear what other folks think.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@logging.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [logging-log4j2] ppkarwasz commented on pull request #735: Adds a shorthand method to specify components names

Posted by GitBox <gi...@apache.org>.
ppkarwasz commented on pull request #735:
URL: https://github.com/apache/logging-log4j2/pull/735#issuecomment-1024956766


   What about a more common way of escaping the dots, like `\.`? Or maybe quoting/double-quoting the logger name? Although it might not be intuitive why the part after `logger.` must be quoted.
   
   What I mostly dislike in the properties format is its verbosity. Unfortunately users apparently like it (judging by the amount of `log4j.properties -> log4j2.properties` questions on StackOverflow) and the format might benefit from fixing those component prefixes to something meaningful.
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@logging.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [logging-log4j2] ppkarwasz edited a comment on pull request #735: Adds a shorthand method to specify components names

Posted by GitBox <gi...@apache.org>.
ppkarwasz edited a comment on pull request #735:
URL: https://github.com/apache/logging-log4j2/pull/735#issuecomment-1024956766


   What about a more common way of escaping the dots, like `\.`? Or maybe quoting/double-quoting the logger name? Although it might not be intuitive why the part after `logger.` must be quoted.
   
   What I mostly dislike in the properties format is its verbosity. Unfortunately users apparently like it (judging by the amount of `log4j.properties -> log4j2.properties` questions on StackOverflow) and the format might benefit from coercing those component prefixes to something meaningful.
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@logging.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [logging-log4j2] carterkozak commented on pull request #735: Adds a shorthand method to specify components names

Posted by GitBox <gi...@apache.org>.
carterkozak commented on pull request #735:
URL: https://github.com/apache/logging-log4j2/pull/735#issuecomment-1024944765


   I agree with Gary. I’m concerned about the user experience, when an operator sees logger.org-apache-foo it’s not going to be obvious that is equivalent to org.apache.foo.
   Relatedly, it’s not clear when hyphens are meant to replace dots as opposed to referencing hyphens.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@logging.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [logging-log4j2] garydgregory commented on pull request #735: Adds a shorthand method to specify components names

Posted by GitBox <gi...@apache.org>.
garydgregory commented on pull request #735:
URL: https://github.com/apache/logging-log4j2/pull/735#issuecomment-1024942878


   Do we really want to open the door here? What about underscore? Any valid Java name separators? What about mixing separators? 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@logging.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [logging-log4j2] ppkarwasz edited a comment on pull request #735: Adds a shorthand method to specify components names

Posted by GitBox <gi...@apache.org>.
ppkarwasz edited a comment on pull request #735:
URL: https://github.com/apache/logging-log4j2/pull/735#issuecomment-1026545182


   @carterkozak: this could work, but maybe let's use another suffix for the condensed property. Is `.config` Ok?
   
   Basically it could work like this:
    - the implicit name of an appender is the part after `appender.` to the **first** dot. The same could apply to filters and internal components. We might reserve the **noadditivity** and **async** appender names, in order to use them in the logger's shorthand notation,
    - the implicit name of a property is the part following `property.` (this is already true),
    - the implicit name of a logger is after `logger`. to the **last** dot. We add `.config` to Matt's shorthand notation (#733)
   
   @jvz : what do you think?
   
   An example config file:
   
   ```
   property.log.file.name=myapp
   appender.ROLLING.type=RollingFile
   appender.ROLLING.fileName=logs/${log.file.name}.log
   appender.ROLLING.filePattern=logs/${log.file.name}.%i.log
   appender.ROLLING.SIZE=SizeBasedTriggeringPolicy
   logger.org.apache.logging.log4j.config=INFO, ROLLING
   ```
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@logging.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [logging-log4j2] ppkarwasz closed pull request #735: Adds a shorthand method to specify components names

Posted by GitBox <gi...@apache.org>.
ppkarwasz closed pull request #735:
URL: https://github.com/apache/logging-log4j2/pull/735


   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@logging.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [logging-log4j2] ppkarwasz edited a comment on pull request #735: Adds a shorthand method to specify components names

Posted by GitBox <gi...@apache.org>.
ppkarwasz edited a comment on pull request #735:
URL: https://github.com/apache/logging-log4j2/pull/735#issuecomment-1026545182


   @carterkozak: this could work, but maybe let's use another suffix for the condensed property. Is `.config` Ok?
   
   Basically it could work like this:
    - the implicit name of an appender is the part after `appender.` to the **first** dot. The same could apply to filters and internal components,
    - the implicit name of a property is the part following `property.` (this is already true),
    - the implicit name of a logger is after `logger`. to the **last** dot. We add `.config` to Matt's shorthand notation (#733)
   
   @jvz : what do you think?
   
   An example config file:
   
   ```
   property.log.file.name=myapp
   appender.ROLLING.type=RollingFile
   appender.ROLLING.fileName=logs/${log.file.name}.log
   appender.ROLLING.filePattern=logs/${log.file.name}.%i.log
   appender.ROLLING.SIZE=SizeBasedTriggeringPolicy
   logger.org.apache.logging.log4j.config=INFO, ROLLING
   ```
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@logging.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [logging-log4j2] ppkarwasz edited a comment on pull request #735: Adds a shorthand method to specify components names

Posted by GitBox <gi...@apache.org>.
ppkarwasz edited a comment on pull request #735:
URL: https://github.com/apache/logging-log4j2/pull/735#issuecomment-1026545182


   @carterkozak: this could work, but maybe let's use another suffix for the condensed property. Is `.config` or `.value` Ok?
   
   Basically it could work like this:
    - the implicit name of an appender is the part after `appender.` to the **first** dot. The same could apply to filters and internal components. We might reserve the **noadditivity** and **async** appender names, in order to use them in the logger's shorthand notation,
    - the implicit name of a property is the part following `property.` (this is already true),
    - the implicit name of a logger is after `logger`. to the **last** dot. We add `.config` to Matt's shorthand notation (#733)
   
   @jvz : what do you think?
   
   An example config file:
   
   ```
   property.log.file.name=myapp
   appender.ROLLING.type=RollingFile
   appender.ROLLING.fileName=logs/${log.file.name}.log
   appender.ROLLING.filePattern=logs/${log.file.name}.%i.log
   appender.ROLLING.SIZE=SizeBasedTriggeringPolicy
   logger.org.apache.logging.log4j.config=INFO, ROLLING
   ```
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@logging.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [logging-log4j2] ppkarwasz edited a comment on pull request #735: Adds a shorthand method to specify components names

Posted by GitBox <gi...@apache.org>.
ppkarwasz edited a comment on pull request #735:
URL: https://github.com/apache/logging-log4j2/pull/735#issuecomment-1024956766


   What about a more common way of escaping the dots, like `\.`? Or maybe quoting/double-quoting the logger name? Although it might not be intuitive why the part after `logger.` must be quoted.
   
   What I mostly dislike in the properties format is its verbosity. Unfortunately users apparently like it (judging by the amount of `log4j.properties -> log4j2.properties` questions on StackOverflow) and the format might benefit from coercing those component prefixes to something meaningful (like the component's name).
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@logging.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org