Created
November 24, 2016 17:58
-
-
Save ctaggart/602c04ae1fa79077864f02c980c72cf7 to your computer and use it in GitHub Desktop.
gcloud logging getting started
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8" ?> | |
<log4net debug="true"> | |
<appender name="ConsoleAppender" type="log4net.Appender.ConsoleAppender" > | |
<layout type="log4net.Layout.PatternLayout"> | |
<conversionPattern value="%-4timestamp [%thread] %-5level %logger %ndc - %message" /> | |
</layout> | |
</appender> | |
<appender name="CloudLogger" type="Google.Logging.Log4Net.GoogleStackdriverAppender, Google.Logging.Log4Net"> | |
<layout type="log4net.Layout.PatternLayout"> | |
<conversionPattern value="%-4timestamp [%thread] %-5level %logger %ndc - %message" /> | |
</layout> | |
<projectId value="tachyusatmion" /> | |
<logId value="myLog" /> | |
<withMetaData value="Location" /> | |
<withMetaData value="ThreadName" /> | |
</appender> | |
<root> | |
<level value="DEBUG" /> | |
<appender-ref ref="ConsoleAppender" /> | |
<appender-ref ref="CloudLogger" /> | |
</root> | |
</log4net> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.IO; | |
using System.Linq; | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
Environment.SetEnvironmentVariable("GRPC_TRACE", "all", EnvironmentVariableTarget.Process); | |
Environment.SetEnvironmentVariable("GRPC_VERBOSITY", "debug", EnvironmentVariableTarget.Process); | |
Grpc.Core.GrpcEnvironment.SetLogger(new Grpc.Core.Logging.ConsoleLogger()); | |
//Google.Logging.Log4Net.GoogleStackdriverAppender | |
var fi = new FileInfo("log4net.xml"); | |
Console.WriteLine("file exists: " + fi.Exists); | |
log4net.Config.XmlConfigurator.Configure(new FileInfo("log4net.xml")); | |
Console.WriteLine("Hello World!"); | |
var log = log4net.LogManager.GetLogger(typeof(Program)); | |
log.Info("An exciting log entry!"); | |
// http://stackoverflow.com/a/2045992/23059 | |
var logger = log.Logger as log4net.Repository.Hierarchy.Logger; | |
if (logger != null) | |
{ | |
foreach (var appender in logger.Appenders) | |
{ | |
Console.WriteLine("appender: " + appender.Name); | |
} | |
} | |
//var repository = log4net.LogManager.GetRepository(); | |
//var appenders = repository.GetAppenders().OfType<log4net.Appender.BufferingAppenderSkeleton>(); | |
//foreach (var appender in appenders) | |
// appender.Flush(); | |
Console.ReadKey(); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | |
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" /> | |
<PropertyGroup> | |
<OutputType>Exe</OutputType> | |
<TargetFramework>net461</TargetFramework> | |
<RuntimeIdentifier>win10-x64</RuntimeIdentifier> | |
</PropertyGroup> | |
<ItemGroup> | |
<Compile Include="**\*.cs" /> | |
<EmbeddedResource Include="**\*.resx" /> | |
</ItemGroup> | |
<ItemGroup> | |
<Content Include="log4net.xml"> | |
<CopyToOutputDirectory>Always</CopyToOutputDirectory> | |
</Content> | |
</ItemGroup> | |
<ItemGroup> | |
<PackageReference Include="NETStandard.Library"> | |
<Version>1.6.1</Version> | |
</PackageReference> | |
<PackageReference Include="Microsoft.NET.Sdk"> | |
<Version>1.0.0-alpha-20161104-2</Version> | |
<PrivateAssets>All</PrivateAssets> | |
</PackageReference> | |
<PackageReference Include="System.Diagnostics.DiagnosticSource"> | |
<Version>4.3.0</Version> | |
</PackageReference> | |
<Reference Include="BouncyCastle.Crypto"> | |
<HintPath>..\google-cloud-dotnet\apis\Google.Logging.V2\Google.Logging.Log4Net\bin\Release\net45\BouncyCastle.Crypto.dll</HintPath> | |
</Reference> | |
<Reference Include="Google.Api.CommonProtos"> | |
<HintPath>..\google-cloud-dotnet\apis\Google.Logging.V2\Google.Logging.Log4Net\bin\Release\net45\Google.Api.CommonProtos.dll</HintPath> | |
</Reference> | |
<Reference Include="Google.Api.Gax"> | |
<HintPath>..\google-cloud-dotnet\apis\Google.Logging.V2\Google.Logging.Log4Net\bin\Release\net45\Google.Api.Gax.dll</HintPath> | |
</Reference> | |
<Reference Include="Google.Api.Gax.Grpc"> | |
<HintPath>..\google-cloud-dotnet\apis\Google.Logging.V2\Google.Logging.Log4Net\bin\Release\net45\Google.Api.Gax.Grpc.dll</HintPath> | |
</Reference> | |
<Reference Include="Google.Apis"> | |
<HintPath>..\google-cloud-dotnet\apis\Google.Logging.V2\Google.Logging.Log4Net\bin\Release\net45\Google.Apis.dll</HintPath> | |
</Reference> | |
<Reference Include="Google.Apis.Auth"> | |
<HintPath>..\google-cloud-dotnet\apis\Google.Logging.V2\Google.Logging.Log4Net\bin\Release\net45\Google.Apis.Auth.dll</HintPath> | |
</Reference> | |
<Reference Include="Google.Apis.Auth.PlatformServices"> | |
<HintPath>..\google-cloud-dotnet\apis\Google.Logging.V2\Google.Logging.Log4Net\bin\Release\net45\Google.Apis.Auth.PlatformServices.dll</HintPath> | |
</Reference> | |
<Reference Include="Google.Apis.Core"> | |
<HintPath>..\google-cloud-dotnet\apis\Google.Logging.V2\Google.Logging.Log4Net\bin\Release\net45\Google.Apis.Core.dll</HintPath> | |
</Reference> | |
<Reference Include="Google.Apis.PlatformServices"> | |
<HintPath>..\google-cloud-dotnet\apis\Google.Logging.V2\Google.Logging.Log4Net\bin\Release\net45\Google.Apis.PlatformServices.dll</HintPath> | |
</Reference> | |
<Reference Include="Google.Logging.Log4Net"> | |
<HintPath>..\google-cloud-dotnet\apis\Google.Logging.V2\Google.Logging.Log4Net\bin\Release\net45\Google.Logging.Log4Net.dll</HintPath> | |
</Reference> | |
<Reference Include="Google.Logging.Type"> | |
<HintPath>..\google-cloud-dotnet\apis\Google.Logging.V2\Google.Logging.Log4Net\bin\Release\net45\Google.Logging.Type.dll</HintPath> | |
</Reference> | |
<Reference Include="Google.Logging.V2"> | |
<HintPath>..\google-cloud-dotnet\apis\Google.Logging.V2\Google.Logging.Log4Net\bin\Release\net45\Google.Logging.V2.dll</HintPath> | |
</Reference> | |
<Reference Include="Google.Protobuf"> | |
<HintPath>..\protobuf\csharp\src\Google.Protobuf\bin\Release\net45\Google.Protobuf.dll</HintPath> | |
</Reference> | |
<Reference Include="Grpc.Auth"> | |
<HintPath>..\google-cloud-dotnet\apis\Google.Logging.V2\Google.Logging.Log4Net\bin\Release\net45\Grpc.Auth.dll</HintPath> | |
</Reference> | |
<Reference Include="Grpc.Core"> | |
<HintPath>..\google-cloud-dotnet\apis\Google.Logging.V2\Google.Logging.Log4Net\bin\Release\net45\Grpc.Core.dll</HintPath> | |
</Reference> | |
<Reference Include="log4net"> | |
<HintPath>..\google-cloud-dotnet\apis\Google.Logging.V2\Google.Logging.Log4Net\bin\Release\net45\log4net.dll</HintPath> | |
</Reference> | |
<Reference Include="Newtonsoft.Json"> | |
<HintPath>..\google-cloud-dotnet\apis\Google.Logging.V2\Google.Logging.Log4Net\bin\Release\net45\Newtonsoft.Json.dll</HintPath> | |
</Reference> | |
<Reference Include="System" /> | |
<Reference Include="System.Interactive.Async"> | |
<HintPath>..\google-cloud-dotnet\apis\Google.Logging.V2\Google.Logging.Log4Net\bin\Release\net45\System.Interactive.Async.dll</HintPath> | |
</Reference> | |
<Reference Include="System.Runtime.InteropServices.RuntimeInformation"> | |
<HintPath>..\google-cloud-dotnet\apis\Google.Logging.V2\Google.Logging.Log4Net\bin\Release\net45\System.Runtime.InteropServices.RuntimeInformation.dll</HintPath> | |
</Reference> | |
<Reference Include="System.Xml" /> | |
<Reference Include="Zlib.Portable"> | |
<HintPath>..\google-cloud-dotnet\apis\Google.Logging.V2\Google.Logging.Log4Net\bin\Release\net45\Zlib.Portable.dll</HintPath> | |
</Reference> | |
</ItemGroup> | |
<ItemGroup /> | |
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> | |
</Project> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment