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

Test logging fix, by default log4j2 looks for log4j2.properties file #2181

Merged
merged 1 commit into from
Aug 30, 2024

Conversation

akatona84
Copy link
Contributor

log4j.properties files are ignored in the test resources, after renamed, finally I was able to change the loglevels while unit/integration testing.

I'm not sure if it was the issue on issue #2152, but this would be the fix for tests. Prod should work with the log4j.properties file as that is passed with -Dlog4j.configurationFile java opt

@akatona84
Copy link
Contributor Author

@mhratson could u take a look?
originally wanted to fix this along with logback exclusion, but then realized that is already merged, so only file renaming

@mhratson
Copy link
Contributor

@akatona84 can you please include before -> after outputs so i can reproduce myself?

Thanks.

@akatona84
Copy link
Contributor Author

without this pr, just on current main

  1. change the logger.kafka.level to degug in file cruise-control-metrics-reporter/src/test/resources/log4j.properties
  2. and then run
    ./gradlew :cruise-control-metrics-reporter:test --tests CruiseControlMetricsReporterTest.testReportingMetrics
  3. and check the
    cruise-control-metrics-reporter/build/test-results/test/TEST-com.linkedin.kafka.cruisecontrol.metricsreporter.CruiseControlMetricsReporterTest.xml
    file, it only contains error level messages
  4. now rename the cruise-control-metrics-reporter/src/test/resources/log4j.properties to cruise-control-metrics-reporter/src/test/resources/log4j2.properties
  5. run ./gradlew :cruise-control-metrics-reporter:test --tests CruiseControlMetricsReporterTest.testReportingMetrics again
  6. see all kinds of kafka logs in cruise-control-metrics-reporter/build/test-results/test/TEST-com.linkedin.kafka.cruisecontrol.metricsreporter.CruiseControlMetricsReporterTest.xml

@mhratson
Copy link
Contributor

Thanks for details, works:

Before

 grep -P ' [IEWD]' cruise-control-metrics-reporter/build/test-results/test/TEST-com.linkedin.kafka.cruisecontrol.metricsreporter.CruiseControlMetricsReporterTest.xml |cut -d' ' -f 3|sort|uniq -c
     25 ERROR
      1 <system-out><![CDATA[22:23:10.813

After

$ grep -P ' [IEWD]' cruise-control-metrics-reporter/build/test-results/test/TEST-com.linkedin.kafka.cruisecontrol.metricsreporter.CruiseControlMetricsReporterTest.xml |cut -d' ' -f 3|sort|uniq -c
   1093 DEBUG
      4 DEFAULT
    744 INFO
      1 <system-out><![CDATA[[2024-08-26
      4 WARN

@mhratson mhratson merged commit c5545ef into linkedin:main Aug 30, 2024
2 checks passed
@akatona84 akatona84 deleted the loggingfix branch September 6, 2024 08:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants