removeAllAppenders() Log4j2

classic Classic list List threaded Threaded
12 messages Options
Reply | Threaded
Open this post in threaded view
|

removeAllAppenders() Log4j2

EDMONDO SENA
Hello,

Is there a similar functionality for Log4j2 that remove All appenders for Loggers?
Kind regards.

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: removeAllAppenders() Log4j2

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 programmatically ? The website says "Log4j 2 API...
 |

 |

 |


is that helpful?
One of the answers does indicate that removing all appenders might not be necessary, perhaps you need smarter filtering?


    On Wednesday, March 25, 2020, 8:34:56 AM EDT, EDMONDO SENA <[hidden email]> wrote:  
 
 Hello,

Is there a similar functionality for Log4j2 that remove All appenders for Loggers?
Kind regards.

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

 
Reply | Threaded
Open this post in threaded view
|

Re: removeAllAppenders() Log4j2

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 <[hidden email]> wrote:

>  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 programmatically ? The website says "Log4j 2 API...
>  |
>
>  |
>
>  |
>
>
> is that helpful?
> One of the answers does indicate that removing all appenders might not be necessary, perhaps you need smarter filtering?
>
>
>     On Wednesday, March 25, 2020, 8:34:56 AM EDT, EDMONDO SENA <[hidden email]> wrote:  
>  
>  Hello,
>
> Is there a similar functionality for Log4j2 that remove All appenders for Loggers?
> Kind regards.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>  

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: removeAllAppenders() Log4j2

Doug Wegscheid
In reply to this post by EDMONDO SENA
 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 appenders? Perhaps there is another way to do whatever needs doing?





    On Wednesday, March 25, 2020, 8:34:56 AM EDT, EDMONDO SENA <[hidden email]> wrote:  
 
 Hello,

Is there a similar functionality for Log4j2 that remove All appenders for Loggers?
Kind regards.

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

 
Reply | Threaded
Open this post in threaded view
|

Re: removeAllAppenders() Log4j2

Doug Wegscheid
In reply to this post by EDMONDO SENA
 Are you looking at clearAppenders()?

    On Wednesday, March 25, 2020, 8:56:57 AM EDT, EDMONDO SENA <[hidden email]> wrote:  
 
 
I think It removes the appender single by single not all in one instruction!



On 2020/03/25 12:46:19, Doug Wegscheid <[hidden email]> wrote:

>  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 programmatically ? The website says "Log4j 2 API...
>  |
>
>  |
>
>  |
>
>
> is that helpful?
> One of the answers does indicate that removing all appenders might not be necessary, perhaps you need smarter filtering?
>
>
>    On Wednesday, March 25, 2020, 8:34:56 AM EDT, EDMONDO SENA <[hidden email]> wrote: 

>  Hello,
>
> Is there a similar functionality for Log4j2 that remove All appenders for Loggers?
> Kind regards.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

 
Reply | Threaded
Open this post in threaded view
|

Re: removeAllAppenders() Log4j2

EDMONDO SENA
In reply to this post by Doug Wegscheid

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 <[hidden email]> wrote:

>  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 appenders? Perhaps there is another way to do whatever needs doing?
>
>
>
>
>
>     On Wednesday, March 25, 2020, 8:34:56 AM EDT, EDMONDO SENA <[hidden email]> wrote:  
>  
>  Hello,
>
> Is there a similar functionality for Log4j2 that remove All appenders for Loggers?
> Kind regards.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>  

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: removeAllAppenders() Log4j2

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 <[hidden email]> 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 Wegscheid <[hidden email]> wrote:

>  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 appenders? Perhaps there is another way to do whatever needs doing?
>
>
>
>
>
>    On Wednesday, March 25, 2020, 8:34:56 AM EDT, EDMONDO SENA <[hidden email]> wrote: 

>  Hello,
>
> Is there a similar functionality for Log4j2 that remove All appenders for Loggers?
> Kind regards.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

 
Reply | Threaded
Open this post in threaded view
|

Re: removeAllAppenders() Log4j2

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 <[hidden email]> 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, EDMONDO SENA <[hidden email]> 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 Wegscheid <[hidden email]> wrote:
> >  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 appenders? Perhaps there is another way to do whatever needs doing?
> >
> >
> >
> >
> >
> >    On Wednesday, March 25, 2020, 8:34:56 AM EDT, EDMONDO SENA <[hidden email]> wrote: 
> > 
> >  Hello,
> >
> > Is there a similar functionality for Log4j2 that remove All appenders for Loggers?
> > Kind regards.
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [hidden email]
> > For additional commands, e-mail: [hidden email]
> >
> > 
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>  

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: removeAllAppenders() Log4j2

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 that information, I (or someone else) might be able to help you get your application converted over to 2.x.

That being said, you are welcome to try the #clearAppenders().
    On Wednesday, March 25, 2020, 9:16:47 AM EDT, EDMONDO SENA <[hidden email]> wrote:  
 
 
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 <[hidden email]> 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, EDMONDO SENA <[hidden email]> 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 Wegscheid <[hidden email]> wrote:
> >  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 appenders? Perhaps there is another way to do whatever needs doing?
> >
> >
> >
> >
> >
> >    On Wednesday, March 25, 2020, 8:34:56 AM EDT, EDMONDO SENA <[hidden email]> wrote: 
> > 
> >  Hello,
> >
> > Is there a similar functionality for Log4j2 that remove All appenders for Loggers?
> > Kind regards.
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [hidden email]
> > For additional commands, e-mail: [hidden email]
> >
> > 
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

 
Reply | Threaded
Open this post in threaded view
|

