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

Provide utility to reset the Logback logging system #460

Closed
sleberknight opened this issue Feb 6, 2024 · 0 comments · Fixed by #468
Closed

Provide utility to reset the Logback logging system #460

sleberknight opened this issue Feb 6, 2024 · 0 comments · Fixed by #468
Labels
new feature A new feature such as a new class, method, package, group of classes, etc.
Milestone

Comments

@sleberknight
Copy link
Member

Provide a way to easily reset the Logback logging system, for example from an @AfterAll method:

@AfterAll
static void resetLogback() {
    LogbackTestHelpers.resetLogback();  // uses default logback-test.xml

    // could provide an overload too:
    LogbackTestHelpers.resetLogback("acme-special-logback-test.xml");
}

The final solution might not look like the above, i.e., the class name may be different, maybe we use instance methods instead of static, etc.

For more background see #457

@sleberknight sleberknight added the new feature A new feature such as a new class, method, package, group of classes, etc. label Feb 6, 2024
@sleberknight sleberknight changed the title Provide utility to reset the Lgoback logging system Provide utility to reset the Logback logging system Feb 6, 2024
@sleberknight sleberknight added this to the 3.3.0 milestone Feb 9, 2024
sleberknight added a commit that referenced this issue Feb 9, 2024
* Add LogbackTestHelpers utility class. This provides utilities
  to reset Logback.
* Add ResetLogbackLoggingExtension, a Jupiter extension to
   reset Logback after all tests have run.
* Add UncheckedJoranException, which wraps the checked
  Logback JoranException.
* Update several tests that use Dropwizard extensions to use
   ResetLogbackLoggingExtension to restore logging.

Closes #460
Closes #461
sleberknight added a commit that referenced this issue Feb 10, 2024
* Add LogbackTestHelpers utility class. This provides static
   utilities to reset Logback.
* Add LogbackTestHelper which mainly delegates to LogbackTestHelpers.
  It adds a new method, resetLogbackWithDefaultOrConfig, which removes
  the duplicate conditional logic in the InMemoryAppenderExtension and
  the ResetLogbackLoggingExtension. It also allows for mocking in
  tests of the Logback reset mechanisms and extensions.
* Add ResetLogbackLoggingExtension, a Jupiter extension to
   reset Logback after all tests have run.
* Add UncheckedJoranException, which wraps the checked
  Logback JoranException.
* Update several tests that use Dropwizard extensions to use
   ResetLogbackLoggingExtension to restore logging.
* Replace duplicate code in InMemoryAppenderExtension with
  call to LogbackTestHelpers#resetLogback

Misc cleanup:

* Make visibility of Dropwizard Configuration classes in
  several tests the same as the Application class
* Add test for InMemoryAppenderExtension.
* Add "clear-box" tests for InMemoryAppenderExtension#getAppender

Closes #460
Closes #461
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new feature A new feature such as a new class, method, package, group of classes, etc.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant