Mailing List Archive

Logging of redirect router in mainlog
Accept routers log to mainlog with R=<name of router> , such as:


2021-09-13 14:05:02 1mPpOA-0007aw-AX => test <test@test.com>
R=mysql_autorespond_staff T=address_mysql


Is there a way to get redirect routers to do the same thing? I only get
the R in the logs for the router it redirects to.

Trying to figure out how many emails are actually caught by an old
redirect router I have in use.

Thanks.
Re: Logging of redirect router in mainlog [ In reply to ]
On 13/09/2021 18:19, Patrick Boutilier via Exim-users wrote:
> Accept routers log to mainlog with R=<name of router> , such as:
>
>
> 2021-09-13 14:05:02 1mPpOA-0007aw-AX => test <test@test.com> R=mysql_autorespond_staff T=address_mysql

This is the delivery that is being logged, and the R= there is the (last)
router; the one that selects the transport.

> Is there a way to get redirect routers to do the same thing? I only get the R in the logs for the router it redirects to.

The quick answer is no.

The complex answer is: you can pull tricks by getting the router you want logged
to call a dummy expansion, and use an acl expansion with "logwrite".
--
Cheers,
Jeremy

--
## List details at https://lists.exim.org/mailman/listinfo/exim-users
## Exim details at http://www.exim.org/
## Please use the Wiki with this list - http://wiki.exim.org/
Re: Logging of redirect router in mainlog [ In reply to ]
On Mon, Sep 13, 2021 at 02:19:25PM -0300, Patrick Boutilier via Exim-users wrote:
> Accept routers log to mainlog with R=<name of router> , such as:
>
> 2021-09-13 14:05:02 1mPpOA-0007aw-AX => test <test@test.com>
> R=mysql_autorespond_staff T=address_mysql
>
> Is there a way to get redirect routers to do the same thing?

Use "condition" option for redirect router. It should be evaluated last,
so all other options are checked as usual and control is passed to this
condition if router accepts address. Put to right side of this condition
any code for logging (${run..}, ${acl..}, etc). Example:

custom_redirect:
driver = redirect
[...]
condition = ${acl{log_router}{applied: custom_redirect}}

and in ACL section

log_router:
logwrite = Router message: \"$acl_arg1\"
message = true
--
Eugene Berdnikov

--
## List details at https://lists.exim.org/mailman/listinfo/exim-users
## Exim details at http://www.exim.org/
## Please use the Wiki with this list - http://wiki.exim.org/
Re: Logging of redirect router in mainlog [ In reply to ]
On 9/13/21 4:19 PM, Evgeniy Berdnikov via Exim-users wrote:
> On Mon, Sep 13, 2021 at 02:19:25PM -0300, Patrick Boutilier via Exim-users wrote:
>> Accept routers log to mainlog with R=<name of router> , such as:
>>
>> 2021-09-13 14:05:02 1mPpOA-0007aw-AX => test <test@test.com>
>> R=mysql_autorespond_staff T=address_mysql
>>
>> Is there a way to get redirect routers to do the same thing?
>
> Use "condition" option for redirect router. It should be evaluated last,
> so all other options are checked as usual and control is passed to this
> condition if router accepts address. Put to right side of this condition
> any code for logging (${run..}, ${acl..}, etc). Example:
>
> custom_redirect:
> driver = redirect
> [...]
> condition = ${acl{log_router}{applied: custom_redirect}}
>
> and in ACL section
>
> log_router:
> logwrite = Router message: \"$acl_arg1\"
> message = true
>


Thanks, that works well. Just needed accept in the acl.

log_router:
accept
logwrite = Router message: \"$acl_arg1\"
message = true