Skip to content

Commit

Permalink
Remove Logback support because of slfj4 1.x / 2.x ecosystem split
Browse files Browse the repository at this point in the history
- Gretty should be open to more than one logging framework.
  Webapps must not have more than one logging framework on their classpath.
- Because servlet containers have different versions requirements on slf4j,
  and, by extension, Logback, maintaining Logback support in Gretty is not
  feasible.
  • Loading branch information
f4lco committed Nov 3, 2022
1 parent f4966bd commit 0ad88db
Show file tree
Hide file tree
Showing 24 changed files with 8 additions and 561 deletions.
1 change: 0 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ tomcat9_version = 9.0.58
tomcat9_servlet_api_version = 4.0.1
asm_version = 9.2
spock_version = 1.3-groovy-2.5
logback_version = 1.2.10
commons_cli_version = 1.3.1
commons_io_version = 2.11.0
slf4j_version = 1.7.36
Expand Down
1 change: 1 addition & 0 deletions integrationTests/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
rootProjectName = gretty-integrationTests
group = org.gretty.internal.integrationTests
org.gradle.warning.mode=all
logback_version = 1.2.10
# other properties are copied by gradle script from top-level project
2 changes: 1 addition & 1 deletion integrationTests/grettyLogging_logback/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ apply plugin: 'org.gretty'
apply plugin: 'org.gretty.internal.integrationTests.IntegrationTestPlugin'

dependencies {
implementation 'ch.qos.logback:logback-classic:1.1.2'
implementation "ch.qos.logback:logback-classic:$logback_version"
}

defineIntegrationTest()
Expand Down
2 changes: 0 additions & 2 deletions libs/gretty-common/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,4 @@ plugins {
dependencies {
// #231 If we decide to drop Gradle 6 support / Groovy 2 support, we can drop choosing Groovy versions at runtime again.
compileOnly localGroovy()

api "org.slf4j:slf4j-api:$slf4j_version"
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,9 @@
*/
package org.akhikhl.gretty

import groovy.util.logging.Slf4j

import java.nio.charset.StandardCharsets
import java.util.concurrent.CompletableFuture

@Slf4j
final class ServiceProtocol {

static Reader createReader(int port = 0) {
Expand Down Expand Up @@ -46,7 +43,6 @@ final class ServiceProtocol {
} finally {
acceptSocket.close()
}
log.debug 'ServiceProtocol.readMessageFromServerSocket({}) -> {}', serverSocket.getLocalPort(), data
return data
}

Expand All @@ -72,7 +68,6 @@ final class ServiceProtocol {
}

def write(final String command) {
log.debug 'ServiceProtocol.send({}, {})', port, command
Socket s = new Socket(InetAddress.loopbackAddress, port)
try {
OutputStream out = s.getOutputStream()
Expand All @@ -87,7 +82,7 @@ final class ServiceProtocol {
try {
write(command)
} catch (e) {
log.debug(e.getMessage(), e)
e.printStackTrace()
}
}

Expand Down
3 changes: 1 addition & 2 deletions libs/gretty-core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import org.apache.tools.ant.filters.*
dependencies {
// #231 If we decide to drop Gradle 6 support / Groovy 2 support, we can drop choosing Groovy versions at runtime again.
compileOnly localGroovy()
compileOnly "org.slf4j:slf4j-api:$slf4j_version"

api "ch.qos.logback:logback-classic:$logback_version"
api "commons-cli:commons-cli:$commons_cli_version"
api 'commons-configuration:commons-configuration:1.10'
api "commons-io:commons-io:$commons_io_version"
Expand Down Expand Up @@ -38,7 +38,6 @@ tasks.processResources {
springBootVersion: project.springBootVersion,
springLoadedVersion: project.springLoadedVersion,
springVersion: project.springVersion,
logbackVersion: project.logback_version,
asmVersion: project.asm_version
]
inputs.properties props
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -250,20 +250,6 @@ abstract class LauncherBase implements Launcher {
writer.write('stop')
}

protected void writeLoggingConfig(json) {
json.with {
if(sconfig.logbackConfigFile)
logbackConfigFile sconfig.logbackConfigFile.toString()
loggingLevel sconfig.loggingLevel
consoleLogEnabled sconfig.consoleLogEnabled
fileLogEnabled sconfig.fileLogEnabled
if(sconfig.logFileName)
logFileName sconfig.logFileName
if(sconfig.logDir)
logDir sconfig.logDir.toString()
}
}

protected void writeRunConfigJson(json) {
def self = this
json.with {
Expand Down Expand Up @@ -304,7 +290,6 @@ abstract class LauncherBase implements Launcher {
realmConfigFile self.fileToString(sconfig.realmConfigFile)
if(sconfig.serverConfigFile)
serverConfigFile self.fileToString(sconfig.serverConfigFile)
writeLoggingConfig(json)
if(config.baseDir)
baseDir config.baseDir.absolutePath
if(sconfig.singleSignOn != null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,6 @@ class ServerConfig {
def serverConfigFile
String interactiveMode
Integer scanInterval
def logbackConfigFile
String loggingLevel
Boolean consoleLogEnabled
Boolean fileLogEnabled
def logFileName
def logDir
List<Closure> onStart
List<Closure> onStop
List<Closure> onScan
Expand All @@ -60,7 +54,6 @@ class ServerConfig {
String springBootVersion
String springLoadedVersion
String springVersion
String logbackVersion
Boolean singleSignOn
/**
* Tomcat-specific: Enables JNDI naming which is disabled by default.
Expand All @@ -83,12 +76,7 @@ class ServerConfig {
result.httpsEnabled = false
result.interactiveMode = 'stopOnKeyPress'
result.scanInterval = 1
result.loggingLevel = 'INFO'
result.consoleLogEnabled = true
result.fileLogEnabled = true
result.logFileName = serverName
result.redeployMode = 'restart'
result.logDir = "${System.getProperty('user.home')}/logs" as String
result.scanner = 'jetty'
result.portPropertiesFileName = 'gretty_ports.properties'
result.liveReloadEnabled = false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,4 @@ tomcat9ServletApiVersion=@tomcat9ServletApiVersion@
springBootVersion=@springBootVersion@
springLoadedVersion=@springLoadedVersion@
springVersion=@springVersion@
logbackVersion=@logbackVersion@
asmVersion=@asmVersion@
1 change: 0 additions & 1 deletion libs/gretty-runner/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ dependencies {

api "commons-cli:commons-cli:$commons_cli_version"
api "commons-io:commons-io:$commons_io_version"
api "ch.qos.logback:logback-classic:$logback_version"
api project(':libs:gretty-common')
api project(':libs:gretty-runner-api')
}
166 changes: 0 additions & 166 deletions libs/gretty-runner/src/main/groovy/org/akhikhl/gretty/LogUtil.groovy

This file was deleted.

Loading

0 comments on commit 0ad88db

Please sign in to comment.