Please use below in logger
%dw 2.0
import * from dw::core::Strings
output application/json
substring(text, 1, 5)
dw functions can be used in logger and it will print