Mongrel cluster and Log4r?

Hi everyone,

Anybody is using Mongrel cluster and log4r (FileOutputter) in production
?
I am using that 3 mongrel clusters on the same server, logging to
log/production.log with log4r FileOutputter.
But unfortunately my logs get somehow interlaced…:frowning:
In one line I have a bit of log of process PID A as well as bit of log
of process ID B.

i looked a the Log4r manual about thread saftyness… i see nothing wrong
in my log4r config

Here is an example of log line I got :
< INFO> Aug 23 15:01:26 [4997]: Parameters:
{“user”=>{“login_email”=>“[email protected]”,
“challenge”=>“4c937c1698c583ff43afsdeb059cdf50c7c7a7c6”,< INFO> Aug 23
15:01:26 [5000]:

below is the my log4r config YML file.

log4r_config:

define all loggers …

loggers:
- name : default
level : DEBUG
additive : ‘true’
trace : ‘false’
outputters:
- fastFileOutputter

outputters:

- type     : FileOutputter
  name     : fastFileOutputter
  level    : DEBUG
  filename : "#{log_dir}/#{RAILS_ENV}.log"
  formatter:
    date_pattern: '%b %d %H:%M:%S'
    pattern     : "<%5l> %d [#{pid}]: %m"
    type        : PatternFormatter

After further investigation into the Log4r source code, I realized I was
missing one really important config parameter : ‘trunc’.

This should absolutely be set to true in a cluster environement
otherwise you will likely have interlaced logs :frowning:

problem soldved.

below is the final working config

log4r_config:

define all loggers …

loggers:
- name : default
level : DEBUG
additive : ‘true’
trace : ‘false’
outputters:
- fastFileOutputter

outputters:

- type     : FileOutputter
  name     : fastFileOutputter
  level    : DEBUG
  filename : "#{log_dir}/#{RAILS_ENV}.log"
  trunc    : 'false'
  formatter:
    date_pattern: '%b %d %H:%M:%S'
    pattern     : "<%5l> %d [#{pid}]: %m"
    type        : PatternFormatter

-sebastien CANTE

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs