We know 3 appender for logging to the file. FILEAPPENDER ROLLINGFILEAPPENDER DAILYROLLINGFILEAPPENDER Suppose we choose FILEAPPENDER,but it would append the log message of the log file.We want the log4j override the log file at every time when the program running. How can I setup? Does the log4j contain the override parameter to setup in the config file? I doesn't find that. Any idea apprecation.
Look again at the javadoc for the Log4j API. The constructor for FileAppender and its two subclasses RollingFileAppender and DailyRollingFileAppender can take a boolean parameter which tells them to append to the file. Set that parameter to false and the file will be truncated before being logged to. You can also call setAppend(false) to do the same trick. I would guess that there is a property Append (or append) which you can set to false. [ December 28, 2003: Message edited by: Barry Gaunt ]
Thx I defind 2 appender as the following setting. One for HTML log,other for console log. When executing the "TEST.Log4jTEST",it would log the message to the html file. When executing the "TEST.Log4jOtherTEST",it earse the html file. Do any way prevent them? I don't want the TEST.Log4jOtherTEST affect the TEST.Log4jTEST's log. Although I have separate them in 2 loggers in the setting file.
posted 15 years ago
I have 3 or more application in the same package. All of them using the same logger(read the same log4j config file). The application may be running at the same time. I want to seperate them to different log according to the main class. Any way to do that? Write a great many catergory in the config file?
posted 15 years ago
"dmhorse" thanks for changing your displayed name. But it's still not correct. If dm are your initials and the horse is your last/family name it should be "d.m. horse" to conform to our naming policy. Please fix it. Returning to your problem, I would like to help, but do not have the time to write a complete test program for your problem. If you have a short example program that demonstrates what you want to do I will try to run it and see if I can help. [ January 01, 2004: Message edited by: Barry Gaunt ]