执行前打印日志

@param request
@param reqBytes
358147
private void preLog(RequestDTO request, byte[] reqBytes) {
        LOG.info(String.format("Navi rpc call start - %d\t%s\t%s\t%s\t%d", request.getTraceId(),
                url, request.getMethod(), serializeHandler.getProtocol().getName(),
                reqBytes == null ? 0 : reqBytes.length));
    }
856780
public static void start(final Logger logger, final Logger auditor, final HttpServletRequest request) {
        start(logger, auditor, request, null);
    }
486805
public CompletableFuture<ExecuteResponse> execute(ExecuteRequest request) {
    logRequest(request);
    return CompletableFuture.completedFuture(logResponse(ExecuteResponse.error()));
  }
634826
public void dumpRequest(final HttpServletRequest req) {
    try {
      Enumeration names = req.getHeaderNames();

      String title = "Request headers";

      debug(title);

      while (names.hasMoreElements()) {
        String key = (String)names.nextElement();
        String val = req.getHeader(key);
        debug("  " + key + " = \"" + val + "\"");
      }

      names = req.getParameterNames();

      title = "Request parameters";

      debug(title + " - global info and uris");
      debug("getRemoteAddr = " + req.getRemoteAddr());
      debug("getRequestURI = " + req.getRequestURI());
      debug("getRemoteUser = " + req.getRemoteUser());
      debug("getRequestedSessionId = " + req.getRequestedSessionId());
      debug("HttpUtils.getRequestURL(req) = " + req.getRequestURL());
      debug("contextPath=" + req.getContextPath());
      debug("query=" + req.getQueryString());
      debug("contentlen=" + req.getContentLength());
      debug("request=" + req);
      debug("parameters:");

      debug(title);

      while (names.hasMoreElements()) {
        String key = (String)names.nextElement();
        String val = req.getParameter(key);
        debug("  " + key + " = \"" + val + "\"");
      }
    } catch (Throwable t) {
    }
  }
553983
public void tracef(String format, Object... params) {
        doLogf(Level.TRACE, FQCN, format, params, null);
    }
861576
protected function logRequest(Request $request)
    {
        $this->logger->log(LogLevel::DEBUG, '> '.$request->getMethod().' '.$request->getRequestUri());
    }
85312
void postProgress(final DownloadRequest request, final long bytesWritten, final long totalBytes) {
    downloadPoster.execute(new Runnable() {
      @Override public void run() {
        request.downloadCallback().onProgress(request.downloadId(), bytesWritten, totalBytes);
      }
    });
  }
31627
protected void writeRequest(final NextFilter nextFilter,
            final SocksProxyRequest request) {
        try {
            boolean isV4ARequest = request.getHost() != null;
            byte[] userID = request.getUserName().getBytes("ASCII");
            byte[] host = isV4ARequest ? request.getHost().getBytes("ASCII")
                    : null;

            int len = 9 + userID.length;

            if (isV4ARequest) {
                len += host.length + 1;
            }

            IoBuffer buf = IoBuffer.allocate(len);

            buf.put(request.getProtocolVersion());
            buf.put(request.getCommandCode());
            buf.put(request.getPort());
            buf.put(request.getIpAddress());
            buf.put(userID);
            buf.put(SocksProxyConstants.TERMINATOR);

            if (isV4ARequest) {
                buf.put(host);
                buf.put(SocksProxyConstants.TERMINATOR);
            }

            if (isV4ARequest) {
                logger.debug("  sending SOCKS4a request");
            } else {
                logger.debug("  sending SOCKS4 request");
            }

            buf.flip();
            writeData(nextFilter, buf);
        } catch (Exception ex) {
            closeSession("Unable to send Socks request: ", ex);
        }
    }
720356
private void handleRequest(ByteBuf request, ChannelHandlerContext context) {
    NettyConnection connection = getConnection(context.channel());
    if (connection != null) {
      connection.handleRequest(request);
    }
  }
611786
public void request(final String method, final HttpServletRequest request,
                        final HttpServletResponse response) throws ServletException, IOException {

        String id = null;
        try{
            requests.set(request);
            id = Session.start(getSessionId(request,response));

            long t = System.currentTimeMillis();
            try {
                String requestId = UUID.randomUUID().toString();

                // set MDC
                MDC.put("requestId", requestId);

                logRequest(method, request);

                I params = parseInput(request);
                logInParams(params);

                //check access
                checkAccess(method, params, request);

                O out = process(method, params, request, response);

                if (out != null) {
                    logOut(out);
                    formatOutput(out, false, request, response);
                }
            } catch (Throwable e) {
                logError(e);
                try {
                    O out = transformError(e, request, response);
                    formatOutput(out, true, request, response);
                } catch (Exception ex) {
                    LOG.error("Error preparing exception output", ex);
                }
            }
            logResult(System.currentTimeMillis() - t);
        }finally {
            requests.remove();
            Session.end(id);
        }
    }
