[ 
https://issues.apache.org/jira/browse/LOG4J2-1405?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15315349#comment-15315349
 ] 

Remko Popma commented on LOG4J2-1405:
-------------------------------------

Can you try adding {{OnStartupTriggeringPolicy}} to your configuration:

{code}
 <RollingFile name="debug_html"
                  fileName="@log4j.debug.html@"
                  filePattern="@log4j.debug.html@-%i.html">
        <HTMLLayout charset="UTF-8" title="....." />
        <Policies>
           <OnStartupTriggeringPolicy />
           <SizeBasedTriggeringPolicy size="5 MB" />
        </Policies>
     </RollingFile>
{code}

What I think happened is that when you reload the web application, Log4j is 
stopped once and then started again. When it is stopped it performs cleanup, 
like writing footers and flushing buffers. The {{</table><br></body></html>}} 
is the HTML Layout footer.

This is fine, but when the application is started again you want to start with 
a header and this is missing. I hope that by adding 
{{<OnStartupTriggeringPolicy />}} we can trigger a rollover when your web app 
is started again. This should generate the header at the start of the new file.

> 2.6 html format - "</table><br></body></html>" inserted in the middle of <TR> 
> when restart tomcat
> -------------------------------------------------------------------------------------------------
>
>                 Key: LOG4J2-1405
>                 URL: https://issues.apache.org/jira/browse/LOG4J2-1405
>             Project: Log4j 2
>          Issue Type: Bug
>    Affects Versions: 2.6
>            Reporter: yl
>         Attachments: debug.html
>
>
> Hello,
> Updated 2.3 to 2.6. When reload tomcat7, the logfile (html format) not shown 
> correctly:
> {code}
> <tr>
> <td>13942164</td>
> <td title="http-bio-.....exec-49 thread">http-bio-.....</td>
> <td title="Level">INFO</td>
> <td title=" logger">ActionClass</td>
> <td title="Message">......</td>
> </tr>
> </table>
> <br>
> </body></html>
> <tr>
> <td>13936096</td>
> <td title=".....c-50 thread">http-bio.....50</td>
> <td title="Level"><font color="#993300"><strong>WARN</strong></font></td>
> <td title="logger">.....</td>
> <td title="Message">.... </td>
> </tr>
> {code}
> "</table><br></body></html>" is added in the middle, so html file cannot be 
> printed correctly.
> Can someone help how to fix this please?
> Here is log4j2.xml config:
> {code}
>  <RollingFile name="debug_html"
>                   fileName="@log4j.debug.html@"
>                   filePattern="@log4j.debug.html@-%i.html">
>         <HTMLLayout charset="UTF-8" title="....." />
>         <Policies>
>            <SizeBasedTriggeringPolicy size="5 MB" />
>         </Policies>
>      </RollingFile>
>   <Logger name="action" level="info" additivity="false">
>      <AppenderRef ref="debug_html"   />
>   </Logger>
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscr...@logging.apache.org
For additional commands, e-mail: log4j-dev-h...@logging.apache.org

Reply via email to