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
34
votes
4 answers

Is Ruby's stdlib Logger class thread-safe?

In short, is the standard library Logger class in Ruby thread-safe? Only useful info Google turned up was someone on a forum saying it "seems" thread-safe. And I don't feel like spending time testing a logger to try to figure out if it is or…
jimeh
  • 1,391
  • 1
  • 16
  • 32
16
votes
3 answers

How to configure Log4r with Rails 3.0.x?

I tried configuring log4r with Rails 3.0.4 based on this article: http://www.dansketcher.com/2007/06/16/integrating-log4r-and-ruby-on-rails/ /Users/toto/.rvm/gems/ruby-1.9.2-p0/gems/log4r-1.1.9/lib/log4r/yamlconfigurator.rb:166:in `sub!': can't…
user553620
  • 775
  • 9
  • 17
12
votes
1 answer

Sidekiq logging to both terminal and log file

I'm using Sidekiq to queue up some jobs in my Rails server. As per the Logging wiki, it's as simple as adding the following in config/sidekiq.yml --- :verbose: false :pidfile: ./tmp/pids/sidekiq.pid :logfile: ./log/sidekiq.log :concurrency: …
absessive
  • 1,121
  • 5
  • 14
  • 36
10
votes
2 answers

What is the best Rails Logging Gem

what is the best way of configuring Logging features on a rails project? I'm looking for something like Log4J which is available to Rails. I have found log4r and it's conflicting built in Logger class and also tried 'Logging' gem and It has some…
Pradeep Sanjaya
  • 1,816
  • 1
  • 15
  • 23
7
votes
2 answers

Properly using Log4r in Ruby Application

I must really be missing something obvious, but I'm having trouble with general use of Log4r in my Ruby application. I am able to log without issue, but the overhead seems clunky the way I have it setup. I'm basically passing the full path to a…
Spencer
  • 85
  • 1
  • 7
6
votes
3 answers

rails 4 log4r server.rb:78:in `start': undefined method `formatter'

I have been researching this topic for far too long now, so I have to post this. I have a few applications running this setup and one of them completely borks on rails startup (rails s). They are both configured nearly the exact same, but I can not…
Chris Hough
  • 3,389
  • 3
  • 41
  • 80
5
votes
4 answers

How can I test logger-messages with MiniTest?

I have an application and I want to test if I get correct messages from my logger. A short example (you may switch between log4r and logger): gem 'minitest' require 'minitest/autorun' require 'log4r' #~ require 'logger' class Testlog <…
knut
  • 27,320
  • 6
  • 84
  • 112
5
votes
1 answer

Undefined Method Formatter for Log4r in RAILS 4.0

I am getting this error after upgrading Rails from 3.1.2 to 4.0. When launching my server with rails s I got stuck with the following error C:/ruby-2.0.0/lib/ruby/gems/2.0.0/gems/railties-4.0.0/lib/rails/commands/server.rb:78:in `start': undefined…
Pol0nium
  • 1,346
  • 4
  • 15
  • 31
4
votes
2 answers

Log4r : logger inheritance, yaml configuration, alternatives?

I'm pretty new to ruby environments and I was looking for a nice logging framework to use it my ruby and rails applications. In my previous experiences I have successfully used log4j and log4p (the perl port) and was expecting the same level of…
devlearn
  • 1,725
  • 2
  • 17
  • 30
3
votes
3 answers

Ruby: Uninitialized constant Log4r::DEBUG (NameError) problem

While using log4r in Ruby, I wrote a configuration file similar to the following: require 'rubygems' require 'log4r' require 'log4r/outputter/datefileoutputter' SERVICE_LOG = { :log_name => 'service', :log_file =>…
ywenbo
  • 3,051
  • 6
  • 31
  • 46
3
votes
1 answer

Log4r - include class name in log output

I'd like to include the name of the class that invokes the logger in the log output, such as: [MyClass] here is the message I've seen the option of using the Contexts but I don't want to have to do something like this throughout my app when I log…
codecraig
  • 3,118
  • 9
  • 48
  • 62
3
votes
1 answer

How to implement logging in rails using rails?

I am working on a project and I have to use logging in the project, I have chosen log4r for logging. Well I want to know what is the best way for implementing it: Should I create a single instance and use that instance for whole application Should…
rajansoft1
  • 1,336
  • 2
  • 18
  • 38
3
votes
2 answers

syslog output for log4r example

Can some one post an example of using syslog outputter for log4r, I am currently using stdout but want to log to syslog. mylog = Logger.new 'mylog' mylog.outputters = Outputter.stdout mylog.info "Starting up." raj Thanks also to the following blog…
Rajkumar S
  • 2,471
  • 5
  • 23
  • 28
3
votes
0 answers

IOError Input/Output Error When Printing to logger

I have a simple function, that being called from worker and prints lines into logger - using log4r. I'm sometimes getting this error in my log: Errno::EIO: Input/output error - Seems that it is unable to write to STDOUT. When/why could the…
user2503775
  • 4,267
  • 1
  • 23
  • 41
2
votes
0 answers

How to find out exception line number in R

I am new to R language. I gone through exception handling frame work tutorials, but i can't able to find any options to print entire error stack trace , below is my code getData<-function(a,b){ c=NULL tryCatch({ c=a+b …
1
2 3 4