Bug report for Log4j [2014/01/26]

2014-01-25 Thread bugzilla
+---+ | Bugzilla Bug ID | | +-+ | | Status: UNC=Unconfirmed NEW=New ASS=Assigned

Re: Enums and Custom Levels

2014-01-25 Thread Scott Deboy
They can already do the same thing with loggers right? Scott On Jan 25, 2014 10:19 PM, "Ralph Goers" wrote: > A malicious app could do > > for (int i=0; i < 10; ++i) { > new Level(“Level” + i, 1000 + i){}; > } > > Sure idiots can do lots of bad things but I don’t think Levels should be > q

Re: Enums and Custom Levels

2014-01-25 Thread Ralph Goers
It was a lot harder when each custom extension was an enum implementing an interface. There was no way to do a new on it. Ralph > On Jan 25, 2014, at 10:33 PM, Remko Popma wrote: > > Hm... > Doesn't it become nearly impossible to protect against malicious intent, the > moment we make it exten

Re: Enums and Custom Levels

2014-01-25 Thread Remko Popma
Hm... Doesn't it become nearly impossible to protect against malicious intent, the moment we make it extensible? On Sunday, January 26, 2014, Ralph Goers wrote: > A malicious app could do > > for (int i=0; i < 10; ++i) { > new Level(“Level” + i, 1000 + i){}; > } > > Sure idiots can do lots

Re: Enums and Custom Levels

2014-01-25 Thread Ralph Goers
A malicious app could do for (int i=0; i < 10; ++i) { new Level(“Level” + i, 1000 + i){}; } Sure idiots can do lots of bad things but I don’t think Levels should be quite that flexible. Ralph On Jan 25, 2014, at 9:39 PM, Remko Popma wrote: > I don't think client code can do new Level(

Re: Enums and Custom Levels

2014-01-25 Thread Ralph Goers
I wanted to have my cake and eat it too. I want the standard levels to be part of an enumeration so I can use switch. The way the code was written I couldn’t do that. I’ve figured out another way. I have a StdLevel enum embedded in the Level class. Ralph On Jan 25, 2014, at 9:39 PM, Remko

Re: Enums and Custom Levels

2014-01-25 Thread Remko Popma
Apologies for thinking out loud and not being clear. Code generation can probably be made to work with either "real" enums or the extensible enums approach. The mechanism may differ but either should be possible. So from that point of view, no preference either way. Again apologies for the confusio

Re: Enums and Custom Levels

2014-01-25 Thread Remko Popma
*static Map in the extensible enum class On Sun, Jan 26, 2014 at 2:56 PM, Remko Popma wrote: > After thinking about it some more, the code generation could just access > the static Map in the extensible enums class and find out what instances > are registered. That would work but assumes that t

Re: Enums and Custom Levels

2014-01-25 Thread Remko Popma
After thinking about it some more, the code generation could just access the static Map in the extensible enums class and find out what instances are registered. That would work but assumes that the configuration (or at least the initialization of the static Map in Levels) is complete before code g

Re: Enums and Custom Levels

2014-01-25 Thread Remko Popma
Did you mean that a custom Level implementation cannot extend StdLevel? So a custom Level implementation would need to include the levels defined in StdLevel (DEBUG, INFO, ...) in addition to the custom levels. I think I see now. How much of a problem is this though? Or, do we need to start thinki

Re: Enums and Custom Levels

2014-01-25 Thread Remko Popma
I don't think client code can do new Level(){} as the constructor requires String and int arguments. By the way, I am unclear on what went wrong with the enum approach you originally took. You said: StdLevel isn’t a Level because it can’t extend it if it is an enum, so I can’t initialize the l

Re: Enums and Custom Levels

2014-01-25 Thread Ralph Goers
Out of curiosity, what exactly is the benefit of declaring the class abstract when it has a protected constructor? It seems like all you are accomplishing is making the instantiation syntax uglier. It also bothers me that open code can just do a new Level(){} - which will do nothing but cause p

Re: Enums and Custom Levels

