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
1
vote
1 answer

Ruby Log4r has issues printing twice the log messages

I use log4r as my logger. I have two questions to the fourum. I find a mysterious behavior, such that the log messages are printed twice in STDOUT. I don’t understand why it is occurring and how to fix. I would like to provide color coding for the…
user2562153
  • 317
  • 1
  • 3
  • 12
1
vote
1 answer

How to log in a Ruby worker script of a Rails app that does not have the environment?

I'm using rufus-scheduler for handling cron jobs for a Rails 3.2.x app. The root worker.rb is being fired off by foreman (actually upstart on this particular server) and therefore when it starts off it does not have the Rails context in which to…
ylluminate
  • 12,102
  • 17
  • 78
  • 152
1
vote
1 answer

How to direct Unicorn stdout and stderr to log4r logs?

I have set up log4r as per outlined here: "How to configure Log4r with Rails 3.0.x?" However now I'm faced with unicorn not sending its output to the log4r logs. How do you do this?
ylluminate
  • 12,102
  • 17
  • 78
  • 152
0
votes
1 answer

Ruby on Rails - Using LogServer for Remote Logging in log4r using ROMP

I am a complete newbie in working with a Ruby on Rails (RoR) application. I am trying to set up a LogServer and tried running the example available on github : https://github.com/colbygk/log4r/blob/master/examples/logserver.rb and the…
Krishnan
  • 3
  • 3
0
votes
0 answers

R 'log4r' package installation issue and issue with cran mirror

Why am I getting the following error when I am trying to install 'log4r' package? Warning in install.packages : unable to access index for repository http://cran.rstudio.com/src/contrib: cannot open URL…
PikaPika
  • 9
  • 3
0
votes
1 answer

Log4r and Chainsaw: gathering additional log message details (line number, etc.)?

I'm using Log4r's Log4j XML formatter to talk to Chainsaw as described here in Log4r's manual. However, basically all I'm getting is the message and warning level -- I'm not getting the additional details that seem to be shown there. Here's the…
Joseph Weissman
  • 5,697
  • 5
  • 46
  • 75
0
votes
1 answer

Package log4r-mongoDB integration

I explored the log4r package and found that we have console and file appenders. I am looking for pushing the logs to a mongoDB database. I am unable to find any way in pushing the logs to mongoDB, do we have any appender for the same. TIA
0
votes
1 answer

Contextual Logging with Log4r

Here's how some of my existing logging code with Log4r is working. As you can see in the WorkerX::a_method, any time that I log a message I want the class name and the calling method to be included (I don't want all the caller history or any other…
keruilin
  • 16,782
  • 34
  • 108
  • 175
0
votes
0 answers

Unwanted logs using log4r on RoR 4.1

I'm using RoR 4.1.12 and log4r gem for formatting the log. I thought that everything is OK, but if I want to change the log level it has no influence at all. I have the following config/log4r_init.rb: require 'log4r' require…
Tibor Nagy
  • 1,185
  • 1
  • 15
  • 28
0
votes
1 answer

Log4r const_get issue with rails 4.2.4

I try to configure log4r with my application: Gem info: gem 'log4r', '1.1.10' gem 'rails', '4.2.4' gem 'mysql2', '0.3.20' application.rb require 'log4r' require 'log4r/yamlconfigurator' require 'log4r/outputter/datefileoutputter' include…
0
votes
1 answer

Ruby On Rails log file name and line number

Right now, I use log4r for logger in Rails to print file name and line number: ======== config/log4r.yml ======== log4r_config: # define all loggers: loggers: - name : rails level : DEBUG trace : 'true' …
fudy
  • 1,540
  • 5
  • 25
  • 41
0
votes
1 answer

How to make log4r output messages syncronous?

I wonder why do I have raised exception between the logger debug output? DEBUG: asdjoasjd DEBUG: asdjoasjd DEBUG: asdjoasjd **RuntimeError: something** DEBUG: continued debug message DEBUG: continued debug message DEBUG: continued…
Alexander.Iljushkin
  • 4,519
  • 7
  • 29
  • 46
0
votes
1 answer

How to create custom levels in log4r via yaml

I have a Rails 4.1 app using log4r 1.1.10 configured via yaml and everything works fine. Now I just want to add a custom level. So at the top of my yaml file I added seven lines after log4r_config: log4r_config: pre_config: custom_levels: …
RussK
  • 199
  • 1
  • 17
0
votes
1 answer

Log4r. How to write two log files from one logger.

I used the following tutorial to configure logging in my rails application http://blog.mmlac.com/log4r-for-rails/ log4r.yml log4r_config: pre_config: custom_levels: - DEBUG - PARAMS - INFO - WARN - ERROR - EXCEPTION …
PaintedRed
  • 1,398
  • 5
  • 19
  • 30
0
votes
1 answer

undefined method `logger=' for Neo4j::ActiveNode:Module (NoMethodError)

I am trying to use log4r with rails 4 and neo4j. I have log4r with Active record and it works fine but I am unable to get it working with neo4j. Main problem which I think is the logger method which is not available for neo4j. I am using gem…
vishB
  • 1,688
  • 2
  • 17
  • 23