Charlie Hubbard created LOG4J2-3190:
---------------------------------------

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


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)

Reply via email to