logging-log4j-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ralph Goers (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (LOG4J2-481) Stream-Interface for Loggers
Date Sun, 05 Jan 2014 07:53:51 GMT

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

Ralph Goers commented on LOG4J2-481:

This looks better but I still have a couple of questions regarding why/how this is useful:
1. if you do:
LoggerStream stream = logger.getStream(Level.INFO);
stream.print(", ");
then the line number of the location info will be for the call to flush.  If they call println
or simply include a newline then it will be for the print. That seems like it could lead to
2. If the flush is forgotten the data will accumulate until something else calls flush or
a newline is written. This could lead to "odd" behavior.
3. The user could just as easily do:
StringBuilder sb = new StringBuilder();
sb.append(", ");
Why isn't that preferable to using a stream?

> Stream-Interface for Loggers
> ----------------------------
>                 Key: LOG4J2-481
>                 URL: https://issues.apache.org/jira/browse/LOG4J2-481
>             Project: Log4j 2
>          Issue Type: New Feature
>          Components: API
>    Affects Versions: 2.0-beta9
>         Environment: Linux, Java 1.7
>            Reporter: Joe Merten
>         Attachments: Add_PrintStream_view_LOG4J2-481.patch, EventLoggerTest.patch
> I would like to have method (or class) to use a logger as a PrintStream, like e.g.:
> {quote}
> PrintStream Logger.getStream(Level level);
> {quote}
> or maybe like this http://www.java2s.com/Open-Source/Java/Testing/jacareto/jacareto/toolkit/log4j/LogOutputStream.java.htm
> (as I recently discovered, org.apache.commons.exec.LogOutputStream is doing different

This message was sent by Atlassian JIRA

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

View raw message