@@ -647,18 +647,21 @@ protected void doConfigure() {
647
647
processConditionals (rootNode );
648
648
preConfigure (rootNode );
649
649
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 );
657
660
}
658
- runtimeStrSubstitutor .setVariableResolver (lookup );
659
- configurationStrSubstitutor .setVariableResolver (lookup );
661
+ break ;
660
662
}
661
- } else {
663
+ }
664
+ if (!hasProperties ) {
662
665
final Map <String , String > map = this .getComponent (CONTEXT_PROPERTIES );
663
666
final StrLookup lookup = map == null ? null : new PropertiesLookup (map );
664
667
final Interpolator interpolator = new Interpolator (lookup , pluginPackages );
@@ -670,7 +673,7 @@ protected void doConfigure() {
670
673
boolean setLoggers = false ;
671
674
boolean setRoot = false ;
672
675
for (final Node child : rootNode .getChildren ()) {
673
- if (child .getName (). equalsIgnoreCase ( "Properties" )) {
676
+ if ("Properties" . equalsIgnoreCase ( child .getName ())) {
674
677
if (tempLookup == runtimeStrSubstitutor .getVariableResolver ()) {
675
678
LOGGER .error ("Properties declaration must be the first element in the configuration" );
676
679
}
@@ -680,7 +683,7 @@ protected void doConfigure() {
680
683
if (child .getObject () == null ) {
681
684
continue ;
682
685
}
683
- if (child .getName (). equalsIgnoreCase ( "Scripts" )) {
686
+ if ("Scripts" . equalsIgnoreCase ( child .getName ())) {
684
687
for (final AbstractScript script : child .getObject (AbstractScript [].class )) {
685
688
if (script instanceof ScriptRef ) {
686
689
LOGGER .error (
@@ -690,19 +693,19 @@ protected void doConfigure() {
690
693
scriptManager .addScript (script );
691
694
}
692
695
}
693
- } else if (child .getName (). equalsIgnoreCase ( "Appenders" )) {
696
+ } else if ("Appenders" . equalsIgnoreCase ( child .getName ())) {
694
697
appenders = child .getObject ();
695
698
} else if (child .isInstanceOf (Filter .class )) {
696
699
addFilter (child .getObject (Filter .class ));
697
- } else if (child .getName (). equalsIgnoreCase ( " Loggers" )) {
700
+ } else if (child .isInstanceOf ( Loggers . class )) {
698
701
final Loggers l = child .getObject ();
699
702
loggerConfigs = l .getMap ();
700
703
setLoggers = true ;
701
704
if (l .getRoot () != null ) {
702
705
root = l .getRoot ();
703
706
setRoot = true ;
704
707
}
705
- } else if (child .getName (). equalsIgnoreCase ( " CustomLevels" )) {
708
+ } else if (child .isInstanceOf ( CustomLevels . class )) {
706
709
customLevels = child .getObject (CustomLevels .class ).getCustomLevels ();
707
710
} else if (child .isInstanceOf (CustomLevelConfig .class )) {
708
711
final List <CustomLevelConfig > copy = new ArrayList <>(customLevels );
0 commit comments