Skip to content

Logging

To assist with development and troubleshooting, FalconPy supports debug logging of all:

  • API endpoints used, including:
    • Operation ID
    • Route
    • HTTP method
  • Headers and Payloads sent
  • API responses and status codes received

FalconPy introduced debug logging functionality in version 1.3.0.

This feature must be explicitly turned on using the debug keyword when creating an instance of a Service Class or the Uber Class.

By default, debug logging is disabled, meaning debug log entries are not generated regardless of the current application debug level.

Logging enablement status is a property of the FalconInterface class, so it is shared by default among Service Classes that are sharing an auth_object via Object Authentication. This feature can be enabled or disabled per Service Class by providing the debug keyword when creating an instance of the desired Service Class.

The following values are redacted from debug logs by default:

  • CrowdStrike API Client IDs
  • CrowdStrike API Client Secrets
  • Bearer tokens
  • Child tenant IDs

Debug log sanitization can be disabled by setting the sanitize_log keyword to False.

⚠️ WARNING ⚠️

Disabling log sanitization will result in the values mentioned above being shown to the console or in the created log file. This setting should be used in production environments with extreme caution and not be left enabled when it is not required.

The following examples demonstrate leveraging debug logging while querying the Hosts service collection.

import logging
from falconpy import Hosts
# Configure our log level.
logging.basicConfig(level=logging.DEBUG)
# Create an instance of the Hosts Service Class, activating debugging when doing so.
hosts = Hosts(client_id=CLIENT_ID,
client_secret=CLIENT_SECRET,
debug=True
)
# Use the Hosts Service Class to call the QueryDevicesByFilterScroll and GetDeviceDetails
# operations to retrieve details for one of the endpoints within our CrowdStrike tenant.
host = hosts.get_device_details(hosts.query_devices_by_filter_scroll(limit=1)["body"]["resources"])
import logging
from falconpy import Hosts
# Configure our log level, message format and debug filename.
logging.basicConfig(format="%(asctime)s %(levelname)s %(message)s",
filename="debug.log",
level=logging.DEBUG
)
# Create an instance of the Hosts Service Class, activating debugging when doing so.
hosts = Hosts(client_id=CLIENT_ID,
client_secret=CLIENT_SECRET,
debug=True
)
# Use the Hosts Service Class to call the QueryDevicesByFilterScroll and GetDeviceDetails
# operations to retrieve details for one of the endpoints within our CrowdStrike tenant.
hosts.get_device_details(hosts.query_devices_by_filter_scroll(limit=1)["body"]["resources"])
import logging
from falconpy import Hosts
# Configure our log level.
logging.basicConfig(level=logging.DEBUG)
# Create an instance of the Hosts Service Class, activating
# debugging and disabling log sanitization when doing so.
hosts = Hosts(client_id=CLIENT_ID,
client_secret=CLIENT_SECRET,
debug=True,
sanitize_log=False
)
# Use the Hosts Service Class to call the QueryDevicesByFilterScroll and GetDeviceDetails
# operations to retrieve details for one of the endpoints within our CrowdStrike tenant.
host = hosts.get_device_details(hosts.query_devices_by_filter_scroll(limit=1)["body"]["resources"])

Page Updated: v1.3.2