You're missing some important details like which PLC you are using and how often the data needs to be logged (every scan, every second, every minute, etc)
If you are using a 1500, you can use the OPC UA server in the PLC to connect to an OPC UA Client in Excel. See this application example.
https://support.industry.siemens.com/cs/us/en/view/109748892
If you're using a 1200 or a 1500, then you can take a trace, load the measurements into Portal, and then export the data points to excel. However, the PLC does have a max amount of data that it can record, so this is very update rate dependant. If you need data every scan, it'll only last for a few sec. If you need data once a minute, it might last an hour.