Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails 3.1 built-in logger vs Log4r

What are the major differences between Rails 3 built-in logger and Log4r? It seems to me that Rails 3 logger gives you everything that you need.

like image 569
keruilin Avatar asked Jan 19 '23 01:01

keruilin


1 Answers

Built-in logger is good enough for both development or production environment. especially at the very beginning stages of your project, you don't need to waste time to testing and choose an appropriate tool or library to do the logger job. You can concentrate on the project itself. the simliar situation like "erb" or "haml", "sass" or "less", "coffeescript" or "plain javascript", etc...

Log4r allow you to format your logs easily through configuration file. its a good built-in logger alternator when you real need it.

http://log4r.rubyforge.org/

What Log4r Is

Log4r is a comprehensive and flexible logging library written in Ruby for use in Ruby programs. It features a hierarchical logging system of any number of levels, custom level names, logger inheritance, multiple output destinations, execution tracing, custom formatting, thread safteyness, XML and YAML configuration, and more. Log4r is an adherent to the philosophy of logging using simple print statements. What Log4r adds to this philosophy is a flexible way of controling the information being logged. Log information can be sent to any kind of destination and with varying degrees of importance. Log4r is designed so that logging statements can remain in production code with almost no extra computational cost.

Log4r intends to be easy to use and configure, no matter the complexity. Casual scripts can use Log4r right away with minimal configuration, while more sophisticated applications can set up a structured configuration file in XML or YAML. Comprehensive documentation is provided, with a user's manual, a reference API, and over a dozen examples. Log4r attempts to abide by the Principle of Least Surprise, which means that it works as intended at all points.

Log4r was inspired by and provides much of the features of the Apache Log4j project, but is not a direct implementation or clone. Aside from superficial similarities, the projects are not related in any way and the code base is completely distinct. Log4r was developed without even looking at the Apache Log4j code.

Log4r is an Open Source project and intends to remain that way. The Log4r license is similar to the Ruby Language license. It resides on this page and in the distribution in a file named LICENSE.

like image 142
Daniel Lv Avatar answered Jan 31 '23 10:01

Daniel Lv