ahmednawras/log4erl

log4erl hangs on application:stop(log4erl).

Closed this issue · 12 comments

Haven't you met such a problem?

We haven't met this problem, though we call application:stop(log4erl) as part of our normal application shutdown (which happens many time per day, as per our integration tests).

Using: log4erl master, file and console appenders + one custom appender.
Running on: R13B01, ERTS 5.7.2, Ubuntu Karmic.

Hi maxlapshin,

I'm not sure I understand you complain here. Is this something you face a lot? Is there an error message you get for example? Can you please provide a sample code? I use log4erl a lot with different OSes (Solaris, linux, win) and don't recall a time when I faced such an issue.

So, it seems, that I don't understand where to put application:stop(log4erl). =(

I call application:start(log4erl) in ems_app:start/2 callback and call application:stop(log4erl) in ems_app:stop/1 callback. Am I doing wrong?

Yes, I've found: it is my fail, I shouldn't stop log4erl from stop/1 callback of main application.

Hi maxlapshin,

That's what I normally do, call application:stop(log4erl) from my applications's stop function. Can you please explain what is the cause of failure in your side and how it was resolved?

Ahmed

http://github.com/erlyvideo/erlyvideo/commit/bb69a955491e32f462985f6517d56bc12f3dce47

I had to move application:stop(log4erl) from ems_app.erl (application handler) to ems.erl (generic module) and hangs disappeared.

Perfect. I will close this case now.

And what is the problem? I have the same hang with my erlang-rtmp application/library

Hi maxlapshin,

I reopened this case again. I'm not sure of the exact reason for the hangs but below you can find my analysis.

I've done a quick review for ems.erl, ems_app.erl and ems_log.erl and found out that you start log4erl and stop it in different modules. Also, I could see in some modules you stop and unload log4erl (ems.erl) and in other you just stop it (ems_log.erl). I suspect this is due to the issue of log4erl hanging.

I suggest you add application:start(log4erl) and application:stop(log4erl) in the same module only and delete the rest. Also, make sure you start before any other log4erl dependant code and stop after it. My initial guess is that this place is ems_log.erl, unless you're using log4erl logging before you actually initialize ems_log.erl module.

I don't normally use application:unload/1 but you may have your own reasoning for using it. If you opt to using it, I'd recommend you also add application:load/1 before application:start/1 just in case.

Please try it again and let me know if you still have problems.

Ahmed

Yes, I will try of course, thank you for review.

Closing

Yes, close it, thank you again for help.