diff --git a/appserver/admingui/common/src/main/java/org/glassfish/admingui/common/handlers/LoggingHandlers.java b/appserver/admingui/common/src/main/java/org/glassfish/admingui/common/handlers/LoggingHandlers.java index 5c9f94b2698..625891964f4 100644 --- a/appserver/admingui/common/src/main/java/org/glassfish/admingui/common/handlers/LoggingHandlers.java +++ b/appserver/admingui/common/src/main/java/org/glassfish/admingui/common/handlers/LoggingHandlers.java @@ -210,7 +210,9 @@ public static void saveLoggingAttributes(HandlerContext handlerCtx) { key.equals("com.sun.enterprise.server.logging.GFFileHandler.logtoConsole") || key.equals("com.sun.enterprise.server.logging.GFFileHandler.multiLineMode") || key.equals("com.sun.enterprise.server.logging.GFFileHandler.rotationOnDateChange" ) || - key.equals("com.sun.enterprise.server.logging.GFFileHandler.compressOnRotation")) + key.equals("com.sun.enterprise.server.logging.GFFileHandler.compressOnRotation") || + key.equals("fish.payara.enterprise.server.logging.PayaraNotificationFileHandler.logtoFile") || + key.equals("fish.payara.enterprise.server.logging.PayaraNotificationFileHandler.rotationOnDateChange")) && (e.getValue() == null)) { attrs.put(key, "false"); } diff --git a/appserver/admingui/common/src/main/resources/configuration/loggerGeneral.jsf b/appserver/admingui/common/src/main/resources/configuration/loggerGeneral.jsf index 7a096f7c2ce..c6a13ccbe7c 100644 --- a/appserver/admingui/common/src/main/resources/configuration/loggerGeneral.jsf +++ b/appserver/admingui/common/src/main/resources/configuration/loggerGeneral.jsf @@ -190,7 +190,11 @@ - + + + + + diff --git a/nucleus/admin/template/src/main/resources/config/logging.properties b/nucleus/admin/template/src/main/resources/config/logging.properties index 2856da89ea4..9e851cd5eb7 100644 --- a/nucleus/admin/template/src/main/resources/config/logging.properties +++ b/nucleus/admin/template/src/main/resources/config/logging.properties @@ -66,6 +66,7 @@ java.util.logging.FileHandler.formatter=java.util.logging.XMLFormatter com.sun.enterprise.server.logging.GFFileHandler.compressOnRotation=false #Payara Notification logging properties +fish.payara.enterprise.server.logging.PayaraNotificationFileHandler.logtoFile=true fish.payara.enterprise.server.logging.PayaraNotificationFileHandler.rotationOnDateChange=false fish.payara.enterprise.server.logging.PayaraNotificationFileHandler.rotationTimelimitInMinutes=0 fish.payara.enterprise.server.logging.PayaraNotificationFileHandler.rotationLimitInBytes=2000000 diff --git a/nucleus/core/logging/src/main/java/com/sun/enterprise/server/logging/LogManagerService.java b/nucleus/core/logging/src/main/java/com/sun/enterprise/server/logging/LogManagerService.java index 0a4868f495a..3c37ffe33d1 100644 --- a/nucleus/core/logging/src/main/java/com/sun/enterprise/server/logging/LogManagerService.java +++ b/nucleus/core/logging/src/main/java/com/sun/enterprise/server/logging/LogManagerService.java @@ -144,8 +144,9 @@ public class LogManagerService implements PostConstruct, PreDestroy, org.glassfi String logFormatDateFormatDetail = ""; String compressOnRotationDetail = ""; - //Payara Notification Logging + //Payara Notification Logging String payaraNotificationLogFileDetail = ""; + String payaraNotificationlogToFileDetail = ""; String payaraNotificationLogRotationOnTimeLimitInMinutesDetail = ""; String payaraNotificationLogRotationOnDateChangeDetail = ""; String payaraNotificationLogRotationInTimeLimitInBytesDetail = ""; @@ -175,6 +176,7 @@ public class LogManagerService implements PostConstruct, PreDestroy, org.glassfi //Payara Notification Logging private static final String PAYARA_NOTIFICATION_LOG_FILE_PROPERTY = "fish.payara.enterprise.server.logging.PayaraNotificationFileHandler.file"; + private static final String PAYARA_NOTIFICATION_LOGTOFILE_PROPERTY = "fish.payara.enterprise.server.logging.PayaraNotificationFileHandler.logtoFile"; private static final String PAYARA_NOTIFICATION_LOG_ROTATIONONDATECHANGE_PROPERTY = "fish.payara.enterprise.server.logging.PayaraNotificationFileHandler.rotationOnDateChange"; private static final String PAYARA_NOTIFICATION_LOG_ROTATIONTIMELIMITINMINUTES_PROPERTY = "fish.payara.enterprise.server.logging.PayaraNotificationFileHandler.rotationTimelimitInMinutes"; private static final String PAYARA_NOTIFICATION_LOG_ROTATIONLIMITINBYTES_PROPERTY = "fish.payara.enterprise.server.logging.PayaraNotificationFileHandler.rotationLimitInBytes"; @@ -430,6 +432,7 @@ public void postConstruct() { //Payara Notification Logging payaraNotificationLogFileDetail = props.get(PAYARA_NOTIFICATION_LOG_FILE_PROPERTY); + payaraNotificationlogToFileDetail = props.get(PAYARA_NOTIFICATION_LOGTOFILE_PROPERTY); payaraNotificationLogRotationOnDateChangeDetail = props.get(PAYARA_NOTIFICATION_LOG_ROTATIONONDATECHANGE_PROPERTY); payaraNotificationLogRotationOnTimeLimitInMinutesDetail = props.get(PAYARA_NOTIFICATION_LOG_ROTATIONTIMELIMITINMINUTES_PROPERTY); payaraNotificationLogRotationInTimeLimitInBytesDetail = props.get(PAYARA_NOTIFICATION_LOG_ROTATIONLIMITINBYTES_PROPERTY); @@ -642,10 +645,14 @@ public void changed(File changedFile) { if (!val.equals(payaraNotificationLogFileDetail)) { generateAttributeChangeEvent(PAYARA_NOTIFICATION_LOG_FILE_PROPERTY, payaraNotificationLogFileDetail, props); } - }else if (a.equals(PAYARA_NOTIFICATION_LOG_ROTATIONTIMELIMITINMINUTES_PROPERTY)) { - if (!val.equals(payaraNotificationLogRotationOnTimeLimitInMinutesDetail)) { - generateAttributeChangeEvent(PAYARA_NOTIFICATION_LOG_ROTATIONTIMELIMITINMINUTES_PROPERTY, payaraNotificationLogRotationOnTimeLimitInMinutesDetail, props); + } else if (a.equals(PAYARA_NOTIFICATION_LOGTOFILE_PROPERTY)) { + if (!val.equals(payaraNotificationlogToFileDetail)) { + generateAttributeChangeEvent(PAYARA_NOTIFICATION_LOGTOFILE_PROPERTY, payaraNotificationlogToFileDetail, props); } + }else if (a.equals(PAYARA_NOTIFICATION_LOG_ROTATIONTIMELIMITINMINUTES_PROPERTY)) { + if (!val.equals(payaraNotificationLogRotationOnTimeLimitInMinutesDetail)) { + generateAttributeChangeEvent(PAYARA_NOTIFICATION_LOG_ROTATIONTIMELIMITINMINUTES_PROPERTY, payaraNotificationLogRotationOnTimeLimitInMinutesDetail, props); + } } else if (a.equals(PAYARA_NOTIFICATION_LOG_ROTATIONLIMITINBYTES_PROPERTY)) { if (!val.equals(payaraNotificationLogRotationInTimeLimitInBytesDetail)) { generateAttributeChangeEvent(PAYARA_NOTIFICATION_LOG_ROTATIONLIMITINBYTES_PROPERTY, payaraNotificationLogRotationInTimeLimitInBytesDetail, props); diff --git a/nucleus/core/logging/src/main/java/com/sun/enterprise/server/logging/commands/SetLogAttributes.java b/nucleus/core/logging/src/main/java/com/sun/enterprise/server/logging/commands/SetLogAttributes.java index 909628a3ad1..4d257d20bb3 100644 --- a/nucleus/core/logging/src/main/java/com/sun/enterprise/server/logging/commands/SetLogAttributes.java +++ b/nucleus/core/logging/src/main/java/com/sun/enterprise/server/logging/commands/SetLogAttributes.java @@ -167,6 +167,7 @@ public class SetLogAttributes implements AdminCommand { "com.sun.enterprise.server.logging.ODLLogFormatter.warnColor", "com.sun.enterprise.server.logging.ODLLogFormatter.severeColor", "fish.payara.enterprise.server.logging.PayaraNotificationFileHandler.file", + "fish.payara.enterprise.server.logging.PayaraNotificationFileHandler.logtoFile", PAYARA_NOTIFICATION_ROTATION_TIMELIMIT_IN_MINUTES, "fish.payara.enterprise.server.logging.PayaraNotificationFileHandler.rotationOnDateChange", PAYARA_NOTIFICATOIN_ROTATION_LIMIT_IN_BYTES, diff --git a/nucleus/core/logging/src/main/java/fish/payara/enterprise/server/logging/PayaraNotificationFileHandler.java b/nucleus/core/logging/src/main/java/fish/payara/enterprise/server/logging/PayaraNotificationFileHandler.java index e0836b49b22..70a0ffe90bb 100644 --- a/nucleus/core/logging/src/main/java/fish/payara/enterprise/server/logging/PayaraNotificationFileHandler.java +++ b/nucleus/core/logging/src/main/java/fish/payara/enterprise/server/logging/PayaraNotificationFileHandler.java @@ -71,45 +71,4 @@ protected String evaluateFileName() { return TranslatedConfigView.getTranslatedValue(logFileProperty).toString(); } - - @Override - public void cleanUpHistoryLogFiles() { - if (maxHistoryFiles == 0) { - return; - } - - synchronized (rotationLock) { - File dir = absoluteFile.getParentFile(); - if (dir == null) { - return; - } - File[] fset = dir.listFiles(); - ArrayList candidates = new ArrayList(); - for (int i = 0; fset != null && i < fset.length; i++) { - if (!NOTIFICATION_FILENAME.equals(fset[i].getName()) && fset[i].isFile() - && fset[i].getName().startsWith(NOTIFICATION_FILENAME)) { - candidates.add(fset[i].getAbsolutePath()); - } - } - if (candidates.size() <= maxHistoryFiles) { - return; - } - Object[] pathes = candidates.toArray(); - java.util.Arrays.sort(pathes); - try { - for (int i = 0; i < pathes.length - maxHistoryFiles; i++) { - File logFile = new File((String) pathes[i]); - boolean delFile = logFile.delete(); - if (!delFile) { - throw new IOException("Could not delete log file: " - + logFile.getAbsolutePath()); - } - } - } catch (Exception e) { - new ErrorManager().error( - "FATAL ERROR: COULD NOT DELETE LOG FILE.", e, - ErrorManager.GENERIC_FAILURE); - } - } - } } \ No newline at end of file