I'm using JsonPath
for my JSON parsing work in Java. Is there any ways to remove the debug
logs upon running the code?
So basically, I am simply trying to run my parsing code in Maven:
String pageName = JsonPath.read(json, "$['pageInfo']['pageName']");
System.out.println(pageName);
But when running the jar
artifact file, it show the following as the first line:
0 [main] DEBUG com.jayway.jsonpath.internal.path.CompiledPath - Evaluating path: $['pageInfo']['pageName']
How to ignore this line? This appears upon running each JsonPath.read()
call.
UPDATES:
Initially I was getting some red-colored logs from log4j
so added these dependencies. The red logs disappeared, but the above log (now black) appeared!
<!-- https://mvnrepository.com/artifact/org.slf4j/slf4j-simple -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.5</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.7.5</version>
</dependency>
I also add the logBack
dependency. But still the code snippet can not be recognized:
This question was actually asked on 2017 on their official github page.
Looks like you need to use a logback as the log implementation
here is the code provided by andreasaronsson from the github issue
LoggerContext logContext = (LoggerContext) LoggerFactory.getILoggerFactory();
ch.qos.logback.classic.Logger log = logContext.getLogger("com.jayway.jsonpath.internal.path.CompiledPath");
log.setLevel(Level.INFO);
You need this in your dependencies
<dependencies>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>2.11.1</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.11.1</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.2.3</version>
</dependency>
</dependencies>
For more closure about the issue you can find it here