How do I configure GlassFish to delete rotated log files?

Paraphrased from the users@glassfish mailing list:

Q. Is there a way to configure GlassFish to either only keep a certain number of rotated log files, or to delete log files after they reach a certain age? I see that you can configure rotation based on file size and age, but the log file directory still grows without bounds. (On my platform, logging to the unix syslog facility is not an option, sadly. Looking for other ideas.)

https://github.com/javaee/glassfish/issues/3874

A. Jan Luehe: Try setting this system property:

com.sun.enterprise.server.logging.max_history_files

which specifies the maximum number of access log files (starting with the most recent ones) to keep. GlassFish has inherited this system property from a patch developed for a customer. Preferably, this would have been defined as an <access-log property> in domain.xml, however, the <access-log> element currently does not support <property> subelements, as per the DTD that governs the domain.xml.

The com.sun.enterprise.server.logging.max_history_files system property limits the number of rotated log files for both access logging and the server log. (This means that if we wanted to make it configurable in domain.xml, we should expose it as both a property (or attribute) on <access-log> and <log-service>, with the ability to specify different values for each.)
Using admin-console, one should reach the appropriate "config/server" whose this system property needs to be set.

For asadmin, try using create-jvm-options command.