Replacing ^M with line break (carriage return or newline) to make viewing log files easier


Some syslog log files produced  contain  ^M  instead of a newline (or carriage return) at where a line ending would normally be.

Systems which use this pattern include the good old Cisco VCS – still my favourite SIP/H.323 call control platform – and also log files from exciting new video conferencing disruptor Pexip – easily my favourite MCU and imho far and away the “best of breed” of next generation video bridges- although I don’t pretend to be in any way unbiased here!

Whilst the use of ^M is actually very useful (as it allows you to easily use powerful command line tools like “grep” to find & filter relevant/interesting logs when troubleshooting) it can mean that reading the logs  you’ve found/filtered that way can be a little bit difficult – particularly if the log contained several  lines  e.g. as a any SIP message would.

There are a number of ways of cleaning these logs  up to make the logs easier for poor humans to read: