Uploaded image for project: 'Puppet Server'
  1. Puppet Server
  2. SERVER-1475

Create Logback adapter for JRuby Logger

    XMLWordPrintable

Details

    • Improvement
    • Status: Closed
    • Normal
    • Resolution: Fixed
    • None
    • SERVER 5.0.0
    • None
    • New Feature
    • Hide
      By default JRuby logs errors to stderr, which Puppet Server writes to either the /var/log/puppetlabs/puppetserver/puppetserver-daemon.log, syslog, or journalctl (depending upon the OS). JRuby also does not, by default, log debug messages without some custom configuration of the JRuby logger.

      In order to take advantage of the existing logging infrastructure in Puppet Server, JRuby now uses a custom slf4j logger that bridges logging from JRuby to logback. As a result, Puppet Server now logs messages from JRuby into the /var/log/puppetlabs/puppetserver/puppetserver.log file. Only "info" or "error" messages from JRuby are logged by default. To view debug-level JRuby messages, set the "level" attribute for the "jruby" element in the /etc/puppetlabs/puppetserver/logback.xml file to "debug".
      Show
      By default JRuby logs errors to stderr, which Puppet Server writes to either the /var/log/puppetlabs/puppetserver/puppetserver-daemon.log, syslog, or journalctl (depending upon the OS). JRuby also does not, by default, log debug messages without some custom configuration of the JRuby logger. In order to take advantage of the existing logging infrastructure in Puppet Server, JRuby now uses a custom slf4j logger that bridges logging from JRuby to logback. As a result, Puppet Server now logs messages from JRuby into the /var/log/puppetlabs/puppetserver/puppetserver.log file. Only "info" or "error" messages from JRuby are logged by default. To view debug-level JRuby messages, set the "level" attribute for the "jruby" element in the /etc/puppetlabs/puppetserver/logback.xml file to "debug".

    Description

      Much of JRuby's internal logging seems to be done through its LoggerFactory class. By default, it uses a logger which outputs messages to stderr. Debug level messages aren't written to stderr at all without some code changes - see https://github.com/jruby/jruby/blob/1.7.25/core/src/main/java/org/jruby/util/log/StandardErrorLogger.java#L37.

      Since it appears to be possible to configure a custom logger via a JRuby option, it might be good to look into having Puppet Server register a custom logger with JRuby which routes logged messages back through the logback infrastructure that Puppet Server uses for its core logging. I don't know if JRuby provides a safe way to configure options programmatically for ScriptingContainer instances. So we may have to have an application opt into this by setting the name of the logback adapter class on the Java command line, via a "-Djruby.logger.class=<theclass>" system property.

      Assuming we do this, we should look into adding it to the jruby-utils library so that other consuming applications besides Puppet Server could benefit from the work.

      Attachments

        Activity

          People

            craig.gomes Craig Gomes
            jeremy.barlow Jeremy Barlow
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Zendesk Support