worldcreatxr
发贴: 149
积分: 0
|
于 2004-07-08 17:39
log4j的htmllayout会把bean和servlet的输出信息区分?
log4j的配置: log4j.rootLogger=DEBUG, stdout, html log4j.appender.html=org.apache.log4j.DailyRollingFileAppender log4j.appender.html.DatePattern='.'yyyy-MM-dd log4j.appender.html.File=log/debug.log.html log4j.appender.html.layout=org.apache.log4j.HTMLLayout
输出:请保存以下的html代码到文件看一看 =======================================
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <title>Log4J Log Messages</title> <style type="text/css"> <!-- body, table {font-family: arial,sans-serif; font-size: x-small;} th {background: #336699; color: #FFFFFF; text-align: left;} --> </style> </head> <body bgcolor="#FFFFFF" topmargin="6" leftmargin="6"> <hr size="1" noshade> Log session start time Thu Jul 08 17:40:45 CST 2004<br> <br> <table cellspacing="0" cellpadding="4" border="1" bordercolor="#224466" width="100%"> <tr> <th>Time</th> <th>Thread</th> <th>Level</th> <th>Category</th> <th>Message</th> </tr>
<tr> <td>0</td> <td title="main thread">main</td> <td title="Level">INFO</td> <td title="creatxr.demos.simple.bean.HelloWorld category">creatxr.demos.simple.bean.HelloWorld</td> <td title="Message">Hello World Bean</td> </tr>
<tr> <td>15</td> <td title="main thread">main</td> <td title="Level"><font color="#339933">DEBUG</font></td> <td title="creatxr.demos.simple.bean.AllJUnitTests.HelloWorldTest category">creatxr.demos.simple.bean.AllJUnitTests.HelloWorldTest</td> <td title="Message">HelloWorld.print() pass</td> </tr> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <title>Log4J Log Messages</title> <style type="text/css"> <!-- body, table {font-family: arial,sans-serif; font-size: x-small;} th {background: #336699; color: #FFFFFF; text-align: left;} --> </style> </head> <body bgcolor="#FFFFFF" topmargin="6" leftmargin="6"> <hr size="1" noshade> Log session start time Thu Jul 08 17:40:46 CST 2004<br> <br> <table cellspacing="0" cellpadding="4" border="1" bordercolor="#224466" width="100%"> <tr> <th>Time</th> <th>Thread</th> <th>Level</th> <th>Category</th> <th>Message</th> </tr>
<tr> <td>0</td> <td title="main thread">main</td> <td title="Level"><font color="#339933">DEBUG</font></td> <td title="creatxr.demos.simple.servlet.AllJUnitTests.HelloWorldTest category">creatxr.demos.simple.servlet.AllJUnitTests.HelloWorldTest</td> <td title="Message"><html><head><title> Servlet Example </title></head><body> Hello World Servlet </body></html> </td> </tr>
<tr> <td>16</td> <td title="main thread">main</td> <td title="Level"><font color="#993300"><strong>WARN</strong></font></td> <td title="creatxr.demos.simple.servlet.HelloWorld category">creatxr.demos.simple.servlet.HelloWorld</td> <td title="Message">127.0.0.1 root</td> </tr>
<tr> <td>32</td> <td title="main thread">main</td> <td title="Level"><font color="#339933">DEBUG</font></td> <td title="creatxr.demos.simple.servlet.AllJUnitTests.HelloWorldTest category">creatxr.demos.simple.servlet.AllJUnitTests.HelloWorldTest</td> <td title="Message"><html><head><title> Servlet Example </title></head><body> username <> userpass </body></html> </td> </tr>
我是世界的缔造者!
|