Reputation: 741
How to get the log location from spring application code. I am implementing the logging functionality for Spring web service using logback-classic. In the logback.xml, i need to mention the location where my custom log file has to be created. I used below snippet as appender in logback.xml.
<appender name="FILE"
class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${logroot}/wsp-bloa.log</file>
<encoder>
<pattern>%d{ISO8601}|%t|%p|%c{1}|%m%n</pattern>
</encoder>
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
<level>${logger.level}</level>
</filter>
<rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
<fileNamePattern>${logroot}/wsp-bloa%i.log.gz</fileNamePattern>
<minIndex>1</minIndex>
<maxIndex>5</maxIndex>
</rollingPolicy>
<triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
<maxFileSize>5MB</maxFileSize>
</triggeringPolicy>
</appender>
Please let me know if we have any other option to get SERVER_LOG_ROOT other than having adding JVM variable in custom properties to mimic the environment SERVER_LOG_ROOT something like this key: logroot, value: ${SERVER_LOG_ROOT}
Upvotes: 0
Views: 533
Reputation: 71
Nope; the websphere variables aren't available for lookup and aren't registered automatically as jvm properties.
You need to add it as you said as JVM custom properties, or alternatively make use of Resource Environment Entries to map the folder to a custom property that you can look up with jndi.
Upvotes: 1