[ https://issues.apache.org/jira/browse/LOG4J2-1531?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17801036#comment-17801036 ]
Matt Sicker edited comment on LOG4J2-1531 at 12/28/23 6:29 PM: --------------------------------------------------------------- So basically a wrapper around the ConfigurationBuilder API, I see. If the general idea here is being able to provide either instances of plugins that were already instantiated or a supplier function of some sort providing the plugin (either with no args or with some context arguments) similar to what Mikael had proposed, then I think we can figure something out along those lines. Edit: this DSL update might not be exactly the same API as existing plugins so that we can expose functional interfaces. was (Author: jvz): So basically a wrapper around the ConfigurationBuilder API, I see. If the general idea here is being able to provide either instances of plugins that were already instantiated or a supplier function of some sort providing the plugin (either with no args or with some context arguments) similar to what Mikael had proposed, then I think we can figure something out along those lines. > Change attribute and component values from String to Object > ----------------------------------------------------------- > > Key: LOG4J2-1531 > URL: https://issues.apache.org/jira/browse/LOG4J2-1531 > Project: Log4j 2 > Issue Type: Improvement > Components: Core > Affects Versions: 2.6.2 > Reporter: Roger Kapsi > Assignee: Matt Sicker > Priority: Major > Attachments: log4j2-1531-1.0.patch > > > I was looking into creating a ConfigurationFactory/Builder that is backed by > a Clojure DSL. It works rather beautifully until I tried to create a filter > that is backed by a Clojure function. There is literally no way to pass > arbitrary objects into a PluginFactory. All component values and attributes > are assumed to be Strings. > {code:java} > (configuration > (appender "stdout" "CONSOLE" > (layout "PatternLayout" > (attribute "pattern" "%d [%t] %-5level: %msg%n")) > (filter "ClojureFilter" > ;; This LoC doesn't work: addAttribute(key, value) > ;; will store the toString() of the value. Bummer. > ;; I'd the so easy and beautiful if it didn't. > (attribute "fn" (fn [logger & more] (println logger))))) > > (logger "TestLogger" Level/INFO > (appender-ref "rolling") > (attribute "additivity" false)) > (root-logger Level/DEBUG > (appender-ref "rolling"))) > {code} > {code:java} > @Plugin(name = "ClojureFilter", category = Node.CATEGORY, elementType = > Filter.ELEMENT_TYPE, printObject = true) > class ClojureFilter extends AbstractFilter { > @PluginFactory > public static ClojureFilter createFilter( > @PluginAttribute("fn") IFn fn, ...) { > return new ClojureFilter(fn, ...); > } > } > {code} -- This message was sent by Atlassian Jira (v8.20.10#820010)