diff --git a/plugins/out_syslog/syslog.c b/plugins/out_syslog/syslog.c
index 4ecc7c4ac..cfe568245 100644
--- a/plugins/out_syslog/syslog.c
+++ b/plugins/out_syslog/syslog.c
@@ -776,12 +776,42 @@ static flb_sds_t syslog_format(struct flb_syslog *ctx, msgpack_object *o,
         }
 
         if (ctx->parsed_mode != FLB_SYSLOG_UDP) {
+            unsigned int msg_len = 0;
+
+            /* Create new SDS for length prefix */
+            flb_sds_t prefix = flb_sds_create_size(ctx->maxsize + 32);
+            if (!prefix) {
+                ret_sds = NULL;
+                goto clean;
+            }
+
+            /* Add newline also to make behaviour similar to syslog-ng */
             tmp = flb_sds_cat(*s, "\n", 1);
             if (!tmp) {
+                flb_sds_destroy(prefix);
                 ret_sds = NULL;
                 goto clean;
             }
             *s = tmp;
+
+            msg_len = flb_sds_len(*s);
+            tmp = flb_sds_printf(&prefix, "%u ", msg_len);
+            if (!tmp) {
+                flb_sds_destroy(prefix);
+                ret_sds = NULL;
+                goto clean;
+            }
+            prefix = tmp;
+
+            tmp = flb_sds_cat(prefix, *s, msg_len);
+            if (!tmp) {
+                flb_sds_destroy(prefix);
+                ret_sds = NULL;
+                goto clean;
+            }
+
+            flb_sds_destroy(*s);
+            *s = tmp;
         }
     }
     else {
