001/*
002 * Licensed to the Apache Software Foundation (ASF) under one or more
003 * contributor license agreements. See the NOTICE file distributed with
004 * this work for additional information regarding copyright ownership.
005 * The ASF licenses this file to You under the Apache license, Version 2.0
006 * (the "License"); you may not use this file except in compliance with
007 * the License. You may obtain a copy of the License at
008 *
009 *      http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the license for the specific language governing permissions and
015 * limitations under the license.
016 */
017
018package org.apache.logging.log4j.core.layout;
019
020import org.apache.logging.log4j.core.Layout;
021import org.apache.logging.log4j.core.LogEvent;
022import org.apache.logging.log4j.core.config.Configuration;
023import org.apache.logging.log4j.core.config.Node;
024import org.apache.logging.log4j.core.config.plugins.Plugin;
025import org.apache.logging.log4j.core.config.plugins.PluginFactory;
026import org.apache.logging.log4j.message.Message;
027
028/**
029 * Formats a {@link LogEvent} in its {@link Message} form.
030 * <p>
031 * Useful in combination with a JMS Appender to map a Log4j {@link org.apache.logging.log4j.message.MapMessage} or
032 * {@link org.apache.logging.log4j.message.StringMapMessage} to a JMS {@link javax.jms.MapMessage}.
033 * </p>
034 */
035@Plugin(name = "MessageLayout", category = Node.CATEGORY, elementType = Layout.ELEMENT_TYPE, printObject = true)
036public class MessageLayout extends AbstractLayout<Message> {
037
038    public MessageLayout() {
039        super(null, null, null);
040    }
041
042    public MessageLayout(final Configuration configuration, final byte[] header, final byte[] footer) {
043        super(configuration, header, footer);
044    }
045
046    @Override
047    public byte[] toByteArray(final LogEvent event) {
048        return null;
049    }
050
051    @Override
052    public Message toSerializable(final LogEvent event) {
053        return event.getMessage();
054    }
055
056    @Override
057    public String getContentType() {
058        return null;
059    }
060
061    @PluginFactory
062    public static Layout<?> createLayout() {
063        return new MessageLayout();
064    }
065
066}