diff --git a/log4j-core/pom.xml b/log4j-core/pom.xml
index c10e8bc..88cfffd 100644
--- a/log4j-core/pom.xml
+++ b/log4j-core/pom.xml
@@ -220,6 +220,11 @@
       <artifactId>json-unit</artifactId>
       <scope>test</scope>
     </dependency>
+    <dependency>
+      <groupId>commons-io</groupId>
+      <artifactId>commons-io</artifactId>
+      <scope>test</scope>
+    </dependency>
     <!-- Other -->
     <dependency>
       <groupId>commons-codec</groupId>
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/layout/GelfLayout.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/layout/GelfLayout.java
index b85cbcf..98e0c4c 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/layout/GelfLayout.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/layout/GelfLayout.java
@@ -90,19 +90,15 @@ public final class GelfLayout extends AbstractStringLayout {
         return new GelfLayout(host, additionalFields, compressionType, compressionThreshold);
     }
 
-    static String formatTimestamp(final long timeMillis) {
-        return new BigDecimal(timeMillis).divide(TIME_DIVISOR).toPlainString();
-    }
+    private final String host;
 
     private final KeyValuePair[] additionalFields;
 
-    private final String host;
+    private final CompressionType compressionType;
 
     private final int compressionThreshold;
 
-    private CompressionType compressionType;
-
-    public GelfLayout(final String host, final KeyValuePair[] additionalFields, CompressionType compressionType,
+    public GelfLayout(final String host, final KeyValuePair[] additionalFields, final CompressionType compressionType,
             final int compressionThreshold) {
         super(Charsets.UTF_8);
         this.host = host;
@@ -135,21 +131,26 @@ public final class GelfLayout extends AbstractStringLayout {
         }
     }
 
-    private String escapeJson(final String s) {
-        return s.replace("\\", "\\\\").replace("\"", "\\\"");
+    static String formatTimestamp(final long timeMillis) {
+        return new BigDecimal(timeMillis).divide(TIME_DIVISOR).toPlainString();
+    }
+
+    static String escapeJson(final String s) {
+        return s.replace("\\", "\\\\").replace("\"", "\\\"").replace("\r","\\r").replace("\n","\\n").replace("\t","\\t");
     }
 
     /**
      * http://en.wikipedia.org/wiki/Syslog#Severity_levels
      */
-    private int formatLevel(final Level level) {
+    static int formatLevel(final Level level) {
         return Severity.getSeverity(level).getCode();
     }
 
-    private String formatThrowable(final Throwable throwable) {
+    static String formatThrowable(final Throwable throwable) {
         final StringWriter sw = new StringWriter();
         final PrintWriter pw = new PrintWriter(sw);
         throwable.printStackTrace(pw);
+        pw.flush();
         return sw.toString();
     }
 
diff --git a/log4j-core/src/test/java/org/apache/logging/log4j/core/layout/GelfLayoutTest.java b/log4j-core/src/test/java/org/apache/logging/log4j/core/layout/GelfLayoutTest.java
index 207d1b6..88d3b51 100644
--- a/log4j-core/src/test/java/org/apache/logging/log4j/core/layout/GelfLayoutTest.java
+++ b/log4j-core/src/test/java/org/apache/logging/log4j/core/layout/GelfLayoutTest.java
@@ -24,11 +24,15 @@ import org.apache.logging.log4j.core.config.ConfigurationFactory;
 import org.apache.logging.log4j.core.layout.GelfLayout.CompressionType;
 import org.apache.logging.log4j.core.util.KeyValuePair;
 import org.apache.logging.log4j.test.appender.ListAppender;
+import org.apache.commons.io.IOUtils;
 import org.junit.AfterClass;
 import org.junit.BeforeClass;
 import org.junit.Test;
 
+import java.io.ByteArrayInputStream;
+import java.io.InputStream;
 import java.util.List;
+import java.util.zip.GZIPInputStream;
 
 import static net.javacrumbs.jsonunit.JsonAssert.assertJsonEquals;
 
@@ -48,6 +52,7 @@ public class GelfLayoutTest {
 
     private static final String LINE1 = "empty mdc";
     private static final String LINE2 = "filled mdc";
+    private static final String LINE3 = "error message";
 
     static ConfigurationFactory configFactory = new BasicConfigurationFactory();
 
@@ -70,19 +75,22 @@ public class GelfLayoutTest {
         for (final Appender appender : root.getAppenders().values()) {
             root.removeAppender(appender);
         }
-        // set up appender
+        // set up appenders
         final GelfLayout layout = GelfLayout.createLayout(HOSTNAME, new KeyValuePair[] {
                 new KeyValuePair(KEY1, VALUE1),
                 new KeyValuePair(KEY2, VALUE2), }, CompressionType.GZIP, 1024);
         // ConsoleAppender appender = new ConsoleAppender("Console", layout);
         final ListAppender eventAppender = new ListAppender("Events", null, null, true, false);
-        final ListAppender appender = new ListAppender("Layouted", null, layout, true, false);
+        final ListAppender rawAppender = new ListAppender("Raw", null, layout, true, true);
+        final ListAppender formattedAppender = new ListAppender("Formatted", null, layout, true, false);
         eventAppender.start();
-        appender.start();
+        rawAppender.start();
+        formattedAppender.start();
 
-        // set appender on root and set level to debug
+        // set appenders on root and set level to debug
         root.addAppender(eventAppender);
-        root.addAppender(appender);
+        root.addAppender(rawAppender);
+        root.addAppender(formattedAppender);
         root.setLevel(Level.DEBUG);
 
         root.debug(LINE1);
@@ -92,41 +100,66 @@ public class GelfLayoutTest {
 
         root.info(LINE2);
 
+        final Exception exception = new RuntimeException("some error");
+        root.error(LINE3, exception);
+
         ThreadContext.clearMap();
 
-        appender.stop();
+        formattedAppender.stop();
 
         final List<LogEvent> events = eventAppender.getEvents();
-        final List<String> list = appender.getMessages();
+        final List<byte[]> raw = rawAppender.getData();
+        final List<String> messages = formattedAppender.getMessages();
 
         //@formatter:off
         assertJsonEquals("{" +
-                "\"version\": \"1.1\"," +
-                "\"host\": \"" + HOSTNAME + "\"," +
-                "\"timestamp\": "+GelfLayout.formatTimestamp(events.get(0).getTimeMillis())+"," +
-                "\"level\": 7," +
-                "\"_thread\": \"main\"," +
-                "\"_logger\": \"\"," +
-                "\"short_message\": \"" + LINE1 + "\"," +
-                "\"_" + KEY1 + "\": \"" + VALUE1 + "\"," +
-                "\"_" + KEY2 + "\": \"" + VALUE2 + "\"" +
-                "}",
-        list.get(0));
+                        "\"version\": \"1.1\"," +
+                        "\"host\": \"" + HOSTNAME + "\"," +
+                        "\"timestamp\": " + GelfLayout.formatTimestamp(events.get(0).getTimeMillis()) + "," +
+                        "\"level\": 7," +
+                        "\"_thread\": \"main\"," +
+                        "\"_logger\": \"\"," +
+                        "\"short_message\": \"" + LINE1 + "\"," +
+                        "\"_" + KEY1 + "\": \"" + VALUE1 + "\"," +
+                        "\"_" + KEY2 + "\": \"" + VALUE2 + "\"" +
+                        "}",
+                messages.get(0));
 
         assertJsonEquals("{" +
-                "\"version\": \"1.1\"," +
-                "\"host\": \"" + HOSTNAME + "\"," +
-                "\"timestamp\": "+GelfLayout.formatTimestamp(events.get(1).getTimeMillis())+"," +
-                "\"level\": 6," +
-                "\"_thread\": \"main\"," +
-                "\"_logger\": \"\"," +
-                "\"short_message\": \"" + LINE2 + "\"," +
-                "\"_" + KEY1 + "\": \"" + VALUE1 + "\"," +
-                "\"_" + KEY2 + "\": \"" + VALUE2 + "\"," +
-                "\"_" + MDCKEY1 + "\": \"" + MDCVALUE1 + "\"," +
-                "\"_" + MDCKEY2 + "\": \"" + MDCVALUE2 + "\"" +
-                "}",
-        list.get(1));
+                        "\"version\": \"1.1\"," +
+                        "\"host\": \"" + HOSTNAME + "\"," +
+                        "\"timestamp\": " + GelfLayout.formatTimestamp(events.get(1).getTimeMillis()) + "," +
+                        "\"level\": 6," +
+                        "\"_thread\": \"main\"," +
+                        "\"_logger\": \"\"," +
+                        "\"short_message\": \"" + LINE2 + "\"," +
+                        "\"_" + KEY1 + "\": \"" + VALUE1 + "\"," +
+                        "\"_" + KEY2 + "\": \"" + VALUE2 + "\"," +
+                        "\"_" + MDCKEY1 + "\": \"" + MDCVALUE1 + "\"," +
+                        "\"_" + MDCKEY2 + "\": \"" + MDCVALUE2 + "\"" +
+                        "}",
+                messages.get(1));
+
+        final byte[] compressed = raw.get(2);
+        final InputStream gzipStream = new GZIPInputStream(new ByteArrayInputStream(compressed));
+        final byte[] uncompressed = IOUtils.toByteArray(gzipStream);
+        gzipStream.close();
+        final String uncompressedString = new String(uncompressed, layout.getCharset());
+        assertJsonEquals("{" +
+                        "\"version\": \"1.1\"," +
+                        "\"host\": \"" + HOSTNAME + "\"," +
+                        "\"timestamp\": " + GelfLayout.formatTimestamp(events.get(2).getTimeMillis()) + "," +
+                        "\"level\": 3," +
+                        "\"_thread\": \"main\"," +
+                        "\"_logger\": \"\"," +
+                        "\"short_message\": \"" + LINE3 + "\"," +
+                        "\"full_message\": \"" + GelfLayout.escapeJson(GelfLayout.formatThrowable(exception)) + "\"," +
+                        "\"_" + KEY1 + "\": \"" + VALUE1 + "\"," +
+                        "\"_" + KEY2 + "\": \"" + VALUE2 + "\"," +
+                        "\"_" + MDCKEY1 + "\": \"" + MDCVALUE1 + "\"," +
+                        "\"_" + MDCKEY2 + "\": \"" + MDCVALUE2 + "\"" +
+                        "}",
+                uncompressedString);
         //@formatter:on
     }
 }
diff --git a/pom.xml b/pom.xml
index 24781ca..5319e5a 100644
--- a/pom.xml
+++ b/pom.xml
@@ -650,6 +650,12 @@
         <version>1.1.6</version>
         <scope>test</scope>
       </dependency>      
+      <dependency>
+        <groupId>commons-io</groupId>
+        <artifactId>commons-io</artifactId>
+        <version>2.4</version>
+        <scope>test</scope>
+      </dependency>
     </dependencies>
   </dependencyManagement>
   <build>
