log4j, for JavaLanguage, is the JakartaProject's logging system for Java. It straps onto your class hierarchy and enables hierarchical logging, keyed by the usual set of levels and module names. : "With log4j it is possible to enable logging at runtime without modifying the application binary. The log4j package is designed so that these statements can remain in shipped code without incurring a heavy performance cost. Logging behavior can be controlled by editing a configuration file, without touching the application binary. : "Logging equips the developer with detailed context for application failures. On the other hand, testing provides quality assurance and confidence in the application. Logging and testing should not be confused. They are complementary. When logging is wisely used, it can prove to be an essential tool. : "One of the distinctive features of log4j is the notion of inheritance in loggers. Using a logger hierarchy it is possible to control which log statements are output at arbitrarily fine granularity but also great ease. This helps reduce the volume of logged output and minimize the cost of logging." http://logging.apache.org/log4j/docs/index.html Log4r is a RubyLanguage clone: : "A comprehensive and flexible logging library... It features a hierarchical logging system of any number of levels, custom level names, logger inheritance, multiple output destinations, execution tracing, custom formatting, thread safety, 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 controlling 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." http://log4r.sourceforge.net/ So they both apparently solve exactly same problem in exactly the same way. log4j's src folder has 31,764 lines of code. log4r's src folder has 2,071 lines of code. ---- Some criticism on this comparison by Remon van Vliet: As per Java convention, the Java version has the lowest level API reference documentation included in its source code which, obviously adds quite a few newlines (an odd measurement of verbosity to begin with but hey). It also happened to be properly spaced and indented code. Now I took the liberty of browsing through the code of the Ruby equivalent you mentioned and it has none of that (as in, hardly any comments and horribly formatted code). Since both are more a matter of taste/style I don't see its relevance anyway. I'm pretty sure a similar amount of input went into both versions (code + docs). ''another item to compare would be development time. I [PhlIp] am a RubyLanguage zealot, yet the super-terse style of other zealots makes me postal. Yet if the language indeed permitted a super short development time, _despite_ its terse style, then...'' ---- ''another item to compare would be development time...'' It's very difficult to compare development time for a library which has been developed over a period of time in one language, and one which is a copy of said library. For the redevelopment in Ruby, its bound to go faster, because you're copying the analysis (and ideas, etc). This isn't to say that RubyLanguage isn't a faster development environment, but that this situation is not a good one for comparison. -- MatthewFarwell ''Try "another item to compare would be development time, despite the faster language's crappy indenting!'' ---- ''As per Java convention, the Java version has the lowest level API reference documentation included in its source code which, obviously adds quite a few newlines'' Hmm. This: require 'find' total_lines = real_lines = 0 Find.find("src") do |file| next unless file =~ /\.java$/ File.open(file) do |fh| source = fh.read total_lines += source.count "\n" source.gsub!(/\/\*.*?\*\//m, "") source.gsub!(/\/\/[^\n]*/, "") real_lines += source.split("\n").grep(/[^\s]/).size end end print "Total lines: #{total_lines}\n" print "Real lines: #{real_lines}\n" yields: [jfelice@untamo logging-log4j-1.2.13]$ ruby slime.rb Total lines: 31802 Real lines: 15331 So it seems that comments do not account for the order of magnitude difference. (This is without removing blank lines or comments from log4r *snicker*). '''Update:''' Forgot to match newlines. *sigh* Now only 7 times larger. --JasonFelice ---- See also LogForJava LogForRuby PatternsForLoggingDiagnosticMessages ---- Topical in MayZeroSix CategoryJava CategoryRuby CategoryLogging