Tomcat logs can become overwhelming to read in a development environment. Usually, you would only need to see the most recent error logs when testing your program. The older errors are irrelevant. This simple shell script solves the problem of error logs piling up.
Navigate to the tomcat/bin folder. Edit the file named “startup.sh”. You will need to be logged in as root to perform these changes. Place the following code at the top of the file, directly after the last comments.
# ----------------------------------------------------------------------------- # Start Script for the CATALINA Server # ----------------------------------------------------------------------------- echo "DELETING OLD LOG FILES ..." cd ../logs rm catalina* rm local* rm manager* rm admin* rm host* echo "DELETING OLD WEB APP ..." cd ../webapps rm -r YOURAPPNAME echo "PERFORMING NORMAL STARTUP ..." cd ../bin
Now when Tomcat starts it will remove all old log files, and the application folder before proceeding.
Using with Netbeans
To deploy with Netbeans navigate to Services -> Servers -> Apache Tomcat (Your server). Right click and select Properties. There will be a tab labeled Startup. Select Use Custom Catalina Script. Finally, browse and select the tomcat startup.sh script that was edited above.
this didnt work on netbeans8.2 with windows
According to kurdtpage, over on stackoverflow, this “uses Linux .sh files, but you could easily create a Windows .bat file using this method. The script would have to be slightly modified, substituting del for rm.”
https://stackoverflow.com/questions/14912679/netbeans-tomcat-clear-log-files