You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@karaf.apache.org by Steinar Bang <sb...@dod.no> on 2019/05/16 15:51:48 UTC

Rotating karaf.log?

I have a 14MB karaf.log file on my production server and emacs think
that is large and complains every time I open it.

Is there some configuration in karaf that can make it rotate the
karaf.log file?  Is there a way karaf.log can be rotated by the OS?

Thanks!


- Steinar


Re: Rotating karaf.log?

Posted by Frédéric Gendebien <fr...@gmail.com>.
Unsubscribe

On Thu, 16 May 2019 at 17:58, Steinar Bang <sb...@dod.no> wrote:

> I have a 14MB karaf.log file on my production server and emacs think
> that is large and complains every time I open it.
>
> Is there some configuration in karaf that can make it rotate the
> karaf.log file?  Is there a way karaf.log can be rotated by the OS?
>
> Thanks!
>
>
> - Steinar
>
> --
Frédéric Gendebien.

Re: Rotating karaf.log?

Posted by Jean-Baptiste Onofré <jb...@nanthrax.net>.
You are welcome ;)

Regards
JB

On 26/05/2019 08:26, Steinar Bang wrote:
>>>>>> Jean-Baptiste Onofré <jb...@nanthrax.net>:
> 
>> Hi Steinar,
>> yes, you can rotate by configuration in etc/org.ops4j.pax.logging.cfg.
> 
>> By configuration, the rotation is set to 16MB:
> 
>> # Rolling file appender
>> log4j2.appender.rolling.type = RollingRandomAccessFile
>> log4j2.appender.rolling.name = RollingFile
>> log4j2.appender.rolling.fileName = ${karaf.log}/karaf.log
>> log4j2.appender.rolling.filePattern = ${karaf.log}/karaf.log.%i
>> # uncomment to not force a disk flush
>> #log4j2.appender.rolling.immediateFlush = false
>> log4j2.appender.rolling.append = true
>> log4j2.appender.rolling.layout.type = PatternLayout
>> log4j2.appender.rolling.layout.pattern = ${log4j2.pattern}
>> log4j2.appender.rolling.policies.type = Policies
>> log4j2.appender.rolling.policies.size.type = SizeBasedTriggeringPolicy
>> log4j2.appender.rolling.policies.size.size = 16MB
> 
> 
>> Just change the rolling.policies.size.size to the rotation you want.
> 
> Thanks, JB!
> 
> I SSH'd in to the karaf console and gave the following commands:
>  config:edit org.ops4j.pax.logging
>  config:property-set log4j2.appender.rolling.policies.size.size 1MB
>  config:update
> 
> (default for debian logrotate seems to be 100kB so I picked a middle
> ground between that and 16MB...:-) )
> 
> This morning, the logs had rotated:
>   /var/log/karaf:
>   total used in directory 16740 available 11603336
>   drwxr-xr-x  2 karaf karaf     4096 May 25 12:32 .
>   drwxr-xr-x 13 root  root      4096 May 26 05:09 ..
>   -rw-r--r--  1 karaf karaf    63507 May 26 07:07 karaf.log
>   -rw-r--r--  1 karaf karaf 15024655 May 25 12:22 karaf.log.1
> 
> Thanks again!
> 

-- 
Jean-Baptiste Onofré
jbonofre@apache.org
http://blog.nanthrax.net
Talend - http://www.talend.com

Re: Rotating karaf.log?

Posted by Steinar Bang <sb...@dod.no>.
>>>>> Jean-Baptiste Onofré <jb...@nanthrax.net>:

> Hi Steinar,
> yes, you can rotate by configuration in etc/org.ops4j.pax.logging.cfg.

> By configuration, the rotation is set to 16MB:

> # Rolling file appender
> log4j2.appender.rolling.type = RollingRandomAccessFile
> log4j2.appender.rolling.name = RollingFile
> log4j2.appender.rolling.fileName = ${karaf.log}/karaf.log
> log4j2.appender.rolling.filePattern = ${karaf.log}/karaf.log.%i
> # uncomment to not force a disk flush
> #log4j2.appender.rolling.immediateFlush = false
> log4j2.appender.rolling.append = true
> log4j2.appender.rolling.layout.type = PatternLayout
> log4j2.appender.rolling.layout.pattern = ${log4j2.pattern}
> log4j2.appender.rolling.policies.type = Policies
> log4j2.appender.rolling.policies.size.type = SizeBasedTriggeringPolicy
> log4j2.appender.rolling.policies.size.size = 16MB


> Just change the rolling.policies.size.size to the rotation you want.

Thanks, JB!

I SSH'd in to the karaf console and gave the following commands:
 config:edit org.ops4j.pax.logging
 config:property-set log4j2.appender.rolling.policies.size.size 1MB
 config:update

(default for debian logrotate seems to be 100kB so I picked a middle
ground between that and 16MB...:-) )

This morning, the logs had rotated:
  /var/log/karaf:
  total used in directory 16740 available 11603336
  drwxr-xr-x  2 karaf karaf     4096 May 25 12:32 .
  drwxr-xr-x 13 root  root      4096 May 26 05:09 ..
  -rw-r--r--  1 karaf karaf    63507 May 26 07:07 karaf.log
  -rw-r--r--  1 karaf karaf 15024655 May 25 12:22 karaf.log.1

Thanks again!


Re: Rotating karaf.log?

Posted by Jean-Baptiste Onofré <jb...@nanthrax.net>.
Hi Steinar,

yes, you can rotate by configuration in etc/org.ops4j.pax.logging.cfg.

By configuration, the rotation is set to 16MB:

# Rolling file appender
log4j2.appender.rolling.type = RollingRandomAccessFile
log4j2.appender.rolling.name = RollingFile
log4j2.appender.rolling.fileName = ${karaf.log}/karaf.log
log4j2.appender.rolling.filePattern = ${karaf.log}/karaf.log.%i
# uncomment to not force a disk flush
#log4j2.appender.rolling.immediateFlush = false
log4j2.appender.rolling.append = true
log4j2.appender.rolling.layout.type = PatternLayout
log4j2.appender.rolling.layout.pattern = ${log4j2.pattern}
log4j2.appender.rolling.policies.type = Policies
log4j2.appender.rolling.policies.size.type = SizeBasedTriggeringPolicy
log4j2.appender.rolling.policies.size.size = 16MB


Just change the rolling.policies.size.size to the rotation you want.

Regards
JB

On 16/05/2019 17:51, Steinar Bang wrote:
> I have a 14MB karaf.log file on my production server and emacs think
> that is large and complains every time I open it.
> 
> Is there some configuration in karaf that can make it rotate the
> karaf.log file?  Is there a way karaf.log can be rotated by the OS?
> 
> Thanks!
> 
> 
> - Steinar
> 

-- 
Jean-Baptiste Onofré
jbonofre@apache.org
http://blog.nanthrax.net
Talend - http://www.talend.com