Hi there,
Stupid question for a friday!
How do I get the logger in an app to print to the sg desktop log? eg the app.py in the starter-app?
I’ve tried self.logger.info("blah") self.engine.logger.info("blah")
Neither produce any output.
I’ve also tried a standard logger = sgtk.LogManager.get_logger(__name__) method… but no joy.
Is this the old “desktop ate my logs” issue rearing its head?
That is curious, are you able to run engine.logger.info("blah") from the Python Console in SG Desktop and have it appear in your logs?
I just tried that here and it worked on my side, also what OS are you on, just in case that makes a difference?
Thanks Philip,
Yes, I can get the logger to work from the Python console no problem.
It’s definitely not firing from the app.py at the top level of the starter-app.
I’ve also tried:-
self._log = sgtk.platform.get_logger(__name__)
self._log.info("################# TEST ########################")
But nothing is showing up either.
I assume logs from app app.py calls should appear after the core engine_init logs have appeared?
I’m seeing the logs from the engine when the app calls engine.register_command, so the code is being run without error (the log calls are prior to the engine.register_command call). The engine is also, by implication, up and running, so self.engine.logger.info should fire logs to the console I would have assumed?
OK yeah quite a lot is out of date there, we did put a fix in for logging not all that long ago so updating hopefully should fix that for you. I can’t remember exactly which component it was in, I think tk-desktop.
For comparison here is my about box:
Hm, I don’t think I’ve ever seen this work. The desktop console only seems to be printing up to app launch. The rest is usually in the dcc’s own console, and also the corresponding log file.