module RJack::SLF4J::JUL

Utilities for finer grain control of the JDK java.util.logging (JUL). In particular, unlike other logging API's reimplemented by slf4j adapters, JUL log levels remain significant for enabling output or avoiding log message generation cycles. For a particular level to be output, both JUL and the destination SLF4J output adapter must enable it.

Usage

Adjust JUL levels (in conjunction with 'slf4j/jul-to-slf4j' or 'slf4j/jdk14', see SLF4J.)

require 'rjack-slf4j/jul'
SLF4J::JUL[ "my.jul.logger" ].level = SLF4J::JUL::FINER

Direct all output to SLF4J (output adapter != 'jdk14')

require 'rjack-slf4j/jul-to-slf4j'
RJack::SLF4J::JUL.replace_root_handlers

Constants

ALL
CONFIG
FINE
FINER
FINEST
INFO
Level
LogManager
Logger
SEVERE
WARNING

Public Class Methods

[]( name ) click to toggle source

Get java.util.logging.Logger by name (responds to level=, etc.)

# File lib/rjack-slf4j/jul.rb, line 69
def self.[]( name )
  Logger.get_logger( name )
end
replace_root_handlers() click to toggle source

Replace any existing configured root java.util.Logger Handlers with the org.slf4j.bridge.SLF4JBridgeHandler

# File lib/rjack-slf4j/jul-to-slf4j.rb, line 34
def self.replace_root_handlers
  root_logger = root
  root_logger.handlers.each do |handler|
    root_logger.remove_handler( handler )
  end
  handler = Java::org.slf4j.bridge.SLF4JBridgeHandler.new

  root_logger.add_handler( handler )
end
reset() click to toggle source

Global java.util.logging.LogManager reset: close any handlers and set root level to INFO.

# File lib/rjack-slf4j/jul.rb, line 64
def self.reset
  LogManager.log_manager.reset
end
root() click to toggle source

Get the root logger (empty string name)

# File lib/rjack-slf4j/jul.rb, line 74
def self.root
  Logger.get_logger( "" )
end