Most judges require two or three letters of recommendation. For most federal judges, at least two of these letters should come from full-time law school faculty.
Judges want evaluations of both your legal ability and your personal qualifications. They value most highly evaluations from people who can (a) compare you meaningfully with many talented potential clerks and (b) comment on what you would be like to work with, both professionally and personally. Judges tend to prefer recommendations from law professors over others (i.e., summer employers) and because most law professors have a good basis for comparison among law students, they often fulfill the first factor very well. If you have worked as a research assistant, taken multiple courses from the same professor, spoken a fair amount in class, taken a small group seminar, visited a professor's office hours, and/or otherwise gotten to know a professor outside of class, by all means ask that professor for a recommendation. On the other hand, if you believe that all a professor would have to say about you substantively is what your final grade was, consider other potential recommenders, such as a legal employer. Glowing, in-depth recommendations are always strategically better than tepid, generic ones. Therefore, a professor who has gotten to know you well and appreciates your talents will often write a stronger, more beneficial letter than a professor who gave you a higher grade but does not know you as well.
If you are a student who has not gotten to know any of your professors well, take the time to meet with some of them now to discuss your background and aspirations. Such a meeting may help the professor write a more "three dimensional" letter for you.