Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PAYARA-2843 Add Logging format options to Payara Notification Logger #2845

Merged
merged 2 commits into from
Jun 18, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,12 @@
<sun:checkbox label="$resource{i18n.common.Enabled}" selected="#{pageSession.logAttributes['fish.payara.enterprise.server.logging.PayaraNotificationFileHandler.rotationOnDateChange']}" selectedValue="true" />
</sun:property>

<sun:property id="PayaraNotificationLogfileFormat" labelAlign="left" noWrap="#{true}" overlapLabel="#{false}" label="$resource{i18nc.log.FileLogFormat}" helpText="$resource{i18nc.log.FilePayaraNotificationLogFormatHelp}">
<sun:dropDown id="logfileFormat" selected="#{pageSession.logAttributes['fish.payara.enterprise.server.logging.PayaraNotificationFileHandler.formatter']}"
labels={ "ULF","ODL","JSON"}
values={"com.sun.enterprise.server.logging.UniformLogFormatter", "com.sun.enterprise.server.logging.ODLLogFormatter", "fish.payara.enterprise.server.logging.JSONLogFormatter"} />
</sun:property>

<sun:property id="PayaraNotificationFileRotationLimitProp" labelAlign="left" noWrap="#{true}" overlapLabel="#{false}" label="$resource{i18nc.log.FileRotationLimit}" helpText="$resource{i18nc.log.FileRotationLimitHelp}">
<sun:textField id="FileRotationLimit" styleClass="integer" columns="$int{30}" maxLength="#{sessionScope.fieldLengths['maxLength.log.FileRotationLimit']}" text="#{pageSession.logAttributes['fish.payara.enterprise.server.logging.PayaraNotificationFileHandler.rotationLimitInBytes']}" />
<sun:staticText id="byte" style="padding: 8pt" text="$resource{i18n.common.Bytes}"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,7 @@ log.ConsoleLogFormat=Console Logging Format:
log.ConsoleLogFormatHelp=Format for logging to the console
log.FileLogFormat=Log File Logging Format:
log.FileLogFormatHelp=Format for logging to the server log file
log.FilePayaraNotificationLogFormatHelp=Format for logging to the Notification log file
log.excludeFields=Format Exclude Fields:
log.excludeFieldsHelp=Exclude these fields in log records
log.CompressOnRotation=Compress on Rotation:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ fish.payara.enterprise.server.logging.PayaraNotificationFileHandler.rotationLimi
fish.payara.enterprise.server.logging.PayaraNotificationFileHandler.maxHistoryFiles=0
fish.payara.enterprise.server.logging.PayaraNotificationFileHandler.file=${com.sun.aas.instanceRoot}/logs/notification.log
fish.payara.enterprise.server.logging.PayaraNotificationFileHandler.compressOnRotation=false
fish.payara.enterprise.server.logging.PayaraNotificationFileHandler.formatter=com.sun.enterprise.server.logging.ODLLogFormatter

fish.payara.deprecated.jsonlogformatter.underscoreprefix=false

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ public final class Constants {
public final static String PY_HANDLER_MAXIMUM_FILES = PY_FILE_HANDLER + "maxHistoryFiles";
public final static String PY_HANDLER_LOG_FILE = PY_FILE_HANDLER + "file";
public final static String PY_HANDLER_COMPRESS_ON_ROTATION = PY_FILE_HANDLER + "compressOnRotation";
public final static String PY_HANDLER_LOG_FORMATTER = PY_FILE_HANDLER + "formatter";

public final static String GF_HANDLER_LOG_TO_FILE_DEFAULT_VALUE = "true";

Expand All @@ -68,5 +69,6 @@ public final class Constants {
public final static String PY_HANDLER_MAXIMUM_FILES_DEFAULT_VALUE = "0";
public final static String PY_HANDLER_LOG_FILE_DEFAULT_VALUE = "${com.sun.aas.instanceRoot}/logs/notification.log";
public final static String PY_HANDLER_COMPRESS_ON_ROTATION_DEFAULT_VALUE = "false";
public final static String PY_HANDLER_LOG_FORMATTER_DEFAULT_VALUE = "com.sun.enterprise.server.logging.ODLLogFormatter";

}
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,16 @@ public synchronized Map<String, String> checkForLoggingProperties(Map<String, St
setLoggingProperty(Constants.PY_HANDLER_COMPRESS_ON_ROTATION, Constants.PY_HANDLER_COMPRESS_ON_ROTATION_DEFAULT_VALUE, targetConfigName);
}
}

if (!loggingProperties.containsKey(Constants.PY_HANDLER_LOG_FORMATTER)) {
loggingProperties.put(Constants.PY_HANDLER_LOG_FORMATTER, Constants.PY_HANDLER_LOG_FORMATTER_DEFAULT_VALUE);
if (targetConfigName == null || targetConfigName.isEmpty()) {
setLoggingProperty(Constants.PY_HANDLER_LOG_FORMATTER, Constants.PY_HANDLER_LOG_FORMATTER_DEFAULT_VALUE);
} else {
setLoggingProperty(Constants.PY_HANDLER_LOG_FORMATTER, Constants.PY_HANDLER_LOG_FORMATTER_DEFAULT_VALUE, targetConfigName);
}
}