2014-01-25 Thread Ralph Goers
Yeah, I missed the {} as I modified the class before I tried to compile it. You can’t just use an AtomicInteger because you might be adding a duplicate to the map, in which case you have incorrectly incremented the ordinal. I used simple synchronization. Unfortunately, because the extended lev

Re: Enums and Custom Levels

2014-01-25 Thread Remko Popma
Ralph, I copied Nick's code _as is_ and had no compile errors. The class is abstract, but instances are defined in the static block as: OFF = new Level("OFF", 0) {}; // note the {}: this creates an anonymous concrete subclass I agree that read access needs to be synchronized as well, not just writ

Re: Enums and Custom Levels

2014-01-25 Thread Nicholas Williams
Ralph, if you're getting compile errors with that code, A) there's a copy-paste/transposition error, or B) there's something wrong with your (non-standard?) compiler. Given: abstract class A { ... } This is perfectly legal in Java 5+: A a = new A() { }; That's an anonymous inner class extendi

Re: Enums and Custom Levels

2014-01-25 Thread Ralph Goers
That was what I was originally thinking. I suspect that what the result of what we are thinking would be to just be able to dynamically generate the wrapper based on the custom Level(s). Ralph On Jan 25, 2014, at 8:43 PM, Gary Gregory wrote: > My idea was _not_ to add byte codes to the Logger

Re: Enums and Custom Levels

2014-01-25 Thread Ralph Goers
As I am working on this I just want to point out a number of issues with the code below: 1. The class is abstract. The static block is doing a bunch of new Level() invocations which obviously generate compile errors on an abstract class. I had to make it be a non-abstract class. 2. As I pointe

Re: Enums and Custom Levels

2014-01-25 Thread Gary Gregory
My idea was _not_ to add byte codes to the Logger interface, it was to add code to a user's class that wraps a logger.  G Original message From: Remko Popma Date:01/25/2014 21:51 (GMT-05:00) To: Log4J Developers List Subject: Re: Enums and Custom Levels I've started to

Re: Enums and Custom Levels

2014-01-25 Thread Ralph Goers
Yeah, I took another 5 minutes and thought about it. A proxy isn’t the full answer as somehow we need to create the method signatures for compile time. I’ve done that before from database data to generate an interface but this is a little different. Ralph On Jan 25, 2014, at 7:07 PM, Remko Po

Re: Enums and Custom Levels

2014-01-25 Thread Remko Popma
I mean, not sure whether to use Proxy or generate code or something else, but hopefully get really close to the ease-of-use of the current Logger interface... On Sun, Jan 26, 2014 at 12:06 PM, Remko Popma wrote: > I'm not sure how close we can get to what we have now, but yes, that was > what I

Re: Enums and Custom Levels

2014-01-25 Thread Remko Popma
I'm not sure how close we can get to what we have now, but yes, that was what I had in mind... On Sun, Jan 26, 2014 at 12:00 PM, Ralph Goers wrote: > Wow - I had never thought about using a Java Proxy to implement all those > methods before. That would be a piece of cake. > > Ralph > > On Jan 2

[jira] [Commented] (LOG4J2-513) Use more OSGi-friendly class loading mechanisms.

