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

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

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

Reply via email to