I'm having a hard time configuring SLF4J with Gradle in IntelliJ. No matter what I do I get this message:
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder". SLF4J: Defaulting to no-operation (NOP) logger implementation SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
I'm trying to log in to the console and after testing to a file in a specific folder. Any help would be great.
build.gradle file:
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 file (in src/main/resources/):
# 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
In most cases, a project relies on reusable functionality in the form of libraries or is broken up into individual components to compose a modularized system. Dependency management is a technique for declaring, resolving and using dependencies required by the project in an automated fashion.
As the name specified, SLF4J is a simple logging façade for java. It is not a logging component, and even it does not do the actual logging. It is only an abstraction layer to an underlying logging component. In the case of Log4j, it is a logging component, and it does the logging instructed to do.
You need a logging framework on your classpath. SLF4J is a logging facade that supports multiple implementations (logback, log4j etc.). However, if you don't include a specific backend, SLF4J defaults to a NOP implementation that simply ignores everything. :)
If you want to use log4j
, you need to include a binding for it like this:
compile group: 'org.slf4j', name: 'slf4j-log4j12', version: '1.7.29'
For more information, see http://www.slf4j.org/manual.html#swapping
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With