Java tutorial
//package com.java2s; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.HashMap; import java.util.HashSet; import java.util.Set; import java.util.Map; public class Main { /** log4j logger */ private static org.apache.log4j.Logger log = org.apache.log4j.Logger.getLogger("Missed"); private static Map<String, Set<String>> _logged_msgs = new HashMap<String, Set<String>>(); private static final SimpleDateFormat _logged_fmt = new SimpleDateFormat("dd/MM/yyyy"); final private static void log_info(String message) { if (_already_logged(message)) return; log.info(message); } final static private boolean _already_logged(String message) { String today = _logged_fmt.format(Calendar.getInstance().getTime()); if (!_logged_msgs.containsKey(today)) { _logged_msgs.clear(); _logged_msgs.put(today, new HashSet<String>()); } Set<String> msgs = _logged_msgs.get(today); if (msgs != null && msgs.contains(message)) { return true; } if (msgs != null) { msgs.add(message); } return false; } }