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

print custom log message during an automated test #205

Closed
jaymiller455 opened this issue Apr 21, 2021 · 3 comments
Closed

print custom log message during an automated test #205

jaymiller455 opened this issue Apr 21, 2021 · 3 comments
Assignees
Labels

Comments

@jaymiller455
Copy link

jaymiller455 commented Apr 21, 2021

Thank you for your awesome plugin, but I am stuck and new at this. How can I see custom log messages I print during an automated test? Sometimes we need to know specific variable values at different moments of an automated test. I enabled as many settings in gradle-test-logger-plugin as I knew how (version 3.0.0). I even tried adding a log4j2.yaml file to the project as a last ditch effort for org.apache.logging.log4j.LogManager and org.apache.logging.log4j.Logger.

Currently, in our Kotlin/Java project within Intellij IDE, I can see log output in the console using something like:

import org.apache.log4j.LogManager

private val logger = Logger.getLogger(this::class.java.simpleName)
logger.info("log message to show during my automated test")

But when I view the logs on Bamboo, those "logger.info" strings are never printed, only your PASS / FAIL lines. I'm okay with it printed after a test passes or fails, since your plugin formats/prints output after gradle finishes a test. Do you have any suggestions? Thank you in advance. The testlogger settings I am using are:

testlogger {
    theme 'standard-parallel'
    showExceptions true
    showStackTraces true
    showFullStackTraces true
    showCauses true
    slowThreshold 2000
    showSummary true
    showSimpleNames false
    showPassed true
    showSkipped true
    showFailed true
    showStandardStreams true
    showPassedStandardStreams true
    showSkippedStandardStreams true
    showFailedStandardStreams true
    logLevel 'lifecycle'
}

Gradle Version: 6.8.3

@radarsh
Copy link
Owner

radarsh commented Apr 21, 2021

The showStandardStreams should do the trick. If that's not working for you, I'd start comparing with what you get with Gradle without this plug-in applied.

@jaymiller455
Copy link
Author

Thank you, your guidance of checking gradle instead of the plugin helped me get closer. I was using

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

but actually needed to be using

import java.util.logging.Level
import java.util.logging.Logger
import java.util.logging.Logger.getLogger

private val logger: Logger = getLogger(this::class.java.simpleName)

logger.info("This shows in the logs")
logger.log(Level.INFO, "This also shows in the logs")

Related question -- in version 3.0.0 is says "Implemented enhancements: Display start of the test #165"...was that feature added / how to use it?

@radarsh
Copy link
Owner

radarsh commented May 25, 2021

@jaymiller455 Unfortunately no. I should probably tweak the changelog generator I use to not mark issues that were closed without resolution as "Implemented enhancements". Anyway, see related comment:

#100 (comment)

@radarsh radarsh closed this as completed May 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants