# Define a source for log files.  This causes syslog-ng to
# listen on an IP that then allows your application server
# syslog-ng servers to talk to. 
source app_cluster { 
    udp( ip(<%= configuration[:syslog_ng][:log_server_ip] %>) port(<%= configuration[:syslog_ng][:log_server_port]%>)); 
}; 

# Define a destination.  Our filter will then map anything
# from our above source to this destination. 
destination d_rails_apps { 
  file( "/var/log/rails/$HOST/$PROGRAM.log" 
        owner("<%= configuration[:user] %>") 
        group("<%= configuration[:group] || configuration[:user] %>") 
        perm(0660) 
        dir_perm(0770) 
        create_dirs(yes)); 
}; 

destination d_passenger { 
  file( "/var/log/rails/$HOST/passenger.log" 
        owner("<%= configuration[:user] %>") 
        group("<%= configuration[:group] || configuration[:user] %>") 
        perm(0660) 
        dir_perm(0770) 
        create_dirs(yes)); 
}; 

# Now use the above source and destination to route our
# log file to the appropriate place. 
log {
  source(app_cluster); 
  filter (f_rails_apps); 
  destination(d_rails_apps); 
  flags(final);
};

log {
  source(app_cluster); 
  filter (f_passenger); 
  destination(d_passenger); 
  flags(final);
};

# Define a source for log files.  This causes syslog-ng to
# listen on an IP that then allows your application server
# syslog-ng servers to talk to. 
source app_cluster { 
    <%= configuration[:syslog_ng][:log_server_protocol] || "udp" %>( ip(<%= configuration[:syslog_ng][:log_server_ip] %>) port(<%= configuration[:syslog_ng][:log_server_port]%>)); 
}; 

# Define a destination.  Our filter will then map anything
# from our above source to this destination. 
destination d_rails_apps { 
  file( "/var/log/rails/$HOST/$PROGRAM.log" 
        owner("<%= configuration[:user] %>") 
        group("<%= configuration[:group] || configuration[:user] %>") 
        perm(0660) 
        dir_perm(0770) 
        create_dirs(yes)); 
}; 

destination d_passenger { 
  file( "/var/log/rails/$HOST/passenger.log" 
        owner("<%= configuration[:user] %>") 
        group("<%= configuration[:group] || configuration[:user] %>") 
        perm(0660) 
        dir_perm(0770) 
        create_dirs(yes)); 
}; 

# Now use the above source and destination to route our
# log file to the appropriate place. 
log {
  source(app_cluster); 
  filter (f_rails_apps); 
  destination(d_rails_apps); 
  flags(final);
};

log {
  source(app_cluster); 
  filter (f_passenger); 
  destination(d_passenger); 
  flags(final);
};

Allow protocol override for logging.
Allow protocol override for logging.
