logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Gary Gregory <garydgreg...@gmail.com>
Subject Re: "</table><br></body></html>" cause html log file cannot be displayed correctly.
Date Fri, 07 Oct 2016 19:13:56 GMT
Emi,

This is odd, in 2.7, the method

org.apache.logging.log4j.core.layout.HtmlLayout.getHeader()

writes more header bytes before it gets to:

<body bgcolor="#FFFFFF" topmargin="6" leftmargin="6">

Looking at the code I do not see how an HTML file written by Log4j 2.7 can
start with a body tag.

Can you verify that only Log4j 2.7 is on the classpath?

Thank you,
Gary


On Fri, Oct 7, 2016 at 8:08 AM, Emi <emilu@encs.concordia.ca> wrote:

> Hello,
>
> Tried log4j2.7, when stop/reload tomcat, html log file shows wrong format.
>
> This happens only when there are already previous records in the html log
> file.
>
>
> Debug steps:
> ================
> (1) run login and log one/two records in html format
>
> (2) stop webapp
>     reinstalled webapp
>     start webapp
>
>     or just reload webapp
>
> (3) run login and log record
>
> test.html will be shown as:
>
>
> <body bgcolor="#FFFFFF" topmargin="6" leftmargin="6">
> <hr size="1" noshade="noshade">
> Log session start time Fri Oct 07 10:42:05 EDT 2016<br>
> <br>
> <table cellspacing="0" cellpadding="4" border="1" bordercolor="#224466"
> width="100%">
> <tr>
> <th>Time</th>
> <th>Thread</th>
> <th>Level</th>
> <th>Logger</th>
> <th>Message</th>
> </tr>
>
> <tr>
> <td>237858</td>
> <td title="http-bio-8080-exec-22 thread">http-bio-8080-exec-22</td>
> <td title="Level"><font color="#339933">DEBUG</font></td>
> <td title="ProcessLogin logger">ProcessLogin</td>
> <td title="Message">2016-10-07 10:42:25 username: abc trying to login</td>
> </tr>
>
>
> </table>
> <br>
> </body></html>
>
>
> <tr>
> <td>344092</td>
> <td title="http-bio-8080-exec-29 thread">http-bio-8080-exec-29</td>
> <td title="Level"><font color="#339933">DEBUG</font></td>
> <td title="ProcessLogin logger">ProcessLogin</td>
> <td title="Message">2016-10-07 10:44:11 username: abc trying to login</td>
> </tr>
>
>
>
> "</table><br></body></html>" cause the html cannot be displayed
correctly.
>
>
> If this cannot be fixed, can someone let me know is there a way when
> reinstall webapp or reload webapp from tomcat, there will always a new log
> file generated?
>
> Want to upgrade jars from 2.3 to new version; log4j2.3 never with this
> problem.
>
> Thanks a lot!
> --
> . tomcat 7.0.70
> . log4j2.xml
> <RollingFile name="debug_html"
>                    fileName="@log4j.debug.html@"
>                    filePattern="@log4j.debug.html@-%i.html">
>          <HTMLLayout charset="UTF-8" title="login_out_info" />
>
>          <Policies>
>             <SizeBasedTriggeringPolicy size="1 MB" />
>             <OnStartupTriggeringPolicy/>
>          </Policies>
> </RollingFile>
>



-- 
E-Mail: garydgregory@gmail.com | ggregory@apache.org
Java Persistence with Hibernate, Second Edition
<http://www.manning.com/bauer3/>
JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
Spring Batch in Action <http://www.manning.com/templier/>
Blog: http://garygregory.wordpress.com
Home: http://garygregory.com/
Tweet! http://twitter.com/GaryGregory

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message