当前位置: 首页>>代码示例>>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;未经允许,请勿转载。