IAF log file rotation
Rotating the IAF log file refers to closing the IAF log file while the IAF is running and opening a new log file. This lets you archive log files and avoid log files that are too large to easily view.
Each site should decide on and implement its own IAF log rotation policy. You should consider the following:
How often to rotate log files.
How large an IAF log file can be.
What IAF log file naming conventions to use to organize log files.
There is a lot of useful header information in the log file being used when the IAF starts. If you need to provide log files to Apama technical support, you should be able to provide the log file that was in use when the IAF started, as well as any other log files that were in use before and when a problem occurred.
Note:
Regularly rotating log files and storing the old ones in a secure location may be important as part of your personal data protection policy. For more information, see
Protecting and erasing data from Apama log files.
On Windows, to automate log file rotation, you can set up scheduled tasks that run the following tools:
The following command instructs the IAF to close the log file it is using and start using a log file that has the name you specify. When you run this request to rotate the log file the IAF log file has a new name each time you rotate it. This is because Windows does not let you change the name of a file that is being used. If the name of the file contains blanks, be sure enclose it in quotation marks.
iaf_management --setLogFile new-log-filename
You can configure the IAF to log to two separate files. Each command instructs the IAF to start using the specified log file for either the IAF core processes (generic IAF information such as status messages) or the IAF plug-in processes (transports and codecs being used). If the name of a file contains blanks, be sure enclose it in quotation marks.
iaf_management -r setCoreLogFile new-log-filename
iaf_management -r setPluginLogFile new-log-filename
Consider using two IAF log files when you need to focus on diagnosing something specific to your application, for example, you need to easily spot authentication messages. If you do use separate log files you might want to rotate them at the same time so that they stay in sync with each other.
On UNIX, to automate log file rotation, you can write a cron job that periodically does any of the following:
Set log file name:
iaf_management --setLogFile new-log-filename
Set core log file and plug-in log file:
iaf_management -r setCoreLogFile new-log-filename
iaf_management -r setPluginLogFile new-log-filename
Reopen the log:
iaf_management --reopenLog
Move the IAF log file before you execute the --reopenLog option. Since UNIX allows you to rename a file that is in use, the IAF processes will log to the renamed log file. When you then request the IAF to reopen its log file, the IAF creates a new log file with the same name. For example, suppose you move iaf_current.log to iaf_archive_2014_01_31.log and then send a reopenLog request. The IAF creates iaf_current.log, opens it, and begins sending any log messages to it. Be sure to enclose the argument after -r in quotation marks.
If you are using two IAF log files, the --reopenLog option applies to both of them. Consequently, you want to move both log files before you issue the --reopenLog option.
Send a
SIGHUP signal:
You can write a cron job that sends a SIGHUP signal to IAF processes. The standard UNIX SIGHUP mechanism causes IAF processes to re-open their log files.
The cron job should first rename log files. Since UNIX allows you to rename a file that is in use, the IAF processes will log to the renamed log files until the cron job sends a SIGHUP to IAF processes. The SIGHUP signal makes the processes re-open their log files and so they open files that have the old names and begin using them. Of course, these files are initially empty because the IAF must re-create them.
Sending a SIGHUP signal does the same thing as the reopenLog request. Also, a SIGHUP signal forces the IAF configuration file to be reloaded and this reload stops and starts the transports and codecs.
If you instruct the IAF to open a named log file and the IAF cannot open that log file or cannot write to that log file, the IAF sends log messages to stderr but does not generate an error.
Apama does not support automatic log file rotation based on time of day or log file size.
Note:
Some people use the term log rolling instead of log rotation.