I have been using staf for my test automation. While running multiple testcases, I have observed that all staf logs are written in a single file which is configured in the staf configuration file like the following,
TRACE SET DESTINATION TO FILE C:\STAF\STAFLog.log
While running more number of test cases that log file is growing even more than 15GB and i am not able to open and read.
Kindly suggest me how to configure staf log which could be maximum size of 4 MB. After that it will create a new file and write the logs. This i could do it in log4net like the following,
<appender name="RollingFile" type="log4net.Appender.RollingFileAppender">
<file value="..\..\Logs\STAFLog.log">
<appendtofile value="true">
<rollingstyle value="Composite">
<maxsizerollbackups value="50">
<maximumfilesize value="4 MB">
<layout type="log4net.Layout.PatternLayout">
<conversionpattern value="%date:%-5level:<span>[%C{3}.%M]</span> %message%newline">
</conversionpattern></layout>
<filter type="log4net.Filter.LevelRangeFilter">
<levelmin value="ALL">
<levelmax value="ERROR">
</levelmax></levelmin></filter>
</maximumfilesize></maxsizerollbackups></rollingstyle></appendtofile></file></appender>
In your STAF.cfg file in your attachment, it contains the following lines for STAF tracing:
You added the "TRACE SET DESTINATION TO FILE C:\STAF\STAFLog.log" and "TRACE ENABLE ALL" lines to your STAF.cfg file as these are not the default settings. You do not generally want to enable all STAF tracing as that will generate a ton of output as you've seen (except if debugging a problem and even then, you usually do not want to enable ALL tracing). Generally, you only want to have the default lines:
And if you want to redirect STAF trace output to a file you can leave in line:
But, you should remove line:
Note that STAF itself does not provide the ability to configure a STAF log with a maximum size. But I don't think that really is the issue as you should not be enabling all STAF tracing and, as you read on, you really want to be looking at the STAX job and job user logs, not the STAF tracing log, if you're trying to debug a STAX job and/or view the output logged by a STAX job.
Also, note that any time you change the STAF.cfg file you must shutdown STAF (STAF local SHUTDOWN SHUTDOWN) and restart STAFProc in order for the changes to take effect. Or, you can also dynamically disable all tracing (which only has an effect for this instance of STAFProc currently running):
You said "While running multiple testcases, I have observed that all staf logs are written in a single file". This is not true. I think that perhaps you don't understand that STAX Job Logs are generated for each STAX job that you run. The STAF tracing output is for debugging problems in STAF and this is a completely different log from STAX Job Logs and STAX Job User Logs. Are you trying to view the output logged by your STAX job? For example, in TestGroup.xml you use a <log> elements as follows:</log>
These messages will be written to the STAX Job User log for the Job ID of the submitted STAX job. For example, here I'm showing running a modified version of your attached TestGroup.xml that just contains the <log message="1"> elements to logs messages 'execute tc started' and 'execute tc completed' and how you can then query the STAX Job Log and STAX Job User Logs that running it created:</log>
See section "STAX Logging" in the STAX User's Guide at http://staf.sourceforge.net/current/STAX/staxug.html#Header_StaxLogging for more information about STAX Job Logs and STAX Job User Logs.
Also, you may want to use the STAX Monitor to submit your STAX jobs via its GUI and/or to monitor a STAX job. The STAX Monitor also provides a GUI to view STAX job logs. For more information, see section "STAX Monitor", sub-section "Displaying a Job Log" in the STAX User's Guide at http://staf.sourceforge.net/current/STAX/staxug.html#Header_DisplayJobLog.
Thanks for the information shared. I hope i shall limit my staf logs like the way you have suggested. But cases of long running test scenarios, if i have an option to write the staf logs(not talking about job logs) in multiple files it shall be manageable for us.