Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Attach Test ScreenShots to Logs in reportportal Using TestNG and Log4j2 With java getting error #1829

Closed
sharathhatter1 opened this issue Aug 30, 2022 · 4 comments
Labels
bug Bug in ReportPortal

Comments

@sharathhatter1
Copy link

sharathhatter1 commented Aug 30, 2022

Attach Test ScreenShots to Logs in reportportal Using TestNG and Log4j2 With java getting error

On the console - " [INFO ] 2022-08-30 13:39:30.541 [Test worker] CoreLogger - com.epam.reportportal.message.ReportPortalMessage@1d0305fb"

image

Versions:

  • Windows, chrome
  • Version of RP- implementation 'com.epam.reportportal:logger-java-log4j:5.1.3'

code -

protected void takeScreenshot(WebDriver driver, String methodName) {
        ReportPortalMessage message = null;
        TakesScreenshot scrShot = ((TakesScreenshot) driver);
        File fileSourceFile = scrShot.getScreenshotAs(OutputType.FILE);
        logger.info("Inside screenshot method");
        String strDirectory = System.getProperty("user.dir");
        File fileDestinationFile = new File(strDirectory + "/test-outputs/Screenshots/" + methodName + ".jpg");
        try {
            FileUtils.copyFile(fileSourceFile, fileDestinationFile);
            String rp_message = "test message for ReportPortal";
            message = new ReportPortalMessage(fileSourceFile, rp_message);
        } catch (IOException e) {
            e.printStackTrace();
        }
        logger.info(message);
    }
@sharathhatter1 sharathhatter1 added the bug Bug in ReportPortal label Aug 30, 2022
@HardNorth
Copy link
Member

@sharathhatter1 I don't see any error messages. Please provide more details.

@sharathhatter1
Copy link
Author

sharathhatter1 commented Aug 30, 2022

@HardNorth I am not seeing the error.

But I donot see my logs in the reportportal io

I have added below prop in the log4j properties file

Send logs into Report Portal

rootLogger = INFO, reportportal
appender.reportportal=com.epam.ta.reportportal.log4j.appender.ReportPortalAppender
appender.reportportal.layout=org.apache.log4j.PatternLayout
appender.reportportal.layout.ConversionPattern=[%d{HH:mm:ss}] %-5p (%F:%L) - %m%n

Log4j Dependency - 2.17.2

Only errors are showing in the report porter, rest of the logs are not shown. Im trying to attach screenshot also and not seeing it.

image

image

@HardNorth
Copy link
Member

HardNorth commented Aug 30, 2022

@sharathhatter1 You are using Log4j 1.x.x configuration file format to configure Log4j 2.17.2. It won't work, they are incompatible.

Please read carefully our configuration guide: https://github.com/reportportal/logger-java-log4j#configuration---log4j2

@DzmitryHumianiuk
Copy link
Member

@sharathhatter1 and make sure this file size is less then 16mb.
it's a default configuration for this request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Bug in ReportPortal
Projects
None yet
Development

No branches or pull requests

3 participants