在Neo4j服务器中为每个记录单独的时间记录http请求/响应 [英] Logging http request/response with separate timings for each in Neo4j server
问题描述
我想记录http请求和对Neo4j服务器的响应。我在下面的问题中搜索并获得了stackoverflow本身的答案:
如何将查询语句记录到Neo4j服务器,是否可能?
I wanted to log http request and response to Neo4j server. I searched and got the answer on stackoverflow itself in below question: How to log query statement to Neo4j server, is it possible?
答案中的配置以上问题结果同时记录了请求/响应。我想知道那个时间代表什么,即服务器何时收到请求或何时生成响应?
The configuration in the answer to above question results in same time logged for both request/response. I was wondering what that time represents ,i.e, when the server received the request or when it generated the response?
另外,我想记录每个请求和响应的个别时间(即服务器收到请求时的请求和生成时的响应时间)?
我试图为响应添加单独的模式,但它不起作用:
Also, I want to log the request and response with individual time for each(i.e, request with time when server received it and response with time when it was generated)? I tried to add a separate pattern for response but it didn't work:
<pattern>%h %l %user [%t{dd/MMM/yyyy:HH:mm:ss Z}] "%r" %s %b "%i{Referer}" "%i{User-Agent}" \nRequest:\n%fullRequest</pattern>
<pattern>%h %l %user [%t{dd/MMM/yyyy:HH:mm:ss Z}] "%r" %s %b "%i{Referer}" "%i{User-Agent}" \nResponse:\n%fullResponse</pattern>
任何实现它的想法?
问候,
Rahul
Regards, Rahul
推荐答案
您需要配置三个不同的appender,生成三种不同的模式,但不知道是否可以为同一个appender设置多个模式。
You need to configure three different appenders generating three different patterns, don't know if it is possible to have multiple patterns for the same appender though.
请务必将此行添加到 conf / neo4j-server.properties 文件
make sure to add this line to your conf/neo4j-server.properties file
org.neo4j.server.http.unsafe.content_log.enabled=true
这是 neo4j-http-logging.xml 满足您需求的示例
<configuration>
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>data/log/http.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>data/log/http.%d{yyyy-MM-dd_HH}.log</fileNamePattern>
<maxHistory>30</maxHistory>
</rollingPolicy>
<encoder>
<!-- Note the deliberate misspelling of "referer" in accordance with RFC1616 -->
<pattern>%h %l %user [%t{dd/MMM/yyyy:HH:mm:ss Z}] "%r" %s %b "%i{Referer}" "%i{User-Agent}" %D</pattern>
</encoder>
</appender>
<appender name="REQUEST" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>data/log/http.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>data/log/http.%d{yyyy-MM-dd_HH}.log</fileNamePattern>
<maxHistory>30</maxHistory>
</rollingPolicy>
<encoder>
<!-- Note the deliberate misspelling of "referer" in accordance with RFC1616 -->
<pattern>%h %l %user [%t{dd/MMM/yyyy:HH:mm:ss Z}] "%r" %s %b "%i{Referer}" "%i{User-Agent}" %D \n%fullRequest</pattern>
</encoder>
</appender>
<appender name="RESPONSE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>data/log/http.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>data/log/http.%d{yyyy-MM-dd_HH}.log</fileNamePattern>
<maxHistory>30</maxHistory>
</rollingPolicy>
<encoder>
<!-- Note the deliberate misspelling of "referer" in accordance with RFC1616 -->
<pattern>%h %l %user [%t{dd/MMM/yyyy:HH:mm:ss Z}] "%r" %s %b "%i{Referer}" "%i{User-Agent}" %D \n%fullResponse</pattern>
</encoder>
</appender>
<appender-ref ref="FILE"/>
<appender-ref ref="REQUEST"/>
<appender-ref ref="RESPONSE"/>
</configuration>
重启你的Neo4j服务器
Restart your Neo4j server
这篇关于在Neo4j服务器中为每个记录单独的时间记录http请求/响应的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!