logging-log4j-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Nick Williams <nicho...@nicholaswilliams.net>
Subject LOG4J2-242 (Fluent Logging)
Date Mon, 29 Jul 2013 20:39:54 GMT
I'm working on LOG4J2-242 to add the ability to log fluently. It's going to work something
like this:

interface Logger:
    + MessageBuilder trace();
    + MessageBuilder debug();
    + MessageBuilder info();
    + MessageBuilder warn();
    + MessageBuilder error();
    + MessageBuilder fatal();
    + MessageBuilder log(Level);

+ interface MessageBuilder:
    message(String);
    message(Object);
    message(String, Object...);
    marker(Marker);
    exception(Throwable);
    argument(Object);
    arguments(Object...);
    log();

Bruce (the requester) had suggested adding the methods that return MessageBuilder to a different
interface (as opposed to Logger) to keep from cluttering the Logger API. The way I see it
our options are:

- Create a FluentLogger interface to house these methods. I don't like this option because
A) it complicates things significantly, B) it makes users have to call a different method
on LogManager (getFluentLogger) to get a FluentLogger, and C) it means users have to have
a Logger and a FluentLogger if they want to use both APIs.

- Create a FluentLogger interface that extends Logger. This option is much better. It avoids
cluttering the Logger API if that's all someone wants to use, it doesn't require someone to
have a Logger and FluentLogger if they want to use both APIs, and it doesn't complicate the
implementation significantly (all implementations can just implement FluentLogger). It does
still mean LogManager (and related classes/interfaces) need getLogger and getFluentLogger
methods, which I don't necessarily like.

- Just add these methods to Logger, which is what I intended to do from the get-go and is
what I still think is the best option.

I'm going to proceed with #3 for now, but if someone has a strong opinion otherwise please
voice it so that we can discuss before I complete this.

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


Mime
View raw message