Simultaneous Measurement of Local Gain and Electron Density in X-ray Lasers