初始化
This commit is contained in:
@@ -0,0 +1,84 @@
|
||||
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
|
||||
<ProductVersion>8.0.30703</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{10584CC5-EB33-4B68-8DE9-085694DEFEC6}</ProjectGuid>
|
||||
<OutputType>Exe</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>LOGSDKSample</RootNamespace>
|
||||
<AssemblyName>LOGSDKSample</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
|
||||
<TargetFrameworkProfile>
|
||||
</TargetFrameworkProfile>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<StartupObject />
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="LOGSDK">
|
||||
<HintPath>..\bin\net40\Release\LOGSDK.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Program.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<EmbeddedResource Include="Properties\Resources.resx">
|
||||
<Generator>ResXFileCodeGenerator</Generator>
|
||||
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
||||
<SubType>Designer</SubType>
|
||||
</EmbeddedResource>
|
||||
<Compile Include="Properties\Resources.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>Resources.resx</DependentUpon>
|
||||
</Compile>
|
||||
<None Include="Properties\Settings.settings">
|
||||
<Generator>SettingsSingleFileGenerator</Generator>
|
||||
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
|
||||
</None>
|
||||
<Compile Include="Properties\Settings.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>Settings.settings</DependentUpon>
|
||||
<DesignTimeSharedInput>True</DesignTimeSharedInput>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Folder Include="Resources\" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
</Project>
|
||||
94
bin/aliyun-log-csharp-sdk-master/LOGSDKSample/Program.cs
Normal file
94
bin/aliyun-log-csharp-sdk-master/LOGSDKSample/Program.cs
Normal file
@@ -0,0 +1,94 @@
|
||||
using Aliyun.Api.LOG.Common.Utilities;
|
||||
using Aliyun.Api.LOG.Data;
|
||||
using Aliyun.Api.LOG.Request;
|
||||
using Aliyun.Api.LOG.Response;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
|
||||
namespace Aliyun.Api.LOG.sample
|
||||
{
|
||||
class LoghubSample
|
||||
{
|
||||
static void Main(string[] args)
|
||||
{
|
||||
// select you endpoint https://help.aliyun.com/document_detail/29008.html
|
||||
String endpoint = "your project region endpoint",
|
||||
accesskeyId = "your accesskey id",
|
||||
accessKey = "your access key",
|
||||
project = "",
|
||||
logstore = "";
|
||||
LogClient client = new LogClient(endpoint, accesskeyId, accessKey);
|
||||
//init http connection timeout
|
||||
client.ConnectionTimeout = client.ReadWriteTimeout = 10000;
|
||||
//list logstores
|
||||
foreach (String l in client.ListLogstores(new ListLogstoresRequest(project)).Logstores)
|
||||
{
|
||||
Console.WriteLine(l);
|
||||
}
|
||||
//put logs
|
||||
PutLogsRequest putLogsReqError = new PutLogsRequest();
|
||||
putLogsReqError.Project = project;
|
||||
putLogsReqError.Topic = "dotnet_topic";
|
||||
putLogsReqError.Logstore = logstore;
|
||||
putLogsReqError.LogItems = new List<LogItem>();
|
||||
for (int i = 1; i <= 10; ++i)
|
||||
{
|
||||
LogItem logItem = new LogItem();
|
||||
logItem.Time = DateUtils.TimeSpan();
|
||||
for (int k = 0; k < 10; ++k)
|
||||
logItem.PushBack("error_" + i.ToString(), "invalid operation");
|
||||
putLogsReqError.LogItems.Add(logItem);
|
||||
}
|
||||
PutLogsResponse putLogRespError = client.PutLogs(putLogsReqError);
|
||||
|
||||
Thread.Sleep(5000);
|
||||
|
||||
//query logs, if query string is "", it means query all data
|
||||
GetLogsRequest getLogReq = new GetLogsRequest(project,
|
||||
logstore,
|
||||
DateUtils.TimeSpan() - 100,
|
||||
DateUtils.TimeSpan(),
|
||||
"dotnet_topic",
|
||||
"",
|
||||
100,
|
||||
0,
|
||||
false);
|
||||
GetLogsResponse getLogResp = client.GetLogs(getLogReq);
|
||||
Console.WriteLine("Log count : " + getLogResp.Logs.Count.ToString());
|
||||
for (int i = 0; i < getLogResp.Logs.Count; ++i)
|
||||
{
|
||||
var log = getLogResp.Logs[i];
|
||||
Console.WriteLine("Log time : " + DateUtils.GetDateTime(log.Time));
|
||||
for (int j = 0; j < log.Contents.Count; ++j)
|
||||
{
|
||||
Console.WriteLine("\t" + log.Contents[j].Key + " : " + log.Contents[j].Value);
|
||||
}
|
||||
Console.WriteLine("");
|
||||
}
|
||||
|
||||
//query histogram
|
||||
GetHistogramsResponse getHisResp = client.GetHistograms(new GetHistogramsRequest(project,
|
||||
logstore,
|
||||
DateUtils.TimeSpan() - 100,
|
||||
DateUtils.TimeSpan(),
|
||||
"dotnet_topic",
|
||||
""));
|
||||
Console.WriteLine("Histograms total count : " + getHisResp.TotalCount.ToString());
|
||||
|
||||
//list shards
|
||||
ListShardsResponse listResp = client.ListShards(new ListShardsRequest(project, logstore));
|
||||
Console.WriteLine("Shards count : " + listResp.Shards.Count.ToString());
|
||||
|
||||
//batch get logs
|
||||
for (int i = 0; i < listResp.Shards.Count; ++i)
|
||||
{
|
||||
//get cursor
|
||||
String cursor = client.GetCursor(new GetCursorRequest(project, logstore, listResp.Shards[i], ShardCursorMode.BEGIN)).Cursor;
|
||||
Console.WriteLine("Cursor : " + cursor);
|
||||
BatchGetLogsResponse batchGetResp = client.BatchGetLogs(new BatchGetLogsRequest(project, logstore, listResp.Shards[i], cursor, 10));
|
||||
Console.WriteLine("Batch get log, shard id : " + listResp.Shards[i].ToString() + ", log count : " + batchGetResp.LogGroupList.LogGroupList_Count.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user