[ 
https://issues.apache.org/jira/browse/LOG4J2-3191?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Charlie Hubbard updated LOG4J2-3191:
------------------------------------
    Description: 
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 shown with a simple example of such.

 

  was:
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.

 


> ScriptAppenderSelector documentation example fails with importPackage 
> undefined.
> --------------------------------------------------------------------------------
>
>                 Key: LOG4J2-3191
>                 URL: https://issues.apache.org/jira/browse/LOG4J2-3191
>             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 shown with a simple example of such.
>  



--
This message was sent by Atlassian Jira
(v8.20.1#820001)

Reply via email to