You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@logging.apache.org by "virajjasani (via GitHub)" <gi...@apache.org> on 2023/01/26 19:27:44 UTC

[GitHub] [logging-log4j2] virajjasani opened a new issue, #1227: ERROR No appender references provided to AsyncAppender: appenderRefs

virajjasani opened a new issue, #1227:
URL: https://github.com/apache/logging-log4j2/issues/1227

   ## Description
   Using log4j2.properties to define AsyncAppender and have RFA added to the AsyncAppender. Somehow the appender ref is not correctly getting identified and hence it's resulting in error.
   
   ## Configuration
   
   **Version:** 2.17.2
   
   **Operating system:** MacOS 13.2
   
   **JDK:** 1.8.0_341
   
   log4j2.properties:
   
   ```
   appender.DRFA.type = RollingFile
   appender.DRFA.name = DRFA
   appender.DRFA.fileName = xyz
   appender.DRFA.filePattern = xyz
   appender.DRFA.createOnDemand = true
   appender.DRFA.layout.type = PatternLayout
   appender.DRFA.layout.pattern = %d{ISO8601} %-5p [%t] %c{2}: %.1000m%n
   appender.DRFA.policies.type = Policies
   appender.DRFA.policies.time.type = TimeBasedTriggeringPolicy
   appender.DRFA.policies.time.interval = 1
   appender.DRFA.policies.time.modulate = true
   appender.DRFA.policies.size.type = SizeBasedTriggeringPolicy
   appender.DRFA.policies.size.size = 256MB
   appender.DRFA.strategy.type = DefaultRolloverStrategy
   appender.DRFA.strategy.max = 20
   
   
   appender.ASYA.type = Async
   appender.ASYA.name = ASYA
   appender.ASYA.appenderRefs = DRFA
   appender.ASYA.blocking = true
   appender.ASYA.bufferSize = 256
   ```
   
   This results in error:
   
   ```
   2023-01-26 00:58:07,944 main ERROR No appender references provided to AsyncAppender: appenderRefs
   2023-01-26 00:58:07,951 main DEBUG AsyncAppender$Builder(={}, errorRef="null", blocking="true", shutdownTimeout="null", bufferSize="256", name="ASYA", includeLocation="null", Configuration(PropertiesConfig), ignoreExceptions="null", BlockingQueueFactory=null, Filter=null, ={})
   2023-01-26 00:58:07,951 main ERROR Could not create plugin of type class org.apache.logging.log4j.core.appender.AsyncAppender for element Async org.apache.logging.log4j.core.config.ConfigurationException: Arguments given for element Async are invalid: field 'appenderRefs' has invalid value '[Lorg.apache.logging.log4j.core.config.AppenderRef;@35cabb2a'
       at org.apache.logging.log4j.core.config.plugins.util.PluginBuilder.injectFields(PluginBuilder.java:212)
       at org.apache.logging.log4j.core.config.plugins.util.PluginBuilder.build(PluginBuilder.java:123)
       at org.apache.logging.log4j.core.config.AbstractConfiguration.createPluginObject(AbstractConfiguration.java:1122)
   ...
   ...
   ... 
   ```
   
   Tried these options but they are not able to attach ref:
   
   ```
   appender.ASYA.appenderRefs.ref = DRFA
   appender.ASYA.appenderRefs.DRFA.ref = DRFA
   appender.ASYA = DRFA 
   ```
   


-- 
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.apache.org

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


[GitHub] [logging-log4j2] ppkarwasz commented on issue #1227: ERROR No appender references provided to AsyncAppender: appenderRefs

Posted by "ppkarwasz (via GitHub)" <gi...@apache.org>.
ppkarwasz commented on issue #1227:
URL: https://github.com/apache/logging-log4j2/issues/1227#issuecomment-1411468631

   Check the [`AsyncAppender` javadoc](https://logging.apache.org/log4j/1.2/apidocs/org/apache/log4j/AsyncAppender.html):
   
   > **Important note**: The AsyncAppender can only be script configured using the [DOMConfigurator](https://logging.apache.org/log4j/1.2/apidocs/org/apache/log4j/xml/DOMConfigurator.html).
   
   In the XML configuration you can use `<appender-ref ref="..."/>`.
   
   **Remark**:  Log4j 1.2 reached end-of-life almost 8 years ago. Several security vulnerabilities were discovered since then. You should **not** use it.


-- 
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] virajjasani commented on issue #1227: ERROR No appender references provided to AsyncAppender: appenderRefs

Posted by "virajjasani (via GitHub)" <gi...@apache.org>.
virajjasani commented on issue #1227:
URL: https://github.com/apache/logging-log4j2/issues/1227#issuecomment-1406856186

   Closing the issue, thanks


-- 
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] virajjasani commented on issue #1227: ERROR No appender references provided to AsyncAppender: appenderRefs

