當前位置: 首頁>>代碼示例>>Java>>正文


Java LoggerContext.getLogger方法代碼示例

本文整理匯總了Java中ch.qos.logback.classic.LoggerContext.getLogger方法的典型用法代碼示例。如果您正苦於以下問題:Java LoggerContext.getLogger方法的具體用法?Java LoggerContext.getLogger怎麽用?Java LoggerContext.getLogger使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在ch.qos.logback.classic.LoggerContext的用法示例。


在下文中一共展示了LoggerContext.getLogger方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: testUdpSender

import ch.qos.logback.classic.LoggerContext; //導入方法依賴的package包/類
@Test
public void testUdpSender() throws JoranException, InterruptedException {
  LoggerContext context = (LoggerContext) LoggerFactory.getILoggerFactory();
  JoranConfigurator configurator = new JoranConfigurator();
  configurator.setContext(context);
  context.reset();
  configurator.doConfigure(this.getClass().getClassLoader().getResourceAsStream("logback-syslog-udp.xml"));

  Logger logger = context.getLogger("test-udp");
  logger.info("test message over udp");

  context.stop();
  Thread.sleep(100);

  final String serverData = serverStream.toString();
  assertTrue("Server received: " + serverData, serverData.contains("test message over udp"));
}
 
開發者ID:serioussam,項目名稱:syslogappender,代碼行數:18,代碼來源:SyslogAppenderTest.java

示例2: testTcpSender

import ch.qos.logback.classic.LoggerContext; //導入方法依賴的package包/類
@Test
public void testTcpSender() throws JoranException, InterruptedException {
  LoggerContext context = (LoggerContext) LoggerFactory.getILoggerFactory();
  JoranConfigurator configurator = new JoranConfigurator();
  configurator.setContext(context);
  context.reset();
  configurator.doConfigure(this.getClass().getClassLoader().getResourceAsStream("logback-syslog-tcp.xml"));

  Logger logger = context.getLogger("test-tcp");
  logger.info("test message over tcp");

  context.stop();
  Thread.sleep(100);

  final String serverData = serverStream.toString();
  assertTrue("Server received: " + serverData, serverData.contains("test message over tcp"));
}
 
開發者ID:serioussam,項目名稱:syslogappender,代碼行數:18,代碼來源:SyslogAppenderTest.java

示例3: testTlsSender

import ch.qos.logback.classic.LoggerContext; //導入方法依賴的package包/類
@Test
public void testTlsSender() throws JoranException, InterruptedException {
  LoggerContext context = (LoggerContext) LoggerFactory.getILoggerFactory();
  JoranConfigurator configurator = new JoranConfigurator();
  configurator.setContext(context);
  context.reset();
  configurator.doConfigure(this.getClass().getClassLoader().getResourceAsStream("logback-syslog-tls.xml"));

  Logger logger = context.getLogger("test-tls");
  logger.info("test message over tls");

  context.stop();
  Thread.sleep(100);

  final String serverData = serverStream.toString();
  assertTrue("Server received: " + serverData, serverData.contains("test message over tls"));
}
 
開發者ID:serioussam,項目名稱:syslogappender,代碼行數:18,代碼來源:SyslogAppenderTest.java

示例4: setUp

import ch.qos.logback.classic.LoggerContext; //導入方法依賴的package包/類
@Before
public void setUp() throws Exception {
  registry = RegistryService.getMetricRegistry();

  TagEncodedMetricName rootName = APPENDS_BASE_NAME;
  TagEncodedMetricName throwablesBaseName = THROWABLES_BASE_NAME;

  meters = new HashMap<>();
  meters.put("total", getMeter(rootName.submetric("total")));
  meters.put("trace", getMeter(rootName.withTags("level", "trace")));
  meters.put("debug", getMeter(rootName.withTags("level", "debug")));
  meters.put("info", getMeter(rootName.withTags("level", "info")));
  meters.put("warn", getMeter(rootName.withTags("level", "warn")));
  meters.put("error", getMeter(rootName.withTags("level", "error")));
  meters.put("throwCount", getMeter(throwablesBaseName.submetric("total")));
  meters.put("throw[RuntimeException]",
      getMeter(throwablesBaseName.withTags("class", RuntimeException.class.getName())
      ));

  LoggerContext context = new LoggerContext();

  logger = context.getLogger(LogbackInstrumentationTest.class);
  origLevel = logger.getLevel();
  logger.setLevel(Level.ALL);
}
 
