JAVA-5190: Create a new spring-boot-disable-logging module
This commit is contained in:
1
spring-boot-modules/spring-boot-disable-logging/disabling-console-logback/.gitignore
vendored
Normal file
1
spring-boot-modules/spring-boot-disable-logging/disabling-console-logback/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
disabled-console.log
|
||||
@@ -0,0 +1,23 @@
|
||||
<?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>
|
||||
<artifactId>disabling-console-logback</artifactId>
|
||||
<name>disabling-console-logback</name>
|
||||
|
||||
<parent>
|
||||
<groupId>com.baeldung.spring-boot-modules</groupId>
|
||||
<artifactId>spring-boot-disable-logging</artifactId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
<relativePath>../</relativePath>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
@@ -0,0 +1,11 @@
|
||||
package com.baeldung.springbootlogging.disablingconsole.logback.xml;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
@SpringBootApplication
|
||||
public class DisablingConsoleLogbackApp {
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(DisablingConsoleLogbackApp.class, args);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.baeldung.springbootlogging.disablingconsole.logback.xml.controllers;
|
||||
|
||||
import java.time.LocalTime;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
public class DisabledConsoleRestController {
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(DisabledConsoleRestController.class);
|
||||
|
||||
@GetMapping("/disabled-console-logback-xml")
|
||||
public String logTime() {
|
||||
LOG.info("Current time: {}", LocalTime.now());
|
||||
return "finished!";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
logging.file=disabled-console.log
|
||||
|
||||
### we could potentially 'disable' console logging by setting a blank log pattern:
|
||||
#logging.pattern.console=
|
||||
|
||||
### or disable the logs completely by setting the root logging level as 'OFF':
|
||||
#logging.level.root=OFF
|
||||
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<configuration>
|
||||
<include resource="org/springframework/boot/logging/logback/defaults.xml" />
|
||||
<include resource="org/springframework/boot/logging/logback/file-appender.xml" />
|
||||
<root level="INFO">
|
||||
<appender-ref ref="FILE" />
|
||||
</root>
|
||||
</configuration>
|
||||
Reference in New Issue
Block a user