To confess your sins to your pastor makes no sense to worldly logic, but it is another example of worldly wisdom falling short. It is a positive and healthy thing for  Christians to do.