Hi
I am doing the web application testing. Is there anyways to reduce the log details to display the message and date only, and how to set the date without T and z
I have tried to change the logback.xml but it is still the same (have t and z on the date)
No. You can not customize the format of the <katalon project>/Reports/yyyymmdd_hhMMss/tsName/yyyymmdd_hhMMss/execution0.log file.
The <record> in the execution0.log file contains this:
This implies that the execution0.log file is written by com.kms.katalon.core.logging.XmlKeywordLogger class.
You can read the source code of this class in <Katalon Studio installed directory>/Contents/Eclipse/configuration/resources/source/com.kms.katalon.core/com.kms.katalon.core-sources.jar. The line#78 looks as:
So the com.kms.katalon.core.logging.CustomXmlFormatter class determines how each LogRecords are formatted into XML string representation. You can read the source of the CustomXmlFormatter class as well.
If you read the source, you can find that the com.kms.katalon.core.logging.CustomXmlFormatter class uses the java.util.logging package, not the logback.
I made a simple Test Case script that mimics how the CustomXmlFormatter class utilizes the java.util.logging package:
import java.util.logging.Level
import java.util.logging.LogRecord
import java.util.logging.XMLFormatter
LogRecord logRecord = new LogRecord(Level.INFO, "Merry Christmas!")
String formattedText = new XMLFormatter().format(logRecord)
println formattedText
You can copy & paste this test case script into your Katalon Studio and run it.
When I ran this, I got the following output in the console:
2024-12-23 18:00:17.605 INFO c.k.katalon.core.main.TestCaseExecutor - --------------------
2024-12-23 18:00:17.608 INFO c.k.katalon.core.main.TestCaseExecutor - START Test Cases/testJavaUtilLoggingClasses
<record>
<date>2024-12-23T09:00:18.116037Z</date>
<millis>1734944418116</millis>
<nanos>37000</nanos>
<sequence>3</sequence>
<level>INFO</level>
<thread>1</thread>
<message>Merry Christmas!</message>
</record>
2024-12-23 18:00:18.186 INFO c.k.katalon.core.main.TestCaseExecutor - END Test Cases/testJavaUtilLoggingClasses
The CustomXmlFormatter class uses the bare java.util.logging.XMLFormatter.format() method without any customization.
Please find the <date> element has a content text 2024-12-23T09:00:18.116037Z. This is exactly the same as the text found in the execution0.log. The date text contains T and Z, which @testlms21102024 wants to erase.
However, Katalon Studio provides no way for @testlms21102024 to customize the CustomXmlFormatter. Please, don’t ask me why.
Katalon Studio uses the java.util.logging package to write logs into the execution0.log file in the Reports folder, which is used as the source to compile the reports in HTML format, etc.
Also, Katalon Studio uses the logback to write logs into the console tab in the Katalon Studio GUI.
I don’t know why Katalon Studio uses these 2 logging frameworks intermixed.
Hi @kazurayam, is there any way to configure the Katalon report to be generated before running the log filter test cases, after the main test cases in the same test suite?
For example, test case A is the main test case, and test case B is the log filter test case. When I put them in the same test suite for a seamless process, I use a test listener to get the latest folder timestamp to use as the path to the log. However, I encounter an issue where the log and all reports are created at the end of the test suite execution. Therefore, there won’t be any execution.log file in the report folder before the test suite execution ends.
You can see that the execution0.log file created by this Test Case is found in a location under the temporary directory that Java Runtime Environment manages. But the exact folder location of exectuion0.log does not matter much to you, as you can retrieve the location and you can read the file, as this sample code does.
I noticed that the content of execution0.log was incomplete in that it does not contain the <record> of the very last Groovy statement
println content.
Also you should note that the content of the observed execution0.log is a mal-formed XML. It misses a closing </log> tag.
I think that the monitorReportFolder does something brutal. But @testlms21102024 may find it applicable to his case.