[logback-user] Writing logs to ByteArrayStream programmatically

Dan Filimon dangeorge.filimon at gmail.com
Wed Jan 2 19:20:51 CET 2013


I've been trying for the past couple of hours to log to a
ByteArrayStream that I then convert to String and process.

This is the code I came up with [1], that's sadly not working.

I read an older e-mail about this [2], but I still can't get it working.

I added some asserts to make sure I'm starting the objects properly
and to my surprise the PatternLayoutEncoder's isStarted() method
(actually the one in LayoutWrappingEncoder) always returns false,
despite started being configurable.

And, in any case, even removing the offending assert, I still can't
write anything to the byte stream.
It doesn't output anything now (after I call reset() on the
LoggerContext object), otherwise it prints to the console (I don't
have any config file set up).

What am I doing wrong?


[1] https://gist.github.com/4436581
[2] http://old.nabble.com/Programmatic-configuration-of-OutputStreamAppender-tt34181621.html#a34181738

More information about the Logback-user mailing list