Don't call configure every time you log. In fact, don't bother
calling it at all and just put a log4j.properties or log4j.xml in the
root package, or default package, of the classpath. Log4j will
configure itself. You only need to worry about logging.
Remember, Log4j is additive. Each configure doesn't blow away
previous ones, it just add on. For every appender that gets added,
you'll get another log statement on all those appenders.
You really should read the log4j manual to bring you up to speed on
logging basics.
Jake
At 07:15 PM 10/16/2006, you wrote:
>Hello,
>
>I am getting multiple logs for the same log in my source code. What's more,
>is the number of duplicate logs are incremental.
>
>ex:
>the first log logs one,
>the second logs twice,
>....
>the nth log logs n tiime.
>etc...
>
>Can anyone help discover the solution to my problem?
>In my project, the logging is accessible from only one class. Here is where
>the magic happens:
>
>import org.apache.log4j.Logger;
>import org.apache.log4j.BasicConfigurator;
>
>public class ABCmodLogger
>{
>
>....
>.... <cut>
>....
> /**
> * Uses the Log4Java package to log a message of the given
> * severity.
> * @param severity The severity of the log message.
> * @param message The message to be logged.
> * @param arg The Class object of the calling class.
> */
> public void log(int severity, String message, Class arg)
> {
> Logger logger = Logger.getLogger(arg);
> BasicConfigurator.configure();
>
> switch(severity)
> {
> case INFO:
> {
> logger.info(message);
> break;
> }
>
> ...
> ... <cut>
> ...
>
> case DEBUG:
> default:
> {
> logger.debug(message);
> break;
> }
> }
> }
>}
>
>Thanks,
>Ben.
>
>_________________________________________________________________
>Experience Live Search from your PC or mobile device today.
>http://www.live.com/?mkt=en-ca
>
>
>---------------------------------------------------------------------
>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]