/**
* 获取当前线程id
*/
private Long getThreadId() {
try {
return Thread.currentThread().getId();
} catch (Exception e) {
return null;
}
}
/**
* 获取当前进程id
*/
private Long getProcessId() {
try {
RuntimeMXBean runtime = ManagementFactory.getRuntimeMXBean();
String name = runtime.getName();
String pid = name.substring(0, name.indexOf('@' ));
return Long.parseLong(pid);
} catch (Exception e) {
return null;
}
}
/**
* 获取当前服务器ip地址
*/
private String getServerIp() {
try {
//用 getLocalHost() 方法创建的InetAddress的对象
InetAddress address = InetAddress.getLocalHost();
return address.getHostAddress();
} catch (Exception e) {
return null;
}
}