You may be wondering what can be done to stop dogs from escaping. Well here is a good article if you want to read more about it. What I think though, is that for short or temporary periods it is better to use a crate than have an accident. That being said, the cage must meet certain rules to be legal: for starters, no puppy less than 6 months should be in it, for the other older dogs the leash must have a minimum length of 3 meters, be equipped at the end with a good fastener so that the leash does not twist each time the dog moves.
The bottom of the crate must be good enough to avoid becoming dirty. The dog must have an enclosure that is sufficiently spacious and aligned correctly to the wind and therefore to the weather. The shelter must be warm and raised from the ground to stop water from getting in.
Lastly, the dog must have a bowl of water accessible at all times but it can not be left without being held down with twist ties. I repeat once again that there are probably other ways to prevent your dog from leaving, especially for a long time.
For the naughty type of dogs, the two other solutions that I will present to you seem to work ok. The first is to simply build a fairly large kennel with a built in a hard floor, with tooth-guarded and walls that cant be climbed, some types of roofs are better than others too.
The electric fence (there are different models like the cow fence, invisible perimeter fence or the special one made for dogs. As far as I know, after seeing dozens, I only know one case of a dog scaling one of these.
The disadvantage of a fence is the price can put off some. With this being said, compared to the huge amount of damage that the dog can cause, it is a good investment). I already hear people saying that this might be not very nice for the dog. I disagree because the ultimate thing that will hurt your dog is to get out so why not prevent it in the first place.