Skip to content

Commit

Permalink
PAYARA-2398 Add option to disable Payara Notification logging to file. (
Browse files Browse the repository at this point in the history
  • Loading branch information
MeroRai authored and smillidge committed Jan 18, 2018
1 parent 7e0b95a commit 791c1ea
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 47 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,11 @@

<!-- Payara Notification Logger Settings -->
<sun:propertySheetSection id="poolSettingSection" label="Payara Notification Logger Settings">


<sun:property id="PayaraNotificationLogtoFile" labelAlign="left" noWrap="#{true}" overlapLabel="#{false}" label="$resource{i18nc.log.LogtoFile}" helpText="$resource{i18nc.log.LogtoFileHelp}">
<sun:checkbox label="$resource{i18n.common.Enabled}" selected="#{pageSession.logAttributes['fish.payara.enterprise.server.logging.PayaraNotificationFileHandler.logtoFile']}" selectedValue="true" />
</sun:property>

<sun:property id="PayaraNotificationRotationOnDateChange" labelAlign="left" noWrap="#{true}" overlapLabel="#{false}" label="$resource{i18nc.log.rotationOnDateChange}" helpText="$resource{i18nc.log.rotationOnDateChangeHelp}">
<sun:checkbox label="$resource{i18n.common.Enabled}" selected="#{pageSession.logAttributes['fish.payara.enterprise.server.logging.PayaraNotificationFileHandler.rotationOnDateChange']}" selectedValue="true" />
</sun:property>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "";
Expand Down Expand Up @@ -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";
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}
}

0 comments on commit 791c1ea

Please sign in to comment.