Re: removeAllAppenders() Log4j2

2020-03-25 Thread EDMONDO SENA
I told you repeatedly that for internal library I means: log4j.logger.org.apache.http=ERROR log4j.logger.org.apache.http.wire=ERROR log4j.logger.org.apache.http.impl.conn=ERROR log4j.logger.org.apache.http.impl.client=ERROR log4j.logger.org.apache.http.client=ERROR # SFTP server log

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

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

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

Re: removeAllAppenders() Log4j2

2020-03-25 Thread Ralph Goers
If you want to clear all the appenders it is far more likely you want to perform a shutdown. If that is the case just call the shutdown method on LogManager. If all you are trying to do is copy the logic you had to customize Log4j 1 to Log4j 2 I am NOT going to help you with that. I have told

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 >

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

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

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

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

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

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

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();

Re: removeAllAppenders() Log4j2

2020-03-25 Thread EDMONDO SENA
How? That being said, you are welcome to try the #clearAppenders(). On 2020/03/25 13:21:25, Doug Wegscheid wrote: > I understand that, but am trying to help you find a solution that works with > 2.x. > While your code removed all the appenders in 1,x, that might not be necessary > under

loggerConfig.getAppenderRefs().clear()

2020-03-25 Thread EDMONDO SENA
Why this instruction goes in UnsupportedOperationException? List value = loggerConfig.getAppenderRefs(); value.clear(); - To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org For additional commands, e-mail:

Re: removeAllAppenders() Log4j2

2020-03-25 Thread Doug Wegscheid
I understand that, but am trying to help you find a solution that works with 2.x. While your code removed all the appenders in 1,x, that might not be necessary under 2.x, but I can't help you with that if you don't share more information about why the appenders need to be removed. If you share

Re: removeAllAppenders() Log4j2

2020-03-25 Thread EDMONDO SENA
Sorry but my question is: Is possible to use in some way removeAllAppenders? Why this instruction has been deleted? On 2020/03/25 13:14:52, Doug Wegscheid wrote: > why do you need to remove all appenders? what happens if you do not? > > On Wednesday, March 25, 2020, 9:12:45 AM EDT,

Re: removeAllAppenders() Log4j2

2020-03-25 Thread Doug Wegscheid
why do you need to remove all appenders? what happens if you do not? On Wednesday, March 25, 2020, 9:12:45 AM EDT, EDMONDO SENA wrote: When you close or switch off our system we've to remove all appenders. In log4j this instruction was possible! On 2020/03/25 12:59:30, Doug

Re: removeAllAppenders() Log4j2

2020-03-25 Thread EDMONDO SENA
When you close or switch off our system we've to remove all appenders. In log4j this instruction was possible! On 2020/03/25 12:59:30, Doug Wegscheid wrote: > However: from > https://logging.apache.org/log4j/log4j-2.1/manual/configuration.html: > | Note that unlike Log4j 1.x, the public

Re: removeAllAppenders() Log4j2

2020-03-25 Thread Doug Wegscheid
Are you looking at clearAppenders()? On Wednesday, March 25, 2020, 8:56:57 AM EDT, EDMONDO SENA wrote: I think It removes the appender single by single not all in one instruction! On 2020/03/25 12:46:19, Doug Wegscheid wrote: >  I googled for "log4j2 remove all appenders" and

Re: removeAllAppenders() Log4j2

2020-03-25 Thread Doug Wegscheid
However: from https://logging.apache.org/log4j/log4j-2.1/manual/configuration.html: | Note that unlike Log4j 1.x, the public Log4j 2 API does not expose methods to add, modify or remove appenders and filters or manipulate the configuration in any way. *Why* do you need to remove the

Re: removeAllAppenders() Log4j2

2020-03-25 Thread EDMONDO SENA
I think It removes the appender single by single not all in one instruction! On 2020/03/25 12:46:19, Doug Wegscheid wrote: > I googled for "log4j2 remove all appenders" and found this: > How to remove appender from logger in log4j2 programmatically? > > | > | > | > | | | > > | > >

Re: removeAllAppenders() Log4j2

2020-03-25 Thread Doug Wegscheid
I googled for "log4j2 remove all appenders" and found this: How to remove appender from logger in log4j2 programmatically? | | | | | | | | | | | How to remove appender from logger in log4j2 programmatically? Is there any way I can remove appender from a logger in log4j2

removeAllAppenders() Log4j2

2020-03-25 Thread EDMONDO SENA
Hello, Is there a similar functionality for Log4j2 that remove All appenders for Loggers? Kind regards. - To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org For additional commands, e-mail: