43StringBuffer sbuf = new StringBuffer(s);
44for (int i = 0; i < sbuf.length(); i++) {
45if (sbuf.charAt(i) >= 0x80) {
46sbuf.setCharAt(i, '?');
47}
48}
49part = new MimeBodyPart();
50part.setContent(sbuf.toString(), layout.getContentType());
51}
52}
53
54Multipart mp = new MimeMultipart();
55mp.addBodyPart(part);
56msg.setContent(mp);
57
58msg.setSentDate(new Date());
59Transport.send(msg);
60} catch (MessagingException e) {
61LogLog.error("Error occured while sending e-mail notification.", e);
62} catch (RuntimeException e) {
63LogLog.error("Error occured while sending e-mail notification.", e);
64}
65 }
66 protected String formatBody() {
67StringBuffer sbuf = new StringBuffer();
68String t = layout.getHeader();
69if (t != null)
70sbuf.append(t);
71int len = cb.length();
72for (int i = 0; i < len; i++) {
73LoggingEvent event = cb.get();
74sbuf.append(layout.format(event));
75if (layout.ignoresThrowable()) {
76String[] s = event.getThrowableStrRep();
77if (s != null) {
78for (int j = 0; j < s.length; j++) {
79sbuf.append(s[j]);
80sbuf.append(Layout.LINE_SEP);
81}
82}
83}
84}
85t = layout.getFooter();
86if (t != null) {
87sbuf.append(t);
88}
89return sbuf.toString();
90 }
SocketAppender类
SocketAppender将日志消息(LoggingEvent序列化实例)发送到指定Host的port端口。在创建SocketAppender时,SocketAppender会根据设置的Host和端口建立和远程服务器的链接,并创建ObjectOutputStream实例。
1 void connect(InetAddress address, int port) {
2if (this.address == null)
3return;
4try {
5cleanUp();
6oos = new ObjectOutputStream(
本文来自电脑杂谈,转载请注明本文网址:
http://www.pc-fly.com/a/jisuanjixue/article-29497-16.html
经济下滑并不全是坏事
感谢你把海浪带入MV
给予为祖国统一的力量全面支持