Search code examples
logback

How can I get bat to colorize *.log files and honor the escape codes in the log file itself


I have .log files that were generated by a Java program using logback. Some of the columns in the log file are colorized with logback. The escape codes for the colors are embedded in the file.

When I view this file with an older version 0.6.0 of bat the log file is displayed with all the original colors. But, i just installed bat version 0.19.0 and now *.log files are displayed differently. bat --list-languages shows that there is a language called log mapped to *.log. What is this "log" language? How do I change it to just show the raw file with its embedded colors?


Solution

  • Ok, after a little more poking around, I found this seemed to work:

    $ batcat --map-syntax "*.log:Plain Text" buildout.log 
    

    Apparently, "Plain Text" will generate output that is not as plain as /usr/bin/cat. "Plain Text" will honor the embedded escape codes.