KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: Information Component startup based on external file
PRODUCT: 4D | VERSION: 13.4 | PLATFORM: Mac & Win
Published On: April 4, 2014

The reports generated by the Information Component can be very useful for tracking down issues. The reports are typically generated every 5 minutes and often times usage trends can be obtained from analyzing a set of folder_reports over a period of uptime.

A great way to ensure that the logs are available when you need them is enable logging when the application starts in the On Server Startup method using the following sample code;

// enable the information component to log a report every 5 minutes
ARRAY TEXT($at_Components;0)
COMPONENT LIST($at_Components)
If (Find in array($at_Components;"4D_Info_Report@")>0)
   // to start the stored procedure creating report every 5 minutes.
   EXECUTE METHOD("aa4D_NP_Schedule_Reports_Server";*;5;0)
End if


This sample code is useful in that it first checks the component list and only executes the component method if the component exists. This allows the developer to remove the component from sites that do not need it as well as to add it to other that start needing it.

Another option is to have the database startup method check for the existence of a file prior to starting the logging process; this allows you to enable the logging based on the presence of a file.

The following sample code checks for a file named 'enable_logging' next to thew structure file and the the logging is enabled only if the file exists:

// check for 'enable_logging' file next to structure
If (Test path name(Get 4D folder(Database folder)+"enable_logging")=Is a document)
    // 'enable_logging' file found next to structure
    // enable the information component to log a report every 5 minutes
   ARRAY TEXT($at_Components;0)
   COMPONENT LIST($at_Components)
   If (Find in array($at_Components;"4D_Info_Report@")>0)
      // to start the stored procedure creating report every 5 minutes.
      EXECUTE METHOD("aa4D_NP_Schedule_Reports_Server";*;5;0)
   End if
End if