-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Revamp the Extending, Plugins, Architecture, and Programmatic configuration pages
#2696
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
Merged
Merged
Changes from 34 commits
Commits
Show all changes
48 commits
Select commit
Hold shift + click to select a range
ee07dc3
Revamp JTL page
vy 439d206
Revamp JTL page
vy 454c421
Move Pattern Layout to a separate page
vy f3879ab
Rewrite layouts in `layouts.adoc`
vy 3150d81
Merge remote-tracking branch 'origin/2.x' into doc/2.x/layouts
vy 631dbe4
Small adjustments
vy 74a6ae4
Improve wording on UTF-8 default
vy f67176a
Improve wording
vy 78330f0
Apply suggestions from code review
vy d651754
Merge remote-tracking branch 'origin/doc/2.x/layouts' into doc/2.x/la…
vy b95d668
Explain `PatternLayout` documentation notation
vy 76f77b5
Remove incorrectly documented `%m{lookups}`
vy f77b5c0
Fix Pattern Layout gc-free lookups docs
vy c5f0126
Fix garbage-free notes about lookups for PL and JTL
vy 0cf6c34
Add plugin ref links
vy f9deaaf
Move extending appenders/filters/lookups to their own pages
vy 08d942b
Improve extending layouts
vy 3c20113
Merge remote-tracking branch 'origin/2.x' into doc/2.x/extending
vy d495947
Rewrite `plugins.adoc`
vy 65b9924
Merge remote-tracking branch 'origin/2.x' into doc/2.x/extending
vy fc1953b
Merge remote-tracking branch 'origin/2.x' into doc/2.x/extending
vy e5b8161
Revamp `extending.adoc`
vy 34eb9f0
Rewrite architecture page and several other affected pages
vy df1813d
Merge remote-tracking branch 'origin/2.x' into doc/2.x/extending
vy defb250
Merge remote-tracking branch 'origin/2.x' into doc/2.x/extending
vy e4c028b
Replace Ditaa with PlantUML
vy 4c7414c
Add information about reconfiguration
ppkarwasz 71fbef6
Move `ConfigurationFactory` to `configuration.adoc`
vy dd7d8bc
Rewrite programmatic configuration
vy 136506e
Merge remote-tracking branch 'origin/2.x' into doc/2.x/extending
vy f8a5534
Place `Reconfiguration reliability` under `Configuration`
vy 0a09e70
Advise against programmatically modifying components
vy b690448
Fix Spotless failures
vy df9ee62
Remove incorrectly placed `Filters` section in `configuration.adoc`
vy e2a2168
Improve wording
vy def1d8f
Fix `ExampleConfigurationFactory` method overload
vy b950f88
Remove the mention of `type-safe`
vy cd56f42
Fix explanation on `Configurator.initialize()`
vy 6399dbe
Fix explanation on `ConfigurationFactory` ordering
vy d1149f0
Fixing HTTP redirects based on fragments
vy c3e71b4
Fix `@Order` in `ExampleConfigurationFactory`
vy a44fe6c
Improve wording on `Usage#loadConfigurationFile()` example
vy 43f84a7
Improve `LoggerContextFactory` explanations
vy 8fd4b7e
Improve message factory documentation on placeholders
vy e505c16
Improve wording
vy 242a7ed
Remove the mention of `elementType`
vy be4b992
Fix code typo
vy 0b8c835
Explain which class loader is used
vy File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
18 changes: 18 additions & 0 deletions
18
src/site/antora/modules/ROOT/examples/manual/customconfig/ConfigurationBuilder/log4j2.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| { | ||
| "Configuration": { | ||
| "Appenders": { | ||
| "Console": { | ||
| "name": "CONSOLE", | ||
| "JsonTemplateLayout": {} | ||
| } | ||
| }, | ||
| "Loggers": { | ||
| "Root": { | ||
| "level": "WARN", | ||
| "AppenderRef": { | ||
| "ref": "CONSOLE" | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } |
22 changes: 22 additions & 0 deletions
22
...e/antora/modules/ROOT/examples/manual/customconfig/ConfigurationBuilder/log4j2.properties
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| # | ||
| # Licensed to the Apache Software Foundation (ASF) under one or more | ||
| # contributor license agreements. See the NOTICE file distributed with | ||
| # this work for additional information regarding copyright ownership. | ||
| # The ASF licenses this file to you under the Apache License, Version 2.0 | ||
| # (the "License"); you may not use this file except in compliance with | ||
| # the License. You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
| # | ||
| appender.0.type = Console | ||
| appender.0.name = CONSOLE | ||
| appender.0.layout.type = JsonTemplateLayout | ||
|
|
||
| rootLogger.level = WARN | ||
| rootLogger.appenderRef.0.ref = CONSOLE |
36 changes: 36 additions & 0 deletions
36
src/site/antora/modules/ROOT/examples/manual/customconfig/ConfigurationBuilder/log4j2.xml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <!-- | ||
| ~ Licensed to the Apache Software Foundation (ASF) under one or more | ||
| ~ contributor license agreements. See the NOTICE file distributed with | ||
| ~ this work for additional information regarding copyright ownership. | ||
| ~ The ASF licenses this file to you under the Apache License, Version 2.0 | ||
| ~ (the "License"); you may not use this file except in compliance with | ||
| ~ the License. You may obtain a copy of the License at | ||
| ~ | ||
| ~ http://www.apache.org/licenses/LICENSE-2.0 | ||
| ~ | ||
| ~ Unless required by applicable law or agreed to in writing, software | ||
| ~ distributed under the License is distributed on an "AS IS" BASIS, | ||
| ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| ~ See the License for the specific language governing permissions and | ||
| ~ limitations under the License. | ||
| --> | ||
| <Configuration xmlns="https://logging.apache.org/xml/ns" | ||
| xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
| xsi:schemaLocation=" | ||
| https://logging.apache.org/xml/ns | ||
| https://logging.apache.org/xml/ns/log4j-config-2.xsd"> | ||
|
|
||
| <Appenders> | ||
| <Console name="CONSOLE"> | ||
| <JsonTemplateLayout/> | ||
| </Console> | ||
| </Appenders> | ||
|
|
||
| <Loggers> | ||
| <Root level="WARN"> | ||
| <AppenderRef ref="CONSOLE"/> | ||
| </Root> | ||
| </Loggers> | ||
|
|
||
| </Configuration> |
28 changes: 28 additions & 0 deletions
28
src/site/antora/modules/ROOT/examples/manual/customconfig/ConfigurationBuilder/log4j2.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| # | ||
| # Licensed to the Apache Software Foundation (ASF) under one or more | ||
| # contributor license agreements. See the NOTICE file distributed with | ||
| # this work for additional information regarding copyright ownership. | ||
| # The ASF licenses this file to you under the Apache License, Version 2.0 | ||
| # (the "License"); you may not use this file except in compliance with | ||
| # the License. You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
| # | ||
| Configuration: | ||
|
|
||
| Appenders: | ||
| Console: | ||
| name: "CONSOLE" | ||
| JsonTemplateLayout: {} | ||
|
|
||
| Loggers: | ||
| Root: | ||
| level: "WARN" | ||
| AppenderRef: | ||
| ref: "CONSOLE" |
47 changes: 47 additions & 0 deletions
47
src/site/antora/modules/ROOT/examples/manual/customconfig/ExampleConfiguration.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one or more | ||
| * contributor license agreements. See the NOTICE file distributed with | ||
| * this work for additional information regarding copyright ownership. | ||
| * The ASF licenses this file to you under the Apache License, Version 2.0 | ||
| * (the "License"); you may not use this file except in compliance with | ||
| * the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
| package com.example; | ||
|
|
||
| import org.apache.logging.log4j.Level; | ||
| import org.apache.logging.log4j.core.Appender; | ||
| import org.apache.logging.log4j.core.LoggerContext; | ||
| import org.apache.logging.log4j.core.config.AppenderRef; | ||
| import org.apache.logging.log4j.core.config.ConfigurationSource; | ||
| import org.apache.logging.log4j.core.config.LoggerConfig; | ||
|
|
||
| public class ExampleConfiguration extends XmlConfiguration { | ||
|
|
||
| public ExampleConfiguration(LoggerContext loggerContext, ConfigurationSource configSource) { | ||
| super(loggerContext, configSource); | ||
| } | ||
|
|
||
| @Override | ||
| protected void doConfigure() { | ||
| Appender appender = createAppender("ExampleAppender"); | ||
| appender.start(); | ||
| addAppender(appender); | ||
| LoggerConfig loggerConfig = LoggerConfig.newBuilder() | ||
| .withConfig(this) | ||
| .withAdditivity(false) | ||
| .withLevel(Level.INFO) | ||
| .withLoggerName("com.example") | ||
| .withRefs(new AppenderRef[] {AppenderRef.createAppenderRef("ExampleAppender", null, null)}) | ||
| .build(); | ||
| loggerConfig.addAppender(appender, null, null); | ||
| addLogger("com.example", loggerConfig); | ||
| } | ||
| } |
41 changes: 41 additions & 0 deletions
41
src/site/antora/modules/ROOT/examples/manual/customconfig/ExampleConfigurationFactory.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one or more | ||
| * contributor license agreements. See the NOTICE file distributed with | ||
| * this work for additional information regarding copyright ownership. | ||
| * The ASF licenses this file to you under the Apache License, Version 2.0 | ||
| * (the "License"); you may not use this file except in compliance with | ||
| * the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
| package com.example; | ||
|
|
||
| import org.apache.logging.log4j.core.LoggerContext; | ||
| import org.apache.logging.log4j.core.config.Configuration; | ||
| import org.apache.logging.log4j.core.config.ConfigurationFactory; | ||
| import org.apache.logging.log4j.core.config.ConfigurationSource; | ||
| import org.apache.logging.log4j.core.config.Order; | ||
| import org.apache.logging.log4j.core.config.plugins.Plugin; | ||
|
|
||
| // tag::class[] | ||
| @Order(5) | ||
| @Plugin(name = "ExampleConfigurationFactory", category = ConfigurationFactory.CATEGORY) | ||
| public class ExampleConfigurationFactory extends ConfigurationFactory { | ||
|
|
||
| @Override | ||
| public Configuration getConfiguration(LoggerContext loggerContext, ConfigurationSource source) { | ||
| // Return a `Configuration`... | ||
| } | ||
|
|
||
| @Override | ||
| public String[] getSupportedTypes() { | ||
| return new String[] {"*"}; | ||
| } | ||
ppkarwasz marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
| // end::class[] | ||
90 changes: 90 additions & 0 deletions
90
src/site/antora/modules/ROOT/examples/manual/customconfig/Usage.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,90 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one or more | ||
| * contributor license agreements. See the NOTICE file distributed with | ||
| * this work for additional information regarding copyright ownership. | ||
| * The ASF licenses this file to you under the Apache License, Version 2.0 | ||
| * (the "License"); you may not use this file except in compliance with | ||
| * the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
| package com.example; | ||
|
|
||
| import java.net.URI; | ||
| import java.util.Arrays; | ||
| import org.apache.logging.log4j.Level; | ||
| import org.apache.logging.log4j.core.LoggerContext; | ||
| import org.apache.logging.log4j.core.config.AbstractConfiguration; | ||
| import org.apache.logging.log4j.core.config.Configuration; | ||
| import org.apache.logging.log4j.core.config.ConfigurationFactory; | ||
| import org.apache.logging.log4j.core.config.Configurator; | ||
| import org.apache.logging.log4j.core.config.builder.api.ConfigurationBuilder; | ||
| import org.apache.logging.log4j.core.config.builder.api.ConfigurationBuilderFactory; | ||
| import org.apache.logging.log4j.core.config.builder.impl.BuiltConfiguration; | ||
| import org.apache.logging.log4j.core.config.composite.CompositeConfiguration; | ||
|
|
||
| final class Usage { | ||
|
|
||
| private static Configuration createConfiguration() { | ||
| // tag::createConfiguration[] | ||
| ConfigurationBuilder<BuiltConfiguration> configBuilder = | ||
| ConfigurationBuilderFactory.newConfigurationBuilder(); // <1> | ||
| Configuration configuration = configBuilder | ||
| .add( | ||
| configBuilder // <2> | ||
| .newAppender("CONSOLE", "List") | ||
| .add(configBuilder.newLayout("JsonTemplateLayout"))) | ||
| .add( | ||
| configBuilder // <3> | ||
| .newRootLogger(Level.WARN) | ||
| .add(configBuilder.newAppenderRef("CONSOLE"))) | ||
| .build(false); // <4> | ||
| // end::createConfiguration[] | ||
| } | ||
|
|
||
| private static void useConfiguration() { | ||
| // tag::useConfiguration[] | ||
| Configuration configuration = createConfiguration(); | ||
| try (LoggerContext loggerContext = Configurator.initialize(configuration)) { | ||
| // Use `LoggerContext`... | ||
| } | ||
| // end::useConfiguration[] | ||
| } | ||
|
|
||
| private static void reconfigureActiveLoggerContext() { | ||
| // tag::reconfigureActiveLoggerContext[] | ||
| Configuration configuration = createConfiguration(); | ||
| Configurator.reconfigure(configuration); | ||
| // end::reconfigureActiveLoggerContext[] | ||
| } | ||
|
|
||
| private static Configuration loadConfigurationFile() { | ||
| // tag::loadConfigurationFile[] | ||
| ConfigurationFactory.getInstance() | ||
| .getConfiguration( | ||
| null, // <1> | ||
| null, // <2> | ||
| URI.create("uri://to/my/log4j2.xml")); // <3> | ||
| // end::loadConfigurationFile[] | ||
| } | ||
|
|
||
| private static Configuration combineConfigurations() { | ||
| // tag::combineConfigurations[] | ||
| ConfigurationFactory configFactory = ConfigurationFactory.getInstance(); | ||
| AbstractConfiguration commonConfig = (AbstractConfiguration) // <2> | ||
| configFactory.getConfiguration(null, null, URI.create("classpath:log4j2-common.xml")); // <1> | ||
| AbstractConfiguration appConfig = (AbstractConfiguration) // <2> | ||
| configFactory.getConfiguration(null, null, URI.create("classpath:log4j2-app.xml")); // <1> | ||
| AbstractConfiguration runtimeConfig = ConfigurationBuilderFactory.newConfigurationBuilder() | ||
| // ... | ||
| .build(false); // <3> | ||
| return new CompositeConfiguration(Arrays.asList(commonConfig, appConfig, runtimeConfig)); // <4> | ||
| // end::combineConfigurations[] | ||
| } | ||
| } |
Binary file not shown.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.