You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@sling.apache.org by "rombert (via GitHub)" <gi...@apache.org> on 2026/06/09 14:31:18 UTC
Re: [PR] SLING-13224 - Allow configuring which loggers the LogStore captures [sling-org-apache-sling-commons-log]
rombert commented on code in PR #34:
URL: https://github.com/apache/sling-org-apache-sling-commons-log/pull/34#discussion_r3381442015
##########
src/main/java/org/apache/sling/commons/log/logback/internal/store/LogStoreRegistrar.java:
##########
@@ -74,14 +77,23 @@ void updated(@Nullable Dictionary<String, ?> properties) {
.defaultValue(LogStoreImpl.DEFAULT_MAX_ENTRIES)
.to(Integer.class);
+ String[] loggers = Converters.standardConverter()
+ .convert(properties.get(PROP_LOGGERS))
+ .defaultValue(DEFAULT_LOGGERS)
+ .to(String[].class);
+ if (loggers == null || loggers.length == 0) {
Review Comment:
Is this actually needed if you set `defaultValue` above?
##########
src/main/java/org/apache/sling/commons/log/logback/internal/store/LogStoreRegistrar.java:
##########
@@ -97,8 +109,33 @@ private void activate(int maxEntries) {
Dictionary<String, Object> appenderProps = new Hashtable<>();
appenderProps.put(Constants.SERVICE_VENDOR, LogConstants.ASF_SERVICE_VENDOR);
appenderProps.put(Constants.SERVICE_DESCRIPTION, "Log Store Appender");
- appenderProps.put("loggers", "ROOT");
+ appenderProps.put(PROP_LOGGERS, loggers);
appenderRegistration = bundleContext.registerService(Appender.class, appender, appenderProps);
+ activeLoggers = loggers;
+ }
+
+ private void applyLoggerConfig(String[] loggers) {
+ if (appenderRegistration == null || equalLoggers(activeLoggers, loggers)) {
+ return;
+ }
+ Dictionary<String, Object> appenderProps = new Hashtable<>();
+ appenderProps.put(Constants.SERVICE_VENDOR, LogConstants.ASF_SERVICE_VENDOR);
+ appenderProps.put(Constants.SERVICE_DESCRIPTION, "Log Store Appender");
+ appenderProps.put(PROP_LOGGERS, loggers);
+ appenderRegistration.setProperties(appenderProps);
+ activeLoggers = loggers;
+ }
+
+ private boolean equalLoggers(String[] a, String[] b) {
Review Comment:
Can't this be replaced with `Arrays#equals(Object[], Object[])` ?
--
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: dev-unsubscribe@sling.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org