-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
rewrote Markers #2584
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
rewrote Markers #2584
Changes from all commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
f4d3301
rewrote Markers
grobmeier fbc06fa
wording
grobmeier 6d0146b
improved syntax
grobmeier 75a915f
uppercase letters for constants
grobmeier f940fec
wording
grobmeier 45d7088
uppercase constants
grobmeier a7a89ad
link
grobmeier 9c57434
link
grobmeier 710eafc
link
grobmeier fb3ff23
corrected capitalization and code highlighting
grobmeier 9d1dbad
imrpoved some wording
grobmeier ac18c9e
used proper formatting
grobmeier 49701cb
added comments for better copy / pasting
grobmeier 77ded9c
improved example
grobmeier d4b2bbf
better linking to source
grobmeier 5ef18e6
remaining feedback, improved wording (active voice)
grobmeier 2159c0e
some more activating voice, formatting
grobmeier 014652c
Fix `Logger` variable
vy efeb47e
Merge remote-tracking branch 'refs/remotes/apache/2.x' into doc/2.x/m…
ppkarwasz 13afdaf
Externalize examples
ppkarwasz c09b1d3
Fix RAT failure
ppkarwasz 1dcea03
Fix examples
vy a190192
added blanks for improved spell checker support
grobmeier c2a3733
some spelling errors, active/passive
grobmeier 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
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
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
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
63 changes: 63 additions & 0 deletions
63
src/site/antora/modules/ROOT/examples/manual/markers/MarkerExample.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,63 @@ | ||
/* | ||
* 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; | ||
import org.apache.logging.log4j.Marker; | ||
import org.apache.logging.log4j.MarkerManager; | ||
|
||
public final class MarkerExample { | ||
|
||
private static final Logger logger = LogManager.getLogger("example.MarkerExample"); | ||
// tag::create-marker[] | ||
private static final Marker SQL_MARKER = MarkerManager.getMarker("SQL"); | ||
// end::create-marker[] | ||
// tag::create-marker-parent[] | ||
private static final Marker QUERY_MARKER = | ||
MarkerManager.getMarker("SQL_QUERY").addParents(SQL_MARKER); | ||
private static final Marker UPDATE_MARKER = | ||
MarkerManager.getMarker("UPDATE").addParents(SQL_MARKER); | ||
// end::create-marker-parent[] | ||
|
||
public static void main(final String[] args) { | ||
doQuery("my_table"); | ||
doQueryParent("my_table"); | ||
doUpdate("my_table", "column", "value"); | ||
} | ||
|
||
public static void doQuery(String table) { | ||
// Do business logic here | ||
// tag::use-marker[] | ||
logger.debug(SQL_MARKER, "SELECT * FROM {}", table); | ||
// end::use-marker[] | ||
} | ||
|
||
public static void doQueryParent(String table) { | ||
// Do business logic here | ||
// tag::use-marker-parent[] | ||
logger.debug(QUERY_MARKER, "SELECT * FROM {}", table); | ||
// end::use-marker-parent[] | ||
} | ||
|
||
public static void doUpdate(String table, String column, String value) { | ||
// Do business logic here | ||
// tag::use-marker-parent[] | ||
logger.debug(UPDATE_MARKER, "UPDATE {} SET {} = {}", table, column, value); | ||
// end::use-marker-parent[] | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
src/site/antora/modules/ROOT/examples/manual/markers/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,31 @@ | ||
{ | ||
"Configuration": { | ||
"Appenders": { | ||
"Console": { | ||
"name": "SQL_LOG", | ||
"PatternLayout": { | ||
"pattern": "%d{HH:mm:ss.SSS} (%marker) %m%n" | ||
} | ||
} | ||
}, | ||
"Loggers": { | ||
"Root": { | ||
"level": "INFO" | ||
}, | ||
// tag::logger[] | ||
"Logger": { | ||
"name": "example", | ||
"level": "ALL", // <1> | ||
"AppenderRef": { | ||
"ref": "SQL_LOG", | ||
"MarkerFilter": { // <2> | ||
"marker": "SQL", | ||
"onMatch": "ACCEPT", | ||
"onMismatch": "DENY" | ||
} | ||
} | ||
} | ||
// end::logger[] | ||
} | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
src/site/antora/modules/ROOT/examples/manual/markers/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,34 @@ | ||
# | ||
# 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 = SQL_LOG | ||
appender.0.layout.type = PatternLayout | ||
appender.0.layout.pattern = %d{HH:mm:ss.SSS} (%marker) %m%n | ||
|
||
rootLogger.level = INFO | ||
|
||
# tag::logger[] | ||
logger.0.name = example | ||
# <1> | ||
logger.0.level = ALL | ||
logger.0.appenderRef.0.ref = SQL_LOG | ||
# <2> | ||
logger.0.appenderRef.0.filter.type = MarkerFilter | ||
logger.0.appenderRef.0.filter.marker = SQL | ||
logger.0.appenderRef.0.filter.onMatch = ACCEPT | ||
logger.0.appenderRef.0.filter.onMismatch = DENY | ||
# end::logger[] |
43 changes: 43 additions & 0 deletions
43
src/site/antora/modules/ROOT/examples/manual/markers/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,43 @@ | ||
<?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="SQL_LOG"> | ||
<PatternLayout pattern="%d{HH:mm:ss.SSS} (%marker) %m%n"/> | ||
</Console> | ||
</appenders> | ||
|
||
<loggers> | ||
<root level="INFO"/> | ||
<!-- tag::logger[] --> | ||
<logger name="example" level="ALL"><!--1--> | ||
<AppenderRef ref="SQL_LOG"> | ||
<MarkerFilter marker="SQL" | ||
onMatch="ACCEPT" | ||
onMismatch="DENY"/><!--2--> | ||
</AppenderRef> | ||
</logger> | ||
<!-- end::logger[] --> | ||
</loggers> | ||
|
||
</Configuration> |
36 changes: 36 additions & 0 deletions
36
src/site/antora/modules/ROOT/examples/manual/markers/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,36 @@ | ||
# | ||
# 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: "SQL_LOG" | ||
PatternLayout: | ||
pattern: "%d{HH:mm:ss.SSS} (%marker) %m%n" | ||
Loggers: | ||
Root: | ||
level: "INFO" | ||
# tag::logger[] | ||
Logger: | ||
name: "example" | ||
level: "ALL" # <1> | ||
AppenderRef: | ||
ref: "SQL_LOG" | ||
MarkerFilter: # <2> | ||
marker: "SQL" | ||
onMatch: "ACCEPT" | ||
onMismatch: DENY | ||
# end::logger[] |
23 changes: 23 additions & 0 deletions
23
src/site/antora/modules/ROOT/examples/manual/markers/marker-filtering.log
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,23 @@ | ||
# | ||
# 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. | ||
# | ||
# tag::use-marker[] | ||
10:42:30.982 (SQL) SELECT * FROM my_table | ||
# end::use-marker[] | ||
# tag::use-marker-parent[] | ||
10:42:30.982 (SQL_QUERY[ SQL ]) SELECT * FROM my_table | ||
10:42:30.982 (SQL_UPDATE[ SQL ]) UPDATE my_table SET column = value | ||
# end::use-marker-parent[] |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The correct capitalization is
Logger
:logging-log4j2/log4j-core/src/main/java/org/apache/logging/log4j/core/config/LoggerConfig.java
Line 62 in 2e17be4
I did republish the XSD a couple of weeks ago, but apparently something is wrong with it (not the examples).