Posted by "virajjasani (via GitHub)" <gi...@apache.org>.
virajjasani commented on issue #1227:
URL: https://github.com/apache/logging-log4j2/issues/1227#issuecomment-1411529807

   > Important note: The AsyncAppender can only be script configured using the [DOMConfigurator](https://logging.apache.org/log4j/1.2/apidocs/org/apache/log4j/xml/DOMConfigurator.html).
   
   I see, thanks for the details. Looks like we might have to use AsyncAppenders together with RFA in that case (instead of applying RFA as appender ref to AsyncAppender).
   
   
   > Remark: Log4j 1.2 reached end-of-life almost 8 years ago. Several security vulnerabilities were discovered since then. You should not use it.
   
   I agree, we are migrating from Log4J1 to Log4J2 only. However, as part of the big migration, we would be working on several sub-tasks. Since we use log4j.properties (rather than xml), we had added RFA to AsyncAppender programmatically. In order to avoid using `org.apache.log4j.Logger` directly, we need to replace them with slf4j. Before we do that, first I wanted to replace code that does `asyncAppender.addAppender(rfaAppender)` with log4j.properties in log4j1. Once this sub-task is done, as part of the overall migration, we can directly replace all log4j.properties to log4j2.properties in one shot.
   Hence, I raised above question.
   
   Thanks


-- 
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 issue #1227: ERROR No appender references provided to AsyncAppender: appenderRefs

Posted by "ppkarwasz (via GitHub)" <gi...@apache.org>.
ppkarwasz commented on issue #1227:
URL: https://github.com/apache/logging-log4j2/issues/1227#issuecomment-1411549556

   @virajjasani,
   
   Check our [Log4j 1.2 to Log4j 2.x](https://logging.apache.org/log4j/2.x/manual/migration.html) migration guide. Even if the original Log4j 1.2 does not support configuring an `AsyncAppender` through properties [`log4j-1.2-api`](https://mvnrepository.com/artifact/org.apache.logging.log4j/log4j-1.2-api) does (the config you provided should work just fine).
   
   > ... we need to replace them with slf4j.
   
   No you don't, Log4j2 API provides everything SLF4J does and more. Check [Remko's answer on SO](https://stackoverflow.com/q/41498021/11748454) from 5 years ago. Although SLF4J has introduced some features since the, Log4j2 API was not idling either.
   
   If you have more question on the migration, I propose to continue this discussion on the [`log4j-user` mailing list](https://logging.apache.org/log4j/2.x/mail-lists.html).


-- 
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] virajjasani commented on issue #1227: ERROR No appender references provided to AsyncAppender: appenderRefs

Posted by "virajjasani (via GitHub)" <gi...@apache.org>.
virajjasani commented on issue #1227:
URL: https://github.com/apache/logging-log4j2/issues/1227#issuecomment-1411208411

   @ppkarwasz 
   
   ```
   appender.ASYA.$0.type = AppenderRef
   appender.ASYA.$0.ref = DRFA
   ```
   
   Are you aware of log4j1.properties alternatives for the above?
   
   ```
   log4j.appender.RFA=org.apache.log4j.RollingFileAppender
   log4j.appender.RFA.File=${hadoop.log.dir}/datanode-metrics.log
   log4j.appender.RFA.layout=org.apache.log4j.PatternLayout
   log4j.appender.RFA.layout.ConversionPattern=%d{ISO8601} %m%n
   log4j.appender.RFA.MaxBackupIndex=1
   log4j.appender.RFA.MaxFileSize=64MB
   log4j.appender.ASYNC=org.apache.log4j.AsyncAppender
   log4j.appender.ASYNC.appender-ref=RFA
   log4j.logger.classname=INFO,ASYNC
   log4j.additivity.classname=false
   ```
   
   I tried this but it says `log4j:WARN No such property [appender-ref] in org.apache.log4j.AsyncAppender.`
   


-- 
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 issue #1227: ERROR No appender references provided to AsyncAppender: appenderRefs

Posted by "ppkarwasz (via GitHub)" <gi...@apache.org>.
ppkarwasz commented on issue #1227:
URL: https://github.com/apache/logging-log4j2/issues/1227#issuecomment-1405572159

   @virajjasani,
   
   Try:
   
   ```
   appender.ASYA.$0.type = AppenderRef
   appender.ASYA.$0.ref = DRFA
   ```
   
   You chose probably the worst configuration format available. Log4j2 configuration is hierarchical, which can not be said of the properties format. The properties format basically follows these rules:
   
    * all properties and subcomponents of a Log4j2 component have the same prefix (in your case `appender.ASYA` for the asynchronous appender),
    * simple properties are specified as `prefix.property_name` (e.g. `appender.ASYA.blocking`),
    * subcomponents have a prefix of `parent_prefix.unique_id` (in my example `appender.ASYA.$0`), must have a `type` property (`appender.ASYA.$0.type = AppenderRef` in the example) and then you specify the subcomponent's properties as in the previous points.
   
   **Remark:** some subcomponents, such as layouts or filters have a hardcoded unique id.
   


-- 
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


Re: [I] ERROR No appender references provided to AsyncAppender: appenderRefs (logging-log4j2)

Posted by "virajjasani (via GitHub)" <gi...@apache.org>.
virajjasani commented on issue #1227:
URL: https://github.com/apache/logging-log4j2/issues/1227#issuecomment-1451131493

   Thanks @ppkarwasz 


-- 
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] virajjasani commented on issue #1227: ERROR No appender references provided to AsyncAppender: appenderRefs

Posted by "virajjasani (via GitHub)" <gi...@apache.org>.
virajjasani commented on issue #1227:
URL: https://github.com/apache/logging-log4j2/issues/1227#issuecomment-1406854312

   Thanks @ppkarwasz. Yes looks like I got it wrong with hierarchical way for 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] virajjasani closed issue #1227: ERROR No appender references provided to AsyncAppender: appenderRefs

Posted by "virajjasani (via GitHub)" <gi...@apache.org>.
virajjasani closed issue #1227: ERROR No appender references provided to AsyncAppender: appenderRefs
URL: https://github.com/apache/logging-log4j2/issues/1227


-- 
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