Giter VIP home page Giter VIP logo

log4r's People

Contributors

carsonreinke avatar colbygk avatar dansketcher avatar mareklipka avatar mlew avatar nbrochu avatar nitay avatar pcting avatar toadjamb avatar tony-kerz avatar tylerholien avatar unasuke avatar voxik avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

log4r's Issues

Can't run examples in 1.1.11

>rvm use 2.1.5@log4rtest
>gem list
*** LOCAL GEMS ***

bigdecimal (1.2.4)
bundle (0.0.1)
bundler (1.12.3)
bundler-unload (1.0.2)
executable-hooks (1.3.2)
io-console (0.4.2)
json (1.8.1)
minitest (4.7.5)
psych (2.0.5)
rake (10.1.0, 0.8.7)
rdoc (4.1.0)
rubygems-bundler (1.4.4)
test-unit (2.1.5.0)
>cd examples
>ruby simpleconfig.rb
/scratch/ralstonm/log4r/lib/log4r/staticlogger.rb:5:in `root': uninitialized constant Log4r::Logger::RootLogger (NameError)
        from simpleconfig.rb:12:in `<main>'
outofthebox.rb:5:in `initialize': wrong number of arguments (1 for 0) (ArgumentError)
        from outofthebox.rb:5:in `new'
        from outofthebox.rb:5:in `<main>'

undefined method `formatter' for Log4r::Logger in Rails?

Hi there,

I'm getting the following error: https://gist.github.com/solars/5af4e6743ac301a2ecdc
when trying to run a rails project with log4r locally in production mode - somehow I don't get it with passenger on the server, not sure why.

It seems as if rails expects a formatter method somewhere else than log4r has it, versions are:
log4r (1.1.10)
rails (4.0.13)

Since I don't want to risk breaking the app, is there a fix/workaround for this in later versions? Or is it something else?

Thanks a lot,
Christoph

UDPOutputter and JRuby

I'm writing a monitoring service for REST api's using ruby and Log4r. I'm running it under JRuby 1.7.1 so I can use threading.

Only under JRuby, I get this error...

Log4r::ConfigError:
Problem creating outputter: can't convert String into Integer

The line that errors is:
Configurator.load_xml_file('log4r_config.xml')

Playing around with the config file, I narrowed it down to the "port" setting for my UDPOutputter outputter

123456

Would it be possible to fix this JRuby compatibility issue? Or maybe I'm doing something wrong. Again this works perfectly under regular ruby.

yamlconfigurator issue in Ruby 2.5.0

Processing a log4r yaml configuration file fails in Ruby 2.5.0 with the following error
.rvm/gems/ruby-2.5.0/gems/log4r-1.1.10/lib/log4r/yamlconfigurator.rb:42:in load_yaml_file' .rvm/gems/ruby-2.5.0/gems/log4r-1.1.10/lib/log4r/yamlconfigurator.rb:56:in actual_load': undefined method `load_documents' for Psych:Module (NoMethodError)
Did you mean? load_stream

1.1.10 breaks use of third party outputters

My log4r-gelf outputter stopped working with 1.1.10. Log4r is now only looking for types defined directly in Log4r namespace, but anything deeper fails to be resolved, e.g. Log4r::Gelf::GelfOutputter. This worked in 1.1.9. I can change the class name, but maybe this should be more permissive

d052fcd

Adding child logger before initial parent results in unexpected level

Defining a child logger before the initial parent will result in the child logger receiving a level of 0 instead of the default from the parent.

This means that developers need to be very careful about the load order of modules and classes or alternatively should provide a mechanism to easily reset child logger levels on defining of a parent logger.

At the very least, I'd suggest documenting the current behaviour more clearly to warn developers that order is important.

See vagrant-libvirt/vagrant-libvirt#430

Log4r::Logger.new("log4r") results in a stack error if you add a rolling file outputter

This one's exciting:

filename = '/tmp/testme'

logger = Log4r::Logger.new("log4r")

outputter =  Log4r::RollingFileOutputter.new("foo", :filename => filename, :maxtime => 10)

logger.outputters = outputter

# (wait patiently with some logging)
sleep 20
logger.warn("foo")

This is exciting because in rollingfileoutputter.rb , when checking whether a roll is needed, we log that a roll is needed. that log checks that a roll is needed, and so logs that the roll is needed (and so on, ad infinitum).

This results in a SystemStackError, like so:

/usr/lib/ruby/1.8/monitor.rb:240:in `synchronize': stack level too deep (SystemStackError)
        from /usr/lib/ruby/1.8/log4r/repository.rb:36:in `[]'
        from /usr/lib/ruby/1.8/log4r/staticlogger.rb:15:in `[]'
        from /usr/lib/ruby/1.8/log4r/staticlogger.rb:44:in `log_internal'
        from /usr/lib/ruby/1.8/log4r/outputter/rollingfileoutputter.rb:169:in `requiresRoll'
        from /usr/lib/ruby/1.8/log4r/outputter/rollingfileoutputter.rb:129:in `write'
        from /usr/lib/ruby/1.8/log4r/outputter/outputter.rb:110:in `canonical_log'
        from /usr/lib/ruby/1.8/log4r/outputter/outputter.rb:130:in `synch'
        from /usr/lib/ruby/1.8/monitor.rb:242:in `synchronize'
         ... 3431 levels...

It seems to go log_internal -> requiresRoll -> logInternal -> requireRoll, ad infinitum.

There's scope for calling this a configuration error, but nowhere in the documentation does it state that the rolling file outputter shouldn't be used for the log4r internal logger...

/Nick

XML configurator throws exception with EmailOutputter

My tag is:
<outputter type="EmailOutputter" name="exception_email" trunc="false" level="ERROR" buffsize="10">
<formatter type="PatternFormatter" pattern="#{pattern}"/>
<server>#{smtp_address}</server>
<port>#{smtp_port}</port>
<domain>#{smtp_domain}</domain>
<from>logging@#{smtp_domain}</from>
<to>[email protected]</to>
<subject>Log Report</subject>
<immediate_at>ERROR, FATAL</immediate_at>
</outputter>

I've double and triple checked the XML variables by stepping-through the source code.

The exception I get is:

