Issue Type: Bug Bug
Affects Versions: 1.0.13
Assignee: Logback dev list
Components: logback-classic, logback-core
Created: 13/Nov/13 2:19 PM
Description:

I am trying to use Janino condition to instantiate default Logback SMTP appender if and only if javax.mail is present is application classpath. Here is my simple config file for that purposes:

<property name="common.log.date.format" value="{MM/dd HH:mm:ss:SSS}" />
<property name="common.log.conversionpattern" value="[%d${common.log.date.format}] [%t] [%c{0}] [%p]: %m%n" />

<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
    <encoder>
	<pattern>${common.log.conversionpattern}</pattern>
    </encoder>
</appender>

<!-- Should be true if javax.mail jar exists in claspath -->
<define name="JAVAX_MAIL_EXISTS_IN_CLASSPATH" class="ch.qos.logback.core.property.ResourceExistsPropertyDefiner">
	<resource>javax.mail.Authenticator</resource>
</define>

<appender name="Property value is ${JAVAX_MAIL_EXISTS_IN_CLASSPATH}!!!" class="ch.qos.logback.core.ConsoleAppender">
    <encoder>
	<pattern>${common.log.conversionpattern}</pattern>
    </encoder>
</appender>

<if condition='"true".equals(property("JAVAX_MAIL_EXISTS_IN_CLASSPATH"))'>
  <then>
	<appender name="EMAIL" class="ch.qos.logback.classic.net.SMTPAppender">
		<smtpHost>webmail.reveredata.com</smtpHost>
		<to>dyaroslavtsev@reveredata.com</to>
		<from>noreply@reveredata.com</from>
		<subject>[${app.name}] [%marker] [%p]</subject>
		<asynchronousSending>false</asynchronousSending>
		<layout class="ch.qos.logback.classic.PatternLayout">
			<pattern>${common.log.conversionpattern}</pattern>
		</layout>
	</appender>
	<root level="ERROR">
		<appender-ref ref="EMAIL" />
	</root>
  </then>
</if>

<root level="INFO">
	<appender-ref ref="STDOUT" />
</root>

There is no convenient way to write JAVAX_MAIL_EXISTS_IN_CLASSPATH state to sysout, so I am using an additional ConsoleAppender and '-Dlogback.debug=true' option to see value of my JAVAX_MAIL_EXISTS_IN_CLASSPATH variable.
It is always false, regardless if javax.mail jar exist in classpath, or not.

My environment is: Ubuntu 12.04, logback classic/core 1.0.13, Janino 2.6.1, javax.mail 1.4.

Environment:

Ubuntu 12.04, logback classic/core 1.0.13, janino 2.6.1, javax.mail 1.4

Project: logback
Priority: Major Major
Reporter: Daniil Yaroslavtsev
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira