The anisotropic magnetic properties of Sr$_2$IrO$_4$ are investigated, using longitudinal and torque magnetometry. The critical scaling across $T_c$ of the longitudinal magnetization is the one expected for the 2D XY universality class. Modeling the torque for a magnetic field in the basal-plane, and taking into account all in-plane and out-of-plane magnetic couplings, we derive the effective 4-fold anisotropy $K_4 approx$ 1 10$^5$ erg mole$^{-1}$. Although larger than for the cuprates, it is found too small to account for a significant departure from the isotropic 2D XY model. The in-plane torque also allows us to put an upper bound for the anisotropy of a field-induced shift of the antiferromagnetic ordering temperature.