java - spring mvc app on tomcat : slf4j doesn't find logback.xml and only logs to catalina.out -


update: question has been solved. problem tried put log files directory tomcat7 user did not have access. see answers , comments below.

original post:

i have spring mvc app runs on tomcat

i build app gradle (3.0)

i have installed slf4j logs catalina.out (same in post unable find logback.xml)

i have put logback.xml file both under 'project\src\main\java' , under 'project\src\main\webapp\resources', either way doesn't create log files, puts logs catalina.out

from other post mentioned above, says put file under classpath, understand 'project\src' directory

any ideas on how work out appreciated

thanks ahl

logback.xml:

<?xml version="1.0" encoding="utf-8"?> <configuration>      <!-- *** configure application log directory *** -->     <property name="dev_home" value="/var/lib/tomcat7/logs/spring4-1" />      <appender name="stdout" class="ch.qos.logback.core.consoleappender">         <layout class="ch.qos.logback.classic.patternlayout">             <pattern>                 %d{yyyy-mm-dd hh:mm:ss} [%thread] %-5level %logger{36} - %msg%n             </pattern>         </layout>     </appender>      <appender name="file-audit"         class="ch.qos.logback.core.rolling.rollingfileappender">         <file>${dev_home}/debug.log</file>         <encoder class="ch.qos.logback.classic.encoder.patternlayoutencoder">             <pattern>                 %d{yyyy-mm-dd hh:mm:ss} - %msg%n             </pattern>         </encoder>          <rollingpolicy class="ch.qos.logback.core.rolling.timebasedrollingpolicy">             <!-- rollover daily -->             <filenamepattern>${dev_home}/archived/debug.%d{yyyy-mm-dd}.%i.log                         </filenamepattern>             <timebasedfilenamingandtriggeringpolicy                 class="ch.qos.logback.core.rolling.sizeandtimebasedfnatp">                 <maxfilesize>10mb</maxfilesize>             </timebasedfilenamingandtriggeringpolicy>         </rollingpolicy>      </appender>      <appender name="file-error"         class="ch.qos.logback.core.rolling.rollingfileappender">         <file>${dev_home}/error.log</file>         <encoder class="ch.qos.logback.classic.encoder.patternlayoutencoder">             <pattern>                 %d{yyyy-mm-dd hh:mm:ss} - %msg%n             </pattern>         </encoder>          <rollingpolicy class="ch.qos.logback.core.rolling.timebasedrollingpolicy">             <!-- rollover daily -->             <filenamepattern>${dev_home}/archived/error.%d{yyyy-mm-dd}.%i.log                         </filenamepattern>             <timebasedfilenamingandtriggeringpolicy                 class="ch.qos.logback.core.rolling.sizeandtimebasedfnatp">                 <maxfilesize>10mb</maxfilesize>             </timebasedfilenamingandtriggeringpolicy>         </rollingpolicy>      </appender>      <!-- send logs both console , file audit -->     <logger name="com.concretepage" level="debug"         additivity="false">         <appender-ref ref="file-audit" />         <appender-ref ref="stdout" />     </logger>      <root level="error">         <appender-ref ref="file-error" />     </root>  </configuration> 

project tree:

vagrant@precise32:/vagrant/spring4restangularjs$ tree . . |-- build |   |-- classes |   |   `-- main |   |       `-- com |   |           `-- concretepage |   |               |-- config |   |               |   |-- appconfig.class |   |               |   |-- dbconfig.class |   |               |   `-- webappinitializer.class |   |               |-- controller |   |               |   `-- personcontroller.class |   |               |-- dao |   |               |   |-- ipersondao.class |   |               |   `-- persondao.class |   |               |-- entity |   |               |   `-- person.class |   |               `-- service |   |                   |-- ipersonservice.class |   |                   `-- personservice.class |   |-- dependency-cache |   |-- libs |   |   `-- spring4-1.war |   |-- resources |   |   `-- main |   |       `-- logback.xml |   `-- tmp |       |-- compilejava |       |   `-- emptysourcepathref |       `-- war |           `-- manifest.mf |-- build.gradle |-- deploy.sh `-- src     `-- main         |-- java         |   `-- com         |       `-- concretepage         |           |-- config         |           |   |-- appconfig.java         |           |   |-- dbconfig.java         |           |   `-- webappinitializer.java         |           |-- controller         |           |   `-- personcontroller.java         |           |-- dao         |           |   |-- ipersondao.java         |           |   `-- persondao.java         |           |-- entity         |           |   `-- person.java         |           `-- service         |               |-- ipersonservice.java         |               `-- personservice.java         |-- resources         |   `-- logback.xml         `-- webapp             |-- resources             |   |-- css             |   |   `-- style.css             |   |-- js             |   |   |-- app.js             |   |   `-- lib             |   |       |-- angular.min.js             |   |       `-- angular-resource.min.js             |   `-- sql             |       `-- db.sql             `-- web-inf                 `-- view                     `-- home.jsp  37 directories, 30 files vagrant@precise32:/vagrant/spring4restangularjs$ 

