Network lifetime maximization is a critical problem for long-term data collection in wireless sensor networks. For large-scale networks, distributed and self-adaptive solutions are highly desired. In this paper, we investigate how to optimize the network lifetime by a localized method. Specifically, the network lifetime maximization problem is converted to a localized cost-balancing problem with an appropriately designed local cost function. A distributed algorithm,
, which adopts the idea of adaptive probabilistic routing, is proposed to construct a localized and self-adaptive optimal solution to maximize the network lifetime. We analyze LocalWiser in both static and dynamic networks. In static networks, it is formally proved that 1) LocalWiser can reach a stable status; 2) the stable status is optimal for maximizing the network lifetime. In dynamic networks, our extensive simulations illustrate that LocalWiser can converge to the optimal status rapidly for the network topology and flow dynamics.