Labels

Wednesday, June 13, 2012

How to rotate-log in GlassFish ?

GlassFish has a command to rotate or reset server.log file:

$GLASSFISH_HOME/bin/asadmin rotate-log

After running this command the logs directory looks like this:
/glassfish-3.1/glassfish/domains/domain1/logs > ll
total 200
-rw-r--r--  1 root      0 Jun 25 10:11 server.log
-rw-r--r--  1 root  10780 Jun 25 10:11 server.log_2010-06-25T10-09-48
-rw-r--r--  1 root  16384 Jun 25 10:10 jvm.log
drwxr-xr-x  3 root    102 Jun 25 10:02 server/
 
 
This command renames server.log file to a timestamped backup file, and leaves the current server.log file empty. I usually run this command before starting a test run to make sure the current server.log only contains logs from this test run.

For convenience, I also have an alias for it (in tcsh syntax):


alias rlog '$GLASSFISH_HOME/bin/asadmin rotate-log'
For more details, see official docs, or view the online help:


$GLASSFISH_HOME/bin/asadmin rotate-log --help
 

No comments:

Post a Comment