According to Ampere's circuital law, integral of magnetic field along a closed curve equals the sum of all electric currents passing through the cross section of the closed curve times permeability.∮→I.→dl=μoIenclosed
To find magnetic field inside a long straight wire of cross-sectional area a, refer the attached figure. Magnetic field lines in this configuration forms concentric circles centered at O, the axis of the cylindrical wire. Hence, it is the preferred path of the Amperian Loop.
Consider an Amperian Loop of radius a<r as shown in the figure.
Current enclosed in a cross-section area πa2 is I
Then, Current enclosed in a cross-section area πr2 is Ienclosed=r2a2I
Taking the magnetic field integral along the loop, we get
∮→B⋅→dl=B×2πr
Using Ampere's Law, we get
B×2πr=μoIr2a2
B=μorI2πa2
Direction of magnetic field can be found using Fleming's Right hand thumb rule.