return loggingProperties;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ public class LoggingPropertyNames {
public static final String payaraNotificationFile = PYFileHandler + "file";

public static final String logFormatter = GFFileHandler + "formatter";

public static final String payaraNotificationLogFormatter = PYFileHandler + "formatter";

public static final String logHandler = "handlers";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ public class LoggingXMLNames {
public static final String payaraNotificationLogRotationTimelimitInMinutes = "payara-notification-log-rotation-timelimit-in-minutes";

public static final String logFormatter = "log-formatter";

public static final String payaraNotificationLogFormatter = "payara-notification-log-formatter";

public static final String logHandler = "log-handler";

Expand Down Expand Up @@ -124,6 +126,7 @@ public class LoggingXMLNames {
put(file, LoggingPropertyNames.file);
put(payaraNotificationFile, LoggingPropertyNames.payaraNotificationFile);
put(logFormatter, LoggingPropertyNames.logFormatter);
put(payaraNotificationLogFormatter, LoggingPropertyNames.payaraNotificationLogFormatter);
put(logHandler, LoggingPropertyNames.logHandler);
put(useSystemLogging, LoggingPropertyNames.useSystemLogging);
put(retainErrorStatisticsForHours, LoggingPropertyNames.retainErrorStatisticsForHours);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,8 @@ public class GFFileHandler extends StreamHandler implements
private Long rotationTimeLimitValue;
private boolean compressionOnRotation;
private boolean multiLineMode;
private String gffileHandlerFormatter = "";
private String currentgffileHandlerFormatter = "";
private String fileHandlerFormatter = "";
private String currentFileHandlerFormatter = "";

/** Initially the LogRotation will be off until the domain.xml value is read. */
private int limitForFileRotation = 0;
Expand Down Expand Up @@ -266,9 +266,9 @@ public void postConstruct() {
}

if (odlFormatter > 0) {
currentgffileHandlerFormatter = "com.sun.enterprise.server.logging.ODLLogFormatter";
currentFileHandlerFormatter = "com.sun.enterprise.server.logging.ODLLogFormatter";
} else if (uniformLogFormatter > 0) {
currentgffileHandlerFormatter = "com.sun.enterprise.server.logging.UniformLogFormatter";
currentFileHandlerFormatter = "com.sun.enterprise.server.logging.UniformLogFormatter";
}

// start the Queue consumer thread.
Expand Down Expand Up @@ -333,12 +333,12 @@ public void postConstruct() {

// Below snapshot of the code is used to rotate server.log file on startup. It is used to avoid different format
// log messages logged under same server.log file.
gffileHandlerFormatter = formatterName;
fileHandlerFormatter = formatterName;
if (mustRotate) {
rotate();
} else if (gffileHandlerFormatter != null
&& !gffileHandlerFormatter
.equals(currentgffileHandlerFormatter)) {
} else if (fileHandlerFormatter != null
&& !fileHandlerFormatter
.equals(currentFileHandlerFormatter)) {
rotate();
}
excludeFields = manager.getProperty(LogManagerService.EXCLUDE_FIELDS_PROPERTY);
Expand Down Expand Up @@ -1097,21 +1097,21 @@ public synchronized void setMultiLineMode(boolean multiLineMode) {
this.multiLineMode = multiLineMode;
// Rotate log file to avoid different log format to be displayed in same log file
rotate();
configureLogFormatter(gffileHandlerFormatter, excludeFields, multiLineMode);
configureLogFormatter(fileHandlerFormatter, excludeFields, multiLineMode);
}

public synchronized void setGffileHandlerFormatter(String gffileHandlerFormatter) {
this.gffileHandlerFormatter = gffileHandlerFormatter;
public synchronized void setFileHandlerFormatter(String fileHandlerFormatter) {
this.fileHandlerFormatter = fileHandlerFormatter;
// Rotate log file to avoid different log format to be displayed in same log file
rotate();
configureLogFormatter(gffileHandlerFormatter, excludeFields, multiLineMode);
configureLogFormatter(fileHandlerFormatter, excludeFields, multiLineMode);
}

public synchronized void setExcludeFields(String excludeFields) {
this.excludeFields = excludeFields;
// Rotate log file to avoid different log format to be displayed in same log file
rotate();
configureLogFormatter(gffileHandlerFormatter, excludeFields, multiLineMode);
configureLogFormatter(fileHandlerFormatter, excludeFields, multiLineMode);
}

public synchronized void setRotationLimitAttrValue(Integer rotationLimitAttrValue) {
Expand Down
Loading