How to get SLF4J “Hello World” working with log4j?

后端 未结 5 1034
耶瑟儿~
耶瑟儿~ 2020-12-04 13:18

The \"Hello World\" example from SLF4J is not working for me. I guess this is because I added slf4j-log4 to my classpath. Should I configure log4j directly for the hello wor

5条回答
  •  感情败类
    2020-12-04 13:48

    I had the same problem. I called my own custom logger in the log4j.properties file from code when using log4j api directly. If you are using the slf4j api calls, you are probably using the default root logger so you must configure that to be associated with an appender in the log4j.properties:

    
        # Set root logger level to DEBUG and its only appender to A1.
        log4j.rootLogger=DEBUG, A1
    
        # A1 is set to be a ConsoleAppender.
        log4j.appender.A1=org.apache.log4j.ConsoleAppender
    
    

提交回复
热议问题