• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java AWSLogs类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.amazonaws.services.logs.AWSLogs的典型用法代码示例。如果您正苦于以下问题:Java AWSLogs类的具体用法?Java AWSLogs怎么用?Java AWSLogs使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



AWSLogs类属于com.amazonaws.services.logs包,在下文中一共展示了AWSLogs类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: fetchCloudWatchLogs

import com.amazonaws.services.logs.AWSLogs; //导入依赖的package包/类
private void fetchCloudWatchLogs(String logStreamName, PrintStream logger) {
    if(logStreamName == null || "".equals(logStreamName)) return;

    logger.println("Fetching logs from cloudwatch logs for final attempt...");
    logger.println("-------------------------------------------------------");

    AWSLogs awslogs = AWSLogsClientBuilder.defaultClient();

    GetLogEventsResult logEventsResult =  awslogs.getLogEvents(
            new GetLogEventsRequest()
                    .withLogGroupName("/aws/batch/job")
                    .withLogStreamName(logStreamName)
    );

    for(OutputLogEvent ole : logEventsResult.getEvents()) {
        logger.printf("[%s] %s%n", df.format(new Date(ole.getTimestamp())), ole.getMessage());
    }

}
 
开发者ID:nfultz,项目名称:aws-batch,代码行数:20,代码来源:BatchLogRetriever.java


示例2: testGettersSetters

import com.amazonaws.services.logs.AWSLogs; //导入依赖的package包/类
@Test
public void testGettersSetters() {
    @SuppressWarnings("unchecked")
    final Layout<ILoggingEvent> layout = mock(Layout.class);
    final AWSLogs awsLogs = mock(AWSLogs.class);
    final String logGroupName = "myGroup";
    final String logStreamName = "myStream";

    final CloudWatchAppender appender = new CloudWatchAppender();
    appender.setLayout(layout);
    appender.setAwsLogs(awsLogs);
    appender.setLogGroupName(logGroupName);
    appender.setLogStreamName(logStreamName);

    assertEquals(layout, appender.getLayout());
    assertEquals(awsLogs, appender.getAwsLogs());
    assertEquals(logGroupName, appender.getLogGroupName());
    assertEquals(logStreamName, appender.getLogStreamName());
}
 
开发者ID:minijax,项目名称:minijax,代码行数:20,代码来源:CloudWatchAppenderTest.java


示例3: testDefaultValues

import com.amazonaws.services.logs.AWSLogs; //导入依赖的package包/类
@Test
public void testDefaultValues() {
    final Context mockContext = mock(Context.class);

    final PutLogEventsResult mockResult = mock(PutLogEventsResult.class);
    when(mockResult.getNextSequenceToken()).thenReturn("2");

    final AWSLogs mockAwsLogs = mock(AWSLogs.class);
    when(mockAwsLogs.putLogEvents(any())).thenReturn(mockResult);

    final CloudWatchAppender appender = new CloudWatchAppender();
    appender.setContext(mockContext);
    appender.setAwsLogs(mockAwsLogs);
    appender.start();
    appender.doAppend(new LoggingEvent());
    appender.stop();
}
 
开发者ID:minijax,项目名称:minijax,代码行数:18,代码来源:CloudWatchAppenderTest.java


示例4: testAlreadyExists

import com.amazonaws.services.logs.AWSLogs; //导入依赖的package包/类
@Test
public void testAlreadyExists() {
    final Context mockContext = mock(Context.class);

    final PutLogEventsResult mockResult = mock(PutLogEventsResult.class);
    when(mockResult.getNextSequenceToken()).thenReturn("2");

    final AWSLogs mockAwsLogs = mock(AWSLogs.class);
    when(mockAwsLogs.createLogGroup(any())).thenThrow(ResourceAlreadyExistsException.class);
    when(mockAwsLogs.createLogStream(any())).thenThrow(ResourceAlreadyExistsException.class);
    when(mockAwsLogs.putLogEvents(any())).thenReturn(mockResult);

    final CloudWatchAppender appender = new CloudWatchAppender();
    appender.setContext(mockContext);
    appender.setAwsLogs(mockAwsLogs);
    appender.start();
    appender.doAppend(new LoggingEvent());
    appender.stop();
}
 
开发者ID:minijax,项目名称:minijax,代码行数:20,代码来源:CloudWatchAppenderTest.java


示例5: CloudwatchLogsLogEventPutter

import com.amazonaws.services.logs.AWSLogs; //导入依赖的package包/类
/**
 * For internal use only. This constructor lets us switch the AWSLogs implementation for testing.
 */
