Log4j recording from Neo4j extension server

My unmanaged server extension is using the slf4j-log4j protocol. When log4j.properties comes with an extension, the logging works fine. If it is not linked, but instead placed in the Neo4j conf directory, I assumed that

wrapper.java.additional=-Dlog4j.configuration=file:conf/log4j.properties

      

of neo4j-wrapper.conf

will provide his choice. However, I do not see the log file generated or the log level in use. The config file must be correct because it works as it is provided with the extension. Adding -Dlog4j.debug

, as pointed out in other posts, doesn't add more information.

Is there something I have missed? I am using Neo4j 2.1.3 for Mac OS X

+3


source to share


1 answer


Neo4j internally has banks logback

on board, so every logging using slf4j

will be handled with a log.

My approach to logging from an unmanaged extension looks like this:

Setting up your registrar in an unmanaged extension depends on slf4j-api

(don't add any other slf4j implementations to the classpath either) and use the registrar like this:

 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;

 private static final Logger logger = LoggerFactory.getLogger(com.mycompany.UnmanagedExtension.class);

      



Modify conf/custom-logback.xml

and correct at the end:

  <appender name="EXTENSIONLOG"  class="ch.qos.logback.core.FileAppender">
      <file>extensions.log</file>
      <encoder>
          <pattern>%date{yyyy-MM-dd HH:mm:ss.SSSZ} %-5level [%logger{15}]: %message%n</pattern>
      </encoder>
  </appender>

  <logger name="com.mycompany" level="debug">
    <appender-ref ref="EXTENSIONLOG"/>
  </logger>

      

conf/custom-logback.xml

included in Neo4j internal log config, see https://github.com/neo4j/neo4j/blob/master/community/kernel/src/main/resources/neo4j-logback.xml

+5


source







All Articles