forked from apache/logging-log4j2
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
We revamp the `Lookups` page by: * Adding information on different evaluation contexts supported by lookups. * Adding a cheatsheet on which lookup is available in which evaluation context. E.g., using `$${sys:something}` on a per-event level is a major performance waster. * Removing the description of the broken `jvmrunargs` lookup (see apache#2726). * Improving the description of the `main` lookup by providing a code example that does not fail if the user switches logging implementations. * Shortening and improving the description of other lookups.
- Loading branch information
Showing
24 changed files
with
1,127 additions
and
557 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
43 changes: 43 additions & 0 deletions
43
src/site/antora/modules/ROOT/examples/manual/lookups/MainArgsExample.java
This file contains 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,43 @@ | ||
/* | ||
* 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 example; | ||
|
||
import org.apache.logging.log4j.LogManager; | ||
import org.apache.logging.log4j.Logger; | ||
|
||
public final class MainArgsExample implements Runnable { | ||
|
||
// tag::usage[] | ||
private final Logger logger = LogManager.getLogger(); // <1> | ||
|
||
public static void main(final String[] args) { | ||
try { // <2> | ||
Class.forName("org.apache.logging.log4j.core.lookup.MainMapLookup") | ||
.getDeclaredMethod("setMainArguments", String[].class) | ||
.invoke(null, (Object) args); | ||
} catch (final ReflectiveOperationException e) { | ||
// Log4j Core is not used. | ||
} | ||
new MainArgsExample().run(); | ||
} | ||
// end::usage[] | ||
|
||
@Override | ||
public void run() { | ||
logger.info("Hello `main` lookup!"); | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
src/site/antora/modules/ROOT/examples/manual/lookups/mainArgs.json
This file contains 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,31 @@ | ||
{ | ||
"Configuration": { | ||
"Properties": { | ||
"Property": [ // <1> | ||
{ | ||
"name": "--logfile", | ||
"value": "logs/app.log" | ||
}, | ||
{ | ||
"name": "--loglevel", | ||
"value": "INFO" | ||
} | ||
] | ||
}, | ||
"Appenders": { | ||
"File": { | ||
"fileName": "${main:\\--logfile}", // <2> | ||
"name": "FILE", | ||
"JsonTemplateLayout": {} | ||
} | ||
}, | ||
"Loggers": { | ||
"Root": { | ||
"level": "${main:\\--loglevel", // <2> | ||
"AppenderRef": { | ||
"ref": "FILE" | ||
} | ||
} | ||
} | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
src/site/antora/modules/ROOT/examples/manual/lookups/mainArgs.properties
This file contains 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,29 @@ | ||
# | ||
# 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. | ||
# | ||
## | ||
# <1> | ||
property.--logfile = logs/app.log | ||
property.--loglevel = INFO | ||
|
||
appender.0.type = File | ||
# <2> | ||
appender.0.fileName = ${main:\\--logfile} | ||
appender.0.name = FILE | ||
|
||
# <2> | ||
rootLogger.level = ${main:\\--loglevel} | ||
rootLogger.appenderRef.0.ref = FILE |
36 changes: 36 additions & 0 deletions
36
src/site/antora/modules/ROOT/examples/manual/lookups/mainArgs.xml
This file contains 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"> | ||
<Properties> <!--1--> | ||
<Property name="--logfile" value="logs/app.log"/> | ||
<Property name="--loglevel" value="INFO"/> | ||
</Properties> | ||
<Appenders> | ||
<File fileName="${main:\--logfile}" | ||
name="FILE"/> <!--2--> | ||
</Appenders> | ||
<Loggers> | ||
<Root level="${main:\--loglevel}"> <!--2--> | ||
<AppenderRef ref="FILE"/> | ||
</Root> | ||
</Loggers> | ||
</Configuration> |
Oops, something went wrong.