James you are right. I am doing 'new' every time. Can you please tell me why
this is happening. Because I am calling the log method in the current
instance.
Thanks,
Babu
On 7/27/06, James Stauffer <[EMAIL PROTECTED]> wrote:
If you "new" that class muliple times I could see how that might happen.
Is there any reason that you can't use a config file? That is more
standard and easier to configure.
On 7/27/06, Eshwaramoorthy Babu <[EMAIL PROTECTED]> wrote:
> Hello all,
>
> I am using below code to log the mesage and I am getting duplicate
messages
> in the log file.
> I am passing the EAILogger class instance to different classes and
invoking
> the log method.
>
> Can any one help me to resolve this issue.
>
>
>
> /////////////////////////Source Code
>
> import org.apache.log4j.*;
>
> public class EAILogger
> {
> private Logger logger = null;
> public EBEAILogger()
> {
> try
> {
> String fileName = "TEST.LOG";
> String datePattern = "yyyy-MM-dd.'log'";
> String logPattern = "%d %-2p [%c{3}] - %m - [%F:%M:%L] %n";
>
> Layout layout = new PatternLayout(logPattern);
> DailyRollingFileAppender appender = new
DailyRollingFileAppender(layout,
> fileName, datePattern);
> logger = Logger.getRootLogger();
> logger.addAppender(appender);
> logger.setAdditivity(false);
>
> }
> catch(Exception e)
> {
> e.printStackTrace();
> }
> }
>
> public void log(String message)
> {
> logger.info(message);
> }
> }
>
>
> /////////Log file
>
> 2006-07-27 19:07:41,289 INFO [root] - Hello!!!!!!!!!!!!!!!!!!!!1 -
[?:log:?]
>
> 2006-07-27 19:07:52,293 INFO [root] - Hello!!!!!!!!!!!!!!!!!!!!1 -
[?:log:?]
>
> 2006-07-27 19:07:52,293 INFO [root] - Hello!!!!!!!!!!!!!!!!!!!!1 -
[?:log:?]
>
>
--
James Stauffer
Are you good? Take the test at http://www.livingwaters.com/good/
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]