Part of my code:
public class TestContext {
private static TestContext textContext = null;
private WebDriver driver;
static ConfigFileReader configFileReader = new ConfigFileReader();
private static Logger log = LogManager.getLogger(TestContext.class.getName());
public static void main(String[] args)
{
log.debug("Debug Message Logged !!!");
log.info("Info Message Logged !!!");
log.error("Error Message Logged !!!");
}
In console when I ran it:
17:17:49.037 [main] ERROR Util.TestContext - Error Message Logged !!!
Properties file:
status = error
name = PropertiesConfig
#Make sure to change log file path as per your need
property.filename = C:/logs/debug.log
filters = threshold
filter.threshold.type = ThresholdFilter
filter.threshold.level = debug
appenders = rolling
appender.rolling.type = RollingFile
appender.rolling.name = RollingFile
appender.rolling.fileName = ${filename}
appender.rolling.filePattern = debug-backup-%d{MM-dd-yy-HH-mm-ss}-%i.log.gz
appender.rolling.layout.type = PatternLayout
appender.rolling.layout.pattern = %d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n
appender.rolling.policies.type = Policies
appender.rolling.policies.time.type = TimeBasedTriggeringPolicy
appender.rolling.policies.time.interval = 1
appender.rolling.policies.time.modulate = true
appender.rolling.policies.size.type = SizeBasedTriggeringPolicy
appender.rolling.policies.size.size=10MB
appender.rolling.strategy.type = DefaultRolloverStrategy
appender.rolling.strategy.max = 20
loggers = rolling
#Make sure to change the package structure as per your application
logger.rolling.name = com.howtodoinjava
logger.rolling.level = debug
logger.rolling.additivity = false
logger.rolling.appenderRef.rolling.ref = RollingFile
Where the configuration file: enter image description here
Dependencies:
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>2.14.1</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.14.1</version>
</dependency>
is it because it can not locate the properties file???