Please excuse my language. I am only Deutsch A1, ich kann nicht technical satze formulieren.
Also coming to the question,
Totally a newbie to the concept I am asking about.
I have a maven project, with the support of project lombok and Slf4j for logging.
I expect the timestamp to be present in the log output. But I observe only the class name and the message.
Could anyone guide me through or suggest some links to go to?
1) pom.xml
2) Main class:
3) In the src/main/resources there is logback.xml
4) Output:
[main] INFO model.ObjectsAndVariables - HELLO
How to get the timestamps? Is there anything wrong in the heirarchy?
Also coming to the question,
Totally a newbie to the concept I am asking about.
I have a maven project, with the support of project lombok and Slf4j for logging.
I expect the timestamp to be present in the log output. But I observe only the class name and the message.
Could anyone guide me through or suggest some links to go to?
1) pom.xml
XML:
<dependencies>
<!-- https://mvnrepository.com/artifact/org.projectlombok/lombok -->
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.20</version>
<scope>provided</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/org.slf4j/slf4j-api -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>2.0.0-alpha4</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.slf4j/slf4j-simple -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>2.0.0-alpha4</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
</dependencies>
2) Main class:
Java:
import lombok.extern.slf4j.Slf4j;
@Slf4j
public class ObjectsAndVariables {
public static void main(String[] args) {
log.info("HELLO");
}}
3) In the src/main/resources there is logback.xml
XML:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<conversionRule conversionWord="clr"
converterClass="org.springframework.boot.logging.logback.ColorConverter" />
<conversionRule conversionWord="wex"
converterClass="org.springframework.boot.logging.logback.WhitespaceThrowableProxyConverter" />
<conversionRule conversionWord="wEx"
converterClass="org.springframework.boot.logging.logback.ExtendedWhitespaceThrowableProxyConverter" />
<property name="CONSOLE_LOG_PATTERN"
value="${CONSOLE_LOG_PATTERN:-%clr(%d{yyyy-MM-dd HH:mm:ss.SSS}){faint} %clr(${LOG_LEVEL_PATTERN:-%5p}) %clr(${PID:- }){magenta} %clr(---){faint} %clr([%15.15t]){faint} %clr(%-40.40logger{39}){cyan} %clr(:){faint} %m%n${LOG_EXCEPTION_CONVERSION_WORD:-%wEx}}" />
<appender name="STDOUT"
class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>${CONSOLE_LOG_PATTERN}</pattern>
<charset>UTF-8</charset>
</encoder>
</appender>
<!-- Console output log level -->
<root level="INFO">
<appender-ref ref="STDOUT" />
</root>
</configuration>
4) Output:
[main] INFO model.ObjectsAndVariables - HELLO
How to get the timestamps? Is there anything wrong in the heirarchy?