My iPhone 4 is not charging but it detects the charger?

Well, my iPhone 4 is not charging but when i switch it off and plug the charger, the apple logo appears and it turn on. When it turn on it does not charge. Please can anyone tell me what to do.

Three possibilities:

1, It's a bad battery.
2, It's a bad charger.
3, There's low current coming from your outlet.

Sounds like you need to buy a new charger. Is your charger a deferent brand then apple?