7

I've been working on an application and accidentally created an infinite loop. Great lots of output went to the tomcat server log file and each time I start tomcat from NetBeans, the IDE is loading all those logs into the GUI. It makes my computer suffocate without operating memory. Unfortunately, the IDE doesn't provide any "clear logs" button.

I've been trying to locate tomcat log files, but I failed. My tomcat is installed in ~/apache-tomcat-7.0.27 and the latest log file under logs subdir is catalina.2013-01-12.log. And today is 2013-02-16. And I found no tomcat under /var/log ;)

I've tried restarting NetBeans, but it doesn't change anything. Still the IDE is loading those great amounts of logs - so the file has got to be somewhere.

I'd appreciate any hints on where to search for those files.

5 Answers 5

8

Somehow I managed to find the correct directory: ~/.netbeans/7.2.1/apache-tomcat-7.0.27.0_base/logs. It held 1,7 GB :)

Still, I don't know:

  • why there's no /var/log/tomcat (maybe because tomcat was installed within NB and not as a standalone package)
  • why is anything put into ~/.netbeans directory
6

For me on Windows 7 the logs are in:

C:\Users\<user>\AppData\Roaming\NetBeans\7.2.1\apache-tomcat-7.0.27.0_base
6

The tomcat log files depend on your configuration, to see exactly where they are, in NetBeans, go to the "Tools" menu and click "Servers". Select the Tomcat version you're using and in the tab "Connection" take a look to the field "Catalina Base". That's the file path you need, enter this folder, in my case "C:\Users\Tiago Peres\AppData\Roaming\NetBeans\7.3\apache-tomcat-7.0.34.0_base", enter the folder "logs", and delete everything.

1

You could always create a script to delete log files in startup. I was looking to do this myself and found a great article with instructions on how to do this: http://blog.sixthpoint.com/clearing-tomcat-logs-on-startup/

Edit: The article 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

1
  • note that this is not an easy task, because from my experience, using startup.bat as in the mentioned tutorial, breaks the way Netbeans bootstraps Tomcat and deploys the debugged application (after hacking some quotes in startup.bat to surpass some cryptic messages like not recognizing 127.0.0.1) - - - another idea would be to modify catalina.bat itself (I think it is called in all cases, even if you opt out of using startup.bat) to clean up the %CATALINA_HOME%\logs directory (I hope the files there won't have become locked yet). Aug 19, 2021 at 7:33
0

if you are like me, being fed up with Netbeans somehow showing the remains of the previous debug session, with old stack traces etc. - yet another idea would be to modify %CATALINA_HOME%\conf\logging.properties to leave it at a bare minimum. Unfortunately, though, JULI AsyncFileAppender doesn't expose properties that control how a new session would treat the already existing files (like .append=false option for LOG4J appenders).

So I ended up modifying catalina.bat at my own risk and in danger that in a few weeks I will have forgotten that I did this and will wonder and blame the world around me about why my log directory suddenly gets picked clean each time I start Tomcat.

%CATALINA_HOME%\bin\catalina.bat:

...

REM these are the original lines that existed in catalina.bat before
rem Copy CATALINA_BASE from CATALINA_HOME if not defined
if not "%CATALINA_BASE%" == "" goto gotBase
set "CATALINA_BASE=%CATALINA_HOME%"
:gotBase

REM these are the lines that I am adding
rem cleanup logs directory
del /q/s %CATALINA_HOME%\logs\*.*

...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.