本文整理了Java中org.apache.logging.log4j.Marker.getName()
方法的一些代码示例,展示了Marker.getName()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Marker.getName()
方法的具体详情如下:
包路径:org.apache.logging.log4j.Marker
类名称:Marker
方法名:getName
[英]Returns the name of this Marker.
[中]返回此标记的名称。
代码示例来源:origin: medcl/elasticsearch-analysis-ik
public String prefix() {
return this.marker.getName();
}
代码示例来源:origin: org.apache.logging.log4j/log4j-slf4j-impl
@Override
public String getName() {
return marker.getName();
}
代码示例来源:origin: org.apache.logging.log4j/log4j-api
@Override
public boolean equals(final Object o) {
if (this == o) {
return true;
}
if (o == null || !(o instanceof Marker)) {
return false;
}
final Marker marker = (Marker) o;
return name.equals(marker.getName());
}
代码示例来源:origin: apache/hive
@Override
public boolean isInstanceOf(Marker m) {
if (m!= null && this.getName().equals(m.getName())) {
return true;
} else {
return false;
}
}
代码示例来源:origin: apache/hive
@Override
public void update(String key, LogEvent event) {
Marker marker = event.getMarker();
if (marker != null && marker.getName() != null && marker.getName().equals(Log4jQueryCompleteMarker.EOF_MARKER)) {
LOGGER.debug("Received " + Log4jQueryCompleteMarker.EOF_MARKER + " for key. Attempting cleanup.");
keyComplete(key);
}
else {
if (knownAppenders.add(key)) {
if (LOGGER.isDebugEnabled()) {
LOGGER.debug("Registered key: [" + key + "] on purgePolicyWithName=" + name +
", thisAddress=" + System.identityHashCode(this));
}
}
}
}
代码示例来源:origin: org.apache.logging.log4j/log4j-slf4j-impl
@Override
public Iterator<Marker> iterator() {
final org.apache.logging.log4j.Marker[] log4jParents = this.marker.getParents();
final List<Marker> parents = new ArrayList<>(log4jParents.length);
for (final org.apache.logging.log4j.Marker m : log4jParents) {
parents.add(factory.getMarker(m.getName()));
}
return parents.iterator();
}
代码示例来源:origin: apache/hive
@Override
public void append(LogEvent event) {
setupAppenderIfRequired(event);
if (appenderControl.get() != null) {
if (!(event.getMarker() != null && event.getMarker().getName() != null &&
event.getMarker().getName().equals(Log4jQueryCompleteMarker.EOF_MARKER))) {
appenderControl.get().callAppender(event);
} else {
LOGGER.debug("Not forwarding message with maker={}, marker.getName={}", event.getMarker(),
(event.getMarker() == null ? "nullMarker" : event.getMarker().getName()));
}
}
}
代码示例来源:origin: org.apache.logging.log4j/log4j-api
@PerformanceSensitive("allocation")
private static void addParentInfo(final StringBuilder sb, final Marker... parents) {
sb.append("[ ");
boolean first = true;
// noinspection ForLoopReplaceableByForEach
for (int i = 0, parentsLength = parents.length; i < parentsLength; i++) {
final Marker marker = parents[i];
if (!first) {
sb.append(", ");
}
first = false;
sb.append(marker.getName());
final Marker[] p = marker instanceof Log4jMarker ? ((Log4jMarker) marker).parents : marker.getParents();
if (p != null) {
addParentInfo(sb, p);
}
}
sb.append(" ]");
}
}
代码示例来源:origin: apache/geode
@Before
public void setUp() {
MessageFactory messageFactory = new ParameterizedMessageFactory();
mockedLogger = mock(ExtendedLogger.class);
mockedMarker = mock(Marker.class);
when(mockedLogger.getMessageFactory()).thenReturn(messageFactory);
when(mockedLogger.getName()).thenReturn(LOGGER_NAME);
when(mockedLogger.getLevel()).thenReturn(Level.INFO);
when(mockedMarker.getName()).thenReturn(MARKER_NAME);
fastLogger = new FastLogger(mockedLogger);
FastLogger.setDelegating(true);
clearInvocations(mockedLogger);
assertThat(mockedLogger.getLevel()).isEqualTo(Level.INFO);
}
代码示例来源:origin: org.apache.logging.log4j/log4j-core
@Test
public void testLookupExistant() {
final String value = strLookup.lookup(MarkerManager.getMarker(markerName).getName());
assertEquals(markerName, value);
}
代码示例来源:origin: org.elasticsearch/elasticsearch
/**
* Obtain the prefix for this prefix logger. This can be used to create a logger with the same prefix as this one.
*
* @return the prefix
*/
public String prefix() {
return marker.getName();
}
代码示例来源:origin: org.apache.logging.log4j/log4j-core
protected void assertLogEvent(final LogEvent logEvent) {
assertThat(logEvent, is(notNullValue()));
assertThat(logEvent.getInstant().getEpochMillisecond(), equalTo(1493121664118L));
assertThat(logEvent.getThreadName(), equalTo("main"));
assertThat(logEvent.getThreadId(), equalTo(1L));
assertThat(logEvent.getThreadPriority(), equalTo(5));
assertThat(logEvent.getLevel(), equalTo(Level.INFO));
assertThat(logEvent.getLoggerName(), equalTo("HelloWorld"));
assertThat(logEvent.getMarker().getName(), equalTo("child"));
assertThat(logEvent.getMarker().getParents()[0].getName(), equalTo("parent"));
assertThat(logEvent.getMarker().getParents()[0].getParents()[0].getName(),
equalTo("grandparent"));
assertThat(logEvent.getMessage().getFormattedMessage(), equalTo("Hello, world!"));
assertThat(logEvent.getThrown(), is(nullValue()));
assertThat(logEvent.getThrownProxy().getMessage(), equalTo("error message"));
assertThat(logEvent.getThrownProxy().getName(), equalTo("java.lang.RuntimeException"));
assertThat(logEvent.getThrownProxy().getExtendedStackTrace()[0].getClassName(),
equalTo("logtest.Main"));
assertThat(logEvent.getLoggerFqcn(), equalTo("org.apache.logging.log4j.spi.AbstractLogger"));
assertThat(logEvent.getContextStack().asList(), equalTo(Arrays.asList("one", "two")));
assertThat((String) logEvent.getContextData().getValue("foo"), equalTo("FOO"));
assertThat((String) logEvent.getContextData().getValue("bar"), equalTo("BAR"));
assertThat(logEvent.getSource().getClassName(), equalTo("logtest.Main"));
}
}
代码示例来源:origin: org.apache.logging.log4j/log4j-api
fail("Incorrect marker. Expected null. Actual is " + marker.getName());
} else {
assertTrue("Incorrect marker. Expected " + currentEvent.markerName + ", actual " +
marker.getName(), currentEvent.markerName.equals(marker.getName()));
代码示例来源:origin: org.apache.logging.log4j/log4j-api
fail("Incorrect marker. Expected null. Actual is " + marker.getName());
} else {
assertTrue("Incorrect marker. Expected " + currentEvent.markerName + ", actual " +
marker.getName(), currentEvent.markerName.equals(marker.getName()));
代码示例来源:origin: org.apache.logging.log4j/log4j-api
fail("Incorrect marker. Expected null. Actual is " + marker.getName());
} else {
assertTrue("Incorrect marker. Expected " + currentEvent.markerName + ", actual " +
marker.getName(), currentEvent.markerName.equals(marker.getName()));
代码示例来源:origin: org.apache.logging.log4j/log4j-core
@Test
public void testLookupEventExistant() {
final Marker marker = MarkerManager.getMarker(markerName);
final LogEvent event = Log4jLogEvent.newBuilder() //
.setLoggerName(this.getClass().getName()) //
.setMarker(marker) //
.setLoggerFqcn("org.apache.logging.log4j.core.Logger") //
.setLevel(Level.INFO) //
.setMessage(new SimpleMessage("Hello, world!")).build();
final String value = strLookup.lookup(event, marker.getName());
assertEquals(markerName, value);
}
代码示例来源:origin: org.apache.logging.log4j/log4j-core
@Test
public void testLookup() {
final Message msg = new StructuredDataMessage("Test", "This is a test", "Audit");
final Marker eventMarker = MarkerManager.getMarker("EVENT");
final Marker auditMarker = MarkerManager.getMarker("AUDIT").setParents(eventMarker);
final LogEvent event = Log4jLogEvent.newBuilder().setLoggerName("MyLogger").setMarker(auditMarker)
.setLevel(Level.DEBUG).setMessage(msg).build();
final StringBuilder sb = new StringBuilder();
final MarkerSimpleNamePatternConverter converter = MarkerSimpleNamePatternConverter.newInstance(null);
converter.format(event, sb);
assertEquals(auditMarker.getName(), sb.toString());
}
}
代码示例来源:origin: org.apache.logging.log4j/log4j-api
@Test
public void testTraceEntryExit() {
currentLevel = Level.TRACE;
final FlowMessageFactory fact = new DefaultFlowMessageFactory();
final ParameterizedMessage paramMsg = new ParameterizedMessage("Tracy {}", "Logan");
currentEvent = new LogEvent(ENTRY_MARKER.getName(), fact.newEntryMessage(paramMsg), null);
final EntryMessage entry = traceEntry("Tracy {}", "Logan");
final ReusableParameterizedMessage msg = ReusableParameterizedMessageTest.set(
new ReusableParameterizedMessage(), "Tracy {}", "Logan");
ReusableParameterizedMessageTest.set(msg, "Some other message {}", 123);
currentEvent = new LogEvent(null, msg, null);
trace("Some other message {}", 123);
// ensure original entry message not overwritten
assertEquals("Tracy Logan", entry.getMessage().getFormattedMessage());
currentEvent = new LogEvent(EXIT_MARKER.getName(), fact.newExitMessage(entry), null);
traceExit(entry);
// ensure original entry message not overwritten
assertEquals("Tracy Logan", entry.getMessage().getFormattedMessage());
}
代码示例来源:origin: org.apache.logging.log4j/log4j-api
@Test
public void testTraceEntryMessage() {
currentLevel = Level.TRACE;
final FlowMessageFactory fact = new DefaultFlowMessageFactory();
final ParameterizedMessage paramMsg = new ParameterizedMessage("Tracy {}", "Logan");
currentEvent = new LogEvent(ENTRY_MARKER.getName(), fact.newEntryMessage(paramMsg), null);
final ReusableParameterizedMessage msg = ReusableParameterizedMessageTest.set(
new ReusableParameterizedMessage(), "Tracy {}", "Logan");
final EntryMessage entry = traceEntry(msg);
ReusableParameterizedMessageTest.set(msg, "Some other message {}", 123);
currentEvent = new LogEvent(null, msg, null);
trace("Some other message {}", 123);
// ensure original entry message not overwritten
assertEquals("Tracy Logan", entry.getMessage().getFormattedMessage());
currentEvent = new LogEvent(EXIT_MARKER.getName(), fact.newExitMessage(entry), null);
traceExit(entry);
// ensure original entry message not overwritten
assertEquals("Tracy Logan", entry.getMessage().getFormattedMessage());
}
}
代码示例来源:origin: org.apache.logging.log4j/log4j-slf4j18-impl
@Override
public Iterator<Marker> iterator() {
final org.apache.logging.log4j.Marker[] log4jParents = this.marker.getParents();
final List<Marker> parents = new ArrayList<>(log4jParents.length);
for (final org.apache.logging.log4j.Marker m : log4jParents) {
parents.add(factory.getMarker(m.getName()));
}
return parents.iterator();
}
内容来源于网络,如有侵权,请联系作者删除!