java中日志推送_java问题一个系统的操作日志怎么推送给另一个系统,有什么设计思路吗...

我有一个系统,要将本系统的操作日志推送给别人的系统,这个对接有什么设计思路吗?我的想法是生成一个文件让对方读取,但是日志推送是用线程定时读的,还有更正的地方或者实现思路吗?请大佬帮我解答一下,十分感激.现在输出是写死的 需要输出到别的系统

public class NoticesThread extends Thread

{

private String sql = " select t.id, "+

" t.content, "+

" t.log_type, "+

" u.name as userName, "+

" d.name as departName "+

" from ry_gis_opr_log t "+

" left join cfg_user u "+

" on t.operator_fk = u.id "+

" left join ry_gis_department d "+

" on t.belongto_fk = d.id "+

" where t.log_type = '上传' "+

" and t.is_fail != 1 " +

" and t.belongto_fk != 0" +

" and t.id > ? " +

" order by t.id desc ";

boolean isStart = true;

Long startLogId = 0l;

public void run() {

Properties prop = new Properties();

try {

InputStream in = new NoticesThread().getClass().getResourceAsStream("/config/jdbc.properties");

prop.load(in);

} catch (IOException e) {

e.printStackTrace();

}

final String driverName = prop.getProperty("jdbc.driverClassName");

final String url = prop.getProperty("jdbc.url");

final String oracleUser = prop.getProperty("jdbc.username");

final String password = prop.getProperty("jdbc.password");

Timer timer = new Timer();

timer.schedule(new TimerTask() {

@Override

public void run() {

Connection conn = null;

PreparedStatement st = null;

try {

Class.forName(driverName);

conn = DriverManager.getConnection(url, oracleUser, password);

st = conn.prepareStatement(sql, ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);

st.setLong(1, startLogId);

ResultSet rs = st.executeQuery();

if(!isStart){

if(rs.first()) {

startLogId = rs.getLong(1);

String content = rs.getString(2);

String userName = rs.getString(4);

String departName = rs.getString(5);

System.out.println("---logId:" + startLogId + "---content:"+content +"----userName:" + userName +"---departName:" + departName);

}

while(rs.next()){

Long logId = rs.getLong(1);

String content = rs.getString(2);

String userName = rs.getString(4);

String departName = rs.getString(5);

System.out.println("---logId:" + logId + "---content:"+content +"----userName:" + userName +"---departName:" + departName);

}

} else {

isStart = false;

if(rs.first()) {

startLogId = rs.getLong(1);

}

}

} catch (ClassNotFoundException e) {

e.printStackTrace();

} catch (SQLException e) {

e.printStackTrace();

} finally {

try {

if(conn != null) {

conn.close();

}

if(st != null) {

st.close();

}

} catch (SQLException e) {

e.printStackTrace();

}

}

}

}, 0, 5000);

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值