Link to home
Start Free TrialLog in
Avatar of West100
West100

asked on

How to use log4j with appending more log messages

How should a log4j properties file be configured so that messages won't be appended for each run to the same log file? Currently weeks worth of logged messages have been rolled into the same log file making it huge and difficult to work with.  I want to have a fresh log file containing only the current runs logged messages. I don't want separate logs for each run. One log is enough containing one runs worth of messages at a time.

I am currently using the following log4j.properties file configurations:
log4j.rootLogger = INFO, F
log4j.appender.F=org.apache.log4j.FileAppender
log4j.appender.F.File=/usr/local/admin/logs/QASBulk.log
log4j.appender.F.layout=org.apache.log4j.PatternLayout
log4j.appender.F.layout.ConversionPattern=[%d{MMM dd HH:mm:ss}] (%-5p) - %m - at (%F:%L)%n

Thanks

Avatar of CEHJ
CEHJ
Flag of United Kingdom of Great Britain and Northern Ireland image

Try

log4j.appender.F.fileAppend=false
Avatar of West100
West100

ASKER

No that does not work
ASKER CERTIFIED SOLUTION
Avatar of CEHJ
CEHJ
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Also have a look on RollingFileAppender and DailyRollingFileAppender

http://veerasundar.com/blog/2009/07/log4j-tutorial-how-to-send-the-log-messages-to-a-file/
:)