本文整理匯總了Java中org.apache.logging.log4j.core.layout.PatternLayout.createDefaultLayout方法的典型用法代碼示例。如果您正苦於以下問題:Java PatternLayout.createDefaultLayout方法的具體用法?Java PatternLayout.createDefaultLayout怎麽用?Java PatternLayout.createDefaultLayout使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.logging.log4j.core.layout.PatternLayout
的用法示例。
在下文中一共展示了PatternLayout.createDefaultLayout方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: createAppender
import org.apache.logging.log4j.core.layout.PatternLayout; //導入方法依賴的package包/類
/**
* Factory method. Log4j will parse the configuration and call this factory
* method to construct the appender with
* the configured attributes.
*
* @param name Name of appender
* @param layout Log layout of appender
* @param filter Filter for appender
* @return The TextAreaAppender
*/
@PluginFactory
public static TextAreaAppender createAppender(
@PluginAttribute("name")
String name,
@PluginElement("Layout")
Layout<? extends Serializable> layout,
@PluginElement("Filter")
final Filter filter) {
if (name == null) {
LOGGER.error("No name provided for TextAreaAppender");
return null;
}
if (layout == null) {
layout = PatternLayout.createDefaultLayout();
}
return new TextAreaAppender(name, filter, layout, true);
}
示例2: watch
import org.apache.logging.log4j.core.layout.PatternLayout; //導入方法依賴的package包/類
public void watch(Class<?> loggerClass, Level level) {
this.loggerClass = loggerClass;
Appender appender = new AbstractAppender(APPENDER_NAME, null, PatternLayout.createDefaultLayout()) {
@Override
public void append(LogEvent event) {
logEvents.add(event);
}
};
appender.start();
final LoggerContext ctx = getLoggerContext();
LoggerConfig loggerConfig = ctx.getConfiguration().getLoggerConfig(loggerClass.getName());
oldLevel = loggerConfig.getLevel();
loggerConfig.setLevel(level);
loggerConfig.addAppender(appender, level, null);
ctx.updateLoggers();
}
示例3: ProcessCallable
import org.apache.logging.log4j.core.layout.PatternLayout; //導入方法依賴的package包/類
public ProcessCallable(MCRSession session, Session webSocketSession) {
this.commands = new ObservableCommandList();
this.session = session;
this.webSocketSession = webSocketSession;
this.logs = new ObservableLogEventDeque();
this.logGrabber = new Log4JGrabber(MCRWebCLIContainer.class.getSimpleName() + session.getID(), null,
PatternLayout.createDefaultLayout());
this.logGrabber.start();
this.commandListObserver = new CommandListObserver(commands, webSocketSession);
commands.addObserver(commandListObserver);
this.logEventQueueObserver = new LogEventDequeObserver(logs, webSocketSession);
logs.addObserver(logEventQueueObserver);
this.currentCommand = "";
this.continueIfOneFails = false;
}
示例4: createAppender
import org.apache.logging.log4j.core.layout.PatternLayout; //導入方法依賴的package包/類
@PluginFactory
public static WorkspaceLogAppender createAppender(@PluginAttribute("name") String name,
@PluginElement("Layout") Layout<? extends Serializable> layout,
@PluginElement("Filter") final Filter filter) {
if (name == null) {
LOGGER.error("No name provided for WorkspaceLogAppender");
return null;
}
if (layout == null) {
layout = PatternLayout.createDefaultLayout();
}
return new WorkspaceLogAppender(name, filter, layout, true);
}
示例5: createAppender
import org.apache.logging.log4j.core.layout.PatternLayout; //導入方法依賴的package包/類
@PluginFactory
public static SlackAppender createAppender(
@PluginAttribute("name") String name,
@PluginElement("Layout") Layout<? extends Serializable> layout,
@PluginElement("Filter") final Filter filter,
@PluginAttribute("webhookUrl") URL webhookUrl,
@PluginAttribute("channel") String channel,
@PluginAttribute(value = "username", defaultString = "Blazkowicz") String username,
@PluginAttribute(value = "meltdownProtection", defaultBoolean = true) boolean meltdownProtection,
@PluginAttribute(value = "similarMessageSize", defaultInt = 50) int similarMessageSize,
@PluginAttribute(value = "timeBetweenSimilarLogsMs", defaultInt = 60000) int timeBetweenSimilarLogsMs,
@PluginAttribute(value = "packagesToMute", defaultString = "") String packagesToMute,
@PluginAttribute(value = "httpClientImpl", defaultString = "") String httpClientImpl) {
if (name == null) {
LOGGER.error("No name provided for MyCustomAppenderImpl");
return null;
}
if (layout == null) {
layout = PatternLayout.createDefaultLayout();
}
Client client = findClientImpl(httpClientImpl);
SlackAppender slackAppender = new SlackAppender(name, filter, layout, webhookUrl, username, channel, meltdownProtection, similarMessageSize, timeBetweenSimilarLogsMs, client);
slackAppender.setPackagesToMute(packagesToMute);
return slackAppender;
}
示例6: createAppender
import org.apache.logging.log4j.core.layout.PatternLayout; //導入方法依賴的package包/類
@PluginFactory
public static DebuggerAppender createAppender(@PluginAttribute("name") String name,
@PluginElement("Layout") Layout<?> layout,
@PluginElement("Filters") Filter filter,
@PluginAttribute("ignoreExceptions") boolean ignoreExceptions) {
if (name == null) {
LOGGER.error("No name provided for JTextAreaAppender");
return null;
}
if (layout == null) {
layout = PatternLayout.createDefaultLayout();
}
return new DebuggerAppender(name, layout, filter, ignoreExceptions);
}
示例7: createAppender
import org.apache.logging.log4j.core.layout.PatternLayout; //導入方法依賴的package包/類
@PluginFactory
public static ApiLogAppenderImpl createAppender(
@PluginAttribute("name") String name,
@PluginElement("Layout") Layout<? extends Serializable> layout,
@PluginElement("Filter") final Filter filter,
@PluginAttribute("format") String otherAttribute) {
if (name == null) {
LOGGER.error("No name provided for ApiLogAppenderImpl");
return null;
}
if (layout == null) {
layout = PatternLayout.createDefaultLayout();
}
return new ApiLogAppenderImpl(name, filter, layout, true);
}
示例8: createAppender
import org.apache.logging.log4j.core.layout.PatternLayout; //導入方法依賴的package包/類
/**
* A custom appender needs to declare a factory method annotated with `@PluginFactory`.
* Log4j will parse the configuration and call this factory method to construct an appender instance with
* the configured attributes.
*
* @param name - the logger name
* @param layout - the layout
* @param filter - the filter
* @param otherAttribute - other attributes
* @return a text area logger
*/
@PluginFactory
public static TextAreaLogger createAppender(
@PluginAttribute("name") String name,
@PluginElement("Layout") Layout<? extends Serializable> layout,
@PluginElement("Filter") final Filter filter,
@PluginAttribute("otherAttribute") String otherAttribute) {
if (name == null) {
LOGGER.error("No name provided for MyCustomAppenderImpl");
return null;
}
if (layout == null) {
layout = PatternLayout.createDefaultLayout();
}
return new TextAreaLogger(name, filter, layout, true);
}
示例9: createAppender
import org.apache.logging.log4j.core.layout.PatternLayout; //導入方法依賴的package包/類
@PluginFactory
public static MongoFXMessageAppender createAppender(@PluginAttribute("name") String name,
@PluginAttribute("ignoreExceptions") boolean ignoreExceptions,
@PluginElement("Layout") Layout<? extends Serializable> layout,
@PluginElement("Filters") Filter filter) {
if (name == null) {
LOGGER.error("No name provided for StubAppender");
return null;
}
if (layout == null) {
layout = PatternLayout.createDefaultLayout();
}
return new MongoFXMessageAppender(name, filter, layout, ignoreExceptions);
}
示例10: createAppender
import org.apache.logging.log4j.core.layout.PatternLayout; //導入方法依賴的package包/類
@PluginFactory
public static MemoryAppender createAppender(
@PluginAttribute("name") String name,
@PluginElement("Layout") Layout<? extends Serializable> layout,
@PluginElement("Filter") final Filter filter,
@PluginAttribute("numberOfLines") String numberOfLines) {
if (name == null) {
LOGGER.error("No name provided for MemoryAppender");
return null;
}
if (layout == null) {
layout = PatternLayout.createDefaultLayout();
}
if (numberOfLines != null) {
logsize = Integer.valueOf(numberOfLines);
}
return new MemoryAppender(name, filter, layout, true);
}
示例11: createAppender
import org.apache.logging.log4j.core.layout.PatternLayout; //導入方法依賴的package包/類
@PluginFactory
public static ConsoleWindowAppender createAppender(@PluginAttribute("name") String name, @PluginAttribute("ignoreExceptions") boolean ignoreExceptions, @PluginElement("Layout") Layout layout, @PluginElement("Filters") Filter filter)
{
if (name == null)
{
LOGGER.error("No name provided for StubAppender");
return null;
}
if (layout == null)
{
layout = PatternLayout.createDefaultLayout();
}
//noinspection unchecked
return new ConsoleWindowAppender(name, filter, layout, ignoreExceptions);
}
示例12: createAppender
import org.apache.logging.log4j.core.layout.PatternLayout; //導入方法依賴的package包/類
@PluginFactory
public static JesterJAppender createAppender(@PluginAttribute("name") String name,
@PluginAttribute("ignoreExceptions") boolean ignoreExceptions,
@PluginElement("Layout") Layout layout,
@PluginElement("Filters") Filter filter) {
if (name == null) {
LOGGER.error("No name provided for JesterJAppender");
return null;
}
manager = createManager();
if (manager == null) {
return null;
}
if (layout == null) {
layout = PatternLayout.createDefaultLayout();
}
cassandra.addStatement(FTI_INSERT_Q, INSERT_FTI);
cassandra.addStatement(REG_INSERT_Q, INSERT_REG);
return new JesterJAppender(name, layout, filter, manager, ignoreExceptions);
}
示例13: build
import org.apache.logging.log4j.core.layout.PatternLayout; //導入方法依賴的package包/類
@Override
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);
}
示例14: createAppender
import org.apache.logging.log4j.core.layout.PatternLayout; //導入方法依賴的package包/類
/**
* Creates a Console Appender.
*
* @param layout The layout to use (required).
* @param filter The Filter or null.
* @param targetStr The target ("SYSTEM_OUT" or "SYSTEM_ERR"). The default is "SYSTEM_OUT".
* @param name The name of the Appender (required).
* @param follow If true will follow changes to the underlying output stream.
* @param ignore If {@code "true"} (default) exceptions encountered when appending events are logged; otherwise they
* are propagated to the caller.
* @return The ConsoleAppender.
* @deprecated Deprecated in 2.7; use {@link #newBuilder()}.
*/
@Deprecated
public static ConsoleAppender createAppender(Layout<? extends Serializable> layout,
final Filter filter,
final String targetStr,
final String name,
final String follow,
final String ignore) {
if (name == null) {
LOGGER.error("No name provided for ConsoleAppender");
return null;
}
if (layout == null) {
layout = PatternLayout.createDefaultLayout();
}
final boolean isFollow = Boolean.parseBoolean(follow);
final boolean ignoreExceptions = Booleans.parseBoolean(ignore, true);
final Target target = targetStr == null ? DEFAULT_TARGET : Target.valueOf(targetStr);
return new ConsoleAppender(name, layout, filter, getManager(target, isFollow, false, layout), ignoreExceptions, target);
}
示例15: createAppender
import org.apache.logging.log4j.core.layout.PatternLayout; //導入方法依賴的package包/類
/**
* Method for initializing a new instance of JFXAppender; used by Log4j.
*
* @param layout the layout for events
* @param filter the initial filter of the appender
* @return the newly created JFXAppender
*/
@PluginFactory
public static JFXAppender createAppender(
@PluginElement("Layout") final Layout<? extends Serializable> layout,
@PluginElement("Filter") final Filter filter) {
return new JFXAppender("JFXAppender", filter,
layout == null ? PatternLayout.createDefaultLayout() : layout, true);
}