Re: removeAllAppenders() Log4j2

EDMONDO SENA

How?

That being said, you are welcome to try the #clearAppenders().



On 2020/03/25 13:21:25, Doug Wegscheid <[hidden email]> 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 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 that information, I (or someone else) might be able to help you get your application converted over to 2.x.
>
> That being said, you are welcome to try the #clearAppenders().
>     On Wednesday, March 25, 2020, 9:16:47 AM EDT, EDMONDO SENA <[hidden email]> wrote:  
>  
>  
> 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 <[hidden email]> 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, EDMONDO SENA <[hidden email]> 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 Wegscheid <[hidden email]> wrote:
> > >  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 appenders? Perhaps there is another way to do whatever needs doing?
> > >
> > >
> > >
> > >
> > >
> > >    On Wednesday, March 25, 2020, 8:34:56 AM EDT, EDMONDO SENA <[hidden email]> wrote: 
> > > 
> > >  Hello,
> > >
> > > Is there a similar functionality for Log4j2 that remove All appenders for Loggers?
> > > Kind regards.
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: [hidden email]
> > > For additional commands, e-mail: [hidden email]
> > >
> > > 
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [hidden email]
> > For additional commands, e-mail: [hidden email]
> >
> > 
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>  

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: removeAllAppenders() Log4j2

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 you repeatedly that the way to perform a migration is to list your requirements and then figure out the proper way to meet each requirement with Log4j 2. If you can’t figure out what that is then come to use with some thing like “I have a requirement to …. and need help figuring out how to accomplish that” where the requirement is not something like “remove all appenders”, but is the reason WHY you need to remove all the appenders.

Ralph

> On Mar 25, 2020, at 7:09 AM, EDMONDO SENA <[hidden email]> wrote:
>
>
> How?
>
> That being said, you are welcome to try the #clearAppenders().
>
>
>
> On 2020/03/25 13:21:25, Doug Wegscheid <[hidden email]> 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 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 that information, I (or someone else) might be able to help you get your application converted over to 2.x.
>>
>> That being said, you are welcome to try the #clearAppenders().
>>    On Wednesday, March 25, 2020, 9:16:47 AM EDT, EDMONDO SENA <[hidden email]> wrote:  
>>
>>
>> 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 <[hidden email]> 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, EDMONDO SENA <[hidden email]> 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 Wegscheid <[hidden email]> wrote:
>>>>   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 appenders? Perhaps there is another way to do whatever needs doing?
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>     On Wednesday, March 25, 2020, 8:34:56 AM EDT, EDMONDO SENA <[hidden email]> wrote:  
>>>>  
>>>>   Hello,
>>>>
>>>> Is there a similar functionality for Log4j2 that remove All appenders for Loggers?
>>>> Kind regards.
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: [hidden email]
>>>> For additional commands, e-mail: [hidden email]
>>>>
>>>>  
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: [hidden email]
>>> For additional commands, e-mail: [hidden email]
>>>
>>>  
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [hidden email]
>> For additional commands, e-mail: [hidden email]
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>



---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: removeAllAppenders() Log4j2

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
log4j.category.com.maverick=WARN,A1
log4j.additivity.com.maverick=false

# FTP server log
log4j.category.org.apache.ftpserver=ERROR,A1,stdout
log4j.additivity.org.apache.ftpserver=false

log4j2.properties doesn't work.



On 2020/03/25 15:16:33, Ralph Goers <[hidden email]> wrote:

> 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 you repeatedly that the way to perform a migration is to list your requirements and then figure out the proper way to meet each requirement with Log4j 2. If you can’t figure out what that is then come to use with some thing like “I have a requirement to …. and need help figuring out how to accomplish that” where the requirement is not something like “remove all appenders”, but is the reason WHY you need to remove all the appenders.
>
> Ralph
>
> > On Mar 25, 2020, at 7:09 AM, EDMONDO SENA <[hidden email]> wrote:
> >
> >
> > How?
> >
> > That being said, you are welcome to try the #clearAppenders().
> >
> >
> >
> > On 2020/03/25 13:21:25, Doug Wegscheid <[hidden email]> 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 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 that information, I (or someone else) might be able to help you get your application converted over to 2.x.
> >>
> >> That being said, you are welcome to try the #clearAppenders().
> >>    On Wednesday, March 25, 2020, 9:16:47 AM EDT, EDMONDO SENA <[hidden email]> wrote:  
> >>
> >>
> >> 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 <[hidden email]> 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, EDMONDO SENA <[hidden email]> 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 Wegscheid <[hidden email]> wrote:
> >>>>   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 appenders? Perhaps there is another way to do whatever needs doing?
> >>>>
> >>>>
> >>>>
> >>>>
> >>>>
> >>>>     On Wednesday, March 25, 2020, 8:34:56 AM EDT, EDMONDO SENA <[hidden email]> wrote:  
> >>>>  
> >>>>   Hello,
> >>>>
> >>>> Is there a similar functionality for Log4j2 that remove All appenders for Loggers?
> >>>> Kind regards.
> >>>>
> >>>> ---------------------------------------------------------------------
> >>>> To unsubscribe, e-mail: [hidden email]
> >>>> For additional commands, e-mail: [hidden email]
> >>>>
> >>>>  
> >>>
> >>> ---------------------------------------------------------------------
> >>> To unsubscribe, e-mail: [hidden email]
> >>> For additional commands, e-mail: [hidden email]
> >>>
> >>>  
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: [hidden email]
> >> For additional commands, e-mail: [hidden email]
> >>
> >>
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [hidden email]
> > For additional commands, e-mail: [hidden email]
> >
> >
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]