Merge "Update ifmap log format configuration file" into stacklight
diff --git a/opencontrail/database.sls b/opencontrail/database.sls
index 9640d9f..7c9e7cc 100644
--- a/opencontrail/database.sls
+++ b/opencontrail/database.sls
@@ -37,6 +37,16 @@
     - pkg: opencontrail_database_packages
 {% endif %}
 
+{{ database.cassandra_config }}logback.xml:
+  file.managed:
+  - source: salt://opencontrail/files/{{ database.version }}/database/logback.xml
+  - template: jinja
+  - makedirs: True
+{% if grains.os_family == "RedHat" %}
+  - require:
+    - pkg: opencontrail_database_packages
+{% endif %}
+
 {{ database.cassandra_config }}cassandra-env.sh:
   file.managed:
   - source: salt://opencontrail/files/{{ database.version }}/database/cassandra-env.sh
@@ -56,6 +66,7 @@
   - require:
     - file: {{ database.cassandra_config }}cassandra.yaml
     - file: {{ database.cassandra_config }}cassandra-env.sh
+    - file: {{ database.cassandra_config }}logback.xml
 {% endif %}
 
 /etc/zookeeper/conf/log4j.properties:
@@ -124,6 +135,7 @@
   - watch: 
     - file: {{ database.cassandra_config }}cassandra.yaml
     - file: {{ database.cassandra_config }}cassandra-env.sh
+    - file: {{ database.cassandra_config }}logback.xml
     - file: /etc/zookeeper/conf/zoo.cfg
     - file: /etc/contrail/contrail-database-nodemgr.conf
     - file: /var/lib/zookeeper/myid
diff --git a/opencontrail/files/2.2/database/logback.xml b/opencontrail/files/2.2/database/logback.xml
new file mode 100644
index 0000000..47b357f
--- /dev/null
+++ b/opencontrail/files/2.2/database/logback.xml
@@ -0,0 +1,53 @@
+    <!--
+     Licensed to the Apache Software Foundation (ASF) under one
+     or more contributor license agreements.  See the NOTICE file
+     distributed with this work for additional information
+     regarding copyright ownership.  The ASF licenses this file
+     to you under the Apache License, Version 2.0 (the
+     "License"); you may not use this file except in compliance
+     with the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+     Unless required by applicable law or agreed to in writing,
+     software distributed under the License is distributed on an
+     "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+     KIND, either express or implied.  See the License for the
+     specific language governing permissions and limitations
+     under the License.
+    -->
+
+    <configuration scan="true">
+      <jmxConfigurator />
+      <appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
+        <file>${cassandra.logdir}/system.log</file>
+        <rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
+          <fileNamePattern>${cassandra.logdir}/system.log.%i.zip</fileNamePattern>
+          <minIndex>1</minIndex>
+          <maxIndex>20</maxIndex>
+        </rollingPolicy>
+
+        <triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
+          <maxFileSize>20MB</maxFileSize>
+        </triggeringPolicy>
+        <encoder>
+          <pattern>%date{ISO8601} - %-5level - [%thread] %F:%L - %msg%n</pattern>
+          <!-- old-style log format
+          <pattern>%5level [%thread] %date{ISO8601} %F (line %L) %msg%n</pattern>
+          -->
+        </encoder>
+      </appender>
+
+      <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
+        <encoder>
+          <pattern>%-5level %date{HH:mm:ss,SSS} %msg%n</pattern>
+        </encoder>
+      </appender>
+
+      <root level="INFO">
+        <appender-ref ref="FILE" />
+        <appender-ref ref="STDOUT" />
+      </root>
+
+      <logger name="com.thinkaurelius.thrift" level="ERROR"/>
+    </configuration>
diff --git a/opencontrail/files/3.0/database/logback.xml b/opencontrail/files/3.0/database/logback.xml
new file mode 100644
index 0000000..47b357f
--- /dev/null
+++ b/opencontrail/files/3.0/database/logback.xml
@@ -0,0 +1,53 @@
+    <!--
+     Licensed to the Apache Software Foundation (ASF) under one
+     or more contributor license agreements.  See the NOTICE file
+     distributed with this work for additional information
+     regarding copyright ownership.  The ASF licenses this file
+     to you under the Apache License, Version 2.0 (the
+     "License"); you may not use this file except in compliance
+     with the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+     Unless required by applicable law or agreed to in writing,
+     software distributed under the License is distributed on an
+     "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+     KIND, either express or implied.  See the License for the
+     specific language governing permissions and limitations
+     under the License.
+    -->
+
+    <configuration scan="true">
+      <jmxConfigurator />
+      <appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
+        <file>${cassandra.logdir}/system.log</file>
+        <rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
+          <fileNamePattern>${cassandra.logdir}/system.log.%i.zip</fileNamePattern>
+          <minIndex>1</minIndex>
+          <maxIndex>20</maxIndex>
+        </rollingPolicy>
+
+        <triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
+          <maxFileSize>20MB</maxFileSize>
+        </triggeringPolicy>
+        <encoder>
+          <pattern>%date{ISO8601} - %-5level - [%thread] %F:%L - %msg%n</pattern>
+          <!-- old-style log format
+          <pattern>%5level [%thread] %date{ISO8601} %F (line %L) %msg%n</pattern>
+          -->
+        </encoder>
+      </appender>
+
+      <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
+        <encoder>
+          <pattern>%-5level %date{HH:mm:ss,SSS} %msg%n</pattern>
+        </encoder>
+      </appender>
+
+      <root level="INFO">
+        <appender-ref ref="FILE" />
+        <appender-ref ref="STDOUT" />
+      </root>
+
+      <logger name="com.thinkaurelius.thrift" level="ERROR"/>
+    </configuration>
diff --git a/opencontrail/meta/config.yml b/opencontrail/meta/config.yml
index 8d294dc..d28e7d3 100644
--- a/opencontrail/meta/config.yml
+++ b/opencontrail/meta/config.yml
@@ -60,6 +60,9 @@
   cassandra.yaml:
     source: "salt://opencontrail/files/{{ database.version }}/cassandra.yaml"
     template: jinja
