lu-xiaoshuang commented on issue #3442: URL: https://github.com/apache/logging-log4j2/issues/3442#issuecomment-2699866460
> [@lu-xiaoshuang](https://github.com/lu-xiaoshuang), in [#3482](https://github.com/apache/logging-log4j2/pull/3482), I see you randomly choose hosts to write to. Can't you simply define multiple socket appenders and choose them using [scripted routes](https://logging.apache.org/log4j/2.x/manual/appenders/delegating.html#RoutingAppender-example-script): > > <Configuration xmlns="https://logging.apache.org/xml/ns" > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" > xsi:schemaLocation=" > https://logging.apache.org/xml/ns > https://logging.apache.org/xml/ns/log4j-config-2.xsd"> > <Appenders> > <Routing name="ROUTING"> > <Script language="groovy"> > staticVariables.hosts = [ > 'h1.example.com', > 'h2.example.com', > 'h3.example.com' > ]; > staticVariables.random = new Random(); > </Script> > <Routes> > <Script language="groovy"> > int hostIndex = staticVariables.random.nextInt(staticVariables.hosts.length); > String host = staticVariables.hosts[hostIndex]; > return configuration.properties['host'] = host; > </Script> > <Route> > <Socket name="${host}" > protocol="TCP" > host="${host}" > port="500"> > <JsonTemplateLayout/> > </Socket> > </Route> > </Routes> > </Routing> > </Appenders> > <Loggers> > <Root level="INFO"> > <AppenderRef ref="ROUTING"/> > </Root> > </Loggers> > </Configuration> Thanks for your reply, @vy I'm afraid ```Routing``` is not an elegant way. It seems a little bit ugly instead. It would be great if the framework could hide the underlying complexity (i.e. transparent to users). I think offering a new ```SocketAppender``` (assuming ```SocketAppenderV2```) may be a possible solution. Because origin design of ```SocketAppender``` is not easy to support multiple sockets. When ```SocketAppenderV2``` is ready, users can migrate from old version to new version. At last, ```log4j``` can deprecate ```SocketAppender```. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: notifications-unsubscr...@logging.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org