Menu

#1547 Log file size is growing

All
closed-works-for-me
Log (2)
3
2015-04-22
2015-04-16
No

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:&lt;span&gt;[%C{3}.%M]&lt;/span&gt; %message%newline">
</conversionpattern></layout>
<filter type="log4net.Filter.LevelRangeFilter">
<levelmin value="ALL">
<levelmax value="ERROR">
</levelmax></levelmin></filter>
</maximumfilesize></maxsizerollbackups></rollingstyle></appendtofile></file></appender>

1 Attachments

Discussion

  • Sharon Lucas

    Sharon Lucas - 2015-04-16

    In your STAF.cfg file in your attachment, it contains the following lines for STAF tracing:

    # Turn on tracing of internal errors and deprecated options
    trace enable tracepoints "error deprecated"
    TRACE SET DESTINATION TO FILE C:\STAF\STAFLog.log
    TRACE ENABLE ALL
    

    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:

    # Turn on tracing of internal errors and deprecated options
    enable tracepoints "error deprecated"
    

    And if you want to redirect STAF trace output to a file you can leave in line:

    TRACE SET DESTINATION TO FILE C:\STAF\STAFLog.log
    

    But, you should remove line:

    TRACE ENABLE ALL
    

    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):

    C:\>STAF local TRACE DISABLE ALL
    Response
    --------
    
    C:\>STAF local TRACE ENABLE TRACEPOINTS "error deprecated"
    Response
    --------
    

    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>

        <log message="1">'execute tc started'</log>
        <log message="1">'execute tc completed'</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>

    C:\>STAF local STAX EXECUTE FILE C:/temp/TestGroup.xml JOBNAME "TestGroup"
    Response
    --------
    4
    
    C:\>STAF local LOG QUERY MACHINE {STAF/Config/MachineNickname} LOGNAME STAX_Job_4
    Response
    --------
    Date-Time         Level  Message
    ----------------- ------ ------------------------------------------------------
    20150416-11:30:52 Start  JobID: 4, File: C:/temp/TestGroup.xml, Machine: local:
                             //local, Function: , Args: , JobName: TestGroup
    20150416-11:30:52 Status Testcase Totals: Tests: 0, Pass: 0, Fail: 0
    20150416-11:30:52 Status Job Result: None
    20150416-11:30:52 Stop   JobID: 4
    
    
    C:\>STAF local LOG QUERY MACHINE {STAF/Config/MachineNickname} LOGNAME STAX_Job_4_User
    Response
    --------
    Date-Time         Level Message
    ----------------- ----- --------------------
    20150416-11:30:52 Info  execute tc started
    20150416-11:30:52 Info  execute tc completed
    
    C:\>
    

    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.

     
  • Sharon Lucas

    Sharon Lucas - 2015-04-16
    • assigned_to: STAF Automated Build --> Sharon Lucas
     
  • Jegaveerapandian

    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.

     
  • Sharon Lucas

    Sharon Lucas - 2015-04-22
    • status: open --> closed-works-for-me
     

Log in to post a comment.