Discussion:
[jira] [Created] (LOG4J2-547) Update LoggerStream API
Matt Sicker (JIRA)
2014-02-22 20:02:19 UTC
Permalink
Matt Sicker created LOG4J2-547:
----------------------------------

Summary: Update LoggerStream API
Key: LOG4J2-547
URL: https://issues.apache.org/jira/browse/LOG4J2-547
Project: Log4j 2
Issue Type: Improvement
Components: API
Affects Versions: 2.0-rc1
Reporter: Matt Sicker
Fix For: 2.0


I've got some ideas on how to improve the LoggerStream idea that I added a little while ago. The main thing I'd like to do is extract an interface from it, rename the default implementation to SimpleLoggerStream (part of the SimpleLogger stuff), and allow log4j implementations to specify a different implementation if desired.

In doing this, I'm not sure where specifically I'd prefer the getStream methods to be. Right now, it's in Logger, but really, it could be in LoggerContext instead. I don't think I should be required to get a Logger just to get a LoggerStream.

Now if only the java.io package used interfaces instead of classes. This would be so much easier to design!



--
This message was sent by Atlassian JIRA
(v6.1.5#6160)
Matt Sicker (JIRA)
2014-02-23 07:56:19 UTC
Permalink
[ https://issues.apache.org/jira/browse/LOG4J2-547?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Matt Sicker updated LOG4J2-547:
-------------------------------

Attachment: 0001-PrintStream-API-update.patch

Here's what I had in mind.
Post by Matt Sicker (JIRA)
Update LoggerStream API
-----------------------
Key: LOG4J2-547
URL: https://issues.apache.org/jira/browse/LOG4J2-547
Project: Log4j 2
Issue Type: Improvement
Components: API
Affects Versions: 2.0-rc1
Reporter: Matt Sicker
Fix For: 2.0
Attachments: 0001-PrintStream-API-update.patch
I've got some ideas on how to improve the LoggerStream idea that I added a little while ago. The main thing I'd like to do is extract an interface from it, rename the default implementation to SimpleLoggerStream (part of the SimpleLogger stuff), and allow log4j implementations to specify a different implementation if desired.
In doing this, I'm not sure where specifically I'd prefer the getStream methods to be. Right now, it's in Logger, but really, it could be in LoggerContext instead. I don't think I should be required to get a Logger just to get a LoggerStream.
Now if only the java.io package used interfaces instead of classes. This would be so much easier to design!
--
This message was sent by Atlassian JIRA
(v6.1.5#6160)
Ralph Goers (JIRA)
2014-03-01 00:18:19 UTC
Permalink
[ https://issues.apache.org/jira/browse/LOG4J2-547?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13916619#comment-13916619 ]

Ralph Goers commented on LOG4J2-547:
------------------------------------

After looking at the patch it makes me wonder if we shouldn't just remove the LoggerStream stuff entirely. At first glance it seems odd and complicated to have the LoggerStream move into the LoggerContext. After thinking about it I understand why this is a better approach, but I'm still wondering if there is any real benefit to supporting LoggerStream vs the cost of maintaining it.
Post by Matt Sicker (JIRA)
Update LoggerStream API
-----------------------
Key: LOG4J2-547
URL: https://issues.apache.org/jira/browse/LOG4J2-547
Project: Log4j 2
Issue Type: Improvement
Components: API
Affects Versions: 2.0-rc1
Reporter: Matt Sicker
Fix For: 2.0
Attachments: 0001-PrintStream-API-update.patch
I've got some ideas on how to improve the LoggerStream idea that I added a little while ago. The main thing I'd like to do is extract an interface from it, rename the default implementation to SimpleLoggerStream (part of the SimpleLogger stuff), and allow log4j implementations to specify a different implementation if desired.
In doing this, I'm not sure where specifically I'd prefer the getStream methods to be. Right now, it's in Logger, but really, it could be in LoggerContext instead. I don't think I should be required to get a Logger just to get a LoggerStream.
Now if only the java.io package used interfaces instead of classes. This would be so much easier to design!
--
This message was sent by Atlassian JIRA
(v6.1.5#6160)
Bruce Brouwer (JIRA)
2014-03-01 19:02:19 UTC
Permalink
[ https://issues.apache.org/jira/browse/LOG4J2-547?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13917159#comment-13917159 ]

Bruce Brouwer commented on LOG4J2-547:
--------------------------------------

In looking at LoggerStream, I can see how it could help me when shelling out to commands when all I want to do is log the output of that shelled command. There is some non-trivial stuff that LoggerStream is doing, so I don't want to get rid of that concept.

But I agree that as it stands, the most helpful part of LoggerStream is actually the HelperStream. I'm including a patch that gets rid of LoggerStream and instead returns a plain old PrintWriter. This involved making a LoggerWriter which does basically what HelperStream did before.

I don't see a whole lot of value adding this to the LoggerContext. In the end it needs an AbstractLogger anyway, so why not get it from the AbstractLogger.
Post by Matt Sicker (JIRA)
Update LoggerStream API
-----------------------
Key: LOG4J2-547
URL: https://issues.apache.org/jira/browse/LOG4J2-547
Project: Log4j 2
Issue Type: Improvement
Components: API
Affects Versions: 2.0-rc1
Reporter: Matt Sicker
Fix For: 2.0
Attachments: 0001-PrintStream-API-update.patch, log4j2-loggerStream.patch
I've got some ideas on how to improve the LoggerStream idea that I added a little while ago. The main thing I'd like to do is extract an interface from it, rename the default implementation to SimpleLoggerStream (part of the SimpleLogger stuff), and allow log4j implementations to specify a different implementation if desired.
In doing this, I'm not sure where specifically I'd prefer the getStream methods to be. Right now, it's in Logger, but really, it could be in LoggerContext instead. I don't think I should be required to get a Logger just to get a LoggerStream.
Now if only the java.io package used interfaces instead of classes. This would be so much easier to design!
--
This message was sent by Atlassian JIRA
(v6.1.5#6160)
Bruce Brouwer (JIRA)
2014-03-01 19:02:19 UTC
Permalink
[ https://issues.apache.org/jira/browse/LOG4J2-547?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Bruce Brouwer updated LOG4J2-547:
---------------------------------

Attachment: log4j2-loggerStream.patch
Post by Matt Sicker (JIRA)
Update LoggerStream API
-----------------------
Key: LOG4J2-547
URL: https://issues.apache.org/jira/browse/LOG4J2-547
Project: Log4j 2
Issue Type: Improvement
Components: API
Affects Versions: 2.0-rc1
Reporter: Matt Sicker
Fix For: 2.0
Attachments: 0001-PrintStream-API-update.patch, log4j2-loggerStream.patch
I've got some ideas on how to improve the LoggerStream idea that I added a little while ago. The main thing I'd like to do is extract an interface from it, rename the default implementation to SimpleLoggerStream (part of the SimpleLogger stuff), and allow log4j implementations to specify a different implementation if desired.
In doing this, I'm not sure where specifically I'd prefer the getStream methods to be. Right now, it's in Logger, but really, it could be in LoggerContext instead. I don't think I should be required to get a Logger just to get a LoggerStream.
Now if only the java.io package used interfaces instead of classes. This would be so much easier to design!
--
This message was sent by Atlassian JIRA
(v6.1.5#6160)
Bruce Brouwer (JIRA)
2014-03-01 19:04:23 UTC
Permalink
[ https://issues.apache.org/jira/browse/LOG4J2-547?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13917159#comment-13917159 ]

Bruce Brouwer edited comment on LOG4J2-547 at 3/1/14 7:04 PM:
--------------------------------------------------------------

In looking at LoggerStream, I can see how it could help me when shelling out to commands when all I want to do is log the output of that shelled command. There is some non-trivial stuff that LoggerStream is doing, so I don't want to get rid of that concept.

But I agree that as it stands, the most helpful part of LoggerStream is actually the HelperStream. I'm including a patch that gets rid of LoggerStream and instead returns a plain old PrintWriter. This involved making a LoggerWriter which does basically what HelperStream did before.

I don't see a whole lot of value adding this to the LoggerContext. In the end it needs an AbstractLogger anyway, so why not get it from the AbstractLogger.

Oh, and I called the method .printWriter(...) instead of .getStream(...). First, the old .getStream didn't even return an OutputStream, it returned something that extended PrintWriter. And also, by removing the .get part, users might not expect to get the exact same PrintWriter instance each time they call it. In this case, I don't think I would want to get the same instance each time.


was (Author: bruce.brouwer):
In looking at LoggerStream, I can see how it could help me when shelling out to commands when all I want to do is log the output of that shelled command. There is some non-trivial stuff that LoggerStream is doing, so I don't want to get rid of that concept.

But I agree that as it stands, the most helpful part of LoggerStream is actually the HelperStream. I'm including a patch that gets rid of LoggerStream and instead returns a plain old PrintWriter. This involved making a LoggerWriter which does basically what HelperStream did before.

I don't see a whole lot of value adding this to the LoggerContext. In the end it needs an AbstractLogger anyway, so why not get it from the AbstractLogger.
Post by Matt Sicker (JIRA)
Update LoggerStream API
-----------------------
Key: LOG4J2-547
URL: https://issues.apache.org/jira/browse/LOG4J2-547
Project: Log4j 2
Issue Type: Improvement
Components: API
Affects Versions: 2.0-rc1
Reporter: Matt Sicker
Fix For: 2.0
Attachments: 0001-PrintStream-API-update.patch, log4j2-loggerStream.patch
I've got some ideas on how to improve the LoggerStream idea that I added a little while ago. The main thing I'd like to do is extract an interface from it, rename the default implementation to SimpleLoggerStream (part of the SimpleLogger stuff), and allow log4j implementations to specify a different implementation if desired.
In doing this, I'm not sure where specifically I'd prefer the getStream methods to be. Right now, it's in Logger, but really, it could be in LoggerContext instead. I don't think I should be required to get a Logger just to get a LoggerStream.
Now if only the java.io package used interfaces instead of classes. This would be so much easier to design!
--
This message was sent by Atlassian JIRA
(v6.1.5#6160)
Ralph Goers (JIRA)
2014-03-01 19:21:19 UTC
Permalink
[ https://issues.apache.org/jira/browse/LOG4J2-547?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13917166#comment-13917166 ]

Ralph Goers commented on LOG4J2-547:
------------------------------------

I'm going to look at it a bit more after I apply the patch, but at first glance I like this patch a lot more.
Post by Matt Sicker (JIRA)
Update LoggerStream API
-----------------------
Key: LOG4J2-547
URL: https://issues.apache.org/jira/browse/LOG4J2-547
Project: Log4j 2
Issue Type: Improvement
Components: API
Affects Versions: 2.0-rc1
Reporter: Matt Sicker
Fix For: 2.0
Attachments: 0001-PrintStream-API-update.patch, log4j2-loggerStream.patch
I've got some ideas on how to improve the LoggerStream idea that I added a little while ago. The main thing I'd like to do is extract an interface from it, rename the default implementation to SimpleLoggerStream (part of the SimpleLogger stuff), and allow log4j implementations to specify a different implementation if desired.
In doing this, I'm not sure where specifically I'd prefer the getStream methods to be. Right now, it's in Logger, but really, it could be in LoggerContext instead. I don't think I should be required to get a Logger just to get a LoggerStream.
Now if only the java.io package used interfaces instead of classes. This would be so much easier to design!
--
This message was sent by Atlassian JIRA
(v6.1.5#6160)
Ralph Goers (JIRA)
2014-03-01 19:21:20 UTC
Permalink
[ https://issues.apache.org/jira/browse/LOG4J2-547?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Ralph Goers reassigned LOG4J2-547:
----------------------------------

Assignee: Ralph Goers
Post by Matt Sicker (JIRA)
Update LoggerStream API
-----------------------
Key: LOG4J2-547
URL: https://issues.apache.org/jira/browse/LOG4J2-547
Project: Log4j 2
Issue Type: Improvement
Components: API
Affects Versions: 2.0-rc1
Reporter: Matt Sicker
Assignee: Ralph Goers
Fix For: 2.0
Attachments: 0001-PrintStream-API-update.patch, log4j2-loggerStream.patch
I've got some ideas on how to improve the LoggerStream idea that I added a little while ago. The main thing I'd like to do is extract an interface from it, rename the default implementation to SimpleLoggerStream (part of the SimpleLogger stuff), and allow log4j implementations to specify a different implementation if desired.
In doing this, I'm not sure where specifically I'd prefer the getStream methods to be. Right now, it's in Logger, but really, it could be in LoggerContext instead. I don't think I should be required to get a Logger just to get a LoggerStream.
Now if only the java.io package used interfaces instead of classes. This would be so much easier to design!
--
This message was sent by Atlassian JIRA
(v6.1.5#6160)
Matt Sicker (JIRA)
2014-03-01 19:23:20 UTC
Permalink
[ https://issues.apache.org/jira/browse/LOG4J2-547?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13917167#comment-13917167 ]

Matt Sicker commented on LOG4J2-547:
------------------------------------

I like this print writer patch better, too. The only reason my patch started getting complicated was due to the call stack getting weird if you didn't make a decorate class for PrintStream or similar. Then it became next to impossible to figure out the calling class to construct it properly.
Post by Matt Sicker (JIRA)
Update LoggerStream API
-----------------------
Key: LOG4J2-547
URL: https://issues.apache.org/jira/browse/LOG4J2-547
Project: Log4j 2
Issue Type: Improvement
Components: API
Affects Versions: 2.0-rc1
Reporter: Matt Sicker
Assignee: Ralph Goers
Fix For: 2.0
Attachments: 0001-PrintStream-API-update.patch, log4j2-loggerStream.patch
I've got some ideas on how to improve the LoggerStream idea that I added a little while ago. The main thing I'd like to do is extract an interface from it, rename the default implementation to SimpleLoggerStream (part of the SimpleLogger stuff), and allow log4j implementations to specify a different implementation if desired.
In doing this, I'm not sure where specifically I'd prefer the getStream methods to be. Right now, it's in Logger, but really, it could be in LoggerContext instead. I don't think I should be required to get a Logger just to get a LoggerStream.
Now if only the java.io package used interfaces instead of classes. This would be so much easier to design!
--
This message was sent by Atlassian JIRA
(v6.1.5#6160)
Ralph Goers (JIRA)
2014-03-01 19:48:19 UTC
Permalink
[ https://issues.apache.org/jira/browse/LOG4J2-547?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Ralph Goers resolved LOG4J2-547.
--------------------------------

Resolution: Fixed

Bruce's patch was applied in revision 1573212. Please verify that this addresses the problem and works and then close.
Post by Matt Sicker (JIRA)
Update LoggerStream API
-----------------------
Key: LOG4J2-547
URL: https://issues.apache.org/jira/browse/LOG4J2-547
Project: Log4j 2
Issue Type: Improvement
Components: API
Affects Versions: 2.0-rc1
Reporter: Matt Sicker
Assignee: Ralph Goers
Fix For: 2.0
Attachments: 0001-PrintStream-API-update.patch, log4j2-loggerStream.patch
I've got some ideas on how to improve the LoggerStream idea that I added a little while ago. The main thing I'd like to do is extract an interface from it, rename the default implementation to SimpleLoggerStream (part of the SimpleLogger stuff), and allow log4j implementations to specify a different implementation if desired.
In doing this, I'm not sure where specifically I'd prefer the getStream methods to be. Right now, it's in Logger, but really, it could be in LoggerContext instead. I don't think I should be required to get a Logger just to get a LoggerStream.
Now if only the java.io package used interfaces instead of classes. This would be so much easier to design!
--
This message was sent by Atlassian JIRA
(v6.1.5#6160)
Bruce Brouwer (JIRA)
2014-03-01 20:12:19 UTC
Permalink
[ https://issues.apache.org/jira/browse/LOG4J2-547?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13917180#comment-13917180 ]

Bruce Brouwer commented on LOG4J2-547:
--------------------------------------

One thing I noticed I missed. We might want to synchronize on buf in the close() method.
Post by Matt Sicker (JIRA)
Update LoggerStream API
-----------------------
Key: LOG4J2-547
URL: https://issues.apache.org/jira/browse/LOG4J2-547
Project: Log4j 2
Issue Type: Improvement
Components: API
Affects Versions: 2.0-rc1
Reporter: Matt Sicker
Assignee: Ralph Goers
Fix For: 2.0
Attachments: 0001-PrintStream-API-update.patch, log4j2-loggerStream.patch
I've got some ideas on how to improve the LoggerStream idea that I added a little while ago. The main thing I'd like to do is extract an interface from it, rename the default implementation to SimpleLoggerStream (part of the SimpleLogger stuff), and allow log4j implementations to specify a different implementation if desired.
In doing this, I'm not sure where specifically I'd prefer the getStream methods to be. Right now, it's in Logger, but really, it could be in LoggerContext instead. I don't think I should be required to get a Logger just to get a LoggerStream.
Now if only the java.io package used interfaces instead of classes. This would be so much easier to design!
--
This message was sent by Atlassian JIRA
(v6.1.5#6160)
Bruce Brouwer (JIRA)
2014-03-01 20:33:19 UTC
Permalink
[ https://issues.apache.org/jira/browse/LOG4J2-547?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13917184#comment-13917184 ]

Bruce Brouwer commented on LOG4J2-547:
--------------------------------------

Also, you should be able to delete LoggerStream and LoggerStreamTest
Post by Matt Sicker (JIRA)
Update LoggerStream API
-----------------------
Key: LOG4J2-547
URL: https://issues.apache.org/jira/browse/LOG4J2-547
Project: Log4j 2
Issue Type: Improvement
Components: API
Affects Versions: 2.0-rc1
Reporter: Matt Sicker
Assignee: Ralph Goers
Fix For: 2.0
Attachments: 0001-PrintStream-API-update.patch, log4j2-loggerStream.patch
I've got some ideas on how to improve the LoggerStream idea that I added a little while ago. The main thing I'd like to do is extract an interface from it, rename the default implementation to SimpleLoggerStream (part of the SimpleLogger stuff), and allow log4j implementations to specify a different implementation if desired.
In doing this, I'm not sure where specifically I'd prefer the getStream methods to be. Right now, it's in Logger, but really, it could be in LoggerContext instead. I don't think I should be required to get a Logger just to get a LoggerStream.
Now if only the java.io package used interfaces instead of classes. This would be so much easier to design!
--
This message was sent by Atlassian JIRA
(v6.1.5#6160)
Matt Sicker (JIRA)
2014-03-02 00:45:19 UTC
Permalink
[ https://issues.apache.org/jira/browse/LOG4J2-547?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13917245#comment-13917245 ]

Matt Sicker commented on LOG4J2-547:
------------------------------------

Just as I suspected. By not decorating PrintWriter, now the calling information says that {{java.io.Writer}} is the calling class.
Post by Matt Sicker (JIRA)
Update LoggerStream API
-----------------------
Key: LOG4J2-547
URL: https://issues.apache.org/jira/browse/LOG4J2-547
Project: Log4j 2
Issue Type: Improvement
Components: API
Affects Versions: 2.0-rc1
Reporter: Matt Sicker
Assignee: Ralph Goers
Fix For: 2.0
Attachments: 0001-PrintStream-API-update.patch, log4j2-loggerStream.patch
I've got some ideas on how to improve the LoggerStream idea that I added a little while ago. The main thing I'd like to do is extract an interface from it, rename the default implementation to SimpleLoggerStream (part of the SimpleLogger stuff), and allow log4j implementations to specify a different implementation if desired.
In doing this, I'm not sure where specifically I'd prefer the getStream methods to be. Right now, it's in Logger, but really, it could be in LoggerContext instead. I don't think I should be required to get a Logger just to get a LoggerStream.
Now if only the java.io package used interfaces instead of classes. This would be so much easier to design!
--
This message was sent by Atlassian JIRA
(v6.1.5#6160)
Bruce Brouwer (JIRA)
2014-03-02 01:01:52 UTC
Permalink
[ https://issues.apache.org/jira/browse/LOG4J2-547?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13917247#comment-13917247 ]

Bruce Brouwer commented on LOG4J2-547:
--------------------------------------

I wasn't picking up on that. I'll take a look at it. I think I know now what you're saying the problem is.
Post by Matt Sicker (JIRA)
Update LoggerStream API
-----------------------
Key: LOG4J2-547
URL: https://issues.apache.org/jira/browse/LOG4J2-547
Project: Log4j 2
Issue Type: Improvement
Components: API
Affects Versions: 2.0-rc1
Reporter: Matt Sicker
Assignee: Ralph Goers
Fix For: 2.0
Attachments: 0001-PrintStream-API-update.patch, log4j2-loggerStream.patch
I've got some ideas on how to improve the LoggerStream idea that I added a little while ago. The main thing I'd like to do is extract an interface from it, rename the default implementation to SimpleLoggerStream (part of the SimpleLogger stuff), and allow log4j implementations to specify a different implementation if desired.
In doing this, I'm not sure where specifically I'd prefer the getStream methods to be. Right now, it's in Logger, but really, it could be in LoggerContext instead. I don't think I should be required to get a Logger just to get a LoggerStream.
Now if only the java.io package used interfaces instead of classes. This would be so much easier to design!
--
This message was sent by Atlassian JIRA
(v6.1.5#6160)
Matt Sicker (JIRA)
2014-03-02 01:54:19 UTC
Permalink
[ https://issues.apache.org/jira/browse/LOG4J2-547?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Matt Sicker reopened LOG4J2-547:
--------------------------------


Needs correct caller information. I'll submit a patch for the unit tests in just a moment.
Post by Matt Sicker (JIRA)
Update LoggerStream API
-----------------------
Key: LOG4J2-547
URL: https://issues.apache.org/jira/browse/LOG4J2-547
Project: Log4j 2
Issue Type: Improvement
Components: API
Affects Versions: 2.0-rc1
Reporter: Matt Sicker
Assignee: Ralph Goers
Fix For: 2.0
Attachments: 0001-PrintStream-API-update.patch, log4j2-loggerStream.patch
I've got some ideas on how to improve the LoggerStream idea that I added a little while ago. The main thing I'd like to do is extract an interface from it, rename the default implementation to SimpleLoggerStream (part of the SimpleLogger stuff), and allow log4j implementations to specify a different implementation if desired.
In doing this, I'm not sure where specifically I'd prefer the getStream methods to be. Right now, it's in Logger, but really, it could be in LoggerContext instead. I don't think I should be required to get a Logger just to get a LoggerStream.
Now if only the java.io package used interfaces instead of classes. This would be so much easier to design!
--
This message was sent by Atlassian JIRA
(v6.1.5#6160)
Matt Sicker (JIRA)
2014-03-02 01:56:19 UTC
Permalink
[ https://issues.apache.org/jira/browse/LOG4J2-547?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Matt Sicker updated LOG4J2-547:
-------------------------------

Attachment: Add_caller_info_tests.patch

Here's a unit test to demonstrate the calling class and calling method information. Originally, I was going to split the two test methods into four, but really, they're both testing the same functionality, so it made sense to combine them. As you can see, running the tests on the current trunk will fail, but only once it gets to verifying the contents of the log message created via the print writer.
Post by Matt Sicker (JIRA)
Update LoggerStream API
-----------------------
Key: LOG4J2-547
URL: https://issues.apache.org/jira/browse/LOG4J2-547
Project: Log4j 2
Issue Type: Improvement
Components: API
Affects Versions: 2.0-rc1
Reporter: Matt Sicker
Assignee: Ralph Goers
Fix For: 2.0
Attachments: 0001-PrintStream-API-update.patch, Add_caller_info_tests.patch, log4j2-loggerStream.patch
I've got some ideas on how to improve the LoggerStream idea that I added a little while ago. The main thing I'd like to do is extract an interface from it, rename the default implementation to SimpleLoggerStream (part of the SimpleLogger stuff), and allow log4j implementations to specify a different implementation if desired.
In doing this, I'm not sure where specifically I'd prefer the getStream methods to be. Right now, it's in Logger, but really, it could be in LoggerContext instead. I don't think I should be required to get a Logger just to get a LoggerStream.
Now if only the java.io package used interfaces instead of classes. This would be so much easier to design!
--
This message was sent by Atlassian JIRA
(v6.1.5#6160)
Bruce Brouwer (JIRA)
2014-03-02 02:16:19 UTC
Permalink
[ https://issues.apache.org/jira/browse/LOG4J2-547?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13917268#comment-13917268 ]

Bruce Brouwer commented on LOG4J2-547:
--------------------------------------

Thanks, I'll use those unit tests.

Here's what I was thinking and a quick spike proved it works. If I pass the FQCN to the LoggerWriter and make the FQCN=java.io.PrintWriter, I get the correct call information. I don't have to decorate any classes. But is that too hacky to give PrintWriter as the FQCN to the LoggerWriter?

Also, I didn't realize initially that you were using PrintStream, not PrintWriter. In some ways, I prefer your idea of using PrintWriter. It is easier to turn a PrintStream into a PrintWriter than the other way around. Or do you think there is value in keeping both?
Post by Matt Sicker (JIRA)
Update LoggerStream API
-----------------------
Key: LOG4J2-547
URL: https://issues.apache.org/jira/browse/LOG4J2-547
Project: Log4j 2
Issue Type: Improvement
Components: API
Affects Versions: 2.0-rc1
Reporter: Matt Sicker
Assignee: Ralph Goers
Fix For: 2.0
Attachments: 0001-PrintStream-API-update.patch, Add_caller_info_tests.patch, log4j2-loggerStream.patch
I've got some ideas on how to improve the LoggerStream idea that I added a little while ago. The main thing I'd like to do is extract an interface from it, rename the default implementation to SimpleLoggerStream (part of the SimpleLogger stuff), and allow log4j implementations to specify a different implementation if desired.
In doing this, I'm not sure where specifically I'd prefer the getStream methods to be. Right now, it's in Logger, but really, it could be in LoggerContext instead. I don't think I should be required to get a Logger just to get a LoggerStream.
Now if only the java.io package used interfaces instead of classes. This would be so much easier to design!
--
This message was sent by Atlassian JIRA
(v6.1.5#6160)
Bruce Brouwer (JIRA)
2014-03-02 02:16:19 UTC
Permalink
[ https://issues.apache.org/jira/browse/LOG4J2-547?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13917268#comment-13917268 ]

Bruce Brouwer edited comment on LOG4J2-547 at 3/2/14 2:15 AM:
--------------------------------------------------------------

Thanks, I'll use those unit tests.

Here's what I was thinking and a quick spike proved it works. If I pass the FQCN to the LoggerWriter and make the FQCN=java.io.PrintWriter, I get the correct call information. I don't have to decorate any classes. But is that too hacky to give PrintWriter as the FQCN to the LoggerWriter?

Also, I didn't realize initially that you were using PrintStream, not PrintWriter. In some ways, I prefer your idea of using PrintStream. It is easier to turn a PrintStream into a PrintWriter than the other way around. Or do you think there is value in keeping both?


was (Author: bruce.brouwer):
Thanks, I'll use those unit tests.

Here's what I was thinking and a quick spike proved it works. If I pass the FQCN to the LoggerWriter and make the FQCN=java.io.PrintWriter, I get the correct call information. I don't have to decorate any classes. But is that too hacky to give PrintWriter as the FQCN to the LoggerWriter?

Also, I didn't realize initially that you were using PrintStream, not PrintWriter. In some ways, I prefer your idea of using PrintWriter. It is easier to turn a PrintStream into a PrintWriter than the other way around. Or do you think there is value in keeping both?
Post by Matt Sicker (JIRA)
Update LoggerStream API
-----------------------
Key: LOG4J2-547
URL: https://issues.apache.org/jira/browse/LOG4J2-547
Project: Log4j 2
Issue Type: Improvement
Components: API
Affects Versions: 2.0-rc1
Reporter: Matt Sicker
Assignee: Ralph Goers
Fix For: 2.0
Attachments: 0001-PrintStream-API-update.patch, Add_caller_info_tests.patch, log4j2-loggerStream.patch
I've got some ideas on how to improve the LoggerStream idea that I added a little while ago. The main thing I'd like to do is extract an interface from it, rename the default implementation to SimpleLoggerStream (part of the SimpleLogger stuff), and allow log4j implementations to specify a different implementation if desired.
In doing this, I'm not sure where specifically I'd prefer the getStream methods to be. Right now, it's in Logger, but really, it could be in LoggerContext instead. I don't think I should be required to get a Logger just to get a LoggerStream.
Now if only the java.io package used interfaces instead of classes. This would be so much easier to design!
--
This message was sent by Atlassian JIRA
(v6.1.5#6160)
Matt Sicker (JIRA)
2014-03-02 02:34:21 UTC
Permalink
[ https://issues.apache.org/jira/browse/LOG4J2-547?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13917275#comment-13917275 ]

Matt Sicker commented on LOG4J2-547:
------------------------------------

Yeah, I chose PrintStream originally because you could just wrap it in a PrintWriter. Using java.io.PrintWriter as the FQCN doesn't seem too hacky considering that's the class being used for method calls. I wasn't sure that would work properly, though, as it the call stack then depends on which method in PrintWriter you call (which can differ based on the JDK in use at the time and the internal class structure). If you've got more than one JDK installed, it would be good to test out any fix in as many different environments as possible (e.g., JDK 6, 7, 8, and even a different JVM if possible like JRockit).
Post by Matt Sicker (JIRA)
Update LoggerStream API
-----------------------
Key: LOG4J2-547
URL: https://issues.apache.org/jira/browse/LOG4J2-547
Project: Log4j 2
Issue Type: Improvement
Components: API
Affects Versions: 2.0-rc1
Reporter: Matt Sicker
Assignee: Ralph Goers
Fix For: 2.0
Attachments: 0001-PrintStream-API-update.patch, Add_caller_info_tests.patch, log4j2-loggerStream.patch
I've got some ideas on how to improve the LoggerStream idea that I added a little while ago. The main thing I'd like to do is extract an interface from it, rename the default implementation to SimpleLoggerStream (part of the SimpleLogger stuff), and allow log4j implementations to specify a different implementation if desired.
In doing this, I'm not sure where specifically I'd prefer the getStream methods to be. Right now, it's in Logger, but really, it could be in LoggerContext instead. I don't think I should be required to get a Logger just to get a LoggerStream.
Now if only the java.io package used interfaces instead of classes. This would be so much easier to design!
--
This message was sent by Atlassian JIRA
(v6.1.5#6160)
Bruce Brouwer (JIRA)
2014-03-02 14:05:19 UTC
Permalink
[ https://issues.apache.org/jira/browse/LOG4J2-547?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13917415#comment-13917415 ]

Bruce Brouwer commented on LOG4J2-547:
--------------------------------------

So, I've been thinking about the actual use case for this feature. I was thinking it would be even more helpful if I grabbed a writer that actually wrapped another writer. This way I could "spy" on the writer and send all its content to a Logger and to the actual writer. I'm thinking of a method signatures like this:
{code}
public Writer writer(Writer writer, Level level);
public Writer writer(Writer writer, Marker marker, Level level);
public OutputStream stream(OutputStream stream, Level level);
public OutputStream stream(OutputStream stream, Marker marker, Level level);
{code}
We could also provide ones basically like before:
{code}
public Writer writer(Level level);
public Writer writer(Marker marker, Level level);
public OutputStream stream(Level level);
public OutputStream stream(Marker marker, Level level);
{code}
Maybe we would keep the PrintWriter/PrintStream variants as well. But then why stop there. We could spy on Readers as well:
{code}
public Reader reader(Reader reader, Level level);
public Reader reader(Reader reader, Marker marker, Level level);
public InputStream stream(InputStream stream, Level level);
public InputStream stream(InputStream stream, Marker marker, Level level);
{code}
Making this all work is not really any harder than what is already there.

But now we're starting to really pollute the Logger interface with stuff that 99% of the time I'll never want or use. What if we took it a different direction and didn't put these reader/writer methods on Logger, but instead put them on LogManager or even a new class LogStreaming. Now I could get one of these things with code like this:
{code}
Writer writer = LogStreaming.writer(myWriter, Level.WARNING);
{code}

We could go even further and add debug/warn/info/error methods on here as well:
{code}
Writer writer = LogStreaming.debugWriter(myWriter);
{code}

This goes along with another idea I had in LOG4J-242 which would make a fluent interface for log4j. I eventually decided that all that stuff doesn't belong in Logger either, so instead I would want a FluentLogManager instead of LogManager.

Now back to the whole FQCN thing. If I do the hack I mentioned coupled with these new methods I described, if I were to pass in a PrintWriter to this writer method, then using the FQCN of PrintWriter will determine the caller is the caller of the PrintWriter I passed in, and not the one being created by the writer method.

Furthermore, the reason I would want one of these Writers is to pass to some function that expects a Writer, and therefore the call stack will not be from my code anyway and then the caller location probably won't be as useful to me as I would want.

So, what are your thoughts on all of these ideas? Am I making this more complicated than it should be?
Post by Matt Sicker (JIRA)
Update LoggerStream API
-----------------------
Key: LOG4J2-547
URL: https://issues.apache.org/jira/browse/LOG4J2-547
Project: Log4j 2
Issue Type: Improvement
Components: API
Affects Versions: 2.0-rc1
Reporter: Matt Sicker
Assignee: Ralph Goers
Fix For: 2.0
Attachments: 0001-PrintStream-API-update.patch, Add_caller_info_tests.patch, log4j2-loggerStream.patch
I've got some ideas on how to improve the LoggerStream idea that I added a little while ago. The main thing I'd like to do is extract an interface from it, rename the default implementation to SimpleLoggerStream (part of the SimpleLogger stuff), and allow log4j implementations to specify a different implementation if desired.
In doing this, I'm not sure where specifically I'd prefer the getStream methods to be. Right now, it's in Logger, but really, it could be in LoggerContext instead. I don't think I should be required to get a Logger just to get a LoggerStream.
Now if only the java.io package used interfaces instead of classes. This would be so much easier to design!
--
This message was sent by Atlassian JIRA
(v6.1.5#6160)
Bruce Brouwer (JIRA)
2014-03-02 17:02:31 UTC
Permalink
[ https://issues.apache.org/jira/browse/LOG4J2-547?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13917415#comment-13917415 ]

Bruce Brouwer edited comment on LOG4J2-547 at 3/2/14 5:01 PM:
--------------------------------------------------------------

So, I've been thinking about the actual use case for this feature. I was thinking it would be even more helpful if I grabbed a writer that actually wrapped another writer. This way I could "spy" on the writer and send all its content to a Logger and to the actual writer. I'm thinking of a method signatures like this:
{code}
public Writer writer(Writer writer, Level level);
public Writer writer(Writer writer, Marker marker, Level level);
public OutputStream stream(OutputStream stream, Level level);
public OutputStream stream(OutputStream stream, Marker marker, Level level);
{code}
We could also provide ones basically like before:
{code}
public Writer writer(Level level);
public Writer writer(Marker marker, Level level);
public OutputStream stream(Level level);
public OutputStream stream(Marker marker, Level level);
{code}
Maybe we would keep the PrintWriter/PrintStream variants as well. But then why stop there. We could spy on Readers as well:
{code}
public Reader reader(Reader reader, Level level);
public Reader reader(Reader reader, Marker marker, Level level);
public InputStream stream(InputStream stream, Level level);
public InputStream stream(InputStream stream, Marker marker, Level level);
{code}
Making this all work is not really any harder than what is already there.

But now we're starting to really pollute the Logger interface with stuff that 99% of the time I'll never want or use. What if we took it a different direction and didn't put these reader/writer methods on Logger, but instead put them on LogManager or even a new class LogStreaming. Now I could get one of these things with code like this:
{code}
Writer writer = LogStreaming.writer(myWriter, Level.WARNING);
{code}

We could go even further and add debug/warn/info/error methods on here as well:
{code}
Writer writer = LogStreaming.debugWriter(MyExample.class, myWriter);
{code}

This goes along with another idea I had in LOG4J-242 which would make a fluent interface for log4j. I eventually decided that all that stuff doesn't belong in Logger either, so instead I would want a FluentLogManager instead of LogManager.

Now back to the whole FQCN thing. If I do the hack I mentioned coupled with these new methods I described, if I were to pass in a PrintWriter to this writer method, then using the FQCN of PrintWriter will determine the caller is the caller of the PrintWriter I passed in, and not the one being created by the writer method.

Furthermore, the reason I would want one of these Writers is to pass to some function that expects a Writer, and therefore the call stack will not be from my code anyway and then the caller location probably won't be as useful to me as I would want.

So, what are your thoughts on all of these ideas? Am I making this more complicated than it should be?


was (Author: bruce.brouwer):
So, I've been thinking about the actual use case for this feature. I was thinking it would be even more helpful if I grabbed a writer that actually wrapped another writer. This way I could "spy" on the writer and send all its content to a Logger and to the actual writer. I'm thinking of a method signatures like this:
{code}
public Writer writer(Writer writer, Level level);
public Writer writer(Writer writer, Marker marker, Level level);
public OutputStream stream(OutputStream stream, Level level);
public OutputStream stream(OutputStream stream, Marker marker, Level level);
{code}
We could also provide ones basically like before:
{code}
public Writer writer(Level level);
public Writer writer(Marker marker, Level level);
public OutputStream stream(Level level);
public OutputStream stream(Marker marker, Level level);
{code}
Maybe we would keep the PrintWriter/PrintStream variants as well. But then why stop there. We could spy on Readers as well:
{code}
public Reader reader(Reader reader, Level level);
public Reader reader(Reader reader, Marker marker, Level level);
public InputStream stream(InputStream stream, Level level);
public InputStream stream(InputStream stream, Marker marker, Level level);
{code}
Making this all work is not really any harder than what is already there.

But now we're starting to really pollute the Logger interface with stuff that 99% of the time I'll never want or use. What if we took it a different direction and didn't put these reader/writer methods on Logger, but instead put them on LogManager or even a new class LogStreaming. Now I could get one of these things with code like this:
{code}
Writer writer = LogStreaming.writer(myWriter, Level.WARNING);
{code}

We could go even further and add debug/warn/info/error methods on here as well:
{code}
Writer writer = LogStreaming.debugWriter(myWriter);
{code}

This goes along with another idea I had in LOG4J-242 which would make a fluent interface for log4j. I eventually decided that all that stuff doesn't belong in Logger either, so instead I would want a FluentLogManager instead of LogManager.

Now back to the whole FQCN thing. If I do the hack I mentioned coupled with these new methods I described, if I were to pass in a PrintWriter to this writer method, then using the FQCN of PrintWriter will determine the caller is the caller of the PrintWriter I passed in, and not the one being created by the writer method.

Furthermore, the reason I would want one of these Writers is to pass to some function that expects a Writer, and therefore the call stack will not be from my code anyway and then the caller location probably won't be as useful to me as I would want.

So, what are your thoughts on all of these ideas? Am I making this more complicated than it should be?
Post by Matt Sicker (JIRA)
Update LoggerStream API
-----------------------
Key: LOG4J2-547
URL: https://issues.apache.org/jira/browse/LOG4J2-547
Project: Log4j 2
Issue Type: Improvement
Components: API
Affects Versions: 2.0-rc1
Reporter: Matt Sicker
Assignee: Ralph Goers
Fix For: 2.0
Attachments: 0001-PrintStream-API-update.patch, Add_caller_info_tests.patch, log4j2-loggerStream.patch
I've got some ideas on how to improve the LoggerStream idea that I added a little while ago. The main thing I'd like to do is extract an interface from it, rename the default implementation to SimpleLoggerStream (part of the SimpleLogger stuff), and allow log4j implementations to specify a different implementation if desired.
In doing this, I'm not sure where specifically I'd prefer the getStream methods to be. Right now, it's in Logger, but really, it could be in LoggerContext instead. I don't think I should be required to get a Logger just to get a LoggerStream.
Now if only the java.io package used interfaces instead of classes. This would be so much easier to design!
--
This message was sent by Atlassian JIRA
(v6.2#6252)
Bruce Brouwer (JIRA)
2014-03-02 17:02:32 UTC
Permalink
[ https://issues.apache.org/jira/browse/LOG4J2-547?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13917415#comment-13917415 ]

Bruce Brouwer edited comment on LOG4J2-547 at 3/2/14 5:02 PM:
--------------------------------------------------------------

So, I've been thinking about the actual use case for this feature. I was thinking it would be even more helpful if I grabbed a writer that actually wrapped another writer. This way I could "spy" on the writer and send all its content to a Logger and to the actual writer. I'm thinking of a method signatures like this:
{code}
public Writer writer(Writer writer, Level level);
public Writer writer(Writer writer, Marker marker, Level level);
public OutputStream stream(OutputStream stream, Level level);
public OutputStream stream(OutputStream stream, Marker marker, Level level);
{code}
We could also provide ones basically like before:
{code}
public Writer writer(Level level);
public Writer writer(Marker marker, Level level);
public OutputStream stream(Level level);
public OutputStream stream(Marker marker, Level level);
{code}
Maybe we would keep the PrintWriter/PrintStream variants as well. But then why stop there. We could spy on Readers as well:
{code}
public Reader reader(Reader reader, Level level);
public Reader reader(Reader reader, Marker marker, Level level);
public InputStream stream(InputStream stream, Level level);
public InputStream stream(InputStream stream, Marker marker, Level level);
{code}
Making this all work is not really any harder than what is already there.

But now we're starting to really pollute the Logger interface with stuff that 99% of the time I'll never want or use. What if we took it a different direction and didn't put these reader/writer methods on Logger, but instead put them on LogManager or even a new class LogStreaming. Now I could get one of these things with code like this:
{code}
Writer writer = LogStreaming.writer(MyExample.class, myWriter, Level.WARNING);
{code}

We could go even further and add debug/warn/info/error methods on here as well:
{code}
Writer writer = LogStreaming.debugWriter(MyExample.class, myWriter);
{code}

This goes along with another idea I had in LOG4J-242 which would make a fluent interface for log4j. I eventually decided that all that stuff doesn't belong in Logger either, so instead I would want a FluentLogManager instead of LogManager.

Now back to the whole FQCN thing. If I do the hack I mentioned coupled with these new methods I described, if I were to pass in a PrintWriter to this writer method, then using the FQCN of PrintWriter will determine the caller is the caller of the PrintWriter I passed in, and not the one being created by the writer method.

Furthermore, the reason I would want one of these Writers is to pass to some function that expects a Writer, and therefore the call stack will not be from my code anyway and then the caller location probably won't be as useful to me as I would want.

So, what are your thoughts on all of these ideas? Am I making this more complicated than it should be?


was (Author: bruce.brouwer):
So, I've been thinking about the actual use case for this feature. I was thinking it would be even more helpful if I grabbed a writer that actually wrapped another writer. This way I could "spy" on the writer and send all its content to a Logger and to the actual writer. I'm thinking of a method signatures like this:
{code}
public Writer writer(Writer writer, Level level);
public Writer writer(Writer writer, Marker marker, Level level);
public OutputStream stream(OutputStream stream, Level level);
public OutputStream stream(OutputStream stream, Marker marker, Level level);
{code}
We could also provide ones basically like before:
{code}
public Writer writer(Level level);
public Writer writer(Marker marker, Level level);
public OutputStream stream(Level level);
public OutputStream stream(Marker marker, Level level);
{code}
Maybe we would keep the PrintWriter/PrintStream variants as well. But then why stop there. We could spy on Readers as well:
{code}
public Reader reader(Reader reader, Level level);
public Reader reader(Reader reader, Marker marker, Level level);
public InputStream stream(InputStream stream, Level level);
public InputStream stream(InputStream stream, Marker marker, Level level);
{code}
Making this all work is not really any harder than what is already there.

But now we're starting to really pollute the Logger interface with stuff that 99% of the time I'll never want or use. What if we took it a different direction and didn't put these reader/writer methods on Logger, but instead put them on LogManager or even a new class LogStreaming. Now I could get one of these things with code like this:
{code}
Writer writer = LogStreaming.writer(myWriter, Level.WARNING);
{code}

We could go even further and add debug/warn/info/error methods on here as well:
{code}
Writer writer = LogStreaming.debugWriter(MyExample.class, myWriter);
{code}

This goes along with another idea I had in LOG4J-242 which would make a fluent interface for log4j. I eventually decided that all that stuff doesn't belong in Logger either, so instead I would want a FluentLogManager instead of LogManager.

Now back to the whole FQCN thing. If I do the hack I mentioned coupled with these new methods I described, if I were to pass in a PrintWriter to this writer method, then using the FQCN of PrintWriter will determine the caller is the caller of the PrintWriter I passed in, and not the one being created by the writer method.

Furthermore, the reason I would want one of these Writers is to pass to some function that expects a Writer, and therefore the call stack will not be from my code anyway and then the caller location probably won't be as useful to me as I would want.

So, what are your thoughts on all of these ideas? Am I making this more complicated than it should be?
Post by Matt Sicker (JIRA)
Update LoggerStream API
-----------------------
Key: LOG4J2-547
URL: https://issues.apache.org/jira/browse/LOG4J2-547
Project: Log4j 2
Issue Type: Improvement
Components: API
Affects Versions: 2.0-rc1
Reporter: Matt Sicker
Assignee: Ralph Goers
Fix For: 2.0
Attachments: 0001-PrintStream-API-update.patch, Add_caller_info_tests.patch, log4j2-loggerStream.patch
I've got some ideas on how to improve the LoggerStream idea that I added a little while ago. The main thing I'd like to do is extract an interface from it, rename the default implementation to SimpleLoggerStream (part of the SimpleLogger stuff), and allow log4j implementations to specify a different implementation if desired.
In doing this, I'm not sure where specifically I'd prefer the getStream methods to be. Right now, it's in Logger, but really, it could be in LoggerContext instead. I don't think I should be required to get a Logger just to get a LoggerStream.
Now if only the java.io package used interfaces instead of classes. This would be so much easier to design!
--
This message was sent by Atlassian JIRA
(v6.2#6252)
Gary Gregory (JIRA)
2014-03-02 17:59:31 UTC
Permalink
[ https://issues.apache.org/jira/browse/LOG4J2-547?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13917500#comment-13917500 ]

Gary Gregory commented on LOG4J2-547:
-------------------------------------

This streaming aspect of Log4j2 really looks and feels so different from what we started with that I agree, it should not live in the Logger interface.

You could hang the factory methods in LogManager, I like having ONE root class. LogStreaming is not a great name, if you MUST have a separate class, maybe StreamingLogManager or LogManagerStreams...
Post by Matt Sicker (JIRA)
Update LoggerStream API
-----------------------
Key: LOG4J2-547
URL: https://issues.apache.org/jira/browse/LOG4J2-547
Project: Log4j 2
Issue Type: Improvement
Components: API
Affects Versions: 2.0-rc1
Reporter: Matt Sicker
Assignee: Ralph Goers
Fix For: 2.0
Attachments: 0001-PrintStream-API-update.patch, Add_caller_info_tests.patch, log4j2-loggerStream.patch
I've got some ideas on how to improve the LoggerStream idea that I added a little while ago. The main thing I'd like to do is extract an interface from it, rename the default implementation to SimpleLoggerStream (part of the SimpleLogger stuff), and allow log4j implementations to specify a different implementation if desired.
In doing this, I'm not sure where specifically I'd prefer the getStream methods to be. Right now, it's in Logger, but really, it could be in LoggerContext instead. I don't think I should be required to get a Logger just to get a LoggerStream.
Now if only the java.io package used interfaces instead of classes. This would be so much easier to design!
--
This message was sent by Atlassian JIRA
(v6.2#6252)
Matt Sicker (JIRA)
2014-03-02 21:14:31 UTC
Permalink
[ https://issues.apache.org/jira/browse/LOG4J2-547?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13917561#comment-13917561 ]

Matt Sicker commented on LOG4J2-547:
------------------------------------

I'm starting to see two ways this can go: as part of the API, or a separate module dependent on log4j-api (similar to fluent-hc from HttpComponents). I like the idea of going the full java.io route for spying and such (which can help log I/O as well as provide a path for logger-less code to transition to real loggers).

As for the one root class, of course LogManager should have the API available to create the streams and reader/writers, but that could easily be delegated just like how most of the methods in LogManager already delegate to a LoggerContextFactory.
Post by Matt Sicker (JIRA)
Update LoggerStream API
-----------------------
Key: LOG4J2-547
URL: https://issues.apache.org/jira/browse/LOG4J2-547
Project: Log4j 2
Issue Type: Improvement
Components: API
Affects Versions: 2.0-rc1
Reporter: Matt Sicker
Assignee: Ralph Goers
Fix For: 2.0
Attachments: 0001-PrintStream-API-update.patch, Add_caller_info_tests.patch, log4j2-loggerStream.patch
I've got some ideas on how to improve the LoggerStream idea that I added a little while ago. The main thing I'd like to do is extract an interface from it, rename the default implementation to SimpleLoggerStream (part of the SimpleLogger stuff), and allow log4j implementations to specify a different implementation if desired.
In doing this, I'm not sure where specifically I'd prefer the getStream methods to be. Right now, it's in Logger, but really, it could be in LoggerContext instead. I don't think I should be required to get a Logger just to get a LoggerStream.
Now if only the java.io package used interfaces instead of classes. This would be so much easier to design!
--
This message was sent by Atlassian JIRA
(v6.2#6252)
Matt Sicker (JIRA)
2014-03-02 21:18:30 UTC
Permalink
[ https://issues.apache.org/jira/browse/LOG4J2-547?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13917561#comment-13917561 ]

Matt Sicker edited comment on LOG4J2-547 at 3/2/14 9:16 PM:
------------------------------------------------------------

I'm starting to see two ways this can go: as part of the API, or a separate module dependent on log4j-api (similar to fluent-hc from HttpComponents). I like the idea of going the full java.io route for spying and such (which can help log I/O as well as provide a path for logger-less code to transition to real loggers).

As for the one root class, of course LogManager should have the API available to create the streams and reader/writers, but that could easily be delegated just like how most of the methods in LogManager already delegate to a LoggerContextFactory.

Edit: if we made a fluent API, it would definitely make sense to put it in its own module such as fluent-logging or log4j-fluent (more consistent naming there at least). Fluent APIs are neat, but they're also limited in functionality (which is the point) and really belong in separate modules. Then again, I'm all about modules lately, so I might be a bit biased. ;)


was (Author: jvz):
I'm starting to see two ways this can go: as part of the API, or a separate module dependent on log4j-api (similar to fluent-hc from HttpComponents). I like the idea of going the full java.io route for spying and such (which can help log I/O as well as provide a path for logger-less code to transition to real loggers).

As for the one root class, of course LogManager should have the API available to create the streams and reader/writers, but that could easily be delegated just like how most of the methods in LogManager already delegate to a LoggerContextFactory.
Post by Matt Sicker (JIRA)
Update LoggerStream API
-----------------------
Key: LOG4J2-547
URL: https://issues.apache.org/jira/browse/LOG4J2-547
Project: Log4j 2
Issue Type: Improvement
Components: API
Affects Versions: 2.0-rc1
Reporter: Matt Sicker
Assignee: Ralph Goers
Fix For: 2.0
Attachments: 0001-PrintStream-API-update.patch, Add_caller_info_tests.patch, log4j2-loggerStream.patch
I've got some ideas on how to improve the LoggerStream idea that I added a little while ago. The main thing I'd like to do is extract an interface from it, rename the default implementation to SimpleLoggerStream (part of the SimpleLogger stuff), and allow log4j implementations to specify a different implementation if desired.
In doing this, I'm not sure where specifically I'd prefer the getStream methods to be. Right now, it's in Logger, but really, it could be in LoggerContext instead. I don't think I should be required to get a Logger just to get a LoggerStream.
Now if only the java.io package used interfaces instead of classes. This would be so much easier to design!
--
This message was sent by Atlassian JIRA
(v6.2#6252)
Bruce Brouwer (JIRA)
2014-03-02 21:21:31 UTC
Permalink
[ https://issues.apache.org/jira/browse/LOG4J2-547?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13917565#comment-13917565 ]

Bruce Brouwer commented on LOG4J2-547:
--------------------------------------

Matt, you're going down the exact same thought-path I am.

The way I'm looking at it, there are a number of alternate log4j interfaces available, some of which haven't come to light yet. There's the slf4j interface and the jcl interface. I'm starting to think of this streaming API in the same light, putting it in log4j-streaming. And I agree, my fluent api should go in another module: log4j-fluent.

I like keeping the Logger interface more along the lines of the "classic" log4j interface without adding a bunch of other methods. Because of my viewpoint, I would prefer having a different root class that accessed this streaming API. I don't have a strong preference for the actual name, I kind of like StreamingLogManager. This new root class would live in log4j-streaming and not impact the classic nature of the LogManager interface.

Is it too big of a change to introduce a new artifact this late in the game? Should the streaming API be pushed off to 2.1? But I like how there is general agreement to get it out of Logger.
Post by Matt Sicker (JIRA)
Update LoggerStream API
-----------------------
Key: LOG4J2-547
URL: https://issues.apache.org/jira/browse/LOG4J2-547
Project: Log4j 2
Issue Type: Improvement
Components: API
Affects Versions: 2.0-rc1
Reporter: Matt Sicker
Assignee: Ralph Goers
Fix For: 2.0
Attachments: 0001-PrintStream-API-update.patch, Add_caller_info_tests.patch, log4j2-loggerStream.patch
I've got some ideas on how to improve the LoggerStream idea that I added a little while ago. The main thing I'd like to do is extract an interface from it, rename the default implementation to SimpleLoggerStream (part of the SimpleLogger stuff), and allow log4j implementations to specify a different implementation if desired.
In doing this, I'm not sure where specifically I'd prefer the getStream methods to be. Right now, it's in Logger, but really, it could be in LoggerContext instead. I don't think I should be required to get a Logger just to get a LoggerStream.
Now if only the java.io package used interfaces instead of classes. This would be so much easier to design!
--
This message was sent by Atlassian JIRA
(v6.2#6252)
Matt Sicker (JIRA)
2014-03-02 21:41:31 UTC
Permalink
[ https://issues.apache.org/jira/browse/LOG4J2-547?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13917570#comment-13917570 ]

Matt Sicker commented on LOG4J2-547:
------------------------------------

Considering the OSGi support tends to introduce more new modules every time we do anything with it, I don't think that additional modules are all that big a deal. It's important that each module does one thing and does it well. For convenience reasons, it's easy to just add log4j-core to your classpath and not worry too much, but it's also gotten rather bloated in terms of features when you look at it from a modular perspective.

When it comes to doing things this late in the game, I was under the impression that any API changes and such should be all done before 2.0.0.RELEASE (or whatever it will be called; I like that name for the OSGi version because RELEASE comes alphabetically after RC, so it's considered a "newer" version according to OSGi versioning standards as well as Maven). However, adding API (not changing it, but adding to it) is perfectly fine in 2.x releases according to the usual semantic versioning standards.

The tl;dr of this is that I'd support holding off introducing the streaming/java.io API until 2.1. However, if we did that, I would highly suggest removing the existing PrintStream/LoggerStream functionality to prevent future API headaches.
Post by Matt Sicker (JIRA)
Update LoggerStream API
-----------------------
Key: LOG4J2-547
URL: https://issues.apache.org/jira/browse/LOG4J2-547
Project: Log4j 2
Issue Type: Improvement
Components: API
Affects Versions: 2.0-rc1
Reporter: Matt Sicker
Assignee: Ralph Goers
Fix For: 2.0
Attachments: 0001-PrintStream-API-update.patch, Add_caller_info_tests.patch, log4j2-loggerStream.patch
I've got some ideas on how to improve the LoggerStream idea that I added a little while ago. The main thing I'd like to do is extract an interface from it, rename the default implementation to SimpleLoggerStream (part of the SimpleLogger stuff), and allow log4j implementations to specify a different implementation if desired.
In doing this, I'm not sure where specifically I'd prefer the getStream methods to be. Right now, it's in Logger, but really, it could be in LoggerContext instead. I don't think I should be required to get a Logger just to get a LoggerStream.
Now if only the java.io package used interfaces instead of classes. This would be so much easier to design!
--
This message was sent by Atlassian JIRA
(v6.2#6252)
Gary Gregory (JIRA)
2014-03-02 23:23:21 UTC
Permalink
[ https://issues.apache.org/jira/browse/LOG4J2-547?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13917602#comment-13917602 ]

Gary Gregory commented on LOG4J2-547:
-------------------------------------

Please, not another jar.
Post by Matt Sicker (JIRA)
Update LoggerStream API
-----------------------
Key: LOG4J2-547
URL: https://issues.apache.org/jira/browse/LOG4J2-547
Project: Log4j 2
Issue Type: Improvement
Components: API
Affects Versions: 2.0-rc1
Reporter: Matt Sicker
Assignee: Ralph Goers
Fix For: 2.0
Attachments: 0001-PrintStream-API-update.patch, Add_caller_info_tests.patch, log4j2-loggerStream.patch
I've got some ideas on how to improve the LoggerStream idea that I added a little while ago. The main thing I'd like to do is extract an interface from it, rename the default implementation to SimpleLoggerStream (part of the SimpleLogger stuff), and allow log4j implementations to specify a different implementation if desired.
In doing this, I'm not sure where specifically I'd prefer the getStream methods to be. Right now, it's in Logger, but really, it could be in LoggerContext instead. I don't think I should be required to get a Logger just to get a LoggerStream.
Now if only the java.io package used interfaces instead of classes. This would be so much easier to design!
--
This message was sent by Atlassian JIRA
(v6.2#6252)
Matt Sicker (JIRA)
2014-03-02 23:27:20 UTC
Permalink
[ https://issues.apache.org/jira/browse/LOG4J2-547?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13917603#comment-13917603 ]

Matt Sicker commented on LOG4J2-547:
------------------------------------

For the streaming interface? Sure, it makes sense as part of the normal API. The OSGi bundles, however, are meant to be split up into several JARs. It doesn't affect you if you just use log4j-core outside of an OSGi environment. For OSGi users, though, it would be nice to only have to load the bundles relevant to your configuration needs.
Post by Matt Sicker (JIRA)
Update LoggerStream API
-----------------------
Key: LOG4J2-547
URL: https://issues.apache.org/jira/browse/LOG4J2-547
Project: Log4j 2
Issue Type: Improvement
Components: API
Affects Versions: 2.0-rc1
Reporter: Matt Sicker
Assignee: Ralph Goers
Fix For: 2.0
Attachments: 0001-PrintStream-API-update.patch, Add_caller_info_tests.patch, log4j2-loggerStream.patch
I've got some ideas on how to improve the LoggerStream idea that I added a little while ago. The main thing I'd like to do is extract an interface from it, rename the default implementation to SimpleLoggerStream (part of the SimpleLogger stuff), and allow log4j implementations to specify a different implementation if desired.
In doing this, I'm not sure where specifically I'd prefer the getStream methods to be. Right now, it's in Logger, but really, it could be in LoggerContext instead. I don't think I should be required to get a Logger just to get a LoggerStream.
Now if only the java.io package used interfaces instead of classes. This would be so much easier to design!
--
This message was sent by Atlassian JIRA
(v6.2#6252)
Bruce Brouwer (JIRA)
2014-03-03 00:27:27 UTC
Permalink
[ https://issues.apache.org/jira/browse/LOG4J2-547?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13917644#comment-13917644 ]

Bruce Brouwer commented on LOG4J2-547:
--------------------------------------

If we were going to put the streaming interface in -core or -api, then I agree with Gary that there is no use for another JAR. If, however, we decide this streaming API isn't part of the core of log4j (as I am of the opinion), then I vote to put that in a -streaming JAR. That would include StreamingLogManager.

I personally don't mind the extra JAR if it requires me to explicitly choose to include it for the desired functionality (like slf4j or jcl). I'm a big user of Spring and I felt the same way when they broke that up into a whole bunch of JARs. Now it just seems like common practice to have smaller, more targeted JARs. Sometimes it can be a pain to know which jar has a particular class, but [http://search.maven.org] class search makes that easy to figure out.

Do you think we can gain consensus to just remove it completely until after 2.0 is released? Maybe some time will help us settle on a direction.
Post by Matt Sicker (JIRA)
Update LoggerStream API
-----------------------
Key: LOG4J2-547
URL: https://issues.apache.org/jira/browse/LOG4J2-547
Project: Log4j 2
Issue Type: Improvement
Components: API
Affects Versions: 2.0-rc1
Reporter: Matt Sicker
Assignee: Ralph Goers
Fix For: 2.0
Attachments: 0001-PrintStream-API-update.patch, Add_caller_info_tests.patch, log4j2-loggerStream.patch
I've got some ideas on how to improve the LoggerStream idea that I added a little while ago. The main thing I'd like to do is extract an interface from it, rename the default implementation to SimpleLoggerStream (part of the SimpleLogger stuff), and allow log4j implementations to specify a different implementation if desired.
In doing this, I'm not sure where specifically I'd prefer the getStream methods to be. Right now, it's in Logger, but really, it could be in LoggerContext instead. I don't think I should be required to get a Logger just to get a LoggerStream.
Now if only the java.io package used interfaces instead of classes. This would be so much easier to design!
--
This message was sent by Atlassian JIRA
(v6.2#6252)
Matt Sicker (JIRA)
2014-03-03 00:43:21 UTC
Permalink
[ https://issues.apache.org/jira/browse/LOG4J2-547?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13917651#comment-13917651 ]

Matt Sicker commented on LOG4J2-547:
------------------------------------

I think it would depend on how many classes the streaming interface would really add. While I do like using proper modularity for things, it does make it a hassle to use without a corresponding bom. For example, search for "arquillian" on search.maven.org and tell me that's not a pain in the ass without the bom pom specifying all the proper version numbers to use for its various modules. I think it's a neat idea in theory, but in practice, there needs to be better documentation.

Speaking of Spring and splitting everything up like that, I came across that issue in a rather direct way: the javadocs for Spring Framework specify all these neat classes available, but in reality, you could end up specifying like 10 JARs just to get things you thought were all in the core framework. There's certainly a documentation problem.
Post by Matt Sicker (JIRA)
Update LoggerStream API
-----------------------
Key: LOG4J2-547
URL: https://issues.apache.org/jira/browse/LOG4J2-547
Project: Log4j 2
Issue Type: Improvement
Components: API
Affects Versions: 2.0-rc1
Reporter: Matt Sicker
Assignee: Ralph Goers
Fix For: 2.0
Attachments: 0001-PrintStream-API-update.patch, Add_caller_info_tests.patch, log4j2-loggerStream.patch
I've got some ideas on how to improve the LoggerStream idea that I added a little while ago. The main thing I'd like to do is extract an interface from it, rename the default implementation to SimpleLoggerStream (part of the SimpleLogger stuff), and allow log4j implementations to specify a different implementation if desired.
In doing this, I'm not sure where specifically I'd prefer the getStream methods to be. Right now, it's in Logger, but really, it could be in LoggerContext instead. I don't think I should be required to get a Logger just to get a LoggerStream.
Now if only the java.io package used interfaces instead of classes. This would be so much easier to design!
--
This message was sent by Atlassian JIRA
(v6.2#6252)
Gary Gregory (JIRA)
2014-03-03 01:21:21 UTC
Permalink
[ https://issues.apache.org/jira/browse/LOG4J2-547?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13917662#comment-13917662 ]

Gary Gregory commented on LOG4J2-547:
-------------------------------------

This clearly belongs in the api and/or core, not in a separate jar. The api and/or core part depends on whether you want underlying implementations to change based on the backend (log4j, slf4j, and so on).

Just redo the code now, it has our attention and momentum now.
Post by Matt Sicker (JIRA)
Update LoggerStream API
-----------------------
Key: LOG4J2-547
URL: https://issues.apache.org/jira/browse/LOG4J2-547
Project: Log4j 2
Issue Type: Improvement
Components: API
Affects Versions: 2.0-rc1
Reporter: Matt Sicker
Assignee: Ralph Goers
Fix For: 2.0
Attachments: 0001-PrintStream-API-update.patch, Add_caller_info_tests.patch, log4j2-loggerStream.patch
I've got some ideas on how to improve the LoggerStream idea that I added a little while ago. The main thing I'd like to do is extract an interface from it, rename the default implementation to SimpleLoggerStream (part of the SimpleLogger stuff), and allow log4j implementations to specify a different implementation if desired.
In doing this, I'm not sure where specifically I'd prefer the getStream methods to be. Right now, it's in Logger, but really, it could be in LoggerContext instead. I don't think I should be required to get a Logger just to get a LoggerStream.
Now if only the java.io package used interfaces instead of classes. This would be so much easier to design!
--
This message was sent by Atlassian JIRA
(v6.2#6252)
Bruce Brouwer (JIRA)
2014-03-03 01:23:21 UTC
Permalink
[ https://issues.apache.org/jira/browse/LOG4J2-547?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13917664#comment-13917664 ]

Bruce Brouwer commented on LOG4J2-547:
--------------------------------------

Yes, the default search in search.maven.org can yield a ton of stuff. I'm talking about the advanced search where you can specify a fully qualified class name. And I agree, the Spring docs don't make it clear enough which JARs you need for any particular feature.

As for the bom, that's a great idea. I created LOG4J2-558.
Post by Matt Sicker (JIRA)
Update LoggerStream API
-----------------------
Key: LOG4J2-547
URL: https://issues.apache.org/jira/browse/LOG4J2-547
Project: Log4j 2
Issue Type: Improvement
Components: API
Affects Versions: 2.0-rc1
Reporter: Matt Sicker
Assignee: Ralph Goers
Fix For: 2.0
Attachments: 0001-PrintStream-API-update.patch, Add_caller_info_tests.patch, log4j2-loggerStream.patch
I've got some ideas on how to improve the LoggerStream idea that I added a little while ago. The main thing I'd like to do is extract an interface from it, rename the default implementation to SimpleLoggerStream (part of the SimpleLogger stuff), and allow log4j implementations to specify a different implementation if desired.
In doing this, I'm not sure where specifically I'd prefer the getStream methods to be. Right now, it's in Logger, but really, it could be in LoggerContext instead. I don't think I should be required to get a Logger just to get a LoggerStream.
Now if only the java.io package used interfaces instead of classes. This would be so much easier to design!
--
This message was sent by Atlassian JIRA
(v6.2#6252)
Gary Gregory (JIRA)
2014-03-03 01:29:21 UTC
Permalink
[ https://issues.apache.org/jira/browse/LOG4J2-547?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13917668#comment-13917668 ]

Gary Gregory commented on LOG4J2-547:
-------------------------------------

Telling people they have to search some website to locate a class A in a jar B... is just nonesense and a barrier to sane development. Then class B shows up in jar A and B, then it depends what version, bleh. I beg projects to provide all-in-one jars and be done with it. Optimizing for size on disk/downloads can be done later if its a bottle neck...
Post by Matt Sicker (JIRA)
Update LoggerStream API
-----------------------
Key: LOG4J2-547
URL: https://issues.apache.org/jira/browse/LOG4J2-547
Project: Log4j 2
Issue Type: Improvement
Components: API
Affects Versions: 2.0-rc1
Reporter: Matt Sicker
Assignee: Ralph Goers
Fix For: 2.0
Attachments: 0001-PrintStream-API-update.patch, Add_caller_info_tests.patch, log4j2-loggerStream.patch
I've got some ideas on how to improve the LoggerStream idea that I added a little while ago. The main thing I'd like to do is extract an interface from it, rename the default implementation to SimpleLoggerStream (part of the SimpleLogger stuff), and allow log4j implementations to specify a different implementation if desired.
In doing this, I'm not sure where specifically I'd prefer the getStream methods to be. Right now, it's in Logger, but really, it could be in LoggerContext instead. I don't think I should be required to get a Logger just to get a LoggerStream.
Now if only the java.io package used interfaces instead of classes. This would be so much easier to design!
--
This message was sent by Atlassian JIRA
(v6.2#6252)
Bruce Brouwer (JIRA)
2014-03-03 01:38:21 UTC
Permalink
[ https://issues.apache.org/jira/browse/LOG4J2-547?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13917673#comment-13917673 ]

Bruce Brouwer commented on LOG4J2-547:
--------------------------------------

It sounds like the log4j team supports keeping this in core. I will put together a patch unless anyone else volunteers.

I'll put the factory methods in LogManager as this being considered part of the core of log4j.
Post by Matt Sicker (JIRA)
Update LoggerStream API
-----------------------
Key: LOG4J2-547
URL: https://issues.apache.org/jira/browse/LOG4J2-547
Project: Log4j 2
Issue Type: Improvement
Components: API
Affects Versions: 2.0-rc1
Reporter: Matt Sicker
Assignee: Ralph Goers
Fix For: 2.0
Attachments: 0001-PrintStream-API-update.patch, Add_caller_info_tests.patch, log4j2-loggerStream.patch
I've got some ideas on how to improve the LoggerStream idea that I added a little while ago. The main thing I'd like to do is extract an interface from it, rename the default implementation to SimpleLoggerStream (part of the SimpleLogger stuff), and allow log4j implementations to specify a different implementation if desired.
In doing this, I'm not sure where specifically I'd prefer the getStream methods to be. Right now, it's in Logger, but really, it could be in LoggerContext instead. I don't think I should be required to get a Logger just to get a LoggerStream.
Now if only the java.io package used interfaces instead of classes. This would be so much easier to design!
--
This message was sent by Atlassian JIRA
(v6.2#6252)
Bruce Brouwer (JIRA)
2014-03-03 03:35:20 UTC
Permalink
[ https://issues.apache.org/jira/browse/LOG4J2-547?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13917712#comment-13917712 ]

Bruce Brouwer commented on LOG4J2-547:
--------------------------------------

Ok, I need a bit of advice. In LogManager, I get access to a Logger. Is it ok to just cast that to AbstractLogger or is there some better way?
Post by Matt Sicker (JIRA)
Update LoggerStream API
-----------------------
Key: LOG4J2-547
URL: https://issues.apache.org/jira/browse/LOG4J2-547
Project: Log4j 2
Issue Type: Improvement
Components: API
Affects Versions: 2.0-rc1
Reporter: Matt Sicker
Assignee: Ralph Goers
Fix For: 2.0
Attachments: 0001-PrintStream-API-update.patch, Add_caller_info_tests.patch, log4j2-loggerStream.patch
I've got some ideas on how to improve the LoggerStream idea that I added a little while ago. The main thing I'd like to do is extract an interface from it, rename the default implementation to SimpleLoggerStream (part of the SimpleLogger stuff), and allow log4j implementations to specify a different implementation if desired.
In doing this, I'm not sure where specifically I'd prefer the getStream methods to be. Right now, it's in Logger, but really, it could be in LoggerContext instead. I don't think I should be required to get a Logger just to get a LoggerStream.
Now if only the java.io package used interfaces instead of classes. This would be so much easier to design!
--
This message was sent by Atlassian JIRA
(v6.2#6252)
Remko Popma (JIRA)
2014-03-03 04:20:21 UTC
Permalink
[ https://issues.apache.org/jira/browse/LOG4J2-547?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13917734#comment-13917734 ]

Remko Popma commented on LOG4J2-547:
------------------------------------

If you need AbstractLogger functionality that is not in the Logger interface you have little choice but to fail if this is not available... So casting is okay, I think.
Post by Matt Sicker (JIRA)
Update LoggerStream API
-----------------------
Key: LOG4J2-547
URL: https://issues.apache.org/jira/browse/LOG4J2-547
Project: Log4j 2
Issue Type: Improvement
Components: API
Affects Versions: 2.0-rc1
Reporter: Matt Sicker
Assignee: Ralph Goers
Fix For: 2.0
Attachments: 0001-PrintStream-API-update.patch, Add_caller_info_tests.patch, log4j2-loggerStream.patch
I've got some ideas on how to improve the LoggerStream idea that I added a little while ago. The main thing I'd like to do is extract an interface from it, rename the default implementation to SimpleLoggerStream (part of the SimpleLogger stuff), and allow log4j implementations to specify a different implementation if desired.
In doing this, I'm not sure where specifically I'd prefer the getStream methods to be. Right now, it's in Logger, but really, it could be in LoggerContext instead. I don't think I should be required to get a Logger just to get a LoggerStream.
Now if only the java.io package used interfaces instead of classes. This would be so much easier to design!
--
This message was sent by Atlassian JIRA
(v6.2#6252)
Bruce Brouwer (JIRA)
2014-03-16 23:28:42 UTC
Permalink
[ https://issues.apache.org/jira/browse/LOG4J2-547?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Bruce Brouwer updated LOG4J2-547:
---------------------------------

Attachment: log4j2-547-bbrouwer.patch

Here is my solution to LoggerStream (log4j2-547-bbrouwer.patch). It includes logger versions of InputStream, BufferedInputStream, Reader, BufferedReader, OutputStream, PrintStream, Writer and PrintWriter.

Something missing from the current LoggerPrintStream is that it cannot handle character sets other than the default system character set. In this patch, InputStream, BufferedInputStream, OutputStream and PrintStream can all handle any specified character set. Supporting other character sets is the reason for some of the extra complexity in this patch.

Also, because of the wide variety of options for creating them, there are multiple constructors to all of these classes. This goes with the spirit of the corresponding classes in Java where they are created by calling their constructors.

Because of the wide variety of options, this would add a significant amount of new methods on the LogManager interface. I am proposing that we not do that. As directed, I put this in log4j-api, but I want to make one last request that this not be included in log4j-api but rather in a new artifact called log4j-streams. These new classes stand alone on their own and I see little value in adding corresponding factory methods in LogManager for each constructor specified by these classes.

This patch relies on my latest patch in LOG4J2-555 and because of the overlap with some classes in the LOG4J-555 patch, I am not able to cleanly provide a patch that gets rid of LoggerStream and LoggerWriter and the existing printStream and printWriter methods in LogManager. It is my intent that these all be removed should this patch be accepted.
Post by Matt Sicker (JIRA)
Update LoggerStream API
-----------------------
Key: LOG4J2-547
URL: https://issues.apache.org/jira/browse/LOG4J2-547
Project: Log4j 2
Issue Type: Improvement
Components: API
Affects Versions: 2.0-rc1
Reporter: Matt Sicker
Assignee: Ralph Goers
Fix For: 2.0
Attachments: 0001-PrintStream-API-update.patch, Add_caller_info_tests.patch, log4j2-547-bbrouwer.patch, log4j2-loggerStream.patch
I've got some ideas on how to improve the LoggerStream idea that I added a little while ago. The main thing I'd like to do is extract an interface from it, rename the default implementation to SimpleLoggerStream (part of the SimpleLogger stuff), and allow log4j implementations to specify a different implementation if desired.
In doing this, I'm not sure where specifically I'd prefer the getStream methods to be. Right now, it's in Logger, but really, it could be in LoggerContext instead. I don't think I should be required to get a Logger just to get a LoggerStream.
Now if only the java.io package used interfaces instead of classes. This would be so much easier to design!
--
This message was sent by Atlassian JIRA
(v6.2#6252)
Matt Sicker (JIRA)
2014-03-17 00:14:43 UTC
Permalink
[ https://issues.apache.org/jira/browse/LOG4J2-547?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13937381#comment-13937381 ]

Matt Sicker commented on LOG4J2-547:
------------------------------------

Thanks for reminding me. I added the unit tests. Bruce, could you add a couple tests to {{log4j-core/src/test/java/org/apache/logging/log4j/core/pattern/CallerInformationTest.java}} to verify caller information correctness?
Post by Matt Sicker (JIRA)
Update LoggerStream API
-----------------------
Key: LOG4J2-547
URL: https://issues.apache.org/jira/browse/LOG4J2-547
Project: Log4j 2
Issue Type: Improvement
Components: API
Affects Versions: 2.0-rc1
Reporter: Matt Sicker
Assignee: Ralph Goers
Fix For: 2.0
Attachments: 0001-PrintStream-API-update.patch, log4j2-547-bbrouwer.patch, log4j2-loggerStream.patch
I've got some ideas on how to improve the LoggerStream idea that I added a little while ago. The main thing I'd like to do is extract an interface from it, rename the default implementation to SimpleLoggerStream (part of the SimpleLogger stuff), and allow log4j implementations to specify a different implementation if desired.
In doing this, I'm not sure where specifically I'd prefer the getStream methods to be. Right now, it's in Logger, but really, it could be in LoggerContext instead. I don't think I should be required to get a Logger just to get a LoggerStream.
Now if only the java.io package used interfaces instead of classes. This would be so much easier to design!
--
This message was sent by Atlassian JIRA
(v6.2#6252)
Matt Sicker (JIRA)
2014-03-17 00:14:44 UTC
Permalink
[ https://issues.apache.org/jira/browse/LOG4J2-547?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Matt Sicker updated LOG4J2-547:
-------------------------------

Attachment: (was: Add_caller_info_tests.patch)
Post by Matt Sicker (JIRA)
Update LoggerStream API
-----------------------
Key: LOG4J2-547
URL: https://issues.apache.org/jira/browse/LOG4J2-547
Project: Log4j 2
Issue Type: Improvement
Components: API
Affects Versions: 2.0-rc1
Reporter: Matt Sicker
Assignee: Ralph Goers
Fix For: 2.0
Attachments: 0001-PrintStream-API-update.patch, log4j2-547-bbrouwer.patch, log4j2-loggerStream.patch
I've got some ideas on how to improve the LoggerStream idea that I added a little while ago. The main thing I'd like to do is extract an interface from it, rename the default implementation to SimpleLoggerStream (part of the SimpleLogger stuff), and allow log4j implementations to specify a different implementation if desired.
In doing this, I'm not sure where specifically I'd prefer the getStream methods to be. Right now, it's in Logger, but really, it could be in LoggerContext instead. I don't think I should be required to get a Logger just to get a LoggerStream.
Now if only the java.io package used interfaces instead of classes. This would be so much easier to design!
--
This message was sent by Atlassian JIRA
(v6.2#6252)
Bruce Brouwer (JIRA)
2014-03-22 01:18:43 UTC
Permalink
[ https://issues.apache.org/jira/browse/LOG4J2-547?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13943823#comment-13943823 ]

Bruce Brouwer commented on LOG4J2-547:
--------------------------------------

So, I put all this stream stuff in package {{org.apache.logging.log4j.streams}} inside the log4j-api project. It seems awkward to me to put these tests inside log4j-core when the code it is testing is inside log4j-api. To me, it seems like another reason to pull this into its own artifact called log4j-streams. This way there is nothing related to these streams in log4j-api, and the log4j-streams artifact could pull in log4j-core as a test dependency for the purpose of making this caller information test.

I'm going to make some separate caller-info test classes inside log4j-core, but in the {{org.apache.logging.log4j.streams}} package (not {{org.apache.logging.log4j.*core*.streams}}) just so we can look at what we are talking about, but I don't expect things to stay where they are represented in my next patch.
Post by Matt Sicker (JIRA)
Update LoggerStream API
-----------------------
Key: LOG4J2-547
URL: https://issues.apache.org/jira/browse/LOG4J2-547
Project: Log4j 2
Issue Type: Improvement
Components: API
Affects Versions: 2.0-rc1
Reporter: Matt Sicker
Assignee: Ralph Goers
Fix For: 2.0
Attachments: 0001-PrintStream-API-update.patch, log4j2-547-bbrouwer.patch, log4j2-loggerStream.patch
I've got some ideas on how to improve the LoggerStream idea that I added a little while ago. The main thing I'd like to do is extract an interface from it, rename the default implementation to SimpleLoggerStream (part of the SimpleLogger stuff), and allow log4j implementations to specify a different implementation if desired.
In doing this, I'm not sure where specifically I'd prefer the getStream methods to be. Right now, it's in Logger, but really, it could be in LoggerContext instead. I don't think I should be required to get a Logger just to get a LoggerStream.
Now if only the java.io package used interfaces instead of classes. This would be so much easier to design!
--
This message was sent by Atlassian JIRA
(v6.2#6252)
Bruce Brouwer (JIRA)
2014-03-23 02:45:44 UTC
Permalink
[ https://issues.apache.org/jira/browse/LOG4J2-547?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13944312#comment-13944312 ]

Bruce Brouwer commented on LOG4J2-547:
--------------------------------------

It was definitely a good call to write these tests. I'm running into all kinds of trouble. The various InputStream and Reader tests were easy to fix, but I'm struggling to see what should be done with PrintStream. Check out this call stack:

{code}
LoggerPrintStream.write(byte[], int, int) line: 113
StreamEncoder.writeBytes() line: 221 [local variables unavailable]
StreamEncoder.implFlushBuffer() line: 291 [local variables unavailable]
StreamEncoder.flushBuffer() line: 104 [local variables unavailable]
OutputStreamWriter.flushBuffer() line: 185 [local variables unavailable]
LoggerPrintStream(PrintStream).write(char[]) line: 505
LoggerPrintStream(PrintStream).print(char[]) line: 653
LoggerPrintStream.print(char[]) line: 158
LoggerPrintStream(PrintStream).println(char[]) line: 792
LoggerPrintStream.println(char[]) line: 208
LoggerPrintStreamCallerInfoTest.print_chararray() line: 74
{code}

The FQCN logic trips up pretty quickly as it looks at that top element, which is the FQCN it is looking for, so it return the next item down in the call stack, which is {{sun.nio.cs.StreamEncoder}}. The only thing I can think of to make this work is to go back to the way this was before I started messing around with this and LoggerPrintStream simply delegates to another PrintStream.

Should this delegate mechanism be what we use for all of these streams?
Post by Matt Sicker (JIRA)
Update LoggerStream API
-----------------------
Key: LOG4J2-547
URL: https://issues.apache.org/jira/browse/LOG4J2-547
Project: Log4j 2
Issue Type: Improvement
Components: API
Affects Versions: 2.0-rc1
Reporter: Matt Sicker
Assignee: Ralph Goers
Fix For: 2.0
Attachments: 0001-PrintStream-API-update.patch, log4j2-547-bbrouwer.patch, log4j2-loggerStream.patch
I've got some ideas on how to improve the LoggerStream idea that I added a little while ago. The main thing I'd like to do is extract an interface from it, rename the default implementation to SimpleLoggerStream (part of the SimpleLogger stuff), and allow log4j implementations to specify a different implementation if desired.
In doing this, I'm not sure where specifically I'd prefer the getStream methods to be. Right now, it's in Logger, but really, it could be in LoggerContext instead. I don't think I should be required to get a Logger just to get a LoggerStream.
Now if only the java.io package used interfaces instead of classes. This would be so much easier to design!
--
This message was sent by Atlassian JIRA
(v6.2#6252)
Remko Popma (JIRA)
2014-03-23 03:04:43 UTC
Permalink
[ https://issues.apache.org/jira/browse/LOG4J2-547?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13944313#comment-13944313 ]

Remko Popma commented on LOG4J2-547:
------------------------------------

Interesting. This looks like a problem in the stack trace-walking logic to me: it ignores the possibility that the FQCN appears multiple times and assumes the first hit is the correct one. If the strack trace-walking logic were to read _bottom-up_ it would correctly return {{LoggerPrintStreamCallerInfoTest.print_chararray() line: 74}} as the location, no?
Post by Matt Sicker (JIRA)
Update LoggerStream API
-----------------------
Key: LOG4J2-547
URL: https://issues.apache.org/jira/browse/LOG4J2-547
Project: Log4j 2
Issue Type: Improvement
Components: API
Affects Versions: 2.0-rc1
Reporter: Matt Sicker
Assignee: Ralph Goers
Fix For: 2.0
Attachments: 0001-PrintStream-API-update.patch, log4j2-547-bbrouwer.patch, log4j2-loggerStream.patch
I've got some ideas on how to improve the LoggerStream idea that I added a little while ago. The main thing I'd like to do is extract an interface from it, rename the default implementation to SimpleLoggerStream (part of the SimpleLogger stuff), and allow log4j implementations to specify a different implementation if desired.
In doing this, I'm not sure where specifically I'd prefer the getStream methods to be. Right now, it's in Logger, but really, it could be in LoggerContext instead. I don't think I should be required to get a Logger just to get a LoggerStream.
Now if only the java.io package used interfaces instead of classes. This would be so much easier to design!
--
This message was sent by Atlassian JIRA
(v6.2#6252)
Bruce Brouwer (JIRA)
2014-03-23 03:46:44 UTC
Permalink
[ https://issues.apache.org/jira/browse/LOG4J2-547?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13944321#comment-13944321 ]

Bruce Brouwer commented on LOG4J2-547:
--------------------------------------

Yes, walking bottom-up would definitely solve this problem and would work in probably 99% of cases. One cost, though, that I can think of is that usually the entry we are looking for is usually closest to the top of the stack trace, not the bottom. So there might be a performance hit in the bottom-up approach.

Also, in this case, I could theoretically pass a a LoggerPrintStream wrapping a FilterOutputStream wrapping another LoggerPrintStream. I have no idea why anyone would do that, but in this situation, the top down approach would be the only way that could identify the correct caller info.

I'm not prepared to advocate for switching to a bottom-up approach, but if you thought it was best, I would be in support of it.

If, we don't go for bottom-up, then I'll have to switch this to a delegating pattern, rather than simply subclassing PrintWriter.
Post by Matt Sicker (JIRA)
Update LoggerStream API
-----------------------
Key: LOG4J2-547
URL: https://issues.apache.org/jira/browse/LOG4J2-547
Project: Log4j 2
Issue Type: Improvement
Components: API
Affects Versions: 2.0-rc1
Reporter: Matt Sicker
Assignee: Ralph Goers
Fix For: 2.0
Attachments: 0001-PrintStream-API-update.patch, log4j2-547-bbrouwer.patch, log4j2-loggerStream.patch
I've got some ideas on how to improve the LoggerStream idea that I added a little while ago. The main thing I'd like to do is extract an interface from it, rename the default implementation to SimpleLoggerStream (part of the SimpleLogger stuff), and allow log4j implementations to specify a different implementation if desired.
In doing this, I'm not sure where specifically I'd prefer the getStream methods to be. Right now, it's in Logger, but really, it could be in LoggerContext instead. I don't think I should be required to get a Logger just to get a LoggerStream.
Now if only the java.io package used interfaces instead of classes. This would be so much easier to design!
--
This message was sent by Atlassian JIRA
(v6.2#6252)
Remko Popma (JIRA)
2014-03-23 04:40:42 UTC
Permalink
[ https://issues.apache.org/jira/browse/LOG4J2-547?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13944333#comment-13944333 ]

Remko Popma commented on LOG4J2-547:
------------------------------------

FYI, this logic lives in [Log4JLogEvent#calcLocation|http://logging.apache.org/log4j/2.x/log4j-core/xref/org/apache/logging/log4j/core/impl/Log4jLogEvent.html#311]; I think the expensive part of this method is the call to {{Thread.currentThread().getStackTrace()}}, and looping over the resulting array to do String comparisons is relatively cheap. So I suspect the performance impact would be minimal. (On the other hand I have seen Spring-based applications with ridiculously deep stack traces, and it does all add up, so you could be right...)

About the corner case of LoggerPrintStream #1 (providing the FQCN) wrapping a FilterOutputStream, wrapping another LoggerPrintStream #2 (also providing an FQCN), wouldn't the stack trace look like the below, so only the bottom-up approach would give correct results?

{code}
LoggerPrintStream.someMethod()
FilterOutputStream.someMethod()
LoggerPrintStream.someMethod()
ApplicationClass_TheCaller.theMethod() <-- the calling class we want to print in location info
{code}
Post by Matt Sicker (JIRA)
Update LoggerStream API
-----------------------
Key: LOG4J2-547
URL: https://issues.apache.org/jira/browse/LOG4J2-547
Project: Log4j 2
Issue Type: Improvement
Components: API
Affects Versions: 2.0-rc1
Reporter: Matt Sicker
Assignee: Ralph Goers
Fix For: 2.0
Attachments: 0001-PrintStream-API-update.patch, log4j2-547-bbrouwer.patch, log4j2-loggerStream.patch
I've got some ideas on how to improve the LoggerStream idea that I added a little while ago. The main thing I'd like to do is extract an interface from it, rename the default implementation to SimpleLoggerStream (part of the SimpleLogger stuff), and allow log4j implementations to specify a different implementation if desired.
In doing this, I'm not sure where specifically I'd prefer the getStream methods to be. Right now, it's in Logger, but really, it could be in LoggerContext instead. I don't think I should be required to get a Logger just to get a LoggerStream.
Now if only the java.io package used interfaces instead of classes. This would be so much easier to design!
--
This message was sent by Atlassian JIRA
(v6.2#6252)
Matt Sicker (JIRA)
2014-03-23 20:26:42 UTC
Permalink
[ https://issues.apache.org/jira/browse/LOG4J2-547?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Matt Sicker updated LOG4J2-547:
-------------------------------

Fix Version/s: (was: 2.0)
2.0-rc2
Post by Matt Sicker (JIRA)
Update LoggerStream API
-----------------------
Key: LOG4J2-547
URL: https://issues.apache.org/jira/browse/LOG4J2-547
Project: Log4j 2
Issue Type: Improvement
Components: API
Affects Versions: 2.0-rc1
Reporter: Matt Sicker
Assignee: Ralph Goers
Fix For: 2.0-rc2
Attachments: 0001-PrintStream-API-update.patch, log4j2-547-bbrouwer.patch, log4j2-loggerStream.patch
I've got some ideas on how to improve the LoggerStream idea that I added a little while ago. The main thing I'd like to do is extract an interface from it, rename the default implementation to SimpleLoggerStream (part of the SimpleLogger stuff), and allow log4j implementations to specify a different implementation if desired.
In doing this, I'm not sure where specifically I'd prefer the getStream methods to be. Right now, it's in Logger, but really, it could be in LoggerContext instead. I don't think I should be required to get a Logger just to get a LoggerStream.
Now if only the java.io package used interfaces instead of classes. This would be so much easier to design!
--
This message was sent by Atlassian JIRA
(v6.2#6252)
Ralph Goers (JIRA)
2014-03-23 22:07:43 UTC
Permalink
[ https://issues.apache.org/jira/browse/LOG4J2-547?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13944603#comment-13944603 ]

Ralph Goers commented on LOG4J2-547:
------------------------------------

I would not be in favor of reversing the processing of the stack. When I was working with the Liferay portal it would have stacks that had hundreds of entries. I am sure that in cases such as this (which I doubt is unusual) I would expect there to be a noticeable hit in performance.

I am still wondering if supporting streams is more trouble than it is worth. I'm tempted to say it should go in some sort of "extras" library. I am at the point where I don't think we can throw everything everybody wants into the main project.
Post by Matt Sicker (JIRA)
Update LoggerStream API
-----------------------
Key: LOG4J2-547
URL: https://issues.apache.org/jira/browse/LOG4J2-547
Project: Log4j 2
Issue Type: Improvement
Components: API
Affects Versions: 2.0-rc1
Reporter: Matt Sicker
Assignee: Ralph Goers
Fix For: 2.0-rc2
Attachments: 0001-PrintStream-API-update.patch, log4j2-547-bbrouwer.patch, log4j2-loggerStream.patch
I've got some ideas on how to improve the LoggerStream idea that I added a little while ago. The main thing I'd like to do is extract an interface from it, rename the default implementation to SimpleLoggerStream (part of the SimpleLogger stuff), and allow log4j implementations to specify a different implementation if desired.
In doing this, I'm not sure where specifically I'd prefer the getStream methods to be. Right now, it's in Logger, but really, it could be in LoggerContext instead. I don't think I should be required to get a Logger just to get a LoggerStream.
Now if only the java.io package used interfaces instead of classes. This would be so much easier to design!
--
This message was sent by Atlassian JIRA
(v6.2#6252)
Matt Sicker (JIRA)
2014-03-23 22:17:42 UTC
Permalink
[ https://issues.apache.org/jira/browse/LOG4J2-547?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13944606#comment-13944606 ]

Matt Sicker commented on LOG4J2-547:
------------------------------------

I'm thirding the +1 for putting this in a separate module such as log4j-stream. I know that I'd find it useful in this shitty framework I have to use at work (ATG, damn Oracle product they don't care about anymore since they bought the company ATG) where plenty of their classes use PrintStream-logging where you provide a PrintStream for various methods or classes to log to (even though they provide a sort of commons-logging style API in the first place!).
Post by Matt Sicker (JIRA)
Update LoggerStream API
-----------------------
Key: LOG4J2-547
URL: https://issues.apache.org/jira/browse/LOG4J2-547
Project: Log4j 2
Issue Type: Improvement
Components: API
Affects Versions: 2.0-rc1
Reporter: Matt Sicker
Assignee: Ralph Goers
Fix For: 2.0-rc2
Attachments: 0001-PrintStream-API-update.patch, log4j2-547-bbrouwer.patch, log4j2-loggerStream.patch
I've got some ideas on how to improve the LoggerStream idea that I added a little while ago. The main thing I'd like to do is extract an interface from it, rename the default implementation to SimpleLoggerStream (part of the SimpleLogger stuff), and allow log4j implementations to specify a different implementation if desired.
In doing this, I'm not sure where specifically I'd prefer the getStream methods to be. Right now, it's in Logger, but really, it could be in LoggerContext instead. I don't think I should be required to get a Logger just to get a LoggerStream.
Now if only the java.io package used interfaces instead of classes. This would be so much easier to design!
--
This message was sent by Atlassian JIRA
(v6.2#6252)
Bruce Brouwer (JIRA)
2014-03-23 22:47:42 UTC
Permalink
[ https://issues.apache.org/jira/browse/LOG4J2-547?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13944619#comment-13944619 ]

Bruce Brouwer commented on LOG4J2-547:
--------------------------------------

My comments of performance were me remembering the code I saw in {{ClassLoaderContextSelector}}, which I think actually doesn't come into play in this scenario. So, it probably is as simple as getting the stack trace (the expensive part) and iterating over the list doing a few string comparisons (maybe a few hundred). Would it help if I made a little performance test comparison?

As for my comment about top-down being more technically correct, I was thinking that in the short stack trace example that Remko outlined, I think the top LoggerPrintStream should report its caller as {{FilterOutputStream.someMethod()}}, not {{ApplicationClass_TheCaller.theMethod()}}. However, in probably 90%+ of cases, the more useful caller to report would be {{ApplicationClass_TheCaller.theMethod()}}, which would be discovered by the bottom-up approach. It's an interesting edge case, but probably not worth worrying about.
Post by Matt Sicker (JIRA)
Update LoggerStream API
-----------------------
Key: LOG4J2-547
URL: https://issues.apache.org/jira/browse/LOG4J2-547
Project: Log4j 2
Issue Type: Improvement
Components: API
Affects Versions: 2.0-rc1
Reporter: Matt Sicker
Assignee: Ralph Goers
Fix For: 2.0-rc2
Attachments: 0001-PrintStream-API-update.patch, log4j2-547-bbrouwer.patch, log4j2-loggerStream.patch
I've got some ideas on how to improve the LoggerStream idea that I added a little while ago. The main thing I'd like to do is extract an interface from it, rename the default implementation to SimpleLoggerStream (part of the SimpleLogger stuff), and allow log4j implementations to specify a different implementation if desired.
In doing this, I'm not sure where specifically I'd prefer the getStream methods to be. Right now, it's in Logger, but really, it could be in LoggerContext instead. I don't think I should be required to get a Logger just to get a LoggerStream.
Now if only the java.io package used interfaces instead of classes. This would be so much easier to design!
--
This message was sent by Atlassian JIRA
(v6.2#6252)
Bruce Brouwer (JIRA)
2014-03-24 00:56:43 UTC
Permalink
[ https://issues.apache.org/jira/browse/LOG4J2-547?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Bruce Brouwer updated LOG4J2-547:
---------------------------------

Attachment: PerfTestCalcLocation.java

I decided to run a quick performance test. You can see the tester code in {{PerfTestCalcLocation.java}}, which I attached. The alternate {{calcLocation}} code I wrote looks like this (which is actually much simpler than the current code:

{code}
public static StackTraceElement calcLocation2(final String fqcnOfLogger) {
if (fqcnOfLogger == null) {
return null;
}
final StackTraceElement[] stackTrace = Thread.currentThread().getStackTrace();

// start 2 below, just in case the last entry happens to match the FQCN
for (int i = stackTrace.length - 2; i >= 0; i--) {
if (fqcnOfLogger.equals(stackTrace[i].getClassName())) {
return stackTrace[i + 1];
}
}
return null;
}
{code}

And here are the performance results:
{code}
10 deep: Top-down: 83653 ops/sec, bottom-up: 86745 ops/sec, -3.5644684% slower
50 deep: Top-down: 24557 ops/sec, bottom-up: 24033 ops/sec, 2.180336% slower
100 deep: Top-down: 12854 ops/sec, bottom-up: 12927 ops/sec, -0.5647125% slower
200 deep: Top-down: 6640 ops/sec, bottom-up: 6640 ops/sec, 0.0% slower
500 deep: Top-down: 2623 ops/sec, bottom-up: 2630 ops/sec, -0.26615906% slower
{code}

It appears that the direction we traverse the stack trace has negligible impact on the performance, no matter how deep the stack trace. I've never seen the results go above 3% slower over multiple runs, and often, it shows it going faster.

So if performance is the only concern, I kind of like the idea of switching to the bottom-up approach.
Post by Matt Sicker (JIRA)
Update LoggerStream API
-----------------------
Key: LOG4J2-547
URL: https://issues.apache.org/jira/browse/LOG4J2-547
Project: Log4j 2
Issue Type: Improvement
Components: API
Affects Versions: 2.0-rc1
Reporter: Matt Sicker
Assignee: Ralph Goers
Fix For: 2.0-rc2
Attachments: 0001-PrintStream-API-update.patch, PerfTestCalcLocation.java, log4j2-547-bbrouwer.patch, log4j2-loggerStream.patch
I've got some ideas on how to improve the LoggerStream idea that I added a little while ago. The main thing I'd like to do is extract an interface from it, rename the default implementation to SimpleLoggerStream (part of the SimpleLogger stuff), and allow log4j implementations to specify a different implementation if desired.
In doing this, I'm not sure where specifically I'd prefer the getStream methods to be. Right now, it's in Logger, but really, it could be in LoggerContext instead. I don't think I should be required to get a Logger just to get a LoggerStream.
Now if only the java.io package used interfaces instead of classes. This would be so much easier to design!
--
This message was sent by Atlassian JIRA
(v6.2#6252)
Remko Popma (JIRA)
2014-03-24 01:14:45 UTC
Permalink
[ https://issues.apache.org/jira/browse/LOG4J2-547?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13944679#comment-13944679 ]

Remko Popma commented on LOG4J2-547:
------------------------------------

Micro-benchmarks can be tricky stuff. Do you get the same results if you first measure bottom-up, then top-down? Or start with recurse(500), and work down to recurse(100)?

Things that make it tricky:
* avoid measuring during the first 3-10 seconds after the JVM started, as JVM initialization is still taking place in parallel
* Hotspot will compile "hot" code to native code. The default threshold is after 10,000 invocations. So in the example this will happen sometime while you are measuring.
* During compilation, hotspot will look at places to optimize. The loop can be unrolled, and statements in the loop re-ordered. If hotspot determines the code has no side-effects (doesn't change any state) and doesn't return a value, it may decide to optimize by simply not executing that code... Same results, but a lot faster. :-)

If you have time, please take a look at [JMH|http://openjdk.java.net/projects/code-tools/jmh/].
JHM is specifically designed to avoid these and other pitfalls.
Post by Matt Sicker (JIRA)
Update LoggerStream API
-----------------------
Key: LOG4J2-547
URL: https://issues.apache.org/jira/browse/LOG4J2-547
Project: Log4j 2
Issue Type: Improvement
Components: API
Affects Versions: 2.0-rc1
Reporter: Matt Sicker
Assignee: Ralph Goers
Fix For: 2.0-rc2
Attachments: 0001-PrintStream-API-update.patch, PerfTestCalcLocation.java, log4j2-547-bbrouwer.patch, log4j2-loggerStream.patch
I've got some ideas on how to improve the LoggerStream idea that I added a little while ago. The main thing I'd like to do is extract an interface from it, rename the default implementation to SimpleLoggerStream (part of the SimpleLogger stuff), and allow log4j implementations to specify a different implementation if desired.
In doing this, I'm not sure where specifically I'd prefer the getStream methods to be. Right now, it's in Logger, but really, it could be in LoggerContext instead. I don't think I should be required to get a Logger just to get a LoggerStream.
Now if only the java.io package used interfaces instead of classes. This would be so much easier to design!
--
This message was sent by Atlassian JIRA
(v6.2#6252)
Bruce Brouwer (JIRA)
2014-03-24 03:13:42 UTC
Permalink
[ https://issues.apache.org/jira/browse/LOG4J2-547?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Bruce Brouwer updated LOG4J2-547:
---------------------------------

Attachment: MyBenchmark.java

I took a stab at JMH. When I pulled out the code that actually takes the stack trace (using a pre-generated stack trace) and left only the iterating code, it shows the current code to be *much* faster. However, when you throw in the generation of the stack trace, it looks like it becomes inconsequential. Here are the results for a stack trace that is 200 entries deep.
{code}
Benchmark Mode Samples Mean Mean error Units
o.s.MyBenchmark.bottomUp thrpt 200 6.923 0.036 ops/ms
o.s.MyBenchmark.topDown thrpt 200 6.913 0.034 ops/ms
{code}
I've attached the benchmark code, too as {{MyBenchmark.java}}. This could be skewed somewhat as part of this time is spent making a recursive call of 208 methods deep just to make the call to build the stack trace, but I wasn't coming up with a better way to generate the stack trace and have it be part of the benchmark results.
Post by Matt Sicker (JIRA)
Update LoggerStream API
-----------------------
Key: LOG4J2-547
URL: https://issues.apache.org/jira/browse/LOG4J2-547
Project: Log4j 2
Issue Type: Improvement
Components: API
Affects Versions: 2.0-rc1
Reporter: Matt Sicker
Assignee: Ralph Goers
Fix For: 2.0-rc2
Attachments: 0001-PrintStream-API-update.patch, MyBenchmark.java, PerfTestCalcLocation.java, log4j2-547-bbrouwer.patch, log4j2-loggerStream.patch
I've got some ideas on how to improve the LoggerStream idea that I added a little while ago. The main thing I'd like to do is extract an interface from it, rename the default implementation to SimpleLoggerStream (part of the SimpleLogger stuff), and allow log4j implementations to specify a different implementation if desired.
In doing this, I'm not sure where specifically I'd prefer the getStream methods to be. Right now, it's in Logger, but really, it could be in LoggerContext instead. I don't think I should be required to get a Logger just to get a LoggerStream.
Now if only the java.io package used interfaces instead of classes. This would be so much easier to design!
--
This message was sent by Atlassian JIRA
(v6.2#6252)
Bruce Brouwer (JIRA)
2014-03-26 02:32:15 UTC
Permalink
[ https://issues.apache.org/jira/browse/LOG4J2-547?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Bruce Brouwer updated LOG4J2-547:
---------------------------------

Attachment: log4j2-547-remove-streams.patch

Perhaps we can agree to at least remove the streaming stuff from log4j-api. This way if we can't resolve the streaming solution before 2.0, we at least won't have it in the API where it will have to be supported forever.
Post by Matt Sicker (JIRA)
Update LoggerStream API
-----------------------
Key: LOG4J2-547
URL: https://issues.apache.org/jira/browse/LOG4J2-547
Project: Log4j 2
Issue Type: Improvement
Components: API
Affects Versions: 2.0-rc1
Reporter: Matt Sicker
Assignee: Ralph Goers
Fix For: 2.0-rc2
Attachments: 0001-PrintStream-API-update.patch, MyBenchmark.java, PerfTestCalcLocation.java, log4j2-547-bbrouwer.patch, log4j2-547-remove-streams.patch, log4j2-loggerStream.patch
I've got some ideas on how to improve the LoggerStream idea that I added a little while ago. The main thing I'd like to do is extract an interface from it, rename the default implementation to SimpleLoggerStream (part of the SimpleLogger stuff), and allow log4j implementations to specify a different implementation if desired.
In doing this, I'm not sure where specifically I'd prefer the getStream methods to be. Right now, it's in Logger, but really, it could be in LoggerContext instead. I don't think I should be required to get a Logger just to get a LoggerStream.
Now if only the java.io package used interfaces instead of classes. This would be so much easier to design!
--
This message was sent by Atlassian JIRA
(v6.2#6252)
Bruce Brouwer (JIRA)
2014-04-14 02:44:15 UTC
Permalink
[ https://issues.apache.org/jira/browse/LOG4J2-547?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Bruce Brouwer updated LOG4J2-547:
---------------------------------

Attachment: log4j2-547-new-module.patch

I've added log4j2-547-new-module.patch. It makes a new module called log4j-streams. It also changes the direction of looking for FQCN. It also includes tests to show that FQCN works for the streams. As I cannot create a branch, I'm providing this patch. You can decide how to apply this patch, either as a branch or into trunk.
Post by Matt Sicker (JIRA)
Update LoggerStream API
-----------------------
Key: LOG4J2-547
URL: https://issues.apache.org/jira/browse/LOG4J2-547
Project: Log4j 2
Issue Type: Improvement
Components: API
Affects Versions: 2.0-rc1
Reporter: Matt Sicker
Assignee: Ralph Goers
Fix For: 2.0-rc2
Attachments: 0001-PrintStream-API-update.patch, MyBenchmark.java, PerfTestCalcLocation.java, log4j2-547-bbrouwer.patch, log4j2-547-new-module.patch, log4j2-547-remove-streams.patch, log4j2-loggerStream.patch
I've got some ideas on how to improve the LoggerStream idea that I added a little while ago. The main thing I'd like to do is extract an interface from it, rename the default implementation to SimpleLoggerStream (part of the SimpleLogger stuff), and allow log4j implementations to specify a different implementation if desired.
In doing this, I'm not sure where specifically I'd prefer the getStream methods to be. Right now, it's in Logger, but really, it could be in LoggerContext instead. I don't think I should be required to get a Logger just to get a LoggerStream.
Now if only the java.io package used interfaces instead of classes. This would be so much easier to design!
--
This message was sent by Atlassian JIRA
(v6.2#6252)
Matt Sicker (JIRA)
2014-04-15 03:47:16 UTC
Permalink
[ https://issues.apache.org/jira/browse/LOG4J2-547?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13969191#comment-13969191 ]

Matt Sicker commented on LOG4J2-547:
------------------------------------

Added in r1587396.
Post by Matt Sicker (JIRA)
Update LoggerStream API
-----------------------
Key: LOG4J2-547
URL: https://issues.apache.org/jira/browse/LOG4J2-547
Project: Log4j 2
Issue Type: Improvement
Components: API
Affects Versions: 2.0-rc1
Reporter: Matt Sicker
Assignee: Ralph Goers
Fix For: 2.0-rc2
Attachments: 0001-PrintStream-API-update.patch, MyBenchmark.java, PerfTestCalcLocation.java, log4j2-547-bbrouwer.patch, log4j2-547-new-module.patch, log4j2-547-remove-streams.patch, log4j2-loggerStream.patch
I've got some ideas on how to improve the LoggerStream idea that I added a little while ago. The main thing I'd like to do is extract an interface from it, rename the default implementation to SimpleLoggerStream (part of the SimpleLogger stuff), and allow log4j implementations to specify a different implementation if desired.
In doing this, I'm not sure where specifically I'd prefer the getStream methods to be. Right now, it's in Logger, but really, it could be in LoggerContext instead. I don't think I should be required to get a Logger just to get a LoggerStream.
Now if only the java.io package used interfaces instead of classes. This would be so much easier to design!
--
This message was sent by Atlassian JIRA
(v6.2#6252)
Matt Sicker (JIRA)
2014-04-15 03:49:14 UTC
Permalink
[ https://issues.apache.org/jira/browse/LOG4J2-547?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13969192#comment-13969192 ]

Matt Sicker commented on LOG4J2-547:
------------------------------------

Although I'd recommend creating builders instead of giant constructors, but that's somewhat of a style opinion I guess.
Post by Matt Sicker (JIRA)
Update LoggerStream API
-----------------------
Key: LOG4J2-547
URL: https://issues.apache.org/jira/browse/LOG4J2-547
Project: Log4j 2
Issue Type: Improvement
Components: API
Affects Versions: 2.0-rc1
Reporter: Matt Sicker
Assignee: Ralph Goers
Fix For: 2.0-rc2
Attachments: 0001-PrintStream-API-update.patch, MyBenchmark.java, PerfTestCalcLocation.java, log4j2-547-bbrouwer.patch, log4j2-547-new-module.patch, log4j2-547-remove-streams.patch, log4j2-loggerStream.patch
I've got some ideas on how to improve the LoggerStream idea that I added a little while ago. The main thing I'd like to do is extract an interface from it, rename the default implementation to SimpleLoggerStream (part of the SimpleLogger stuff), and allow log4j implementations to specify a different implementation if desired.
In doing this, I'm not sure where specifically I'd prefer the getStream methods to be. Right now, it's in Logger, but really, it could be in LoggerContext instead. I don't think I should be required to get a Logger just to get a LoggerStream.
Now if only the java.io package used interfaces instead of classes. This would be so much easier to design!
--
This message was sent by Atlassian JIRA
(v6.2#6252)
Bruce Brouwer (JIRA)
2014-04-17 03:22:16 UTC
Permalink
[ https://issues.apache.org/jira/browse/LOG4J2-547?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Bruce Brouwer updated LOG4J2-547:
---------------------------------

Attachment: log4j2-547-builders-and-more.patch

I like the builder idea too. I was just following the pattern that all other Java related streams take. So I decided to take a stab at it with log4j2-547-builders-and-more.patch.

Also in that patch are some things that I missed originally, so here's what it includes:
* Builders
* Updated log4j-bom to include streams
* Moved helper classes into a .helpers package

I haven't written the tests because I wanted to hear some feedback on the approach.
Post by Matt Sicker (JIRA)
Update LoggerStream API
-----------------------
Key: LOG4J2-547
URL: https://issues.apache.org/jira/browse/LOG4J2-547
Project: Log4j 2
Issue Type: Improvement
Components: API
Affects Versions: 2.0-rc1
Reporter: Matt Sicker
Assignee: Ralph Goers
Fix For: 2.0-rc2
Attachments: 0001-PrintStream-API-update.patch, MyBenchmark.java, PerfTestCalcLocation.java, log4j2-547-bbrouwer.patch, log4j2-547-builders-and-more.patch, log4j2-547-new-module.patch, log4j2-547-remove-streams.patch, log4j2-loggerStream.patch
I've got some ideas on how to improve the LoggerStream idea that I added a little while ago. The main thing I'd like to do is extract an interface from it, rename the default implementation to SimpleLoggerStream (part of the SimpleLogger stuff), and allow log4j implementations to specify a different implementation if desired.
In doing this, I'm not sure where specifically I'd prefer the getStream methods to be. Right now, it's in Logger, but really, it could be in LoggerContext instead. I don't think I should be required to get a Logger just to get a LoggerStream.
Now if only the java.io package used interfaces instead of classes. This would be so much easier to design!
--
This message was sent by Atlassian JIRA
(v6.2#6252)
Bruce Brouwer (JIRA)
2014-04-17 12:12:15 UTC
Permalink
[ https://issues.apache.org/jira/browse/LOG4J2-547?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Bruce Brouwer updated LOG4J2-547:
---------------------------------

Attachment: (was: log4j2-547-builders-and-more.patch)
Post by Matt Sicker (JIRA)
Update LoggerStream API
-----------------------
Key: LOG4J2-547
URL: https://issues.apache.org/jira/browse/LOG4J2-547
Project: Log4j 2
Issue Type: Improvement
Components: API
Affects Versions: 2.0-rc1
Reporter: Matt Sicker
Assignee: Ralph Goers
Fix For: 2.0-rc2
Attachments: 0001-PrintStream-API-update.patch, MyBenchmark.java, PerfTestCalcLocation.java, log4j2-547-bbrouwer.patch, log4j2-547-new-module.patch, log4j2-547-remove-streams.patch, log4j2-loggerStream.patch
I've got some ideas on how to improve the LoggerStream idea that I added a little while ago. The main thing I'd like to do is extract an interface from it, rename the default implementation to SimpleLoggerStream (part of the SimpleLogger stuff), and allow log4j implementations to specify a different implementation if desired.
In doing this, I'm not sure where specifically I'd prefer the getStream methods to be. Right now, it's in Logger, but really, it could be in LoggerContext instead. I don't think I should be required to get a Logger just to get a LoggerStream.
Now if only the java.io package used interfaces instead of classes. This would be so much easier to design!
--
This message was sent by Atlassian JIRA
(v6.2#6252)
Bruce Brouwer (JIRA)
2014-04-17 12:14:16 UTC
Permalink
[ https://issues.apache.org/jira/browse/LOG4J2-547?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13972262#comment-13972262 ]

Bruce Brouwer edited comment on LOG4J2-547 at 4/17/14 12:13 PM:
----------------------------------------------------------------

I like the builder idea too. I was just following the pattern that all other Java related streams take. So I decided to take a stab at it with log4j2-547-builders.patch.

Also in that patch are some things that I missed originally, so here's what it includes:
* LoggerStreams.Builder (and related classes)
* Updated log4j-bom to include streams
* Moved helper classes into a .helpers package

I haven't written the tests because I wanted to hear some feedback on the approach.


was (Author: bruce.brouwer):
I like the builder idea too. I was just following the pattern that all other Java related streams take. So I decided to take a stab at it with log4j2-547-builders-and-more.patch.

Also in that patch are some things that I missed originally, so here's what it includes:
* Builders
* Updated log4j-bom to include streams
* Moved helper classes into a .helpers package

I haven't written the tests because I wanted to hear some feedback on the approach.
Post by Matt Sicker (JIRA)
Update LoggerStream API
-----------------------
Key: LOG4J2-547
URL: https://issues.apache.org/jira/browse/LOG4J2-547
Project: Log4j 2
Issue Type: Improvement
Components: API
Affects Versions: 2.0-rc1
Reporter: Matt Sicker
Assignee: Ralph Goers
Fix For: 2.0-rc2
Attachments: 0001-PrintStream-API-update.patch, MyBenchmark.java, PerfTestCalcLocation.java, log4j2-547-bbrouwer.patch, log4j2-547-builders.patch, log4j2-547-new-module.patch, log4j2-547-remove-streams.patch, log4j2-loggerStream.patch
I've got some ideas on how to improve the LoggerStream idea that I added a little while ago. The main thing I'd like to do is extract an interface from it, rename the default implementation to SimpleLoggerStream (part of the SimpleLogger stuff), and allow log4j implementations to specify a different implementation if desired.
In doing this, I'm not sure where specifically I'd prefer the getStream methods to be. Right now, it's in Logger, but really, it could be in LoggerContext instead. I don't think I should be required to get a Logger just to get a LoggerStream.
Now if only the java.io package used interfaces instead of classes. This would be so much easier to design!
--
This message was sent by Atlassian JIRA
(v6.2#6252)
Bruce Brouwer (JIRA)
2014-04-17 12:14:20 UTC
Permalink
[ https://issues.apache.org/jira/browse/LOG4J2-547?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Bruce Brouwer updated LOG4J2-547:
---------------------------------

Attachment: log4j2-547-builders.patch
Post by Matt Sicker (JIRA)
Update LoggerStream API
-----------------------
Key: LOG4J2-547
URL: https://issues.apache.org/jira/browse/LOG4J2-547
Project: Log4j 2
Issue Type: Improvement
Components: API
Affects Versions: 2.0-rc1
Reporter: Matt Sicker
Assignee: Ralph Goers
Fix For: 2.0-rc2
Attachments: 0001-PrintStream-API-update.patch, MyBenchmark.java, PerfTestCalcLocation.java, log4j2-547-bbrouwer.patch, log4j2-547-builders.patch, log4j2-547-new-module.patch, log4j2-547-remove-streams.patch, log4j2-loggerStream.patch
I've got some ideas on how to improve the LoggerStream idea that I added a little while ago. The main thing I'd like to do is extract an interface from it, rename the default implementation to SimpleLoggerStream (part of the SimpleLogger stuff), and allow log4j implementations to specify a different implementation if desired.
In doing this, I'm not sure where specifically I'd prefer the getStream methods to be. Right now, it's in Logger, but really, it could be in LoggerContext instead. I don't think I should be required to get a Logger just to get a LoggerStream.
Now if only the java.io package used interfaces instead of classes. This would be so much easier to design!
--
This message was sent by Atlassian JIRA
(v6.2#6252)
Matt Sicker (JIRA)
2014-04-20 17:28:14 UTC
Permalink
[ https://issues.apache.org/jira/browse/LOG4J2-547?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13975202#comment-13975202 ]

Matt Sicker commented on LOG4J2-547:
------------------------------------

Added in revision 1588797 on the experimental branch.
Post by Matt Sicker (JIRA)
Update LoggerStream API
-----------------------
Key: LOG4J2-547
URL: https://issues.apache.org/jira/browse/LOG4J2-547
Project: Log4j 2
Issue Type: Improvement
Components: API
Affects Versions: 2.0-rc1
Reporter: Matt Sicker
Assignee: Ralph Goers
Fix For: 2.0-rc2
Attachments: 0001-PrintStream-API-update.patch, MyBenchmark.java, PerfTestCalcLocation.java, log4j2-547-bbrouwer.patch, log4j2-547-builders.patch, log4j2-547-new-module.patch, log4j2-547-remove-streams.patch, log4j2-loggerStream.patch
I've got some ideas on how to improve the LoggerStream idea that I added a little while ago. The main thing I'd like to do is extract an interface from it, rename the default implementation to SimpleLoggerStream (part of the SimpleLogger stuff), and allow log4j implementations to specify a different implementation if desired.
In doing this, I'm not sure where specifically I'd prefer the getStream methods to be. Right now, it's in Logger, but really, it could be in LoggerContext instead. I don't think I should be required to get a Logger just to get a LoggerStream.
Now if only the java.io package used interfaces instead of classes. This would be so much easier to design!
--
This message was sent by Atlassian JIRA
(v6.2#6252)
Matt Sicker (JIRA)
2014-05-04 23:27:16 UTC
Permalink
[ https://issues.apache.org/jira/browse/LOG4J2-547?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Matt Sicker updated LOG4J2-547:
-------------------------------

Fix Version/s: (was: 2.0-rc2)
2.1
Post by Matt Sicker (JIRA)
Update LoggerStream API
-----------------------
Key: LOG4J2-547
URL: https://issues.apache.org/jira/browse/LOG4J2-547
Project: Log4j 2
Issue Type: Improvement
Components: API
Affects Versions: 2.0-rc1
Reporter: Matt Sicker
Assignee: Ralph Goers
Fix For: 2.1
Attachments: 0001-PrintStream-API-update.patch, MyBenchmark.java, PerfTestCalcLocation.java, log4j2-547-bbrouwer.patch, log4j2-547-builders.patch, log4j2-547-new-module.patch, log4j2-547-remove-streams.patch, log4j2-loggerStream.patch
I've got some ideas on how to improve the LoggerStream idea that I added a little while ago. The main thing I'd like to do is extract an interface from it, rename the default implementation to SimpleLoggerStream (part of the SimpleLogger stuff), and allow log4j implementations to specify a different implementation if desired.
In doing this, I'm not sure where specifically I'd prefer the getStream methods to be. Right now, it's in Logger, but really, it could be in LoggerContext instead. I don't think I should be required to get a Logger just to get a LoggerStream.
Now if only the java.io package used interfaces instead of classes. This would be so much easier to design!
--
This message was sent by Atlassian JIRA
(v6.2#6252)
Remko Popma (JIRA)
2014-09-16 23:14:35 UTC
Permalink
[ https://issues.apache.org/jira/browse/LOG4J2-547?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14136472#comment-14136472 ]

Remko Popma commented on LOG4J2-547:
------------------------------------

This module is now merged into master but still needs some documentation.
Post by Matt Sicker (JIRA)
Update LoggerStream API
-----------------------
Key: LOG4J2-547
URL: https://issues.apache.org/jira/browse/LOG4J2-547
Project: Log4j 2
Issue Type: Improvement
Components: API
Affects Versions: 2.0-rc1
Reporter: Matt Sicker
Assignee: Ralph Goers
Fix For: 2.1
Attachments: 0001-PrintStream-API-update.patch, MyBenchmark.java, PerfTestCalcLocation.java, log4j2-547-bbrouwer.patch, log4j2-547-builders.patch, log4j2-547-new-module.patch, log4j2-547-remove-streams.patch, log4j2-loggerStream.patch
I've got some ideas on how to improve the LoggerStream idea that I added a little while ago. The main thing I'd like to do is extract an interface from it, rename the default implementation to SimpleLoggerStream (part of the SimpleLogger stuff), and allow log4j implementations to specify a different implementation if desired.
In doing this, I'm not sure where specifically I'd prefer the getStream methods to be. Right now, it's in Logger, but really, it could be in LoggerContext instead. I don't think I should be required to get a Logger just to get a LoggerStream.
Now if only the java.io package used interfaces instead of classes. This would be so much easier to design!
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)
Matt Sicker (JIRA)
2014-09-18 22:57:35 UTC
Permalink
[ https://issues.apache.org/jira/browse/LOG4J2-547?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Matt Sicker resolved LOG4J2-547.
--------------------------------
Resolution: Fixed
Assignee: Matt Sicker (was: Ralph Goers)

Implemented in 2.1.
Post by Matt Sicker (JIRA)
Update LoggerStream API
-----------------------
Key: LOG4J2-547
URL: https://issues.apache.org/jira/browse/LOG4J2-547
Project: Log4j 2
Issue Type: Improvement
Components: API
Affects Versions: 2.0-rc1
Reporter: Matt Sicker
Assignee: Matt Sicker
Fix For: 2.1
Attachments: 0001-PrintStream-API-update.patch, MyBenchmark.java, PerfTestCalcLocation.java, log4j2-547-bbrouwer.patch, log4j2-547-builders.patch, log4j2-547-new-module.patch, log4j2-547-remove-streams.patch, log4j2-loggerStream.patch
I've got some ideas on how to improve the LoggerStream idea that I added a little while ago. The main thing I'd like to do is extract an interface from it, rename the default implementation to SimpleLoggerStream (part of the SimpleLogger stuff), and allow log4j implementations to specify a different implementation if desired.
In doing this, I'm not sure where specifically I'd prefer the getStream methods to be. Right now, it's in Logger, but really, it could be in LoggerContext instead. I don't think I should be required to get a Logger just to get a LoggerStream.
Now if only the java.io package used interfaces instead of classes. This would be so much easier to design!
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)
Matt Sicker (JIRA)
2014-09-18 22:58:34 UTC
Permalink
[ https://issues.apache.org/jira/browse/LOG4J2-547?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Matt Sicker closed LOG4J2-547.
------------------------------
Post by Matt Sicker (JIRA)
Update LoggerStream API
-----------------------
Key: LOG4J2-547
URL: https://issues.apache.org/jira/browse/LOG4J2-547
Project: Log4j 2
Issue Type: Improvement
Components: API
Affects Versions: 2.0-rc1
Reporter: Matt Sicker
Assignee: Matt Sicker
Fix For: 2.1
Attachments: 0001-PrintStream-API-update.patch, MyBenchmark.java, PerfTestCalcLocation.java, log4j2-547-bbrouwer.patch, log4j2-547-builders.patch, log4j2-547-new-module.patch, log4j2-547-remove-streams.patch, log4j2-loggerStream.patch
I've got some ideas on how to improve the LoggerStream idea that I added a little while ago. The main thing I'd like to do is extract an interface from it, rename the default implementation to SimpleLoggerStream (part of the SimpleLogger stuff), and allow log4j implementations to specify a different implementation if desired.
In doing this, I'm not sure where specifically I'd prefer the getStream methods to be. Right now, it's in Logger, but really, it could be in LoggerContext instead. I don't think I should be required to get a Logger just to get a LoggerStream.
Now if only the java.io package used interfaces instead of classes. This would be so much easier to design!
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Loading...