Hi... Thanks for the help.. it was the appender which has got registered more than once..
Thank you, Regards, Charith I. Fernando +94 77 3263222 (Mobile) -----Original Message----- From: Bender Heri [mailto:[EMAIL PROTECTED] Sent: Monday, October 24, 2005 5:47 PM To: Log4J Users List Subject: RE: LOG4J messages printing twice Ah, now I see. The code which you posted: static Logger logger = Logger.getLogger(Module.class); private void sendMailButtonAction() { SimpleLayout layout = new SimpleLayout(); FileAppender appender = null; try { String fileName = DateFormat.getDateInstance().format(new java.util.GregorianCalendar() .getTime()) + "-LOG_FILE.txt"; System.out.println(fileName); appender = new FileAppender(layout,fileName,true); } catch(Exception e)You should { e.printStackTrace(); } logger.addAppender(appender); logger.setLevel((Level) Level.DEBUG); logger.info(logger.getName()); is your event handler of the button press. You always add an appender more to the logger. No wonder, you have one more output on each button press. You should instantiate and attach the appender only once at startup of program. It would also be interesting how looks your logger definition. Heri > -----Original Message----- > From: Charith Fernando [mailto:[EMAIL PROTECTED] > Sent: Monday, October 24, 2005 1:14 PM > To: 'Log4J Users List' > Subject: RE: LOG4J messages printing twice > > > Absolutely correct.... > > Thank you, > Regards, > Charith I. Fernando > +94 77 3263222 (Mobile) > > -----Original Message----- > From: Bender Heri [mailto:[EMAIL PROTECTED] > Sent: Monday, October 24, 2005 5:07 PM > To: Log4J Users List > Subject: RE: LOG4J messages printing twice > > Do you mean: > > - start program > - press button > - -> one log entry on console > - press button again > - -> two more entries > - press button again > - -> three more entries > - now you have 6 entries? > > This sounds very strange... > > Heri > > > -----Original Message----- > > From: Charith Fernando [mailto:[EMAIL PROTECTED] > > Sent: Monday, October 24, 2005 11:55 AM > > To: 'Log4J Users List' > > Subject: RE: LOG4J messages printing twice > > > > > > Lets say I have a program that logs information when u click > > the button... I > > have given the name of the class which contains the button to > > the logger... > > and each time I press the key the number of times it logs > increases by > > one... > > > > > > Thank you, > > Regards, > > Charith I. Fernando > > +94 77 3263222 (Mobile) > > > > -----Original Message----- > > From: Bender Heri [mailto:[EMAIL PROTECTED] > > Sent: Monday, October 24, 2005 3:32 PM > > To: Log4J Users List > > Subject: RE: LOG4J messages printing twice > > > > Hallo > > > > A static member is initialized only once, at the time when > > the class first > > time is loaded. Beside that, the call to Logger.getLogger( > > xyz ) delivers > > always the same instance of the logger xyz. You can call this > > as much as you > > like. The logger repository is built new on every restart > of the JVM. > > > > Plz, can you point out what you mean exactly with "in each run" ? > > > > Heri > > > > > > > > > > > > > -----Original Message----- > > > From: Charith Fernando [mailto:[EMAIL PROTECTED] > > > Sent: Monday, October 24, 2005 8:17 AM > > > To: 'Log4J Users List' > > > Subject: RE: LOG4J messages printing twice > > > > > > > > > static Logger logger = > > Logger.getLogger(MessageSenderBean.class); > > > > > > this is the code that I use to initialize the logger..... > > > > > > Thank you, > > > Regards, > > > Charith I. Fernando > > > +94 77 3263222 (Mobile) > > > > > > -----Original Message----- > > > From: Charith Fernando [mailto:[EMAIL PROTECTED] > > > Sent: Monday, October 24, 2005 11:59 AM > > > To: 'Log4J Users List' > > > Subject: RE: LOG4J messages printing twice > > > > > > I think the problem is the class gets called twice so the > > logger gets > > > initialized twice.. how can I solve this problem. > > > > > > Thank you, > > > Regards, > > > Charith I. Fernando > > > +94 77 3263222 (Mobile) > > > > > > -----Original Message----- > > > From: Charith Fernando [mailto:[EMAIL PROTECTED] > > > Sent: Monday, October 24, 2005 10:29 AM > > > To: 'Log4J Users List' > > > Subject: RE: LOG4J messages printing twice > > > > > > Can u do this by having a static initializer? > > > > > > Thank you, > > > Regards, > > > Charith I. Fernando > > > +94 77 3263222 (Mobile) > > > > > > -----Original Message----- > > > From: Charith Fernando [mailto:[EMAIL PROTECTED] > > > Sent: Monday, October 24, 2005 10:19 AM > > > To: [email protected] > > > Subject: LOG4J messages printing twice > > > > > > Hi all, > > > > > > > > > > > > When my code runs the number of times it prints on the screen > > > increases by 1 > > > in each run. > > > > > > > > > > > > I suspect that the loader gets registered more than once. > > > whats the solution > > > for this? > > > > > > > > > > > > Thank you, > > > > > > Regards, > > > > > > Charith I. Fernando > > > > > > +94 77 3263222 (Mobile) > > > > > > > > > > > > > > > > > > > > > --------------------------------------------------------------------- > > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > > For additional commands, e-mail: > [EMAIL PROTECTED] > > > > > > > > > > > > --------------------------------------------------------------------- > > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > > For additional commands, e-mail: > [EMAIL PROTECTED] > > > > > > > > > > > > --------------------------------------------------------------------- > > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > > For additional commands, e-mail: > [EMAIL PROTECTED] > > > > > > > > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
