Questions tagged [log4r]

Log4r is a logging library for Ruby akin to Log4j for those coming from Java.

Log4r is a comprehensive and flexible logging library written in Ruby for use in Ruby programs. It features a hierarchical logging system of any number of levels, custom level names, logger inheritance, multiple output destinations, execution tracing, custom formatting, thread safteyness, XML and YAML configuration, and more. Log4r is an adherent to the philosophy of logging using simple print statements. What Log4r adds to this philosophy is a flexible way of controling the information being logged. Log information can be sent to any kind of destination and with varying degrees of importance. Log4r is designed so that logging statements can remain in production code with almost no extra computational cost.

Log4r intends to be easy to use and configure, no matter the complexity. Casual scripts can use Log4r right away with minimal configuration, while more sophisticated applications can set up a structured configuration file in XML or YAML. Comprehensive documentation is provided, with a user's manual, a reference API, and over a dozen examples. Log4r attempts to abide by the Principle of Least Surprise, which means that it works as intended at all points.

Log4r was inspired by and provides much of the features of the Apache Log4j project, but is not a direct implementation or clone. Aside from superficial similarities, the projects are not related in any way and the code base is completely distinct. Log4r was developed without even looking at the Apache Log4j code.

Log4r is an Open Source project and intends to remain that way. The Log4r license is similar to the Ruby Language license.

57 questions
2
votes
1 answer

Is Log4r Actually Threadsafe in a Rails 4 Application?

Setting the Scene In an effort to make the default Rails logging more helpful in a production environment, I have been taking advantage of Log4r and its diagnostic context, specifically MDC. In addition to the logs that come out of the Rails…
2
votes
1 answer

Log4r using yml configurator: The log message won't include trace

I'm trying to configure log4r with yml configuration file. Everything is configured as per the doc, but the log message won't include the class_name or trace. However it works fine with manual configuration without yml , but since it doesn't provide…
Niroj
  • 66
  • 6
2
votes
0 answers

Log4r is not writing logs after few days( 7 days)

Two instance of process were running on each server(total 2 servers) and it stopped writing logs in all 4 logs file(each process has its respective log file) after a week when process were started. Process are still running but each process has…
2
votes
1 answer

Ruby on Rails log4r and rabbitMQ Custom Outputter

I am trying to create a custom outputter that logs remotely using a message queue... I found an outputter in the log4r project and tried to modify it... but i suck... so there is likely a WAY better way to do this. i.e.: one that works. ;) Here i…
Pandem1c
  • 778
  • 1
  • 5
  • 12
1
vote
0 answers

Override logging in thin

I am starting thin in a cluster with 4 thin instances(with Sinatra). It seems that thin creates 4 different log files, one for each instance. I want to override this logging behavior. My requirements :- Single log file for all thin instances.…
randomuser
  • 1,858
  • 2
  • 17
  • 21
1
vote
1 answer

Set up 2 log files with log4r

I have added log4r in my Rails 2.3.8 project. I want to create 2 log files. For application login (INFO messages) (application.log) Error messages (any message other than info message) (errors.log) Following are my yml configuration files for each…
sameera207
  • 16,547
  • 19
  • 87
  • 152
1
vote
2 answers

Use Log4r as logger in Sinatra App

I want to use log4r with log-levels info, warn and error in a Sinatra 1.3.1 app. The output should go to requests.log (http requests), error.log and sinatra.log (other outputs). How do I go about configuring it? I've just spent a lot of time…
scrrr
  • 5,135
  • 7
  • 42
  • 52
1
vote
1 answer

rails6 log4r tagged_logging.rb:22:in `call': wrong number of arguments

When I use log4r in rails 6, I report the following error This is the complete error information .rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/activesupport-6.0.3.2/lib/active_support/tagged_logging.rb:22:in `call': wrong number of arguments (given…
周永建
  • 113
  • 6
1
vote
1 answer

How to configure log4r for logstash

Someone please show me an example of log4r configuration for sending logs to logstash. My rails application lies in a remote server. Also logstash configuration for recieving log4r logs. Thanks in Advance
Babeesh
  • 107
  • 1
  • 1
  • 10
1
vote
2 answers

Rails logging 404 errors in a separate logfile

I'm searching for a while now a way to log only 404 errors in another log file than the other errors. Is there a way to do it with the ruby logger or with log4r, in that way that the logging only happens in the new created log file?
Joschka Schulz
  • 674
  • 1
  • 8
  • 18
1
vote
0 answers

Log4r Yaml Configuration Dymamically Change

I'm trying to use Log4r in ruby for logging purposes. I would like to be able to dynamically change the yaml configuration file for the logger on the fly (example: log level) and have that change automatically propagate through to the logger. I know…
fowlball1010
  • 343
  • 3
  • 13
1
vote
0 answers

Is it possible to use log4r ( logger for Ruby ) to send SNMP traps?

Similar loggers - log4j, log4net etc., have "SNMP appenders", cannot find same for log4r If not log4r, is there an alternative logger for Ruby that has SNMP trap send feature ?
twenty20
  • 59
  • 8
1
vote
1 answer

NameError: uninitialized constant Logger - Should I be doing this differently?

Fairly new to ruby, playing with Mini Test and log4r, trying to write a wrapper class. Getting the following error: Run options: --seed 18181 # Running tests: E Finished tests in 0.015625s, 63.9996 tests/s, 0.0000 assertions/s. 1)…
jbobbylopez
  • 257
  • 2
  • 6
  • 15
1
vote
2 answers

Error using Log4r

I have a problem using Log4r. uninitialized constant Log4r::Logger::RootLogger I tried this, but still got an error: >> require "log4r" => true >> Log4r::DEBUG NameError: uninitialized constant Log4r::DEBUG >> Log4r::Logger.root => uninitialized…
user2503775
  • 4,267
  • 1
  • 23
  • 41
1
vote
1 answer

Can I set Log4r log level per file/class?

Note: I am talking about Ruby, not Rails. Is there any way to have Log4r levels set based on the class or file it's logging from? This is my current configuration for Log4r: --- log4r_config: loggers: - name: logger level: INFO …
Zoltán
  • 21,321
  • 14
  • 93
  • 134