# Tomcat Access ロギングオン

{% hint style="info" %}

<pre><code><strong>TomcatのaccessログをPLURA ロギング(logging)連動設定する方法です。
</strong></code></pre>

{% endhint %}

### 1. Tomcat server.xmlファイルにロギング関連設定を修正します。 <a href="#id-1" id="id-1"></a>

{% hint style="info" %}

```
# Change for PLURA log format

 <Valve className=”org.apache.catalina.valves.AccessLogValve” directory=”/var/log/plura”
 rotatable=”false”
 renameOnRotate=”false”
 prefix=”weblog” suffix=”.log”
 pattern=”{“Remote-addr”: “%a”, “X-forwarded-for”: “%{X-Forwarded-For}i”, “Request-date”: “%{dd/MM/yyyy:HH:mm:ss.SSS}t +0900”, “Method”: “%m”, “Request”: “%r”, “Host”: “%A”, “Uri”: “%U”, “Cookie”: “%{Cookie}i”, “Referer”: “%{Referer}i”, “User-Agent”: “%{User-Agent}i”, “Status”: “%s”, “Resp-Content-Length”: “%b”}” />
```

{% endhint %}

pattern内”は`&quot;`修正する必要があります。

<figure><img src="/files/k7SlgvyfQM87IMlIdEgm" alt=""><figcaption></figcaption></figure>

▶ Git source, <https://github.com/QubitSecurity/ModPlura/tree/main/tomcat>

### 2. Tomcat logging.propertiesファイルにロギング関連設定を修正します。 <a href="#id-2" id="id-2"></a>

{% hint style="info" %}

```
2localhost.org.apache.juli.AsyncFileHandler.directory = /var/log/plura
 2localhost.org.apache.juli.AsyncFileHandler.prefix = weblog.
 2localhost.org.apache.juli.FileHandler.suffix = log
```

{% endhint %}

### 3. Tomcatリブート <a href="#id-3" id="id-3"></a>

`# systemctl restart tomcat8`

### 4. Tomcatをウェブシステムとして認識させるコマンド

`# echo “ModPlura-tomcat” > /etc/modplura`

`# echo “0.0.1” >> /etc/modplura`

`# touch /etc/.modplura`

<br>

### 5. Tomcat Accessログファイルに権限付与 <a href="#id-5" id="id-5"></a>

`# touch /var/log/plura/weblog.log`

`# chmod -R 766 /var/log/plura/weblog.log`

`# chcon -t syslog_log_t /var/log/plura/weblog.log`

<br>

### 内部ブログ <a href="#id-6" id="id-6"></a>

<https://docs.plura.io/ja/faq/siem/syslog/tomcat-catalina.out>

<br>

### 参考サイト <a href="#id-7" id="id-7"></a>

<https://tomcat.apache.org/tomcat-9.0-doc/config/valve.html>

<https://m.blog.naver.com/solinsystem/221796167356>

<https://gyrfalcon.tistory.com/entry/Apache-Tomcat-access-log-%EC%84%A4%EC%A0%95>

<https://gyrfalcon.tistory.com/entry/Apache-Tomcat-access-log-%EC%84%A4%EC%A0%95>

<https://stackoverflow.com/questions/39896222/how-to-include-time-format-with-millisecond-precision-in-apache-access-log>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.plura.io/ja/faq/siem/logging/tomcat-access.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
