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
INFOlevel, unless log message is pre-fixed by[debug]then logged atDEBUGlevel. - 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.adbat levelINFO - Log message
"[debug] [XCUITest] Xcode version set to 'x.y.z' "is logged by loggerappium.service.xcuitestat levelDEBUG
More general purposes
These methods are provided for more general use cases:
service.addSlf4jLogMessageConsumer(BiConsumer); service.addLogMessageConsumer(Consumer)