To achieve an ultrahigh resolution of a beamline for soft X-rays at the Taiwan Photon Source (TPS), the profile of a highly precise grating is required at various curvatures. The slope error could be decreased to 0.1 μrad (rms) at a thermal load with a specially designed bender having 25 actuators. In the meantime, a long-trace profiler (LTP) was developed in situ to monitor the grating profile under a thermal load; it consists of a moving optical head, an air-bearing slide, an adjustable stand, and a glass viewport on the vacuum chamber. In the design of this system, a test chamber with an interior mirror was designed to simulate the chamber in the beamline. To prevent an error induced from a commercial viewport, a precision glass viewport (150CF, flatness 1/150 λ rms at 632.8 nm) was designed. The error induced from the slope error of the glass surface and the vacuum deformation was also simulated. The performance of the optical head of the LTP in situ (ISLTP) has been tested in the metrology laboratory. The sources of error of this LTP including the linearity and the glass viewport were corrected after the measurement. For the beamline measurement, an optical head was mounted outside the vacuum chamber; the measuring beam passed through the glass viewport to measure the grating profile in vacuum. The measurement of the LTP after correction of the above errors yielded a precision about 0.2 μrad (rms). In a preliminary test, an ISLTP was used to measure the grating profile at soft X-ray beamline TPS45A. The measured profile was for the bending mechanism to optimize the slope profile. From the measured energy spectrum, the slope error of the grating was estimated with software for optical simulation to be about 0.3 μrad (rms), consistent with our estimate of the ISLTP. In the future, it will be used to monitor the thermal bump under a large thermal load. In addition, an ISLTP was used to monitor the properties of optical elements-the twist and radius in the beamline during the installation phase.