Java Code Examples for ch.qos.logback.classic.LoggerContext#setName()
The following examples show how to use
ch.qos.logback.classic.LoggerContext#setName() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Red5LoggerFactory.java From red5-server-common with Apache License 2.0 | 6 votes |
public static ContextSelector getContextSelector() { if (useLogback) { ContextSelectorStaticBinder contextSelectorBinder = ContextSelectorStaticBinder.getSingleton(); ContextSelector selector = contextSelectorBinder.getContextSelector(); if (selector == null) { if (DEBUG) { System.err.println("Context selector was null, creating default context"); } LoggerContext defaultLoggerContext = new LoggerContext(); defaultLoggerContext.setName(CoreConstants.DEFAULT_CONTEXT_NAME); try { contextSelectorBinder.init(defaultLoggerContext, null); selector = contextSelectorBinder.getContextSelector(); } catch (Exception e) { e.printStackTrace(); } } //System.out.printf("Context selector: %s%n", selector.getClass().getName()); return selector; } return null; }
Example 2
Source File: MapAppenderUnitTest.java From tutorials with MIT License | 5 votes |
@Before public void setUp() throws Exception { ctx = new LoggerContext(); ctx.setName("test context"); ctx.setStatusManager(new BasicStatusManager()); mapAppender.setContext(ctx); mapAppender.setPrefix("prefix"); event = new LoggingEvent("fqcn", ctx.getLogger("logger"), Level.INFO, "Test message for logback appender", null, new Object[0]); ctx.start(); }
Example 3
Source File: SingularityExecutorLogging.java From Singularity with Apache License 2.0 | 4 votes |
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; }