public CloudwatchLogsLogEventPutter(CloudwatchLogsConfig config, BlockingQueue<CloudwatchLogsLogEvent> eventQueue,
                                    AWSLogs awsLogs, boolean enabled) {
    this.config = config;
    logGroupName = config.getLogGroup();
    String image = config.getImage();
    app = image.substring(0, image.indexOf(":"));
    this.eventQueue = eventQueue;
    this.enabled = enabled;
    logsClient = awsLogs;
}
 
开发者ID:boxfuse,项目名称:cloudwatchlogs-java-appender,代码行数:14,代码来源:CloudwatchLogsLogEventPutter.java


示例6: createLogsClient

import com.amazonaws.services.logs.AWSLogs; //导入依赖的package包/类
static AWSLogs createLogsClient(CloudwatchLogsConfig config) {
    AWSLogsClientBuilder builder = AWSLogsClientBuilder.standard();
    if (config.getEndpoint() != null) {
        // Non-AWS mock endpoint
        builder.setCredentials(new AWSStaticCredentialsProvider(new AnonymousAWSCredentials()));
        builder.setEndpointConfiguration(new AwsClientBuilder.EndpointConfiguration(config.getEndpoint(), config.getRegion()));
    } else {
        builder.setRegion(config.getRegion());
    }
    return builder.build();
}
 
开发者ID:boxfuse,项目名称:cloudwatchlogs-java-appender,代码行数:12,代码来源:CloudwatchLogsLogEventPutter.java


示例7: AWSLogsStub

import com.amazonaws.services.logs.AWSLogs; //导入依赖的package包/类
AWSLogsStub(String logGroupName, String logStreamName, String logRegion) {

        this.logGroupName = logGroupName;
        this.logStreamName = logStreamName;

        AWSLogs awsLogs = new AWSLogsClient();
        if (logRegion != null) {
            awsLogs.setRegion(RegionUtils.getRegion(logRegion));
        }
        this.awsLogs = awsLogs;
    }
 
开发者ID:pierredavidbelanger,项目名称:logback-awslogs-appender,代码行数:12,代码来源:AWSLogsStub.java


示例8: main

import com.amazonaws.services.logs.AWSLogs; //导入依赖的package包/类
public static void main(String[] args) {
  AWSLogs client = AWSLogsClientBuilder.standard().withRegion("eu-west-1").build();

  // Harvest all the log groups in this region
  DescribeLogGroupsRequest describeLogGroupsRequest = new DescribeLogGroupsRequest();
  DescribeLogGroupsResult describeLogGroupsResult = client
      .describeLogGroups(describeLogGroupsRequest);
  List<LogGroup> logGroups = describeLogGroupsResult.getLogGroups();
  String token = describeLogGroupsResult.getNextToken();
  int index = 0;
  while (token != null) {
    index++;
    describeLogGroupsRequest.setNextToken(token);
    describeLogGroupsResult = client.describeLogGroups(describeLogGroupsRequest);
    logGroups.addAll(describeLogGroupsResult.getLogGroups());
    token = describeLogGroupsResult.getNextToken();
    System.out.println(index);
    System.out.println(token);
  }

  // Delete each log group
  logGroups.stream().forEach(
      (logGroup) -> {
        DeleteLogGroupRequest deleteLogGroupRequest = new DeleteLogGroupRequest(logGroup
            .getLogGroupName());
        try {
          RetryHelper.DoWithRetries(() -> client.deleteLogGroup(deleteLogGroupRequest),
              AmazonServiceException.class, Optional.of("429"), (logString) -> {
              });
        } catch (Exception e) {
          e.printStackTrace();
        }
      });
}
 
开发者ID:robinsteel,项目名称:Sqawsh,代码行数:35,代码来源:LogGroupDeleter.java


示例9: main

import com.amazonaws.services.logs.AWSLogs; //导入依赖的package包/类
public static void main(String[] args) {

        final String USAGE =
            "To run this example, supply:\n" +
            "* a filter name\n" +
            "* filter pattern\n" +
            "* log group name\n" +
            "* lambda function arn\n\n" +
            "Ex: PutSubscriptionFilter <filter-name> \\\n" +
            "                          <filter pattern> \\\n" +
            "                          <log-group-name> \\\n" +
            "                          <lambda-function-arn>\n";

        if (args.length != 4) {
            System.out.println(USAGE);
            System.exit(1);
        }

        String filter = args[0];
        String pattern = args[1];
        String log_group = args[2];
        String function_arn = args[3];

        final AWSLogs cwl = AWSLogsClientBuilder.defaultClient();

        PutSubscriptionFilterRequest request =
            new PutSubscriptionFilterRequest()
                .withFilterName(filter)
                .withFilterPattern(pattern)
                .withLogGroupName(log_group)
                .withDestinationArn(function_arn);

        PutSubscriptionFilterResult response =
            cwl.putSubscriptionFilter(request);

        System.out.printf(
            "Successfully created CloudWatch logs subscription filter %s",
            filter);
    }
 
