Centralised log file for all users running an app

We have an ingest app based on tk-desktop engine. Currently, all logs are handled in the engine logging instance.
Instead of having those logs in each user’s own log files, we would like to set it up in a centralised log file for the app.

Is it possible to set this up within Shotgun log module?

Thanks for your help! Cheers!

1 Like

OK, so I’ve figured this out:

import logging
import sgtk

# Define a file handler and initialise it with sgtk
file_handler = logging.FileHandler("/path/to/my/wonderful/file.log", mode="a", encoding=None, delay=False)
sgtk.log.LogManager().initialize_custom_handler(file_handler)

logger = sgtk.platform.get_logger("my-custom-app")


logger.info("It works!")

This way, you’ll keep both. Standard toolkit logger and a centralised log file for this app :slight_smile:

2 Likes