1204049
@SuppressWarnings("unused")
  private static final void dump(HttpClient client, HttpUriRequest req) {
    if (logger.isTraceEnabled()) {
      StringBuilder sb = new StringBuilder("\n=== Request ===");
      sb.append("\n").append(req.getRequestLine());
      for (Header h : req.getAllHeaders()) {
        sb.append("\n").append(h.getName()).append(": ").append(h.getValue());
      }
      logger.trace(sb.toString());
      
      HttpResponse resp = null;
      try {
        resp = client.execute(req);
      } catch (Exception e) {
        logger.trace("Error executing request", e);
        return;
      }
      
      sb = new StringBuilder("\n=== Response ===");
      sb.append("\n").append(resp.getStatusLine());
      for (Header h : resp.getAllHeaders()) {
        sb.append("\n").append(h.getName()).append(": ").append(h.getValue());
      }
      logger.trace(sb.toString());
      
      HttpEntity entity = resp.getEntity();
      if (entity != null) {
        sb = new StringBuilder("\n=== Content ===");
        try {
          int len = (int) entity.getContentLength();
          if (len < 0) len = 100;
          ByteArrayOutputStream baos = new ByteArrayOutputStream(len);
          entity.writeTo(baos);
          sb.append("\n").append(baos.toString("UTF-8"));
          logger.trace(sb.toString());
        } catch (IOException e) {
          logger.trace("Error reading content", e);
        }
      }
    }
  }
580760
private void logRequest(final HttpServletRequest req, final Session session) {
    final StringBuilder buf = new StringBuilder();
    buf.append(getRealClientIpAddr(req)).append(" ");
    if (session != null && session.getUser() != null) {
      buf.append(session.getUser().getUserId()).append(" ");
    } else {
      buf.append(" - ").append(" ");
    }

    buf.append("\"");
    buf.append(req.getMethod()).append(" ");
    buf.append(req.getRequestURI()).append(" ");
    if (req.getQueryString() != null && !isIllegalPostRequest(req)) {
      buf.append(req.getQueryString()).append(" ");
    } else {
      buf.append("-").append(" ");
    }
    buf.append(req.getProtocol()).append("\" ");

    final String userAgent = req.getHeader("User-Agent");
    if (this.shouldLogRawUserAgent) {
      buf.append(userAgent);
    } else {
      // simply log a short string to indicate browser or not
      if (StringUtils.isFromBrowser(userAgent)) {
        buf.append("browser");
      } else {
        buf.append("not-browser");
      }
    }

    logger.info(buf.toString());
  }
415869
private void debug(final HttpServletRequest request) {
        if (!logger.isInfoEnabled()) {
            logger.warn("Logger INTO not enabled!");
            return;
        }

        logger.info(HEADERS);
        Enumeration headerEnumeration = request.getHeaderNames();
        while (headerEnumeration.hasMoreElements()) {
            String elementName = (String) headerEnumeration.nextElement();
            logger.info(elementName + " = " + request.getHeader(elementName));
        }

        logger.info(ATTRIBUTES);
        Enumeration attributeEnumeration = request.getAttributeNames();
        while (attributeEnumeration.hasMoreElements()) {
            String elementName = (String) attributeEnumeration.nextElement();
            logger.info(elementName + " = " + request.getAttribute(elementName));
        }

        logger.info(PARAMETERS);
        Map<String, String[]> parameterMap = request.getParameterMap();
        for (Map.Entry<String, String[]> entry : parameterMap.entrySet()) {
            StringBuilder parameterValues = new StringBuilder();
            if (entry.getValue() != null)
                for (String value : entry.getValue()) {
                    parameterValues.append(value);
                    parameterValues.append(' ');
                }
            logger.info(entry.getKey() + " = " + parameterValues);
        }
        HttpSession session = request.getSession(false);
        if (session != null) {
            logger.info("Session = " + session.getId());
            logger.info(SESSION_ATTRIBUTES);

            Enumeration sessionAttrEnumeration = session.getAttributeNames();
            while (sessionAttrEnumeration.hasMoreElements()) {
                String elementName = (String) sessionAttrEnumeration.nextElement();
                logger.info(elementName + " = " + session.getAttribute(elementName));
            }
        }
        logger.info("Remote ip = " + request.getRemoteAddr());
        logger.info("Server name = " + request.getServerName());
        logger.info("Server port = " + request.getServerPort());
    }
