android log4j 将日志自动发送到邮箱,log4j配置发送错误日志到邮箱

本文档展示了如何配置log4j.xml文件,包括不同类型的appender、logger、root及相关的属性设置。同时,提到了一个自定义的Java类MailLayout_seth,用于设置邮件日志的HTML内容格式,确保日志信息以UTF-8编码发送。
摘要由CSDN通过智能技术生成

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";

}

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值