On 2010-05-16 23:19, Pete Muir wrote:
Mark is right, but it goes deeper than whether there is a logger you
can inject to whether there is a common logging interface for use with CDI - there
isn't as part of CDI itself, and for Weld and Seam we are currently using slf4j as an
abstraction. I would suggest choosing this, and making it a dependency of your extension.
If you want to avoid this, you must use JUL, but that has a horrible API (not just around
serializability, but also the API itself)...
Thanks guys for your replies.
I haven't looked at my interceptor from a performance point of view, but
in performance statistics logger is usually heavy used and it could be a
problem.
Regards
Marcin
On 16 May 2010, at 05:45, Mark Struberg wrote:
> Hoi Marcin!
>
> You'd like to get an honest answer?
>
> You know the old saying with the hammer? "If you have a hammer, every problem
seems to be a nail."
>
> My suggestion: Don't use logger Injection for high performance debug logging at
least.
>
> There is a lot code running inside the NormalScoped proxies MethodHandler, and you
most probably like to lose as little time as possible.
>
> In my projects, I also started with that appproach, but after looking at the
performance (both with Weld and OWB) with my yourkit profiler, we decided to step back and
use classic private static Loggers.
>
> Also, if you use jul.Logger, then you'd be doomed anyway. This beast is not
Serializable, and you also cannot make a Serializable subclass because it's final...
>
> CDI is a huge boost in my projects, but there is no need to use it for each and every
instance creation :)
>
> LieGrue,
> strub
>
> --- On Sat, 5/15/10, Marcin Zajączkowski <mszpak(a)wp.pl> wrote:
>
>> From: Marcin Zajączkowski <mszpak(a)wp.pl>
>> Subject: [weld-dev] How to obtain logger in an interceptor?
>> To: weld-dev(a)lists.jboss.org
>> Date: Saturday, May 15, 2010, 9:33 PM
>> Hi,
>>
>>
>> I am working on a Perf4j [1] integration with CDI/Weld
>> (sister project
>> to Seam-Perf4j [2] which offers integration with Seam
>> 2.2.x). Perf4j
>> heavy uses logger for its performance statistics.
>>
>> I would like to ask is there an unified way in CDI to
>> obtain a logger in
>> an interceptor?
>>
>>
>> In Seam 2.2.x I could get logger with:
>> org.jboss.seam.log.Logging.getLog(loggerName)
>>
>> With Weld I don't want to get Weld logger directly - I
>> would like to be
>> compatible with other CDI implementations as well.
>>
>> I have seen Weld's extension for logging, but it's rather
>> for injection
>> logger into "normal" beans, not to obtain it explicitly in
>> an
>> interceptor (it's a producer which calls
>> LoggerFactory.getLogger() from
>> slf4j which I can do directly).
>>
>>
>> Is it possible to get logger proper for CDI implementation
>> in context
>> which my code is running? Or the best solution would be to
>> use slf4j
>> logger with hope it is already using there?
>>
>>
>> [1] -
http://perf4j.codehaus.org/
>> [2] -
http://seam-perf4j.sourceforge.net/
>>
>>
>> Thanks for your comments
>> Marcin
>> _______________________________________________
>> weld-dev mailing list
>> weld-dev(a)lists.jboss.org
>>
https://lists.jboss.org/mailman/listinfo/weld-dev