Skip to content

Commit

Permalink
logging cleanups:
Browse files Browse the repository at this point in the history
- update to latest slf4j. This required converting logback.groovy to logback.xml
- change stairctl to not log at all
  • Loading branch information
pshapiro4broad committed Aug 1, 2024
1 parent b94e8b7 commit 939558d
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 73 deletions.
2 changes: 1 addition & 1 deletion buildSrc/src/main/groovy/stairway.java-conventions.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ repositories {

dependencies {
// For logging
implementation group: 'org.slf4j', name: 'slf4j-api', version: '1.7.36'
implementation group: 'org.slf4j', name: 'slf4j-api', version: '2.0.13'

// Database
runtimeOnly group: 'org.postgresql', name: 'postgresql', version: '42.7.2'
Expand Down
6 changes: 1 addition & 5 deletions stairctl/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,5 @@ dependencies {
// Spring
implementation group: 'org.springframework.boot', name: 'spring-boot'
// Spring Boot and Spring Shell versions should stay in sync
implementation('org.springframework.shell:spring-shell-starter:3.3.1') {
exclude module: 'spring-boot-starter-logging'
}

implementation 'org.slf4j:slf4j-simple:1.7.36'
implementation group: 'org.springframework.shell', name: 'spring-shell-starter', version: '3.3.1'
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,13 @@
import org.apache.commons.lang3.ClassUtils;
import org.apache.commons.lang3.StringUtils;
import org.jline.terminal.Terminal;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

@Component
public class Output {

private final Terminal terminal;

private static final Logger logger = LoggerFactory.getLogger(Output.class);

private static final int CLASS_DISPLAY_LENGTH = 36;
private static final String FLIGHT_LIST_FORMAT =
"%6s %-36s %-" + CLASS_DISPLAY_LENGTH + "s %-27s %-27s %-12s %-30s\n";
Expand Down Expand Up @@ -243,7 +239,6 @@ private int display(String indent, List<Pair> pairList) {

public void error(String userMessage, Exception ex) {
println(userMessage + ": " + ex.getMessage());
logger.error("{}: ", userMessage, ex);
}

private static String shortenClassName(String in) {
Expand Down
5 changes: 5 additions & 0 deletions stairctl/src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,8 @@ spring:
enabled: true
script:
enabled: true

# Disable logging
logging:
pattern:
console:
31 changes: 0 additions & 31 deletions stairctl/src/main/resources/logback.groovy

This file was deleted.

31 changes: 0 additions & 31 deletions stairway/src/test/resources/logback.groovy

This file was deleted.

35 changes: 35 additions & 0 deletions stairway/src/test/resources/logback.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<!--
LogBack Configuration File
This file controls how, where, and what gets logged.
-->

<!-- Frequency of checking this file for changes and altering the logging. -->
<configuration scan="true" scanPeriod="30 seconds">
<!-- Where the logs will go -->
<property name="LOG_PATH" value="logs" />

<!-- Appender that sends to the console -->
<appender name="Console-Appender" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%date %-5level [%thread] %logger{36}: %message%n</pattern>
</encoder>
</appender>

<!-- Appender that sends to a file -->
<appender name="File-Appender" class="ch.qos.logback.core.FileAppender">
<file>${LOG_PATH}/stairway.log</file>
<encoder>
<pattern>%date %-5level [%thread]: %message%n</pattern>
<outputPatternAsHeader>true</outputPatternAsHeader>
</encoder>
</appender>

<logger name="bio.terra.stairway" level="DEBUG" />
<logger name="liquibase" level="WARN" />

<!-- root sets the default logging level and appenders -->
<root level="INFO">
<appender-ref ref="Console-Appender" />
<appender-ref ref="File-Appender" />
</root>
</configuration>

0 comments on commit 939558d

Please sign in to comment.