自定义日志布局-Log4j2

时间:2019-01-11 19:04:00

标签: java log4j log4j2

在log4j中,我通过扩展log4j Layout类来自定义日志:

import org.apache.log4j.Layout;
import org.apache.log4j.spi.LoggingEvent;

public class CustomLayout extends Layout{

    public String format(LoggingEvent loggingEvent) {
        return "any log"
    }
}

log4j.properties:

log4j.appender.stdout.layout=com.sample.CustomLayout

如何在log4j2中创建自定义布局?

0 个答案:

没有答案