The periodic comet 46P/Wirtanen made a favorable apparition in late 2018 as it was very close to the Earth (0.077 AU) near its perihelion (1.055 AU). We present analysis of X-ray and optical/UV data from the Neil Gehrels-Swift Observatory (XRT and UVOT) and the Chandra X-ray Observatory (ACIS) for three epochs, pre-, at, and post-perihelion. Clear evidence of charge exchange emission from the interaction of solar wind ions with the neutrals in the comet coma is observed. Taking advantage of near-simultaneous and multiple observations at different epochs (Swift/XRT and Chandra/ACIS), it was possible to characterize the X-ray flux and spectral shape overcoming problems related to the intrinsic variability of the emission and, using combined optical and UV measurements (Swift/UVOT), to characterize the water production rate. Results indicate that the comet has a very different morphology in X-ray and UV showing an offset caused by the collisional depth of the solar wind penetrating the coma. X-ray flux variations with time are well-correlated with solar wind measurements performed by the ACE and SOHO observatories located at the first Lagrangian point, properly propagated to the comet location. This confirms that charge exchange emission is a reliable probe of local space weather.