GraphHopper.com | Forum | GitHub | Maps | Blog

Mapmatching log level


#1

Hi there,

i wrote code which is using the latest graphhopper-map-matching-core, currently version 0.11.0-4. My developing environment is eclipse.

My problem is, that the logger level of map-matching is apparently set to DEBUG and the log level of graphhopper-core to INFO since my output includes

[main] DEBUG com.graphhopper.matching.MapMatching...

I figured, that i have to put log4j.xml in /src/main/ressources/, but it has no effect.

My log4.xml:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
<log4j:configuration>
    <appender name="stdout" class="org.apache.log4j.ConsoleAppender">
        <layout class="org.apache.log4j.PatternLayout">
            <param name="ConversionPattern" value="%d [%t] %-5p %c - %m%n"/>
        </layout>
    </appender>
    <appender name="ASYNC" class="org.apache.log4j.AsyncAppender">
        <param name="BufferSize" value="500"/>
        <appender-ref ref="stdout"/>
    </appender>   
    <logger name="com.graphhopper" additivity="false">
        <level value="off" />
        <appender-ref ref="ASYNC" />
    </logger>
    <!-- order important otherwise we'll get a warning -->
    <root>
        <priority value="info"></priority>
        <appender-ref ref="ASYNC"/>
    </root>
</log4j:configuration>

if i run mvn dependency:build-classpath -Dmdep.outputFile=classpath.txt the file classpath.txt starts with:

/Users/knowname/.m2/repository/com/graphhopper/graphhopper-map-matching-core/0.11.0-4/graphhopper-map-matching-core-0.11.0-4.jar:
/Users/knowname/.m2/repository/com/graphhopper/graphhopper-reader-osm/0.11.0/graphhopper-reader-osm-0.11.0.jar:
/Users/knowname/.m2/repository/com/graphhopper/graphhopper-core/0.11.0/graphhopper-core-0.11.0.jar:
...

Any ideas what to do so that my log4j.xml is beeing used?

Thank you!


#2

Since 0.11 you configure logging directly in the config.yml like described here: https://www.dropwizard.io/1.3.5/docs/manual/configuration.html#logging


#3

Thank you for that hint.

For now i copied the logback.xml from here to src/main/resources.
After my modification it does what i want (WARN instead of DEBUG).

<configuration debug="false"> 
  <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> 
    <!-- encoders are  by default assigned the type
         ch.qos.logback.classic.encoder.PatternLayoutEncoder -->
    <encoder>
      <pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
    </encoder>
  </appender>

  <root level="WARN">
    <appender-ref ref="STDOUT" />
  </root>
</configuration>

I guess the right way through config.yml would mean to create a separate Configuration class like MapMatchingServerConfiguration?