在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中创建自定义布局?