2014-01-25 Thread Remko Popma (JIRA)
[ https://issues.apache.org/jira/browse/LOG4J2-513?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13882158#comment-13882158 ] Remko Popma commented on LOG4J2-513: That would be great! Just speaking for myself, I

Re: Enums and Custom Levels

2014-01-25 Thread Ralph Goers
Wow - I had never thought about using a Java Proxy to implement all those methods before. That would be a piece of cake. Ralph On Jan 25, 2014, at 6:51 PM, Remko Popma wrote: > I've started to think about how to implement Gary's idea to use these custom > levels to generate code that would a

Re: Enums and Custom Levels

2014-01-25 Thread Scott Deboy
Great! That plus support for defining custom levels from the config (with no custom class required) would mean we would have found a solution that I believe resolves everyone's issues. Scott On Jan 25, 2014 6:52 PM, "Remko Popma" wrote: > I've started to think about how to implement Gary's idea

Re: Enums and Custom Levels

2014-01-25 Thread Remko Popma
I've started to think about how to implement Gary's idea to use these custom levels to generate code that would add methods to the Logger interface, but I think I'll wait a little to see what form the custom levels take. On Sun, Jan 26, 2014 at 11:45 AM, Remko Popma wrote: > These are the switc

Re: Enums and Custom Levels

2014-01-25 Thread Remko Popma
These are the switches I found: * log4j-1.2-api: org.apache.log4j.Category - just FYI, it looks like this switch is missing the FATAL level... is this a bug? * log4j-api: org.apache.logging.log4j.status.StatusLogger * log4j-core: org.apache.logging.log4j.core.net.Severity * log4j-core: org.apache.l

Re: Enums and Custom Levels

2014-01-25 Thread Ralph Goers
I am not sure what you mean by this. I have already succeeded in adding custom level names to the configuration and making them be valid. I am just trying to clean it up a bit based on what Nick is suggesting. Ralph On Jan 25, 2014, at 6:30 PM, Scott Deboy wrote: > There's no way to add sup

Re: Enums and Custom Levels

2014-01-25 Thread Ralph Goers
Actually, we can use switch in all the places it is currently being used. They are all places where we are converting between our levels to a Level or Severity from some other framework. I handled that by first mapping custom levels to the closest standard level and then using the switch state

Re: Enums and Custom Levels

2014-01-25 Thread Scott Deboy
There's no way to add support for users to define level entries (name and value pairs as a new element in the config) and have us do the work to make those valid? That would get get rid of my request for additional levels, right? On Jan 25, 2014 6:15 PM, "Ralph Goers" wrote: > The class is needed

Re: Enums and Custom Levels

2014-01-25 Thread Paul Benedict
You can't "switch" anymore because custom levels means you're dealing with an unknown quantity of levels. You'll have to look them up in a registry/map. That's the trade off of an extensible system. On Jan 25, 2014 8:13 PM, "Ralph Goers" wrote: > Rats. StdLevel isn’t a Level because it can’t ext

Re: Enums and Custom Levels

2014-01-25 Thread Ralph Goers
The class is needed because it is a name and a value (two items) that has to be represented as a single parameter to Logger methods. Using raw int or String is not a good alternative. Ralph On Jan 25, 2014, at 4:54 PM, Scott Deboy wrote: > If levels are just a name and a value why require a

Re: Enums and Custom Levels

2014-01-25 Thread Ralph Goers
Rats. StdLevel isn’t a Level because it can’t extend it if it is an enum, so I can’t initialize the levels using that. So no switch statements if we go this way. I’ll keep looking at it but that makes this solution less appealing to me. Ralph On Jan 25, 2014, at 6:05 PM, Ralph Goers wrote:

Re: Enums and Custom Levels

2014-01-25 Thread Ralph Goers
Sure, I can take a look at doing it that way. But it is going to have many of the same problems to implement as to what I just finished doing - except that I won’t need the Levels class or Levels interface. The one downside to this approach is that there are 4 or 5 places where Level is used in

Re: Enums and Custom Levels

2014-01-25 Thread Paul Benedict
Nick, I think because your solution is considered "old style" enums. I don't know anyone making those kind of enums anymore since JDK 1.5 gave us an official "enum" keyword. Using that and interfaces is preferred, I think. On Sat, Jan 25, 2014 at 7:32 PM, Nicholas Williams < nicho...@nicholaswill

[jira] [Created] (LOG4J2-513) Use more OSGi-friendly class loading mechanisms.

2014-01-25 Thread Matt Sicker (JIRA)
Matt Sicker created LOG4J2-513: -- Summary: Use more OSGi-friendly class loading mechanisms. Key: LOG4J2-513 URL: https://issues.apache.org/jira/browse/LOG4J2-513 Project: Log4j 2 Issue Type: Sub-

Re: Enums and Custom Levels

2014-01-25 Thread Nicholas Williams
I actually do object I think. It sounds like a significantly more convoluted approach than the extensible enum. With the extensible enum, new levels are immediately discovered, serialization works automatically, and extenders don't have to do any extra work in the constructor. Why are we making

[jira] [Commented] (LOG4J2-373) Classloader issue in OSGi-environment

2014-01-25 Thread Matt Sicker (JIRA)
[ https://issues.apache.org/jira/browse/LOG4J2-373?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13882132#comment-13882132 ] Matt Sicker commented on LOG4J2-373: Shouldn't you be loading core as a bundle too? >

Re: Enums and Custom Levels

2014-01-25 Thread Paul Benedict
In any event, I'd like to thank the entire Log4J Developer community here for hearing out my interface idea without biting my head off -- after all, it's a "big" change near a GA release :-) It was also nice knowing there exists a place where a serious technical debate can remain cordial. Kudos. An

[jira] [Updated] (LOG4J2-346) Cyclic dependency in OSGi-context. Apache Log4j SLF4J Binding <-> slf4j-api

2014-01-25 Thread Matt Sicker (JIRA)
[ https://issues.apache.org/jira/browse/LOG4J2-346?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Matt Sicker updated LOG4J2-346: --- Attachment: 0001-Add-SLF4J-related-bundles.patch Here's a better patch. I've added two submodules to

Re: Enums and Custom Levels

2014-01-25 Thread Scott Deboy
If levels are just a name and a value why require a class at all? What about just having it defined in the configuration. On Jan 25, 2014 4:37 PM, "Ralph Goers" wrote: > Because we don't know the class name that the Level belongs to. It is > referenced in the configuration just as "DIAG", not >

Re: Enums and Custom Levels

2014-01-25 Thread Ralph Goers
Because we don’t know the class name that the Level belongs to. It is referenced in the configuration just as “DIAG”, not “org.apache.logging.test.ExtendedLevel.DIAG”. In any case I fixed it. I just annotated the new Level as a Plugin and then look up all the Level plugins in BaseConfiguratio

Re: Enums and Custom Levels

2014-01-25 Thread Remko Popma
Would it be an option to require that the custom level class package is mentioned in the Configuration packages="..." attribute? On Sun, Jan 26, 2014 at 9:26 AM, Paul Benedict wrote: > If you made it a requirement for the constructor to register, why not just > instantiate each level as you enc

Re: Enums and Custom Levels

2014-01-25 Thread Paul Benedict
If you made it a requirement for the constructor to register, why not just instantiate each level as you encounter it in the config? On Sat, Jan 25, 2014 at 6:06 PM, Ralph Goers wrote: > Hmm. It seems I am going to have to do something to force the registration > as the custom level class hasn’t

Re: Enums and Custom Levels

2014-01-25 Thread Ralph Goers
Hmm. It seems I am going to have to do something to force the registration as the custom level class hasn’t been constructed before the levels are referenced in the configuration. Ralph On Jan 25, 2014, at 3:43 PM, Ralph Goers wrote: > In the constructor each of them calls Levels.addLevel(t

Re: Enums and Custom Levels

2014-01-25 Thread Ralph Goers
In the constructor each of them calls Levels.addLevel(this). Ralph On Jan 25, 2014, at 2:21 PM, Remko Popma wrote: > Interesting! So, users would add custom levels by creating a new enum that > implements the Level interface? How does the new enum get registered? In > config or in code? > >

Re: Enums and Custom Levels

2014-01-25 Thread Remko Popma
Interesting! So, users would add custom levels by creating a new enum that implements the Level interface? How does the new enum get registered? In config or in code? Just trying to understand how it works... (With Nick's class I understood how that would work: users would extend the Level class

Re: Enums and Custom Levels

2014-01-25 Thread Matt Sicker
That sounds like a pretty good idea. Matt Sicker > On Jan 25, 2014, at 15:18, Ralph Goers wrote: > > Here is what I am implementing: > > 1. Level is now an Interface. This allows the vast amount of code to > continue to work. > 2. The current Level enum has been renamed to StdLevel. It impl

Re: Enums and Custom Levels

2014-01-25 Thread Ralph Goers
Here is what I am implementing: 1. Level is now an Interface. This allows the vast amount of code to continue to work. 2. The current Level enum has been renamed to StdLevel. It implements the Level interface. 3. A new class named Levels is in the spi package of the API. It contains a Concurr

Re: Enums and Custom Levels

2014-01-25 Thread Nicholas Williams
No, of course, everyone seems to agree that custom levels should be permitted. But I never heard agreement on whether we were going the extensible enum route or the Level-as-interface route. The camp still seemed to disagree on that. Nick Sent from my iPhone, so please forgive brief replies and

ApacheCon CFP

2014-01-25 Thread Christian Grobmeier
Hi folks, I would like to remind you ApacheCon is happening in April 2014. If you would like to submit your talk, now is the chance. I think it would be great to have somebody presenting our Logging frameworks. I will not be there unfortunately. Regards, Christian --- http://www.grobmeier.de Th

Re: Enums and Custom Levels

2014-01-25 Thread Ralph Goers
I have not heard anyone disagree with allowing custom Levels. The disagreement I am hearing is over adding new pre-defined levels. Ralph On Jan 25, 2014, at 7:29 AM, Nick Williams wrote: > I may have missed something. Did we decide on an approach? Last I heard, the > camp was still split: S

Re: Enums and Custom Levels

2014-01-25 Thread Nick Williams
I may have missed something. Did we decide on an approach? Last I heard, the camp was still split: Some wanted to go with my extensible enum, others wanted to change Level to an interface and make a Levels enum. So I'm a bit confused. Which implementation are you working on? Nick On Jan 25, 20

Re: Enums and Custom Levels

2014-01-25 Thread Ralph Goers
I am working on the implementation of custom levels now. I should have it done today. Ralph On Jan 24, 2014, at 7:07 PM, Remko Popma wrote: > What is the best way to make progress on the custom levels implementation? > > Do we re-open LOG4J-41 or start a fresh Jira ticket? For implementation

[jira] [Created] (LOG4J2-512) Log4j2 need to support Asynchronous Servlets/ Servlet 3.0 while automatically starting, and configurable to initialize and de-initialize loggers from the code

2014-01-25 Thread Chandra Sekhar Kakarla (JIRA)
Chandra Sekhar Kakarla created LOG4J2-512: - Summary: Log4j2 need to support Asynchronous Servlets/ Servlet 3.0 while automatically starting, and configurable to initialize and de-initialize loggers from the code Key: LO

Re: Levels added in revision 1560602

2014-01-25 Thread Gary Gregory
On Sat, Jan 25, 2014 at 5:10 AM, Christian Grobmeier wrote: > Thanks a lot Gary for the great response. Now I understand you better. Thank you Christian. I created the branch https://svn.apache.org/repos/asf/logging/log4j/log4j2/branches/new-levelsfor those who want to a have easy look. Gary

[jira] [Commented] (LOG4J2-316) Logo Contest Submissions

2014-01-25 Thread Gary Gregory (JIRA)
[ https://issues.apache.org/jira/browse/LOG4J2-316?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13881854#comment-13881854 ] Gary Gregory commented on LOG4J2-316: - Imo if there is any text it should only be "Log

[jira] [Comment Edited] (LOG4J2-316) Logo Contest Submissions

2014-01-25 Thread Alireza Fattahi (JIRA)
[ https://issues.apache.org/jira/browse/LOG4J2-316?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13881743#comment-13881743 ] Alireza Fattahi edited comment on LOG4J2-316 at 1/25/14 10:11 AM: --

Re: Levels added in revision 1560602

2014-01-25 Thread Christian Grobmeier
Thanks a lot Gary for the great response. Now I understand you better. On 25 Jan 2014, at 2:00, Ralph Goers wrote: I have the same problem with your use of NOTICE as I did with CONFIG. If I want to see startup and shutdown log events I MUST also get warning messages, which isn’t necessarily wh