Skip to content

LoggingApplicationListener calls loggingSystem.cleanUp() after nested context was destroyed #4651

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

Closed
toughpheeckouse opened this issue Dec 1, 2015 · 5 comments
Assignees
Labels
type: bug A general bug
Milestone

Comments

@toughpheeckouse
Copy link

Is it right way to cleanUp loggingSystem after nested context was destroyed?

I have next code:

migrationContext = new AnnotationConfigApplicationContext();

migrationContext.setParent(applicationContext);

.../*(some actions in migrationContext */

migrationContext.destroy(); // sends ContextClosedEvent to LoggingApplicationListener `

After that I can't get log messages from JUL.

What I'm doing wrong? Is it bug in LoggingApplicationListener or I use wrong way to create nested context?

As workaround - do not send ContextClosedEvent by nested context:

migrationContext = new AnnotationConfigApplicationContext()
{
    @Override
    public void publishEvent(ApplicationEvent event)
    {
        if (!(event instanceof ContextClosedEvent))
        {
            super.publishEvent(event);
        }
    }
};
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Dec 1, 2015
@wilkinsona
Copy link
Member

As described in the guidelines for contributing, we prefer to use GitHub issues only for bugs and enhancements. For general usage questions, please use StackOverflow

@wilkinsona wilkinsona added for: stackoverflow A question that's better suited to stackoverflow.com and removed status: waiting-for-triage An issue we've not yet triaged labels Dec 1, 2015
@toughpheeckouse
Copy link
Author

But it seems to be a bug or not?

@wilkinsona
Copy link
Member

Sorry, but I can tell from your description. For example, you haven't described the lifecycle of the nested context in relation to its parent or exactly what it is you're trying to do.

@toughpheeckouse
Copy link
Author

lifecycle of the nested context is described in code block

it is just created and after some action (I think it's no matter what exact action) it is destroyed.
when nested context is destroyed it sends event ContextClosedEvent
which handled by LoggingApplicationListener.
and this listener does not look from what context this event has been sent and calls loggingSystem.cleanUp() where SLF4JBridgeHandler is uninstalled.

I think this is a bug - the SLF4JBridgeHandler is installed for parent context not for nested, but uninstalled when nested context is destroyed.

Sorry, for confused explanation

@wilkinsona
Copy link
Member

That's much clearer now, thank you.

@wilkinsona wilkinsona removed the for: stackoverflow A question that's better suited to stackoverflow.com label Dec 1, 2015
@wilkinsona wilkinsona reopened this Dec 1, 2015
@wilkinsona wilkinsona added the for: team-attention An issue we'd like other members of the team to review label Dec 1, 2015
@philwebb philwebb added this to the 1.2.8 milestone Dec 2, 2015
@wilkinsona wilkinsona added type: bug A general bug and removed for: team-attention An issue we'd like other members of the team to review labels Dec 2, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug A general bug
Projects
None yet
Development

No branches or pull requests

4 participants