開發者ID:ApptuitAI,項目名稱:JInsight,代碼行數:26,代碼來源:LogbackInstrumentationTest.java

示例5: configure

import ch.qos.logback.classic.LoggerContext; //導入方法依賴的package包/類
@Override
public void configure(final LoggerContext lc) {

    final ConsoleAppender<ILoggingEvent> ca = new ConsoleAppender<>();
    ca.setContext(lc);
    ca.setName("console");
    final LayoutWrappingEncoder<ILoggingEvent> encoder = new LayoutWrappingEncoder<>();
    encoder.setContext(lc);
    final TTLLLayout layout = new TTLLLayout();
    layout.setContext(lc);
    layout.start();
    encoder.setLayout(layout);
    ca.setEncoder(encoder);
    ca.start();
    final Logger rootLogger = lc.getLogger("ROOT");
    rootLogger.setLevel(Level.WARN);
    rootLogger.addAppender(ca);
}
 
開發者ID:trajano,項目名稱:app-ms,代碼行數:19,代碼來源:LogConfigurator.java

示例6: init

import ch.qos.logback.classic.LoggerContext; //導入方法依賴的package包/類
@Before
public void init()
{
    LoggerContext ctx = (LoggerContext) LoggerFactory.getILoggerFactory();

    ctx.reset();

    this.layoutProducer = new LayoutProducer();
    ConsoleAppender<ILoggingEvent> appender = new ConsoleAppender<>();
    appender.setLayout(layoutProducer);
    appender.setContext(ctx);
    appender.start();

    Logger basicLogger = ctx.getLogger(LogFmtTest.class);
    basicLogger.addAppender(appender);
    this.logger = LogFmt.from(basicLogger);

    ctx.start();
}
 
開發者ID:BatchLabs,項目名稱:escalog,代碼行數:20,代碼來源:LogFmtTest.java

示例7: init

import ch.qos.logback.classic.LoggerContext; //導入方法依賴的package包/類
@BeforeClass
@SuppressWarnings("unchecked")
public static void init() {
    loggerContext = (LoggerContext) LoggerFactory.getILoggerFactory();

    appender = new CdpAppender();
    appender.setContext(loggerContext);
    appender.start();
    appender.setName(CdpAppender.class.getName());

    Logger logger = loggerContext.getLogger("cdp4j.flow");
    logger.addAppender((Appender<ILoggingEvent>) appender);

    factory = new Launcher().launch();

    session = factory.create();

    session.enableConsoleLog();

    URL url = TestAll.class.getResource("/session-test.html");
    session.navigate(url.toString());
}
 
開發者ID:webfolderio,項目名稱:cdp4j,代碼行數:23,代碼來源:TestAll.java

示例8: configure

import ch.qos.logback.classic.LoggerContext; //導入方法依賴的package包/類
@Override
public void configure(LoggerContext lc) {
  addInfo("Setting up robot logging configuration.");

  ConsoleAppender<ILoggingEvent> ca = new ConsoleAppender<>();
  ca.setContext(lc);
  ca.setName("console");
  LayoutWrappingEncoder<ILoggingEvent> encoder = new LayoutWrappingEncoder<>();
  encoder.setContext(lc);

  PatternLayout layout = new PatternLayout();
  layout.setPattern("%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n");

  layout.setContext(lc);
  layout.start();
  encoder.setLayout(layout);

  ca.setEncoder(encoder);
  ca.start();

  Logger rootLogger = lc.getLogger(Logger.ROOT_LOGGER_NAME);
  rootLogger.addAppender(ca);
  rootLogger.setLevel(Level.DEBUG);
}
 
開發者ID:strykeforce,項目名稱:thirdcoast,代碼行數:25,代碼來源:LoggingConfigurator.java

示例9: configure

