ppkarwasz commented on code in PR #3501:
URL: https://github.com/apache/logging-log4j2/pull/3501#discussion_r2104447177


##########
log4j-core/src/main/java/org/apache/logging/log4j/core/config/MonitorResource.java:
##########
@@ -0,0 +1,74 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to you under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.logging.log4j.core.config;
+
+import static java.util.Objects.requireNonNull;
+
+import java.net.URI;
+import org.apache.logging.log4j.core.Core;
+import org.apache.logging.log4j.core.config.plugins.Plugin;
+import org.apache.logging.log4j.core.config.plugins.PluginAttribute;
+import org.apache.logging.log4j.core.config.plugins.PluginFactory;
+
+/**
+ * Container for the {@code MonitorResource} element.
+ */
+@Plugin(name = "MonitorResource", category = Core.CATEGORY_NAME, printObject = 
true)
+public final class MonitorResource {
+
+    private final URI uri;
+
+    private MonitorResource(final URI uri) {
+        this.uri = requireNonNull(uri, "uri");
+        if (!"file".equals(uri.getScheme())) {
+            final String message =
+                    String.format("Only `file` scheme is supported in monitor 
resource URIs! Illegal URI: `%s`", uri);
+            throw new IllegalArgumentException(message);
+        }
+    }
+
+    @PluginFactory
+    public static MonitorResource 
createMonitorResource(@PluginAttribute("uri") final URI uri) {

Review Comment:
   URIs can be problematic for some Windows users, which is likely why 
`log4j2.configurationFile` supports both URIs and native file paths. In Log4j 
Core 3, I used the term `location` for this kind of attribute (see 
[`log4j.configuration.location`](https://logging.apache.org/log4j/3.x/manual/systemproperties.html#log4j.configuration.location)).
   
   For `MonitorResource`, we could consider two approaches:
   
   - **Use a single `location` attribute** that accepts both file paths and 
URIs.
   - **Introduce two separate attributes** (`path` and `uri`) to allow users to 
be explicit about the format.
   
   At this point, I'm unsure which approach is best. Since it's unclear whether 
users will request support for Windows paths in the future, adopting the 
builder pattern now seems like a reasonable way to postpone this decision 
without blocking the current feature.
   



-- 
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