Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

logging in ruby

Tags:

logging

ruby

I'm searching for a logging framework for Ruby. Are there any advantages of log4r over the standard Logger class?

like image 494
ceth Avatar asked Dec 27 '09 17:12

ceth


2 Answers

One of the big advantages of the log4r package is that it follows the pattern of the log4j, log4cpp, log4net, etc packages that many people are already familiar with. It also has support for configuration files, allowing logging to be configured easily at runtime without modifying the code. A disadvantage is that it is not an exact clone of the log4j family of frameworks into Ruby, and thus the configuration file doesn't follow the same format as the rest of the log4j family (and other details may be different as well, which may catch people up who are familiar with log4j).

If you don't need configurability built in, and you don't particularly care about following the log4j pattern, then using the standard Logger class should probably be sufficient, and will help reduce your extra dependencies.

like image 53
Brian Campbell Avatar answered Oct 21 '22 17:10

Brian Campbell


Log4Rr comes with several outputter classes out of the box, which can be handy if you need to do stuff other than standard "append to file and stdout". For example, we have a set of Ruby scripts running daily or hourly and we have them sending emails to us whenever they crash (which we use FAIL level for) or encounter an ERROR.

There is also bunch of handy stuff, such as named loggers: for each we create a configuration section, and upon execution we easily override the used one by command argument or environment variable. Etc, etc...

So it's not only the compatibility with log4j pattern (which we didn't care about, really), but a rich functionality as well.

like image 43
Mladen Jablanović Avatar answered Oct 21 '22 16:10

Mladen Jablanović