logging-log4j-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Roger Kapsi (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (LOG4J2-1531) Change attribute and component values from String to Object
Date Sat, 20 Aug 2016 13:37:21 GMT

    [ https://issues.apache.org/jira/browse/LOG4J2-1531?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15429381#comment-15429381

Roger Kapsi commented on LOG4J2-1531:

Looking at it as an outsider... You have a working plugin system with documentation, knowledge
and a community. The {{DefaultConfigurationBuilder}} class and its buddies are like 99% there
and everything works. The only thing missing is the ability to pass around non-String configuration
values which seems an relic of text based configuration files. The place I'm working at has
given up on text based configuration a very long time ago and we're using that other logging
framework that has a Groovy DSL. 

Adding adder methods to {{ConfigurationBuilder}} for the various types certainly works. It'll
possibly be a lot more involved and seems like an API breaking change. That's fine by me but
I'm not vested in log4j yet. Up to you.

But honestly, your plugin system works fine and all that is needed for it to be 100% there
is the ability to pass non-String configuration values around.

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

To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-dev-help@logging.apache.org

View raw message