Java Code Examples for com.aliyun.openservices.log.exception.LogException#printStackTrace()
The following examples show how to use
com.aliyun.openservices.log.exception.LogException#printStackTrace() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: KefuLog.java From wangmarket with Apache License 2.0 | 6 votes |
public void run() { if(Global.aliyunLogUtil == null){ return; } System.out.println("KefuLog 已开启自动提交线程,每间隔一分钟会自动提交一次"); while(true){ try { Thread.sleep(60000); } catch (InterruptedException e1) { e1.printStackTrace(); } try { //如果其中有值,则自动提交 if(Global.aliyunLogUtil.logGroupCache.size() > 0){ Global.aliyunLogUtil.cacheCommit(); } } catch (LogException e) { System.out.println("日志用多线程自动提交出现问题"); e.printStackTrace(); } } }
Example 2
Source File: KefuLog.java From wangmarket with Apache License 2.0 | 6 votes |
public static void insert(Message msg){ if(Global.aliyunLogUtil == null){ return; } LogItem item = Global.aliyunLogUtil.newLogItem(); //发送方 item.PushBack("sendId", msg.getSendId()+""); item.PushBack("sendUserName", msg.getSendUserName()); //接收方 item.PushBack("receiveId", msg.getReceiveId()+""); item.PushBack("receiveUserName", msg.getReceiveUserName()); //发送的消息内容 item.PushBack("content", msg.getContent()); //接收方的socket标示 item.PushBack("receiveSocketId", msg.getSocketId()+""); item.PushBack("receiveSocketUuid", msg.getSocketUuid()); try { Global.aliyunLogUtil.cacheLog(item); } catch (LogException e) { e.printStackTrace(); } }
Example 3
Source File: ImController.java From wangmarket with Apache License 2.0 | 6 votes |
@RequestMapping("previewByToken${url.suffix}") public String previewByToken(HttpServletRequest request,Model model, @RequestParam(value = "token", required = false , defaultValue="") String token){ //进行安全过滤 token = token.replaceAll("\\s*", ""); token = filter(token); if(token.length() != 64){ return error(model, "授权码错误"); }else{ int currentTime = DateUtil.timeForUnix10(); int startTime = currentTime - 86400*30; //30天内有效 try { AliyunLogPageUtil log = new AliyunLogPageUtil(Global.aliyunLogUtil); JSONArray jsonArray = log.listForJSONArray("receiveSocketUuid="+token, "", false, startTime, currentTime, 100, request); model.addAttribute("list", jsonArray); } catch (LogException e) { e.printStackTrace(); } } return "im/perviewByToken"; }
Example 4
Source File: ImController.java From wangmarket with Apache License 2.0 | 6 votes |
/** * 历史聊天人列表,会话列表,每一项都是一个人 */ @RequestMapping("hostoryChatList${url.suffix}") public String hostoryChatList(HttpServletRequest request,Model model){ if(Global.aliyunLogUtil == null){ return error(model, "您未开启IM客服访问相关的日志服务!"); } User user = getUser(); int currentTime = DateUtil.timeForUnix10(); int startTime = currentTime - 86400*30; //30天内有效 try { AliyunLogPageUtil log = new AliyunLogPageUtil(Global.aliyunLogUtil); JSONArray jsonArray = log.listForJSONArray("receiveId = "+user.getId()+" | select max(sendId) , map_agg('array',sendUserName) as sendUserName,max(sendId) as sendIds, count(*) as count, max(__time__) as time group by sendId order by time desc limit 100", "", false, startTime, currentTime, 100, request); model.addAttribute("list", jsonArray); } catch (LogException e) { e.printStackTrace(); } return "im/hostoryChatList"; }
Example 5
Source File: ImController.java From wangmarket with Apache License 2.0 | 6 votes |
/** * 聊天记录,跟某个人之间,一个会话的聊天记录,两个人之间的聊天记录 * @param id 跟自己会话的那个人的id,对方的id */ @RequestMapping("chatRecord${url.suffix}") public String chatRecord(HttpServletRequest request,Model model, @RequestParam(value = "id", required = false , defaultValue="0") long id){ if(id == 0){ return error(model, "请输入要查看得对方得id编号"); } User user = getUser(); int currentTime = DateUtil.timeForUnix10(); int startTime = currentTime - 86400*30; //30天内有效 try { AliyunLogPageUtil log = new AliyunLogPageUtil(Global.aliyunLogUtil); JSONArray jsonArray = log.listForJSONArray("(receiveId = "+user.getId()+" and sendId = "+id+" ) or (receiveId = "+id+" and sendId = "+user.getId()+" )", "", false, startTime, currentTime, 100, request); JSONArray ja = new JSONArray(); //将其倒序 for (int i = jsonArray.size()-1; i >-1 ; --i) { ja.add(jsonArray.get(i)); } model.addAttribute("list", ja); } catch (LogException e) { e.printStackTrace(); } model.addAttribute("user", user); return "im/chatRecord"; }
Example 6
Source File: Log.java From wangmarket with Apache License 2.0 | 6 votes |
public static void requestLog(HttpServletRequest request, RequestInfo requestInfo, SImpleSiteVO simpleSiteVO){ //未开启日志记录 if(aliyunLogUtil == null){ return; } if(simpleSiteVO.getResult() - SImpleSiteVO.FAILURE == 0){ //失败的,没有访问正规站点的,可能是ip直接访问的,或者访问的未绑定上的域名过来的。这样的不与记录。 return; } LogItem logItem = new LogItem(DateUtil.timeForUnix10()); logItem.PushBack("ip", requestInfo.getIp()); logItem.PushBack("referer", requestInfo.getReferer()); logItem.PushBack("userAgent", requestInfo.getUserAgent()); logItem.PushBack("htmlFile", requestInfo.getHtmlFile()); logItem.PushBack("siteid", simpleSiteVO.getSimpleSite().getId()+""); logItem.PushBack("serverName", requestInfo.getServerName()); try { aliyunLogUtil.cacheLog(logItem); } catch (LogException e1) { e1.printStackTrace(); } }
Example 7
Source File: SiteSizeChangeLog.java From wangmarket with Apache License 2.0 | 5 votes |
/** * 增加动作日志。此方法不可直接调用,需间接 * @param userid 当前日志属于哪个登录用户的,对应其user.id * @param username 当前日志属于哪个登录用户的,对应其user.username * @param agencyName 当前登录的代理的 {@link Agency}.name 若是不是代理,那就是管理员了,管理员可传入空字符串 * @param remark 备注说明 * @param agencySiteSizeChange 代理变动的“站”余额的多少,消耗为负数,增加为正数 {@link Agency}.siteSize * @param changeBefore 变动前,站点的站余额是多少, {@link Agency}.siteSize * @param changeAfter 变化之后的站点的站余额是多少。{@link Agency}.siteSize * @param goalid 其余额变动,是开通的哪个站点引起的,记录站点的id,或者是哪个人给他增加的,记录给他增加的人的userid * @param ip 操做人的ip地址 * @param topic 主题,分类。减去站币,消费,传入"xiaofei", 增加站币,充值,传入"chongzhi" */ private static void addChangeLog(int userid, String username, String agencyName, String remark, int agencySiteSizeChange, int changeBefore, int changeAfter, int goalid, String ip, String topic){ if(aliyunLogUtil == null){ return; } StackTraceElement st = Thread.currentThread().getStackTrace()[3]; LogItem logItem = aliyunLogUtil.newLogItem(); /*用户相关信息*/ logItem.PushBack("userid", userid+""); logItem.PushBack("username", username); /*日志信息*/ logItem.PushBack("goalid", goalid+""); logItem.PushBack("remark", remark); /*代理信息,如果是代理操作的话*/ logItem.PushBack("agencyName", agencyName); logItem.PushBack("changeBefore", changeBefore+""); logItem.PushBack("changeAfter", changeAfter+""); logItem.PushBack("agencySiteSizeChange", agencySiteSizeChange+""); /*使用的类的信息,来源位置*/ logItem.PushBack("class", st.getClassName()); logItem.PushBack("method", st.getMethodName()); try { aliyunLogUtil.save(topic, ip, logItem); } catch (LogException e) { MailUtil.sendMail(Global.get("SERVICE_MAIL"), "站币消费出错", e.getMessage()+","+logItem.ToJsonString()); e.printStackTrace(); } }
Example 8
Source File: ActionLogCache.java From wangmarket with Apache License 2.0 | 5 votes |
/** * 插入一条日志 * @param logItem 传入要保存的logItem,若为空,则会创建一个新的。此项主要为扩展使用,可自行增加其他信息记录入日志 * @param request HttpServletRequest * @param goalid 操作的目标的id,若无,可为0,也可为空 * @param action 动作的名字,如:用户登录、更改密码 * @param remark 动作的描述,如用户将名字张三改为李四 */ public static synchronized void insert(LogItem logItem, HttpServletRequest request, int goalid, String action, String remark){ if(aliyunLogUtil == null){ //不使用日志服务,终止即可 return; } if(logItem == null){ logItem = aliyunLogUtil.newLogItem(); } /*用户相关信息,只有用户登录后,才会记录用户信息*/ User user = ShiroFunc.getUser(); if(user != null){ logItem.PushBack("userid", user.getId()+""); logItem.PushBack("username", user.getUsername()); } /* 动作相关 */ logItem.PushBack("goalid", goalid+""); logItem.PushBack("action", action); logItem.PushBack("remark", remark); /*浏览器自动获取的一些信息*/ if(request != null){ logItem.PushBack("ip", IpUtil.getIpAddress(request)); logItem.PushBack("param", request.getQueryString()); logItem.PushBack("url", request.getRequestURL().toString()); logItem.PushBack("referer", request.getHeader("referer")); logItem.PushBack("userAgent", request.getHeader("User-Agent")); } try { aliyunLogUtil.cacheLog(logItem); } catch (LogException e) { e.printStackTrace(); } }