开发者ID:awsdocs,项目名称:aws-doc-sdk-examples,代码行数:40,代码来源:PutSubscriptionFilter.java


示例10: main

import com.amazonaws.services.logs.AWSLogs; //导入依赖的package包/类
public static void main(String[] args) {

        final String USAGE =
            "To run this example, supply a filter name and log group name\n" +
            "Ex: DeleteSubscriptionFilter <filter-name> <log-group-name>\n";

        if (args.length != 2) {
            System.out.println(USAGE);
            System.exit(1);
        }

        String filter = args[0];
        String log_group = args[1];

        final AWSLogs logs = AWSLogsClientBuilder.defaultClient();

        DeleteSubscriptionFilterRequest request =
            new DeleteSubscriptionFilterRequest()
                .withFilterName(filter)
                .withLogGroupName(log_group);

        DeleteSubscriptionFilterResult response =
            logs.deleteSubscriptionFilter(request);

        System.out.printf(
            "Successfully deleted CloudWatch logs subscription filter %s",
            filter);
    }
 
开发者ID:awsdocs,项目名称:aws-doc-sdk-examples,代码行数:29,代码来源:DeleteSubscriptionFilter.java


示例11: createMockClient

import com.amazonaws.services.logs.AWSLogs; //导入依赖的package包/类
public static AWSLogs createMockClient()
{
    staticFactoryMock = new MockCloudWatchClient();
    return staticFactoryMock.createClient();
}
 
开发者ID:kdgregory,项目名称:log4j-aws-appenders,代码行数:6,代码来源:TestCloudWatchAppender.java


示例12: createClient

import com.amazonaws.services.logs.AWSLogs; //导入依赖的package包/类
/**
 *  Creates the client proxy. This is used internally, and also by the test
 *  for calling a static factory method.
 */
public AWSLogs createClient()
{
    return (AWSLogs)Proxy.newProxyInstance(
                        getClass().getClassLoader(),
                        new Class<?>[] { AWSLogs.class },
                        MockCloudWatchClient.this);
}
 
开发者ID:kdgregory,项目名称:log4j-aws-appenders,代码行数:12,代码来源:MockCloudWatchClient.java


示例13: createClient

import com.amazonaws.services.logs.AWSLogs; //导入依赖的package包/类
/**
 *  This function is used as a client factory by the smoketest.
 */
public static AWSLogs createClient()
{
    return AWSLogsClientBuilder.defaultClient();
}
 
开发者ID:kdgregory,项目名称:log4j-aws-appenders,代码行数:8,代码来源:CloudWatchAppenderIntegrationTest.java


示例14: getAwsLogs

import com.amazonaws.services.logs.AWSLogs; //导入依赖的package包/类
public AWSLogs getAwsLogs() {
    return awsLogs;
}
 
开发者ID:minijax,项目名称:minijax,代码行数:4,代码来源:CloudWatchAppender.java


示例15: setAwsLogs

import com.amazonaws.services.logs.AWSLogs; //导入依赖的package包/类
public void setAwsLogs(final AWSLogs awsLogs) {
    this.awsLogs = awsLogs;
}
 
开发者ID:minijax,项目名称:minijax,代码行数:4,代码来源:CloudWatchAppender.java


示例16: concurrencyAndThroughput

import com.amazonaws.services.logs.AWSLogs; //导入依赖的package包/类
@Test(timeout = 15000)
public void concurrencyAndThroughput() throws InterruptedException {
    final AWSLogs awsLogs = mock(AWSLogs.class);
    when(awsLogs.putLogEvents(any(PutLogEventsRequest.class))).thenReturn(new PutLogEventsResult());
    final CloudwatchLogsLogbackAppender appender = new CloudwatchLogsLogbackAppender() {
        @Override
        CloudwatchLogsLogEventPutter createCloudwatchLogsLogEventPutter() {
            return new CloudwatchLogsLogEventPutter(config, eventQueue, awsLogs, true);
        }
    };
    appender.setConfig(new CloudwatchLogsConfig());
    appender.start();

    ExecutorService executorService = Executors.newFixedThreadPool(NUM_THREADS);

    final LoggerContext loggerContext = new LoggerContext();

    for (int i = 0; i < NUM_THREADS; i++) {
        executorService.execute(new Runnable() {
            @Override
            public void run() {
                String fqcn = "class-" + UUID.randomUUID();
                Logger logger = loggerContext.getLogger(fqcn);
                for (int j = 0; j < EVENTS_PER_THREAD; j++) {
                    appender.append(new LoggingEvent(fqcn, logger, Level.DEBUG, "msg-" + j, null, null));
                }
            }
        });
    }

    executorService.shutdown();
    executorService.awaitTermination(1, TimeUnit.MINUTES);

    while (NUM_THREADS * EVENTS_PER_THREAD > appender.putter.getProcessedCount()) {
        Thread.sleep(100);
    }

    appender.stop();

    assertEquals(0, appender.getDiscardedCount());
    assertEquals(NUM_THREADS * EVENTS_PER_THREAD, appender.getProcessedCount());
    assertEquals(NUM_THREADS * EVENTS_PER_THREAD, appender.putter.getProcessedCount());
}
 
