Add "direct" option for logging to console. 90/72190/5
authorJanki Chhatbar <jchhatba@redhat.com>
Wed, 23 May 2018 11:34:27 +0000 (17:04 +0530)
committerJanki Chhatbar <jchhatba@redhat.com>
Thu, 14 Jun 2018 14:59:43 +0000 (14:59 +0000)
Log4j 'direct' option for performance improved OpenDaylight
logging.

Change-Id: I308ed47b531313035e62233428e431be4bfc9d7d
Signed-Off-By: Janki Chhatbar <jchhatba@redhat.com>
manifests/config.pp
spec/spec_helper.rb
spec/spec_helper_acceptance.rb

index 9560ff538153481672c1567911478516210c19f5..94c66ce80525c4f8cca066475fb2f44f5177eba8 100644 (file)
@@ -238,7 +238,15 @@ class opendaylight::config {
       after  => 'log4j2.rootLogger.appenderRef.Console.filter.threshold.type = ThresholdFilter',
       match  => '^karaf.log.console.*$'
     }
+    file_line { 'direct':
+      ensure => present,
+      path   => '/opt/opendaylight/etc/org.ops4j.pax.logging.cfg',
+      line   => 'log4j2.appender.console.direct = true',
+      after  => 'karaf.log.console=INFO',
+      match  => '^log4j2.appender.console.direct.*$'
+    }
   } else {
+
     # Set maximum ODL log file size
     file_line { 'logmaxsize':
       ensure => present,
index 65107d8c5d8d48655e8b32e3dc298e047b1434bb..abeeb52aec8424178822725fa36e89842e9717e3 100644 (file)
@@ -90,27 +90,36 @@ def log_settings(options = {})
         'match' => '^karaf.log.console.*$'
       )
     }
+    it {
+      should contain_file_line('direct').with(
+        'path'  => '/opt/opendaylight/etc/org.ops4j.pax.logging.cfg',
+        'line'  => 'log4j2.appender.console.direct = true',
+        'after' => 'karaf.log.console=INFO',
+        'match' => '^log4j2.appender.console.direct.*$'
+      )
+    }
   else
-  it {
-    should contain_file_line('logmaxsize').with(
-      'path'   => '/opt/opendaylight/etc/org.ops4j.pax.logging.cfg',
-      'line'   => "log4j2.appender.rolling.policies.size.size = #{log_max_size}",
-      'match'  => '^log4j2.appender.rolling.policies.size.size.*$',
-    )
-  }
-  it {
-    should contain_file_line('rolloverstrategy').with(
-      'path'   => '/opt/opendaylight/etc/org.ops4j.pax.logging.cfg',
-      'line'   => 'log4j2.appender.rolling.strategy.type = DefaultRolloverStrategy'
-    )
-  }
-  it {
-    should contain_file_line('logmaxrollover').with(
-      'path'   => '/opt/opendaylight/etc/org.ops4j.pax.logging.cfg',
-      'line'   => "log4j2.appender.rolling.strategy.max = #{log_max_rollover}",
-      'match'  => '^log4j2.appender.rolling.strategy.max.*$',
-    )
-  }
+
+    it {
+      should contain_file_line('logmaxsize').with(
+        'path'   => '/opt/opendaylight/etc/org.ops4j.pax.logging.cfg',
+        'line'   => "log4j2.appender.rolling.policies.size.size = #{log_max_size}",
+        'match'  => '^log4j2.appender.rolling.policies.size.size.*$',
+      )
+    }
+    it {
+      should contain_file_line('rolloverstrategy').with(
+        'path'   => '/opt/opendaylight/etc/org.ops4j.pax.logging.cfg',
+        'line'   => 'log4j2.appender.rolling.strategy.type = DefaultRolloverStrategy'
+      )
+    }
+    it {
+      should contain_file_line('logmaxrollover').with(
+        'path'   => '/opt/opendaylight/etc/org.ops4j.pax.logging.cfg',
+        'line'   => "log4j2.appender.rolling.strategy.max = #{log_max_rollover}",
+        'match'  => '^log4j2.appender.rolling.strategy.max.*$',
+      )
+    }
   end
 end
 
index 941d9c691710bc6336ba640ede00027bcd282c5d..06a85bcd9ac8647d9405e25d38b57ff4c9368738 100644 (file)
@@ -233,6 +233,7 @@ def log_settings_validations(options = {})
       it { should be_owned_by 'odl' }
       it { should be_grouped_into 'odl' }
       its(:content) { should match /^karaf.log.console=INFO/ }
+      its(:content) { should match /^log4j2.appender.console.direct = true/ }
     end
   else
     describe file('/opt/opendaylight/etc/org.ops4j.pax.logging.cfg') do