[logback-dev] [JIRA] Created: (LBCLASSIC-180) XML/HTML tags haven't get escaped in HTMLLayout

Xu Hui Hui (JIRA) noreply-jira at qos.ch
Sat Jan 16 09:17:33 CET 2010

XML/HTML tags haven't get escaped in HTMLLayout

                 Key: LBCLASSIC-180
                 URL: http://jira.qos.ch/browse/LBCLASSIC-180
             Project: logback-classic
          Issue Type: Bug
          Components: layout
    Affects Versions: 0.9.18
         Environment: Linux (Ubuntu), JavaSE 1.6
            Reporter: Xu Hui Hui
            Assignee: Logback dev list

View it here for a better looking: http://stackoverflow.com/questions/2069135/how-to-make-xml-get-escaped-in-htmllayout-of-logback

I'm using logback (with slf4j) to do the logging, and I've got many XML content to be logged in both text files and HTML files (with HTMLLayout). However, logback just inserts the raw XML in the <TD> tags for the HTMLLayout, without any escaping or <pre> processing.

Here is the snippet of my logback.xml:

<appender name="ALL" class="ch.qos.logback.core.rolling.RollingFileAppender">     
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
  <TimeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
<layout class="ch.qos.logback.classic.html.HTMLLayout">
  <cssBuilder class="ch.qos.logback.classic.html.UrlCssBuilder">
  <title>Logs (ALL)</title>

And the following is what I got:

<td class="Message">(DemoCall) parsing response failed. Details:
What I'm expecting:

<td class="Message">(DemoCall) parsing response failed. Details:

Or better wrap the above message with a <pre> tag. Do I need to extend the HTMLLayout to archive that? Or is it my job to do a StringEscapeUtils.escapeHTML(msg) for each log statement (I'm not going to do that, since there also is a file appender for which the escaping is not needed).


This message is automatically generated by JIRA.
If you think it was sent incorrectly contact one of the administrators: http://jira.qos.ch/secure/Administrators.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira


More information about the logback-dev mailing list