Redirect System.out and System.err to slf4j

后端 未结 2 1732
無奈伤痛
無奈伤痛 2020-11-28 09:27

I needed to redirect System.out/err.println outputs to slf4j.

I know that this is not the way to do logging properly but there is an external librar

2条回答
  •  一个人的身影
    2020-11-28 09:40

    You can use sysout-over-slf4j.

    The sysout-over-slf4j module allows a user to redirect all calls to System.out and System.err to an SLF4J defined logger with the name of the fully qualified class in which the System.out.println (or similar) call was made, at configurable levels.

    If you are not using Maven, download the jar and add it to your classpath.

    Alternatively, add it as a Maven dependency:

    
        uk.org.lidalia
        sysout-over-slf4j
        1.0.2
    
    

    Then at application startup, call:

    SysOutOverSLF4J.sendSystemOutAndErrToSLF4J();
    

提交回复
热议问题