Using Logging in the Spinnaker SDK

Download PDF - Spinnaker-Logging

File Logging—Logging Levels and Configuration Files

Spinnaker supports five levels of logging:

  • Error—failures that are non-recoverable (this is the default level)
  • Warning—failures that are recoverable without user intervention
  • Notice—information about events such as camera arrival or disconnect, camera initialize, camera start/stop, or modification of a feature
  • Info—information about recurring events that are generated with every image
  • Debug—information that can be used to troubleshoot the system

You can define the logging level that you want to monitor. Levels are inclusive, that is, if you monitor debug level error, you also monitor all logging levels above it.

Spinnaker generates four log files:

Log FileDescriptionConfiguration File
GenTL.log Transport layer Log4cpp.gentl.property
Spinnaker.log Spinnaker SDK and GenICam Log4cpp.spinnaker.property
SpinnakerNET.log Spinnaker GUI Log4cpp.spinnakernet.property
spinview.txt Spinnaker evaluation application SpinView SpinView_WPF.config

Spinnaker log files are stored in: 
C:\ProgramData\Spinnaker\Logs

Log files are configured with property files located in: 
C:\Program Files\Point Grey Research\Spinnaker\bin64\vs2013\

If you are using a different Visual Studio, adjust the path accordingly to \vs2015\, or \vs2010\.

By default, the logging level is ERROR, except for the SpinView logging pane which defaults to NOTICE.

To change the logging level, edit the configuration file. For example, to change from ERROR to DEBUG:

Change:

log4cpp.category.SpinnakerCategory=ERROR, SpinnakerCategory

To:

log4cpp.category.SpinnakerCategory=DEBUG, SpinnakerCategory

API Logging—Add Custom Logging to your Application

Note: When writing your own application that requires log files, ensure that the executable or include path contains the Log4cpp.[Node Level].property file.

You can use the Spinnaker API to add custom logging to your application.

1. Define your customized logging function.

class LoggingEventHandler : public LoggingEvent
{
   //This function displays readily available logging information
   void OnLogEvent(LoggingEventDataPtr loggingEventDataPtr)
   {
    //Insert custom logging function
   }
};

2. Register your customized logging function.

system->RegisterLoggingEvent(*loggingEventHandler);

3. Set your logging priority level.

system->SetLoggingEventPriorityLevel(LOG_LEVEL_INFO);

There is a source code example in Spinnaker.

Logging.cpp shows how to create a handler to access logging events.

The example creates a user-defined class, LoggingEventHandler, that inherits from the Spinnaker class, LoggingEvent. The child class allows the user to define any properties, parameters, and the event itself while LoggingEvent allows the child class to appropriately interface with the Spinnaker SDK.

Using Logs to Troubleshoot Issues

Example: Camera fails to enumerate in SpinView

In SpinView, the camera is not detected. The SpinView logging pane has no messages about the camera, because it cannot detect it.

1. Configure the GenTL.log to use the debug level of logging.

log4cpp.category.GenTLCategory=DEBUG, GenTLCategory

2. Connect the camera again.

3. View the GenTL.log from C:\ProgramData\Spinnaker\Logs.

...
[DEBUG] 2017-02-07 08:23:32,069 [1904] Entering HAL_UsbCheckDriver()
[DEBUG] 2017-02-07 08:23:32,069 [1904] HAL_UsbCheckDriver: Incompatible driver detected
[DEBUG] 2017-02-07 08:23:32,069 [1904] Leaving HAL_UsbCheckDriver()
...

Using the debug log, you can see that an incompatible driver is preventing the camera from being detected.

Related Articles