org.jboss.logging.Log4j2LoggerProvider Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of pax-logging-api Show documentation
Show all versions of pax-logging-api Show documentation
The Pax Logging API Library is to allow for the Pax Logging Service to be reloaded without stopping the many
dependent bundles. It also contains the OSGi Log Service API and the Knopflerfish Log API.
/*
* JBoss, Home of Professional Open Source.
*
* Copyright 2013 Red Hat, Inc.
*
* Licensed 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.jboss.logging;
import java.util.HashMap;
import java.util.Map;
import org.apache.logging.log4j.ThreadContext;
final class Log4j2LoggerProvider implements LoggerProvider {
@Override
public Log4j2Logger getLogger(String name) {
return new Log4j2Logger(name);
}
@Override
public void clearMdc() {
ThreadContext.clearMap();
}
@Override
public Object putMdc(String key, Object value) {
try {
return ThreadContext.get(key);
} finally {
ThreadContext.put(key, String.valueOf(value));
}
}
@Override
public Object getMdc(String key) {
return ThreadContext.get(key);
}
@Override
public void removeMdc(String key) {
ThreadContext.remove(key);
}
@Override
public Map getMdcMap() {
return new HashMap(ThreadContext.getImmutableContext());
}
@Override
public void clearNdc() {
ThreadContext.clearStack();
}
@Override
public String getNdc() {
return ThreadContext.peek();
}
@Override
public int getNdcDepth() {
return ThreadContext.getDepth();
}
@Override
public String popNdc() {
return ThreadContext.pop();
}
@Override
public String peekNdc() {
return ThreadContext.peek();
}
@Override
public void pushNdc(String message) {
ThreadContext.push(message);
}
@Override
public void setNdcMaxDepth(int maxDepth) {
ThreadContext.trim(maxDepth);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy