Java Code Examples for org.apache.logging.log4j.core.layout.AbstractStringLayout

The following examples show how to use org.apache.logging.log4j.core.layout.AbstractStringLayout. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: logging-log4j2   Source File:    License: Apache License 2.0 7 votes vote down vote up
public ServletAppender build() {
	final String name = getName();
	if (name == null) {
		LOGGER.error("No name provided for ServletAppender");
	final ServletContext servletContext = WebLoggerContextUtils.getServletContext();
	if (servletContext == null) {
		LOGGER.error("No servlet context is available");
		return null;
	Layout<? extends Serializable> layout = getLayout();
	if (layout == null) {
		layout = PatternLayout.createDefaultLayout();
	} else if (!(layout instanceof AbstractStringLayout)) {
		LOGGER.error("Layout must be a StringLayout to log to ServletContext");
		return null;
          return new ServletAppender(name, layout, getFilter(), servletContext, isIgnoreExceptions(), logThrowables,
Example 2
Source Project: logging-log4j2   Source File:    License: Apache License 2.0 5 votes vote down vote up
public void append(final LogEvent event) {
    final String serialized = ((AbstractStringLayout) getLayout()).toSerializable(event);
    if (logThrowables) {
        servletContext.log(serialized, event.getThrown());
    } else {