We consider a static self-gravitating system consisting of perfect fluid with isometries of an $(n-2)$-dimensional maximally symmetric space in Lovelock gravity theory. A straightforward analysis of the time-time component of the equations of motion suggests a generalized mass function. Tolman-Oppenheimer-Volkoff like equation is obtained by using this mass function and gravitational equations. We investigate the maximum entropy principle in Lovelock gravity, and find that this Tolman-Oppenheimer-Volkoff equation can also be deduced from the so called maximum entropy principle which is originally customized for Einstein gravity theory. This investigation manifests a deep connection between gravity and thermodynamics in this generalized gravity theory.