[jira] [Commented] (LOG4J2-1531) Change attribute and component values from String to Object

2016-08-30 Thread JIRA

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

Mikael Ståldal commented on LOG4J2-1531:


LOG4J2-1528 is now done and merged to master. Please update any work on this to 
include the latest master branch.

We need to figure out how rich programmatic configuration should be handled by 
the new XML building methods.

> 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: Ralph Goers
> 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
(v6.3.4#6332)

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



[jira] [Commented] (LOG4J2-1531) Change attribute and component values from String to Object

2016-08-21 Thread Ralph Goers (JIRA)

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

Ralph Goers commented on LOG4J2-1531:
-

Ok. Then I will do it when I get some time.

> 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: Ralph Goers
> 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
(v6.3.4#6332)

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



[jira] [Commented] (LOG4J2-1531) Change attribute and component values from String to Object

2016-08-21 Thread Roger Kapsi (JIRA)

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

Roger Kapsi commented on LOG4J2-1531:
-

I looked at {{@PluginElement}} et al. It's just a deferral to {{@Plugin}} and a 
few other types that get their values again via {{addAttribute()}} which are 
strings.

Please notice that I'm not looking for a replacement for attributes or 
elements. The title of this ticket does say to change the value type of 
attributes but that was before I dug deeper into the implementation of it. The 
patch I submitted proposes a new {{add_ARG_ument(String, Object)}} method along 
with a new {{@Plugin_ARG_ument}} annotation that doesn't interfere with 
attributes or elements. It just allows plugin developers to pass arbitrary 
objects into their {{@PluginFactory}}. The latter is desirable for programmatic 
configuration. Be it plain Java or some other lang. I have mentioned Lamdas a 
lot as they're as arbitrary as it gets but it applies equally well to other 
objects. Either because they can't or it's simply not desirable. 

Adding methods such as {{add(Appender)}} to the configuration builder works 
(and you should probably do it) but it doesn't necessarily facilitate a 
standard way of constructing things. Speaking in terms of a DSL it's not 
necessarily something you want. You want a standard way of construction with 
arbitrary arguments and you have a nice builder+plugin system for that. It's 
only missing that one feature.

I have now solved the problem with a few hundred LoC of using a facade pattern, 
inheritance and overriding some methods. It's sensitive to upstream changes but 
it works. I wish it wasn't necessary though.

Please let me know when you've figured out the essence of this ticket. I'm 
happy to iterate on it but attributes and elements aren't it and I don't want 
to go in circles on it.


> 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
(v6.3.4#6332)

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



[jira] [Commented] (LOG4J2-1531) Change attribute and component values from String to Object

2016-08-20 Thread Ralph Goers (JIRA)

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

Ralph Goers commented on LOG4J2-1531:
-

Yes, I have no problem with those being added. I have a problem in that they 
are treated as replacements for Attributes instead of Elements.

> 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
(v6.3.4#6332)

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



[jira] [Commented] (LOG4J2-1531) Change attribute and component values from String to Object

2016-08-20 Thread Ralph Goers (JIRA)

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

Ralph Goers commented on LOG4J2-1531:
-

If you do the above you have to allow arbitrary objects. This is because 
Appenders, Filters, etc can be configured with other objects that you have no 
way of anticipating. That is why ConfigurationBuilder has an newComponent 
method.

> 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
(v6.3.4#6332)

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



[jira] [Commented] (LOG4J2-1531) Change attribute and component values from String to Object

2016-08-20 Thread Roger Kapsi (JIRA)

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

Roger Kapsi commented on LOG4J2-1531:
-

Please notice that the Patch I submitted doesn't change {{addAttribute()}} or 
{{@PluginAttribute}}. They stay as is.

There is a new {{addArgument()}} method and {{@PluginArgument}} annotation.

> 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
(v6.3.4#6332)

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



[jira] [Commented] (LOG4J2-1531) Change attribute and component values from String to Object

2016-08-20 Thread JIRA

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

Mikael Ståldal commented on LOG4J2-1531:


This could interfere with LOG4J2-1528. I would like to get LOG4J2-1528 done 
before we do this.

> 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
(v6.3.4#6332)

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



[jira] [Commented] (LOG4J2-1531) Change attribute and component values from String to Object

2016-08-20 Thread JIRA

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

Mikael Ståldal commented on LOG4J2-1531:


Not arbitrary objects. 

My proposal is to add this to {{ConfigurationBuilder}}:
{code}
ConfigurationBuilder add(Appender appender);
ConfigurationBuilder add(Filter filter);
{code}

and this to {{AppenderComponentBuilder}}:
{code}
AppenderComponentBuilder add(Layout layout);
{code}

and this to {{FilterableComponentBuilder}}:
{code}
T add(Filter filter);
{code}

> 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
(v6.3.4#6332)

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



[jira] [Commented] (LOG4J2-1531) Change attribute and component values from String to Object

2016-08-20 Thread Ralph Goers (JIRA)

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

Ralph Goers commented on LOG4J2-1531:
-

Mikael,I don't know that I would want to move in this direction because you 
would still have to have the addComponent variant that allows arbitrary objects 
to be created.

> 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
(v6.3.4#6332)

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



[jira] [Commented] (LOG4J2-1531) Change attribute and component values from String to Object

2016-08-20 Thread Ralph Goers (JIRA)

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

Ralph Goers commented on LOG4J2-1531:
-

I like what this patch is trying to do, however, I have some concerns.
1. When would it ever be desirable that the value of a Node is not a String? 
From a programmatic perspective I am not sure why you would want anything else.
2. Do we really need to support anything other than a Function? Although it 
would be nice to be able to use Java 8's Function interface I would imagine we 
could just use our own, more or less as you have done.
3.PluginAttributes are Strings and really should stay that way. When a Plugin 
has a parameter that is a complex object it is represented by a PluginElement, 
which is a complex object represented by its own Node. So a PluginAttribute (or 
PluginFunction?) really should be a PluginElement where the PluginType has the 
Object already populated. With that I believe most of these changes are 
unnecessary. 

> 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
(v6.3.4#6332)

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



[jira] [Commented] (LOG4J2-1531) Change attribute and component values from String to Object

2016-08-20 Thread JIRA

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

Mikael Ståldal commented on LOG4J2-1531:


Why would my proposal be more API breaking than yours?

> 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
(v6.3.4#6332)

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



[jira] [Commented] (LOG4J2-1531) Change attribute and component values from String to Object

2016-08-20 Thread Roger Kapsi (JIRA)

[ 
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
(v6.3.4#6332)

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



[jira] [Commented] (LOG4J2-1531) Change attribute and component values from String to Object

2016-08-20 Thread JIRA

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

Mikael Ståldal commented on LOG4J2-1531:


I think that this is a misuse of the {{@Plugin}} mechanism, it is designed for 
configuration files rather than programmatic configuration.

If we want rich programmatic configuration, I think we should bypass the 
reflection based {{@Plugin}} mechanism altogether.

What about overloading the add methods in {{ConfigurationBuilder}} to also take 
a programmaticly constructed Filter, Layout, Appender instances? You can then 
create ad-hoc Filters, Layouts, Appenders only for this purpose, and they 
should not need to have any annotations.

We can also create some Single Abstract Method abstract Filters, Layouts, 
Appenders for this purpuse to make it possible to use Java 8 lambdas 
conveniently.


> 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
(v6.3.4#6332)

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



[jira] [Commented] (LOG4J2-1531) Change attribute and component values from String to Object

2016-08-19 Thread Remko Popma (JIRA)

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

Remko Popma commented on LOG4J2-1531:
-

This may be a fairly painless change, and it would be great if it helps make 
the dynamic languages folks enthusiastic about Log4j 2.

> 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
(v6.3.4#6332)

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



[jira] [Commented] (LOG4J2-1531) Change attribute and component values from String to Object

2016-08-19 Thread Roger Kapsi (JIRA)

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

Roger Kapsi commented on LOG4J2-1531:
-

So Clojure itself is Java 6+ compatible. I'm happy to contribute a DSL if 
you're looking for a configuration method that isn't as static as Java and as 
not as "detached" as XML/JSON/YAML/Properties. The beauty of Clojure is that it 
compiles down to bytecode, you get the benefits of a Compiler as your input 
validation and it remains dynamic. 

I've been referring to Java 8+ and Java lambdas as I don't know how familiar 
you're with Clojure/Lisp. Java would be a little bit more static (even with 
lambdas) but there are simply things such as:

{code:java}
(logger, level, marker, msg) -> logger.getName().equals("org.apache.MyClass")
&& level.equals(Level.ERROR)
&& msg != null && msg.contains("Hello, World!");
{code}

That cannot be expressed very elegantly in XML/JSON/YAML/Propertie and even it 
was possible, Log4J2's API simply doesn't allow it right now because every 
configuration value is assumed to be a String.

This ticket is about opening the door for non-String configuration values that 
can be passed into {{@Plugin}} and {{@PluginFactory}} which enables rich 
programmatic configuration from Java, Clojure, Scala, Kotlin, Groovy. The 
emphasis is on programmatic configuration. There is no interest on my end in 
parsing and object mapping of Strings ala XML, JSON, YAML, Properties.

> 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
(v6.3.4#6332)

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



[jira] [Commented] (LOG4J2-1531) Change attribute and component values from String to Object

2016-08-19 Thread Gary Gregory (JIRA)

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

Gary Gregory commented on LOG4J2-1531:
--

Should we have a log4j-closure module that can depend on Java 8 and use lambdas?

> 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
(v6.3.4#6332)

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



[jira] [Commented] (LOG4J2-1531) Change attribute and component values from String to Object

2016-08-19 Thread Roger Kapsi (JIRA)

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

Roger Kapsi commented on LOG4J2-1531:
-

That doesn't quite cut it. Because Java 7 doesn't have lambda functions I had 
to fake it and keep it simple. Hence the one arg but somewhat useless function. 
I also don't want to narrow it down to just filters. That stuff is equally 
applicable to appenders, layout and everything else.

Here's one more try to explain it from the DSL's point of view.

{code}
(configuration
  (appender "out" "CONSOLE"
(layout "ClojureLayout"
(argument "fn" (fn [msg]
 (replace msg #"Hello, World!" "Hack the 
Planet!")
   
  (filter "ClojureFilter" "DENY" "NEUTRAL"
 (argument "fn" (fn [logger level marker msg & more] 
  (and (= (.getName logger) "org.apache.MyClass")
   (= level Level/ERROR)
   (and (not (nil? msg))
(.contains msg "Hello, World!")))
{code}

{code:java}
@Plugin(name = "ClojureFilter", category = Node.CATEGORY, elementType = 
Filter.ELEMENT_TYPE, printObject = true)
public final class ClojureFilter extends AbstractFilter {

  private static final Logger LOG = StatusLogger.getLogger();

  /**
   * Clojure's {@link IFn#invoke()} method takes up to 20 arguments without 
using {@code varargs}. That's great but 
   * requires us to do some extra work as seen in {@link 
#invoke(org.apache.logging.log4j.core.Logger, Level, Marker, String, Object...)}
   */
  private static final int MAX_INVOKE_ARGS = 20;
  
  /**
   * @see #MAX_INVOKE_ARGS
   */
  private static final int MIN_INVOKE_ARGS = 4;
  
  /**
   * @see #MAX_INVOKE_ARGS
   */
  private static final int MAX_PARAM_INVOKE_ARGS = MAX_INVOKE_ARGS - 
MIN_INVOKE_ARGS;
  
  @PluginFactory
  public static ClojureFilter createFilter(
  @PluginArgument("fn") IFn fn,
  @PluginAttribute("onMatch") Result match, 
  @PluginAttribute("onMismatch") Result mismatch) {

if (fn == null) {
  LOG.error("A fn must be provided for this ClojureFilter");
  return null;
}

if (!(fn instanceof IFn)) {
  LOG.error("The 'fn' attribute must be an IFn: " + fn + ", " + 
fn.getClass());
  return null;
}

return new ClojureFilter((IFn)fn, match, mismatch);
  }
  
  private final IFn fn;

  private ClojureFilter(IFn fn, Result match, Result mismatch) {
super(match, mismatch);

this.fn = fn;
  }
  
  private Result toResult(Object value) {
return value == null || !Boolean.TRUE.equals(value) ? onMismatch : onMatch;
  }
  
  @Override
  public Result filter(LogEvent event) {
Object value = fn.invoke(event);
return toResult(value);
  }

  @Override
  public Result filter(org.apache.logging.log4j.core.Logger logger, Level 
level, Marker marker, Message msg,
  Throwable t) {

Object value = fn.invoke(logger, level, marker, msg, t);
return toResult(value);
  }
  
  @Override
  public Result filter(org.apache.logging.log4j.core.Logger logger, Level 
level, Marker marker, Object msg,
  Throwable t) {

Object value = fn.invoke(logger, level, marker, msg, t);
return toResult(value);
  }
  
  @Override
  public Result filter(org.apache.logging.log4j.core.Logger logger, Level 
level, Marker marker, String msg, Object p0) {
Object value = fn.invoke(logger, level, marker, msg, p0);
return toResult(value);
  }

  @Override
  public Result filter(org.apache.logging.log4j.core.Logger logger, Level 
level, Marker marker, String msg, Object p0,
  Object p1) {
Object value = fn.invoke(logger, level, marker, msg, p0, p1);
return toResult(value);
  }

  @Override
  public Result filter(org.apache.logging.log4j.core.Logger logger, Level 
level, Marker marker, String msg, Object p0,
  Object p1, Object p2) {

Object value = fn.invoke(logger, level, marker, msg, p0, p1, p2);
return toResult(value);
  }

  @Override
  public Result filter(org.apache.logging.log4j.core.Logger logger, Level 
level, Marker marker, String msg, Object p0,
  Object p1, Object p2, Object p3) {

Object value = fn.invoke(logger, level, marker, msg, p0, p1, p2, p3);
return toResult(value);
  }

  @Override
  public Result filter(org.apache.logging.log4j.core.Logger logger, Level 
level, Marker marker, String msg, Object p0,
  Object p1, Object p2, Object p3, Object p4) {

Object value = fn.invoke(logger, level, marker, msg, p0, p1, p2, p3, p4);
return toResult(value);
  }
  
  @Override
  public Result filter(org.apache.logging.log4j.core.Logger logger, Level 
level, Marker marker, String msg, Object p0,
  Object p1, Object p2, Object p3, Object p4, Object p5) {
Object value = fn.invoke(logger, level, marke

[jira] [Commented] (LOG4J2-1531) Change attribute and component values from String to Object

2016-08-19 Thread JIRA

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

Mikael Ståldal commented on LOG4J2-1531:


I'm not sure it's wise to add {{addArgument(String, Object)}} to 
{{ComponentBuilder}}.

What about instead add something like this:

{{code}}
interface FilterFunction {
boolean apply(Object msg);
}

FilterComponentBuilder newFilter(FilterFunction fn, Filter.Result onMatch, 
Filter.Result onMisMatch);
{{code}}

Which would allow you to do this even more simple:

{{code}}
ConfigurationBuilder.FilterFunction fn = new 
ConfigurationBuilder.FilterFunction() {
@Override
public boolean apply(Object msg) {
return /* logic here */;
}
};

builder.add(builder.newFilter(fn, Filter.Result.DENY, 
Filter.Result.NEUTRAL));
{{code}}

> 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
(v6.3.4#6332)

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



[jira] [Commented] (LOG4J2-1531) Change attribute and component values from String to Object

2016-08-19 Thread Roger Kapsi (JIRA)

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

Roger Kapsi commented on LOG4J2-1531:
-

Please see attached patch. In particular the newly added 
{{ComponentArgumentTest}} which shows the use-case using plain Java.

> 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
(v6.3.4#6332)

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



[jira] [Commented] (LOG4J2-1531) Change attribute and component values from String to Object

2016-08-19 Thread Matt Sicker (JIRA)

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

Matt Sicker commented on LOG4J2-1531:
-

Same here, I'm interesting in how this will be integrated.

> 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
>
> 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
(v6.3.4#6332)

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



[jira] [Commented] (LOG4J2-1531) Change attribute and component values from String to Object

2016-08-19 Thread Ralph Goers (JIRA)

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

Ralph Goers commented on LOG4J2-1531:
-

Can you create a patch for this?  I'd prefer to look at the code before drawing 
conclusions.

> 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
>
> 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
(v6.3.4#6332)

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



[jira] [Commented] (LOG4J2-1531) Change attribute and component values from String to Object

2016-08-19 Thread Roger Kapsi (JIRA)

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

Roger Kapsi commented on LOG4J2-1531:
-

Correct but if you look above (the JavaFunctionFilter example) you could (and 
probably want if you're Java 8+) to be able to do that even from plain Java. My 
Clojure DSL example is actually using log4j2's own ConfigurationBuilder. 
Everything works out of the box except for being able to pass in non-String 
configuration values such as lambda functions. I'm happy to contribute that DSL 
btw. It's really trivial.

My current thought is to add a {{addArgument(String, Object}} method to 
{{ComponentBuilder}} and a new {{PluginArgument}} annotation (and Visitor). 
Thoughts?

> 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
>
> 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
(v6.3.4#6332)

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



[jira] [Commented] (LOG4J2-1531) Change attribute and component values from String to Object

2016-08-19 Thread Matt Sicker (JIRA)

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

Matt Sicker commented on LOG4J2-1531:
-

This sounds like something only relevant to the configuration builder DSL, 
right? Though it may require some support in the plugin builder system.

> 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
>
> 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
(v6.3.4#6332)

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



[jira] [Commented] (LOG4J2-1531) Change attribute and component values from String to Object

2016-08-19 Thread Roger Kapsi (JIRA)

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

Roger Kapsi commented on LOG4J2-1531:
-

Please see above example. I want to inject arbitrary "configuration objects" 
into PluginFactories such as a Java 8+ lambda function. This is for pure 
programmatic configuration (possibly with a Clojure DSL such as shown above or 
let's say Groovy as its possible in Logback) with no interest in being able to 
express/parse these things from Strings.

> 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
>
> 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
(v6.3.4#6332)

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



[jira] [Commented] (LOG4J2-1531) Change attribute and component values from String to Object

2016-08-19 Thread JIRA

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

Mikael Ståldal commented on LOG4J2-1531:


I am not sure it would be wise to make addAttribute take an arbitrary Object as 
value, I would like it to be a bit more type safe than that. But maybe add a 
few overloads that take some other relevant types in addition to String.

> 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
>
> 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
(v6.3.4#6332)

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



[jira] [Commented] (LOG4J2-1531) Change attribute and component values from String to Object

2016-08-19 Thread Matt Sicker (JIRA)

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

Matt Sicker commented on LOG4J2-1531:
-

Do you want plugin injection into attributes similar to how they're allowed as 
elements?

> 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
>
> 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
(v6.3.4#6332)

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



[jira] [Commented] (LOG4J2-1531) Change attribute and component values from String to Object

2016-08-19 Thread Roger Kapsi (JIRA)

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

Roger Kapsi commented on LOG4J2-1531:
-

Conceptually speaking...

{code:java}
Component#value to Object
Component#attributes to Map

Node#value to Object
Node#attributes to Map

DefaultComponentBuilder#addAttribute(String, k) to retain the object value of k 
instead of toString'ing it
{code}

And from there are few rabbit holes. That is probably an API breaking change. 
Instead of that maybe retain the existing "string view" of these objects and 
provide new accessors for the raw values. The PluginAttribute (and a few 
others) could have a new property that tells it to use the raw value instead of 
the toString() view.

Keep in mind this is only relevant for programmatic configuration. Instead of 
the Clojure DSL example maybe something like this:

{code:java}
@Plugin(name = "JavaFunctionFilter", category = Node.CATEGORY, elementType = 
Filter.ELEMENT_TYPE, printObject = true)
class JavaFunctionFilter extends AbstractFilter {
  @PluginFactory
  public static JavaFunctionFilter createFilter(
  @PluginAttribute("fn") Function fn, ...) {

 return new JavaFunctionFilter(fn, ...);
  }
}

ConfigurationBuilder builder 
= ConfigurationBuilderFactory.newConfigurationBuilder();
  
builder.add(builder.newFilter("JavaFunctionFilter", Filter.Result.DENY, 
Filter.Result.NEUTRAL)
  .addAttribute("fn", (event) -> 
event.getLoggerName().equals("org.apache.Foo")));
{code}

> 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
>
> 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
(v6.3.4#6332)

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



[jira] [Commented] (LOG4J2-1531) Change attribute and component values from String to Object

2016-08-19 Thread JIRA

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

Mikael Ståldal commented on LOG4J2-1531:


Can you clarify which method in which class you want to change?

> 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
>
> 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
(v6.3.4#6332)

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



[jira] [Commented] (LOG4J2-1531) Change attribute and component values from String to Object

2016-08-18 Thread Roger Kapsi (JIRA)

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

Roger Kapsi commented on LOG4J2-1531:
-

Certainly.

> 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
>
> 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
(v6.3.4#6332)

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



[jira] [Commented] (LOG4J2-1531) Change attribute and component values from String to Object

2016-08-18 Thread Remko Popma (JIRA)

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

Remko Popma commented on LOG4J2-1531:
-

Roger, would you mind providing a patch for this (ideally with unit tests)?

> 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
>
> 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
(v6.3.4#6332)

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