If you start/stop Appium server from code, then the output will be displayed in console. After that you can use any standard method to print this console in text file.
Example, if you are using maven, then you can use Run -> Run Configurations… -> -> Common tab and then set output file location.