Tools you will need:
Security Torx Screwdriver set
Multimeter (I used Techshop's Rigol DM3058 Multimeter, but a handheld will work just fine).
Mass Air Flow Cleaner (available at your local autoparts store)
The Mass Air Flow Sensor sits within your cars air hose and lets the cars computer know how much air is flowing into the engine. This allows the computer to adjust to achieve an appropriate ratio of air and fuel (and spark) in a fuel injection engine.
On a 1999 Subaru Forester, the MAF Sensor is located on the passenger side, on the air hose that comes off of the air filter. The one in the picture below has a blue stripe on the top.
Step 1: Open Air Filter Cover
2) Lift up on the cover.
Step 2: Unplug MAF Sensor
Step 3: Remove MAF Sensor
Step 4: Clean MAF
If this wire gets dirty or corroded, its resistance will shift out of spec and the computer won't have an accurate gauge on the volume of air flow.
First, clean the wire using some Mass Air Flow Cleaner (available at your local autoparts store). Simply spray about ten bursts onto the wire (hidden in the end of the MAF Sensor) and allow it to air dry. DO NOT WIPE. Wiping the wire may contaminate it.
Step 5: Check MAF
You are testing the resistance of these terminals to see if they are within the appropriate range.
Terminals 1, 2 and 4 should have approximately 1 mega-ohm of resistance to ground. Terminal 3 should have zero ohms resistance to ground.
If any of the terminals are outside of this range, you will want to replace the MAF Sensor.
The sensor itself costs about $50-$70 to replace. However, they may try to sell you the whole housing etc... which will run you more than $350.
Step 6: Re-install Your Cleaned MAF Sensor (or Your Replacement MAF Sensor)
Screw into place using the security torx screws.
Plug in MAF Sensor Plug.
Close and latch air filter housing.