use of java.util.logging.LogManager in project Payara by payara.
the class PayaraNotificationFileHandler method evaluateFileName.
@Override
protected String evaluateFileName() {
String cname = getClass().getName();
LogManager manager = LogManager.getLogManager();
logFileProperty = manager.getProperty(cname + ".file");
if (logFileProperty == null || logFileProperty.trim().equals("")) {
logFileProperty = env.getInstanceRoot().getAbsolutePath() + File.separator + LOGS_DIR + File.separator + NOTIFICATION_FILENAME;
}
return TranslatedConfigView.expandValue(logFileProperty);
}
use of java.util.logging.LogManager in project Payara by payara.
the class GFFileHandler method configureUniformLogFormatter.
private void configureUniformLogFormatter(String excludeFields, boolean multiLineMode) {
LogManager manager = LogManager.getLogManager();
String cname = getClass().getName();
// this loop is used for UFL formatter
UniformLogFormatter formatterClass;
// set the formatter
if (agent != null) {
formatterClass = new UniformLogFormatter(new AgentFormatterDelegate(agent), excludeFields);
setFormatter(formatterClass);
} else {
formatterClass = new UniformLogFormatter(excludeFields);
setFormatter(formatterClass);
}
formatterClass.setMultiLineMode(multiLineMode);
formatterClass.setLogEventBroadcaster(this);
formatterClass.noAnsi();
String recordBeginMarker = manager.getProperty(cname + ".logFormatBeginMarker");
if (recordBeginMarker == null || ("").equals(recordBeginMarker)) {
recordBeginMarker = RECORD_BEGIN_MARKER;
}
String recordEndMarker = manager.getProperty(cname + ".logFormatEndMarker");
if (recordEndMarker == null || ("").equals(recordEndMarker)) {
recordEndMarker = RECORD_END_MARKER;
}
String recordFieldSeparator = manager.getProperty(cname + ".logFormatFieldSeparator");
if (recordFieldSeparator == null || ("").equals(recordFieldSeparator) || recordFieldSeparator.length() > 1) {
recordFieldSeparator = RECORD_FIELD_SEPARATOR;
}
String recordDateFormat = manager.getProperty(cname + ".logFormatDateFormat");
if (recordDateFormat != null && !("").equals(recordDateFormat)) {
SimpleDateFormat sdf = new SimpleDateFormat(recordDateFormat);
try {
sdf.format(new Date());
} catch (Exception e) {
recordDateFormat = RECORD_DATE_FORMAT;
}
} else {
recordDateFormat = RECORD_DATE_FORMAT;
}
formatterClass.setRecordBeginMarker(recordBeginMarker);
formatterClass.setRecordEndMarker(recordEndMarker);
formatterClass.setRecordDateFormat(recordDateFormat);
formatterClass.setRecordFieldSeparator(recordFieldSeparator);
}
use of java.util.logging.LogManager in project Payara by payara.
the class GFFileHandler method evaluateFileName.
protected String evaluateFileName() {
String cname = getClass().getName();
LogManager manager = LogManager.getLogManager();
logFileProperty = manager.getProperty(cname + ".file");
if (logFileProperty == null || logFileProperty.trim().equals("")) {
logFileProperty = env.getInstanceRoot().getAbsolutePath() + File.separator + LOGS_DIR + File.separator + LOG_FILE_NAME;
}
return TranslatedConfigView.expandConfigValue(logFileProperty);
}
use of java.util.logging.LogManager in project Payara by payara.
the class LogDomains method getLogger.
/**
* Returns initialized logger. If the resourceBundleLoader is not null,
* tries to find and load the LogStrings.properties.
*
* @param clazz
* @param namePrefix
* @param resourceBundleLoader
* @return
*/
public static Logger getLogger(final Class clazz, final String namePrefix, final ClassLoader resourceBundleLoader) {
final String loggerName = getLoggerName(clazz, namePrefix);
final LogManager logManager = LogManager.getLogManager();
final Logger cachedLogger = logManager.getLogger(loggerName);
if (cachedLogger != null) {
return cachedLogger;
}
final String rbName = getResourceBundleNameForDomainRoot(namePrefix);
final ResourceBundle resourceBundle;
if (resourceBundleLoader == null) {
resourceBundle = null;
} else {
resourceBundle = getResourceBundle(rbName, clazz, resourceBundleLoader);
}
// we should only add a logger of the same name at time.
final Logger cLogger = new LogDomainsLogger(loggerName, resourceBundle);
// We must not return an orphan logger (the one we just created) if
// a race condition has already created one
boolean added = logManager.addLogger(cLogger);
if (added) {
return cLogger;
}
// Another thread was faster
return logManager.getLogger(cLogger.getName());
}
use of java.util.logging.LogManager in project beam by apache.
the class DataflowWorkerHarnessHelper method initializeLogging.
@SuppressWarnings("Slf4jIllegalPassedClass")
public static void initializeLogging(Class<?> workerHarnessClass) {
/* Set up exception handling tied to the workerHarnessClass. */
Thread.setDefaultUncaughtExceptionHandler(new WorkerUncaughtExceptionHandler(LoggerFactory.getLogger(workerHarnessClass)));
// Reset the global log manager, get the root logger and remove the default log handlers.
LogManager logManager = LogManager.getLogManager();
logManager.reset();
java.util.logging.Logger rootLogger = logManager.getLogger(ROOT_LOGGER_NAME);
for (Handler handler : rootLogger.getHandlers()) {
rootLogger.removeHandler(handler);
}
DataflowWorkerLoggingInitializer.initialize();
}
Aggregations