Good morning, I have been googling solutions trying to understand how to get my log.debug("...")
messages to output to my console this morning. My research into the problem indicates that I should only have to pass in an argument via command line when launching my app. That seems not to be the case. I am simply trying to see the output of log.debug()
somewhere.
I am using IntelliJ. I am using Maven.
Here is my pom.xml:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.example</groupId>
<artifactId>testapp</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.5</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>1.7.5</version>
</dependency>
</dependencies>
</project>
Here is App.java
import org.slf4j.*;
public class App {
private static final Logger log = LoggerFactory.getLogger(App.class);
public static void main(String[] args){
log.info("Info");
log.debug("Debug");
log.warn("Warn");
log.error("Error");
}
}
When I run the app with IntelliJ, here is the output:
"C:\Program Files\Java\jdk-17\bin\java.exe" "-javaagent:C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2021.2.2\lib\idea_rt.jar=63071:C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2021.2.2\bin" -Dfile.encoding=UTF-8 -classpath C:\Users\613296\lb\gits\testapp\target\classes;C:\Users\613296\.m2\repository\org\slf4j\slf4j-api\1.7.5\slf4j-api-1.7.5.jar;C:\Users\613296\.m2\repository\org\slf4j\slf4j-simple\1.7.5\slf4j-simple-1.7.5.jar App -Dorg.sl4fj.simpleLogger.defaultLogLevel=DEBUG
[main] INFO App - Info
[main] WARN App - Warn
[main] ERROR App - Error
Process finished with exit code 0
I am at a loss for what to do at this point. I've confirmed all the jar files in my classpath are present. The last option -Dorg.sl4fj.simpleLogger.defaultLogLevel=DEBUG
is what I thought would make this work (according to a lot of reading I've done). So, I must be missing something vital. Please help me understand what I need to do to achieve my goal!
CodePudding user response:
Move it before App
in the command line so the JVM sees it.
All arguments after the class to invoke are passed in the args
parameter. (Try printing it out)
CodePudding user response:
Did you try to run this app in DEBUG mode? If not try to run in debug mode, you might get the debug logs printed in console/log file.