I am working on a Java SOAP based webservice application where I am writing stdout to a text file as log for our reference. That file is growing enormously, so I need to check f
Most logging frameworks provide what you're looking for. In logback you should be able to achieve it by properly configuring a RollingFileAppender:
RollingFileAppender extends FileAppender with the capability to rollover log files. For example, RollingFileAppender can log to a file named log.txt file and, once a certain condition is met, change its logging target to another file.
and
RollingPolicy is responsible for the rollover procedure which involves file moving and renaming.
http://logback.qos.ch/manual/appenders.html