Configure logs

How to configure logs to track your activities with Python SDK.

Read time 2 minutes
Last updated 9 months ago

The log files are generated in the following format: UnityCloud_YYYY-MM-DD_HH-MM-SS.log. A new log file is generated for each session, which starts when you call unity_cloud.initialize().

Find the logs

By default Python SDK logs are saved in a UnityCloud folder. To find Python SDK logs, go to AppData > UnityCloud.

Set a custom logging folder path

You can change the location where Python SDK logs are saved. To set a custom logging folder path, follow these steps:

  1. Locate the folder to use and store that path as a string.
  2. Use the unity_cloud.set_logger_path method to edit the location of the folder as a string.
    unity_cloud.set_logger_path(
      path = "path/to/folder"
    )
    unity_cloud.initialize()

For each session started by calling unity_cloud.initialize() a new log file is generated in the most recently set folder path. If the folder does not exist, the folder will be created for the logs. The method accepts both absolute and relative paths.

Add a log entry

To add a log entry to the log file, follow these steps:

  1. Use the unity_cloud.logger.log method and set the log message as a string.
  2. Edit the log message level which defaults to an info log level.
  3. (Optional) Include a custom source for the message. The default value is Unity Cloud Python SDK.
    unity_cloud.initialize()
    unity_cloud.logger.log(
      message = "Test log message",
      level = unity_cloud.logger.log_level.info,
      source = "custom_source"
    )