Generally, if the cost is associated with operating the property (real estate taxes, hazard insurance, etc.) they are deducted as expenses, whereas costs associated with purchasing
the property (title search fees, recording fees, etc.) are added to the
property's cost basis, which means they get depreciated.
See https://ttlc.intuit.com/questions/1900982-what-can-i-deduct-when-refinancing-rental-property
Closing costs, including the below are not tax deductible but
may increase the cost basis of your property which may benefit you in the event of
sale.
Attorney
fees in connection with obtaining property
Commissions
State
stamp taxes and transfer taxes
Tax
service fees
Title
policy fees or title insurance
Miscellaneous
abstracts of title, surveys, recording of deed
Appraisal
Fee