use of org.apache.log4j.PatternLayout in project mpeg-audio-streams by addradio.
the class Log4J method configureLog4J.
/**
* configureLog4J.
* @param level {@link Level}
*/
public static final void configureLog4J(final Level level) {
final Logger rootLogger = Logger.getRootLogger();
if (!rootLogger.getAllAppenders().hasMoreElements()) {
rootLogger.addAppender(new ConsoleAppender(new PatternLayout(PatternLayout.TTCC_CONVERSION_PATTERN)));
}
rootLogger.setLevel(level);
}
use of org.apache.log4j.PatternLayout in project pwm by pwm-project.
the class PwmLogManager method initConsoleLogger.
private static void initConsoleLogger(final Configuration config, final String consoleLogLevel) {
final Layout patternLayout = new PatternLayout(config.readAppProperty(AppProperty.LOGGING_PATTERN));
// configure console logging
if (consoleLogLevel != null && consoleLogLevel.length() > 0 && !"Off".equals(consoleLogLevel)) {
final ConsoleAppender consoleAppender = new ConsoleAppender(patternLayout);
final Level level = Level.toLevel(consoleLogLevel);
consoleAppender.setThreshold(level);
for (final Package logPackage : LOGGING_PACKAGES) {
if (logPackage != null) {
final Logger logger = Logger.getLogger(logPackage.getName());
logger.setLevel(Level.TRACE);
logger.addAppender(consoleAppender);
}
}
LOGGER.debug("successfully initialized default console log4j config at log level " + level.toString());
} else {
LOGGER.debug("skipping stdout log4j initialization due to blank setting for log level");
}
}
use of org.apache.log4j.PatternLayout in project pwm by pwm-project.
the class PwmLogManager method initFileLogger.
private static void initFileLogger(final Configuration config, final String fileLogLevel, final File pwmApplicationPath) {
final Layout patternLayout = new PatternLayout(config.readAppProperty(AppProperty.LOGGING_PATTERN));
// configure file logging
final String logDirectorySetting = config.readAppProperty(AppProperty.LOGGING_FILE_PATH);
final File logDirectory = FileSystemUtility.figureFilepath(logDirectorySetting, pwmApplicationPath);
if (logDirectory != null && fileLogLevel != null && fileLogLevel.length() > 0 && !"Off".equals(fileLogLevel)) {
try {
if (!logDirectory.exists()) {
if (logDirectory.mkdir()) {
LOGGER.info("created directory " + logDirectory.getAbsoluteFile());
} else {
throw new IOException("failed to create directory " + logDirectory.getAbsoluteFile());
}
}
final String fileName = logDirectory.getAbsolutePath() + File.separator + PwmConstants.PWM_APP_NAME + ".log";
final RollingFileAppender fileAppender = new RollingFileAppender(patternLayout, fileName, true);
final Level level = Level.toLevel(fileLogLevel);
fileAppender.setThreshold(level);
fileAppender.setMaxBackupIndex(Integer.parseInt(config.readAppProperty(AppProperty.LOGGING_FILE_MAX_ROLLOVER)));
fileAppender.setMaxFileSize(config.readAppProperty(AppProperty.LOGGING_FILE_MAX_SIZE));
PwmLogger.setFileAppender(fileAppender);
for (final Package logPackage : LOGGING_PACKAGES) {
if (logPackage != null) {
// if (!logPackage.equals(PwmApplication.class.getPackage())) {
final Logger logger = Logger.getLogger(logPackage.getName());
logger.setLevel(Level.TRACE);
logger.addAppender(fileAppender);
// }
}
}
LOGGER.debug("successfully initialized default file log4j config at log level " + level.toString());
} catch (IOException e) {
LOGGER.debug("error initializing RollingFileAppender: " + e.getMessage());
}
}
}
use of org.apache.log4j.PatternLayout in project onebusaway-application-modules by camsys.
the class BundleBuildingServiceImpl method configureLogging.
/**
* setup a logger just for the bundle building activity.
*/
private void configureLogging(OutputStream os) {
if (_debug)
return;
Layout layout = new PatternLayout(PatternLayout.TTCC_CONVERSION_PATTERN);
WriterAppender wa = new WriterAppender(layout, os);
wa.setName("bundlebuilder.out");
// introducing log4j dependency here
org.apache.log4j.Logger logger = org.apache.log4j.Logger.getRootLogger();
logger.addAppender(wa);
_log.info("configuring logging");
}
use of org.apache.log4j.PatternLayout in project BiglyBT by BiglySoftware.
the class UI method initRootLogger.
/**
* Creates a new instance of Main
*/
/*public UI() {
}*/
public static void initRootLogger() {
if (Logger.getRootLogger().getAppender("ConsoleAppender") == null) {
Appender app;
app = new ConsoleAppender(new PatternLayout(PatternLayout.TTCC_CONVERSION_PATTERN));
app.setName("ConsoleAppender");
// 'log off' by default
app.addFilter(new DenyAllFilter());
Logger.getRootLogger().addAppender(app);
}
}
Aggregations