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 weld-servlet-shaded Show documentation
Show all versions of weld-servlet-shaded Show documentation
This jar bundles all the bits of Weld and CDI required for running in a Servlet container.
/*
* 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 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);
}
}