Kumaresh Roy
Kumaresh Roy

Reputation: 29

slf4j logger is not creating log file in my spring batch application

I am using slf4j in my application for logging purpose. But it's not creating log file in file system but it's logging to console. Below is my log4j.properties file:

 # Root logger option
    log4j.rootLogger=DEBUG, RollingAppender,stdout
    # Redirect log messages to console
    log4j.appender.stdout=org.apache.log4j.ConsoleAppender
    log4j.appender.stdout.Target=System.out
    log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
    log4j.appender.stdout.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n

    # Redirect log messages to a log file
    log4j.appender.RollingAppender=org.apache.log4j.DailyRollingFileAppender
    log4j.appender.RollingAppender.File=E:\\SalesTerritory.log
    log4j.appender.RollingAppender.DatePattern='.'yyyy-MM-dd
    log4j.appender.RollingAppender.layout=org.apache.log4j.PatternLayout
    log4j.appender.RollingAppender.layout.ConversionPattern=[%p] %d %c %M - %m%n


    And dependency I am using in pom.xml for logging is:

    <dependency>
               <groupId>org.slf4j</groupId>
               <artifactId>slf4j-api</artifactId>
               <version>1.7.6</version>
           </dependency>

           <dependency>
             <groupId>org.slf4j</groupId>
             <artifactId>slf4j-log4j12</artifactId>
             <version>1.7.5</version>
          </dependency>[enter image description here][1]

    Please find the dependency jar list in attached image files.
      [1]: https://i.stack.imgur.

com/KGa2x.png

Upvotes: 1

Views: 998

Answers (1)

vishal paalakurthi
vishal paalakurthi

Reputation: 138

use this below Dependency for log4j

   <!-- https://mvnrepository.com/artifact/log4j/log4j -->
    <dependency>
        <groupId>log4j</groupId>
        <artifactId>log4j</artifactId>
        <version>1.2.17</version>
    </dependency>
  • Use INFO in log4j.rootLogger instead of DEBUG because INFO designates informational messages that highlight the progress of the crawl at a coarse-grained level.

Upvotes: 1

Related Questions