Package biz.paluch.logging.gelf.intern

Examples of biz.paluch.logging.gelf.intern.GelfMessage


public class ContextAwareGelfLogHandler
    extends GelfLogHandler
{
    @Override
    protected GelfMessage createGelfMessage(final LogRecord record) {
        final GelfMessage message = super.createGelfMessage(record);
        final Map<String, String> ctxFields
            = record.getThrown() == null
            ? LoggingContext.getContext()
            : LoggingContext.getLastEnteredContext();
        if (ctxFields != null) {
            final Map<String, String> logFields = message.getAdditonalFields();
            for (Map.Entry<String, String> entry : ctxFields.entrySet()) {
                logFields.put("context." + entry.getKey(), entry.getValue());
            }
        }
        return message;
View Full Code Here


            reportError("Could not send GELF message: " + e.getMessage(), e, ErrorManager.OPEN_FAILURE);
            return;
        }

        try {
            GelfMessage message = createGelfMessage(record);
            if (!message.isValid()) {
                reportError("GELF Message is invalid: " + message.toJson(), null, ErrorManager.WRITE_FAILURE);
            }

            if (null == gelfSender || !gelfSender.sendMessage(message)) {
                reportError("Could not send GELF message", null, ErrorManager.WRITE_FAILURE);
            }
View Full Code Here

        try {
            if (null == gelfSender) {
                gelfSender = GelfSenderFactory.createSender(gelfMessageAssembler, this);
            }

            GelfMessage message = createGelfMessage(event);
            if (!message.isValid()) {
                reportError("GELF Message is invalid: " + message.toJson(), null);
            }

            if (null == gelfSender || !gelfSender.sendMessage(message)) {
                reportError("Could not send GELF message", null);
            }
View Full Code Here

        if (event == null) {
            return;
        }

        try {
            GelfMessage message = createGelfMessage(event);
            if (!message.isValid()) {
                reportError("GELF Message is invalid: " + message.toJson(), null);
            }

            if (null == gelfSender || !gelfSender.sendMessage(message)) {
                reportError("Could not send GELF message", null);
            }
View Full Code Here

            if (null == gelfSender) {
                gelfSender = GelfSenderFactory.createSender(gelfMessageAssembler, this);
            }

            GelfMessage message = createGelfMessage(event);
            if (!message.isValid()) {
                reportError("GELF Message is invalid: " + message.toJson(), null);
            }

            if (null == gelfSender || !gelfSender.sendMessage(message)) {
                reportError("Could not send GELF message", null);
            }
View Full Code Here

    }

    public GelfMessage createGelfMessage(LogEvent logEvent) {

        GelfMessage gelfMessage = super.createGelfMessage(logEvent);
        if (mdcProfiling) {
            GelfUtil.addMdcProfiling(logEvent, gelfMessage);
        }

        return gelfMessage;
View Full Code Here

        String shortMessage = message;
        if (message.length() > MAX_SHORT_MESSAGE_LENGTH) {
            shortMessage = message.substring(0, MAX_SHORT_MESSAGE_LENGTH - 1);
        }

        final GelfMessage gelfMessage = new GelfMessage(shortMessage, message, logEvent.getLogTimestamp(),
                logEvent.getSyslogLevel());

        for (MessageField field : fields) {
            Values values = getValues(logEvent, field);
            if (values == null || !values.hasValues()) {
                continue;
            }

            for (String entryName : values.getEntryNames())
            {
                String value = values.getValue(entryName);
                if(value == null)
                {
                    continue;

                }
                gelfMessage.addField(entryName, value);
            }
        }

        if (extractStackTrace) {
            addStackTrace(logEvent, gelfMessage);
        }

        if (logEvent.getParameters() != null) {
            for (int i = 0; i < logEvent.getParameters().length; i++) {
                Object param = logEvent.getParameters()[i];
                gelfMessage.addField(FIELD_MESSAGE_PARAM + i, "" + param);
            }
        }

        gelfMessage.setHost(getOriginHost());

        if (null != facility) {
            gelfMessage.setFacility(facility);
        }

        gelfMessage.setMaximumMessageSize(maximumMessageSize);
        return gelfMessage;
    }
View Full Code Here

            reportError("Could not send GELF message: " + e.getMessage(), e, ErrorManager.OPEN_FAILURE);
            return;
        }

        try {
            GelfMessage message = createGelfMessage(record);
            if (!message.isValid()) {
                reportError("GELF Message is invalid: " + message.toJson(), null, ErrorManager.WRITE_FAILURE);
                return;
            }

            if (null == gelfSender || !gelfSender.sendMessage(message)) {
                reportError("Could not send GELF message", null, ErrorManager.WRITE_FAILURE);
View Full Code Here

        try {
            if (null == gelfSender) {
                gelfSender = GelfSenderFactory.createSender(gelfMessageAssembler, this);
            }

            GelfMessage message = createGelfMessage(event);
            if (!message.isValid()) {
                reportError("GELF Message is invalid: " + message.toJson(), null);
                return;
            }

            if (null == gelfSender || !gelfSender.sendMessage(message)) {
                reportError("Could not send GELF message", null);
View Full Code Here

        if (event == null) {
            return;
        }

        try {
            GelfMessage message = createGelfMessage(event);
            if (!message.isValid()) {
                reportError("GELF Message is invalid: " + message.toJson(), null);
                return;
            }

            if (null == gelfSender || !gelfSender.sendMessage(message)) {
                reportError("Could not send GELF message", null);
View Full Code Here

TOP

Related Classes of biz.paluch.logging.gelf.intern.GelfMessage

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.