import ch.qos.logback.classic.LoggerContext; //導入方法依賴的package包/類
@Override
public void configure(LoggerContext loggerContext) {
    addInfo("Setting up default configuration.");

    NonMetricsConsoleAppender nonMetricsConsoleAppender = new NonMetricsConsoleAppender();
    nonMetricsConsoleAppender.setContext(loggerContext);
    nonMetricsConsoleAppender.setName("CONSOLE");
    nonMetricsConsoleAppender.start();

    MetricsConsoleAppender metricsConsoleAppender = new MetricsConsoleAppender();
    metricsConsoleAppender.setContext(loggerContext);
    metricsConsoleAppender.setName("METRICS");
    metricsConsoleAppender.start();

    Logger rootLogger = loggerContext.getLogger(Logger.ROOT_LOGGER_NAME);
    rootLogger.setLevel(Level.INFO);
    rootLogger.addAppender(nonMetricsConsoleAppender);
    rootLogger.addAppender(metricsConsoleAppender);
}
 
開發者ID:symphoniacloud,項目名稱:lambda-monitoring,代碼行數:20,代碼來源:DefaultMetricsLogbackConfigurator.java

示例10: doInitializer

import ch.qos.logback.classic.LoggerContext; //導入方法依賴的package包/類
/**
 * Initializer logback
 * 
 * @param file
 * @param level
 * @param maxHistory
 */
private void doInitializer(String file, String level, int maxHistory) {
	LoggerContext loggerContext = (LoggerContext) LoggerFactory.getILoggerFactory();
	Logger rootLogger = loggerContext.getLogger(Logger.ROOT_LOGGER_NAME);
	rootLogger.detachAndStopAllAppenders();

	// appender
	RollingFileAppender<ILoggingEvent> fileAppender = new RollingFileAppender<ILoggingEvent>();
	fileAppender.setContext(loggerContext);
	fileAppender.setName("application");
	fileAppender.setFile(file);
	fileAppender.setAppend(true);

	// policy
	TimeBasedRollingPolicy<ILoggingEvent> policy = new TimeBasedRollingPolicy<ILoggingEvent>();
	policy.setContext(loggerContext);
	policy.setMaxHistory(maxHistory);
	policy.setFileNamePattern(file + ".%d{yyyy-MM-dd}");
	policy.setParent(fileAppender);
	policy.start();
	fileAppender.setRollingPolicy(policy);

	// encoder
	PatternLayoutEncoder encoder = new PatternLayoutEncoder();
	encoder.setContext(loggerContext);
	encoder.setPattern("%date [%thread] %-5level %logger (%file:%line\\) - %msg%n");
	encoder.start();
	fileAppender.setEncoder(encoder);
	
	fileAppender.start();

	rootLogger.addAppender(fileAppender);
	rootLogger.setLevel(Level.toLevel(level));
	rootLogger.setAdditive(false);
}
 
開發者ID:dachengxi,項目名稱:EatDubbo,代碼行數:42,代碼來源:LogbackContainer.java

示例11: Graylog2Impl

import ch.qos.logback.classic.LoggerContext; //導入方法依賴的package包/類
@Inject
public Graylog2Impl(Configuration config) {
    String canonicalHostName;
    try {
        canonicalHostName = config.getString(
                "graylog2.appender.sourcehost",
                InetAddress.getLocalHost().getCanonicalHostName()
        );
    } catch (UnknownHostException e) {
        canonicalHostName = "unknown";
    }

    accessLogEnabled = config.getBoolean("graylog2.appender.access-log", false);

    final GelfConfiguration gelfConfiguration = getGelfConfiguration(config);

    GelfTransport transport = GelfTransports.create(gelfConfiguration);

    final LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();
    final Logger rootLogger = lc.getLogger(Logger.ROOT_LOGGER_NAME);

    gelfClientAppender = new GelfClientAppender(transport, canonicalHostName);

    gelfClientAppender.setContext(lc);

    gelfClientAppender.start();

    rootLogger.addAppender(gelfClientAppender);
}
 
開發者ID:tochkak,項目名稱:play-graylog2,代碼行數:30,代碼來源:Graylog2Component.java

示例12: getNewLogger

