Hi,
You should only configure log4j once.  The BasicConfigurator adds a
ConsoleAppender each time, and they're all additive by default.  That's
why you're seeing multiple statements.

Move the BasicConfigurator.configure() call to your static main()
method, out of your mainTest() method, and see what happens.

Yoav Shapira
Millennium ChemInformatics


>-----Original Message-----
>From: Purushotham P [mailto:[EMAIL PROTECTED]]
>Sent: Tuesday, November 26, 2002 11:26 AM
>To: [EMAIL PROTECTED]
>Cc: [EMAIL PROTECTED]
>Subject: facing problem when call logger.info().....
>
>hi All
>
>       I am facing problem when i call logger.info() method
>more than one
>time in the same class. How i can over come this ?
>The problem is the message given to logger.info() is
>printing cumulatively
>as output shown bellow.
>
>Thanks
>Purshi
>
>    import org.apache.log4j.Logger;
>    import org.apache.log4j.BasicConfigurator;
>
>    public class Hello {
>       private static Logger logger;
>
>      public static void main(String argv[]) {
>       logger = Logger.getRootLogger();
>       Hello hl = new Hello();
>               System.out.println ("In Hello Main 1");
>                hl.mainTest();
>               System.out.println ("In Hello Main 2");
>                hl.mainTest();
>               System.out.println ("In Hello Main 3");
>                hl.mainTest();
>               System.out.println ("In Hello Main 4");
>                hl.mainTest();
>      }
>
>        public void mainTest() {
>               BasicConfigurator.configure();
>               String str = "What a beatiful day.";
>               logger.info(str);
>               str = null;
>      }
>    }
>
>java Hello
>
>In Hello Main 1
>0 [main] INFO root  - What a beatiful day.
>
>In Hello Main 2
>20 [main] INFO root  - What a beatiful day.
>20 [main] INFO root  - What a beatiful day.
>
>In Hello Main 3
>20 [main] INFO root  - What a beatiful day.
>20 [main] INFO root  - What a beatiful day.
>20 [main] INFO root  - What a beatiful day.
>
>In Hello Main 4
>20 [main] INFO root  - What a beatiful day.
>20 [main] INFO root  - What a beatiful day.
>20 [main] INFO root  - What a beatiful day.
>20 [main] INFO root  - What a beatiful day.
>
>
>_______________________________________________________________________
_
>Missed your favourite TV serial last night? Try the new, Yahoo! TV.
>       visit http://in.tv.yahoo.com
>
>--
>To unsubscribe, e-mail:   <mailto:log4j-user-
>[EMAIL PROTECTED]>
>For additional commands, e-mail: <mailto:log4j-user-
>[EMAIL PROTECTED]>


--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to