You are correct in your assessment. The default route is the one that does not have a key. Naming a route “default” doesn’t make it the default. The value of the key is the value that is required for the route to match. Having the pattern and key be the same expression means it will always match, which makes the routing appender useless.
Ralph > On Jan 11, 2021, at 4:01 AM, Stamatis Zampetakis <zabe...@gmail.com> wrote: > > Hello, > > During code review I bump into a configuration (snippet below) for a > routing appender that seems wrong in various aspects. > > appender.query-routing.type = Routing > appender.query-routing.name = query-routing > appender.query-routing.routes.type = Routes > appender.query-routing.routes.pattern = $${ctx:queryId} > # purge policy > ... > # default route > appender.query-routing.routes.route-default.type = Route > appender.query-routing.routes.route-default.key = $${ctx:queryId} > appender.query-routing.routes.route-default.ref = RFA > # queryId based route > appender.query-routing.routes.route-mdc.type = Route > appender.query-routing.routes.route-mdc.file-mdc.type = RandomAccessFile > appender.query-routing.routes.route-mdc.file-mdc.name = query-file-appender > ... > > I've never used the routing appender before so I would be grateful if > somebody could verify the findings below. > > First, the naming pattern (and comment) indicating that the first route > (route-default) is the default one seems to be wrong. > Based on the documentation [1], if there is no key definition for a route > then that one is the default; so in this case the second route seems to be > the default and not the first one. > > The lookup based key definition in the first route seems to be useless. > Although not explicitly stated in the doc [1] from the code it seems that > only static literals (not lookups) are supported in route keys. > > All in all, at the current state the route-default seems to be useless and > I suppose can be removed. > > Best, > Stamatis > > [1] > https://logging.apache.org/log4j/2.x/manual/appenders.html#RoutingAppender --------------------------------------------------------------------- To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org For additional commands, e-mail: log4j-user-h...@logging.apache.org