Search code examples
qaf

How to set log level in QAF / Qmetry framework?


I would like to reduce the log level displayed in the console during my automation run in QAF / QMetry framework. When I tried playing around in log4j.properties, it is not showing any difference in the console logging. Tried following in log4j.properties:

log4j.logger.com.qmetry.qaf=ERROR
log4j.rootCategory=off

# CONSOLE is set to be a ConsoleAppender using a PatternLayout.
log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
log4j.appender.CONSOLE.Threshold=ERROR
log4j.appender.CONSOLE.Follow=false

Note: Not seeing any ws.log file created as mentioned in the below property


log4j.logger.com.qmetry.qaf.automation.ws=DEBUG, file
log4j.appender.file=org.apache.log4j.RollingFileAppender
log4j.appender.file.file=${outputDir}/ws.log
log4j.appender.file.MaxFileSize=1GB
log4j.appender.file.MaxBackupIndex=10
log4j.appender.file.layout=org.apache.log4j.PatternLayout
log4j.appender.file.layout.conversionPattern=%d{[dd.MM.yyyy] [HH:mm:ss]} %p [%t] %c (%F:%L) - %m%n

Log4j is set in the Maven config: (I have also tried putting the log4j config in the src folder).

<plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.9</version>
                <configuration>
                    <suiteXmlFiles>
                        <suiteXmlFile>${testSuiteFile}</suiteXmlFile>
                    </suiteXmlFiles>
                    <reportsDirectory>${test.results.dir}/${run.time}</reportsDirectory>
                    <systemPropertyVariables>
                        <org.uncommons.reportng.xml-dialect>testng</org.uncommons.reportng.xml-dialect>
                        <org.uncommons.reportng.escape-output>false</org.uncommons.reportng.escape-output>
                        <log4j.configuration>file:///${resource.dir}/log4j.properties</log4j.configuration>
                        <outputDir>${output.dir}</outputDir>
                        <test.results.dir>${output.dir}/html</test.results.dir>
                        <json.report.root.dir>${test.results.dir}</json.report.root.dir>
                        <json.report.dir>${output.dir}/json</json.report.dir>
                        <selenium.screenshots.dir>${output.dir}/img</selenium.screenshots.dir>
                        <selenium.screenshots.relative.path>../img</selenium.screenshots.relative.path>
</systemPropertyVariables>
</configuration>
</plugin>

Solution

  • You need to set log4j properties file location. Refer sample ant or maven project. If you are not familiar, easiest way is to move log4j.properties file under src directory.