Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added information how to configure logback with environment variables #369

Merged
1 commit merged into from
Mar 7, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 62 additions & 0 deletions src/main/pages/setup-docker/docker-config.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,68 @@ Instance configuration is generated by Che and is updated by our internal config
/instance/config # Configuration files for Che which are volume mounted into containers
```


**Logback configuration**

By default ws-master and ws-agent are configured to use logback as default logging backend. With has such configuration
```
<configuration>
<contextListener class="ch.qos.logback.classic.jul.LevelChangePropagator">
<resetJUL>true</resetJUL>
</contextListener>
<contextListener class="org.eclipse.che.commons.logback.EnvironmentVariablesLogLevelPropagator"/>
<property name="max.retention.days" value="60" />
<jmxConfigurator/>
<appender name="stdout" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%-41(%date[%.15thread]) %-45([%-5level] [%.30logger{30} %L]) - %msg%n</pattern>
</encoder>
</appender>
<appender name="file" class="ch.qos.logback.core.rolling.RollingFileAppender">
<append>true</append>
<prudent>true</prudent>
<encoder>
<charset>utf-8</charset>
<pattern>%-41(%date[%.15thread]) %-45([%-5level] [%.30logger{30} %L]) - %msg%n</pattern>
</encoder>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>${che.logs.dir}/archive/%d{yyyy/MM/dd}/catalina.log</fileNamePattern>
<maxHistory>${max.retention.days}</maxHistory>
</rollingPolicy>
</appender>
<include optional="true" file="${che.local.conf.dir}/logback/logback-additional-appenders.xml"/>
<include optional="true" file="${catalina.home}/conf/logback-additional-appenders.xml"/>
<logger name="org.apache.catalina.loader" level="OFF"/>
<logger name="org.apache.catalina.session.PersistentManagerBase" level="OFF"/>
<logger name="org.apache.jasper.servlet.TldScanner" level="OFF"/>
<root level="${che.logs.level:-INFO}">
<appender-ref ref="stdout"/>
<appender-ref ref="file"/>
</root>
</configuration>
```
Usually, it stored in tomcat's conf folder as logback.xml file.
There are two ways to exted this configuration.
1. Put your configuration in ${che.local.conf.dir}/logback/logback-additional-appenders.xml or ${catalina.home}/conf/logback-additional-appenders.xml file
2. Provide environment variable in such form
```
CHE_LOGGER_CONFIG=logger1=logger1_level,logger2=logger2_level
```
for example
```
CHE_LOGGER_CONFIG=org.eclipse.che=DEBUG,org.eclipse.che.api.installer.server.impl.LocalInstallerRegistry=OFF
```
In case if you are using docker cli you can put this variable to che.env for ws-master or workspace config in case of workspace agent.


**Logstash JSON Encoder**

Che-server comes with `logstash-json-encoder` which allows you to send logs in a JSON format for Logstash or any other log consumers. Adding a new appender can be done by adding a `logback-additional-appenders.xml` in `${CHE_LOCAL_CONF_DIR}/logback/` or `${CATALINA_HOME}/conf/` folder from your custom assembly or mounted volume:
Expand Down