I think you should be able to achieve this with a ThresholdFilter. Make your root logger level TRACE so that it sends all events to all appenders, then put different threshold filters on each appender. The log4j2 manual contains an example.
(EDIT) After understanding the requirements better, I think the SMTP Appender already does what you need: it internally keeps a buffer of the events (512 by default) that preceded the ERROR event that triggered the email. These preceding events will be included in the email.