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/24 08:17:00 UTC
[jira] [Resolved] (LOG4J2-3190) ScriptAppenderSelector documentation example fails with importPackage undefined.
[ https://issues.apache.org/jira/browse/LOG4J2-3190?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Volkan Yazici resolved LOG4J2-3190.
-----------------------------------
Resolution: Fixed
> 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
> Assignee: Volkan Yazici
> Priority: Major
> Fix For: 2.15.0
>
>
> 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)