org.graylog2.logging.GelfLogRecord Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of gelfj Show documentation
Show all versions of gelfj Show documentation
GELF implementation in Java and log4j appender without any dependencies.
The newest version!
package org.graylog2.logging;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.LogRecord;
public class GelfLogRecord extends LogRecord {
private static final long serialVersionUID = 43242341L;
private Map fields;
public GelfLogRecord(Level level, String msg) {
super(level, msg);
}
public void setField(String key, Object value) {
if (fields == null) {
fields = new LinkedHashMap();
}
fields.put(key, value);
}
public Object getField(String key) {
return fields != null ? fields.get(key) : null;
}
public Map getFields() {
if (fields == null) {
return Collections.emptyMap();
}
return Collections.unmodifiableMap(fields);
}
}