Package org.apache.logging.log4j.message

Examples of org.apache.logging.log4j.message.Message


     * @param params parameters to the message.
     */
    @Override
    public void log(final Level level, final Marker marker, final String message, final Object... params) {
        if (isEnabled(level, marker, message, params)) {
            final Message msg = messageFactory.newMessage(message, params);
            log(marker, FQCN, level, msg, msg.getThrowable());
        }
    }
View Full Code Here


     * @param params parameters to the message.
     */
    @Override
    public void log(final Level level, final String message, final Object... params) {
        if (isEnabled(level, null, message, params)) {
            final Message msg = messageFactory.newMessage(message, params);
            log(null, FQCN, level, msg, msg.getThrowable());
        }
    }
View Full Code Here

     * @param params  parameters to the message.
     */
    @Override
    public void trace(final Marker marker, final String message, final Object... params) {
        if (isEnabled(Level.TRACE, marker, message, params)) {
            final Message msg = messageFactory.newMessage(message, params);
            log(marker, FQCN, Level.TRACE, msg, msg.getThrowable());
        }
    }
View Full Code Here

     * @param params  parameters to the message.
     */
    @Override
    public void trace(final String message, final Object... params) {
        if (isEnabled(Level.TRACE, null, message, params)) {
            final Message msg = messageFactory.newMessage(message, params);
            log(null, FQCN, Level.TRACE, msg, msg.getThrowable());
        }
    }
View Full Code Here

     * @param params  parameters to the message.
     */
    @Override
    public void warn(final Marker marker, final String message, final Object... params) {
        if (isEnabled(Level.WARN, marker, message, params)) {
            final Message msg = messageFactory.newMessage(message, params);
            log(marker, FQCN, Level.WARN, msg, msg.getThrowable());
        }
    }
View Full Code Here

     * @param params  parameters to the message.
     */
    @Override
    public void warn(final String message, final Object... params) {
        if (isEnabled(Level.WARN, null, message, params)) {
            final Message msg = messageFactory.newMessage(message, params);
            log(null, FQCN, Level.WARN, msg, msg.getThrowable());
        }
    }
View Full Code Here

     * used to create a new logging event.
     * @return The LogEvent after rewriting.
     */
    @Override
    public LogEvent rewrite(final LogEvent source) {
        final Message msg = source.getMessage();
        if (msg == null || !(msg instanceof MapMessage)) {
            return source;
        }

        final Map<String, String> newMap = new HashMap<String, String>(((MapMessage) msg).getData());
View Full Code Here

     * @param event The LogEvent.
     * @return The RFC 5424 String representation of the LogEvent.
     */
    @Override
    public String toSerializable(final LogEvent event) {
        final Message msg = event.getMessage();
        final boolean isStructured = msg instanceof StructuredDataMessage;
        final StringBuilder buf = new StringBuilder();

        buf.append("<");
        buf.append(Priority.getPriority(facility, event.getLevel()));
        buf.append(">1 ");
        buf.append(computeTimeStampString(event.getMillis()));
        buf.append(' ');
        buf.append(localHostName);
        buf.append(' ');
        if (appName != null) {
            buf.append(appName);
        } else if (configName != null) {
            buf.append(configName);
        } else {
            buf.append("-");
        }
        buf.append(" ");
        buf.append(getProcId());
        buf.append(" ");
        final String type = isStructured ? ((StructuredDataMessage) msg).getType() : null;
        if (type != null) {
            buf.append(type);
        } else if (messageId != null) {
            buf.append(messageId);
        } else {
            buf.append("-");
        }
        buf.append(" ");
        if (isStructured || includeMDC) {
            StructuredDataId id = null;
            String text;
            if (isStructured) {
                final StructuredDataMessage data = (StructuredDataMessage) msg;
                final Map<String, String> map = data.getData();
                id = data.getId();
                formatStructuredElement(id, eventPrefix, map, buf, noopChecker);
                text = data.getFormat();
            } else {
                text = msg.getFormattedMessage();
            }
            if (includeMDC) {
                Map<String, String> map = event.getContextMap();
                if (mdcRequired != null) {
                    checkRequired(map);
                }
                final int ein = id == null || id.getEnterpriseNumber() < 0 ?
                    enterpriseNumber : id.getEnterpriseNumber();
                final StructuredDataId mdcSDID = new StructuredDataId(mdcId, ein, null, null);
                formatStructuredElement(mdcSDID, mdcPrefix, map, buf, checker);
            }
            if (text != null && text.length() > 0) {
                buf.append(" ").append(escapeNewlines(text, escapeNewLine));
            }
        } else {
            buf.append("- ");
            buf.append(escapeNewlines(msg.getFormattedMessage(), escapeNewLine));
        }
        if (formatters != null && event.getThrown() != null) {
            final StringBuilder exception = new StringBuilder("\n");
            for (final PatternFormatter formatter : formatters) {
                formatter.format(event, exception);
View Full Code Here

        buf.append(Transform.escapeTags(String.valueOf(event.getLevel())));
        buf.append("\" thread=\"");
        buf.append(Transform.escapeTags(event.getThreadName()));
        buf.append("\">\r\n");

        final Message msg = event.getMessage();
        if (msg != null) {
            boolean xmlSupported = false;
            if (msg instanceof MultiformatMessage) {
                final String[] formats = ((MultiformatMessage) msg).getFormats();
                for (final String format : formats) {
View Full Code Here

    }


    public void forcedLog(final String fqcn, final Priority level, final Object message, final Throwable t) {
        final org.apache.logging.log4j.Level lvl = org.apache.logging.log4j.Level.toLevel(level.toString());
        final Message msg = message instanceof Message ? (Message) message : new ObjectMessage(message);
        logger.log(null, fqcn, lvl, msg, t);
    }
View Full Code Here

TOP

Related Classes of org.apache.logging.log4j.message.Message

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.