[logback-user] Reading an environment variable for conf purposes

Rusty Wright rwright.lists at gmail.com
Sun Jan 3 20:28:11 CET 2010


If you're running this as a web application:

Echoing an environment variable shows it set for your login shell, but you also need to set the environment variable for your servlet container (e.g., tomcat, jetty, etc.) when it starts.  Find your shell script startup file for your servlet container (perhaps in /etc/init.d) and edit it and add setting the environment variable; for example, OSC_HOME=whatever; export OSC_HOME.

You may also need to use a java -D flag to set it; I don't have a linux system handy at the moment to see how I did it (try doing a google search).


pablo fernandez wrote:
> Hi,
> 
> I have this logback.xml file:
> 
> <configuration debug="true" scan="true" scanPeriod="60 seconds">
> 
>   <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
>     <layout class="ch.qos.logback.classic.PatternLayout">
>       <Pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - 
> %msg%n</Pattern>
>     </layout>
>   </appender>
>   
>   <appender name="FILE" 
> class="ch.qos.logback.core.rolling.RollingFileAppender">
>     <File>${MY_HOME}/logs/mylog.log</File>
>     
>     <rollingPolicy 
> class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
>       <FileNamePattern>logs/my.%d{yyyy-MM-dd}.log</FileNamePattern>
>       <MaxHistory>30</MaxHistory>
>     </rollingPolicy>
>     
>     <layout class="ch.qos.logback.classic.PatternLayout">
>       <Pattern>%d{HH:mm:ss.SSS} [%thread] %-5level - %msg%n</Pattern>
>     </layout>
>     
>   </appender> 
>   
>   <root level="TRACE">
>     <appender-ref ref="FILE"/>
>   </root>
>     
> </configuration>
> 
> 
> And ${OSC_HOME} is a defined system variable (echo $OSC_HOME on linux 
> shows the correct path).
> 
> The thing is that logback doesnt seem to read it properly, it stores the 
> logs under OSC_HOME_IS_UNDEFINED/logs/my.log
> 
> What am I doing wrong? Thanks a lot!
> -- 
> Fernandez, Pablo.
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> Logback-user mailing list
> Logback-user at qos.ch
> http://qos.ch/mailman/listinfo/logback-user


More information about the Logback-user mailing list