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.
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
State stamp taxes and transfer taxes
Tax service fees
Title policy fees or title insurance
Miscellaneous abstracts of title, surveys, recording of deed