Package biz.paluch.logging.gelf.intern

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


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

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

        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

                }
            }
        }

        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

    }

    public GelfMessage createGelfMessage(MdcLogEvent logEvent) {

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

        for (String mdcField : mdcFields) {
            Object value = MDC.get(mdcField);
            if (value != null && !value.toString().equals("")) {
                gelfMessage.addField(mdcField, value.toString());
            }
        }

        return gelfMessage;
    }
View Full Code Here

                }
            }
        }

        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

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

        SimpleDateFormat dateFormat = new SimpleDateFormat(timestampPattern);
        gelfMessage.addField(FIELD_TIME, dateFormat.format(new Date(logEvent.getLogTimestamp())));
        gelfMessage.addField(FIELD_SEVERITY, logEvent.getLevelName());

        gelfMessage.addField(FIELD_THREAD, logEvent.getThreadName());
        gelfMessage.addField(FIELD_SOURCE_CLASS_NAME, logEvent.getSourceClassName());

        String simpleClassName = logEvent.getSourceClassName();
        int index = simpleClassName.lastIndexOf('.');
        if (index != -1) {
            simpleClassName = simpleClassName.substring(index + 1);
        }

        gelfMessage.addField(FIELD_SOURCE_SIMPLE_CLASS_NAME, simpleClassName);
        gelfMessage.addField(FIELD_SOURCE_METHOD_NAME, logEvent.getSourceMethodName());

        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.addField(FIELD_SERVER, getOriginHost());
        gelfMessage.setHost(getOriginHost());

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

        for (Map.Entry<String, String> entry : fields.entrySet()) {
            gelfMessage.addField(entry.getKey(), entry.getValue());
        }

        gelfMessage.setMaximumMessageSize(maximumMessageSize);
        return gelfMessage;
    }
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 (null == gelfSender) {
                RuntimeContainer.initialize(this);
                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

            }

            fields.put(entry.getKey(), entry.getValue().toString());
        }

        GelfMessage gelfMessage = GelfMessageBuilder.newInstance().withJavaTimestamp(System.currentTimeMillis())
                .withFields(fields).build();
        submit(gelfMessage);
    }
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.