V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
• 请不要在回答技术问题时复制粘贴 AI 生成的内容
JasonLaw
V2EX  ›  程序员

使用 IntelliJ IDEA 运行 Spring Boot 应用,日志是有颜色。但是使用 docker 运行的话, docker container logs 没有颜色

  •  
  •   JasonLaw · Apr 8, 2021 · 3118 views
    This topic created in 1858 days ago, the information mentioned may be changed or developed.

    使用 IntelliJ IDEA 运行 Spring Boot 应用,日志是有颜色,如下图:

    但是使用 docker 运行的话,docker container logs没有颜色,怎么让它具有颜色呢?

    Supplement 1  ·  Apr 9, 2021
    6 replies    2021-04-09 14:14:00 +08:00
    xuanbg
        1
    xuanbg  
       Apr 8, 2021
    用 idea 的 docker 插件制作镜像并运行容器,也是有颜色的。但自己运行容器就没了。。。
    JasonLaw
        3
    JasonLaw  
    OP
       Apr 9, 2021
    @chendy #2 我在提问之前看了这个问题。我加了-e "TERM=xterm-256color",但是没有效果。你那边可以出现有颜色的日志?
    JasonLaw
        4
    JasonLaw  
    OP
       Apr 9, 2021
    @xuanbg #1
    @chendy #2

    https://stackoverflow.com/questions/32694928/docker-logs-not-showing-colors-express-nodejs-image

    我加了-it 之后,日志是有颜色的,但是 container 就不能后台运行了。
    bianjp
        5
    bianjp  
    PRO
       Apr 9, 2021   ❤️ 1
    Spring Boot 有个配置项: spring.output.ansi.enabled ( https://docs.spring.io/spring-boot/docs/2.4.4/api/org/springframework/boot/ansi/AnsiOutput.Enabled.html), 默认是 detected, 配置为 always 试试。
    JasonLaw
        6
    JasonLaw  
    OP
       Apr 9, 2021
    @bianjp #5 在提问的时候尝试过这个,但是没有成功,现在竟然 OK 了😅。谢谢啦。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   4228 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 38ms · UTC 05:09 · PVG 13:09 · LAX 22:09 · JFK 01:09
    ♥ Do have faith in what you're doing.