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

Add config to disable passthrough access logging #2128

Merged
merged 1 commit into from
Jan 23, 2024
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 @@ -149,7 +149,9 @@ public void log(HttpRequest request, HttpResponse response) {
}
String logString = result.toString();
log.debug(logString); //log to the console
accessLogger.log(logString); //log to the file
if (accessLogger.isLoggingEnabled) {
accessLogger.log(logString); //log to the file
}
}

/**
Expand Down Expand Up @@ -873,6 +875,8 @@ public void log(HttpRequestWrapper request, HttpResponseWrapper response) {
}
String logString = result.toString();
log.debug(logString); //log to the console
accessLogger.log(logString); //log to the file
if (accessLogger.isLoggingEnabled) {
accessLogger.log(logString); //log to the file
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ public class AccessConstants {

public static final String CONFIG_FILE_DATE_FORMAT = "access_log_file_date_format";

public static final String CONFIG_ENABLE_LOGGING = "access_log_enable";


public static String getLogPattern() {
return AccessConfiguration.getInstance().getStringProperty(CONFIG_PATTERN, LOG_PATTERN);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import static org.apache.synapse.transport.http.access.AccessConstants.CONFIG_ENABLE_LOGGING;

/**
* Class that logs the Http Accesses to the access log files. Code segment borrowed from
* Apache Tomcat's org.apache.catalina.valves.AccessLogValve with thanks.
Expand All @@ -64,7 +66,9 @@ public class AccessLogger {

public AccessLogger(final Log log) {
super();
this.initOpen();
if (isLoggingEnabled) {
this.initOpen();
}
AccessLogger.log = log;
buffered = true;
checkExists = false;
Expand Down Expand Up @@ -114,6 +118,11 @@ public AccessLogger(final Log log) {
*/
private boolean isRotatable = getBooleanValue(IS_LOG_ROTATABLE, true);

/**
* Enable logging.
*/
public boolean isLoggingEnabled = getBooleanValue(CONFIG_ENABLE_LOGGING, true);

/**
* Log the specified message to the log file, switching files if the date
* has changed since the previous log call.
Expand Down
Loading