--- main/logger.c	(revision 138020)
+++ main/logger.c	(working copy)
@@ -353,16 +353,34 @@
 void ast_queue_log(const char *queuename, const char *callid, const char *agent, const char *event, const char *fmt, ...)
 {
 	va_list ap;
-	AST_LIST_LOCK(&logchannels);
-	if (qlog) {
+ 	char qlog_msg[8192];
+	char time_str[16];
+
+	if (ast_check_realtime("queue_log")) {
 		va_start(ap, fmt);
-		fprintf(qlog, "%ld|%s|%s|%s|%s|", (long)time(NULL), callid, queuename, agent, event);
-		vfprintf(qlog, fmt, ap);
-		fprintf(qlog, "\n");
+		vsnprintf(qlog_msg, sizeof(qlog_msg), fmt, ap);
 		va_end(ap);
-		fflush(qlog);
+
+		snprintf(time_str, sizeof(time_str), "%ld", (long)time(NULL));
+		ast_store_realtime("queue_log", "time", time_str, 
+						"callid", callid, 
+						"queuename", queuename, 
+						"agent", agent, 
+						"event", event,
+						"data", qlog_msg,
+						NULL);
+	} else {
+		if (qlog) {
+			AST_LIST_LOCK(&logchannels);
+			va_start(ap, fmt);
+			fprintf(qlog, "%ld|%s|%s|%s|%s|", (long)time(NULL), callid, queuename, agent, event);
+			vfprintf(qlog, fmt, ap);
+			fprintf(qlog, "\n");
+			va_end(ap);
+			fflush(qlog);
+			AST_LIST_UNLOCK(&logchannels);
+		}
 	}
-	AST_LIST_UNLOCK(&logchannels);
 }
 
 int reload_logger(int rotate)
