Skip to content

Commit

Permalink
Merge pull request #2128 from SavinduDimal/passthrough-logs
Browse files Browse the repository at this point in the history
Add config to disable passthrough access logging
  • Loading branch information
SavinduDimal authored Jan 23, 2024
2 parents 5581aa9 + a1bf8bb commit b88b6f3
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
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

0 comments on commit b88b6f3

Please sign in to comment.