@Test public void testIncludeLocationDefaultsToFalse() { final LoggerConfig rootLoggerConfig = AsyncLoggerConfig.RootLogger.createLogger( null, "INFO", null, new AppenderRef[0], null, new DefaultConfiguration(), null); assertFalse("Include location should default to false for async logggers", rootLoggerConfig.isIncludeLocation()); final LoggerConfig loggerConfig = AsyncLoggerConfig.createLogger( null, "INFO", "com.foo.Bar", null, new AppenderRef[0], null, new DefaultConfiguration(), null); assertFalse("Include location should default to false for async logggers", loggerConfig.isIncludeLocation()); } }
final LoggerConfig rootLoggerConfig = loggers.get(""); assertEquals(Level.ERROR, rootLoggerConfig.getLevel()); assertFalse(rootLoggerConfig.isIncludeLocation()); final LoggerConfig loggerConfig = loggers.get("org.apache.logging.log4j"); assertEquals(Level.DEBUG, loggerConfig.getLevel()); assertTrue(loggerConfig.isIncludeLocation()); final Filter filter = config.getFilter(); assertNotNull("No Filter", filter);
@Override public boolean isIncludeLocation() { return loggerConfig.isIncludeLocation(); }
/** * Constructs an {@code AsyncLogger} with the specified context, name and message factory. * * @param context context of this logger * @param name name of this logger * @param messageFactory message factory of this logger * @param loggerDisruptor helper class that logging can be delegated to. This object owns the Disruptor. */ public AsyncLogger(final LoggerContext context, final String name, final MessageFactory messageFactory, final AsyncLoggerDisruptor loggerDisruptor) { super(context, name, messageFactory); this.loggerDisruptor = loggerDisruptor; includeLocation = privateConfig.loggerConfig.isIncludeLocation(); nanoClock = context.getConfiguration().getNanoClock(); }
@Override protected void updateConfiguration(final Configuration newConfig) { nanoClock = newConfig.getNanoClock(); includeLocation = newConfig.getLoggerConfig(name).isIncludeLocation(); super.updateConfiguration(newConfig); }
private void processLogEvent(final LogEvent event) { event.setIncludeLocation(isIncludeLocation()); callAppenders(event); logParent(event); }
public static LoggerConfig getOrCreateLoggerConfig(String name) { LoggerContext context = (LoggerContext)LogManager.getContext(false); Configuration config = context.getConfiguration(); LoggerConfig logConfig = config.getLoggerConfig(name); boolean update = false; if (!logConfig.getName().equals(name)) { List<AppenderRef> appenderRefs = logConfig.getAppenderRefs(); Map<Property, Boolean> properties = logConfig.getProperties(); Set<Property> props = properties == null ? null : properties.keySet(); logConfig = LoggerConfig.createLogger( String.valueOf(logConfig.isAdditive()), logConfig.getLevel(), name, String.valueOf(logConfig.isIncludeLocation()), appenderRefs == null ? null : appenderRefs.toArray(new AppenderRef[appenderRefs.size()]), props == null ? null : props.toArray(new Property[props.size()]), config, null); config.addLogger(name, logConfig); update = true; } if (update) { context.updateLoggers(); } return logConfig; }
logConfig.getLevel(), name, String.valueOf(logConfig.isIncludeLocation()), appenderRefs == null ? null : appenderRefs.toArray(new AppenderRef[appenderRefs.size()]), props == null ? null : props.toArray(new Property[props.size()]),