# Mongrel cluster and Log4r?

**URL:** <https://www.ruby-forum.com/t/mongrel-cluster-and-log4r/112785>\
**Category:** Rails\
**Created:** [August 23, 2007, 7:18am UTC](https://www.ruby-forum.com/t/mongrel-cluster-and-log4r/112785 "2007-08-23T07:18:40Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![seb\_guard](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/50afbb/32.png) [@seb\_guard](https://www.ruby-forum.com/u/seb_guard)\
**Post date:** [August 23, 2007, 7:18am UTC](https://www.ruby-forum.com/t/mongrel-cluster-and-log4r/112785/1 "2007-08-23T07:18:40Z")

</div>

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…☹  
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”=\>“removed\_email\_address@domain.invalid”,  
“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
```

---

<div class="post-metadata">

**Author:** ![seb\_guard](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/50afbb/32.png) [@seb\_guard](https://www.ruby-forum.com/u/seb_guard)\
**Post date:** [August 24, 2007, 7:41am UTC](https://www.ruby-forum.com/t/mongrel-cluster-and-log4r/112785/2 "2007-08-24T07:41:40Z")

</div>

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 ☹

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