build.gradle:

apply plugin: 'java' apply plugin: 'eclipse' apply plugin: 'war' archivesbasename = 'spring4' version = '1'  repositories {     mavencentral() } dependencies {     compile 'org.springframework.boot:spring-boot-starter-web:1.3.3.release'     compile 'org.springframework.boot:spring-boot-starter-data-jpa:1.3.3.release'     compile 'org.hibernate:hibernate-core:4.3.6.final'     compile 'mysql:mysql-connector-java:5.1.31'     compile 'commons-dbcp:commons-dbcp:1.4'     providedruntime 'org.springframework.boot:spring-boot-starter-tomcat:1.3.3.release'         compile "ch.qos.logback:logback-classic:1.1.3"     compile "org.slf4j:log4j-over-slf4j:1.7.13" }  configurations.all {     exclude group: "org.slf4j", module: "slf4j-log4j12"     exclude group: "log4j", module: "log4j" } sourcesets {     main {         resources {             srcdirs "src/main/resources"         }     } } 

tomcat user runs server process:

vagrant@precise32:/vagrant/spring4restangularjs$ ps auxwww | grep -v grep | grep tomcat tomcat7   2435  3.2 77.0 1238660 291328 ?      sl   14:13   0:16 /usr/lib/jvm/java-7-oracle/bin/java -djava.util.logging.config.file=/var/lib/tomcat7/conf/logging.properties -djava.awt.headless=true -xmx128m -xx:+useconcmarksweepgc -djava.util.logging.manager=org.apache.juli.classloaderlogmanager -xms512m -xmx1024m -djava.endorsed.dirs=/usr/share/tomcat7/endorsed -classpath /usr/share/tomcat7/bin/bootstrap.jar:/usr/share/tomcat7/bin/tomcat-juli.jar -dcatalina.base=/var/lib/tomcat7 -dcatalina.home=/usr/share/tomcat7 -djava.io.tmpdir=/tmp/tomcat7-tomcat7-tmp org.apache.catalina.startup.bootstrap start vagrant@precise32:/vagrant/spring4restangularjs$ 

permissions of log folder:

vagrant@precise32:/vagrant/spring4restangularjs$ ll /home/vagrant/ total 72 drwxr-xr-x 7 vagrant vagrant 4096 sep  2 19:04 ./ drwxr-xr-x 3 root    root    4096 sep 14  2012 ../ -rw------- 1 vagrant vagrant 8574 sep  3 09:31 .bash_history -rw-r--r-- 1 vagrant vagrant  220 sep 14  2012 .bash_logout -rw-r--r-- 1 vagrant vagrant 3486 sep 14  2012 .bashrc drwx------ 2 vagrant vagrant 4096 sep 14  2012 .cache/ drwxrwxr-x 6 vagrant vagrant 4096 aug 28 20:01 .gradle/ drwxrwxr-x 2 vagrant vagrant 4096 sep  2 19:04 logs/ drwxrwxr-x 3 vagrant vagrant 4096 aug 27 21:59 .m2/ -rw------- 1 vagrant vagrant 1155 aug 30 22:28 .mysql_history -rwxr-xr-x 1 vagrant vagrant 6487 sep 14  2012 postinstall.sh* -rw-r--r-- 1 vagrant vagrant  675 sep 14  2012 .profile drwx------ 2 vagrant vagrant 4096 aug 27 08:37 .ssh/ -rw-r--r-- 1 vagrant vagrant    0 sep 14  2012 .sudo_as_admin_successful -rw------- 1 vagrant vagrant    6 sep 14  2012 .vbox_version -rw------- 1 vagrant vagrant   12 sep 14  2012 .veewee_version vagrant@precise32:/vagrant/spring4restangularjs$ 

how starting server? sure user running server process has permissions /home/vagrant/logs directory?

also, in logback.xml, trying setting debug attribute:

<configuration debug="true">  

that should output lot of additional information catalina.out if logback.xml getting picked up.


Comments