Log4r : logger inheritance, yaml configuration, alternatives ?

Posted by devlearn on Stack Overflow See other posts from Stack Overflow or by devlearn
Published on 2010-05-18T10:04:35Z Indexed on 2010/05/18 15:00 UTC
Read the original article Hit count: 692

Filed under:
|
|
|
|

Hello,

I'm pretty new to ruby environments and I was looking for a nice logging framework to use it my ruby and rails applications.

In my previous experiences I have successfully used log4j and log4p (the perl port) and was expecting the same level of usability (and maturity) with log4r.

However I must say that there are a number of things that are not clear at all in the log4r framework.

1 Logger Inheritance

The logger inheritance does not seem to be managed at all !

If I declare a logger named 'myapp' and then try to get a logger name 'myapp::engine', the lookup will end with a NameError.

I would expect that the framework returns the root logger according to the naming scheme and to use the 'myapp' logger.

Q1 : Of course I can work around this and manage the names by myself with a lookup method, however is there a cleaner way to do this without any extra coding ?

2 YAML configuration

Second thing that confuses me is the yaml configuration. On the log4r site there are literally no information about this system, the doc links forward to missing pages, so all the info I can find about is contained in the examples directory of the gem.

I was pretty confused with the fact that the yaml configuration must contain the pre_config section, and that I need to define my own levels.

If I remove the pre_config secion, or replace all the “custom” levels by the standard ones ( debug, info, warn, fatal ) , the example will throw the following error :

log4r/yamlconfigurator.rb:68:in `decode_yaml': Log level must be in 0..7 (ArgumentError)

So there seems to be no way of using a simple file where we only declare the loggers and appenders for the framework.

Q2 : I realy think that I missed something and that must be a way of providing a simple yaml conf file. Do you have any examples of such an usage ?

3 Variables substitution in XML file

Q3 : The Yaml configuration system seems to provide such a feature however I was unable to find a similar feature with XML files. Any ideas ?

4 Alternatives ?

I must say that I'm very disappointed by the feature level and the maturity of log4r compared to the log4j and other log4j ports.

I run into this framework with a solid background of logging APIs in other languages and find myself working around in all kinds just to make 'basic things' running in a “real world application”.

By that I mean a complex application composed of several gems, console/scripting apps, and a rails web front end where the configuration must be mutualized and where we make intensive usage of namespaces and inheritance.

I've run several searches in order to find something more suitable or mature, but did not find anything similar.

Q4 : Do you guys know any (serious) alternatives to log4r framework that could be used in a enterprise class app ?

Thanks reading all of this !

I'd really appreciate any pointers,

Kind Regards,

© Stack Overflow or respective owner

Related posts about log4r

Related posts about logger