Bonjour,
J'ai rélèvé toutes lignes contenant une erreur dans un fichier log d'un serveur, pui j'ai récupéré ces lignes dans un arrayList. Maintenant il faut que ces lignes soient le corps d'un mail a envoyé à l'admin du serveur.
Voici la partie du code qui envoi l'email:
Le problème c'est que les lignes vont être envoyées une à une au lieu d'être envoyée en bloc de lignes puisque ce programme sera éxécuté toutes les 15 minutes. Voici c'est que j'ai e output:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25 while ((line = r.readLine()) != null) { Matcher m = patt.matcher(line); while (m.find()) { String res=m.group(1); String res1=m.group(0); Date date = formatter.parse(res1); if((date.after(dtres)) && (date.before(dt))){ System.out.println(res1); list.add(new String(res1)); StringBuilder b = new StringBuilder(); for(Object carrier :list){ b.append(carrier).append("\n"); } //list.clear(); String liststr = b.toString(); envoiMail(liststr); } } }
2019-03-21 14:01:05,165 [9] ERROR BSAmonitor.Service1 [(null)] - Input string was not in a correct format.
Sent message successfully....
2019-03-21 14:10:05,165 [10] ERROR BSAmonitor.Service1 [(null)] - Input string was not in a correct format.
Sent message successfully....
2019-03-21 14:26:05,165 [10] ERROR BSAmonitor.Service1 [(null)] - Input string was not in a correct format.
Sent message successfully....
2019-03-21 14:27:05,165 [10] ERROR BSAmonitor.Service1 [(null)] - Input string was not in a correct format.
Sent message successfully....
2019-03-21 14:50:05,165 [10] ERROR BSAmonitor.Service1 [(null)] - Input string was not in a correct format.
Sent message successfully....
Partager