using InternalLogger in Netty's wrapper
"이희승 (Trustin Lee)"
trustin at gmail.com
Tue Jun 23 05:20:41 EDT 2009
Hi Piotr,
Ideally, all frameworks and libraries could use the same logging
framework (java.util.logging) or facade (like commons-logging or slf4j),
but the reality is some people prefers a particular framework (or even
facade) to others. Therefore, sticking to only one logging framework
will often make your users complain. That's why I wrote a thin logging
layer that is just enough for Netty itself.
For the same reason, I was suggesting you to provide your own logging
layer, but it's up to you. I think using SLF4J is not a bad idea at
all. It's a great facade although it makes some beginners confused and
some people prefers commons logging or just java.util.logging.
However, if you are going to use Netty's logging layer and expose it to
users directly, you are exposing a logger that is optimized for Netty,
not yours. Its behavior is subject to change at any time to serve the
need of Netty itself, not yours. It actually contains some code that is
specific to Netty class names.
I know, in most cases, there will be code duplication and its waste of
time and space, but I think this issue should be addressed in a
different project like code generator or byte code manipulator. Until
then, I'd live with code duplication or just choose SLF4J or commons
logging.
BTW, to change the logging framework in Netty, you can call
InternalLoggerFactory.setDefaultFactory(), and it's absolutely fine. I
did never say that it's prohibited to use InternalLoggerFactory. :)
What's not recommended is to access an InternalLogger, not an
InternalLoggerFactory. So.. your users can call it, too, although it
wouldn't look that beautiful.
HTH,
Trustin
On 2009-06-23 오후 5:50, Piotr Findeisen wrote:
> Hi, Trustin
>
> So should I copy part or the whole Netty's InternalLoggerFactory?
> If I'm going to support logging framework that Netty supports, it would
> mean to copy Netty's code. Well, I very much don't like to copy code --
> this is the reason of my question.
>
> Why InternalLogger is marked as internal? What bad can happen if I use
> it? Maybe it could stop being internal?
> Or -- should I use an external factory that serves similar purpose? I
> haven't used it, but maybe SLF4J does the job?
>
> regards,
> Piotr
>
>
> If you are going to provide a logging layer similar to what Netty
> provides, you could write your own InternalLoggerFactory implementation
> that redirects all logs to your logging layer. It should be trivial to
> implement, and the users will not need to touch InternalLoggerFactory at
> all.
>
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> netty-users mailing list
> netty-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/netty-users
--
— Trustin Lee, http://gleamynode.net/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 258 bytes
Desc: OpenPGP digital signature
Url : http://lists.jboss.org/pipermail/netty-users/attachments/20090623/715fd111/attachment.bin
More information about the netty-users
mailing list