use of org.apache.logging.log4j.util.SortedArrayStringMap in project logging-log4j2 by apache.
the class SortedArrayVsHashMapBenchmark method setup.
@Setup
public void setup() {
openHashMapContextData = new OpenHashStringMap<>();
sortedStringArrayMap = new SortedArrayStringMap();
map = new HashMap<>();
keys = new String[count];
final Random r = new Random();
for (int j = 0; j < keys.length; j++) {
final char[] str = new char[length];
for (int i = 0; i < str.length; i++) {
str[i] = (char) r.nextInt();
}
keys[j] = new String(str);
}
populatedMap = new HashMap<>();
for (int i = 0; i < count; i++) {
populatedMap.put(keys[i], value);
}
populatedSortedStringArrayMap = new SortedArrayStringMap();
for (int i = 0; i < count; i++) {
populatedSortedStringArrayMap.putValue(keys[i], value);
}
populatedOpenHashContextData = new OpenHashStringMap<>();
for (int i = 0; i < count; i++) {
populatedOpenHashContextData.putValue(keys[i], value);
}
}
use of org.apache.logging.log4j.util.SortedArrayStringMap in project logging-log4j2 by apache.
the class ThreadContextBenchmark method setup.
@Setup
public void setup() {
System.setProperty("log4j2.threadContextMap", IMPLEMENTATIONS.get(threadContextMapAlias).getName());
ThreadContextBenchmarkAccess.init();
injector = ContextDataInjectorFactory.createInjector();
System.out.println(threadContextMapAlias + ": Injector = " + injector);
reusableContextData = threadContextMapAlias.contains("Array") ? new SortedArrayStringMap() : new OpenHashStringMap<>();
keys = new String[count];
values = new String[count];
final Random r = new Random();
for (int j = 0; j < keys.length; j++) {
final char[] str = new char[KEY_LENGTH];
for (int i = 0; i < str.length; i++) {
str[i] = (char) r.nextInt();
}
keys[j] = new String(str);
values[j] = new String(str);
}
// count
final int PROPERTIES_COUNT = 5;
propertyList = new ArrayList<>(PROPERTIES_COUNT);
for (int j = 0; j < PROPERTIES_COUNT; j++) {
final char[] str = new char[KEY_LENGTH];
for (int i = 0; i < str.length; i++) {
str[i] = (char) r.nextInt();
}
propertyList.add(Property.createProperty(new String(str), new String(str)));
}
// ensure ThreadContext contains values
clearAndPut();
}
use of org.apache.logging.log4j.util.SortedArrayStringMap in project cas by apereo.
the class LoggingUtils method prepareLogEvent.
/**
* Prepare log event log event.
*
* @param logEvent the log event
* @return the log event
*/
public static LogEvent prepareLogEvent(final LogEvent logEvent) {
final String messageModified = TicketIdSanitizationUtils.sanitize(logEvent.getMessage().getFormattedMessage());
final Message message = new SimpleMessage(messageModified);
final LogEvent newLogEvent = Log4jLogEvent.newBuilder().setLevel(logEvent.getLevel()).setLoggerName(logEvent.getLoggerName()).setLoggerFqcn(logEvent.getLoggerFqcn()).setContextData(new SortedArrayStringMap(logEvent.getContextData())).setContextStack(logEvent.getContextStack()).setEndOfBatch(logEvent.isEndOfBatch()).setIncludeLocation(logEvent.isIncludeLocation()).setMarker(logEvent.getMarker()).setMessage(message).setNanoTime(logEvent.getNanoTime()).setSource(logEvent.getSource()).setThreadName(logEvent.getThreadName()).setThrownProxy(logEvent.getThrownProxy()).setThrown(logEvent.getThrown()).setTimeMillis(logEvent.getTimeMillis()).build();
return newLogEvent;
}
Aggregations