[ 
https://issues.apache.org/jira/browse/LOG4J2-2486?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17488619#comment-17488619
 ] 

ASF subversion and git services commented on LOG4J2-2486:
---------------------------------------------------------

Commit e06433578506569ef7fa493f96a26956cca20606 in logging-log4j2's branch 
refs/heads/release-2.x from Ralph Goers
[ https://gitbox.apache.org/repos/asf?p=logging-log4j2.git;h=e064335 ]

LOG4J2-2486 - Fix test


> AbstractConfiguration - Allow to disable ScriptManager
> ------------------------------------------------------
>
>                 Key: LOG4J2-2486
>                 URL: https://issues.apache.org/jira/browse/LOG4J2-2486
>             Project: Log4j 2
>          Issue Type: Improvement
>          Components: Configurators, Core
>    Affects Versions: 2.11.1
>            Reporter: Sebastian
>            Assignee: Ralph Goers
>            Priority: Minor
>
> I don't use any of the scripting features. Nevertheless, these are always 
> initialized when Log4j2 is initialized (see AbstractConfiguration -> 
> initialize method). Although the component seems to be optional (see below). 
> Therefore I'd wish there was an option to disable this feature.
> At the moment, the initialize method will always _try_ to instantiate 
> ScriptManager. As the ScriptEngineManager used inside is not available on 
> Android (see issue LOG4J2-1920), this initialization is fault-tolerant using 
> try-catch: If it's not available, just leave the member "scriptManager" null 
> and avoid to use it later in the code (null checks). So Log4j2 seems to work 
> without this as well. See the relevant initialization code snippet from 
> AbstractConfiguration:
> {code:java}
>     @Override
>     public void initialize() {
>         LOGGER.debug(Version.getProductString() + " initializing 
> configuration {}", this);
>         subst.setConfiguration(this);
>         try {
>             scriptManager = new ScriptManager(this, watchManager);
>         } catch (final LinkageError | Exception e) {
>             // LOG4J2-1920 ScriptEngineManager is not available in Android
>             LOGGER.info("Cannot initialize scripting support because this JRE 
> does not support it.", e);
>         }
>         // ...
> {code}
> I'd like to be able to use Log4j2 without having it initialize the 
> ScriptManager mandatorily.
> So it would be nice if I could enforce the scripting-less Android mode. ;)
> As I use programmatic configuration using the builder, a setter in the 
> ConfigurationBuilder would be great! Example:
> {code:java}
> void setEnableScriptingManager( boolean enableScriptingManager );
> {code}



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

Reply via email to