768661
function logRequest(req, res) {
		var responseTime = Math.round(req.duration),
			shouldLogRequest = requestLogger && req && req.url && req.url !== '/arrowPing.json',
			shouldADILog = options && options.adiLogging && adiLogger && req && req.url && isWhitelisted(req.url),
			time = new Date().getTime(),
			uri = (req.route && req.route.path) || req.path || (req.url && req.url.split('?')[0]),
			localPort = getPort(req);

		if (shouldLogRequest && req.log && req.logname && (req.logmetadata === undefined || req.logmetadata)) {
			requestLogger.info({
				req_id: req.requestId,
				req: req,
				res: res,
				route: req.route,
				name: req._logname,
				logname: req.logname,
				response_time: responseTime
			});

			const result = {
				url: req.url,
				req_headers: req.headers,
				status: res.status,
				req_id: req.requestId,
				name: req._logname,
				logname: req.logname,
				response_time: responseTime
			};
			fs.writeFile(req.logname + '.metadata', JSON.stringify(result));
		} else if (shouldLogRequest) {
			requestLogger.info({
				req_id: req.requestId,
				response_time: responseTime,
				route: req.route,
				req: req,
				res: res
			});
		}

		if (shouldADILog) {
			adiLogger.info({
				type: 'transaction',
				time: time,
				path: uri,
				protocol: req.protocol,
				protocolSrc: localPort,
				duration: responseTime,
				status: getStatus(res),
				serviceContexts: [
					{
						service: '',
						monitor: '',
						client: null,
						org: null,
						app: options.name,
						method: '',
						status: '',
						duration: ''
					}
				],
				customMsgAtts: {},
				correlationId: getCorrelationId(req),
				legs: [
					{
						uri: uri,
						status: res.statusCode,
						statusText: '',
						method: req.method,
						vhost: null,
						wafStatus: 0,
						bytesSent: parseInt(res.get('Content-Length'), 10) || null,
						bytesReceived: parseInt(req.get('Content-Length'), 10) || null,
						remoteName: '',
						remoteAddr: '',
						localAddr: '',
						remotePort: '',
						localPort: '',
						sslsubject: null,
						leg: 0,
						timestamp: time,
						duration: responseTime,
						serviceName: uri,
						subject: null,
						operation: req.method + ' - ' + uri,
						type: req.protocol,
						finalStatus: ''
					}
				]
			});
		}
		if (req.cleanStream) {
			req.cleanStream();
			req.cleanStream = null;
		}
	}
394618
private void addQueryParams(final Request request) {
        if (log != null) {
            request.addQueryParam("Log", log.toString());
        }

        if (absoluteMessageDate != null) {
            request.addQueryParam("MessageDate", absoluteMessageDate.toString(Request.QUERY_STRING_DATE_FORMAT));
        } else if (rangeMessageDate != null) {
            request.addQueryDateRange("MessageDate", rangeMessageDate);
        }

        if (getPageSize() != null) {
            request.addQueryParam("PageSize", Integer.toString(getPageSize()));
        }
    }
199046
public void init(HttpServletRequest request) {
		resetTimers();
		
		if (request != null) {
			String p = request.getPathInfo();
			final int pathLength = (p == null ? 0 : p.length());
			
			final StringBuffer urlSb = request.getRequestURL();
			String simpleUrl = urlSb.toString(); // without qs
			
			String qs = request.getQueryString();
			if (qs != null) urlSb.append("?").append(qs);
			final String fullUrl = urlSb.toString();
			contextUrl.set(fullUrl);
		
			requestCookies.remove();
			responseCookies.remove();
			
			StringBuilder cookiesDump = new StringBuilder();
			Map<String, Cookie> cookiez = requestCookies.get();
			for (javax.servlet.http.Cookie c : Check.ifNull(request.getCookies(), new javax.servlet.http.Cookie[0])) {
				cookiez.put(c.getName(), new BasicClientCookie(c.getName(), c.getValue()));
				cookiesDump.append(c.toString()).append(";");
			}
	
			String xForwardedFor = request.getHeader(HEADER_X_FORWARDED_FOR);
			clientIp.set(xForwardedFor != null ? xForwardedFor : request.getRemoteAddr());
			
			String xForwardedUrl = request.getHeader(HEADER_X_FORWARDED_URL);
			if (xForwardedUrl != null) {
				int i = xForwardedUrl.lastIndexOf("?");
				simpleUrl = (i == -1 ? xForwardedUrl : xForwardedUrl.substring(0, i));
			}
			
			try {
				simpleUrl = URLDecoder.decode(simpleUrl, "UTF-8"); // convert "%xx" stuff before working with lengths
			} catch (UnsupportedEncodingException e) {
				log.error(e.toString());
			}
			contextPath.set(simpleUrl.substring(0, simpleUrl.length() - pathLength));

			if (verbose) log.info(">>> Time 0 [" + fullUrl + "]. cookies from client: " + cookiesDump.toString());
		}
		
		initialized.set(true);
	}
1232225
public void updateStreamRecording(UpdateStreamRecordingRequest request) {
        checkNotNull(request, "The parameter request should NOT be null.");

        checkStringNotEmpty(request.getDomain(), "Domain should NOT be empty.");
        checkStringNotEmpty(request.getApp(), "App should NOT be empty");
        checkStringNotEmpty(request.getStream(), "Stream should NOT be empty.");
        // recording can be null for letting stream to use domain's recording,
        // so no need to check if recording is null

        InternalRequest internalRequest = createRequest(HttpMethodName.PUT, request,
                LIVE_DOMAIN, request.getDomain(), LIVE_APP, request.getApp(),
                LIVE_STREAM, request.getStream());
        internalRequest.addParameter("recording", request.getRecording());
        invokeHttpClient(internalRequest, AbstractBceResponse.class);
    }