我很难用IntelliJ中的Gradle配置IntelliJ。不管我做什么,我都会得到这样的信息:
SLF4J:未能加载类"org.slf4j.impl.StaticLoggerBinder“。SLF4J:默认为无操作(NOP)记录器实现SLF4J:有关更多详细信息,请参见。
我正在尝试登录到控制台,并在测试到特定文件夹中的文件之后。任何帮助都会很好。
build.gradle文件:
plugins {
id 'java'
id 'org.openjfx.javafxplugin' version '0.0.8'
id 'application'
}
version '1.0-SNAPSHOT'
sourceCompatibility = 1.8
repositories {
mavenCentral()
jcenter()
google()
}
dependencies {
compile group: 'com.googlecode.json-simple', name: 'json-simple', version: '1.+'
testCompile group: 'junit', name: 'junit', version: '4.12'
compile group: 'org.apache.poi', name: 'poi', version: '4.+'
compile group: 'org.apache.poi', name: 'poi-ooxml', version: '4.+'
compile group: 'org.slf4j', name: 'slf4j-api', version: '1.7.+'
// compile group: 'ch.qos.logback', name: 'logback-classic', version: '1.+'
implementation 'com.google.firebase:firebase-admin:6.11.0'
}
javafx {
version = '12'
modules = ['javafx.controls', 'javafx.fxml']
}
mainClassName = 'ui.Main'
apply plugin: 'org.openjfx.javafxplugin'
apply plugin: 'idea'
jar {
manifest {
attributes 'Main-Class': mainClassName
}
from {
configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) }
}
}log4j.properties文件(在src/main/log4j.properties/):
# Define the root logger with appender file
log4j.rootLogger = DEBUG, FILE
# Define the file appender
log4j.appender.FILE=org.apache.log4j.FileAppender
log4j.appender.FILE.File=${log}/log.out
# Define the layout for file appender
log4j.appender.FILE.layout=org.apache.log4j.PatternLayout
log4j.appender.FILE.layout.conversionPattern=%m%n发布于 2019-12-04 14:30:19
您需要在类路径上建立日志框架。SLF4J是一个日志外观,它支持多个实现(logback、log4j等)。但是,如果不包括特定的后端,SLF4J默认为忽略所有内容的NOP实现。:)
如果要使用log4j,则需要为其包括如下绑定:
compile group: 'org.slf4j', name: 'slf4j-log4j12', version: '1.7.29'有关更多信息,请参阅http://www.slf4j.org/manual.html#swapping
发布于 2019-12-04 14:28:23
由于您使用的是log4j.properties文件和SLf4J,所以您必须使用log4j绑定实现。与Slf4j一起使用下面的代码。
compile group: 'org.slf4j', name: 'slf4j-log4j12', version: '1.7.29'或者,如果使用更高版本的gradle,则可以使用implementation而不是编译组。
implementation 'org.slf4j:slf4j-log4j1:1.7.29'发布于 2019-12-04 14:27:16
添加
// https://mvnrepository.com/artifact/org.slf4j/slf4j-jdk14
Compile group: 'org.slf4j', name: 'slf4j-jdk14', version: '1.7.5'作为一种依赖,并进行尝试。
https://stackoverflow.com/questions/59178076
复制相似问题