title: Log4j2 routing appender JavaScript config error
body: <p>I am using lombok's log4j2 logger and I need to config routing appender based on ThreadContext map. Route keys are determined with a script. Here is the whole log4j2.xml config file: </p>
  
  <p>
  </p>
  
  <pre><code>&lt;Appenders&gt;
      &lt;Console name="Console" target="SYSTEM_OUT"&gt;
          &lt;PatternLayout pattern="%highlight{%d{yyyy-MM-dd HH:mm:ss} [%t] %-5level %c{1}: %msg%n%throwable}"/&gt;
      &lt;/Console&gt;
  
      &lt;RollingFile name="GeneralRollingFile" filename="log/test-log.log"
                   filepattern="log/test-log-%d{yyyy-MM-dd HH:mm:ss}.log"&gt;
          &lt;PatternLayout pattern="%d{yyyy-MM-dd HH:mm:ss} [%t] %-5level %c{1}: %msg%n%throwable"/&gt;
          &lt;Policies&gt;
              &lt;SizeBasedTriggeringPolicy size="25 MB"/&gt;
          &lt;/Policies&gt;
          &lt;DefaultRolloverStrategy max="20"/&gt;
      &lt;/RollingFile&gt;
  
      &lt;Routing name="Routing"&gt;
  
          &lt;Routes&gt;
              &lt;Script name="RoutingInit" language="JavaScript"&gt;
                  &lt;![CDATA[
                  if (logEvent.getContextMap().containsKey("operation-1")) {
                      return "operation-1";
                  } else if (logEvent.getContextMap().containsKey("operation-2")) {
                      return "operation-2";
                  } else {
                      return "general";
                  }
              ]]&gt;
              &lt;/Script&gt;
  
              &lt;Route key="general" ref="GeneralRollingFile"/&gt;
  
              &lt;Route key="operation-1"&gt; 
                  &lt;RollingFile name="operation-1-rolling"
                               fileName="log/operation-1/${ctx:operation-1}.log"
                               filePattern="log/operation-1/${ctx:operation-1}-%d{yyyy-MM-dd HH:mm:ss}.log"&gt;
  
                      &lt;PatternLayout pattern="%d{yyyy-MM-dd HH:mm:ss} [%t] %-5level %c{1}: %msg%n%throwable"/&gt;
                      &lt;Policies&gt;
                          &lt;SizeBasedTriggeringPolicy size="25 MB"/&gt;
                      &lt;/Policies&gt;
                      &lt;DefaultRolloverStrategy max="20"/&gt;
                  &lt;/RollingFile&gt;
              &lt;/Route&gt;
  
              &lt;Route key="operation-2"&gt; 
                  &lt;RollingFile name="operation-2-rolling"
                               fileName="log/operation-2/${ctx:operation-2}.log"
                               filePattern="log/operation-2/${ctx:operation-2}-%d{yyyy-MM-dd HH:mm:ss}.log"&gt;
  
                      &lt;PatternLayout pattern="%d{yyyy-MM-dd HH:mm:ss} [%t] %-5level %c{1}: %msg%n%throwable"/&gt;
                      &lt;Policies&gt;
                          &lt;SizeBasedTriggeringPolicy size="25 MB"/&gt;
                      &lt;/Policies&gt;
                      &lt;DefaultRolloverStrategy max="20"/&gt;
                  &lt;/RollingFile&gt;
              &lt;/Route&gt;
  
          &lt;/Routes&gt;
  
  
      &lt;/Routing&gt;
  
  &lt;/Appenders&gt;
  
  &lt;Loggers&gt;
      &lt;Root level="trace" additivity="false"&gt;
          &lt;AppenderRef ref="Console"/&gt;
          &lt;AppenderRef ref="Routing"/&gt;
      &lt;/Root&gt;
  &lt;/Loggers&gt;
  </code></pre>
  
  <p></p>
  
  <p>However, I am getting the following error:</p>
  
  <pre><code> main ERROR Error running script RoutingInit javax.script.ScriptException: &lt;eval&gt;:2:24 Invalid return statement
                      return "operation-1";
  </code></pre>
  
  <p>Log4j2 documentation gives us a similar script example, which does not work for me ether. 
  I am fairly new to JS, but this code seems as a valid script. Am I getting something wrong? </p>
  
  <p>Thanks in advance.</p>