0

I prepared a custom RollingFileAppender configuration in the logback-spring.xml file and application.properties files. The log file soduncu.log created under path /var/app/sefa/logs. This is expected behavior for the configuration but there is an unexpected situation that soduncu.log created under default Linux log path /var/log/. I tried to prevent this unexpected log file creation but I couldn't. What is the situation here and what I did wrong?

logback-spring.xml:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<springProperty name="LOG_DIR" source="logging.path" defaultValue="/var/app/sefa/logs">
</springProperty>
<appender name="ROLLING"
    class="ch.qos.logback.core.rolling.RollingFileAppender">
    <file>${LOG_DIR}/soduncu.log</file>
    <rollingPolicy
        class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
        <!-- rollover daily -->
        <fileNamePattern>${LOG_DIR}/soduncu-%d{yyyy-MM-dd}.%i.log
        </fileNamePattern>
        <maxFileSize>10MB</maxFileSize>
        <maxHistory>60</maxHistory>
        <totalSizeCap>20GB</totalSizeCap>
    </rollingPolicy>
    <encoder>
        <pattern>%date %-4relative [%thread] %-5level %logger{35} - %msg %n</pattern>
    </encoder>
</appender>
<root level="WARN">
    <appender-ref ref="ROLLING" />
</root> 
</configuration>

application.properties:

logging.path=/var/app/sefa/logs
logging.file=/var/app/sefa/logs/soduncu.log
logging.level.root=INFO
logging.level.org.springframework=ERROR
logging.level.com.nuvia=DEBUG

Here is the one Linux process id link to a log file under two different path:

/proc/14368/fd/1 -> /var/log/soduncu.log
/proc/14368/fd/2 -> /var/log/soduncu.log
/proc/14368/fd/6 -> /var/app/sefa/logs/soduncu.log
Marius Jaraminas
  • 813
  • 1
  • 7
  • 19
soduncu
  • 51
  • 1
  • 9

1 Answers1

0

I am unable to replicate this behavior with your code. Try to change

name="LOG_DIR" source="logging.path" 

to

name="LOG_DIR_PATH" source="log.dir.path"

and see what happens make sure to delete soduncu.log from var/log first. I hope it helps.

Vinit Pillai
  • 518
  • 6
  • 17