Collision isn't detected between two obects

I have two 2D objects that I have given a rigid body 2D and box collider 2D. When I play the scene I can see the two objects collide but the collision isn’t seen in the console when I have

function OnCollisionEnter(collision) {
		Debug.Log("colliding");

	}

Even though the collision is working, I need one of the object’s script to be able to tell if the objects are colliding because I want the collision to trigger something such as health decreasing.

That’s because you used the 3D method. Use OnCollisionEnter2D() instead.