The above answer is the only way:
dmesg | grep -v UFW
But you can use this more easily, by setting an alias like this:
alias dmesg='dmesg | grep -v UFW'
This will execute
dmesg | grep -v UFW if you enter
If you want to keep the colorful version of dmesg, you can use the following command:
alias dmesg='dmesg --color=always | grep -v UFW --color=always'
dmesg use colors over the pipe too.
WARNING! Only use this method while viewing logs and searching for something, because this might break some 3rd party scripts in that session.