In Log4j 1.2 a Category was the base class for a Logger. So this would simply 
looking for all the Appenders attached to the Logger. If a Category/Logger has 
Appenders then it searches the parent hierarchy until it finds one. Note that 
if it finds one if the Logger is configured as additive (the default) then the 
event will 
also be passed to the Logger’s parents. 

I haven’t looked at the code recently but I’d bet getAllAppenders only returns 
Appenders directly attached to the Logger/Category.


> On Aug 23, 2022, at 1:15 PM, Joel Griffith <> wrote:
> I'm still trying to parse some Log4j v1 code for the update, and I hit
> something I can't find.
> The docs here:
> say that the Logger.getAllAppenders() method "Get[s] the appenders
> contained in this category as an Enumeration."  There is no definition of
> what it means for an appender to be "contained in" a category, however, so
> I'm unable to predict exactly what the method will return.
> As precisely as possible, what defines the set of appenders that are
> "contained in" a category like a logger?  In particular, does a child
> logger contain appenders assigned to its parent?  Does a parent logger
> contain appenders assigned to its child?
> Thanks,
> Joel
> On Tue, Aug 16, 2022 at 3:37 AM Markus Dimmerling <>
> wrote:
>>> As for delaying creating the file, that can be accomplished just by
>> specifying createOnDemand=“true”.
>> Keep in mind, that this is not true for parent folders. Parent folders
>> will be created on initialization even before createOnDemand. (At least for
>> RollingFileAppenders)
>> This was my workaround for that issue: A RoutingAppender wrapping the
>> RollingFileAppender and routing all logging to null until the value is not
>> empty anymore.
>> <Routing name="parent-folder-route">
>>  <Routes pattern="$${ctx:parent.folder}">
>>    <Route key="$${ctx:parent.folder}">
>>      <Null name="dontlog"/>
>>    </Route>
>>    <Route>
>>      <RollingFile name="logger"
>>                   fileName="${ctx: parent.folder}/Logging.log"
>>                   filePattern="${ctx: parent.folder}/Logging.log.%i"
>>                   createOnDemand="true">
>>        ...
>>      </RollingFile>
>>    </Route>
>>  </Routes>
>> </Routing>

To unsubscribe, e-mail:
For additional commands, e-mail:

Reply via email to