log4j.xml文件配置如下:
log4j.dtd文件:
appender*,plugin*, (category|logger)*,root?,
(categoryFactory|loggerFactory)?)>
xmlns:log4j CDATA #FIXED "http://jakarta.apache.org/log4j/"
threshold (all|trace|debug|info|warn|error|fatal|off|null) "null"
debug (true|false|null) "null"
reset (true|false) "false"
>
renderedClass CDATA #REQUIRED
renderingClass CDATA #REQUIRED
>
class CDATA #REQUIRED
>
rollingPolicy?, triggeringPolicy?, connectionSource?,
layout?, filter*, appender-ref*)>
name CDATA #REQUIRED
class CDATA#REQUIRED
>
classCDATA#REQUIRED
>
classCDATA#REQUIRED
>
class CDATA #REQUIRED
>
ref CDATA #REQUIRED
>
nameCDATA #REQUIRED
valueCDATA#REQUIRED
>
class CDATA#IMPLIED
value CDATA #REQUIRED
>
class CDATA#IMPLIED
value CDATA #REQUIRED
>
class CDATA #IMPLIED
nameCDATA#REQUIRED
additivity(true|false) "true"
>
class CDATA #IMPLIED
nameCDATA#REQUIRED
additivity(true|false) "true"
>
class CDATA #REQUIRED>
class CDATA #REQUIRED>
ref CDATA #REQUIRED
>
name CDATA #REQUIRED
class CDATA #REQUIRED
>
class CDATA #REQUIRED
>
class CDATA #REQUIRED
>
name CDATA #IMPLIED
class CDATA #REQUIRED
>
name CDATA #IMPLIED
class CDATA #REQUIRED
>
xmlns:log4j CDATA #FIXED "http://jakarta.apache.org/log4j/"
version (1.1|1.2) "1.2"
includesLocationInfo (true|false) "true"
>
log4j:locationInfo?, log4j:properties?) >
logger CDATA #REQUIRED
level CDATA #REQUIRED
thread CDATA #REQUIRED
timestamp CDATA #REQUIRED
time CDATA #IMPLIED
>
class CDATA#REQUIRED
method CDATA#REQUIRED
file CDATA#REQUIRED
line CDATA#REQUIRED
>
name CDATA#REQUIRED
value CDATA#REQUIRED
> 邮件自定义格式化Java类:MailLayout_seth.java
package com.hh.util;
import org.apache.log4j.HTMLLayout;
public class MailLayout_seth extends HTMLLayout{
@Override
public String getContentType()
{
return "text/html;charset=UTF-8";
}
}