loggerContext = new LoggerContext(); loggerContext.setName(contextName); synchronizedContextMap.put(contextName, loggerContext);
public Logger buildTaskLogger(String taskId, String executorId, String executorPid, String taskLogFile) { LOG.info("Building a task logger for {} pointing to {}", taskId, taskLogFile); LoggerContext context = new LoggerContext(); context.setName(executorPid); baseLogging.prepareRootLogger(context); String loggerId = taskId; try { SingularityTaskId singularityTaskId = SingularityTaskId.valueOf(taskId); loggerId = String.format("%s.%s.%s.%s.%s", singularityTaskId.getRequestId(), singularityTaskId.getDeployId(), singularityTaskId.getStartedAt(), singularityTaskId.getInstanceNo(), executorId); } catch (InvalidSingularityTaskIdException e) { LOG.info("Handling non-SingularityTaskId %s", taskId); } Logger taskLogger = context.getLogger(loggerId); taskLogger.detachAndStopAllAppenders(); if (baseLogging.getRootLogPath().isPresent()) { taskLogger.addAppender(baseLogging.buildFileAppender(context, baseLogging.getRootLogPath().get())); } taskLogger.addAppender(baseLogging.buildFileAppender(context, taskLogFile)); context.start(); return taskLogger; }
loggerContext = new LoggerContext(); loggerContext.setName(contextName); synchronizedContextMap.put(contextName, loggerContext);
@Override public LoggerContext get() { LoggerContext context = new LoggerContext(); context.putObject(Constants.Logging.PIPELINE_VALIDATION, Boolean.TRUE); return context; } };
// Create a separate context for the plugin LoggerContext pluginContext = new LoggerContext("PluginContext"); // Setup pluginContext... // BasicContextSelector uses ContextAnchor.THREAD_CONTEXT // to bind contexts to threads: ContextAnchor.THREAD_CONTEXT.set(pluginContext); // Your plugin works and has access to your logging context LogManager.getContext(false); // Returns pluginContext // Stop and remove the plugin's logging context pluginContext.stop(); ContextAnchor.THREAD_CONTEXT.set(null);
@Nonnull protected LoggerContext createContextFor(@Nonnull LogbackBasedLoggingEnvironmentConfiguration requirement) { final LoggerContext context = new LoggerContext(); configure(context, requirement); return context; }
@Override public LoggerContext get() { LoggerContext context = new LoggerContext(); context.putObject(Constants.Logging.PIPELINE_VALIDATION, Boolean.TRUE); return context; } };
/** * Creates a context with a status listener */ @BeforeClass static public void beforeClass() { context = new LoggerContext(); }
@Before public void setUp() throws Exception { lc = new LoggerContext(); lc.setName("testContext"); logger = lc.getLogger(LoggerSerializationTest.class); // create the byte output stream bos = new ByteArrayOutputStream(); oos = new ObjectOutputStream(bos); whitelist.add(Foo.class.getName()); }
@Before public void setUp() throws Exception { lc = new LoggerContext(); lc.setName("x"); }
@Before public void setUp() throws Exception { context = new LoggerContext(); context.setName("test"); context.start(); logger = context.getLogger(TurboFilteringInLoggerTest.class); }
private List<String> sort(String pattern, String[] filenames) { FileNamePattern fileNamePattern = new FileNamePattern(pattern, new LoggerContext()); FileSorter sorter = new FileSorter(new DateParser(fileNamePattern), new IntParser(fileNamePattern)); sorter.sort(filenames); return Arrays.asList(filenames); } }
/** * Starts the HTTP test server, initializes the appender, * and creates a context with a status listener * @throws IOException */ @BeforeClass static public void beforeClass() throws IOException { httpServer = new HttpTestServer(PORT); httpServer.start(); context = new LoggerContext(); }
@Before public void setUp() throws Exception { lc = new LoggerContext(); converter = new MarkerConverter(); converter.start(); }
@Before public void setUp() throws Exception { lc = new LoggerContext(); converter = new MDCConverter(); converter.start(); MDC.clear(); }
@Test(timeout = 1000) public void concurrentReset() throws InterruptedException { LoggerContext loggerContext = new LoggerContext(); CyclicBarrier cyclicBarrier = new CyclicBarrier(CONCURRENT_RESET_THREAD_COUNT); StatusChecker statusChecker = new StatusChecker(loggerContext); int desiredResetCount = 100; RunnableWithCounterAndDone[] runnableArray = buildRunnableArray(loggerContext, cyclicBarrier); Harness harness = new Harness((Resetter) runnableArray[0], desiredResetCount); harness.execute(runnableArray); statusChecker.assertIsErrorFree(); }
@Before public void setUp() throws Exception { lc = new LoggerContext(); lc.setName("default"); layout = new XMLLayout(); layout.setLocationInfo(true); layout.setContext(lc); layout.setProperties(true); layout.setLocationInfo(true); layout.start(); root = lc.getLogger(Logger.ROOT_LOGGER_NAME); }
@Before public void setUp() throws Exception { lc = new LoggerContext(); lc.setName("default"); layout = new HTMLLayout(); layout.setThrowableRenderer(new DefaultThrowableRenderer()); layout.setContext(lc); layout.setPattern("%level%thread%msg"); layout.start(); root = lc.getLogger(Logger.ROOT_LOGGER_NAME); }
@Test public void contextNameConverter() { ClassicConverter converter = new ContextNameConverter(); // see http://jira.qos.ch/browse/LBCLASSIC-149 LoggerContext lcOther = new LoggerContext(); lcOther.setName("another"); converter.setContext(lcOther); lc.setName("aValue"); ILoggingEvent event = makeLoggingEvent(null); String result = converter.convert(event); assertEquals("aValue", result); }
public static void main(String args[]) throws InterruptedException { ThreadedThroughputCalculator tp = new ThreadedThroughputCalculator( OVERALL_DURATION_IN_MILLIS); tp.printEnvironmentInfo("lbclassic135 LoggingToFileThrouhput"); LoggerContext lc = new LoggerContext(); Logger logger = buildLoggerContext(lc); for (int i = 0; i < 2; i++) { tp.execute(buildArray(logger)); } tp.execute(buildArray(logger)); tp.printThroughput("File: "); lc.stop(); }