Skip to content

Commit

Permalink
add possibility to logrotate timebased instead on filesize. (only imp…
Browse files Browse the repository at this point in the history
…lemented in the logback configuration) (#198)
  • Loading branch information
mlausch authored Jun 24, 2024
1 parent a42780d commit 0f9d899
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
6 changes: 6 additions & 0 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,9 @@
# @param audit_threshold
# @param audit_maxfilesize
# @param audit_maxbackupindex
# @param logrotate_days
# @param $logrotate_timebased

# @param sasl_users
# @param keytab_path
# @param principal
Expand Down Expand Up @@ -261,6 +264,9 @@
String $audit_threshold = $zookeeper::params::audit_threshold,
String $audit_maxfilesize = $zookeeper::params::audit_maxfilesize,
String $audit_maxbackupindex = $zookeeper::params::audit_maxbackupindex,
Integer $logrotate_days = $zookeeper::params::logrotate_days,
Boolean $logrotate_timebased = $zookeeper::params::logrotate_timebased,

Check failure on line 268 in manifests/init.pp

View workflow job for this annotation

GitHub Actions / lint

trailing whitespace found (check: trailing_whitespace)

Check warning on line 268 in manifests/init.pp

View workflow job for this annotation

GitHub Actions / lint

missing documentation for class parameter zookeeper::logrotate_timebased (check: parameter_documentation)

# sasl options
Hash[String, String] $sasl_users = $zookeeper::params::sasl_users,
String $keytab_path = $zookeeper::params::keytab_path,
Expand Down
2 changes: 2 additions & 0 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,8 @@
$audit_threshold = 'INFO'
$audit_maxfilesize = '10M'
$audit_maxbackupindex = '10'
$logrotate_days = 7
$logrotate_timebased = false

# sasl options
$sasl_krb5 = true
Expand Down
8 changes: 8 additions & 0 deletions templates/conf/logback.xml.erb
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
<property name="zookeeper.log.file" value="zookeeper.log" />
<property name="zookeeper.log.threshold" value="<%= scope.lookupvar("zookeeper::rollingfile_threshold") %>" />
<property name="zookeeper.log.maxfilesize" value="<%= scope.lookupvar("zookeeper::maxfilesize") %>" />
<property name="zookeeper.log.days" value="<%= scope.lookupvar("zookeeper::logrotate_days") %>" />
<property name="zookeeper.log.maxbackupindex" value="<%= scope.lookupvar("zookeeper::maxbackupindex") %>" />

<!--
Expand All @@ -52,6 +53,12 @@
<encoder>
<pattern>%d{ISO8601} [myid:%X{myid}] - %-5p [%t:%C{1}@%L] - %m%n</pattern>
</encoder>
<% if @logrotate_timebased -%>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<maxHistory>${zookeeper.log.days}</maxHistory>
<FileNamePattern>${zookeeper.log.dir}/${zookeeper.log.file}-%d{yyyy-MM-dd}</FileNamePattern>
</rollingPolicy>
<% else -%>
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
<level>${zookeeper.log.threshold}</level>
</filter>
Expand All @@ -62,6 +69,7 @@
<triggeringPolicy class="ch.qos.logback.core.rolling.SizeBasedTriggeringPolicy">
<MaxFileSize>${zookeeper.log.maxfilesize}</MaxFileSize>
</triggeringPolicy>
<% end -%>
</appender>

<!--
Expand Down

0 comments on commit 0f9d899

Please sign in to comment.