Search code examples
javarubyloggingjax-rsjruby

How to configure ruby puts logs to show up in Java-JRuby log file


I have configured JRuby within my JAX-RS application to run some ruby scripts. For debugging, I have used some "puts" statements in the ruby file. They are not getting logged in the JAX-RS webservice log file. How to configure?

Basically I want ruby "puts" logs to display in dropwizard webservice log


Solution

  • I just noticed that I was able to use slf4j too

    log = org.slf4j.LoggerFactory.getLogger(self.class.name)
    

    The logging level depends on what we set at the root level in config.yaml. Only if that is set to DEBUG, we can see log.debug entries.

    logging:
      # The default level of all loggers. Can be OFF, FATAL, ERROR, WARN, INFO, DEBUG, TRACE, or ALL.
      level: DEBUG
    

    I also noticed configuring log level at the package/class level, does not log “debug” statements from ruby

    loggers:
      # Sets the level for 'com.example.app' to DEBUG.
      com.example.test: DEBUG