Skip to content

Commit

Permalink
Merge pull request #1125 from arunans23/accesslogs
Browse files Browse the repository at this point in the history
Update http access logs configuration
  • Loading branch information
DinithiDiaz authored Nov 22, 2024
2 parents 0066da6 + 6ca922f commit 98557c6
Showing 1 changed file with 35 additions and 41 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -384,10 +384,41 @@ See the instructions on [using wire logs to debug]({{base_path}}/develop/using-w

Access logs related to service/API invocations are enabled by default in the Micro Integrator. Access logs for the PassThrough transport will record the request and the response on **two** separate log lines.

By default, access logs are printed to the `http_acces_.log` file (stored in the `<MI_HOME>/repository/logs` folder). If required, you can use the log4j2 configurations to print the access logs to other destinations. Simply apply the following [logger](#log4j2-loggers) with an [appender](#log4j2-appenders).
By default, access logs are printed to the `http_access.log` file (stored in the `<MI_HOME>/repository/logs` folder). If required, you can use the log4j2 configurations to print the access logs to other destinations. Simply apply the following [logger](#log4j2-loggers) with an [appender](#log4j2-appenders).

- <b>Logger Name</b>: PassThroughAccess
- <b>Logger Class</b>: org.apache.synapse.transport.http.access
- <b>Logger Name</b>: `PassThroughAccess`
- <b>Logger Class</b>: `org.apache.synapse.transport.http.access.logs`

Given below is the default log4j2 configuration for the access logs.

```
logger.PassThroughAccess.name = org.apache.synapse.transport.http.access.logs
logger.PassThroughAccess.level = DEBUG
logger.PassThroughAccess.appenderRef.HTTP_ACCESS_LOGFILE.ref = HTTP_ACCESS_LOGFILE
logger.PassThroughAccess.additivity = false
# Appender config to HTTP access logs
appender.HTTP_ACCESS_LOGFILE.type = RollingFile
appender.HTTP_ACCESS_LOGFILE.name = HTTP_ACCESS_LOGFILE
appender.HTTP_ACCESS_LOGFILE.fileName = ${sys:logfiles.home}/http_access.log
appender.HTTP_ACCESS_LOGFILE.filePattern = ${sys:logfiles.home}/http_access_%d{yyyy-MM-dd}.log
appender.HTTP_ACCESS_LOGFILE.layout.type = PatternLayout
appender.HTTP_ACCESS_LOGFILE.layout.pattern = %msg%n
appender.HTTP_ACCESS_LOGFILE.policies.type = Policies
appender.HTTP_ACCESS_LOGFILE.policies.time.type = TimeBasedTriggeringPolicy
appender.HTTP_ACCESS_LOGFILE.policies.time.interval = 1
appender.HTTP_ACCESS_LOGFILE.policies.time.modulate = true
appender.HTTP_ACCESS_LOGFILE.policies.size.type = SizeBasedTriggeringPolicy
appender.HTTP_ACCESS_LOGFILE.policies.size.size=1MB
appender.HTTP_ACCESS_LOGFILE.strategy.type = DefaultRolloverStrategy
appender.HTTP_ACCESS_LOGFILE.strategy.max = 20
appender.HTTP_ACCESS_LOGFILE.filter.threshold.type = ThresholdFilter
appender.HTTP_ACCESS_LOGFILE.filter.threshold.level = DEBUG
```

To disable the access logs, set the log level of `logger.PassThroughAccess.level` to `OFF` or `WARN`.

The output file name and the file pattern can be customized as required by changing the `fileName` and `filePattern` attributes of the `HTTP_ACCESS_LOGFILE` appender.

### Customizing the Access Log format

Expand All @@ -397,40 +428,6 @@ You can customize the format of this access log by changing the following proper

<table>
<tbody>
<tr class="odd">
<td>access_log_directory</td>
<td>Add this property ONLY if you want to change the default location of the log file. By default, the product is configured to store access logs in the <code>MI_HOME/repository/logs</code> directory.</td>
</tr>
<tr class="even">
<td>access_log_prefix</td>
<td>
<div class="content-wrapper">
<p>The prefix added to the log file's name. The default value is as follows:</p>
<div class="code panel pdl" style="border-width: 1px;">
<div class="codeContent panelContent pdl">
<div class="sourceCode" id="cb1" data-syntaxhighlighter-params="brush: java; gutter: false; theme: Confluence" data-theme="Confluence" style="brush: java; gutter: false; theme: Confluence">
<pre class="sourceCode java"><code class="sourceCode java"><span id="cb1-1"><a href="#cb1-1"></a>access_log_prefix=http_access_</span></code></pre>
</div>
</div>
</div>
</div>
</td>
</tr>
<tr class="odd">
<td>access_log_suffix</td>
<td>
<div class="content-wrapper">
<p>The suffix added to the log file's name. The default value is as follows:</p>
<div class="code panel pdl" style="border-width: 1px;">
<div class="codeContent panelContent pdl">
<div class="sourceCode" id="cb2" data-syntaxhighlighter-params="brush: java; gutter: false; theme: Confluence" data-theme="Confluence" style="brush: java; gutter: false; theme: Confluence">
<pre class="sourceCode java"><code class="sourceCode java"><span id="cb2-1"><a href="#cb2-1"></a>access_log_suffix=.<span class="fu">log</span></span></code></pre>
</div>
</div>
</div>
</div>
</td>
</tr>
<tr class="even">
<td>access_log_file_date_format</td>
<td>
Expand Down Expand Up @@ -496,10 +493,7 @@ You can customize the format of this access log by changing the following proper
</table>

3. Restart the server.
4. Invoke a proxy service or REST API that is deployed in the Micro Integrator. The access log file for the service/API will be created in the `<MI_HOME>/repository/logs` directory. The default name of the log file is `http_access_.log`.

!!! Tip
Note that there will be a delay in printing the logs to the log file.
4. Invoke a proxy service or REST API that is deployed in the Micro Integrator. The access log file for the service/API will be created in the `<MI_HOME>/repository/logs` directory. The default name of the log file is `http_access.log`.

### Supported log pattern formats

Expand Down

0 comments on commit 98557c6

Please sign in to comment.