1. 程式人生 > >設定是否記錄日誌介面

設定是否記錄日誌介面

這個介面可以來控制專案引入的日誌註解是否生效(即是否列印日誌)

	/**
	 * 設定是否記錄日誌
	 * http://xxxxxxxxxxxx:8081/xxxxx/appi/busi/log/isWriteLog/true?sign=2d0e3c349dbf29470c1b89dfd895e2ae&timestamp=1539320912
	 * @param isWriteLog
	 * @return
	 */
	@RequestMapping(value = "/isWriteLog/{isWriteLog}",method = RequestMethod.POST)
	@ResponseBody
	public Object isWriteLog(@PathVariable("isWriteLog") String isWriteLog) {
		if(StringUtils.equalsIgnoreCase("true",isWriteLog)){
			ApiLogAspect.isWriteLog = true;
		}else if(StringUtils.equalsIgnoreCase("false",isWriteLog)){
			ApiLogAspect.isWriteLog = false;
		}
		JSONObject jsonObject = new JSONObject();
		jsonObject.put("isWriteLog",ApiLogAspect.isWriteLog);
		try {
			InetAddress addr = InetAddress.getLocalHost();
			String ip = addr.getHostAddress().toString(); //獲取本機ip
			String hostName = addr.getHostName().toString(); //獲取本機計算機名稱
			jsonObject.put("ip",ip);
			jsonObject.put("hostName",hostName);
		} catch (UnknownHostException e) {
			logger.error("isWriteLog:{}",e);
		}
		return ResultUtil.getSuccessResJson(jsonObject);
	}