The paper reports on the optimization process of the soft X-ray pulse height analyzer (PHA) installed on the Wendelstein 7-X (W7-X) stellarator. It is a 3-channel system that records X-ray spectra in the range from 0.6 to 19.6 keV. X-ray spectra, with temporal and spatial resolution of 100 ms and 2.5 cm (depending on selected slit sizes), respectively, are line integrated along a line-of-sight that crosses near to the plasma center. In the second W7-X operation phase with a carbon test divertor unit, light impurities, e.g., carbon and oxygen, were observed as well as mid-to high-Z elements, e.g., sulfur, chlorine, chromium, manganese, iron and nickel. In addition, X-ray lines from several tracer elements have been observed after laser blow-off injection of different impurities, e.g., silicon, titanium and iron, and during discharges with prefill or gas puff of neon or argon. These measurements were achieved by optimizing light absorber-foil selection, which defines the detected energy range, and remotely controlled pinhole size, which defines photon flux. The identification of X-ray lines was confirmed by other spectroscopic diagnostics, e.g., by the High-Efficiency XUV Overview Spectrometer, HEXOS and high-resolution X-ray imaging spectrometer, HR-XIS.