@@ -75,7 +75,7 @@ So, how do you configure logging for {geode-name}?
7575
7676Three things are required to get {geode-name} to log output:
7777
78- . You must declare a logging provider (such as Logback) on your Spring Boot application classpath.
78+ . You must declare a logging provider (such as Logback, or Log4j ) on your Spring Boot application classpath.
7979. (optional) You can declare an adapter (a bridge JAR) between Log4j and your logging provider if your declared
8080logging provider is not Apache Log4j.
8181+
@@ -96,22 +96,27 @@ NOTE: {geode-name}'s `geode-log4j` module covers the required configuration for
9696(`org.apache.logging.log4j:log4j-core`) as the logging provider. The `geode-log4j` module even provides a default
9797`log4j2.xml` configuration file to configure Loggers, Appenders, and log levels for {geode-name}.
9898
99- If you declare Spring Boot's own `org.springframework.boot:spring-boot-starter-logging` on your application classpath,
100- it covers steps 1 and 2 above.
99+ If you declare Spring Boot's own `org.springframework.boot:spring-boot-starter-logging` on your application
100+ classpath, it covers steps 1 and 2 above.
101101
102102The `spring-boot-starter-logging` dependency declares Logback as the logging provider and automatically adapts (bridges)
103103`java.util.logging` (JUL) and Apache Log4j to SLF4J. However, you still need to supply logging provider configuration
104104(such as a `logback.xml` file for Logback) to configure logging not only for your Spring Boot application but for
105105{geode-name} as well.
106106
107+ NOTE: If no user-specified logging configuration is supplied, Logback will apply default configuration
108+ using the `BasicConfigurator`. See Logback https://logback.qos.ch/manual/configuration.html#auto_configuration[documentation]
109+ for complete details.
110+
107111SBDG has simplified the setup of {geode-name} logging. You need only declare the
108112`org.springframework.geode:spring-geode-starter-logging` dependency on your Spring Boot application classpath.
109113
110- Unlike {geode-name}'s default Log4j XML configuration file (`log4j2.xml`), SBDG's provided `logback.xml` configuration
111- file is properly parameterized, letting you adjust log levels as well as add Appenders.
114+ Unlike {geode-name}'s default Log4j XML configuration file (`log4j2.xml` from `geode-log4j`), SBDG's provided
115+ `logback.xml` configuration file is properly parameterized, letting you adjust log levels, add Appenders
116+ as well as adjust other logging settings.
112117
113118In addition, SBDG's provided Logback configuration uses templates so that you can compose your own logging configuration
114- while still including snippets from SBDG's provided logging configuration metadata , such as Loggers and Appenders.
119+ while still including snippets from SBDG's provided logging configuration, such as Loggers and Appenders.
115120
116121[[geode-logging-configuration-log-levels]]
117122==== Configuring Log Levels
@@ -129,7 +134,7 @@ SBDG's Logback configuration defines three Loggers to control the log output fro
129134<comfiguration>
130135 <logger name="com.gemstone.gemfire" level="${spring.boot.data.gemfire.log.level:-INFO}"/>
131136 <logger name="org.apache.geode" level="${spring.boot.data.gemfire.log.level:-INFO}"/>
132- <logger name="org.jgroups" level="${spring.boot.data.gemfire.jgroups.log.level:-ERROR }"/>
137+ <logger name="org.jgroups" level="${spring.boot.data.gemfire.jgroups.log.level:-WARN }"/>
133138</comfiguration>
134139----
135140====
@@ -142,7 +147,7 @@ during the runtime operation of {geode-name}. By default, it logs output at `INF
142147
143148The `org.jgroups` Logger is used to log output from {geode-name}'s message distribution and membership system.
144149{geode-name} uses JGroups for membership and message distribution between peer members (nodes) in the cluster
145- (distributed system). By default, JGroups logs output at `ERROR `.
150+ (distributed system). By default, JGroups logs output at `WARN `.
146151
147152You can configure the log level for the `com.gemstone.gemfire` and `org.apache.geode` Loggers by setting
148153the `spring.boot.data.gemfire.log.level` property. You can independently configure the `org.jgroups` Logger by setting
@@ -195,30 +200,118 @@ or later.
195200As mentioned earlier, SBDG lets you compose your own logging configuration from SBDG's default Logback configuration
196201metadata.
197202
198- SBDG conveniently bundles the Loggers and Appenders from SBDG's logging starter into a template file that you can
199- include into your own custom Logback XML configuration file.
203+ SBDG conveniently bundles the Properties, Loggers and Appenders from SBDG's logging starter into several template files
204+ that you can include into your own custom Logback XML configuration file.
205+
206+ The Logback configuration template files are broken down into:
207+
208+ * `org/springframework/geode/logging/slf4j/logback/properties-include.xml`
209+ * `org/springframework/geode/logging/slf4j/logback/loggers-include.xml`
210+ * `org/springframework/geode/logging/slf4j/logback/appenders-include.xml`
200211
201- The Logback template file appears as follows:
212+ WARNING: As of SBDG `2.7`, the `logback-include.xml` file has been deprecated.
202213
203- .logback-include.xml
214+ The `properties-include.xml` defines Logback "_local_" scoped properties or variables common to SBDG's configuration
215+ of {geode-name} logging.
216+
217+ .properties-include.xml
204218====
205219[source,xml]
206220----
207- include::{starter-logging-resources-dir}/logback-include.xml[]
221+ include::{starter-logging-resources-dir}/org/springframework/geode/logging/slf4j/ logback/properties -include.xml[]
208222----
209223====
210224
211- Then you can include this Logback configuration snippet in an application-specific Logback XML configuration file,
212- as follows:
225+ The `loggers-include.xml` file defines the `Loggers` used to log output from {geode-name} components.
213226
214- .logback .xml
227+ .loggers-include .xml
215228====
216229[source,xml]
217230----
218- include::{starter-logging-resources-dir}/logback.xml[]
231+ include::{starter-logging-resources-dir}/org/springframework/geode/logging/slf4j/ logback/logger-include .xml[]
219232----
220233====
221234
235+ The `appenders-include.xml` file defines Appenders to send the log output to. If Spring Boot is on the application
236+ classpath, then Spring Boot logging configuration will define the "CONSOLE" `Appender`, otherwise, SBDG will provide
237+ a default definition.
238+
239+ The "geode" `Appender` defines the {geode-name} logging pattern as seen in {geode-name}'s Log4j configuration.
240+
241+ .appenders-include.xml
242+ ====
243+ [source,xml]
244+ ----
245+ include::{starter-logging-resources-dir}/org/springframework/geode/logging/slf4j/logback/appender-include.xml[]
246+ ----
247+ ====
248+
249+ Then you can include any of SBDG'S Logback configuration metadata files as needed in your application-specific
250+ Logback XML configuration file, as follows:
251+
252+ .application-specific logback.xml
253+ ====
254+ [source,xml]
255+ ----
256+ <?xml version="1.0" encoding="UTF-8"?>
257+ <configuration>
258+
259+ <include resource="org/springframework/geode/logging/slf4j/logback/properties-include.xml"/>
260+ <include resource="org/springframework/geode/logging/slf4j/logback/appender-include.xml"/>
261+
262+ <logger name="org.apache.geode" level="INFO" additivity="false">
263+ <appender-ref ref="geode"/>
264+ </logger>
265+
266+ <root level="${logback.root.log.level:-INFO}">
267+ <appender-ref ref="CONSOLE"/>
268+ <appender-ref ref="delegate"/>
269+ </root>
270+
271+ </configuration>
272+ ----
273+ ====
274+
275+ [[geode-logging-configuration-customizing]]
276+ ==== Customizing Logging Configuration
277+
278+ It is now possible to customize the configuration of {geode-name} logging using properties defined in
279+ a `spring-geode-logging.properties` file included on the Spring Boot application classpath.
280+
281+ Any of the properties defined in `org/springframework/geode/logging/slf4j/logback/properties-include.xml` (shown above),
282+ such as `APACHE_GEODE_LOG_PATTERN`, or the `spring.geode.logging.appender-ref` property, can be set.
283+
284+ For instance, and by default, {geode-name} components log output using the Spring Boot log pattern. However, if you
285+ prefer the fine-grained details of Apache Geode's logging behavior, you can change the `Appender` used by
286+ the {geode-name} `Logger's` to use the pre-defined "geode" `Appender` instead. Simply set
287+ the `spring-geode.logging.appender-ref` property to "geode" in a `spring-geode-logging.properties` file
288+ on your Spring Boot application classpath, as follows:
289+
290+ .spring-geode-logging.properties
291+ ====
292+ [source,properties]
293+ ----
294+ # spring-geode-logging.properties
295+ spring.geode.logging.appender-ref=geode
296+ ----
297+ ====
298+
299+ Alternatively, if you want to configure the log output of your entire Spring Boot application, including log output
300+ from all {geode-name} components, then you can set the `SPRING_BOOT_LOG_PATTERN` property, or Spring Boot's
301+ `CONSOLE_LOG_PATTERN` property, in `spring-geode-logging.properties`, as follows:
302+
303+ .spring-geode-logging.properties
304+ ====
305+ [source,properties]
306+ ----
307+ # spring-geode-logging.properties
308+ CONSOLE_LOG_PATTERN=TEST - %msg%n
309+ ----
310+ ====
311+
312+ NOTE: The `spring-geode-logging.properties` file is only recognized when the `spring-geode-starter-logging` module
313+ is used.
314+
222315[[geode-logging-slf4j-logback-api-support]]
223316=== SLF4J and Logback API Support
224317
0 commit comments