Re: loggerConfig.getAppenderRefs().clear()

2020-03-25 Thread Doug Wegscheid
also, would a FailoverAppender with the external appender being the primary be a solution? On Wednesday, March 25, 2020, 10:58:16 AM EDT, EDMONDO SENA wrote: 1)  Do the external appenders come and go, or do we know ahead of time if they are available? No, come and go! 2)  Would a R

Re: loggerConfig.getAppenderRefs().clear()

2020-03-25 Thread Doug Wegscheid
Matt, thanks for chiming in. I was running some test cases, and I saw that exact behaviour: lost messages when doing the ctx.update(). On Wednesday, March 25, 2020, 10:58:17 AM EDT, Matt Sicker wrote: Appenders shouldn't be directly modified like that as it would lead to a loss of lo

Re: loggerConfig.getAppenderRefs().clear()

2020-03-25 Thread Doug Wegscheid
Matt's suggestion works. You can make a routing appender that will switch between appenders under program control. Example of something that switches between two different ConsoleAppenders Configuration:

Re: loggerConfig.getAppenderRefs().clear()

2020-03-25 Thread Ralph Goers
Are you saying that you are sending the events to one location and want to reconfigure to send them to another location? The only safe way to do that without losing logging events is to reconfigure - i.e. create a new configuration that replaces the prior configuration. To do what you are askin

Re: loggerConfig.getAppenderRefs().clear()

2020-03-25 Thread EDMONDO SENA
we need only remove all appenders because not necessary in that case. On 2020/03/25 15:03:26, Matt Sicker wrote: > Take a look at this: > https://logging.apache.org/log4j/2.x/manual/appenders.html#RoutingAppender > > This appender is extremely flexible for that use case. I'd recommend > avoid

Re: loggerConfig.getAppenderRefs().clear()

2020-03-25 Thread Matt Sicker
Take a look at this: https://logging.apache.org/log4j/2.x/manual/appenders.html#RoutingAppender This appender is extremely flexible for that use case. I'd recommend avoiding the use of an inline script (JavaScript or Groovy) unless absolutely necessary as that's likely the slowest routing mechanis

Re: loggerConfig.getAppenderRefs().clear()

2020-03-25 Thread Matt Sicker
Appenders shouldn't be directly modified like that as it would lead to a loss of log events during that operation. The appropriate ways to programmatically initialize configuration is documented here: https://logging.apache.org/log4j/2.x/manual/customconfig.html#Configurator On Wed, 25 Mar 2020 at

Re: loggerConfig.getAppenderRefs().clear()

2020-03-25 Thread EDMONDO SENA
1) Do the external appenders come and go, or do we know ahead of time if they are available? No, come and go! 2) Would a RoutingAppender() that knows if external or internal logging is to be done and then routes messages to the appropriate appender a solution? More or less yes. On 2020/03

Re: loggerConfig.getAppenderRefs().clear()

2020-03-25 Thread Doug Wegscheid
ah. a couple of solutions present themself (and hopefully someone more conversant with log4j4 can chime in). Would a RoutingAppender() that knows if external or internal logging is to be done and then routes messages to the appropriate appender a solution? Do the external appenders come and go,

Re: loggerConfig.getAppenderRefs().clear()

2020-03-25 Thread EDMONDO SENA
Can you explain me this behaviour? Map appenders = config.getAppenders(); appenders.clear();*** WORKING *** Map loggers = config.getLoggers(); loggers.clear();*** GOES IN EXCEPTION DOESN'T WORK!! On 2020/03/25 14:41:30, EDMONDO SENA wrote: > In order to disable loc

Re: loggerConfig.getAppenderRefs().clear()

2020-03-25 Thread EDMONDO SENA
In order to disable local logging when the external logging is enabled. So, remove all local appenders and disable local logging for re-enabling the delivery towards another system to run-time. On 2020/03/25 14:29:26, Doug Wegscheid wrote: > upon examination, I see that clearAppenders() is no

Re: loggerConfig.getAppenderRefs().clear()

2020-03-25 Thread Doug Wegscheid
upon examination, I see that clearAppenders() is not public, so that won't work. There is probably a way to do what you want, if you can tell us why you need to clear the appenders. On Wednesday, March 25, 2020, 10:23:38 AM EDT, EDMONDO SENA wrote: Can you explain me how can i do it

Re: loggerConfig.getAppenderRefs().clear()

2020-03-25 Thread EDMONDO SENA
Can you explain me how can i do it? Regards. On 2020/03/25 14:18:03, Doug Wegscheid wrote: > you are trying to clear the list of appenderRefs. Are you trying to call > clearAppenders() instead of clear()? > > On Wednesday, March 25, 2020, 10:03:27 AM EDT, EDMONDO SENA > wrote: >

Re: loggerConfig.getAppenderRefs().clear()

2020-03-25 Thread Doug Wegscheid
you are trying to clear the list of appenderRefs. Are you trying to call clearAppenders() instead of clear()? On Wednesday, March 25, 2020, 10:03:27 AM EDT, EDMONDO SENA wrote: Why this instruction goes in UnsupportedOperationException? List value = loggerConfig.getAppenderRefs(); v