bin/kc.[sh|bat] start --log="console,file"
As an alternative to logging to the console, you can use structured/unstructured logging to a file stored in the filesystem. The more specific file handler configuration mentioned below will only take effect when the file logging is enabled.
Logging to a file is disabled by default. To enable it, enter the following command:
bin/kc.[sh|bat] start --log="console,file"
A log file named keycloak.log is created inside the data/log directory of your Keycloak installation.
To change where the log file is created and the file name, perform these steps:
Create a writable directory to store the log file.
If the directory is not writable, Keycloak starts correctly, but it issues an error and no log file is created.
Enter this command:
bin/kc.[sh|bat] start --log="console,file" --log-file=<path-to>/<your-file.log>
To configure a different logging format for the file log handler, enter the following command:
bin/kc.[sh|bat] start --log-file-format="<pattern>"
See [Configuring the console log format] for more information and a table of the available pattern configuration.
Log level for file log handler can be specified by --log-file-level property as follows:
bin/kc.[sh|bat] start --log-file-level=warn
For more information, see [Specify log level for each handler].
| Type or Values | Default | |
|---|---|---|
Available only when File log handler is activated |
String |
|
Available only when File log handler and MDC logging are activated |
|
|
Available only when File log handler and Tracing is activated |
|
|
Available only when File log handler is activated and output is set to 'json' |
|
|
Available only when File log handler is activated |
|
|
Available only when File log handler is activated |
|
|