[logback-dev] tracking receivers?
ceharris at vt.edu
Mon Apr 22 12:05:23 CEST 2013
> Does it make sense to track receivers? For example, we probably do not want to create the same receiver multiple times upon reconfiguration. Is such tracking currently performed some place? If not I would propose a RECEIVER bag similar to the appenderBag. See use of ActionConst.APPENDER_BAG.
Yes, it makes sense to track them.
My understanding of both LoggerContext.stop and LoggerContext.reset was apparently a bit muddled.
Seems like there are two possible approaches to dealing with receivers during (re-)configuration:
1. In LoggerContext.reset, we could stop() all of the receivers in the bag. Stopping the receiver closes all open connections, and in the case of a passive receiver also closes the listening ServerSocket. If the receiver were stopped during a reset, it would be okay to recreate it. It may be also be desirable to use ServerSocket.setReuseAddress to ensure that the local address for a passive receiver can be re-bound.
2. We could add a name attribute to the receiver and in ReceiverAction.begin, we could check the bag to see if a receiver of the same name has already been created. If a receiver with the same name has already been created, we would not create it again, and in ReceiverAction.end, we would not invoke the existing receiver's start method.
In either case, in order for the receivers to be cleaned up properly, we will need to stop all of the receivers in the bag. If we choose option 2, we will still need to modify LoggerContext.stop so that it stops all receivers in the bag.
Comments or alternatives?
More information about the logback-dev