Skip to content

Commit c3b8ed0

Browse files
Ruben NoguerolesRuben Nogueroles
Ruben Nogueroles
authored and
Ruben Nogueroles
committed
Update log4j version
1 parent bc24e63 commit c3b8ed0

File tree

7 files changed

+49
-28
lines changed

7 files changed

+49
-28
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/target/
22
*/target/**
3+
files/
34
/test-output/
45
*/test-output/**
56
.DS_Store

pom.xml

+10-5
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
<maven-compiler-plugin.version>3.8.0</maven-compiler-plugin.version>
3333
<testng.version>6.14.2</testng.version>
3434
<commons.lang3.version>3.12.0</commons.lang3.version>
35-
<log4j.version>1.2.17</log4j.version>
35+
<log4j.version>2.18.0</log4j.version>
3636
<commons-io.version>2.4</commons-io.version>
3737
<aspectj.version>1.9.9.1</aspectj.version>
3838

@@ -68,10 +68,15 @@
6868
<artifactId>commons-lang3</artifactId>
6969
<version>${commons.lang3.version}</version>
7070
</dependency>
71-
<dependency>
72-
<groupId>log4j</groupId>
73-
<artifactId>log4j</artifactId>
74-
<version>${log4j.version}</version>
71+
<dependency>
72+
<groupId>org.apache.logging.log4j</groupId>
73+
<artifactId>log4j-api</artifactId>
74+
<version>${log4j.version}</version>
75+
</dependency>
76+
<dependency>
77+
<groupId>org.apache.logging.log4j</groupId>
78+
<artifactId>log4j-core</artifactId>
79+
<version>${log4j.version}</version>
7580
</dependency>
7681
<!-- https://mvnrepository.com/artifact/org.aspectj/aspectjweaver -->
7782
<dependency>

src/main/java/com/wizeline/selenium/drivers/BaseWebDriverUtil.java

+12-4
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212
import java.util.List;
1313

1414
import org.apache.commons.io.FileUtils;
15-
import org.apache.log4j.Logger;
15+
import org.apache.logging.log4j.LogManager;
16+
import org.apache.logging.log4j.Logger;
1617
import org.openqa.selenium.By;
1718
import org.openqa.selenium.JavascriptExecutor;
1819
import org.openqa.selenium.OutputType;
@@ -23,12 +24,13 @@
2324
import org.openqa.selenium.support.ui.ExpectedConditions;
2425
import org.openqa.selenium.support.ui.WebDriverWait;
2526

27+
2628
import com.wizeline.selenium.utils.Initialization;
2729

2830

2931
public class BaseWebDriverUtil {
3032

31-
private static Logger log = Logger.getLogger(BaseWebDriverUtil.class);
33+
private static Logger log = LogManager.getLogger(BaseWebDriverUtil.class);
3234

3335
// **** Basic operation methods section ****//
3436
/**
@@ -42,19 +44,25 @@ public class BaseWebDriverUtil {
4244
* case
4345
*/
4446
public static boolean existsElement(BaseWebDriver driver, By selector) {
45-
log.info(
47+
48+
49+
log.info(
4650
"[log-Utils] BaseWebDriverUtil - Start existsElement method");
4751

4852
boolean exists = false;
4953

5054
try {
5155
exists = (driver.findElement(selector) != null);
56+
57+
5258
} catch (Exception ex) {
5359
exists = false;
5460
}
55-
61+
5662
log.info("[log-Utils] BaseWebDriverUtil - End existsElement method");
5763

64+
65+
5866
return exists;
5967
}
6068

src/main/java/com/wizeline/selenium/testSets/DefaultTestSet.java

+4-3
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
import java.io.File;
44
import java.lang.reflect.Method;
55

6-
import org.apache.log4j.Logger;
6+
import org.apache.logging.log4j.LogManager;
7+
import org.apache.logging.log4j.Logger;
78
import org.testng.Assert;
89
import org.testng.ITestResult;
910
import org.testng.annotations.AfterMethod;
@@ -29,8 +30,8 @@ public class DefaultTestSet {
2930
//PageObjetc instances
3031
protected LandingPage landingPage;
3132
protected ResultsPage resultsPage;
32-
33-
protected static Logger log = Logger.getLogger(DefaultTestSet.class);
33+
34+
private static Logger log = LogManager.getLogger(DefaultTestSet.class);
3435

3536
@BeforeClass(description = "beforeClassMethod")
3637
public void beforeClass() {

src/main/java/com/wizeline/selenium/utils/Initialization.java

+6-6
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
import java.util.Properties;
88

99
import org.apache.commons.io.FileUtils;
10-
import org.apache.log4j.Logger;
11-
10+
import org.apache.logging.log4j.LogManager;
11+
import org.apache.logging.log4j.Logger;
1212
import org.openqa.selenium.chrome.ChromeOptions;
1313
import org.openqa.selenium.firefox.FirefoxOptions;
1414
import org.openqa.selenium.firefox.FirefoxProfile;
@@ -17,7 +17,6 @@
1717
import com.wizeline.selenium.drivers.CustomChromeDriver;
1818
import com.wizeline.selenium.drivers.CustomFirefoxDriver;
1919

20-
2120
public class Initialization {
2221

2322
private String properties;
@@ -33,7 +32,8 @@ public class Initialization {
3332
private int heightBeforeMaximize;
3433
private int heightAfterMaximize;
3534
private static Initialization instance = null;
36-
private static Logger log = Logger.getLogger(Initialization.class);
35+
36+
private static Logger log = LogManager.getLogger(Initialization.class);
3737

3838
BaseWebDriver driver;
3939

@@ -63,7 +63,7 @@ public void readProperties() {
6363

6464
properties = "test.properties";
6565
Properties prop = new Properties();
66-
log = Logger.getLogger(this.getClass());
66+
//log = Logger.getLogger(this.getClass());
6767

6868
try {
6969
ClassLoader loader = Thread.currentThread().getContextClassLoader();
@@ -243,7 +243,7 @@ public void cleanDownloadDirectory() {
243243
try {
244244
FileUtils.cleanDirectory(f);
245245
} catch (IOException e) {
246-
log.error(e.getStackTrace());
246+
log.error(e.getStackTrace().toString());
247247
}
248248
}
249249
}

src/main/resources/log4j.properties

-10
This file was deleted.

src/main/resources/log4j2.properties

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Extra logging related to initialization of Log4j
2+
# Set to info or trace if log4j initialization is failing
3+
status = warn
4+
# Name of the configuration
5+
name = ConsoleLogConfigDemo
6+
7+
# Console appender configuration
8+
appender.console.type = Console
9+
appender.console.name = consoleLogger
10+
appender.console.layout.type = PatternLayout
11+
appender.console.layout.pattern = %d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n
12+
13+
# Root logger level
14+
rootLogger.level = INFO
15+
# Root logger referring to console appender
16+
rootLogger.appenderRef.stdout.ref = consoleLogger

0 commit comments

Comments
 (0)