Class Log4jLayoutToLogback


  • public class Log4jLayoutToLogback
    extends org.openrewrite.Recipe
    Log4jLayoutToLogback.Log4jLayoutToLogbackVisitor operates on the following assumptions:
    • A logback-classic layout must extend the LayoutBase<ILoggingEvent> class.
    • log4j's format() is renamed to doLayout() in a logback-classic layout.
    • LoggingEvent getRenderedMessage() is converted to LoggingEvent getMessage().
    • The log4j ignoresThrowable() method is not needed and has no equivalent in logback-classic.
    • The activateOptions() method merits further discussion. In log4j, a layout will have its activateOptions() method invoked by log4j configurators, that is PropertyConfigurator or DOMConfigurator just after all the options of the layout have been set. Thus, the layout will have an opportunity to check that its options are coherent and if so, proceed to fully initialize itself.
    • In logback-classic, layouts must implement the LifeCycle interface which includes a method called start(). The start() method is the equivalent of log4j's activateOptions() method.
    See Also:
    Migration from log4j
    • Field Summary

      • Fields inherited from class org.openrewrite.Recipe

        NOOP, PANIC
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.String getDescription()  
      java.lang.String getDisplayName()  
      protected org.openrewrite.TreeVisitor<?,​org.openrewrite.ExecutionContext> getSingleSourceApplicableTest()  
      protected org.openrewrite.TreeVisitor<?,​org.openrewrite.ExecutionContext> getVisitor()  
      • Methods inherited from class org.openrewrite.Recipe

        causesAnotherCycle, doNext, equals, getApplicableTest, getDescriptor, getJacksonPolymorphicTypeTag, getLanguages, getName, getRecipeList, getTags, hashCode, run, run, run, run, validate, validate, validateAll, validateAll, visit
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • Log4jLayoutToLogback

        public Log4jLayoutToLogback()
    • Method Detail

      • getDisplayName

        public java.lang.String getDisplayName()
        Specified by:
        getDisplayName in class org.openrewrite.Recipe
      • getDescription

        public java.lang.String getDescription()
        Overrides:
        getDescription in class org.openrewrite.Recipe
      • getSingleSourceApplicableTest

        protected org.openrewrite.TreeVisitor<?,​org.openrewrite.ExecutionContext> getSingleSourceApplicableTest()
        Overrides:
        getSingleSourceApplicableTest in class org.openrewrite.Recipe
      • getVisitor

        protected org.openrewrite.TreeVisitor<?,​org.openrewrite.ExecutionContext> getVisitor()
        Overrides:
        getVisitor in class org.openrewrite.Recipe