fix boot logging modules

This commit is contained in:
Loredana Crusoveanu
2018-10-14 23:40:39 +03:00
parent e51b8261c7
commit c882fa6e54
25 changed files with 65 additions and 64 deletions

View File

@@ -0,0 +1,48 @@
<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>
<artifactId>disabling-console-jul</artifactId>
<!-- this needs to use the boot parent directly in order to not inherit logback dependencies -->
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.5.RELEASE</version>
</parent>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jul-to-slf4j</artifactId>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>

View File

@@ -0,0 +1,11 @@
package com.baeldung.springbootlogging.disablingconsole.jul.properties;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class DisablingConsoleJulApp {
public static void main(String[] args) {
SpringApplication.run(DisablingConsoleJulApp.class, args);
}
}

View File

@@ -0,0 +1,19 @@
package com.baeldung.springbootlogging.disablingconsole.jul.properties.controllers;
import java.time.LocalTime;
import java.util.logging.Logger;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class DisabledConsoleRestController {
private static final Logger LOG = Logger.getLogger(DisabledConsoleRestController.class.getName());
@GetMapping("/disabled-console-jul-properties")
public String logTime() {
LOG.info("Current time: " + LocalTime.now());
return "finished!";
}
}

View File

@@ -0,0 +1,4 @@
handlers= java.util.logging.FileHandler
java.util.logging.FileHandler.pattern=baeldung.log
java.util.logging.FileHandler.formatter = java.util.logging.SimpleFormatter