Open TripleG opened 6 months ago
Hey, maybe the same issue as described here: https://github.com/extent-framework/extentreports-java/issues/293?
Hi All,
I've investigated the issue reported in comment1 and have some insights to share:
The code responsible for generating the log timestamp is located in the Log.java
file within the package com.aventstack.extentreports.model
. Unfortunately, this code is not directly modifiable:
private Date timestamp = Calendar.getInstance().getTime();
However, there's a way to adjust the format of the log timestamp by modifying the log.ftl
file found in the templates
directory. Here's how you can proceed:
File Path: src\main\resources\com\aventstack\extentreports\templates\spark\macros\log.ftl
Log.ftl:
<td>${log.timestamp?time?string}</td>
After change:
To change the format to "hh:mm:ss.SSS a", replace it as follows:
<td>${log.timestamp?time?string("format")}</td>
This is my hypothesis after modification will update the format in which the timestamp is displayed in the logs.
I will test and update everything in the next comment. Thanks, Kamalesh.
Hi @TripleG,
I have made changes to the code and found that my earlier hypothesis was correct. Here is a screenshot of the results.
Here is the screenshot of how it looks without changing the CSS values.
After the change:
I have two methods; one is hardcoded and the other method involves creating a variable in the package com.aventstack.extentreports.reporter.configuration
and a file named AbstractConfiguration
.
The First Method is shown above comment.
Second Method:
Create a variable on the package com.aventstack.extentreports.reporter.configuration
and a file named AbstractConfiguration
.
@Builder.Default
private String timeFormat = "hh:mm:ss a";
and you have to change it in these files also.
src/main/resources/com/aventstack/extentreports/templates/commons/commons-variables.ftl
add the below code inside the <#assign>
tag. timeFormat=config.timeFormat
src/main/resources/com/aventstack/extentreports/templates/spark/macros/log.ftl
please modify the below code to:<td>${log.timestamp?time?string["${timeFormat}"]}</td>
But I discovered why the owner kept the format as default format - it looks neat and clean.
@anshooarora could you please confirm this issue, so that the issue can be closed?
Thanks,
Kamalesh.
I want to change the format of the
TIMESTAMP
field to include milliseconds as well. I triedBut the timestamp format does not change:
Am I using the correct setting?