How can I limit the size of a growing logfile Java creates on Linux? Can I have a file that "loses" data at the beginning to keep it from growing past a certain size?

Nathan Meyers

Files don't work that way, but you can rotate logs to keep the size under control. You have a couple of ways to do that easily:

  • The log4j package supports log rotation

  • If you're working in a JDK1.4 or later environment, the java.util.logging capabilities support log rotation.