IdentityManager im = (IdentityManager)CoreSpringFactory.getBean("core.id.IdentityManager");
Identity ident = im.findIdentityByName(username);
//if null, user may crashed befor getting a valid session, try with guest user instead
if (ident == null) ident = im.findIdentityByName("guest");
Emailer emailer = new Emailer(ident, true);
LogFile lf = new LogFile();
Date d = new Date();
SimpleDateFormat year = new SimpleDateFormat("yyyy");
SimpleDateFormat month = new SimpleDateFormat("MM");
SimpleDateFormat day = new SimpleDateFormat("dd");
String errorNum = parseErrorNumber(errorNr);
Collection logFileEntries = lf.getError(errorNum, day.format(d), month.format(d), year.format(d), false);
StringBuilder out = new StringBuilder();
if (logFileEntries != null) {
for (Iterator iter = logFileEntries.iterator(); iter.hasNext();) {
out.append((String) iter.next());
}