Replace JUL active Level check with corresponding SLF4J method calls
Recipe ID
org.openrewrite.java.logging.slf4j.JulToSlf4jLambdaSupplierRecipesArtifact
org.openrewrite.recipe:rewrite-logging-frameworksReplace calls to Logger.isLoggable(Level) with the corresponding SLF4J method calls.
Usage
This recipe has no required configuration options. You’ll need the Moderne CLI configured before running the command below.
mod run . --recipe org.openrewrite.java.logging.slf4j.JulToSlf4jLambdaSupplierRecipesIf the recipe isn’t available locally, install it with:
mod config recipes jar install org.openrewrite.recipe:rewrite-logging-frameworks:3.31.0Definition
This recipe runs the following recipes in order.
- Replace JUL
Logger.finest(Supplier<String>)with SLF4J'sLogger.atTrace().log(Supplier<String>)org.openrewrite.java.logging.slf4j.JulToSlf4jLambdaSupplierRecipes$JulToSlf4jSupplierFinestRecipe - Replace JUL
Logger.finer(Supplier<String>)with SLF4J'sLogger.atTrace().log(Supplier<String>)org.openrewrite.java.logging.slf4j.JulToSlf4jLambdaSupplierRecipes$JulToSlf4jSupplierFinerRecipe - Replace JUL
Logger.fine(Supplier<String>)with SLF4J'sLogger.atDebug().log(Supplier<String>)org.openrewrite.java.logging.slf4j.JulToSlf4jLambdaSupplierRecipes$JulToSlf4jSupplierFineRecipe - Replace JUL
Logger.config(Supplier<String>)with SLF4J'sLogger.atInfo().log(Supplier<String>)org.openrewrite.java.logging.slf4j.JulToSlf4jLambdaSupplierRecipes$JulToSlf4jSupplierConfigRecipe - Replace JUL
Logger.info(Supplier<String>)with SLF4J'sLogger.atInfo().log(Supplier<String>)org.openrewrite.java.logging.slf4j.JulToSlf4jLambdaSupplierRecipes$JulToSlf4jSupplierInfoRecipe - Replace JUL
Logger.warning(Supplier<String>)with SLF4J'sLogger.atWarn().log(Supplier<String>)org.openrewrite.java.logging.slf4j.JulToSlf4jLambdaSupplierRecipes$JulToSlf4jSupplierWarningRecipe - Replace JUL
Logger.severe(Supplier<String>)with SLF4J'sLogger.atError().log(Supplier<String>)org.openrewrite.java.logging.slf4j.JulToSlf4jLambdaSupplierRecipes$JulToSlf4jSupplierSevereRecipe - Replace JUL
Logger.log(Level.FINEST, Supplier<String>)with SLF4J'sLogger.atInfo().log(Supplier<String>)org.openrewrite.java.logging.slf4j.JulToSlf4jLambdaSupplierRecipes$JulToSlf4jSupplierLogFinestRecipe - Replace JUL
Logger.log(Level.FINER, Supplier<String>)with SLF4J'sLogger.atInfo().log(Supplier<String>)org.openrewrite.java.logging.slf4j.JulToSlf4jLambdaSupplierRecipes$JulToSlf4jSupplierLogFinerRecipe - Replace JUL
Logger.log(Level.FINE, Supplier<String>)with SLF4J'sLogger.atInfo().log(Supplier<String>)org.openrewrite.java.logging.slf4j.JulToSlf4jLambdaSupplierRecipes$JulToSlf4jSupplierLogFineRecipe - Replace JUL
Logger.log(Level.CONFIG, Supplier<String>)with SLF4J'sLogger.atInfo().log(Supplier<String>)org.openrewrite.java.logging.slf4j.JulToSlf4jLambdaSupplierRecipes$JulToSlf4jSupplierLogConfigRecipe - Replace JUL
Logger.log(Level.INFO, Supplier<String>)with SLF4J'sLogger.atInfo().log(Supplier<String>)org.openrewrite.java.logging.slf4j.JulToSlf4jLambdaSupplierRecipes$JulToSlf4jSupplierLogInfoRecipe - Replace JUL
Logger.log(Level.WARNING, Supplier<String>)with SLF4J'sLogger.atInfo().log(Supplier<String>)org.openrewrite.java.logging.slf4j.JulToSlf4jLambdaSupplierRecipes$JulToSlf4jSupplierLogWarningRecipe - Replace JUL
Logger.log(Level.SEVERE, Supplier<String>)with SLF4J'sLogger.atInfo().log(Supplier<String>)org.openrewrite.java.logging.slf4j.JulToSlf4jLambdaSupplierRecipes$JulToSlf4jSupplierLogSevereRecipe - Replace JUL
Logger.log(Level.ALL, Supplier<String>)with SLF4J'sLogger.atInfo().log(Supplier<String>)org.openrewrite.java.logging.slf4j.JulToSlf4jLambdaSupplierRecipes$JulToSlf4jSupplierLogAllRecipe
Data tables
Structured output this recipe can produce.
- Source files that had resultsSource files that were modified by the recipe run.
org.openrewrite.table.SourcesFileResults - Source files that had search resultsSearch results that were found during the recipe run.
org.openrewrite.table.SearchResults - Source files that errored on a recipeThe details of all errors produced by a recipe run.
org.openrewrite.table.SourcesFileErrors - Recipe performanceStatistics used in analyzing the performance of recipes.
org.openrewrite.table.RecipeRunStats