Add SLF4J logging support for Appium local service by alexander-poulikakos · Pull Request #1014 · appium/java-client

Change list

Add possibilty to enable server output data logging through SLF4J loggers. This allow server output data to be configured with your preferred logging frameworks (e.g. java.util.logging, logback, log4j).

Types of changes

  • No changes in production code.
  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Details

Normal use case:

	    AppiumDriverLocalService service = ...
	    service.clearOutPutStreams();
	    service.enableDefaultSlf4jLoggingOfOutputData(); // <-- add this method call
	    service.start();

By default log messages are:

  • logged at INFO level, unless log message is pre-fixed by [debug] then logged at DEBUG level.
  • logged by a SLF4J logger instance with a logger name corresponding to the appium sub module as prefixed in log message (logger name is transformed to lower case, no spaces and prefixed with "appium.service.").

Example of log messages:

  • Log message "[ADB] Cannot read version codes of " is logged by logger: appium.service.adb at level INFO
  • Log message "[debug] [XCUITest] Xcode version set to 'x.y.z' " is logged by logger appium.service.xcuitest at level DEBUG

More general purposes
These methods are provided for more general use cases:

service.addSlf4jLogMessageConsumer(BiConsumer);
service.addLogMessageConsumer(Consumer)