# Adding date in keycloak logs

**URL:** <https://forum.keycloak.org/t/adding-date-in-keycloak-logs/12508>\
**Category:** Getting advice\
**Created:** [December 9, 2021, 12:02am UTC](https://forum.keycloak.org/t/adding-date-in-keycloak-logs/12508 "2021-12-09T00:02:52Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![chevchelios1](https://yyz2.discourse-cdn.com/free1/user_avatar/forum.keycloak.org/chevchelios1/32/4550_2.png) [@chevchelios1](https://forum.keycloak.org/u/chevchelios1)\
**Post date:** [December 9, 2021, 12:02am UTC](https://forum.keycloak.org/t/adding-date-in-keycloak-logs/12508/1 "2021-12-09T00:02:52Z")

</div>

We’re using Keycloak in Kubernetes using the jboss/keycloak Docker image.

We want to import the logs into Elasticsearch, but the default logging format is not useful because the date is missing (only the time is included).  
14:47:00,554 INFO

How can I change the logging format to include the date?

Preferably without having to build a custom Docker image, so by passing command line parameters and/or mounting files into the container?

(It would be nice to get rid of the colour codes from the log messages as well, but that’s not a big deal because I can strip them off later.)

---

<div class="post-metadata">

**Author:** ![jangaraj](https://yyz2.discourse-cdn.com/free1/user_avatar/forum.keycloak.org/jangaraj/32/5175_2.png) [@jangaraj](https://forum.keycloak.org/u/jangaraj)\
**Post date:** [December 9, 2021, 7:57am UTC](https://forum.keycloak.org/t/adding-date-in-keycloak-logs/12508/2 "2021-12-09T07:57:33Z")

</div>

You should to switch to [json log format](https://www.youtube.com/watch?v=AnHUqu-Vi_E) (thx for @dasniko ) first, when you want to import logs into Elasticsearch. Your logging life will be far more easier. And this format is comming also with full timestamp, e.g.:

```auto
{"timestamp":"2021-12-09T07:47:05.066Z","sequence":150,"loggerClassName":"org.jboss.as.server.logging.ServerLogger_$logger","loggerName":"org.jboss.as","level":"INFO","message":"WFLYSRV0051: Admin console listening on http://0.0.0.0:9990","threadName":"Controller Boot Thread","threadId":25,"mdc":{},"ndc":"","hostName":"0ab9eb948acc","processName":"jboss-modules.jar","processId":1118}

```

Some parsing rules for logs with `type=` (e.g. splitting into key=\>value) with proper elasticsearch indexing template and you will have decent Keycloak log processing in place.

---

<div class="post-metadata">

**Author:** ![chevchelios1](https://yyz2.discourse-cdn.com/free1/user_avatar/forum.keycloak.org/chevchelios1/32/4550_2.png) [@chevchelios1](https://forum.keycloak.org/u/chevchelios1)\
**Post date:** [December 10, 2021, 1:42pm UTC](https://forum.keycloak.org/t/adding-date-in-keycloak-logs/12508/3 "2021-12-10T13:42:17Z")

</div>

Thaks a lot,thats helps me, but now I have a question about configuring JSON log format for human readable format.

---

<div class="post-metadata">

**Author:** ![semangard](https://yyz2.discourse-cdn.com/free1/user_avatar/forum.keycloak.org/semangard/32/1922_2.png) [@semangard](https://forum.keycloak.org/u/semangard)\
**Post date:** [December 15, 2021, 6:02am UTC](https://forum.keycloak.org/t/adding-date-in-keycloak-logs/12508/4 "2021-12-15T06:02:37Z")

</div>

I used this CLI :

```auto

# ##############################################################################
# CONSOLE handler
# ##############################################################################
embed-server --server-config=standalone-ha.xml --std-out=echo

# add yyyy-MM-dd GMT+1 to each CONSOLE log
try
    echo "Changing CONSOLE pattern..."
    /subsystem=logging/pattern-formatter=COLOR-PATTERN:write-attribute(name="pattern", value="%K{level}%z{GMT+1}%d{yyyy-MM-dd HH:mm:ss,SSS XXX} %-5p [%c] (%t) %s%e%n")
catch
end-try

echo "--------------------------------------------------------------------------"

stop-embedded-server

```
