Reputation: 3329
I have a logback xml as follows:
<?xml version="1.0" encoding="UTF-8"?>
<configuration debug="false" scan="true">
<contextListener class="ch.qos.logback.classic.jul.LevelChangePropagator" />
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%d{yyyy-MM-dd HH:mm:ss} [%thread] %-5level %logger{50} - %msg%n</pattern>
</encoder>
</appender>
<appender name="LOGFILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>/mnt/test/testLog.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
<fileNamePattern>/mnt/test/testLog_%i.log</fileNamePattern>
<minIndex>1</minIndex>
<maxIndex>10</maxIndex>
</rollingPolicy>
<triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
<maxFileSize>10MB</maxFileSize>
</triggeringPolicy>
<encoder>
<pattern>%d{yyyy-MM-dd HH:mm:ss} [%thread] %-5level %logger{50} - %msg%n</pattern>
</encoder>
</appender>
<logger name="weblogic" level="INFO" additivity="false">
<appender-ref ref="LOGFILE"/>
</logger>
<logger name="org.apache" level="ERROR" />
<logger name="httpclient" level="ERROR" />
<logger name="org.test.abc" level="INFO" />
<root level="INFO">
<appender-ref ref="STDOUT" />
</root>
</configuration>
My gradle entry is as follows:
build.gradle dependencies is as follows:
dependencies {
compileOnly 'javax:javaee-api:8.0.1'
// junit
implementation 'junit:junit:4.12'
// logger
testImplementation 'ch.qos.logback:logback-classic:0.9.26'
// jackson
implementation 'com.fasterxml.jackson.core:jackson-annotations:2.13.3'
implementation 'com.fasterxml.jackson.core:jackson-databind:2.13.3'
implementation 'com.fasterxml.jackson.datatype:jackson-datatype-hibernate5:2.13.3'
// hibernate
implementation 'org.hibernate.common:hibernate-commons-annotations:5.0.1.Final'
implementation 'org.hibernate:hibernate-core:5.2.10.Final'
// apache
implementation 'org.apache.commons:commons-lang3:3.12.0'
implementation 'commons-io:commons-io:2.2'
implementation 'org.apache.poi:poi:3.16'
implementation 'org.apache.poi:poi-ooxml:3.16'
implementation 'org.apache.poi:poi-ooxml-schemas:3.16'
implementation 'org.apache.poi:ooxml-schemas:1.1'
// lombok
implementation 'org.projectlombok:lombok:1.18.12'
// swagger
implementation 'io.swagger.core.v3:swagger-annotations:2.2.2'
implementation 'io.swagger.core.v3:swagger-core:2.2.2'
implementation 'io.swagger.core.v3:swagger-integration:2.2.2'
implementation 'io.swagger.core.v3:swagger-jaxrs2:2.2.2'
implementation 'io.springfox:springfox-boot-starter:3.0.0'
// guava
implementation 'com.google.guava:guava:27.0.1-android'
// jjwt
implementation 'io.jsonwebtoken:jjwt:0.9.1'
// spring
implementation 'org.springframework:spring-core:5.2.6.RELEASE'
implementation 'org.springframework:spring-webmvc:5.2.6.RELEASE'
implementation 'org.springframework:spring-jdbc:5.2.6.RELEASE'
implementation 'org.springframework.data:spring-data-jpa:2.2.7.RELEASE'
// Spring security
implementation 'org.springframework.security:spring-security-core:5.2.6.RELEASE'
implementation 'org.springframework.security.oauth:spring-security-oauth2:2.5.0.RELEASE'
// AWS S3 related Jars
implementation group: 'software.amazon.awssdk', name: 's3', version: '2.17.282'
deploy files(war)
}
While I compile and deploy the loggers appears in the console output but nothing is written to the /mnt/test/testLog.log file. The reason i have given the dependecies is to make sure there is no version mismatch. Can someone let me know where am i going wrong with the gradle implementation.
Any input is highly appreciated.
Upvotes: 0
Views: 717
Reputation: 2438
you have not actually used the file appender with a real logger section - there may not be any loggers with exact name as 'weblogic' in your runtime
<logger name="weblogic" level="INFO" additivity="false">
<appender-ref ref="LOGFILE"/>
</logger>
to test if it works try
<root level="INFO">
<appender-ref ref="STDOUT"/>
<appender-ref ref="LOGFILE"/>
</root>
Upvotes: 1