The two main advantages of Log::Any for me:
- your users don't need to configure anything if they don't want logging. When my module, say Foo, uses Log4perl to produce logs, then when you use Foo, Log4perl will emit a warning:
Log4perl: Seems like no initialization happened. Forgot to call init()?
. To remove this warning you need to initialize Log4perl, e.g. usinguse Log::Log4perl qw(:easy); Log::Log4perl->easy_init($FATAL);
This is annoying if you happen to not care about logging.
With Log::Any, the default is null logging. - printf-style logging. For example,
$log->debugf("data = %s", $data);
It can also handle references/nested data structures, so you don't have to resort to something like$log->debug(sub { "data = " . Dumper($big_data) });
. In fact, 99% of the time I use sub{} is precisely because I want to avoid the cost of dumping.
Of course, there are some features in Log4perl that is missing in Log::Any, like logdie() and the TRACE level. But it is a small price to pay. You gain other benefits, the most important of which is compatibility with other logging frameworks. I'm sure some people prefer something else to Log4perl. Log::Any currently supports Log4perl as well as Log::Dispatch, and possibly others too in the future.
Thanks Jonathan for Log::Any!
Tidak ada komentar:
Posting Komentar
Catatan: Hanya anggota dari blog ini yang dapat mengirim komentar.