Hello to all users, I am new on Log4j. I am doing a project in java with eclipse and my project has the following structure:
package ----underpackage ----categories ----one ----class1.java ----class2.java ----two ----class3.java ----class4.java <-- Applet ----class5.java ----three ----LogFile.java And some other information: class4 calls class3 and class5 class2 is called by class1 and class1 called by class5. In LogFile i have written the following: public class LogFile { private static final String dirname = "./log/"; //location of the log files private static Logger logger = Logger.getRootLogger(); /** * This is the default constructor */ public LogFile() { try { PatternLayout layout = new PatternLayout( "%d (%c) [%t] %-5p %m%n" ); DailyRollingFileAppender fileAppender = new DailyRollingFileAppender( layout, dirname + "Log.log", "'.'yyyy-MM-dd" ); logger.addAppender( fileAppender ); logger.setLevel(Level.INFO); } catch( Exception ex ) { System.err.println( ex ); } } public void logError(String message){ logger.info("+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+"); logger.info("Write several more information"); logger.error(message); } } And so I called it on the several classes: private static LogFile lfLogging = new LogFile(); ..... lfLogging.logError("Error Message is written here!"); Well I entered it to all the class and the Logfile is written, the only problem is when the method is called to write to logfile then it is not just written once, but it is written 4 times the same. I commented in all class just not in one the lines of logfile calling and then it just write once in the LogFile. Can somebody help me how I have to declare that my LogFile works correctly. Many thanks in advance for your help. Best regards, Dany -- View this message in context: http://old.nabble.com/Log4j-over-several-java-classes-tp26195319p26195319.html Sent from the Log4j - Users mailing list archive at Nabble.com. --------------------------------------------------------------------- To unsubscribe, e-mail: log4j-user-unsubscr...@logging.apache.org For additional commands, e-mail: log4j-user-h...@logging.apache.org