You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@logging.apache.org by "Volkan Yazici (Jira)" <ji...@apache.org> on 2021/11/23 19:41:00 UTC
[jira] [Commented] (LOG4J2-3190) ScriptAppenderSelector documentation example fails with importPackage undefined.
[ https://issues.apache.org/jira/browse/LOG4J2-3190?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17448243#comment-17448243 ]
Volkan Yazici commented on LOG4J2-3190:
---------------------------------------
Thanks so much for the heads up [~chubbard]! Mind submitting a PR improving the docs as you suggested, please? (You better target {{release-2.x}} branch for your changes.)
> ScriptAppenderSelector documentation example fails with importPackage undefined.
> --------------------------------------------------------------------------------
>
> Key: LOG4J2-3190
> URL: https://issues.apache.org/jira/browse/LOG4J2-3190
> Project: Log4j 2
> Issue Type: Bug
> Components: Appenders
> Affects Versions: 2.14.1
> Environment: JDK 11.0.13, Mac OSX 10.15.7
> Reporter: Charlie Hubbard
> Priority: Major
>
> The ScriptAppenderSelector and RoutingAppender documented example fails because it includes `importPackage` call which is not defined. Due to changes in the JVM and Nashorn `importPackage(java.lang)` is not defined. I've included a simple fix to the documentation:
>
> {code:java}
> <ScriptAppenderSelector name="envSelector">
> <Script language="javascript"><![CDATA[
> java.lang.System.getProperty("spring.profiles.active") == "aws" ? "Cloudwatch" : "logFile";
> ]]>
> </Script>
> <AppenderSet>
> <RollingFileAppender name="logFile" ..../>
> <Cloudwatch name="cloudwatch" .... />
> </AppenderSet>
> </ScriptAppenderSelector> {code}
> Given that Nashorn is dead, and that is the only engine supported out of the box with this appender. It'd be nice if the documentation explained how to hook up other scripting engines that are supported. Is it simply any engine that registers as JSR-223? It might help out if the details of how to plug in new scripting engines was done, and a simple example of such.
>
--
This message was sent by Atlassian Jira
(v8.20.1#820001)