Summary: Managing log file naming, and rolling over policies
OverviewThe log file names, location and format are all properties of the Java log Handler. GigaSpaces uses a rolling file handler implemented by the class com.gigaspaces.logger.RollingFileHandler, which is based on Java's java.util.logging.FileHandler, but with extended functionality. It provides two policies that can trigger a "rollover" to a new file, and a customizable extension point for backing up files. Rolling Over to a New FileThe rollover mechanism is based on two policies, whichever policy is triggered first:
formatter propertyThe default log output formatting is determined by GSSimpleFormatter (see Formatting Log Messages). com.gigaspaces.logger.RollingFileHandler.formatter = com.gigaspaces.logger.GSSimpleFormatter filename-pattern PropertyThe file name pattern can be configured to include a placeholder for properties to resolve, such as homedir, host, pid and date. Each placeholder is identified by a set of curly brackets {..}. It may also be a placeholder for a custom defined property. com.gigaspaces.logger.RollingFileHandler.filename-pattern = {homedir}/logs/{date,yyyy-MM-dd~HH.mm}-gigaspaces-{service}-{host}-{pid}.log To determine the place holder's value, we first look for an overriding system property. If no override was specified, and the property is one of the predefined properties (i.e. homedir, host, pid, date), its value is evaluated by the handler implementation. If the place holder is of a custom property, and no value is defined, the property is left as is. If any error occurs, it is reported and the property is replaced by an empty string. Example override by system property: -Dcom.gigaspaces.logger.RollingFileHandler.filename-pattern.date=yyyy-MM-dd Customization Examples1. One possible customization that might be of interest is to separate the log files into folders named after the host names. com.gigaspaces.logger.RollingFileHandler.filename-pattern = {homedir}/logs/{host}/{date,yyyy-MM-dd~HH.mm}-gigaspaces-{service}-{pid}.log <GigaSpace>/logs/ + host1 - *.log + host2 - *.log 2. We would like to be able to configure the path where GigaSpaces puts its logs. -Dcom.gigaspaces.logger.RollingFileHandler.filename-pattern.homedir = /dev/output/logs And have the filename-pattern include the homedir key com.gigaspaces.logger.RollingFileHandler.filename-pattern = {homedir}/mylog.log 3. We would like to configure a custom filename-pattern property of our own. -Dcom.gigaspaces.logger.RollingFileHandler.filename-pattern.mycustom = value And have the filename-pattern include the mycustom property key com.gigaspaces.logger.RollingFileHandler.filename-pattern = ../{mycustom}/mylog.log
append PropertyThe append property specifies if output should be appended to an existing file. Default is set to false. Thus, if a file already exists by this name, a unique incrementing index to resolve the conflict will be concatenated. It will be added at the end of the filename replacing ".log" with "__{unique}.log" or at the end of the filename if the pattern doesn't end with ".log". com.gigaspaces.logger.RollingFileHandler.append = false
size-rolling-policy PropertyThe file size rolling policy can be configured to roll the file when a size limit is reached. It specifies an approximate maximum amount to write (in bytes) to any one file. If this is zero, then there is no limit. If the property is omitted, then a default of 2MB is assumed. com.gigaspaces.logger.RollingFileHandler.size-rolling-policy = 2000000 time-rolling-policy PropertyThe time based rolling policy can be configured to roll the file based on a certain recurring schedule. The time policy can be set to one of the following values: daily, weekly, monthly or yearly. If the property is omitted, then the default pattern of "daily" is assumed; meaning a daily rollover (at midnight). For example, if "monthly" is configured, the file will rollover at the beginning of each month. com.gigaspaces.logger.RollingFileHandler.time-rolling-policy = daily backup-policy PropertyA backup-policy can be configured to backup files. By default a NullBackupPolicy is configured, which does nothing. It can be replaced by a DeleteBackupPolicy to keep a backup of files for a specified period. The BackupPolicy interface allows custom implementations to be plugged-in. com.gigaspaces.logger.RollingFileHandler.backup-policy = com.gigaspaces.logger.DeleteBackupPolicy com.gigaspaces.logger.DeleteBackupPolicy.period = 30 com.gigaspaces.logger.DeleteBackupPolicy.backup = 10 For more information see Backing-up Files With a Custom Policy debug-level PropertyThe debug level (configured to one of logging Levels) is the level in which debug messages are displayed to the "standard" output stream. By default the level is configured to "CONFIG" which displays the log file name. "Log file: /export/users/gs/gigaspaces-xap/logs/2010-08-04~12.29-gigaspaces-cli-lab1-4422.log" com.gigaspaces.logger.RollingFileHandler.debug-level = CONFIG This can also be overridden by a system property. System property overridesAny of the logger properties can be configured by a system property override, specified as follows: For example: -Dcom.gigaspaces.logger.RollingFileHandler.debug-level=OFF |
![]() |
GigaSpaces.com - Legal Notice - 3rd Party Licenses - Site Map - API Docs - Forum - Downloads - Blog - White Papers - Contact Tech Writing - Gen. by Atlassian Confluence |