import ch.qos.logback.classic.LoggerContext; //導入方法依賴的package包/類
private Logger getNewLogger(String jobID,String fileLogLocation) {
	LoggerContext loggerContext = (LoggerContext) LoggerFactory.getILoggerFactory();

	FileAppender<ILoggingEvent> fileAppender = new FileAppender<>();
	fileAppender.setContext(loggerContext);
	fileAppender.setFile(fileLogLocation);
	
       /*SizeBasedTriggeringPolicy<ILoggingEvent> triggeringPolicy = new SizeBasedTriggeringPolicy<ILoggingEvent>();
       triggeringPolicy.setMaxFileSize("10MB");
       triggeringPolicy.start();*/

       PatternLayoutEncoder encoder = new PatternLayoutEncoder();
       encoder.setContext(loggerContext);
       encoder.setPattern("%msg%n");
       encoder.start();
       
       fileAppender.setEncoder(encoder);
       fileAppender.start();

       // attach the rolling file appender to the logger of your choice
       Logger logbackLogger = loggerContext.getLogger(jobID);
       ((ch.qos.logback.classic.Logger) logbackLogger).addAppender(fileAppender);
       
       executionTrackingLoggers.put(jobID, logbackLogger);
       
	return logbackLogger;
}
 
開發者ID:capitalone,項目名稱:Hydrograph,代碼行數:28,代碼來源:ExecutionTrackingLogger.java

示例13: MongoSender

import ch.qos.logback.classic.LoggerContext; //導入方法依賴的package包/類
public MongoSender(MongoCollection<Document> collection){
    this.collection=collection;
    lis=new LinkedList<Document>();
    semaphore = new Semaphore(1);
    LoggerContext loggerContext = (LoggerContext) LoggerFactory.getILoggerFactory();
    logger= loggerContext.getLogger("framework.MongoSender");
}
 
開發者ID:LithiumSR,項目名稱:media_information_service,代碼行數:8,代碼來源:MongoSender.java

示例14: connect

import ch.qos.logback.classic.LoggerContext; //導入方法依賴的package包/類
private static void connect(String URI){
    //Change MongoDB's logger settings
    LoggerContext loggerContext = (LoggerContext) LoggerFactory.getILoggerFactory();
    rootLogger = loggerContext.getLogger("org.mongodb.driver");
    rootLogger.setLevel(Level.INFO);

    //Setup Connection
    MongoClientURI connectionString = new MongoClientURI(URI);
    MongoClient mongoClient = new MongoClient(connectionString);
    MongoDatabase database = mongoClient.getDatabase("media_information_service_db");
    collection = database.getCollection("messages");

}
 
開發者ID:LithiumSR,項目名稱:media_information_service,代碼行數:14,代碼來源:MongoDBInterface.java

示例15: setup

import ch.qos.logback.classic.LoggerContext; //導入方法依賴的package包/類
public static void setup(AvaIre avaire) {
    if (isSetup) {
        throw new IllegalStateException("The metrics has already been setup!");
    }

    Metrics.avaire = avaire;

    final LoggerContext factory = (LoggerContext) LoggerFactory.getILoggerFactory();
    final ch.qos.logback.classic.Logger root = factory.getLogger(Logger.ROOT_LOGGER_NAME);
    final InstrumentedAppender prometheusAppender = new InstrumentedAppender();
    prometheusAppender.setContext(root.getLoggerContext());
    prometheusAppender.start();
    root.addAppender(prometheusAppender);

    // JVM (hotspot) metrics
    DefaultExports.initialize();
    Metrics.initializeEventMetrics();

    if (!avaire.getConfig().getBoolean("metrics.enabled", true)) {
        LOGGER.info("Metrics web API is disabled, skipping igniting Spark API");
        Metrics.isSetup = true;
        return;
    }

    PORT = avaire.getConfig().getInt("metrics.port", 1256);

    LOGGER.info("Igniting Spark API on port: " + PORT);

    Spark.port(PORT);

    Spark.before(new HttpFilter());
    Spark.exception(Exception.class, new SparkExceptionHandler());

    Spark.get("/metrics", new GetMetrics(MetricsHolder.METRICS));
    Spark.get("/stats", new GetStats(MetricsHolder.METRICS));

    Metrics.isSetup = true;
}
 
開發者ID:avaire,項目名稱:avaire,代碼行數:39,代碼來源:Metrics.java


注:本文中的ch.qos.logback.classic.LoggerContext.getLogger方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。