You have an electric guitar, you have learned how to play it, you have written a wonderful song, and now you just have to record it. But how?
The traditional way
Don't record the guitar, record the amp. The common way to do that is by placing a dynamic microphone in front of the speaker cabinet, only a couple of inches away from the speaker (or one of the speakers). When you move back the microphone, it will capture the sound of the room. To get a bright sound, the mic should point towards the center of the speaker. The more you move away from the speaker center, the more the sound turns heavier and richer in low frequencies. You will surely find a good compromise playing with both the position and the direction of the mic. For example, you could place the mic on the border of the transducer pointing towards the center of the cone.
The microphones available on the market are very different, so the sound can change a lot depending on the model you choose, especially with distorted guitars. Don't hesitate to put several microphones in front of the speaker to pick the best one out. Moreover, you can always use them all while recording and mix them later during mixdown. This recording process is often used to fatten the sound of the instrument.
You can also use ribbon mics like the Royer R121 or the BeyerDynamic M160 and get very good results, especially with distortion guitars that tend to have a sharper sound. Ribbon mics soften the sound.
If the room acoustics are worth it, you can place a condenser mic a couple of meters away from the amp to give some air to the recording and get a more authentic and natural sound.
The silent way
In case your neighbors don't like "noisey" guitars, you can always use a silent recording process. The easiest way is to connect your guitar directly to the instrument input of your digital audio interface, or to a DI-box if your interface has no Hi-Z input. Afterwards, use an amp simulation in your sequencer (Guitar Rig, LePou, Overloud TH2, Peavey Revalver or IK Amplitube) to process the sound of your guitar. The advantage of this method is that you can change the settings on your virtual amp after recording, which is quite convenient!
You can also use a hardware amp modeling system (rack, footboard or desktop) connected to the line input of your audio interface. This solution comes in handy when playing live on stage. Check out what Tech21, Line 6, Vox or AVID have to offer. And if you can't imagine playing without your guitar amp, there are other solutions. For example, French manufacturer Two Notes offers products that simulate the speaker and the mic so that you can record your amp plus your stompboxes... in silence!