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:
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);
We could also provide ones basically like before:
public Writer writer(Level level);
public Writer writer(Marker marker, Level level);
public OutputStream stream(Level level);
public OutputStream stream(Marker marker, Level level);
Maybe we would keep the PrintWriter/PrintStream variants as well. But then why stop there. We could spy on Readers as well:
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);
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:
Writer writer = LogStreaming.writer(MyExample.class, myWriter, Level.WARNING);
We could go even further and add debug/warn/info/error methods on here as well:
Writer writer = LogStreaming.debugWriter(MyExample.class, myWriter);
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?