+  logback.xml:
+    source: "salt://opencontrail/files/{{ database.version }}/database/logback.xml"
+    template: jinja
   cassandra-env.sh:
     source: "salt://opencontrail/files/{{ database.version }}/database/cassandra-env.sh"
     template: jinja
@@ -126,4 +129,4 @@
   contrail-vrouter-nodemgr.ini:
     source: "salt://opencontrail/files/{{ compute.version }}/contrail-vrouter-nodemgr.ini"
     template: jinja
-  {%- endif %}
\ No newline at end of file
+  {%- endif %}
diff --git a/opencontrail/meta/heka.yml b/opencontrail/meta/heka.yml
index 8e1a04a..16cbaeb 100644
--- a/opencontrail/meta/heka.yml
+++ b/opencontrail/meta/heka.yml
@@ -2,18 +2,31 @@
 {%- if pillar.opencontrail.control is defined %}
 {%- from "opencontrail/map.jinja" import control with context %}
 {%- if control.get('enabled', False) %}
-{%- set controller = control %}
+{%- set controller_ref = control %}
 {%- endif %}
 {%- elif pillar.opencontrail.compute is defined %}
 {%- from "opencontrail/map.jinja" import compute with context %}
 {%- if compute.get('enabled', False) %}
-{%- set compute = compute %}
+{%- set compute_ref = compute %}
+{%- endif %}
+{%- endif %}
+{%- if pillar.opencontrail.web is defined %}
+{%- from "opencontrail/map.jinja" import web with context %}
+{%- if web.get('enabled', False) %}
+{%- set web_ref = web %}
 {%- endif %}
 {%- endif %}
 {%- endif %}
 
-{%- if controller is defined or compute is defined %}
+{%- if controller_ref is defined or compute_ref is defined %}
 log_collector:
+{%- if controller_ref is defined %}
+  splitter:
+    java:
+      engine: regex
+      delimiter: '\n([0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2},[0-9]{3} - )'
+      delimiter_eol: false
+{%- endif %}
   decoder:
     contrail:
       engine: sandbox
@@ -25,7 +38,7 @@
       module_file: /usr/share/lma_collector/decoders/contrail_supervisor_log.lua
       module_dir: /usr/share/lma_collector/common;/usr/share/heka/lua_modules
       adjust_timezone: true
-{%- if controller is defined %}
+{%- if controller_ref is defined %}
     contrail_collector:
       engine: sandbox
       module_file: /usr/share/lma_collector/decoders/contrail_collector_log.lua
@@ -36,13 +49,30 @@
       module_file: /usr/share/lma_collector/decoders/contrail_api_stdout_log.lua
       module_dir: /usr/share/lma_collector/common;/usr/share/heka/lua_modules
       adjust_timezone: true
