I'm searching for a logging framework for Ruby. Are there any advantages of log4r over the standard Logger class?
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With