锘??xml version="1.0" encoding="utf-8" standalone="yes"?>
import java.util.Date;
import net.rim.device.api.system.EventLogger;
/**
* 鏃ュ織綾?br />
* @author 2010-09-04
*
*/
public class Logger {
private static final String SEPARATOR = " ";
private static final long GUID = 0x4c9d3452d880a2f1L;
private static final String APP_NAME = "xxxc ";
private Logger() {
EventLogger.register(GUID, APP_NAME, EventLogger.VIEWER_STRING);
}
private static Logger logger = new Logger();
public static Logger getLogger() {
return logger;
}
/**
* Log the information.
*
* @param message
* The message you will log
*/
public void info(String message) {
if (message == null || message.trim().equals(""))
return;
String log = "INFO: " + new Date().toString() + SEPARATOR + message;
try {
log = new String(log.getBytes(), "UTF-8");
byte[] msg_bytes = log.getBytes();
EventLogger.logEvent(GUID, msg_bytes, EventLogger.ALWAYS_LOG);
} catch (Exception ex) {
System.err.println(ex);
}
}
public void error(Exception e) {
StringBuffer log = new StringBuffer();
log.append("ERROR: " + new Date().toString() + SEPARATOR);
log.append(e.getMessage() + " \r\n ");
try {
byte[] msg_bytes = new String(log.toString().getBytes(), "UTF-8").getBytes();
EventLogger.logEvent(GUID, msg_bytes);
} catch (Exception ex) {
System.err.println(ex);
}
}
public void error(String message, Exception e) {
StringBuffer log = new StringBuffer();
log.append("ERROR: " + new Date().toString() + SEPARATOR);
if (message != null || !message.trim().equals("")) {
log.append("message: " + message + " \r\n ");
}
log.append("error: " + e.getMessage() + " \r\n ");
try {
byte[] msg_bytes = new String(log.toString().getBytes(), "UTF-8").getBytes();
EventLogger.logEvent(GUID, msg_bytes);
} catch (Exception ex) {
System.err.println(ex);
}
}
}
涓嶇鏄湪妯℃嫙鍣ㄨ繕鏄湡鏈猴紝鏃ュ織榪樻槸蹇呴』鐨?.....濡傛灉璇ユ枃瀵逛綘鏈夌敤錛屼負(fù)浜嗚〃紺哄浣滆呯殑鏀寔錛岄夯鐑?chǔ)浣犲崟鍑讳竴涓嬩笅闈㈢殑騫垮憡錛岃阿璋?br />