0

I have a logback-spring.xml as below:

<configuration>

<springProperty scope="context" name="ACTIVE_PROFILE" source="spring.profiles.active"/>

<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
    <Target>System.out</Target>
</appender>

<appender name="cust" class="ch.qos.logback.core.rolling.RollingFileAppender">
    <rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
        <fileNamePattern>${ACTIVE_PROFILE}\logs\data_%d.%i.log</fileNamePattern>

    </rollingPolicy>
</appender>
<appender name="custAppender" class="ch.qos.logback.classic.AsyncAppender">
    <appender-ref ref="cust"/>
</appender>

<!-- LOG everything at INFO level -->
<root level="info">
    <appender-ref ref="custAppender"/>
    <appender-ref ref="console"/>
</root>

<logger name="com.ic" level="trace" additivity="false">
    <appender-ref ref="custAppender"/>
    <appender-ref ref="console"/>
</logger>

This is a spring boot standalone application. When running it like java -jar cust.jar -Dspring.profiles.active=local.

Even though I see in logs that local profile is being set in the application but the logs are not being created under local/logs folder. Instead new folder ACTIVE_PROFILE_IS_UNDEFINED is being created which is having logs folder generated inside it.

I am expecting that <springProperty scope="context" name="ACTIVE_PROFILE" source="spring.profiles.active"/> will store the profile passed into the ACTIVE_PROFILE and I have used same to create the folder but I am not succeeding

Rips
  • 1,964
  • 1
  • 23
  • 45

1 Answers1

0

not
java -jar cust.jar -Dspring.profiles.active=local

Do this
java -jar -Dspring.profiles.active=local cust.jar

order is important

MiraGe
  • 311
  • 4
  • 8