0

I'm using a library called JSONPath to parse JSON messages in Java. I should always add the following code to make its redundent logs to disappear.

Is there any ways to do this in the log4j .xml file or somewhere other than my code itself? I just don't want to see this inside the technical code.

// must be added for the JSONPath debug logs to disappear.
LoggerContext logContext = (LoggerContext) LoggerFactory.getILoggerFactory();
ch.qos.logback.classic.Logger log = logContext.getLogger("com.jayway.jsonpath.internal.path.CompiledPath");
log.setLevel(Level.INFO);
Tina J
  • 4,983
  • 13
  • 59
  • 125
  • Try adding this to the xml file ` ` – LMC Apr 18 '19 at 19:35
  • @LuisMuñoz Tried adding that to `log4j2.xml` file. But got error: `2019-04-19 16:03:26,965 main WARN Error while converting string [] to type [class org.apache.logging.log4j.Level]. Using default value [null]. java.lang.IllegalArgumentException: Unknown level constant [].` – Tina J Apr 19 '19 at 21:04
  • My bad! that's for `log4j`. For `log4j2`it should be ` `. – LMC Apr 19 '19 at 22:45
  • @LuisMuñoz no change. Remember, this `logger` comes from `ch.qos.logback.classic.Logger` if you see my code. I hope this helps. – Tina J Apr 22 '19 at 15:05

0 Answers0