How to pull a trigger?

There is a table in which one column is defined as unique. When you insert duplicate values need to catch the primary key and toss them in a log table. I think we need to call a trigger, function or procedure. Tried to do the insert using INSERT INTO ... ON DUPLICATION KEY UPDATE `id` = `id` and the table hanged AFTER UPDATE trigger but when updating the ID by itself it looks like the update is cut during optimization and does not performed, and therefore the trigger does not fire.
June 26th 19 at 14:22
1 answer
June 26th 19 at 14:24
Or BEFORE UPDATE, but the trigger will have to check the uniqueness of the added value.
Or add another column, for example, `errors` and to do ON DUPLICATE KEY UPDATE `errors` = `errors`+1. Then in the AFTER UPDATE trigger you can just check on the OLD.`errors` != NEW.`errors`.

Find more questions by tags MySQLMariaDB