开发者ID:boxfuse,项目名称:cloudwatchlogs-java-appender,代码行数:44,代码来源:CloudwatchLogsLogbackAppenderMediumTest.java


示例17: getAWSLogsClient

import com.amazonaws.services.logs.AWSLogs; //导入依赖的package包/类
/**
 * Returns a CloudwatchLogs service client.
 * 
 * <p>This method is provided so unit tests can mock out CloudwatchLogs.
 */
public AWSLogs getAWSLogsClient(String region) {
  // Use a getter here so unit tests can substitute a mock client
  AWSLogs client = AWSLogsClientBuilder.standard().withRegion(region).build();
  return client;
}
 
开发者ID:robinsteel,项目名称:Sqawsh,代码行数:11,代码来源:LogGroupsCustomResourceLambda.java


示例18: main

import com.amazonaws.services.logs.AWSLogs; //导入依赖的package包/类
public static void main(String[] args) {

        final String USAGE =
            "To run this example, supply a log group name\n" +
            "Ex: DescribeSubscriptionFilters <log-group-name>\n";

        if (args.length != 1) {
            System.out.println(USAGE);
            System.exit(1);
        }

        String log_group = args[0];

        final AWSLogs logs = AWSLogsClientBuilder.defaultClient();
        boolean done = false;

        DescribeSubscriptionFiltersRequest request =
                new DescribeSubscriptionFiltersRequest()
                    .withLogGroupName(log_group)
                    .withLimit(1);
        
        while(!done) {

            DescribeSubscriptionFiltersResult response =
                logs.describeSubscriptionFilters(request);

            for(SubscriptionFilter filter : response.getSubscriptionFilters()) {
                System.out.printf(
                    "Retrieved filter with name %s, " +
                    "pattern %s " +
                    "and destination arn %s",
                    filter.getFilterName(),
                    filter.getFilterPattern(),
                    filter.getDestinationArn());
            }

            request.setNextToken(response.getNextToken());

            if(response.getNextToken() == null) {
                done = true;
            }
        }
    }
 
开发者ID:awsdocs,项目名称:aws-doc-sdk-examples,代码行数:44,代码来源:DescribeSubscriptionFilters.java


示例19: createAWSClient

import com.amazonaws.services.logs.AWSLogs; //导入依赖的package包/类
@Override
protected void createAWSClient()
{
    client = tryClientFactory(clientFactoryMethod, AWSLogs.class, true);
    if ((client == null) && (clientEndpoint == null))
    {
        client = tryClientFactory("com.amazonaws.services.logs.AWSLogsClientBuilder.defaultClient", AWSLogs.class, false);
    }
    if (client == null)
    {
        LogLog.debug(getClass().getSimpleName() + ": creating service client via constructor");
        client = tryConfigureEndpointOrRegion(new AWSLogsClient(), clientEndpoint);
    }
}
 
开发者ID:kdgregory,项目名称:log4j-aws-appenders,代码行数:15,代码来源:CloudWatchLogWriter.java


示例20: create

import com.amazonaws.services.logs.AWSLogs; //导入依赖的package包/类
/**
 * Creates a new EventPutter for the current AWS region.
 *
 * @param config     The config to use.
 * @param eventQueue The event queue to consume from.
 * @return The new EventPutter.
 */
public static CloudwatchLogsLogEventPutter create(CloudwatchLogsConfig config, BlockingQueue<CloudwatchLogsLogEvent> eventQueue) {
    boolean enabled = config.getRegion() != null || config.getEndpoint() != null;
    AWSLogs logsClient = enabled ? createLogsClient(config) : null;
    return new CloudwatchLogsLogEventPutter(config, eventQueue, logsClient, enabled);
}
 
开发者ID:boxfuse,项目名称:cloudwatchlogs-java-appender,代码行数:13,代码来源:CloudwatchLogsLogEventPutter.java



注:本文中的com.amazonaws.services.logs.AWSLogs类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java DefaultSchemaManager类代码示例发布时间:2022-05-22
下一篇:
Java GeoEventDefinitionManagerException类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap