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 && 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 <[EMAIL PROTECTED]> 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 <[EMAIL PROTECTED]> 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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
--
James Stauffer
Are you good? Take the test at http://www.livingwaters.com/good/
--
Antoine Tynevez
Patrimoine Management & Technologie
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]