Created
April 23, 2019 01:40
-
-
Save kurotesuta/6fb0dd6ff6cc68f64175dae62ec9debf to your computer and use it in GitHub Desktop.
Super basic log4j2 example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class HomePage extends BasePage { | |
// Any log will be register under HomePage.class | |
private static final Logger logger = LogManager.getLogger(HomePage.class); | |
@FindBy(xpath = "someXpath here") | |
private WebElement loginButton; | |
public HomePage(AndroidDriver driver) { | |
super(driver); | |
} | |
// Method to have a more descriptive log | |
public void logStep(String step) { | |
logger.log(Level.INFO, step); | |
} | |
public void clickLoginButton() { | |
logStep("CLICK " + getLoginButtonText()); | |
loginButton.click(); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<Configuration status="warn"> | |
<Properties> | |
<Property name="PATTERN_INFO">%-5level %d{yyyy-MM-dd HH:mm:ss.SSS} [%t] %c{0} - %msg%n</Property> | |
</Properties> | |
<Appenders> | |
<Console name="Console" target="SYSTEM_OUT"> | |
<PatternLayout pattern="${PATTERN_INFO}"/> | |
</Console> | |
</Appenders> | |
<Loggers> | |
<Root level="debug"> | |
<AppenderRef ref="Console"/> | |
</Root> | |
</Loggers> | |
</Configuration> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment