logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Eshwaramoorthy Babu" <bab...@gmail.com>
Subject Re: Duplicate messages in the log file
Date Sat, 29 Jul 2006 06:55:15 GMT
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 <stauffer.james@gmail.com> 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 <babuce@gmail.com> 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: log4j-user-unsubscribe@logging.apache.org
> For additional commands, e-mail: log4j-user-help@logging.apache.org
>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message