Crate training can take days or weeks, depending on your dog’s age, temperament and past experiences. It’s important to keep two things in mind while crate training: The crate should always be associated with something pleasant and training should take place in a series of small steps. Don’t go too fast.
Place the crate in an area of your house where the family spends a lot of time, such as the family room. Put a soft blanket or bed in the crate. Take the door off or keep it propped open and let the dog explore the crate at their leisure. Some dogs will be naturally curious and start sleeping in the crate right away. If yours isn’t one of them:
After introducing your dog to the crate, begin feeding them their regular meals near the crate. This will create a pleasant association with the crate.
After your dog is eating their regular meals in the crate with no sign of fear or anxiety, you can confine them there for short periods of time while you’re home.
After your dog can spend about 30 minutes in the crate without becoming anxious or afraid, you can begin leaving them crated for short periods when you leave the house.
When you return home, don’t reward your dog for excited behavior by responding to them in an enthusiastic way. Keep arrivals low-key to avoid increasing their anxiety over when you will return. Continue to crate your dog for short periods from time to time when you’re home so they don’t associate crating with being left alone.
Put your dog in the crate using your regular command and a treat. Initially, it may be a good idea to put the crate in your bedroom or nearby in a hallway, especially if you have a puppy. Puppies often need to go outside to eliminate during the night and you’ll want to be able to hear your puppy when they whine to be let outside. Older dogs should also initially be kept nearby so they don’t associate the crate with social isolation.
Once your dog is sleeping comfortably through the night with the crate near you, you can begin to gradually move it to the location you prefer, although time spent with your dog—even sleep time—is a chance to strengthen the bond between you and your pet.
Whining: If your dog whines or cries while in the crate at night, it may be difficult to decide whether they’re whining to be let out of the crate, or whether they need to be let outside to eliminate. If you’ve followed the training procedures outlined above, then your dog hasn’t been rewarded for whining in the past by being released from their crate. If that is the case, try to ignore the whining. If your dog is just testing you, they’ll probably stop whining soon. Never punish them for whining.
If the whining continues after you’ve ignored them for several minutes, use the phrase they associate with going outside to eliminate. If they respond and become excited, take them outside. This should be a trip with a purpose, not play time. Stand in one spot in your yard where they normally go to the bathroom and wait. If you’re convinced that your dog doesn’t need to eliminate, the best response is to ignore them until they stop whining. If you’ve progressed gradually through the training steps and haven’t done too much too fast, you’ll be less likely to encounter this problem. If the problem becomes unmanageable, you may need to start the crate training process over again.
Separation anxiety: Attempting to use the crate as a remedy for separation anxiety won’t solve the problem. A crate may prevent your dog from being destructive, but they may get injured in an attempt to escape. Separation anxiety problems can only be resolved with counterconditioning and desensitization procedures. You may want to consult a professional animal-behavior specialist for help.
Source: https://www.humanesociety.org/resources/crate-training-101