I'm not sure how deep AppleScript support in Logic is, but that would be the first place to check.
If AppleScript won't do it, then you might try just directly processing MIDI. If you don't need results in real time, then it is easy. Just code up a MIDI processor using your favorite language and library (easy libraries exist for perl and Python. I suspect that good libraries exist for Java, Ruby and other popular languages). You can save individual tracks as MIDI and process them.
Alternately, you can use the Apple IAC bus to create a virtual port. Send MIDI notes from Logic to this port, and then listen to that port with your script. You could setup a second IAC bus to send processed data back to Logic, but be careful of infinite MIDI loops.