Before running down the rabbit hole of possibilities and numerous error codes, stored for retrieval by regular scanners while hidden errors are only decoded by Subaru's SSM scan tool, repair/mobile techs/diyers spending more for moderate to high end scan tools, is your battery original or on its second one and haven't tested it yet? And are battery connections clean and free of corrosion, including main grounds to chassis and engine block? And after testing your battery, have the alternator tested too. Most auto stores selling car batteries can test batteries and alternators on the car (Autozone is one). If testing at home with a multimeter, some things to know.
Standing battery voltage should be around 12.5vdc. Engine idling, serpentine did belt tight, alternator output should be around 14.5vdc. Voltage below 13vdc suggests either a loose drive belt or faulty alternator.
Average battery life is between 3-5 years. More money buys more battery life and vice versa.