Entropy of static spacetimes and microscopic density of states