For logging specific strings you'd need to alter the src to check each string and compare it against an array of words.. which is very resource intensive.
You could achieve the same thing in NPC scripting which is easier to code and manage, but would use more resources than the src version.
// Log CHAT (Global, Whisper, Party, Guild, Main chat, Clan) (Note 3)
// LOGGING FILTERS
// =============================================================
// 0 = Don't log at all
// 1 - Log Global messages
// 2 - Log Whisper messages
// 4 - Log Party messages
// 8 - Log Guild messages
// 16 - Log Main chat messages
// 32 - Log Clan messages
// Example:
// log_chat: 5 = logs both Whisper & Party messages
// log_chat: 8 = logs only Guild messages
// log_chat: 63 = logs everything
log_chat: 0
SQL logging is enabled by default. log_chat should be 63 to log all chats.