How should I log time when I fly from one airport to another and back again without landing?
The time from when you started the engine to when you stopped the engine.  It doesn't matter where you went, except for where you specifically need to record the trip details for training requirements purposes, or for your own historical record.  So you'd log the overall trip time, startup to shutdown, adding something like, "CC YYY to XXX back to YYY - no landing at XXX" in the Remarks.