Sha256: cbcc3158b31d040ecc607df01757a6294d73d53e43f28ca52421413797571804

Contents?: true

Size: 698 Bytes

Versions: 3

Compression:

Stored size: 698 Bytes

Contents

if defined? JRUBY_VERSION
  require 'slf4r/java_logger'

  # load log4j configuration
  props = java.util.Properties.new
  props.load(java.io.FileInputStream.new(File.join(File.dirname(__FILE__), 'log4j.properties')))
  
  # use rails default log file location
  props.setProperty("log4j.appender.logfile.File", File.join(Rails.root, "log", "#{Rails.env}.log"))
  
  # adjust the log level
  root = props.getProperty("log4j.rootCategory")
  props.setProperty("log4j.rootCategory", root.sub(/^[a-zA-Z]+/, Rails.application.config.log_level.to_s))

  # configure log4j
  org.apache.log4j.PropertyConfigurator.configure(props)
else
  Rails.logger.debug("skip log4j config since no jruby is used")
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
slf4r-0.4.2 lib/generators/slf4r/templates/log4j.rb
slf4r-0.4.1 lib/generators/slf4r/templates/log4j.rb
slf4r-0.4.0 lib/generators/slf4r/templates/log4j.rb