Friday, December 19, 2008

Catalina.out gets to big = Server crashes

Usually the programmer used the System.out.print("Something") for debug. And tomcat, by default put it on Catalina.out.
Many System.out.print, made Catalina.out increase the size.
And One day all my report (using JNLP) can't show in. And the worst, all user can't login or made the transaction.
After I delete all logs, and restart again my tomcat, all report can be viewed again. Can login and made the transaction.
The Problem in here, The Catalina out is too big (almost 1 Giga the size ) cuase the system implemented since 2006.
The Solution is the catalina.out must be rotated.
I Used the apache tomcat 5.5.17, And for the rotation :
1. download catalina-5.5.23.jar, commons-digester-1.8.jar tomcat-util-5.5.23.jar
and then put it in common/classes on your tomcat folder.
2. Edit your server.xml, put the XML like this :

<Host name="localhost" appBase="webapps"
unpackWARs="true" autoDeploy="true"
xmlValidation="false" xmlNamespaceAware="false">

<Logger className="org.apache.catalina.logger.FileLogger"
directory="logs" prefix="localhost_log." suffix=".txt"
timestamp="true"/>
<DefaultContext reloadable="false" crossContext="true" swallowOutput="true"/>
<Context path="/app_run" docBase="app_run" crossContext="true" swallowOutput="true"></Context>
<Context path="/app_dev" docBase="app_dev" crossContext="true" swallowOutput="true"></Context>
<Context path="/app_demo" docBase="app_demo" crossContext="true" swallowOutput="true"></Context>
</Host>

And The logs folder become like this :
-rw-r--r-- 1 dev users 0 2008-12-18 18:46 admin.2008-12-18.log

-rw-r--r-- 1 dev users 0 2008-12-19 13:46 admin.2008-12-19.log
-rw-r--r-- 1 dev users 1912 2008-12-18 21:33 catalina.2008-12-18.log
-rw-r--r-- 1 dev users 1438 2008-12-19 13:46 catalina.2008-12-19.log
-rw-r--r-- 1 dev users 3350 2008-12-19 13:46 catalina.out
-rw-r--r-- 1 dev users 0 2008-12-18 18:46 host-manager.2008-12-18.log
-rw-r--r-- 1 dev users 0 2008-12-19 13:46 host-manager.2008-12-19.log
-rw-r--r-- 1 dev users 149134 2008-12-18 21:33 localhost.2008-12-18.log
-rw-r--r-- 1 dev users 12007 2008-12-19 13:48 localhost.2008-12-19.log
-rw-r--r-- 1 dev users 0 2008-12-18 18:46 manager.2008-12-18.log
-rw-r--r-- 1 dev users 0 2008-12-19 13:46 manager.2008-12-19.log


The Catalina.out will be updated only when tomcat start or stop.
And All logs like System.out.println will put on file localhost.yyyy-mm-dd.log, with yyyy-mm-dd is current date.
For More information for tomcat-logging you can visit http://wiki.apache.org/tomcat/FAQ/Logging#Q4



 

Thursday, December 18, 2008

My Serial Number

At End Of Year, the airlines company introduce to the public the newest aircraft.
This aircraft used hi-tech equipment like artificial intelligence with using super computer
that can made decision by self, bullet proof, satalit communication and many ....
And very amazing is ....No need pilots to fly it !!!. All Controlled by super computer.
Just need a flight mechanic to view all situation from the control panel.
And One day at first time flight ....
Auto-Pilot : Welcome all passengers, This your auto-pilot speaking. for a few minutes will take off.
Please fasten your seat belt and no smoking until no smoking light turn off....
In 10 minutes later ...

Auto-Pilot : All passengers. Now we fly on 2 times speed of sound or 2 match with 30,000 feet hight from                    sea level. Enjoy your flight...flight...flight...flight...flight...flight...flight...flight...flight...
                   flight...flight...flight...flight...flight...flight...flight...flight...flight...flight...

Flight Mechanic : ......(Ask to self), why the sound repeated many times ???.
                           Ah, No problem i will make correction on this problem. I've trained it already ...
                           (with type something on keyboard) then On Screen showing :
                                   "Welcome Control Center"
                           "You are First Time Using This System"
                         "Please Enter The Serial Number On The textbox Below"