[logback-dev] svn commit: r1150 - in logback/trunk: logback-classic/src/main/java/ch/qos/logback/classic/html logback-classic/src/main/java/ch/qos/logback/classic/net logback-core/src/main/java/ch/qos/logback/core/net
noreply.seb at qos.ch
noreply.seb at qos.ch
Wed Jan 3 15:19:12 CET 2007
Author: seb
Date: Wed Jan 3 15:19:12 2007
New Revision: 1150
Modified:
logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/html/HTMLLayout.java
logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/net/SMTPAppender.java
logback/trunk/logback-core/src/main/java/ch/qos/logback/core/net/SMTPAppenderBase.java
Log:
Corrected behaviour of SMTPAppender in case of missing configuration elements
Modified: logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/html/HTMLLayout.java
==============================================================================
--- logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/html/HTMLLayout.java (original)
+++ logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/html/HTMLLayout.java Wed Jan 3 15:19:12 2007
@@ -36,8 +36,7 @@
public class HTMLLayout extends HTMLLayoutBase implements ClassicLayout {
/**
- * Default pattern string for log output. Currently set to the string <b>"%m"
- * </b> which just prints the application supplied message.
+ * Default pattern string for log output.
*/
static final String DEFAULT_CONVERSION_PATTERN = "%date%thread%level%logger%mdc%msg";
Modified: logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/net/SMTPAppender.java
==============================================================================
--- logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/net/SMTPAppender.java (original)
+++ logback/trunk/logback-classic/src/main/java/ch/qos/logback/classic/net/SMTPAppender.java Wed Jan 3 15:19:12 2007
@@ -31,7 +31,7 @@
*/
public class SMTPAppender extends SMTPAppenderBase {
- static final String DEFAULT_SUBJECT_PATTERN = "%logger{20} - %m";
+ static final String DEFAULT_SUBJECT_PATTERN = "%logger{20} - %m %nopex";
static final String DEFAULT_EVALUATOR_EXPRESSION = "level >= ERROR";
private int bufferSize = 512;
@@ -43,11 +43,19 @@
* ERROR or higher.
*/
public SMTPAppender() {
- JaninoEventEvaluator jee = new JaninoEventEvaluator();
- jee.setContext(getContext());
- jee.setExpression(DEFAULT_EVALUATOR_EXPRESSION);
- jee.setName("SMTPAppender's default event evaluator");
- this.eventEvaluator = jee;
+
+ }
+
+ public void start() {
+ if (eventEvaluator == null) {
+ JaninoEventEvaluator jee = new JaninoEventEvaluator();
+ jee.setContext(getContext());
+ jee.setExpression(DEFAULT_EVALUATOR_EXPRESSION);
+ jee.setName("SMTPAppender's default event evaluator");
+ jee.start();
+ this.eventEvaluator = jee;
+ }
+ super.start();
}
/**
@@ -105,6 +113,7 @@
subjectStr = DEFAULT_SUBJECT_PATTERN;
}
PatternLayout pl = new PatternLayout();
+ pl.setContext(getContext());
pl.setPattern(subjectStr);
pl.start();
return pl;
Modified: logback/trunk/logback-core/src/main/java/ch/qos/logback/core/net/SMTPAppenderBase.java
==============================================================================
--- logback/trunk/logback-core/src/main/java/ch/qos/logback/core/net/SMTPAppenderBase.java (original)
+++ logback/trunk/logback-core/src/main/java/ch/qos/logback/core/net/SMTPAppenderBase.java Wed Jan 3 15:19:12 2007
@@ -127,6 +127,11 @@
* is returned.
*/
public boolean checkEntryConditions() {
+ if (!this.started) {
+ addError("Attempting to append to a non-started appender: " + this.getName());
+ return false;
+ }
+
if (this.msg == null) {
addError("Message object not configured.");
return false;
More information about the logback-dev
mailing list