logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Antoine TYNEVEZ <atyne...@patrimoine.com>
Subject Re: Messages in a Loop
Date Fri, 27 May 2005 14:10:41 GMT
Hi Ivan, 

I think you could do like this :

class A {

Logger loggerA = Logger.getLogger(A.class.getName());
boolean doLogging = true;

void loop {
   while (true) {
   // some logix  
   ...
   // some verification
   if (condition &amp;&amp; doLogging) {
      loggerA.error("xxx"); // error msg 
      doLogging = false;
   }  
   // sleep for a while...
  }


Hope it can help,

Antoine

Ivan Linhares Martins a écrit :

>James,
>
>It should work with any loop, like this:
>
>class A {
>
>Logger loggerA = Logger.getLogger(A.class.getName());
>
>void loop {
>   while (true) {
>   // some logix  
>   ...
>   // some verification
>   if (condition) {
>      loggerA.error("xxx"); // error msg 
>   }  
>   // sleep for a while...
>  }
>}
>
>the problem is I have this kind of behavior in many parts of my code,
>and I wanted this "error msg" printed only once while the condition is
>true, without creating additional conditional variables inside the
>code.
>
>is it possible to do it? 
>
>[]'s
>Ivan Linhares
>
>
>ps: I should try Aron solution as well, but it requires some extra coding too
>
>
>On 5/24/05, James Stauffer <stauffer.james@gmail.com> wrote:
>  
>
>>Any loop or one specific loop?  If it is one specific loop you could
>>configure the logger that it uses.
>>
>>On 5/24/05, Ivan Linhares Martins <linhares@gmail.com> wrote:
>>    
>>
>>>Hi,
>>>
>>>I´m using log4j version 1-3 alpha 6, working with Socket and File Appenders.
>>>
>>>I would like to know if i can prevent repeated messages generated in a
>>>loop appearing in files or remote receivers only by configuring Log4j,
>>>i.e. not writing additional code. Is it possible?
>>>
>>>Thanks,
>>>Ivan
>>>
>>>---------------------------------------------------------------------
>>>To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
>>>For additional commands, e-mail: log4j-user-help@logging.apache.org
>>>
>>>
>>>      
>>>
>>--
>>James Stauffer
>>Are you good? Take the test at http://www.livingwaters.com/good/
>>
>>    
>>
>
>
>  
>

-- 
Antoine Tynevez
Patrimoine Management & Technologie



---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org


Mime
View raw message