No log4j2 configuration file found. Using default configuration: logging only errors to the console

前端 未结 15 1162
情深已故
情深已故 2020-12-04 22:59
$ java -Dlog4j.configuration=file:///path/to/your/log4j2.xml -jar /path/to/your/jar_file.jar

Written to the console, you get

ERROR          


        
15条回答
  •  忘掉有多难
    2020-12-05 00:05

    In my case I am using the log4j2 Json file log4j2.json in the classpath of my gradle project and I got the same error.

    The solution here was to add dependency for JSON handling to my gradle dependencies.

    compile group:"com.fasterxml.jackson.core", name:"jackson-core", version:'2.8.4'
    compile group:"com.fasterxml.jackson.core", name:"jackson-databind", version:'2.8.4'
    compile group:"com.fasterxml.jackson.core", name:"jackson-annotations", version:'2.8.4'
    

    See also documentation of log4j2:

    The JSON support uses the Jackson Data Processor to parse the JSON files. These dependencies must be added to a project that wants to use JSON for configuration:

提交回复
热议问题