0
我正在一個表中記錄與我的數據庫的所有交互(添加用戶,更新用戶...)。將單一日誌寫入不同的數據庫表
從我userService一個例子:
public function addUserAction()
{
$this->logger->alert("Added user!");
// Code that adds the user to the database (not relevant for my question)
// ...
}
public function updateUserAction($user)
{
$this->logger->alert("Updated user!");
// Code that updates the user to the database (not relevant for my question)
// ...
}
現在我想有不同的表如下:log_added_users,log_updated_users等..
在我有一個通道和一個處理器配置我的config.yml 我已經將記錄器注入userService並使用我的頻道對其進行了標記。
services:
userService:
class: Acme\Services\UserService
arguments: ["@logger"]
tags:
- { name: monolog.logger, channel: my_channel }
我想知道我應該在哪個表中添加某個日誌條目?我不認爲我需要更多的渠道,因爲我只能爲注入的記錄器定義一個(如上面的配置代碼片段所示)
所以我想添加更多的處理程序(每個數據庫表一個)。問題是:當日志正在寫入時,它會遍歷所有處理程序,並將相同的日誌添加到所有表中?
或者我應該只是將我的updateUserAction放在另一個服務中,這樣我就可以使用另一個通道了?
任何幫助表示讚賞:)