Skip to content

Commit

Permalink
Merge pull request payara#512 from JamesHillyard/FISH-5703
Browse files Browse the repository at this point in the history
FISH-5703 Option to Improve Logging Speed
  • Loading branch information
JamesHillyard authored Dec 2, 2021
2 parents f84d956 + e1396e0 commit fc815e7
Show file tree
Hide file tree
Showing 13 changed files with 61 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@ public static void saveLoggingAttributes(HandlerContext handlerCtx) {
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.logStandardStreams") ||
key.equals("com.sun.enterprise.server.logging.GFFileHandler.fastLogging") ||
key.equals("fish.payara.enterprise.server.logging.PayaraNotificationFileHandler.logtoFile") ||
key.equals("fish.payara.enterprise.server.logging.PayaraNotificationFileHandler.rotationOnDateChange") ||
key.equals("fish.payara.enterprise.server.logging.PayaraNotificationFileHandler.compressOnRotation"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,10 @@
<sun:checkbox label="$resource{i18n.common.Enabled}" selected="#{pageSession.logAttributes['com.sun.enterprise.server.logging.GFFileHandler.multiLineMode']}" selectedValue="true" />
</sun:property>

<sun:property id="fastLogging" labelAlign="left" noWrap="#{true}" overlapLabel="#{false}" label="$resource{i18nc.log.fastLogging}" helpText="$resource{i18nc.log.fastLoggingHelp}">
<sun:checkbox label="$resource{i18n.common.Enabled}" selected="#{pageSession.logAttributes['com.sun.enterprise.server.logging.GFFileHandler.fastLogging']}" selectedValue="true" />
</sun:property>

<sun:property id="consoleFormat" labelAlign="left" noWrap="#{true}" overlapLabel="#{false}" label="$resource{i18nc.log.ConsoleLogFormat}" helpText="$resource{i18nc.log.ConsoleLogFormatHelp}">
<sun:dropDown id="consoleFormat" selected="#{pageSession.logAttributes['java.util.logging.ConsoleHandler.formatter']}"
labels={ "ULF","ODL","JSON"}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
# only if the new code is made subject to such option by the copyright
# holder.
#
# Portions Copyright [2016-2019] [Payara Foundation and/or its affiliates]
# Portions Copyright [2016-2021] [Payara Foundation and/or its affiliates]

## 'server' is the name of the server instance. No Not Translate it.
tree.adminServer=server (Admin Server)
Expand Down Expand Up @@ -393,6 +393,8 @@ log.MaxHistoryFiles=Maximum History Files:
log.MaxHistoryFilesHelp=Maximum number of log files to keep. Enter 0 to keep all rotated log files.
log.multiLineMode=Multiline Mode:
log.multiLineModeHelp=Start the log message body on a new line after the message header
log.fastLogging=Fast Logging:
log.fastLoggingHelp=When enabled, the forced toString on parameters which may result in database access is skipped.
log.ConsoleLogFormat=Console Logging Format:
log.ConsoleLogFormatHelp=Format for logging to the console
log.LogStandardStreams=Log Standard Streams:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
* holder.
*/

// Portions Copyright [2018-2019] [Payara Foundation and/or its affiliates]
// Portions Copyright [2018-2021] [Payara Foundation and/or its affiliates]

package com.sun.enterprise.config.serverbeans;

Expand Down Expand Up @@ -202,6 +202,22 @@ public interface LogService extends ConfigBeanProxy {
* @throws PropertyVetoException
*/
public void setLogToFile(String value) throws PropertyVetoException;

/**
* Gets the value of the fastLogging property.
*
* @return possible object is {@link String }
*/
@Attribute(defaultValue = "false", dataType = Boolean.class)
public String getFastLogging();

/**
* Sets the value of the fastLogging property.
*
* @param value allowed object is {@link String }
* @throws PropertyVetoException
*/
public void setFastLogging(String value) throws PropertyVetoException;

/**
* Gets the value of the Payara Notification logToFile property.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
* only if the new code is made subject to such option by the copyright
* holder.
*/
// Portions Copyright [2018-2019] [Payara Foundation and/or its affiliates]
// Portions Copyright [2018-2021] [Payara Foundation and/or its affiliates]

package com.sun.enterprise.admin.servermgmt.logging;

Expand Down Expand Up @@ -134,6 +134,7 @@ private void doUpgrade(Config config) {
logLevels.put("payara-notification-log-to-file", logService.getPayaraNotificationLogToFile());
logLevels.put("log-to-console", logService.getLogToConsole());
logLevels.put("log-rotation-limit-in-bytes", logService.getLogRotationLimitInBytes());
logLevels.put("fast-logging", logService.getFastLogging());
logLevels.put("payara-notification-log-rotation-limit-in-bytes", logService.getPayaraNotificationLogRotationLimitInBytes());
logLevels.put("log-rotation-timelimit-in-minutes", logService.getLogRotationTimelimitInMinutes());
logLevels.put("payara-notification-log-rotation-timelimit-in-minutes", logService.getPayaraNotificationLogRotationTimelimitInMinutes());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ java.util.logging.FileHandler.limit=50000
java.util.logging.FileHandler.pattern=%h/java%u.log
com.sun.enterprise.server.logging.GFFileHandler.compressOnRotation=false
com.sun.enterprise.server.logging.GFFileHandler.excludeFields=
com.sun.enterprise.server.logging.GFFileHandler.fastLogging=false
com.sun.enterprise.server.logging.GFFileHandler.file=${com.sun.aas.instanceRoot}/logs/server.log
com.sun.enterprise.server.logging.GFFileHandler.flushFrequency=1
com.sun.enterprise.server.logging.GFFileHandler.formatter=com.sun.enterprise.server.logging.ODLLogFormatter
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
* holder.
*/

// Portions Copyright [2018-2019] [Payara Foundation and/or its affiliates]
// Portions Copyright [2018-2021] [Payara Foundation and/or its affiliates]

package org.glassfish.admin.amx.impl.mbean;

Expand Down Expand Up @@ -233,6 +233,7 @@ public Map<String, String> getLoggingAttributes() {
attributes.put(gfHandler + ".logtoConsole", props.get(gfHandler + ".logtoConsole"));
attributes.put(gfHandler + ".flushFrequency", props.get(gfHandler + ".flushFrequency"));
attributes.put(gfHandler + ".logStandardStreams", props.get(gfHandler + ".logStandardStreams"));
attributes.put(gfHandler + ".fastLogging", props.get(gfHandler + ".fastLogging"));
attributes.put("handlers", props.get("handlers"));
attributes.put(sysHandler + ".useSystemLogging", props.get(sysHandler + ".useSystemLogging"));
return attributes;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,19 +38,23 @@
* holder.
*/

// Portions Copyright [2016-2021] [Payara Foundation]
// Portions Copyright [2016-2021] [Payara Foundation and/or its affiliates]

package com.sun.common.util.logging;

import java.util.logging.LogRecord;
import java.util.logging.Level;
import java.util.logging.LogManager;
import java.util.logging.LogRecord;

/**
* This class provides additional attributes not supported by JUL LogRecord
* @author rinamdar
*/
public class GFLogRecord extends LogRecord {

private static final String FAST_LOGGER_PROPERTY = "com.sun.enterprise.server.logging.GFFileHandler.fastLogging";
public static Boolean fastLogging = Boolean.parseBoolean(LogManager.getLogManager().getProperty(FAST_LOGGER_PROPERTY));

/**
* SVUID for serialization compatibility
*/
Expand Down Expand Up @@ -116,13 +120,20 @@ public static GFLogRecord wrap(LogRecord record, boolean setThreadName) {
* Append the original parameters at the end, as they are used for by some logging formatters,
* such as JSON logging formatter for context
*
* FISH-5703
* Add the option to skip the toString() method as it can have force a JPA entity to result
* in database access, causing a performance impact.
*
* @param params
* @return parameter array
*/
private static Object[] transformParameters(Object[] params) {
if (params == null) {
return null;
}
if (fastLogging) {
return params;
}
Object[] result = new Object[params.length * 2];
System.arraycopy(params, 0, result, params.length, params.length);
for (int stringParamsIndex = 0, originalParamsIndex = params.length;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ public class LoggingConfigImpl implements LoggingConfig {
DEFAULT_LOG_PROPERTIES.put(PY_FILE_HANDLER + ".compressOnRotation", "false");
DEFAULT_LOG_PROPERTIES.put(GF_FILE_HANDLER + ".logStandardStreams", "true");
DEFAULT_LOG_PROPERTIES.put(PY_FILE_HANDLER + ".formatter", "com.sun.enterprise.server.logging.ODLLogFormatter");
DEFAULT_LOG_PROPERTIES.put(GF_FILE_HANDLER + ".fastLogging", "false");
}

@Inject
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
* holder.
*/

// Portions Copyright [2018-2019] [Payara Foundation and/or its affiliates]
// Portions Copyright [2018-2021] [Payara Foundation and/or its affiliates]

package com.sun.common.util.logging;

Expand Down Expand Up @@ -80,6 +80,8 @@ public class LoggingPropertyNames {

public static final String logToConsole = GFFileHandler + "logtoConsole";

public static final String fastLogging = GFFileHandler + "fastLogging";

public static final String alarms = GFFileHandler + "alarms";

public static final String logStandardStreams = GFFileHandler + "logStandardStreams";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ public class LoggingXMLNames {
public static final String logFilter = "log-filter";

public static final String logToFile = "log-to-file";

public static final String fastLogging = "fast-logging";

public static final String payaraNotificationLogToFile = "payara-notification-log-to-file";

Expand Down Expand Up @@ -137,6 +139,7 @@ public class LoggingXMLNames {
put(logToFile, LoggingPropertyNames.logToFile);
put(payaraNotificationLogToFile, LoggingPropertyNames.payaraNotificationLogToFile);
put(logToConsole, LoggingPropertyNames.logToConsole);
put(fastLogging, LoggingPropertyNames.fastLogging);
put(alarms, LoggingPropertyNames.alarms);
put(root, LogDomains.DOMAIN_ROOT + LEVEL);
put(server, LogDomains.SERVER_LOGGER + LEVEL);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@

package com.sun.enterprise.server.logging;

import com.sun.common.util.logging.GFLogRecord;
import com.sun.common.util.logging.LoggingConfig;
import com.sun.common.util.logging.LoggingConfigFactory;
import com.sun.common.util.logging.LoggingXMLNames;
Expand Down Expand Up @@ -160,6 +161,7 @@ public class LogManagerService implements PostConstruct, PreDestroy, org.glassfi
String logFormatDateFormatDetail = "";
String compressOnRotationDetail = "";
String logStandardStreamsDetail = "";
String fastLoggingDetail = "";

//Payara Notification Logging
String payaraNotificationLogFileDetail = "";
Expand Down Expand Up @@ -195,6 +197,7 @@ public class LogManagerService implements PostConstruct, PreDestroy, org.glassfi
private static final String LOGFORMAT_DATEFORMAT_PROPERTY = "com.sun.enterprise.server.logging.GFFileHandler.logFormatDateFormat";
private static final String COMPRESS_ON_ROTATION_PROPERTY = "com.sun.enterprise.server.logging.GFFileHandler.compressOnRotation";
private static final String LOG_STANDARD_STREAMS_PROPERTY = "com.sun.enterprise.server.logging.GFFileHandler.logStandardStreams";
private static final String FAST_LOGGER_PROPERTY = "com.sun.enterprise.server.logging.GFFileHandler.fastLogging";

//Payara Notification Logging
private static final String PAYARA_NOTIFICATION_LOG_FILE_PROPERTY = "fish.payara.enterprise.server.logging.PayaraNotificationFileHandler.file";
Expand Down Expand Up @@ -725,6 +728,11 @@ public void changed(File changedFile) {
}
}
}
} else if (a.equals(FAST_LOGGER_PROPERTY)) {
if (!val.equals(fastLoggingDetail)) {
fastLoggingDetail = val;
GFLogRecord.fastLogging = Boolean.parseBoolean(fastLoggingDetail);
}
} else if (a.equals(COMPRESS_ON_ROTATION_PROPERTY)) {
if (!val.equals(compressOnRotationDetail)) {
compressOnRotationDetail = val;
Expand Down Expand Up @@ -983,6 +991,7 @@ private void setDefaultLoggingProperties(Map<String, String> props) {
logFormatDateFormatDetail = props.get(LOGFORMAT_DATEFORMAT_PROPERTY);
compressOnRotationDetail = props.get(COMPRESS_ON_ROTATION_PROPERTY);
logStandardStreamsDetail = props.get(LOG_STANDARD_STREAMS_PROPERTY);
fastLoggingDetail = props.get(FAST_LOGGER_PROPERTY);

//Payara Notification Logging
payaraNotificationLogFileDetail = props.get(PAYARA_NOTIFICATION_LOG_FILE_PROPERTY);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
* only if the new code is made subject to such option by the copyright
* holder.
*/
// Portions Copyright [2016-2019] [Payara Foundation and/or its affiliates]
// Portions Copyright [2016-2021] [Payara Foundation and/or its affiliates]
package com.sun.enterprise.server.logging.commands;

import com.sun.common.util.logging.LoggingConfigFactory;
Expand Down Expand Up @@ -140,6 +140,7 @@ public class SetLogAttributes implements AdminCommand {
"com.sun.enterprise.server.logging.GFFileHandler.multiLineMode",
"com.sun.enterprise.server.logging.GFFileHandler.compressOnRotation",
"com.sun.enterprise.server.logging.GFFileHandler.logStandardStreams",
"com.sun.enterprise.server.logging.GFFileHandler.fastLogging",
"com.sun.enterprise.server.logging.UniformLogFormatter.ansiColor",
"com.sun.enterprise.server.logging.UniformLogFormatter.infoColor",
"com.sun.enterprise.server.logging.UniformLogFormatter.warnColor",
Expand Down

0 comments on commit fc815e7

Please sign in to comment.