Uncaught exception: Problem creating outputter: uninitialized constant Log4r::Configurator::EmailOutputter
/usr/local/lib/ruby/gems/2.0.0/gems/log4r-1.1.10/lib/log4r/configurator.rb:87:in block in decode_xml' /usr/local/lib/ruby/2.0.0/rexml/element.rb:905:inblock in each'
/usr/local/lib/ruby/2.0.0/rexml/xpath.rb:67:in each' /usr/local/lib/ruby/2.0.0/rexml/xpath.rb:67:ineach'
/usr/local/lib/ruby/2.0.0/rexml/element.rb:905:in each' /usr/local/lib/ruby/gems/2.0.0/gems/log4r-1.1.10/lib/log4r/configurator.rb:87:indecode_xml'
/usr/local/lib/ruby/gems/2.0.0/gems/log4r-1.1.10/lib/log4r/configurator.rb:82:in actual_load' /usr/local/lib/ruby/gems/2.0.0/gems/log4r-1.1.10/lib/log4r/configurator.rb:56:inload_xml_file'
/root/src/upside/common/upside_logger.rb:16:in initialize' /root/src/upside/common/logger_factory.rb:7:innew'
/root/src/upside/common/logger_factory.rb:7:in new_logger' /root/src/upside/config/application.rb:24:inblock in class:Application'
/usr/local/lib/ruby/gems/2.0.0/gems/activesupport-4.0.2/lib/active_support/lazy_load_hooks.rb:36:in call' /usr/local/lib/ruby/gems/2.0.0/gems/activesupport-4.0.2/lib/active_support/lazy_load_hooks.rb:36:inexecute_hook'
/usr/local/lib/ruby/gems/2.0.0/gems/activesupport-4.0.2/lib/active_support/lazy_load_hooks.rb:28:in block in on_load' /usr/local/lib/ruby/gems/2.0.0/gems/activesupport-4.0.2/lib/active_support/lazy_load_hooks.rb:27:ineach'
/usr/local/lib/ruby/gems/2.0.0/gems/activesupport-4.0.2/lib/active_support/lazy_load_hooks.rb:27:in on_load' /usr/local/lib/ruby/gems/2.0.0/gems/railties-4.0.2/lib/rails/railtie/configuration.rb:53:inbefore_configuration'
/root/src/upside/config/application.rb:23:in <class:Application>' /root/src/upside/config/application.rb:9:inmodule:Upside'
/root/src/upside/config/application.rb:8:in <top (required)>' /usr/local/lib/ruby/gems/2.0.0/gems/railties-4.0.2/lib/rails/commands.rb:74:inrequire'
/usr/local/lib/ruby/gems/2.0.0/gems/railties-4.0.2/lib/rails/commands.rb:74:in block in <top (required)>' /usr/local/lib/ruby/gems/2.0.0/gems/railties-4.0.2/lib/rails/commands.rb:71:intap'
/usr/local/lib/ruby/gems/2.0.0/gems/railties-4.0.2/lib/rails/commands.rb:71:in <top (required)>' /root/src/upside/bin/rails:4:inrequire'
/root/src/upside/bin/rails:4:in <top (required)>' /usr/local/lib/ruby/gems/2.0.0/gems/log4r-1.1.10/lib/log4r/configurator.rb:87:inblock in decode_xml': Problem creating outputter: uninitialized constant Log4r::Configurator::EmailOutputter (Log4r::ConfigError)
from /usr/local/lib/ruby/2.0.0/rexml/element.rb:905:in block in each' from /usr/local/lib/ruby/2.0.0/rexml/xpath.rb:67:ineach'
from /usr/local/lib/ruby/2.0.0/rexml/xpath.rb:67:in each' from /usr/local/lib/ruby/2.0.0/rexml/element.rb:905:ineach'
from /usr/local/lib/ruby/gems/2.0.0/gems/log4r-1.1.10/lib/log4r/configurator.rb:87:in decode_xml' from /usr/local/lib/ruby/gems/2.0.0/gems/log4r-1.1.10/lib/log4r/configurator.rb:82:inactual_load'
from /usr/local/lib/ruby/gems/2.0.0/gems/log4r-1.1.10/lib/log4r/configurator.rb:56:in load_xml_file' from /root/src/upside/common/upside_logger.rb:16:ininitialize'
from /root/src/upside/common/logger_factory.rb:7:in new' from /root/src/upside/common/logger_factory.rb:7:innew_logger'
from /root/src/upside/config/application.rb:24:in block in <class:Application>' from /usr/local/lib/ruby/gems/2.0.0/gems/activesupport-4.0.2/lib/active_support/lazy_load_hooks.rb:36:incall'
from /usr/local/lib/ruby/gems/2.0.0/gems/activesupport-4.0.2/lib/active_support/lazy_load_hooks.rb:36:in execute_hook' from /usr/local/lib/ruby/gems/2.0.0/gems/activesupport-4.0.2/lib/active_support/lazy_load_hooks.rb:28:inblock in on_load'
from /usr/local/lib/ruby/gems/2.0.0/gems/activesupport-4.0.2/lib/active_support/lazy_load_hooks.rb:27:in each' from /usr/local/lib/ruby/gems/2.0.0/gems/activesupport-4.0.2/lib/active_support/lazy_load_hooks.rb:27:inon_load'
from /usr/local/lib/ruby/gems/2.0.0/gems/railties-4.0.2/lib/rails/railtie/configuration.rb:53:in before_configuration' from /root/src/upside/config/application.rb:23:inclass:Application'
from /root/src/upside/config/application.rb:9:in <module:Upside>' from /root/src/upside/config/application.rb:8:in<top (required)>'
from /usr/local/lib/ruby/gems/2.0.0/gems/railties-4.0.2/lib/rails/commands.rb:74:in require' from /usr/local/lib/ruby/gems/2.0.0/gems/railties-4.0.2/lib/rails/commands.rb:74:inblock in <top (required)>'
from /usr/local/lib/ruby/gems/2.0.0/gems/railties-4.0.2/lib/rails/commands.rb:71:in tap' from /usr/local/lib/ruby/gems/2.0.0/gems/railties-4.0.2/lib/rails/commands.rb:71:in<top (required)>'
from /root/src/upside/bin/rails:4:in require' from /root/src/upside/bin/rails:4:in<top (required)>'
from /usr/local/lib/ruby/gems/2.0.0/gems/ruby-debug-ide-0.4.22/lib/ruby-debug-ide.rb:86:in debug_load' from /usr/local/lib/ruby/gems/2.0.0/gems/ruby-debug-ide-0.4.22/lib/ruby-debug-ide.rb:86:indebug_program'
from /usr/local/lib/ruby/gems/2.0.0/gems/ruby-debug-ide-0.4.22/bin/rdebug-ide:110:in `<top (required)>'

Any help appreciated

log4r-color merge?

Would it be possible to merge this repo, which enables colorized stdout, into the existing library? Is there a reason this hasn't been done?

I did not write the colorize extension, but I've been looking through the code and the changes seem reasonable to me. Admittedly, I don't know what else those changes might impact.

I also imagine you all have considered this before, so forgive me if that conversation to add colorized output has already occurred.

log4r-color

It uses colorize

Test fails for 1.1.10

Hi, I am trying to build log4r for Fedora, but hitting on a few failures:

+ pushd ./usr/share/gems/gems/log4r-1.1.10
+ ruby -Ilib:tests -e 'Dir.glob "./tests/test*.rb", &method(:require)'
DEBUG log4r(/builddir/build/BUILD/log4r-1.1.10/usr/share/gems/gems/log4r-1.1.10/lib/log4r/staticlogger.rb:46:in `log_internal'): Added outputter 'log4r' to 'log4r'
DEBUG log4r(/builddir/build/BUILD/log4r-1.1.10/usr/share/gems/gems/log4r-1.1.10/lib/log4r/staticlogger.rb:46:in `log_internal'): Logger 'log4r' set to ALL
DEBUG log4r(/builddir/build/BUILD/log4r-1.1.10/usr/share/gems/gems/log4r-1.1.10/lib/log4r/staticlogger.rb:46:in `log_internal'): Outputter 'udp' level is ALL
DEBUG log4r(/builddir/build/BUILD/log4r-1.1.10/usr/share/gems/gems/log4r-1.1.10/lib/log4r/staticlogger.rb:46:in `log_internal'): Outputter 'udp' using Log4r::DefaultFormatter
DEBUG log4r(/builddir/build/BUILD/log4r-1.1.10/usr/share/gems/gems/log4r-1.1.10/lib/log4r/staticlogger.rb:46:in `log_internal'): UDPOutputter will send to localhost:8071
DEBUG log4r(/builddir/build/BUILD/log4r-1.1.10/usr/share/gems/gems/log4r-1.1.10/lib/log4r/staticlogger.rb:46:in `log_internal'): Outputter 'udp' using Log4r::Log4jXmlFormatter
DEBUG log4r(/builddir/build/BUILD/log4r-1.1.10/usr/share/gems/gems/log4r-1.1.10/lib/log4r/staticlogger.rb:46:in `log_internal'): Logger 'mylog' is tracing
DEBUG log4r(/builddir/build/BUILD/log4r-1.1.10/usr/share/gems/gems/log4r-1.1.10/lib/log4r/staticlogger.rb:46:in `log_internal'): Added outputter 'udp' to 'mylog'
ERROR log4r(/builddir/build/BUILD/log4r-1.1.10/usr/share/gems/gems/log4r-1.1.10/lib/log4r/staticlogger.rb:46:in `log_internal'): UDPOutputter failed to send data to localhost:8071, Connection refused - send(2)
ERROR log4r(/builddir/build/BUILD/log4r-1.1.10/usr/share/gems/gems/log4r-1.1.10/lib/log4r/staticlogger.rb:46:in `log_internal'): UDPOutputter failed to send data to localhost:8071, Connection refused - send(2)
ERROR log4r(/builddir/build/BUILD/log4r-1.1.10/usr/share/gems/gems/log4r-1.1.10/lib/log4r/staticlogger.rb:46:in `log_internal'): UDPOutputter failed to send data to localhost:8071, Connection refused - send(2)
Tue Oct  7 13:56:56 UTC 2014
Run options: 
# Running tests:
.....E.EF..DEBUG log4r(/builddir/build/BUILD/log4r-1.1.10/usr/share/gems/gems/log4r-1.1.10/lib/log4r/staticlogger.rb:46:in `log_internal'): Outputter 'fake1' level is ALL

(...)

Finished tests in 10.790028s, 4.3559 tests/s, 16.6821 assertions/s.
  1) Failure:
TestXmlConf#test_load4 [/builddir/build/BUILD/log4r-1.1.10/usr/share/gems/gems/log4r-1.1.10/tests/testxmlconf.rb:41]:
Exception raised:
<#<Errno::ENOENT: No such file or directory @ rb_sysopen - xml/testconf.xml>>.
  2) Failure:
TestXmlConf#test_load1 [/builddir/build/BUILD/log4r-1.1.10/usr/share/gems/gems/log4r-1.1.10/tests/testxmlconf.rb:22]:
Exception raised:
<#<NameError: uninitialized constant TestXmlConf::Foo>>.
  3) Failure:
TestGDC#test_gdc_default [/builddir/build/BUILD/log4r-1.1.10/usr/share/gems/gems/log4r-1.1.10/tests/testGDC.rb:7]:
Expected 'testGDC.rb' got '-e: TestGDC#test_gdc_default'
  4) Failure:
TestOutputter#test_validation_and_creation [/builddir/build/BUILD/log4r-1.1.10/usr/share/gems/gems/log4r-1.1.10/tests/testoutputter.rb:29]:
Exception raised:
<#<StandardError: 'junk' is not writable!>>.
  5) Failure:
TestOutputter#test_file [/builddir/build/BUILD/log4r-1.1.10/usr/share/gems/gems/log4r-1.1.10/tests/testoutputter.rb:63]:
Exception raised:
<#<StandardError: './junk' is not writable!>>.
  6) Failure:
TestOutputter#test_repository [/builddir/build/BUILD/log4r-1.1.10/usr/share/gems/gems/log4r-1.1.10/tests/testoutputter.rb:26]:
Failed assertion, no message given.
  7) Error:
TestOutputter#test_io:
Errno::ENOENT: No such file or directory @ rb_sysopen - junk/tmpx.log
    /builddir/build/BUILD/log4r-1.1.10/usr/share/gems/gems/log4r-1.1.10/tests/testoutputter.rb:17:in `initialize'
    /builddir/build/BUILD/log4r-1.1.10/usr/share/gems/gems/log4r-1.1.10/tests/testoutputter.rb:17:in `new'
    /builddir/build/BUILD/log4r-1.1.10/usr/share/gems/gems/log4r-1.1.10/tests/testoutputter.rb:17:in `test_io'
  8) Error:
TestOutputter#test_file_encoding:
Errno::ENOENT: No such file or directory @ rb_sysopen - ./junk/tmp2
    /builddir/build/BUILD/log4r-1.1.10/usr/share/gems/gems/log4r-1.1.10/tests/testoutputter.rb:119:in `initialize'
    /builddir/build/BUILD/log4r-1.1.10/usr/share/gems/gems/log4r-1.1.10/tests/testoutputter.rb:119:in `open'
    /builddir/build/BUILD/log4r-1.1.10/usr/share/gems/gems/log4r-1.1.10/tests/testoutputter.rb:119:in `test_file_encoding'
  9) Error:
TestLogger#test_multi_outs:
StandardError: './junk' is not writable!
    /builddir/build/BUILD/log4r-1.1.10/usr/share/gems/gems/log4r-1.1.10/lib/log4r/outputter/fileoutputter.rb:37:in `initialize'
    /builddir/build/BUILD/log4r-1.1.10/usr/share/gems/gems/log4r-1.1.10/tests/testlogger.rb:164:in `new'
    /builddir/build/BUILD/log4r-1.1.10/usr/share/gems/gems/log4r-1.1.10/tests/testlogger.rb:164:in `test_multi_outs'
 10) Error:
TestFormatter#test_simple_formatter:
TypeError: no implicit conversion of Regexp into String
    /builddir/build/BUILD/log4r-1.1.10/usr/share/gems/gems/log4r-1.1.10/tests/testformatter.rb:15:in `test_simple_formatter'
    /usr/share/ruby/test/unit/testcase.rb:17:in `run'
    /usr/share/ruby/test/unit.rb:663:in `block in _run_suites'
    /usr/share/ruby/test/unit.rb:661:in `each'
    /usr/share/ruby/test/unit.rb:661:in `_run_suites'
    /usr/share/ruby/test/unit.rb:27:in `run'
    /usr/share/ruby/test/unit.rb:780:in `run'
    /usr/share/ruby/test/unit.rb:372:in `block (2 levels) in autorun'
    /usr/share/ruby/test/unit.rb:33:in `run_once'
    /usr/share/ruby/test/unit.rb:371:in `block in autorun'
 11) Error:
TestXmlConf#test_load3:
ArgumentError: Log level must be in 0..7
    /builddir/build/BUILD/log4r-1.1.10/usr/share/gems/gems/log4r-1.1.10/lib/log4r/configurator.rb:95:in `decode_pre_config'
    /builddir/build/BUILD/log4r-1.1.10/usr/share/gems/gems/log4r-1.1.10/lib/log4r/configurator.rb:86:in `decode_xml'
    /builddir/build/BUILD/log4r-1.1.10/usr/share/gems/gems/log4r-1.1.10/lib/log4r/configurator.rb:82:in `actual_load'
    /builddir/build/BUILD/log4r-1.1.10/usr/share/gems/gems/log4r-1.1.10/lib/log4r/configurator.rb:62:in `load_xml_string'
    /builddir/build/BUILD/log4r-1.1.10/usr/share/gems/gems/log4r-1.1.10/tests/testxmlconf.rb:34:in `test_load3'
 12) Error:
TestFormatter#test_basic_formatter:
TypeError: no implicit conversion of Regexp into String
    /builddir/build/BUILD/log4r-1.1.10/usr/share/gems/gems/log4r-1.1.10/tests/testformatter.rb:23:in `test_basic_formatter'
    /usr/share/ruby/test/unit/testcase.rb:17:in `run'
    /usr/share/ruby/test/unit.rb:663:in `block in _run_suites'
    /usr/share/ruby/test/unit.rb:661:in `each'
    /usr/share/ruby/test/unit.rb:661:in `_run_suites'
    /usr/share/ruby/test/unit.rb:27:in `run'
    /usr/share/ruby/test/unit.rb:780:in `run'
    /usr/share/ruby/test/unit.rb:372:in `block (2 levels) in autorun'
    /usr/share/ruby/test/unit.rb:33:in `run_once'
    /usr/share/ruby/test/unit.rb:371:in `block in autorun'
47 tests, 180 assertions, 6 failures, 6 errors, 0 skips

Not sure what is the cause of this. Here are the versions installed in the buildroot:

DEBUG util.py:283:  Getting requirements for rubygem-log4r-1.1.10-1.fc22.src
DEBUG util.py:283:   --> rubygem-builder-3.2.2-2.fc21.noarch
DEBUG util.py:283:   --> rubygem-minitest4-4.7.0-4.fc21.noarch
DEBUG util.py:283:   --> rubygems-devel-2.2.2-101.fc21.noarch
DEBUG util.py:283:  ================================================================================
DEBUG util.py:283:   Package                  Arch         Version                Repository   Size
DEBUG util.py:283:  ================================================================================
DEBUG util.py:283:  Installing:
DEBUG util.py:283:   rubygem-builder          noarch       3.2.2-2.fc21           build        16 k
DEBUG util.py:283:   rubygem-minitest4        noarch       4.7.0-4.fc21           build        39 k
DEBUG util.py:283:   rubygems-devel           noarch       2.2.2-101.fc21         build        12 k
DEBUG util.py:283:  Installing for dependencies:
DEBUG util.py:283:   libyaml                  i686         0.1.6-5.fc22           build        58 k
DEBUG util.py:283:   ruby                     i686         2.1.2-23.fc21          build        65 k
DEBUG util.py:283:   ruby-irb                 noarch       2.1.2-23.fc21          build        87 k
DEBUG util.py:283:   ruby-libs                i686         2.1.2-23.fc21          build       2.9 M
DEBUG util.py:283:   rubygem-bigdecimal       i686         1.2.4-23.fc21          build        79 k
DEBUG util.py:283:   rubygem-io-console       i686         0.4.2-23.fc21          build        49 k
DEBUG util.py:283:   rubygem-json             i686         1.8.1-23.fc21          build        73 k
DEBUG util.py:283:   rubygem-psych            i686         2.0.5-23.fc21          build        78 k
DEBUG util.py:283:   rubygem-rdoc             noarch       4.1.1-2.fc21           build       442 k
DEBUG util.py:283:   rubygems                 noarch       2.2.2-101.fc21         build       246 k
DEBUG util.py:283:   rubypick                 noarch       1.1.1-2.fc21           build       5.4 k
DEBUG util.py:283:  Transaction Summary
DEBUG util.py:283:  ================================================================================
DEBUG util.py:283:  Install  3 Packages (+11 Dependent packages)
DEBUG util.py:283:  Total download size: 4.2 M
DEBUG util.py:283:  Installed size: 15 M
DEBUG util.py:283:  Installed:
DEBUG util.py:283:    rubygem-builder.noarch 0:3.2.2-2.fc21                                         
DEBUG util.py:283:    rubygem-minitest4.noarch 0:4.7.0-4.fc21                                       
DEBUG util.py:283:    rubygems-devel.noarch 0:2.2.2-101.fc21                                        
DEBUG util.py:283:  Dependency Installed:
DEBUG util.py:283:    libyaml.i686 0:0.1.6-5.fc22                                                   
DEBUG util.py:283:    ruby.i686 0:2.1.2-23.fc21                                                     
DEBUG util.py:283:    ruby-irb.noarch 0:2.1.2-23.fc21                                               
DEBUG util.py:283:    ruby-libs.i686 0:2.1.2-23.fc21                                                
DEBUG util.py:283:    rubygem-bigdecimal.i686 0:1.2.4-23.fc21                                       
DEBUG util.py:283:    rubygem-io-console.i686 0:0.4.2-23.fc21                                       
DEBUG util.py:283:    rubygem-json.i686 0:1.8.1-23.fc21                                             
DEBUG util.py:283:    rubygem-psych.i686 0:2.0.5-23.fc21                                            
DEBUG util.py:283:    rubygem-rdoc.noarch 0:4.1.1-2.fc21                                            
DEBUG util.py:283:    rubygems.noarch 0:2.2.2-101.fc21                                              
DEBUG util.py:283:    rubypick.noarch 0:1.1.1-2.fc21                           

warning: `+' after local variable or literal is interpreted as binary operator

I'm getting errors like this on JRuby 9.1.2.0:

/Volumes/extra/git/mio/mio.salesstatistics/workers/gems/jruby/2.3.0/gems/log4r-1.1.10/lib/log4r/outputter/outputter.rb:54: warning: '+' after local variable or literal is interpreted as binary operator
/Volumes/extra/git/mio/mio.salesstatistics/workers/gems/jruby/2.3.0/gems/log4r-1.1.10/lib/log4r/outputter>/outputter.rb:54: warning: even though it seems like unary operator
/Volumes/extra/git/mio/mio.salesstatistics/workers/gems/jruby/2.3.0/gems/log4r-1.1.10/lib/log4r/formatter/formatter.rb:72: warning: '+' after local variable or literal is interpreted as binary operator
/Volumes/extra/git/mio/mio.salesstatistics/workers/gems/jruby/2.3.0/gems/log4r-1.1.10/lib/log4r/formatter/formatter.rb:72: warning: even though it seems like unary operator

Push 1.1.11 to RubyGems

Hi there,

I'd love to get the changes in 9f8ba47 for Rails compatibility, but it looks like that version has not been pushed to Rubygems.

Is the the currency source? Or is this a clone of the rubyforge version?

Thanks!

License considerations

I work for VMWare, and we are open sourcing a large project called Cloud Foundry, which is available for download on Github, and also available as a service at cloudfoundry.com. We have a number of participants, including people in industry, academia, and government.

We have chosen to license our software under Apache v.2, which is incompatible with GPL and LGPL as you can read here: http://www.apache.org/licenses/GPL-compatibility.html and here http://www.apache.org/legal/resolved.html

If MIT or Apache is not your preference, the Ruby license offers both GPL, and Apache compatible terms.

http://www.ruby-lang.org/en/LICENSE.txt

Thanks for your consideration.

Matt

log4r does not support reconfiguring during runtime

I see this noted in the test README, but it is affecting my tests as well. Running in jruby incurs a higher startup cost so I'd rather not have to create a new jruby instance for every test which initializes log4r.

Is there any strategy others have adopted for re-configuring log4r during runtime? I mean a full recreate of the loggers and outputters.

1.1.11 introduces breaking changes

From what I can see, in 1.1.11 Log4r::Logger.root raises an error saying RootLogger is undefined. Is that not supported anymore? Sounds like a breaking change... I'm going to have to manually add "~> 1.1.0", "!= 1.1.11" in my project.

I think 1.1.11 could probably be yanked from RubyGems and 1.2 pushed up in its place.

IOError with STDOUT isn't connected to anything

http://stackoverflow.com/questions/19220048/ioerror-input-output-error-when-printing-to-logger

I am running into the same issues as this stackoverflower.

If i have a STDOUT logger, and the task isnt connected to anything, IE running in a background job etc, it throws a hard error and breaks my task, can this be set to gracefully fail the write?

Worker
Justins-MacBook-Pro.local:34069 on IMPORT at just now
Class
 Job::StagingGroupProcess
Arguments
412629
Exception
Errno::EIO
Error
Input/output error - <STDOUT>
/Users/justin/.rvm/gems/ruby-1.9.3-p448@nextlot/gems/log4r-1.1.10/lib/log4r/outputter/iooutputter.rb:42:in `write'
/Users/justin/.rvm/gems/ruby-1.9.3-p448@nextlot/gems/log4r-1.1.10/lib/log4r/outputter/iooutputter.rb:42:in `print'
/Users/justin/.rvm/gems/ruby-1.9.3-p448@nextlot/gems/log4r-1.1.10/lib/log4r/outputter/iooutputter.rb:42:in `write'
/Users/justin/.rvm/gems/ruby-1.9.3-p448@nextlot/gems/log4r-1.1.10/lib/log4r/outputter/outputter.rb:110:in `block in canonical_log'
/Users/justin/.rvm/gems/ruby-1.9.3-p448@nextlot/gems/log4r-1.1.10/lib/log4r/outputter/outputter.rb:130:in `block in synch'
/Users/justin/.rvm/rubies/ruby-1.9.3-p448/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
/Users/justin/.rvm/gems/ruby-1.9.3-p448@nextlot/gems/log4r-1.1.10/lib/log4r/outputter/outputter.rb:130:in `synch'
/Users/justin/.rvm/gems/ruby-1.9.3-p448@nextlot/gems/log4r-1.1.10/lib/log4r/outputter/outputter.rb:110:in `canonical_log'
(eval):3:in `info'
(eval):8:in `block in info'
(eval):8:in `each'
(eval):8:in `info'
/Users/justin/Projects/nextlot-projects/rails/app/models/job/common.rb:12:in `ensure in around_perform_logging'
/Users/justin/Projects/nextlot-projects/rails/app/models/job/common.rb:13:in `around_perform_logging'

Same log file opened multiple times in write mode, truncating file on each write

This is mostly to help other people as we are probably just going to move away from log4r to syslog or something. We have a project which uses log4r with the RollingFileOutputter. The latest log is not growing in size but instead being overwritten frequently. I believe this is the due to the fact that log4r is opening it in write mode instead of append mode.

I see in RollingFileOutputter#roll you have open_log_file('w'), I'm guessing there may be a race condition or something that is causing that to happen in multiple processes. (Extra info: we have the maximum number of logs -- eg max_backups has been reached). I'm not sure why you would ever want to open a log file in write mode, since append mode also creates the file if it doesn't exist.

$ lsof +fg |grep silo.production | grep -v W,AP
ruby      10894     seomoz   13w      REG       W,0x8000      252,0        3318     527976 /var/www/vhosts/silo/shared/log/silo.production000235.log
ruby      15449     seomoz   13w      REG       W,0x8000      252,0        4368     527976 /var/www/vhosts/silo/shared/log/silo.production000235.log
ruby      15909     seomoz   13w      REG       W,0x8000      252,0        4504     527976 /var/www/vhosts/silo/shared/log/silo.production000235.log
ruby      16020     seomoz   13w      REG       W,0x8000      252,0        4504     527976 /var/www/vhosts/silo/shared/log/silo.production000235.log
ruby      16122     seomoz   13w      REG       W,0x8000      252,0        4504     527976 /var/www/vhosts/silo/shared/log/silo.production000235.log

Include license file in the .gem release

Hi,

I am packaging log4r for Fedora and I need to include the license file alongside the source code. It would be beneficial and helpful if the license file(s) would be included in the official .gem release.

LEVEL can't be passed as parameter to yaml cfg file

If I would like to externalize the logging level using by example a variable with the name "LOGGING_LEVEL" as such within the yml config file

log4r_config:
  # define all loggers ...
  loggers:
    - name      : production
      level        :  "#{LOGGING_LEVEL}"

Code

      if level.nil?
        cfg['LOGGING_LEVEL'] = 'INFO'
      else
        cfg['LOGGING_LEVEL'] = levels[level]
      end

      cfg.decode_yaml log4r_f['log4r_config']

then log4r raise the following exception


/Users/chmoulli/.rbenv/versions/1.9.3-p484/lib/ruby/gems/1.9.1/gems/log4r-1.1.10/lib/log4r/yamlconfigurator.rb:189:in `decode_logger_common': Log level must be in 0..7 (ArgumentError)
    from /Users/chmoulli/.rbenv/versions/1.9.3-p484/lib/ruby/gems/1.9.1/gems/log4r-1.1.10/lib/log4r/yamlconfigurator.rb:175:in `decode_logger'
    from /Users/chmoulli/.rbenv/versions/1.9.3-p484/lib/ruby/gems/1.9.1/gems/log4r-1.1.10/lib/log4r/yamlconfigurator.rb:69:in `block in decode_yaml'
    from /Users/chmoulli/.rbenv/versions/1.9.3-p484/lib/ruby/gems/1.9.1/gems/log4r-1.1.10/lib/log4r/yamlconfigurator.rb:69:in `each'
    from /Users/chmoulli/.rbenv/versions/1.9.3-p484/lib/ruby/gems/1.9.1/gems/log4r-1.1.10/lib/log4r/yamlconfigurator.rb:69:in `decode_yaml'
    from /Users/chmoulli/MyProjects/hyla/lib/hyla/logger2.rb:37:in `initialize'

It seems that the file is parsed first with the hash{variable} and replacement is done after the parsing but of course that fails for the LEVEL as it tries to read the string of the hash string

screenshot 2015-03-27 13 58 01

Log4r::Logger.add incompatible with Ruby's Logger.add?

I have log4r working successfully in Rails 3.2.17 app running on Windows Server 2008 R2. However, when I tried starting a DelayedJob worker via rake I found it raised an error.

Basically, DelayedJob is calling logger.add (see delayed_job/lib/delayed/worker.rb line 248):

logger.add level, "#{Time.now.strftime('%FT%T%z')}: #{text}" if logger

This is valid for Ruby's Logger class (see Logger.add), however for log4r it tries to add an outputter in Log4r::Logger.add (see logger.rb line 119)

Is this expected behavior? Am I missing something?

Bugfix in get_current_sequence_number()

get_current_sequence_number() returns an invalid valid value if there is a file for which #{@core_file_name} ends with a digit and a second one being a prefix of the first.

For two log files named /my/path/file42.log and /my/path/file.log we will first create a /my/path/file42000001.log /my/path/file000001.log and later return 42000001 as the current maximum sequence number for file.log .

makeNewFilename will fail on line 137 with negative argument exception
padded_seq_no = "0" * (6 - @current_sequence_number.to_s.length) + @current_sequence_number.to_s

Thus, the regex is get_current_sequence_number() should be replaced with the more restrictive one from purge_log_files().

diff --git a/lib/log4r/outputter/rollingfileoutputter.rb b/lib/log4r/outputter/rollingfileoutputter.rb
index d8ecf0c..4cdd071 100644
--- a/lib/log4r/outputter/rollingfileoutputter.rb
+++ b/lib/log4r/outputter/rollingfileoutputter.rb
@@ -111,7 +111,7 @@ module Log4r
     def get_current_sequence_number()
       max_seq_no = 0
       Dir.foreach(@log_dir) do |child|
-        if child =~ /^#{@core_file_name}(\d+)#{@file_extension}$/
+        if child =~ /^#{@core_file_name}([0-9][0-9][0-9][0-9][0-9][0-9])#{@file_extension}$/
           seq_no = $1.to_i
           if (seq_no > max_seq_no)
             max_seq_no = seq_no

Feature Request: logger methods to always return nil

Background: Expected return value of a logging method call is nil.

Current behavior can be seen here.

TL;DR: When parentcall is nil, the @outputters collection will surprisingly be the return value of the call mylogger.warn 'halleluja'. That value is something like [], .i.e non-nil.

Proposed change: add a final nil line as the last line of the dynamically-defined "log-level methods".

Improved documentation

I've been using Log4r for a while, however, the documentation seems out of date, especially with rubyforge being dead.

Implement <<

The built in ruby logger has a << method that is not implemented by Log4r. We are able to get around the issue for our needs by monkey patching as follows, but that is not a generic solution:

class Log4r::Logger
  def <<(message)
    info(message)
  end
end

make a new release?

Hi,
Would it be possible to publish a release for log4r? there are no git tags here that match the rubygems.org releases and the last rubygems.org release was quite some time ago. Let me know if I can somehow help!

Can not be used under Rails 6.

Hi, when using Log4r in Rails6, using this approach: https://stackoverflow.com/questions/5664136/how-to-configure-log4r-with-rails-3-0-x/5959013

I met this error:

undefined method `tagged' for #<Proc:0x000055da3886f700 /opt/app/maomao/config/initializers/log4r_path.rb:3>

from this line of code: 
  <%= javascript_pack_tag 'application' %>

full trace is as below:

activesupport (6.1.4.1) lib/active_support/tagged_logging.rb:99:in `tagged'
webpacker (5.4.2) lib/webpacker/manifest.rb:58:in `compile'
webpacker (5.4.2) lib/webpacker/manifest.rb:42:in `lookup'
webpacker (5.4.2) lib/webpacker/manifest.rb:49:in `lookup!'
webpacker (5.4.2) lib/webpacker/helper.rb:182:in `block in sources_from_manifest_entries'
webpacker (5.4.2) lib/webpacker/helper.rb:182:in `map'
webpacker (5.4.2) lib/webpacker/helper.rb:182:in `sources_from_manifest_entries'
webpacker (5.4.2) lib/webpacker/helper.rb:81:in `javascript_pack_tag'
app/views/layouts/application.html.erb:8
actionview (6.1.4.1) lib/action_view/base.rb:247:in `public_send'
actionview (6.1.4.1) lib/action_view/base.rb:247:in `_run'
actionview (6.1.4.1) lib/action_view/template.rb:154:in `block in render'
activesupport (6.1.4.1) lib/active_support/notifications.rb:205:in `instrument'
actionview (6.1.4.1) lib/action_view/template.rb:345:in `instrument_render_template'
actionview (6.1.4.1) lib/action_view/template.rb:152:in `render'
actionview (6.1.4.1) lib/action_view/renderer/template_renderer.rb:72:in `block in render_with_layout'
activesupport (6.1.4.1) lib/active_support/notifications.rb:203:in `block in instrument'
activesupport (6.1.4.1) lib/active_support/notifications/instrumenter.rb:24:in `instrument'
activesupport (6.1.4.1) lib/active_support/notifications.rb:203:in `instrument'
actionview (6.1.4.1) lib/action_view/renderer/template_renderer.rb:70:in `render_with_layout'
actionview (6.1.4.1) lib/action_view/renderer/template_renderer.rb:55:in `render_template'
actionview (6.1.4.1) lib/action_view/renderer/template_renderer.rb:11:in `render'
actionview (6.1.4.1) lib/action_view/renderer/renderer.rb:61:in `render_template_to_object'
actionview (6.1.4.1) lib/action_view/renderer/renderer.rb:29:in `render_to_object'
actionview (6.1.4.1) lib/action_view/rendering.rb:117:in `block in _render_template'
actionview (6.1.4.1) lib/action_view/base.rb:273:in `in_rendering_context'
actionview (6.1.4.1) lib/action_view/rendering.rb:116:in `_render_template'
actionpack (6.1.4.1) lib/action_controller/metal/streaming.rb:218:in `_render_template'
actionview (6.1.4.1) lib/action_view/rendering.rb:103:in `render_to_body'
actionpack (6.1.4.1) lib/action_controller/metal/rendering.rb:52:in `render_to_body'
actionpack (6.1.4.1) lib/action_controller/metal/renderers.rb:142:in `render_to_body'
actionpack (6.1.4.1) lib/abstract_controller/rendering.rb:25:in `render'
actionpack (6.1.4.1) lib/action_controller/metal/rendering.rb:36:in `render'
actionpack (6.1.4.1) lib/action_controller/metal/instrumentation.rb:46:in `block (2 levels) in render'
/home/ubuntu/.rbenv/versions/3.0.2/lib/ruby/3.0.0/benchmark.rb:308:in `realtime'
activesupport (6.1.4.1) lib/active_support/core_ext/benchmark.rb:14:in `ms'
actionpack (6.1.4.1) lib/action_controller/metal/instrumentation.rb:46:in `block in render'
actionpack (6.1.4.1) lib/action_controller/metal/instrumentation.rb:86:in `cleanup_view_runtime'
activerecord (6.1.4.1) lib/active_record/railties/controller_runtime.rb:34:in `cleanup_view_runtime'
actionpack (6.1.4.1) lib/action_controller/metal/instrumentation.rb:45:in `render'
actionpack (6.1.4.1) lib/action_controller/metal/implicit_render.rb:35:in `default_render'
actionpack (6.1.4.1) lib/action_controller/metal/basic_implicit_render.rb:6:in `block in send_action'
<internal:kernel>:90:in `tap'
actionpack (6.1.4.1) lib/action_controller/metal/basic_implicit_render.rb:6:in `send_action'
actionpack (6.1.4.1) lib/abstract_controller/base.rb:228:in `process_action'
actionpack (6.1.4.1) lib/action_controller/metal/rendering.rb:30:in `process_action'
actionpack (6.1.4.1) lib/abstract_controller/callbacks.rb:42:in `block in process_action'
activesupport (6.1.4.1) lib/active_support/callbacks.rb:117:in `block in run_callbacks'
actiontext (6.1.4.1) lib/action_text/rendering.rb:20:in `with_renderer'
actiontext (6.1.4.1) lib/action_text/engine.rb:59:in `block (4 levels) in <class:Engine>'
activesupport (6.1.4.1) lib/active_support/callbacks.rb:126:in `instance_exec'
activesupport (6.1.4.1) lib/active_support/callbacks.rb:126:in `block in run_callbacks'
activesupport (6.1.4.1) lib/active_support/callbacks.rb:137:in `run_callbacks'
actionpack (6.1.4.1) lib/abstract_controller/callbacks.rb:41:in `process_action'
actionpack (6.1.4.1) lib/action_controller/metal/rescue.rb:22:in `process_action'
actionpack (6.1.4.1) lib/action_controller/metal/instrumentation.rb:34:in `block in process_action'
activesupport (6.1.4.1) lib/active_support/notifications.rb:203:in `block in instrument'
activesupport (6.1.4.1) lib/active_support/notifications/instrumenter.rb:24:in `instrument'
activesupport (6.1.4.1) lib/active_support/notifications.rb:203:in `instrument'
actionpack (6.1.4.1) lib/action_controller/metal/instrumentation.rb:33:in `process_action'
actionpack (6.1.4.1) lib/action_controller/metal/params_wrapper.rb:249:in `process_action'
activerecord (6.1.4.1) lib/active_record/railties/controller_runtime.rb:27:in `process_action'
actionpack (6.1.4.1) lib/abstract_controller/base.rb:165:in `process'
actionview (6.1.4.1) lib/action_view/rendering.rb:39:in `process'
actionpack (6.1.4.1) lib/action_controller/metal.rb:190:in `dispatch'
actionpack (6.1.4.1) lib/action_controller/metal.rb:254:in `dispatch'
actionpack (6.1.4.1) lib/action_dispatch/routing/route_set.rb:50:in `dispatch'
actionpack (6.1.4.1) lib/action_dispatch/routing/route_set.rb:33:in `serve'
actionpack (6.1.4.1) lib/action_dispatch/journey/router.rb:50:in `block in serve'
actionpack (6.1.4.1) lib/action_dispatch/journey/router.rb:32:in `each'
actionpack (6.1.4.1) lib/action_dispatch/journey/router.rb:32:in `serve'
actionpack (6.1.4.1) lib/action_dispatch/routing/route_set.rb:842:in `call'
rack (2.2.3) lib/rack/tempfile_reaper.rb:15:in `call'
rack (2.2.3) lib/rack/etag.rb:27:in `call'
rack (2.2.3) lib/rack/conditional_get.rb:27:in `call'
rack (2.2.3) lib/rack/head.rb:12:in `call'
actionpack (6.1.4.1) lib/action_dispatch/http/permissions_policy.rb:22:in `call'
actionpack (6.1.4.1) lib/action_dispatch/http/content_security_policy.rb:18:in `call'
rack (2.2.3) lib/rack/session/abstract/id.rb:266:in `context'
rack (2.2.3) lib/rack/session/abstract/id.rb:260:in `call'
actionpack (6.1.4.1) lib/action_dispatch/middleware/cookies.rb:689:in `call'
activerecord (6.1.4.1) lib/active_record/migration.rb:601:in `call'
actionpack (6.1.4.1) lib/action_dispatch/middleware/callbacks.rb:27:in `block in call'
activesupport (6.1.4.1) lib/active_support/callbacks.rb:98:in `run_callbacks'
actionpack (6.1.4.1) lib/action_dispatch/middleware/callbacks.rb:26:in `call'
actionpack (6.1.4.1) lib/action_dispatch/middleware/executor.rb:14:in `call'
actionpack (6.1.4.1) lib/action_dispatch/middleware/actionable_exceptions.rb:18:in `call'
actionpack (6.1.4.1) lib/action_dispatch/middleware/debug_exceptions.rb:29:in `call'
actionpack (6.1.4.1) lib/action_dispatch/middleware/show_exceptions.rb:33:in `call'
railties (6.1.4.1) lib/rails/rack/logger.rb:37:in `call_app'
railties (6.1.4.1) lib/rails/rack/logger.rb:28:in `call'
sprockets-rails (3.2.2) lib/sprockets/rails/quiet_assets.rb:13:in `call'
actionpack (6.1.4.1) lib/action_dispatch/middleware/remote_ip.rb:81:in `call'
actionpack (6.1.4.1) lib/action_dispatch/middleware/request_id.rb:26:in `call'
rack (2.2.3) lib/rack/method_override.rb:24:in `call'
rack (2.2.3) lib/rack/runtime.rb:22:in `call'
activesupport (6.1.4.1) lib/active_support/cache/strategy/local_cache_middleware.rb:29:in `call'
actionpack (6.1.4.1) lib/action_dispatch/middleware/executor.rb:14:in `call'
actionpack (6.1.4.1) lib/action_dispatch/middleware/static.rb:24:in `call'
rack (2.2.3) lib/rack/sendfile.rb:110:in `call'
actionpack (6.1.4.1) lib/action_dispatch/middleware/host_authorization.rb:98:in `call'
webpacker (5.4.2) lib/webpacker/dev_server_proxy.rb:25:in `perform_request'
rack-proxy (0.7.0) lib/rack/proxy.rb:63:in `call'
railties (6.1.4.1) lib/rails/engine.rb:539:in `call'
puma (5.4.0) lib/puma/configuration.rb:249:in `call'
puma (5.4.0) lib/puma/request.rb:77:in `block in handle_request'
puma (5.4.0) lib/puma/thread_pool.rb:340:in `with_force_shutdown'
puma (5.4.0) lib/puma/request.rb:76:in `handle_request'
puma (5.4.0) lib/puma/server.rb:440:in `process_client'
puma (5.4.0) lib/puma/thread_pool.rb:147:in `block in spawn_thread' 

Intermittent error: NoMethodError: undefined method `is_root?' for nil:NilClass

I get the following error intermittently. Mostly when using the logger in IRB, but other times too. Here is the basic code:

Configurator.load_xml_file("log4r_config.xml")
logger = Log4r::Logger["test"]

I'm on Ubuntu using ruby 1.9 and this config file will cause the issue:

   <log4r_config>
  <pre_config>
    <custom_levels>DEBUG, INFO, WARN, ERROR, FATAL</custom_levels>
    <global level="ALL"/>
  </pre_config>
    <outputter name="console_out" type="StdoutOutputter" level="DEBUG" >
        <formatter type="Log4r::PatternFormatter">
            <pattern>%d|level=%l|app=custom|%m</pattern>
            <date_method>strftime("%Y-%m-%d %H:%M:%S.%L")</date_method>
        </formatter>
    </outputter>
    <logger name="ConsoleOnly" additive="true" trace="true">
        <outputter>console_out</outputter>
    </logger>
   </log4r_config>
NoMethodError: undefined method `is_root?' for nil:NilClass
        from /home/project/vendor/ruby/1.9.1/gems/log4r-1.1.10/lib/log4r/loggerfactory.rb:62:in `set_log'
        from /home/project/vendor/ruby/1.9.1/gems/log4r-1.1.10/lib/log4r/loggerfactory.rb:39:in `block in toggle_methods'
        from /home/project/vendor/ruby/1.9.1/gems/log4r-1.1.10/lib/log4r/loggerfactory.rb:35:in `each'
        from /home/project/vendor/ruby/1.9.1/gems/log4r-1.1.10/lib/log4r/loggerfactory.rb:35:in `toggle_methods'
        from /home/project/vendor/ruby/1.9.1/gems/log4r-1.1.10/lib/log4r/loggerfactory.rb:19:in `define_methods'
        from /home/project/vendor/ruby/1.9.1/gems/log4r-1.1.10/lib/log4r/logger.rb:89:in `additive='
        from /home/project/vendor/ruby/1.9.1/gems/log4r-1.1.10/lib/log4r/configurator.rb:213:in `decode_logger_common'
        from /home/project/vendor/ruby/1.9.1/gems/log4r-1.1.10/lib/log4r/configurator.rb:197:in `decode_logger'
        from /home/project/vendor/ruby/1.9.1/gems/log4r-1.1.10/lib/log4r/configurator.rb:88:in `block in decode_xml'
        from /home/dnajd/.rbenv/versions/1.9.3-p484/lib/ruby/1.9.1/rexml/element.rb:905:in `block in each'
        from /home/dnajd/.rbenv/versions/1.9.3-p484/lib/ruby/1.9.1/rexml/xpath.rb:67:in `each'
        from /home/dnajd/.rbenv/versions/1.9.3-p484/lib/ruby/1.9.1/rexml/xpath.rb:67:in `each'
        from /home/dnajd/.rbenv/versions/1.9.3-p484/lib/ruby/1.9.1/rexml/element.rb:905:in `each'
        from /home/project/vendor/ruby/1.9.1/gems/log4r-1.1.10/lib/log4r/configurator.rb:88:in `decode_xml'
        from /home/project/vendor/ruby/1.9.1/gems/log4r-1.1.10/lib/log4r/configurator.rb:82:in `actual_load'
        from /home/project/vendor/ruby/1.9.1/gems/log4r-1.1.10/lib/log4r/configurator.rb:56:in `load_xml_file'

thread name output is not nice with jruby

if you haven't set Thread['name'](which sometimes you can't do nicely if you are working with third party libs), the thread name in the output comes out as #Thread:0x3b6c57b1

I've hacked around it with the following...

Log4r::PatternFormatter::DirectiveTable['h'] = 
  'Thread.current[:name] || Java::JavaLang::Thread.currentThread.name'

So it uses Thread[:name] at first, but falls back to the Java thread name if it isn't set. Could we add this in to log4r somehow?

License inconsistencies

Hi,

The LICENSE & LICENSE.bsd files in the repo list the license as BSD, but doc/content/license.html has it as GPL. I'm assuming it's BSD since that's front & center, but can you clarify this?

Thnx,
Dennis

1.1.10 also breaks configuration

If i have a third party outputter (log4r-gelf), it used to be that the initializer for that class was called with a hash containing symbols as keys. It now calls the initializer with strings for keys. Breaking changes like this should at least bump the minor version number.

related to wr0ngway/log4r-gelf#3

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.