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

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

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