# Kibana logs

**URL:** <https://discuss.elastic.co/t/kibana-logs/312915>\
**Category:** Kibana\
**Created:** [August 25, 2022, 11:53am UTC](https://discuss.elastic.co/t/kibana-logs/312915 "2022-08-25T11:53:43Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![irivas95](https://avatars.discourse-cdn.com/v4/letter/i/839c29/32.png) [@irivas95](https://discuss.elastic.co/u/irivas95)\
**Post date:** [August 25, 2022, 11:53am UTC](https://discuss.elastic.co/t/kibana-logs/312915/1 "2022-08-25T11:53:43Z")

</div>

Hi,  
I have been trying for a while to configure a logrotate file to rotate my kibana logs(version 7.16.3),without success. I need my logs to rotate daily and delete logs older than 7 days. The configuration file I am using is as follows:

```auto
/var/log/kibana/kibana.log {
    create 644 kibana kibana
    daily
    rotate 7
    dateext
    missingok
    notifempty
    compress
    delaycompress
    sharedscripts
    postrotate
        /bin/kill -USR1 `cat /run/kibana/kibana.pid 2>/dev/null` 2>/dev/null || true
    endscript
}

```

Does anyone know what I am doing wrong?  
thanks in advance

---

<div class="post-metadata">

**Author:** ![jsanz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jsanz/32/53734_2.png) [@jsanz](https://discuss.elastic.co/u/jsanz)\
**Post date:** [September 7, 2022, 1:21pm UTC](https://discuss.elastic.co/t/kibana-logs/312915/2 "2022-09-07T13:21:49Z")

</div>

Why not using Kibana [built-in logging features](https://www.elastic.co/guide/en/kibana/current/logging-configuration.html)?

I just tested this sample configuration and works as expected:

```auto
logging:
  appenders:
    console-meta:
      type: console
      layout:
        type: pattern
        pattern: "[%date] [%level] [%logger] [%meta] %message"
        highlight: true
    rolling-file:
      type: rolling-file
      fileName: /usr/share/kibana/logs/kibana.log
      policy:
        type: time-interval
        interval: 60s
        modulate: true
      strategy:
        type: numeric
        pattern: '-%i'
        max: 10
      layout:
        type: pattern
        pattern: "[%date] [%level] [%logger] [%meta] %message"
  root:
    appenders: [console-meta, rolling-file]
    level: info

```

---

<div class="post-metadata">

**Author:** ![irivas95](https://avatars.discourse-cdn.com/v4/letter/i/839c29/32.png) [@irivas95](https://discuss.elastic.co/u/irivas95)\
**Post date:** [September 7, 2022, 4:34pm UTC](https://discuss.elastic.co/t/kibana-logs/312915/3 "2022-09-07T16:34:14Z")

</div>

Hi,  
Thank you for your reply.  
I am using kibana version 7.16.3 and it does not have this feature so I am forced to use logrotate.

---

<div class="post-metadata">

**Author:** ![jsanz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jsanz/32/53734_2.png) [@jsanz](https://discuss.elastic.co/u/jsanz)\
**Post date:** [September 8, 2022, 12:42pm UTC](https://discuss.elastic.co/t/kibana-logs/312915/4 "2022-09-08T12:42:13Z")

</div>

Just tested the same configuration I shared on a 7.16.2 and it also works just adding the `default` appender to the `root.appenders` key.

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/d/8/d89b6f6d15e1781df36a0586ac8b51dedcb49d81.png)

Documentation and examples are here on how to set up logging:

> **[Logging settings in Kibana | Kibana Guide \[7.16\] | Elastic](https://www.elastic.co/guide/en/kibana/7.16/logging-settings.html)**

It's true it does not mention the file rolling appender as it does in newer versions but it is available. Sorry if that confused you.

---

<div class="post-metadata">

**Author:** ![irivas95](https://avatars.discourse-cdn.com/v4/letter/i/839c29/32.png) [@irivas95](https://discuss.elastic.co/u/irivas95)\
**Post date:** [September 9, 2022, 6:31am UTC](https://discuss.elastic.co/t/kibana-logs/312915/5 "2022-09-09T06:31:31Z")

</div>

thank you for your reply.  
One more question, should this configuration be included in kibana.yml or in a separate file like elasticsearch's log4j2.properties, which then needs to be referenced in kibana.yml?

---

<div class="post-metadata">

**Author:** ![jsanz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jsanz/32/53734_2.png) [@jsanz](https://discuss.elastic.co/u/jsanz)\
**Post date:** [September 9, 2022, 8:10am UTC](https://discuss.elastic.co/t/kibana-logs/312915/6 "2022-09-09T08:10:15Z")

</div>

It should be included in the `kibana.yml` file or passed through environment variables as any other Kibana setting.

---

<div class="post-metadata">

**Author:** ![irivas95](https://avatars.discourse-cdn.com/v4/letter/i/839c29/32.png) [@irivas95](https://discuss.elastic.co/u/irivas95)\
**Post date:** [September 12, 2022, 7:03am UTC](https://discuss.elastic.co/t/kibana-logs/312915/8 "2022-09-12T07:03:55Z")

</div>

thank you again for your reply.  
I have done a test like yours and it works.  
Do you know if there is any way to add the date to the pattern I have tried this, but it is not working for me.

```auto
logging:
  appenders:
    console-meta:
      type: console
      layout:
        type: pattern
        pattern: "[%date] [%level] [%logger] [%meta] %message"
        highlight: true
    rolling-file:
      type: rolling-file
      fileName: /var/log/kibana/kibana.log
      policy:
        type: time-interval
        interval: 24h
        modulate: true
      strategy:
        type: numeric
        pattern: '-%d{yyyy-MM-dd}-%i'
        max: 7
      layout:
        type: pattern
        pattern: "[%date] [%level] [%logger] [%meta] %message"
  root:
    appenders: [default, console-meta, rolling-file]
    level: info

```

and the result is this

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/4/f/4fdd9dc44f5440dfdcb39b1e3be3bf9399c8710b.png)

---

<div class="post-metadata">

**Author:** ![jsanz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jsanz/32/53734_2.png) [@jsanz](https://discuss.elastic.co/u/jsanz)\
**Post date:** [September 12, 2022, 11:40am UTC](https://discuss.elastic.co/t/kibana-logs/312915/9 "2022-09-12T11:40:12Z")

</div>

> [@irivas95](#):
>
> Do you know if there is any way to add the date to the pattern

Unfortunately that feature is not yet implemented. There's a tracking issue in case you want to subscribe and stay updated, add your own feedback and so on.

> <https://github.com/elastic/kibana/issues/132400>
>
> Currently, Kibana only supports \[one Rolling strategy: \`numeric\`\](https://www.el…astic.co/guide/en/kibana/master/logging-configuration.html#\_rolling\_strategies)
> 
> We could extend this behaviour with an additional Rolling strategy: \`date\`, or maybe support the \`pattern\` to declare dates (\`pattern: %d{yyyy-MM-dd}\`)?
> 
> It could be useful for folks using the \_Time-interval triggering policy\_ to understand what are the times each log file contains just by looking at the file names.

---

<div class="post-metadata">

**Author:** ![irivas95](https://avatars.discourse-cdn.com/v4/letter/i/839c29/32.png) [@irivas95](https://discuss.elastic.co/u/irivas95)\
**Post date:** [September 13, 2022, 7:03am UTC](https://discuss.elastic.co/t/kibana-logs/312915/10 "2022-09-13T07:03:51Z")

</div>

thank you for everything, it has been very helpful.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [October 11, 2022, 7:04am UTC](https://discuss.elastic.co/t/kibana-logs/312915/11 "2022-10-11T07:04:29Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
