Index: configs/cdr_custom.conf.sample
===================================================================
--- configs/cdr_custom.conf.sample	(revision 123009)
+++ configs/cdr_custom.conf.sample	(working copy)
@@ -1,10 +1,16 @@
 ;
 ; Mappings for custom config file
 ;
-; to get your csv output in a format tailored to your liking, uncomment the following
-; and look for the output in the cdr-custom/Master.csv file (usually in /var/log/asterisk).
-; 
+; to get your csv output in a format tailored to your liking, there are two options:
+
+; 1) uncomment the following and look for the output in the 
+;     cdr-custom/Master.csv file (usually in /var/log/asterisk).
 ;
+; 2) use syslogd by adding an entry to the mappings context.utput to syslogd.
+;    example:
+;       syslog.asterisk-cdr => ...
+;    In this example "asterisk-cdr" is an identity defined in /etc/syslog.conf
+;
 ;[mappings]
 ;Master.csv => "${CDR(clid)}","${CDR(src)}","${CDR(dst)}","${CDR(dcontext)}","${CDR(channel)}","${CDR(dstchannel)}","${CDR(lastapp)}","${CDR(lastdata)}","${CDR(start)}","${CDR(answer)}","${CDR(end)}","${CDR(duration)}","${CDR(billsec)}","${CDR(disposition)}","${CDR(amaflags)}","${CDR(accountcode)}","${CDR(uniqueid)}","${CDR(userfield)}"
 
Index: cdr/cdr_custom.c
===================================================================
--- cdr/cdr_custom.c	(revision 123009)
+++ cdr/cdr_custom.c	(working copy)
@@ -29,13 +29,19 @@
  * Logs in LOG_DIR/cdr_custom
  * \ingroup cdr_drivers
  */
-
+#define _ASTERISK_LOGGER_H
 #include "asterisk.h"
 
 ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
 
 #include <time.h>
 
+#define SYSLOG_NAMES
+#include <syslog.h>
+
+#undef _ASTERISK_LOGGER_H
+
+#include "asterisk/logger.h"
 #include "asterisk/paths.h"	/* use ast_config_AST_LOG_DIR */
 #include "asterisk/channel.h"
 #include "asterisk/cdr.h"
@@ -44,49 +50,84 @@
 #include "asterisk/pbx.h"
 #include "asterisk/utils.h"
 #include "asterisk/lock.h"
+#include "asterisk/linkedlists.h"
 
 #define CUSTOM_LOG_DIR "/cdr_custom"
 
 #define DATE_FORMAT "%Y-%m-%d %T"
 
+#define FORMAT_SIZE 1024
+
 AST_MUTEX_DEFINE_STATIC(lock);
 AST_MUTEX_DEFINE_STATIC(mf_lock);
 
 static char *name = "cdr-custom";
 
 static char master[PATH_MAX];
-static char format[1024]="";
+static char format[FORMAT_SIZE]="";
 
+struct syslog_format {
+	char ident[128];
+	char format[FORMAT_SIZE];
+	AST_LIST_ENTRY(syslog_format) entry;
+};
+
+static AST_LIST_HEAD_STATIC(cdrsyslog, syslog_format);
+
 static int load_config(int reload) 
 {
 	struct ast_config *cfg;
 	struct ast_variable *var;
 	struct ast_flags config_flags = { reload ? CONFIG_FLAG_FILEUNCHANGED : 0 };
+	struct syslog_format *sysf;
 	int res = -1;
 
 	if ((cfg = ast_config_load("cdr_custom.conf", config_flags)) == CONFIG_STATUS_FILEUNCHANGED)
 		return 0;
 
+	while ((sysf = AST_LIST_REMOVE_HEAD(&cdrsyslog, entry))) {
+		ast_free(sysf);
+	}
+
 	strcpy(format, "");
 	strcpy(master, "");
+
 	ast_mutex_lock(&lock);
+
 	if (cfg) {
 		var = ast_variable_browse(cfg, "mappings");
-		while(var) {
-			if (!ast_strlen_zero(var->name) && !ast_strlen_zero(var->value)) {
+
+		for (; var; var = var->next) {
+			if (ast_strlen_zero(var->name) || ast_strlen_zero(var->value)) {
+				ast_log(LOG_NOTICE, "Mapping must have both filename, or syslog and an ident, and format at line %d\n", var->lineno);
+				continue;
+			}
+
+			if (!strncasecmp(var->name, "syslog.", 7) && *(var->name + 7)) {
+				sysf = ast_calloc(1, sizeof(*sysf));
+
+				if (strlen(var->value) > (sizeof(sysf->format) - 1))
+					ast_log(LOG_WARNING, "Format string too long, will be truncated, at line %d\n", var->lineno);
+
+				ast_copy_string(sysf->ident, var->name + 7, sizeof(sysf->ident));
+				ast_copy_string(sysf->format, var->value, sizeof(sysf->format));
+
+				AST_LIST_INSERT_TAIL(&cdrsyslog, sysf, entry);
+			} else if (ast_strlen_zero(master)) {
 				if (strlen(var->value) > (sizeof(format) - 1))
 					ast_log(LOG_WARNING, "Format string too long, will be truncated, at line %d\n", var->lineno);
+
 				ast_copy_string(format, var->value, sizeof(format) - 1);
 				strcat(format,"\n");
 				snprintf(master, sizeof(master),"%s/%s/%s", ast_config_AST_LOG_DIR, name, var->name);
-				if (var->next) {
-					ast_log(LOG_NOTICE, "Sorry, only one mapping is supported at this time, mapping '%s' will be ignored at line %d.\n", var->next->name, var->next->lineno); 
-					break;
-				}
-			} else
-				ast_log(LOG_NOTICE, "Mapping must have both filename and format at line %d\n", var->lineno);
-			var = var->next;
+			} else {
+				ast_log(LOG_WARNING, "Mappings are only supported for one master file and syslog.[ident] at this time, '%s' will be ignored.", var->name);
+				break;
+			}
+
+			ast_log(LOG_DEBUG, "Loaded '%s'.\n", var->name);
 		}
+
 		ast_config_destroy(cfg);
 		res = 0;
 	} else {
@@ -95,6 +136,7 @@
 		else
 			ast_log(LOG_WARNING, "Failed to load configuration file. Module not activated.\n");
 	}
+
 	ast_mutex_unlock(&lock);
 	
 	return res;
@@ -105,18 +147,28 @@
 static int custom_log(struct ast_cdr *cdr)
 {
 	FILE *mf = NULL;
+	struct syslog_format *sysf;
 
 	/* Make sure we have a big enough buf */
 	char buf[2048];
 	struct ast_channel dummy;
 
+	/* Quite possibly the first use of a static struct ast_channel, we need it so the var funcs will work */
+	memset(&dummy, 0, sizeof(dummy));
+	dummy.cdr = cdr;
+
+	AST_LIST_TRAVERSE(&cdrsyslog, sysf, entry) {
+		pbx_substitute_variables_helper(&dummy, sysf->format, buf, sizeof(buf) - 1);
+
+		openlog(sysf->ident, LOG_CONS, LOG_DAEMON);
+		syslog(LOG_INFO, "%s", buf);
+		closelog();
+	}
+
 	/* Abort if no master file is specified */
 	if (ast_strlen_zero(master))
 		return 0;
 
-	/* Quite possibly the first use of a static struct ast_channel, we need it so the var funcs will work */
-	memset(&dummy, 0, sizeof(dummy));
-	dummy.cdr = cdr;
 	pbx_substitute_variables_helper(&dummy, format, buf, sizeof(buf) - 1);
 
 	/* because of the absolutely unconditional need for the
