21

Output of tail logs/development.log in XFCE Terminal:

output of tail logs/development.log in XFCE Terminal

multitail log/development.log

output of multitail log/development.log

Rails adds escape codes to log files automatically. See development.log file:

  ^[[1m^[[36m (84.1ms)^[[0m  ^[[1mCREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL) ^[[0m
  ^[[1m^[[35m (92.6ms)^[[0m  CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
  ^[[1m^[[36m (0.2ms)^[[0m  ^[[1mSELECT version FROM "schema_migrations"^[[0m
  ^[[1m^[[35m (159.3ms)^[[0m  INSERT INTO "schema_migrations" (version) VALUES ('20130327221553')
  ^[[1m^[[36m (59.9ms)^[[0m  ^[[1mINSERT INTO "schema_migrations" (version) VALUES ('20130326152730')^[[0m
  ^[[1m^[[35m (59.8ms)^[[0m  INSERT INTO "schema_migrations" (version) VALUES ('20130327173637')

multitail -c produce non-usable output.

Output of multitail -c

How to colorize logs in Multitail without writing own color scheme?

Chris Stryczynski
  • 30,145
  • 48
  • 175
  • 286
A.D.
  • 4,487
  • 3
  • 38
  • 50

1 Answers1

41

It's all about interpreting ANSI escape sequences which does terminal not tail itself and have to do multitail as well. It can be done with -cT ANSI option:

-cT term    interpret terminal-codes from file/command (for terminal type 'term')

Example:

$ multitail -cT ansi log/development.log
multiple files:
$ multitail -cT ansi log/development.log -cT ANSI log/test.log

colorized output of multitail -cT ansi log/development.log

A.D.
  • 4,487
  • 3
  • 38
  • 50
  • 1
    I can't seem to make this work with a piped input... is there a different command for that? edit:: got this working, you just have to make sure the order is correct. multitail -j -cT ansi doesn't work, but multitail -cT ansi -j does – Joshua Jun 30 '20 at 00:42
  • This does not seem to work together with `-Q i path`. I am using version 6.5.0 of `multitail`. Even without `-Q` it fails to render certain colors like light black (90). My only working solution was to go back to using `tail` which renders everything perfectly. I had to go back to writing a single log file, and using `logrotate` to rotate it. – Asclepius Aug 03 '23 at 01:24