+    zookeeper:
+      engine: sandbox
+      module_file: /usr/share/lma_collector/decoders/zookeeper.lua
+      module_dir: /usr/share/lma_collector/common;/usr/share/heka/lua_modules
+      adjust_timezone: true
+    cassandra:
+      engine: sandbox
+      module_file: /usr/share/lma_collector/decoders/cassandra.lua
+      module_dir: /usr/share/lma_collector/common;/usr/share/heka/lua_modules
+      adjust_timezone: true
+{%- endif %}
+{%- if web_ref is defined %}
+    redis:
+      engine: sandbox
+      module_file: /usr/share/lma_collector/decoders/redis.lua
+      module_dir: /usr/share/lma_collector/common;/usr/share/heka/lua_modules
+      adjust_timezone: true
 {%- endif %}
   input:
     contrail_supervisor_log:
       engine: logstreamer
       log_directory: "/var/log"
       file_match: 'contrail/(?P<Service>supervisord-.+)\.log\.?(?P<Seq>\d*)$'
-      differentiator: ['contrail', '_', 'Service']
+      differentiator: ['contrail', '.', 'Service']
       priority: ["^Seq"]
       decoder: "contrail_supervisor_decoder"
       splitter: "TokenSplitter"
@@ -50,16 +80,16 @@
       engine: logstreamer
       log_directory: "/var/log"
       file_match: 'contrail/contrail-(?P<Service>named)\.log\.?(?P<Seq>\d*)$'
-      differentiator: ['contrail', '_', 'Service']
+      differentiator: ['contrail', '.', 'Service']
       priority: ["^Seq"]
       decoder: "contrail_supervisor_decoder"
       splitter: "TokenSplitter"
-{%- if controller is defined %}
+{%- if controller_ref is defined %}
     contrail_collector_log:
       engine: logstreamer
       log_directory: "/var/log"
       file_match: 'contrail/contrail-(?P<Service>collector|control|dns|query-engine)\.log\.?(?P<Seq>\d*)$'
-      differentiator: ['contrail', '_', 'Service']
+      differentiator: ['contrail', '.', 'Service']
       priority: ["^Seq"]
       decoder: "contrail_collector_decoder"
       splitter: "TokenSplitter"
@@ -67,17 +97,43 @@
       engine: logstreamer
       log_directory: "/var/log"
       file_match: 'contrail/contrail-(?P<Service>discovery-0-stdout)\.log\.?(?P<Seq>\d*)$'
-      differentiator: ['contrail', '_', 'Service']
+      differentiator: ['contrail', '.', 'Service']
       priority: ["^Seq"]
       decoder: "contrail_api_stdout_decoder"
       splitter: "TokenSplitter"
+    zookeeper:
+      engine: logstreamer
+      log_directory: "/var/log"
+      file_match: 'zookeeper/(?P<Service>zookeeper)\.log\.?(?P<Seq>\d*)$'
+      differentiator: ['contrail', '.', 'Service']
+      priority: ["^Seq"]
+      decoder: "zookeeper_decoder"
+      splitter: "java_splitter"
+    cassandra:
+      engine: logstreamer
+      log_directory: "/var/log"
+      file_match: 'cassandra/(?P<Service>system|status)\.log\.?(?P<Seq>\d*)$'
+      differentiator: ['contrail.cassandra', '.', 'Service']
+      priority: ["^Seq"]
+      decoder: "cassandra_decoder"
+      splitter: "java_splitter"
 {%- endif %}
     contrail_main_log:
       engine: logstreamer
       log_directory: "/var/log"
       file_match: 'contrail/contrail-(?P<Service>alarm-gen.*|api|.*-stderr|.*svc-monitor.*|snmp.*)\.log\.?(?P<Seq>\d*)$'
-      differentiator: ['contrail', '_', 'Service']
+      differentiator: ['contrail', '.', 'Service']
       priority: ["^Seq"]
       decoder: "contrail_decoder"
       splitter: "TokenSplitter"
+{%- if web_ref is defined and web_ref.get('cache', {}).get('engine', '') == 'redis' %}
+    redis_log:
+      engine: logstreamer
+      log_directory: "/var/log"
+      file_match: 'redis/(?P<Service>redis-server)\.log\.?(?P<Seq>\d*)$'
+      differentiator: ['contrail', '.', 'Service']
+      priority: ["^Seq"]
+      decoder: "redis_decoder"
+      splitter: "TokenSplitter"
+{%- endif %}
 {%- endif %}