I agree with alophysio. It's Patellofemoral Pain (PFPS).

Had a similar client myself with her experiencing pain during leg extensions in the gym.

On assessment, she had:
- underdeveloped Vastus Medilus Oblique (VMO)
- pain was also eased by applying a medial glide to patella.
- Tight ITB and Weak Glut Med.

Initial Treatment
- Rest from aggravating activity ie no leg extension
in conjunction with
- VMO strengthening ex's (to help realign the patellar tracking. The patella was being pulled laterally and was the root of the pain the client was experiencing)

Additional Tretment
- ITB stetches
- Glut Med strengthening ex's

After a month of REHAB the condition resolved.
However, it's worth noting that the client did not return back to the leg extension ex's for fear of the injury returning.

Best of luck.