Use $.trace.debug("Type your log comments here"); within the xsjs file and then you can see the logs in trace file under the 'Diagnosis File' section for system.
Before that you need to change the 'Database Trace' configuration for XS-Engine under the 'Trace Configuration' Section.