Suvrat1629 commented on code in PR #3394:
URL: https://github.com/apache/logging-log4j2/pull/3394#discussion_r1918207554


##########
log4j-core/src/main/java/org/apache/logging/log4j/core/filter/ScriptFilter.java:
##########
@@ -57,58 +57,67 @@ private ScriptFilter(
         this.configuration = configuration;
     }
 
+    @Override
+    public void start() {
+        super.start();
+        if (script instanceof ScriptRef) {
+            AbstractScript resolvedScript = 
configuration.getScriptManager().getScript(script.getName());
+            if (resolvedScript == null) {
+                LOGGER.error("No script with name {} has been declared.", 
script.getName());
+                // Optionally: mark the filter as unusable or handle failure 
gracefully
+                return;
+            }
+            this.script = resolvedScript; // Update to resolved script
+        } else {
+            if (!configuration.getScriptManager().addScript(script)) {
+                LOGGER.error("Failed to add script {} to the ScriptManager.", 
script.getName());
+            }
+        }
+    }

Review Comment:
   so should i just revert back the changes i made to the ScriptFilter.java 
file and and make changes to the processRootNode method in the 
AbstractConfiguration and update the logic?
   The logic would be:
   1.Process <Properties> first, as it currently does.
   2.Process script-related components (ScriptPatternSelector, Routes, 
ScriptFilter, etc.) after <Properties> to ensure their dependencies are 
resolved.
   3.Process all remaining components afterward.
   
   is this how i should keep my approach?
   
   Also thanks for your patience and guidance :)



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscr...@logging.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to