use of org.apache.log4j.PatternLayout in project ignite by apache.
the class GridLog4jCorrectFileNameTest method createAppender.
/**
* Creates new GridLog4jRollingFileAppender.
*
* @return GridLog4jRollingFileAppender.
*/
private static Log4jRollingFileAppender createAppender() {
Log4jRollingFileAppender appender = new Log4jRollingFileAppender();
appender.setLayout(new PatternLayout("[%d{ISO8601}][%-5p][%t][%c{1}] %m%n"));
appender.setFile("work/log/ignite.log");
appender.setName(Log4jRollingFileAppender.class.getSimpleName());
LevelRangeFilter lvlFilter = new LevelRangeFilter();
lvlFilter.setLevelMin(Level.DEBUG);
lvlFilter.setLevelMax(Level.INFO);
appender.addFilter(lvlFilter);
return appender;
}
use of org.apache.log4j.PatternLayout in project metron by apache.
the class UnitTestHelper method verboseLogging.
public static void verboseLogging(String pattern, Level level) {
// create appender
ConsoleAppender console = new ConsoleAppender();
// configure the appender
console.setLayout(new PatternLayout(pattern));
console.setThreshold(level);
console.activateOptions();
// add appender to any Logger (here is root)
Logger.getRootLogger().addAppender(console);
}
use of org.apache.log4j.PatternLayout in project knime-core by knime.
the class NodeLogger method addKNIMEConsoleWriter.
/**
* Adds a new {@link java.io.Writer} with the given level to this logger.
*
* @param writer The writer to add.
* @param minLevel The minimum level to output.
* @param maxLevel The maximum level to output.
* @since 2.12
*/
public static void addKNIMEConsoleWriter(final Writer writer, final LEVEL minLevel, final LEVEL maxLevel) {
final Appender a = Logger.getRootLogger().getAppender(KNIME_CONSOLE_APPENDER);
final Layout layout;
if (a != null) {
layout = a.getLayout();
checkLayoutFlags(layout);
} else {
layout = WF_DIR_LOG_FILE_LAYOUT;
}
// no stack traces in KNIME's console view:
// a custom layout that pretends Throwable information is baked into the log message
final Layout suppressThrowableLayout = new Layout() {
@Override
public void activateOptions() {
layout.activateOptions();
}
@Override
public String format(final LoggingEvent event) {
return layout.format(event);
}
@Override
public boolean ignoresThrowable() {
// PatternLayout returns true (which makes the appender to log the Throwable)
return false;
}
};
addWriter(writer, suppressThrowableLayout, minLevel, maxLevel);
}
use of org.apache.log4j.PatternLayout in project scheduling by ow2-proactive.
the class RMNodeUpdater method initLogger.
private static Logger initLogger() {
if (System.getProperty("log4j.configuration") == null) {
// While logger is not configured and it not set with sys properties, use Console logger
Logger.getRootLogger().getLoggerRepository().resetConfiguration();
BasicConfigurator.configure(new ConsoleAppender(new PatternLayout("%m%n")));
Logger.getRootLogger().setLevel(Level.INFO);
}
return Logger.getLogger(RMNodeUpdater.class);
}
use of org.apache.log4j.PatternLayout in project scheduling by ow2-proactive.
the class AOSynchronizationTest method classInit.
@BeforeClass
public static void classInit() {
CentralPAPropertyRepository.PA_CLASSLOADING_USEHTTP.setValue(false);
if (System.getProperty("log4j.configuration") == null) {
// While logger is not configured and it not set with sys properties, use Console logger
Logger.getRootLogger().getLoggerRepository().resetConfiguration();
BasicConfigurator.configure(new ConsoleAppender(new PatternLayout("%m%n")));
Logger.getRootLogger().setLevel(Level.INFO);
}
Logger.getLogger(AOSynchronization.class).setLevel(Level.TRACE);
}
Aggregations