@@ -647,18 +647,21 @@ protected void doConfigure() {
647647 processConditionals (rootNode );
648648 preConfigure (rootNode );
649649 configurationScheduler .start ();
650- if (rootNode .hasChildren () && rootNode .getChildren ().get (0 ).getName ().equalsIgnoreCase ("Properties" )) {
651- final Node first = rootNode .getChildren ().get (0 );
652- createConfiguration (first , null );
653- if (first .getObject () != null ) {
654- final StrLookup lookup = (StrLookup ) first .getObject ();
655- if (lookup instanceof LoggerContextAware ) {
656- ((LoggerContextAware ) lookup ).setLoggerContext (loggerContext .get ());
650+ // Find the "Properties" node first
651+ boolean hasProperties = false ;
652+ for (final Node node : rootNode .getChildren ()) {
653+ if ("Properties" .equalsIgnoreCase (node .getName ())) {
654+ hasProperties = true ;
655+ createConfiguration (node , null );
656+ if (node .getObject () != null ) {
657+ final StrLookup lookup = node .getObject ();
658+ runtimeStrSubstitutor .setVariableResolver (lookup );
659+ configurationStrSubstitutor .setVariableResolver (lookup );
657660 }
658- runtimeStrSubstitutor .setVariableResolver (lookup );
659- configurationStrSubstitutor .setVariableResolver (lookup );
661+ break ;
660662 }
661- } else {
663+ }
664+ if (!hasProperties ) {
662665 final Map <String , String > map = this .getComponent (CONTEXT_PROPERTIES );
663666 final StrLookup lookup = map == null ? null : new PropertiesLookup (map );
664667 final Interpolator interpolator = new Interpolator (lookup , pluginPackages );
@@ -670,7 +673,7 @@ protected void doConfigure() {
670673 boolean setLoggers = false ;
671674 boolean setRoot = false ;
672675 for (final Node child : rootNode .getChildren ()) {
673- if (child .getName (). equalsIgnoreCase ( "Properties" )) {
676+ if ("Properties" . equalsIgnoreCase ( child .getName ())) {
674677 if (tempLookup == runtimeStrSubstitutor .getVariableResolver ()) {
675678 LOGGER .error ("Properties declaration must be the first element in the configuration" );
676679 }
@@ -680,7 +683,7 @@ protected void doConfigure() {
680683 if (child .getObject () == null ) {
681684 continue ;
682685 }
683- if (child .getName (). equalsIgnoreCase ( "Scripts" )) {
686+ if ("Scripts" . equalsIgnoreCase ( child .getName ())) {
684687 for (final AbstractScript script : child .getObject (AbstractScript [].class )) {
685688 if (script instanceof ScriptRef ) {
686689 LOGGER .error (
@@ -690,19 +693,19 @@ protected void doConfigure() {
690693 scriptManager .addScript (script );
691694 }
692695 }
693- } else if (child .getName (). equalsIgnoreCase ( "Appenders" )) {
696+ } else if ("Appenders" . equalsIgnoreCase ( child .getName ())) {
694697 appenders = child .getObject ();
695698 } else if (child .isInstanceOf (Filter .class )) {
696699 addFilter (child .getObject (Filter .class ));
697- } else if (child .getName (). equalsIgnoreCase ( " Loggers" )) {
700+ } else if (child .isInstanceOf ( Loggers . class )) {
698701 final Loggers l = child .getObject ();
699702 loggerConfigs = l .getMap ();
700703 setLoggers = true ;
701704 if (l .getRoot () != null ) {
702705 root = l .getRoot ();
703706 setRoot = true ;
704707 }
705- } else if (child .getName (). equalsIgnoreCase ( " CustomLevels" )) {
708+ } else if (child .isInstanceOf ( CustomLevels . class )) {
706709 customLevels = child .getObject (CustomLevels .class ).getCustomLevels ();
707710 } else if (child .isInstanceOf (CustomLevelConfig .class )) {
708711 final List <CustomLevelConfig > copy = new ArrayList <>(customLevels );
0 commit comments