diff options
author | Jérémy Zurcher <jeremy@asynk.ch> | 2017-03-13 08:48:57 +0100 |
---|---|---|
committer | Jérémy Zurcher <jeremy@asynk.ch> | 2017-03-13 08:48:57 +0100 |
commit | 7b2889665d790585f4e1e0ac5c215359240a8d33 (patch) | |
tree | 697e55e82e259b48df48921b302220324f3caef0 | |
parent | ba24c4cf96b9ada4ce319b792201ad8ad7505fbf (diff) | |
download | share-7b2889665d790585f4e1e0ac5c215359240a8d33.zip share-7b2889665d790585f4e1e0ac5c215359240a8d33.tar.gz |
java : vaadin : add logback support
-rw-r--r-- | java/vaadin/ivy.xml | 2 | ||||
-rw-r--r-- | java/vaadin/src/main/java/ch/asynk/HelloWorld.java | 13 | ||||
-rw-r--r-- | java/vaadin/src/main/resources/Application.properties | 2 | ||||
-rw-r--r-- | java/vaadin/src/main/resources/logback-test.xml | 48 |
4 files changed, 65 insertions, 0 deletions
diff --git a/java/vaadin/ivy.xml b/java/vaadin/ivy.xml index 033e347..7be4e62 100644 --- a/java/vaadin/ivy.xml +++ b/java/vaadin/ivy.xml @@ -16,5 +16,7 @@ <dependency org="com.vaadin" name="vaadin-server" rev="&vaadin.version;"/> <dependency org="com.vaadin" name="vaadin-themes" rev="&vaadin.version;"/> <dependency org="com.vaadin" name="vaadin-client-compiled" rev="&vaadin.version;"/> + <dependency org="ch.qos.logback" name="logback-classic" rev="1.2.1"/> + <dependency org="org.codehaus.janino" name="janino" rev="3.0.6"/> </dependencies> </ivy-module> diff --git a/java/vaadin/src/main/java/ch/asynk/HelloWorld.java b/java/vaadin/src/main/java/ch/asynk/HelloWorld.java index 65ef27d..e811599 100644 --- a/java/vaadin/src/main/java/ch/asynk/HelloWorld.java +++ b/java/vaadin/src/main/java/ch/asynk/HelloWorld.java @@ -11,14 +11,20 @@ import com.vaadin.ui.Notification; import com.vaadin.ui.UI; import com.vaadin.ui.VerticalLayout; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + @Title("Hello!!") @Theme("valo") public class HelloWorld extends UI { private static final long serialVersionUID = 511085335415683713L; + private static Logger logger = null; + @Override protected void init(VaadinRequest request) { + logger = LoggerFactory.getLogger(this.getClass()); VerticalLayout content = new VerticalLayout(); setContent(content); @@ -28,6 +34,13 @@ public class HelloWorld extends UI @Override public void buttonClick(ClickEvent event) { Notification.show("Pushed!"); + System.out.println("System.out"); + System.err.println("System.err"); + logger.trace("trace"); + logger.debug("debug"); + logger.info("info"); + logger.warn("warn"); + logger.error("error"); } })); } diff --git a/java/vaadin/src/main/resources/Application.properties b/java/vaadin/src/main/resources/Application.properties index 193ca7f..512362b 100644 --- a/java/vaadin/src/main/resources/Application.properties +++ b/java/vaadin/src/main/resources/Application.properties @@ -1,3 +1,5 @@ app.name=VaadinHelloWorld app.version=0.0.1 app.path=/hello +app.env=DEV +app.logfile=/var/log/tomcat7/HelloWorld.log diff --git a/java/vaadin/src/main/resources/logback-test.xml b/java/vaadin/src/main/resources/logback-test.xml new file mode 100644 index 0000000..4c53061 --- /dev/null +++ b/java/vaadin/src/main/resources/logback-test.xml @@ -0,0 +1,48 @@ +<configuration debug="true"> + + <contextName>HelloWorld</contextName> + <property resource="Application.properties" /> + <property name="LOG_LEVEL" value="INFO" /> + <property name="LOG_REF" value="FILE" /> + <property name="LOG_FILE" value="${app.logfile}" /> + <property name="LOG_PATTERN" value="%contextName %date{ISO8601} [%-5level %thread] [%file:%line] - %msg%n" /> + + <if condition='property("app.env").contains("DEV")'> + <then> + <property name="LOG_LEVEL" value="DEBUG" /> + </then> + </if> + + <if condition='isDefined("TEST_DB")'> + <then> + <property name="LOG_LEVEL" value="DEBUG" /> + <property name="LOG_REF" value="FILE" /> + <property name="LOG_FILE" value="./tests/logs" /> + </then> + </if> + + <if condition='isDefined("TEST_PDF")'> + <then> + <property name="LOG_LEVEL" value="DEBUG" /> + <property name="LOG_REF" value="STDOUT" /> + </then> + </if> + + <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> + <encoder> + <pattern>${LOG_PATTERN}</pattern> + </encoder> + </appender> + + <appender name="FILE" class="ch.qos.logback.core.FileAppender"> + <file>${LOG_FILE}</file> + <encoder> + <pattern>${LOG_PATTERN}</pattern> + </encoder> + </appender> + + <root level="${LOG_LEVEL}"> + <appender-ref ref="${LOG_REF}" /> + </root> + +</configuration> |