use of org.apache.logging.log4j.core.config.builder.api.AppenderComponentBuilder in project logging-log4j2 by apache.
the class Log4j1ConfigurationParser method buildDailyRollingFileAppender.
private void buildDailyRollingFileAppender(final String appenderName) {
final AppenderComponentBuilder appenderBuilder = builder.newAppender(appenderName, RollingFileAppender.PLUGIN_NAME);
buildFileAppender(appenderName, appenderBuilder);
final String fileName = getLog4jAppenderValue(appenderName, "File");
final String datePattern = getLog4jAppenderValue(appenderName, "DatePattern", fileName + "'.'yyyy-MM-dd");
appenderBuilder.addAttribute("filePattern", fileName + "%d{" + datePattern + "}");
final ComponentBuilder<?> triggeringPolicy = builder.newComponent("Policies").addComponent(builder.newComponent("TimeBasedTriggeringPolicy").addAttribute("modulate", true));
appenderBuilder.addComponent(triggeringPolicy);
appenderBuilder.addComponent(builder.newComponent("DefaultRolloverStrategy").addAttribute("max", Integer.MAX_VALUE));
builder.add(appenderBuilder);
}
use of org.apache.logging.log4j.core.config.builder.api.AppenderComponentBuilder in project logging-log4j2 by apache.
the class Log4j1ConfigurationParser method buildRollingFileAppender.
private void buildRollingFileAppender(final String appenderName) {
final AppenderComponentBuilder appenderBuilder = builder.newAppender(appenderName, RollingFileAppender.PLUGIN_NAME);
buildFileAppender(appenderName, appenderBuilder);
final String fileName = getLog4jAppenderValue(appenderName, "File");
appenderBuilder.addAttribute("filePattern", fileName + ".%i");
final String maxFileSizeString = getLog4jAppenderValue(appenderName, "MaxFileSize", "10485760");
final String maxBackupIndexString = getLog4jAppenderValue(appenderName, "MaxBackupIndex", "1");
final ComponentBuilder<?> triggeringPolicy = builder.newComponent("Policies").addComponent(builder.newComponent("SizeBasedTriggeringPolicy").addAttribute("size", maxFileSizeString));
appenderBuilder.addComponent(triggeringPolicy);
appenderBuilder.addComponent(builder.newComponent("DefaultRolloverStrategy").addAttribute("max", maxBackupIndexString));
builder.add(appenderBuilder);
}
use of org.apache.logging.log4j.core.config.builder.api.AppenderComponentBuilder in project logging-log4j2 by apache.
the class PropertiesConfigurationBuilder method createAppender.
private AppenderComponentBuilder createAppender(final String key, final Properties properties) {
final String name = (String) properties.remove(CONFIG_NAME);
if (Strings.isEmpty(name)) {
throw new ConfigurationException("No name attribute provided for Appender " + key);
}
final String type = (String) properties.remove(CONFIG_TYPE);
if (Strings.isEmpty(type)) {
throw new ConfigurationException("No type attribute provided for Appender " + key);
}
final AppenderComponentBuilder appenderBuilder = builder.newAppender(name, type);
addFiltersToComponent(appenderBuilder, properties);
final Properties layoutProps = PropertiesUtil.extractSubset(properties, "layout");
if (layoutProps.size() > 0) {
appenderBuilder.add(createLayout(name, layoutProps));
}
return processRemainingProperties(appenderBuilder, properties);
}
use of org.apache.logging.log4j.core.config.builder.api.AppenderComponentBuilder in project logging-log4j2 by apache.
the class Log4j1ConfigurationParser method buildConsoleAppender.
private void buildConsoleAppender(final String appenderName) {
final AppenderComponentBuilder appenderBuilder = builder.newAppender(appenderName, ConsoleAppender.PLUGIN_NAME);
final String targetValue = getLog4jAppenderValue(appenderName, "Target", "System.out");
if (targetValue != null) {
final ConsoleAppender.Target target;
switch(targetValue) {
case "System.out":
target = ConsoleAppender.Target.SYSTEM_OUT;
break;
case "System.err":
target = ConsoleAppender.Target.SYSTEM_ERR;
break;
default:
reportWarning("Unknown value for console Target: " + targetValue);
target = null;
}
if (target != null) {
appenderBuilder.addAttribute("target", target);
}
}
buildAttribute(appenderName, appenderBuilder, "Follow", "follow");
if (FALSE.equalsIgnoreCase(getLog4jAppenderValue(appenderName, "ImmediateFlush"))) {
reportWarning("ImmediateFlush=false is not supported on Console appender");
}
buildAppenderLayout(appenderName, appenderBuilder);
builder.add(appenderBuilder);
}
use of org.apache.logging.log4j.core.config.builder.api.AppenderComponentBuilder in project logging-log4j2 by apache.
the class Log4j1ConfigurationParser method buildNullAppender.
private void buildNullAppender(final String appenderName) {
final AppenderComponentBuilder appenderBuilder = builder.newAppender(appenderName, NullAppender.PLUGIN_NAME);
builder.add(appenderBuilder);
}
Aggregations