All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.graylog2.logging.GelfLogRecord Maven / Gradle / Ivy

Go to download

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);
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy