java - log4J is Not Writing to Specific Log File in Spring Boot Microservice -


am trying use log4j write local log file in filesystem.

actually used exact properties file different project , changed name of top level directory match app's name. different project writes logs.log file doesn't print content @ all. both projects use same version of log4j.

pom.xml

<dependency>    <groupid>log4j</groupid>    <artifactid>log4j</artifactid>    <version>1.2.17</version> </dependency> 

on unix based macos, cd'ed /var/log/ , did following:

sudo mkdir myapp chmod 777 myapp 

have inside myapp, following setup on place:

if (log.isdebugenabled() {    log.debug("print something"); } 

myapp/src/main/resources/log4j.properties:

log4j.rootcategory=debug, rf  log4j.category.your.category.name=debug  log4j.appender.stdout=org.apache.log4j.consoleappender log4j.appender.stdout.layout=org.apache.log4j.patternlayout  log4j.appender.stdout.layout.conversionpattern=%-5p [%f]: %m [%d{iso8601}]%n log4j.logger.com.amazonaws=debug rf  log4j.appender.rf=org.apache.log4j.rollingfileappender log4j.appender.rf.file=/var/log/myapp/logs.log  log4j.appender.rf.maxfilesize=10mb log4j.appender.rf.maxbackupindex=30 log4j.appender.rf.layout=org.apache.log4j.patternlayout log4j.appender.rf.layout.conversionpattern=[%d{iso8601}]%5p%6.6r[%t]%x(%f:%l) - %m%n threshold=debug 

don't understand why inside:

/var/log/myapp/  

there's no logs.log file present!

am using inside spring boot 1.5.4.release build using:

mvn clean install 

and run using either:

java -jar myapp.jar  

or

mvn spring-boot:run 

would appreciate if provide me either better properties file or see doing wrong?

thank taking time read this.

@veeram right - logs printed logback, comes along spring boot. need replace log4j. however, not option:

from spring boot 1.4.0 release notes:

log4j 1 support has been removed following apache eol announcement.

so may suggest consider upgrade log4j 2.

p.s. think still can use log4j 1.2, in case, have define , specify dependencies should excluded spring-boot-starter-logging module, , should added instead. i've set demo project reproduce problem , here list of dependencies in build.gradle (i use gradle, think point):

dependencies {     compile('org.springframework.boot:spring-boot-starter') {         exclude group: 'ch.qos.logback'         exclude group: 'org.slf4j', module: 'log4j-over-slf4j'     }     compile('commons-logging:commons-logging:1.2')     compile('log4j:log4j:1.2.17')     compile('org.slf4j:slf4j-log4j12:1.7.25')     testcompile('org.springframework.boot:spring-boot-starter-test') } 

Comments

Popular posts from this blog

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -