Hi,
Here are a few suggestions:
1) Confirm your MIDI controller channel and make sure Logic is also set to receive that channel on the Track ( Track Inspector : Midi Channel ( All or specific )
2) What settings are you changing in the MIDI Preferences?
3) ( Long one ) There have been lots of issues with legacy MIDI drivers and MIDI 5 pin DIN interfaces with the move to Catalina ( 64bit ) and Big Sur. Check with your MIDI vendor support and confirm support for Big Sur for your device(s). This is a critical first step since the onus is on the Third party vendor to support Big Sur OSX and many are lagging. I have seen an uptick with Midi Issue with since Logic 10.5 ad here are my observations and tips:
1) Make sure ALL drivers are current and supported (Critical )
2) No USB hubs in the data chain to MIDI devices
3) Always start from a cold boot, no wake from sleep
4) No changing of accounts ( logout / login )
5) If using a combination of USB and a MIDI multi-port interface leave Port A open on the multi-port.
These steps solved about 99% of my ( and fellow musicians ) MIDI issues.
Hope this helps
( If this was helpful please mark as such or mark as solved if that is the case )