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

[I] Script resolution depends on order of element in config file (logging-log4j2)

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

   The resolution of `ScriptRef` elements depends on the order of elements in the configuration file: the `Scripts` element must appear **before** any `ScriptRef` element.
   


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


Re: [I] Script resolution depends on order of element in config file [logging-log4j2]

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

   Hi @jhl221123,
   
   > I'd be grateful if you could take a look when you have a moment. Thanks!
   
   Thanks so much for your PR—and apologies for the delay in reviewing it. I haven’t forgotten about it. We're currently focused on resolving some blockers that are holding up the `2.25.0` release. Once that's sorted, your pull request is at the top of my list.
   
   Appreciate your patience, and thanks for contributing!


-- 
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] Script resolution depends on order of element in config file [logging-log4j2]

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

   Fixed by #3718.


-- 
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] Script resolution depends on order of element in config file (logging-log4j2)

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

   The fix must be done in code.
   
   The basic problem is that the resolution of script references is done in constructors or factory methods of script-enabled components. For example in [`ScriptFilter`](https://logging.apache.org/log4j/2.x/manual/filters.html#Script) we have this snippet in the `createFilter` method:
   
   https://github.com/apache/logging-log4j2/blob/5496c7250184e6460651eb966e8913dd0f3fe341/log4j-core/src/main/java/org/apache/logging/log4j/core/filter/ScriptFilter.java#L148-L157
   
   Since the constructors of Log4j components are called in the order the components are declared in the configuration file, something like this will fail:
   
   ```xml
   <ScriptFilter>
     <ScriptRef ref="GLOBAL_FILTER"/>
   </ScriptFilter>
   <Scripts>
     <ScriptFile name="GLOBAL_FILTER"
                 language="groovy"
                 path="global-filter.groovy"/>
   </Scripts>
   ```
   
   will fail, since at the moment `ScriptRef` is resolved, the `ScriptFile` element has not been processed yet. To solve this problem, the resolution of `ScriptRef`s must be delayed. For example you can perform the resolution in the `start()` method of the [`LifeCycle`](https://logging.apache.org/log4j/2.x/javadoc/log4j-core/org/apache/logging/log4j/core/LifeCycle.html) interface.


-- 
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] Script resolution depends on order of element in config file (logging-log4j2)

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

   Ok, I did make the changes as you suggested by using the start() method. What more changes do i need to make now? Do i need to change the testcases or anything?


-- 
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] Script resolution depends on order of element in config file [logging-log4j2]

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

   Hi @ppkarwasz,
   
   I came across #3176. Noticing the previous pull request had been closed, I've now opened a new PR to address this.
   
   I'd be grateful if you could take a look when you have a moment. 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


Re: [I] Script resolution depends on order of element in config file (logging-log4j2)

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

   Yes you can assign it to me, also can you guide me with the test cases changes as the ScriptFilterTest.java seems to be consistent with my code is there any file that i need to look into?
   


-- 
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] Script resolution depends on order of element in config file (logging-log4j2)

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

   @Suvrat1629,
   
   Yes, if you want to contribute the fix, you should add some tests. See the [PR template](https://github.com/apache/logging-log4j2/blob/2.x/.github/pull_request_template.md) for more details.
   
   Should I assign the issue to you?


-- 
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] Script resolution depends on order of element in config file (logging-log4j2)

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

   (I am new to open source contribution and trying to understand the code)
   Are the changes mentioned in the issue to be made in the log4j2.xml file or the log4j2.json?


-- 
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] Script resolution depends on order of element in config file [logging-log4j2]

Posted by "vy (via GitHub)" <gi...@apache.org>.
vy closed issue #3336: Script resolution depends on order of element in config file
URL: https://github.com/apache/logging-log4j2/issues/3336


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