[logback-dev] Question about a custom binary file appender.

Maarten Bosteels mbosteels.dns at gmail.com
Fri Apr 24 10:58:04 CEST 2009


What about intrducing the Encoder interface I proposed some weeks ago ?

http://code.google.com/p/firewood/source/browse/trunk/compare-formats/src/main/java/com/googlecode/firewood/encoder

==============================
import java.io.OutputStream;
import java.io.IOException;
import ch.qos.logback.classic.spi.ILoggingEvent;

public interface Encoder <T extends OutputStream>{

  void encode(ILoggingEvent event, T output) throws IOException;

  T decorate(OutputStream os) throws IOException;
}
==============================
import ch.qos.logback.classic.spi.ILoggingEvent;

import java.io.OutputStream;
import java.io.IOException;
import java.io.ObjectOutputStream;

/**
 * Encoder that uses plain Java Serialization
 */
public class ObjectEncoder implements Encoder<ObjectOutputStream> {

  public void encode(ILoggingEvent event, ObjectOutputStream output)
throws IOException {
    output.writeObject(event);
  }

  public ObjectOutputStream decorate(OutputStream os) throws IOException {
    return new ObjectOutputStream(os);
  }
}
=====================================

By the way, Joern, trying out a recent version of Lilith is still on
my todo list.

regards,
Maarten

On Thu, Apr 23, 2009 at 6:38 PM, Joern Huxhorn <jhuxhorn at googlemail.com> wrote:
> Hi Ceki.
>
> I'd like to implement a file appender that writes the binary Lilith
> format, i.e. gzipped protobuf-serialized events, instead of Strings.
> I'd also like to have the same functionality that's supported by
> RollingFileAppender right now.
>
> Unfortunately, there seems to be no way to simply write bytes instead of
> a String. How would you go from here?
> Reimplementing everything from the start seems to be a pretty bad idea.
>
> What do you think about enhancing the RFA so it's using byte[] instead
> of Strings? The current behavior could be implemented using those
> methods + string.getBytes("UTF-8") or CharsetEncoder...
>
> Any idea, suggestions?
>
> Regards,
> Joern.
>
> _______________________________________________
> logback-dev mailing list
> logback-dev at qos.ch
> http://qos.ch/mailman/listinfo/logback-dev
>


More information about the logback-dev mailing list