-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLogFactory.java
More file actions
45 lines (31 loc) · 1008 Bytes
/
LogFactory.java
File metadata and controls
45 lines (31 loc) · 1008 Bytes
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package org.koushik.javabrains.messenger.resources;
import java.util.Collection;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.ThreadContext;
import com.google.common.collect.LinkedListMultimap;
import com.google.common.collect.Multimap;
public class LogFactory implements Runnable{
private static final Logger logger = LogManager.getLogger(LogFactory.class);
public static Multimap<String, String> map = LinkedListMultimap.create();
public static synchronized void writeLog(String key) {
Collection<String> logKey = map.get(key);
// Iterator<String> it=logKey.iterator();
ThreadContext.put("ROUTINGKEY", "special");
for (String msg : logKey) {
logger.info(msg);
}
ThreadContext.clearAll();
map.removeAll(key);
}
@Override
public void run() {
// TODO Auto-generated method stub
if(map.size()>0){
Collection<String> keys=map.keySet();
for(String key:keys){
writeLog(key);
}
}
}
}