The latest version: $LATEST_VERSION. Please use Maven Central
link above to get the library.
To start using Report Portal log appending you need to include this library into your project dependencies according to your build system.
Add this section into <dependecies>
section:
<dependency>
<groupId>com.epam.reportportal</groupId>
<artifactId>logger-java-logback</artifactId>
<version>$LATEST_VERSION</version>
<scope>test</scope>
</dependency>
Add this line into dependecies
block:
testImplementation 'com.epam.reportportal:logger-java-logback:$LATEST_VERSION'
Add a report portal appender into logback.xml
configuration file.
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<appender name="ReportPortalAppender" class="com.epam.reportportal.logback.appender.ReportPortalAppender">
<encoder>
<pattern>%d{HH:mm:ss.SSS} [%t] %-5level - %msg%n</pattern>
</encoder>
</appender>
<root>
<appender-ref ref="ReportPortalAppender"/>
</root>
</configuration>
For logback it is possible to attach binary data to the file only by adding to the log message additional text information.
In this case a log message should have next format:
RP_MESSAGE#FILE#FILENAME#MESSAGE_TEST
RP_MESSAGE#BASE64#BASE_64_REPRESENTATION#MESSAGE_TEST
RP_MESSAGE - message header
FILE, BASE64 - attaching data representation type
FILENAME, BASE_64_REPRESENTATION - path to sending file/ base64 representation of sending data
MESSAGE_TEST - string log message
Example:
public class Test {
private static final String JSON_FILE_PATH = "files/file.json";
@Test
public void logJsonBase64() {
/* here we are logging some binary data as BASE64 string */
LOGGER.info(
"RP_MESSAGE#BASE64#{}#{}",
BaseEncoding.base64().encode(Resources.asByteSource(Resources.getResource(JSON_FILE_PATH)).read()),
"I'm logging content via BASE64"
);
}
@Test
public void logJsonFile() {
/* here we are logging some binary data as file (useful for selenium) */
File file = File.createTempFile("rp-test", ".json");
Resources.asByteSource(Resources.getResource(JSON_FILE_PATH)).copyTo(Files.asByteSink(file));
LOGGER.info("RP_MESSAGE#FILE#{}#{}", file.getAbsolutePath(), "I'm logging content via temp file");
}
}
There is a client parameter into reportportal.properties
with boolean
type value for screenshots sending
in grayscale
or color
view. By default, it is set as true
and all pictures for Report Portal will be in grayscale
format.
reportportal.properties
rp.convertimage=true
Possible values:
true
- all images will be converted intograyscale
false
- all images will be ascolor