You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@solr.apache.org by GitBox <gi...@apache.org> on 2022/01/18 10:44:40 UTC

[GitHub] [solr] uschindler edited a comment on pull request #536: SOLR-14142 Enable jetty's request log by default

uschindler edited a comment on pull request #536:
URL: https://github.com/apache/solr/pull/536#issuecomment-1015287079


   For the record this is how to use log4j (just some debugging example copypasted):
   
   ```java
   static final class LoggingAccessLog extends AbstractLifeCycle implements RequestLog {
     private final org.apache.logging.log4j.Logger log;
     
     public LoggingAccessLog(String logname) {
       this.log = org.apache.logging.log4j.LogManager.getLogger(logname);
     }
     
     @Override
     public void log(Request req, Response resp) {
       final StringBuilder line=new StringBuilder("From: ")
         .append(req.getRemoteHost())
         .append("; Req: \"").append(req.getMethod()).append(' ').append(req.getRequestURI());
       final String query = req.getQueryString();
       if (query != null) {
         line.append('?').append(query);
       }
       line.append(' ').append(req.getProtocol()).append("\"; Status: ").append(resp.getStatus()).append("; Bytes: ").append(resp.getContentCount());
       final String referer=req.getHeader(HttpHeader.REFERER.asString());
       if (referer!=null) line.append("; Referer: \"").append(referer).append('"');
       final String userAgent=req.getHeader(HttpHeader.USER_AGENT.asString());
       if (userAgent!=null) line.append("; User-Agent: \"").append(userAgent).append('"');
       if (req.isSecure()) line.append("; secure");
       log.info(line.toString());
     }
   }
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@solr.apache.org
For additional commands, e-mail: issues-help@solr.apache.org