我想记录http请求和对Neo4j服务器的响应。我在下面的问题中搜索并获得了stackoverflow本身的答案: 如何将查询语句记录到Neo4j服务器,是否可能?
对上述问题的回答中的配置导致同时记录请求/响应。我想知道那个时间代表什么,即服务器何时收到请求或何时生成响应?
另外,我想记录每个请求和响应的时间(即,服务器收到请求时的请求和生成时的响应)? 我试图为响应添加一个单独的模式,但它没有工作:
<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>
&#13;
实现它的任何想法?
此致 拉胡
答案 0 :(得分:4)
您需要配置三个不同的appender,生成三种不同的模式,但不知道是否可以为同一个appender设置多个模式。
确保将此行添加到 conf / neo4j-server.properties 文件中
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服务器