Categories:
Audio (13)
Biotech (29)
Bytecode (36)
Database (77)
Framework (7)
Game (7)
General (507)
Graphics (53)
I/O (35)
IDE (2)
JAR Tools (101)
JavaBeans (21)
JDBC (121)
JDK (426)
JSP (20)
Logging (108)
Mail (58)
Messaging (8)
Network (84)
PDF (97)
Report (7)
Scripting (84)
Security (32)
Server (121)
Servlet (26)
SOAP (24)
Testing (54)
Web (15)
XML (309)
Collections:
Other Resources:
Source Code for Apache Log4j Core Implementation
Apache Log4j Core Implementation
provides the functional components of the logging system. Users are free to
create their own plugins and include them in the logging configuration.
Apache Log4j Core is a required module to use Apache Log4j.
Bytecode (Java 8) for Apache Log4j Core Implementation is provided in a separate JAR file like log4j-core-2.14.1.jar.
Source Code files for Apache Log4j API are provided in both binary packge like apache-log4j-2.14.1-bin.zip and source package like apache-log4j-2.14.1-src.zip. You can download them at Apache Log4j Website.
You can also browse Source Code files for Apache Log4j Core Implementation 2.14.1 below.
✍: FYIcenter.com
⏎ org/apache/logging/log4j/core/layout/MarkerPatternSelector.java
/* * 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 org.apache.logging.log4j.core.layout; import java.util.HashMap; import java.util.List; import java.util.Map; import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Marker; import org.apache.logging.log4j.core.LogEvent; import org.apache.logging.log4j.core.config.Configuration; import org.apache.logging.log4j.core.config.Node; import org.apache.logging.log4j.core.config.plugins.Plugin; import org.apache.logging.log4j.core.config.plugins.PluginBuilderAttribute; import org.apache.logging.log4j.core.config.plugins.PluginBuilderFactory; import org.apache.logging.log4j.core.config.plugins.PluginConfiguration; import org.apache.logging.log4j.core.config.plugins.PluginElement; import org.apache.logging.log4j.core.impl.LocationAware; import org.apache.logging.log4j.core.pattern.PatternFormatter; import org.apache.logging.log4j.core.pattern.PatternParser; import org.apache.logging.log4j.status.StatusLogger; /** * Selects the pattern to use based on the Marker in the LogEvent. */ @Plugin(name = "MarkerPatternSelector", category = Node.CATEGORY, elementType = PatternSelector.ELEMENT_TYPE, printObject = true) public class MarkerPatternSelector implements PatternSelector, LocationAware { /** * Custom MarkerPatternSelector builder. Use the {@link MarkerPatternSelector#newBuilder() builder factory method} to create this. */ public static class Builder implements org.apache.logging.log4j.core.util.Builder<MarkerPatternSelector> { @PluginElement("PatternMatch") private PatternMatch[] properties; @PluginBuilderAttribute("defaultPattern") private String defaultPattern; @PluginBuilderAttribute(value = "alwaysWriteExceptions") private boolean alwaysWriteExceptions = true; @PluginBuilderAttribute(value = "disableAnsi") private boolean disableAnsi; @PluginBuilderAttribute(value = "noConsoleNoAnsi") private boolean noConsoleNoAnsi; @PluginConfiguration private Configuration configuration; @Override public MarkerPatternSelector build() { if (defaultPattern == null) { defaultPattern = PatternLayout.DEFAULT_CONVERSION_PATTERN; } if (properties == null || properties.length == 0) { LOGGER.warn("No marker patterns were provided with PatternMatch"); return null; } return new MarkerPatternSelector(properties, defaultPattern, alwaysWriteExceptions, disableAnsi, noConsoleNoAnsi, configuration); } public Builder setProperties(final PatternMatch[] properties) { this.properties = properties; return this; } public Builder setDefaultPattern(final String defaultPattern) { this.defaultPattern = defaultPattern; return this; } public Builder setAlwaysWriteExceptions(final boolean alwaysWriteExceptions) { this.alwaysWriteExceptions = alwaysWriteExceptions; return this; } public Builder setDisableAnsi(final boolean disableAnsi) { this.disableAnsi = disableAnsi; return this; } public Builder setNoConsoleNoAnsi(final boolean noConsoleNoAnsi) { this.noConsoleNoAnsi = noConsoleNoAnsi; return this; } public Builder setConfiguration(final Configuration configuration) { this.configuration = configuration; return this; } } private final Map<String, PatternFormatter[]> formatterMap = new HashMap<>(); private final Map<String, String> patternMap = new HashMap<>(); private final PatternFormatter[] defaultFormatters; private final String defaultPattern; private static Logger LOGGER = StatusLogger.getLogger(); private final boolean requiresLocation; /** * @deprecated Use {@link #newBuilder()} instead. This will be private in a future version. */ @Deprecated public MarkerPatternSelector(final PatternMatch[] properties, final String defaultPattern, final boolean alwaysWriteExceptions, final boolean noConsoleNoAnsi, final Configuration config) { this(properties, defaultPattern, alwaysWriteExceptions, false, noConsoleNoAnsi, config); } private MarkerPatternSelector(final PatternMatch[] properties, final String defaultPattern, final boolean alwaysWriteExceptions, final boolean disableAnsi, final boolean noConsoleNoAnsi, final Configuration config) { boolean needsLocation = false; final PatternParser parser = PatternLayout.createPatternParser(config); for (final PatternMatch property : properties) { try { final List<PatternFormatter> list = parser.parse(property.getPattern(), alwaysWriteExceptions, disableAnsi, noConsoleNoAnsi); PatternFormatter[] formatters = list.toArray(new PatternFormatter[0]); formatterMap.put(property.getKey(), formatters); for (int i = 0; !needsLocation && i < formatters.length; ++i) { needsLocation = formatters[i].requiresLocation(); } patternMap.put(property.getKey(), property.getPattern()); } catch (final RuntimeException ex) { throw new IllegalArgumentException("Cannot parse pattern '" + property.getPattern() + "'", ex); } } try { final List<PatternFormatter> list = parser.parse(defaultPattern, alwaysWriteExceptions, disableAnsi, noConsoleNoAnsi); defaultFormatters = list.toArray(new PatternFormatter[0]); this.defaultPattern = defaultPattern; for (int i = 0; !needsLocation && i < defaultFormatters.length; ++i) { needsLocation = defaultFormatters[i].requiresLocation(); } } catch (final RuntimeException ex) { throw new IllegalArgumentException("Cannot parse pattern '" + defaultPattern + "'", ex); } requiresLocation = needsLocation; } @Override public boolean requiresLocation() { return requiresLocation; } @Override public PatternFormatter[] getFormatters(final LogEvent event) { final Marker marker = event.getMarker(); if (marker == null) { return defaultFormatters; } for (final String key : formatterMap.keySet()) { if (marker.isInstanceOf(key)) { return formatterMap.get(key); } } return defaultFormatters; } /** * Creates a builder for a custom ScriptPatternSelector. * * @return a ScriptPatternSelector builder. */ @PluginBuilderFactory public static Builder newBuilder() { return new Builder(); } /** * Deprecated, use {@link #newBuilder()} instead. * @param properties * @param defaultPattern * @param alwaysWriteExceptions * @param noConsoleNoAnsi * @param configuration * @return a new MarkerPatternSelector. * @deprecated Use {@link #newBuilder()} instead. */ @Deprecated public static MarkerPatternSelector createSelector( final PatternMatch[] properties, final String defaultPattern, final boolean alwaysWriteExceptions, final boolean noConsoleNoAnsi, final Configuration configuration) { final Builder builder = newBuilder(); builder.setProperties(properties); builder.setDefaultPattern(defaultPattern); builder.setAlwaysWriteExceptions(alwaysWriteExceptions); builder.setNoConsoleNoAnsi(noConsoleNoAnsi); builder.setConfiguration(configuration); return builder.build(); } @Override public String toString() { final StringBuilder sb = new StringBuilder(); boolean first = true; for (final Map.Entry<String, String> entry : patternMap.entrySet()) { if (!first) { sb.append(", "); } sb.append("key=\"").append(entry.getKey()).append("\", pattern=\"").append(entry.getValue()).append("\""); first = false; } if (!first) { sb.append(", "); } sb.append("default=\"").append(defaultPattern).append("\""); return sb.toString(); } }
⏎ org/apache/logging/log4j/core/layout/MarkerPatternSelector.java
Or download all of them as a single archive file:
File name: log4j-core-2.14.1-sources.jar File size: 1281358 bytes Release date: 2021-03-06 Download
⇒ Source Code for Apache Log4j JDK Logging Adapter
⇐ Source Code for Apache Log4j API
2015-11-03, 73994👍, 0💬
Popular Posts:
JasperReports, the world's most popular open source business intelligence and reporting engine and J...
What Is ojdbc5.jar for Oracle 11g R1? ojdbc5.jar for Oracle 11g R1 is the JAR files of ojdbc.jar, JD...
What Is commons-collections4-4.4 .jar?commons-collections4-4.4 .jaris the JAR file for Apache Common...
pache Derby is an open source relational database implemented entirely in Java and available under t...
How to download and install ojdbc6.jar for Oracle 11g R2? ojdbc6.jar for Oracle 11g R2 is a Java 6, ...