If you are looking to override a Portlet MVC Action Command then you are at correct place. I'm going to override LoginMVCActionCommand in this example. I'm writing the steps here. Before starting code, you should read the following blogs.
I changed the default annotation and the default code. Let's understand it.
Check the component annotation. I've kept the values that we found from gogo shell. The properties let know the OSGI runtime that which action command is overriden. I've used the service.ranking:Integer=161 here. This property overrides the service.id and used to tell the OSGi runtime which service to use, in cases where there are multiple components registering the same service, with the same properties. The higher the integer you specify here, the more weight your component carries. Therefore I used 161 to override my default value 160.
I've used @Reference annotation to target the original LoginMVCActionCommand object so that I can use the default functionality along with my code. Please notice, I've used the (component.name=com.liferay.login.web.internal.portlet.action.LoginMVCActionCommand) inside the annotation to avoide the circular reference detection issue.
You can write your custom code in doProcessAction method.
Deploy the code and you will see your logs in log window.