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

MaxListenersExceededWarning when adding loggers dynamically #886

Closed
andymel123 opened this issue May 27, 2019 · 2 comments · Fixed by #1110
Closed

MaxListenersExceededWarning when adding loggers dynamically #886

andymel123 opened this issue May 27, 2019 · 2 comments · Fixed by #1110
Milestone

Comments

@andymel123
Copy link

Hi,

I append loggers dynamically with the solution posted here.

The problem with that. With each added logger, file.js adds a 'SIGHUP' listener to process.
process.on('SIGHUP', app.sighupHandler);

Is there a way to tell log4js when I am finished with the specific logger? So that it can remove the listener again? The shutdown function on log4js would shutdown all appenders I guess.

My current workaround (typescript) just removes the listener after it's added. But that's just fighting a symptom of a bigger problem.
process.addListener("newListener", (type, listener) => {...removing that listener again...}

log4js version "^4.3.0"

@nomiddlename
Copy link
Collaborator

I commented on the other issue #437, but I'll comment here as well in case other people are searching for the same thing. You can use the timeout parameter of the multiFile appender to close the underlying file appenders when they have not been used for a while. That may fix your problem.

The real issue is that each file appender adds its own SIGHUP handler when they could all use the same one. See also #852

@lamweili
Copy link
Contributor

This has been patched and should be closed together with #852 once the PR #1110 is approved.

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 a pull request may close this issue.

3 participants