Skip to content

Commit

Permalink
Merge pull request #1 from serilog/master
Browse files Browse the repository at this point in the history
Merge from master
  • Loading branch information
ShawInnes committed May 14, 2014
2 parents 67425dd + 9df7bb4 commit e553a5e
Show file tree
Hide file tree
Showing 187 changed files with 2,505 additions and 373 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ A no-nonsense logging library for the NoSQL era. Combines the best of traditiona
* [Homepage](http://serilog.net)
* [Documentation](https://github.com/nblumhardt/serilog/wiki)

Would you like to help make Serilog even better? We keep a list of issues that are approachable for newcomers under the [up-for-grabs](https://github.com/serilog/serilog/issues?labels=up-for-grabs&state=open) label!

Copyright 2013 Serilog Contributors - Provided under the [Apache License, Version 2.0](http://apache.org/licenses/LICENSE-2.0.html).

Needle and thread logo a derivative of work by [Kenneth Appiah](http://thenounproject.com/kenset/).
28 changes: 28 additions & 0 deletions Serilog.sln
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,14 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LogentriesSample", "sample\
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Serilog.Sinks.Couchbase", "src\Serilog.Sinks.Couchbase\Serilog.Sinks.Couchbase.csproj", "{104D5B1E-47BE-4739-A183-08C35BF4D38D}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Serilog.Extras.MSOwin", "src\Serilog.Extras.MSOwin\Serilog.Extras.MSOwin.csproj", "{FDCEBC10-F403-4DDD-8594-DE6D7DD543AF}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Serilog.Extras.MSOwin.Tests", "test\Serilog.Extras.MSOwin.Tests\Serilog.Extras.MSOwin.Tests.csproj", "{4F81EDAE-2E06-4024-925A-E495C852BDCF}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MSSQLSample", "sample\MSSQLSample\MSSQLSample.csproj", "{F9BEFBBD-0883-4AAF-AEEC-6172E890A713}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Serilog.Sinks.MSSqlServer", "src\Serilog.Sinks.MSSqlServer\Serilog.Sinks.MSSqlServer.csproj", "{31C64BE9-4EF6-42D5-A811-D7D24613EEF6}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -244,6 +252,22 @@ Global
{104D5B1E-47BE-4739-A183-08C35BF4D38D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{104D5B1E-47BE-4739-A183-08C35BF4D38D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{104D5B1E-47BE-4739-A183-08C35BF4D38D}.Release|Any CPU.Build.0 = Release|Any CPU
{FDCEBC10-F403-4DDD-8594-DE6D7DD543AF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{FDCEBC10-F403-4DDD-8594-DE6D7DD543AF}.Debug|Any CPU.Build.0 = Debug|Any CPU
{FDCEBC10-F403-4DDD-8594-DE6D7DD543AF}.Release|Any CPU.ActiveCfg = Release|Any CPU
{FDCEBC10-F403-4DDD-8594-DE6D7DD543AF}.Release|Any CPU.Build.0 = Release|Any CPU
{4F81EDAE-2E06-4024-925A-E495C852BDCF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4F81EDAE-2E06-4024-925A-E495C852BDCF}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4F81EDAE-2E06-4024-925A-E495C852BDCF}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4F81EDAE-2E06-4024-925A-E495C852BDCF}.Release|Any CPU.Build.0 = Release|Any CPU
{F9BEFBBD-0883-4AAF-AEEC-6172E890A713}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F9BEFBBD-0883-4AAF-AEEC-6172E890A713}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F9BEFBBD-0883-4AAF-AEEC-6172E890A713}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F9BEFBBD-0883-4AAF-AEEC-6172E890A713}.Release|Any CPU.Build.0 = Release|Any CPU
{31C64BE9-4EF6-42D5-A811-D7D24613EEF6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{31C64BE9-4EF6-42D5-A811-D7D24613EEF6}.Debug|Any CPU.Build.0 = Debug|Any CPU
{31C64BE9-4EF6-42D5-A811-D7D24613EEF6}.Release|Any CPU.ActiveCfg = Release|Any CPU
{31C64BE9-4EF6-42D5-A811-D7D24613EEF6}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -285,5 +309,9 @@ Global
{7C03FE5B-426F-494C-9B7E-B23F060AB5D3} = {037440DE-440B-4129-9F7A-09B42D00397E}
{BFC7DA08-C46F-4605-8EAA-615A884195AD} = {C4B270F5-E0E9-417A-B9C7-6ACBB9DB3912}
{104D5B1E-47BE-4739-A183-08C35BF4D38D} = {037440DE-440B-4129-9F7A-09B42D00397E}
{FDCEBC10-F403-4DDD-8594-DE6D7DD543AF} = {037440DE-440B-4129-9F7A-09B42D00397E}
{4F81EDAE-2E06-4024-925A-E495C852BDCF} = {0D135C0C-A60B-454A-A2F4-CD74A30E04B0}
{F9BEFBBD-0883-4AAF-AEEC-6172E890A713} = {C4B270F5-E0E9-417A-B9C7-6ACBB9DB3912}
{31C64BE9-4EF6-42D5-A811-D7D24613EEF6} = {037440DE-440B-4129-9F7A-09B42D00397E}
EndGlobalSection
EndGlobal
3 changes: 3 additions & 0 deletions packages/repositories.config
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<repository path="..\sample\Log4NetSample\packages.config" />
<repository path="..\sample\SplunkSample\packages.config" />
<repository path="..\sample\WebHarness\packages.config" />
<repository path="..\src\Serilog.Extras.MSOwin\packages.config" />
<repository path="..\src\Serilog.Extras.TopShelf\packages.config" />
<repository path="..\src\Serilog.Sinks.AzureTableStorage\packages.config" />
<repository path="..\src\Serilog.Sinks.Couchbase\packages.config" />
Expand All @@ -14,9 +15,11 @@
<repository path="..\src\Serilog.Sinks.Loggly\packages.config" />
<repository path="..\src\Serilog.Sinks.Loggr\packages.config" />
<repository path="..\src\Serilog.Sinks.MongoDB\packages.config" />
<repository path="..\src\Serilog.Sinks.MSSQL\packages.config" />
<repository path="..\src\Serilog.Sinks.RavenDB\packages.config" />
<repository path="..\src\Serilog.Sinks.SignalR\packages.config" />
<repository path="..\src\Serilog.Sinks.Splunk\packages.config" />
<repository path="..\test\Serilog.Extras.MSOwin.Tests\packages.config" />
<repository path="..\test\Serilog.Sinks.RavenDB.Tests\packages.config" />
<repository path="..\test\Serilog.Tests\packages.config" />
</repositories>
12 changes: 0 additions & 12 deletions sample/Demo/Demo.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -56,22 +56,10 @@
<Project>{7a9e1095-167d-402a-b43d-b36b97ff183d}</Project>
<Name>Serilog.FullNetFx</Name>
</ProjectReference>
<ProjectReference Include="..\..\src\Serilog.Sinks.Couchbase\Serilog.Sinks.Couchbase.csproj">
<Project>{104d5b1e-47be-4739-a183-08c35bf4d38d}</Project>
<Name>Serilog.Sinks.Couchbase</Name>
</ProjectReference>
<ProjectReference Include="..\..\src\Serilog.Sinks.CouchDB\Serilog.Sinks.CouchDB.csproj">
<Project>{e728d183-07c4-49f7-8c4c-d76d70c8f3b4}</Project>
<Name>Serilog.Sinks.CouchDB</Name>
</ProjectReference>
<ProjectReference Include="..\..\src\Serilog.Sinks.EventLog\Serilog.Sinks.EventLog.csproj">
<Project>{eea8b8eb-0fe6-44c2-9d10-02b7e3dead06}</Project>
<Name>Serilog.Sinks.EventLog</Name>
</ProjectReference>
<ProjectReference Include="..\..\src\Serilog.Sinks.MongoDB\Serilog.Sinks.MongoDB.csproj">
<Project>{8164bde4-48fe-4a81-b33e-fee348904bb8}</Project>
<Name>Serilog.Sinks.MongoDB</Name>
</ProjectReference>
<ProjectReference Include="..\..\src\Serilog\Serilog.csproj">
<Project>{0915dbd9-0f7c-4439-8d9e-74c3d579b219}</Project>
<Name>Serilog</Name>
Expand Down
13 changes: 0 additions & 13 deletions sample/Demo/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
using System.Diagnostics;
using System.Threading;
using Serilog;
using Serilog.Sinks.Couchbase;

namespace Demo
{
Expand All @@ -16,24 +15,12 @@ class Program
{
static void Main()
{
// To append to Couch or Mongo use-
// .WriteTo.CouchDB("http://localhost:5984/log/")
// .WriteTo.MongoDB("mongodb://localhost/logdb")

// To append to Couchbase use-
// .WriteTo.Couchbase(new string[] { "http://localhost:8091/pools/" }, "serilog")

// To append to the Windows event log use-
// .WriteTo.EventLog("Demo", "Serilog")
// where 'Demo' is the name of the source, as it appears in the event log, and 'Serilog' is the name of the event log written to- Appliction, by default.

// ReadAppSettings() is an extension defined in the
// Serilog.Extras.AppSettings package.

Log.Logger = new LoggerConfiguration()
.ReadAppSettings()
.WriteTo.ColoredConsole()
.WriteTo.EventLog("Serilog Demo")
.CreateLogger();

Log.Verbose("This app, {ExeName}, demonstrates the basics of using Serilog", "Demo.exe");
Expand Down
2 changes: 1 addition & 1 deletion sample/Harness/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ static void Main()
Log.Logger = new LoggerConfiguration()
.MinimumLevel.Debug()
.WriteTo.Console(
outputTemplate: "{Timestamp:HH:mm:ss} ({ThreadId}) [{Level}] {Message:l}{NewLine:l}{Exception:l}")
outputTemplate: "{Timestamp:HH:mm:ss} ({ThreadId}) [{Level}] {Message}{NewLine}{Exception}")
.WriteTo.Trace()
.Enrich.WithProperty("App", "Test Harness")
.Enrich.With(new ThreadIdEnricher(),
Expand Down
2 changes: 1 addition & 1 deletion sample/Log4NetSample/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace Log4NetSample
{
class Program
{
const string OutputTemplate = "[SERILOG] {Timestamp:G} ({ThreadId}) {Level} {SourceContext:l} - {Message:l}{NewLine:l}{Exception:l}";
const string OutputTemplate = "[SERILOG] {Timestamp:G} ({ThreadId}) {Level} {SourceContext} - {Message}{NewLine}{Exception}";

static void Main()
{
Expand Down
6 changes: 6 additions & 0 deletions sample/MSSQLSample/App.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5"/>
</startup>
</configuration>
74 changes: 74 additions & 0 deletions sample/MSSQLSample/MSSQLSample.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{F9BEFBBD-0883-4AAF-AEEC-6172E890A713}</ProjectGuid>
<OutputType>Exe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>MSSQLSample</RootNamespace>
<AssemblyName>MSSQLSample</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</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|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<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" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\src\Serilog.FullNetFx\Serilog.FullNetFx.csproj">
<Project>{7a9e1095-167d-402a-b43d-b36b97ff183d}</Project>
<Name>Serilog.FullNetFx</Name>
</ProjectReference>
<ProjectReference Include="..\..\src\Serilog.Sinks.MSSqlServer\Serilog.Sinks.MSSqlServer.csproj">
<Project>{31c64be9-4ef6-42d5-a811-d7d24613eef6}</Project>
<Name>Serilog.Sinks.MSSqlServer</Name>
</ProjectReference>
<ProjectReference Include="..\..\src\Serilog\Serilog.csproj">
<Project>{0915dbd9-0f7c-4439-8d9e-74c3d579b219}</Project>
<Name>Serilog</Name>
</ProjectReference>
</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>
112 changes: 112 additions & 0 deletions sample/MSSQLSample/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Serilog;

namespace MSSQLSample
{
class Position
{
public double Lat { get; set; }
public double Long { get; set; }
}

class Program
{
static void Main()
{

Log.Logger = new LoggerConfiguration()
.WriteTo.ColoredConsole()
.MinimumLevel.Debug()
.WriteTo.MSSqlServer(@"Server=.\SQLEXPRESS;Database=LogEvents;Trusted_Connection=True;", "Logs")
.CreateLogger();

Log.Verbose("This app, {ExeName}, demonstrates the basics of using Serilog", "Demo.exe");

ProcessInput(new Position { Lat = 24.7, Long = 132.2 });
ProcessInput(new Position { Lat = 24.71, Long = 132.15 });
ProcessInput(new Position { Lat = 24.72, Long = 132.2 });


Log.Information("Just biting {Fruit} number {Count}", "Apple", 12);
Log.ForContext<Program>().Information("Just biting {Fruit} number {Count:0000}", "Apple", 12);

// ReSharper disable CoVariantArrayConversion
Log.Information("I've eaten {Dinner}", new[] { "potatoes", "peas" });
// ReSharper restore CoVariantArrayConversion

Log.Information("I sat at {@Chair}", new { Back = "straight", Legs = new[] { 1, 2, 3, 4 } });
Log.Information("I sat at {Chair}", new { Back = "straight", Legs = new[] { 1, 2, 3, 4 } });


const int failureCount = 3;
Log.Warning("Exception coming up because of {FailureCount} failures...", failureCount);



try
{
DoBad();
}
catch (Exception ex)
{
Log.Error(ex, "There's those {FailureCount} failures", failureCount);
}

Log.Verbose("This app, {ExeName}, demonstrates the basics of using Serilog", "Demo.exe");

try
{
DoBad();
}
catch (Exception ex)
{
Log.Error(ex, "We did some bad work here.");
}

var result = 0;
var divideBy = 0;
try
{
result = 10 / divideBy;
}
catch (Exception e)
{
Log.Error(e, "Unable to divide by {divideBy}", divideBy);
}


for (int i = 0; i < 10; i++)
{
Thread.Sleep(500);
Log.Debug("Count: {Counter}", i);
}

Log.Fatal("That's all folks - and all done using {WorkingSet} bytes of RAM", Environment.WorkingSet);
Console.ReadKey(true);
}

static void DoBad()
{
throw new InvalidOperationException("Everything's broken!");
}

static readonly Random Rng = new Random();

static void ProcessInput(Position sensorInput)
{
var sw = new Stopwatch();
sw.Start();
Log.Debug("Processing some input on {MachineName}...", Environment.MachineName);
Thread.Sleep(Rng.Next(0, 100));
sw.Stop();

Log.Information("Processed {@SensorInput} in {Time:000} ms", sensorInput, sw.ElapsedMilliseconds);
}
}
}
36 changes: 36 additions & 0 deletions sample/MSSQLSample/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("MSSQLSample")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("MSSQLSample")]
[assembly: AssemblyCopyright("Copyright © 2014")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]

// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("5b9121fd-e0f6-4197-b2e9-d14b210d9c4e")]

// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

0 comments on commit e553a5e

Please sign in to comment.