Skip to content

Commit

Permalink
Merge pull request #53 from serilog/dev
Browse files Browse the repository at this point in the history
3.0.0 Release
  • Loading branch information
nblumhardt authored Jul 4, 2024
2 parents dd71bd6 + 5b918a8 commit 0a7ff3d
Show file tree
Hide file tree
Showing 9 changed files with 86 additions and 56 deletions.
4 changes: 2 additions & 2 deletions Build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ if(Test-Path .\artifacts) {

$branch = @{ $true = $env:APPVEYOR_REPO_BRANCH; $false = $(git symbolic-ref --short -q HEAD) }[$env:APPVEYOR_REPO_BRANCH -ne $NULL];
$revision = @{ $true = "{0:00000}" -f [convert]::ToInt32("0" + $env:APPVEYOR_BUILD_NUMBER, 10); $false = "local" }[$env:APPVEYOR_BUILD_NUMBER -ne $NULL];
$suffix = @{ $true = ""; $false = "$($branch.Substring(0, [math]::Min(10,$branch.Length)))-$revision"}[$branch -eq "master" -and $revision -ne "local"]
$suffix = @{ $true = ""; $false = "$($branch.Substring(0, [math]::Min(10,$branch.Length)))-$revision"}[$branch -eq "main" -and $revision -ne "local"]
$commitHash = $(git rev-parse --short HEAD)
$buildSuffix = @{ $true = "$($suffix)-$($commitHash)"; $false = "$($branch)-$($commitHash)" }[$suffix -ne ""]

Expand All @@ -23,7 +23,7 @@ foreach ($src in ls src/*) {

echo "build: Packaging project in $src"

& dotnet build -c Release --version-suffix=$buildSuffix
& dotnet build -c Release --version-suffix=$buildSuffix /p:ContinuousIntegrationBuild=true

if($suffix) {
& dotnet pack -c Release --include-source --no-build -o ..\..\artifacts --version-suffix=$suffix
Expand Down
28 changes: 25 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,14 @@ Sink assemblies must be specified using the `serilog:using` syntax. For example,
If the sink accepts parameters, these are specified by appending the parameter name to the setting.

```csharp
.WriteTo.RollingFile(@"C:\Logs\myapp-{Date}.txt", retainedFileCountLimit: 10)
.WriteTo.File(@"C:\Logs\myapp-{Date}.txt", retainedFileCountLimit: 10)
```

In XML:

```xml
<add key="serilog:write-to:RollingFile.pathFormat" value="C:\Logs\myapp-{Date}.txt" />
<add key="serilog:write-to:RollingFile.retainedFileCountLimit" value="10" />
<add key="serilog:write-to:File.path" value="C:\Logs\myapp-{Date}.txt" />
<add key="serilog:write-to:File.retainedFileCountLimit" value="10" />
```

Any environment variables specified in a setting value (e.g. `%TEMP%`) will be expanded appropriately when read.
Expand Down Expand Up @@ -140,3 +140,25 @@ For example, to configure the `RollingInterval` of the [File Sink](https://githu
```

If you specify the the name of the enumeration, you'll receive an error similar to `System.ArgumentException: Requested value 'RollingInterval.Day' was not found`

### Destructuring

```csharp

LoggerConfiguration
.Destructure.ToMaximumDepth(maximumDestructuringDepth: 3)
.Destructure.ToMaximumStringLength(maximumStringLength: 3)
.Destructure.ToMaximumCollectionCount(maximumCollectionCount: 3)
.Destructure.AsScalar(typeof(System.Version))
.Destructure.With(new CustomPolicy());
```

and in XML

```xml
<add key="serilog:destructure:ToMaximumDepth.maximumDestructuringDepth" value="3" />
<add key="serilog:destructure:ToMaximumStringLength.maximumStringLength" value="3" />
<add key="serilog:destructure:ToMaximumCollectionCount.maximumCollectionCount" value="3" />
<add key="serilog:destructure:AsScalar.scalarType" value="System.Version" />
<add key="serilog:destructure:With.policy" value="My.CustomPolicy, MyAssembly, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" />
```
13 changes: 8 additions & 5 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,24 +1,27 @@
version: '{build}'
skip_tags: true
image: Visual Studio 2017
image: Visual Studio 2022
configuration: Release
build_script:
- ps: ./Build.ps1
test: off
artifacts:
- path: artifacts/Serilog.*.nupkg
- path: artifacts/Serilog.*.snupkg
deploy:
- provider: NuGet
api_key:
secure: bd9z4P73oltOXudAjPehwp9iDKsPtC+HbgshOrSgoyQKr5xVK+bxJQngrDJkHdY8
secure: 0blv8+bRwb/S3wEXjl7xdUjJaf/2sONe4TXeGuN/AywGXCMjUL/qBuMo/jHy+bMU
skip_symbols: true
on:
branch: /^(master|dev)$/
branch: /^(main|dev)$/
- provider: GitHub
auth_token:
secure: p4LpVhBKxGS5WqucHxFQ5c7C8cP74kbNB0Z8k9Oxx/PMaDQ1+ibmoexNqVU5ZlmX
artifact: /Serilog.*\.nupkg/
artifacts:
/Serilog.*\.nupkg/
/Serilog.*\.snupkg/
tag: v$(appveyor_build_version)
on:
branch: master
branch: main

Binary file added assets/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public static class AppSettingsLoggerConfigurationExtensions
/// <returns>An object allowing configuration to continue.</returns>
[EditorBrowsable(EditorBrowsableState.Never)]
public static LoggerConfiguration AppSettings(
this LoggerSettingsConfiguration settingConfiguration, string settingPrefix)
this LoggerSettingsConfiguration settingConfiguration, string? settingPrefix)
{
return AppSettings(settingConfiguration, settingPrefix, filePath: null);
}
Expand All @@ -60,10 +60,10 @@ public static LoggerConfiguration AppSettings(
/// By default, the current application's configuration file will be used.</param>
/// <returns>An object allowing configuration to continue.</returns>
public static LoggerConfiguration AppSettings(
this LoggerSettingsConfiguration settingConfiguration, string settingPrefix = null, string filePath = null)
this LoggerSettingsConfiguration settingConfiguration, string? settingPrefix = null, string? filePath = null)
{
if (settingConfiguration == null) throw new ArgumentNullException(nameof(settingConfiguration));
if (settingPrefix != null)
if (settingConfiguration is null) throw new ArgumentNullException(nameof(settingConfiguration));
if (settingPrefix is not null)
{
if (settingPrefix.Contains(":")) throw new ArgumentException("Custom setting prefixes cannot contain the colon (:) character.");
if (settingPrefix == "serilog") throw new ArgumentException("The value \"serilog\" is not a permitted setting prefix. To use the default, do not specify a custom prefix at all.");
Expand Down
2 changes: 0 additions & 2 deletions src/Serilog.Settings.AppSettings/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
using System.Reflection;
using System.Runtime.CompilerServices;

[assembly: AssemblyVersion("2.0.0.0")]

[assembly: CLSCompliant(true)]

[assembly: InternalsVisibleTo("Serilog.Tests, PublicKey=" +
Expand Down
Original file line number Diff line number Diff line change
@@ -1,42 +1,54 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<Description>XML configuration (System.Configuration &lt;appSettings&gt;) support for Serilog.</Description>
<VersionPrefix>2.2.2</VersionPrefix>
<VersionPrefix>3.0.0</VersionPrefix>
<Authors>Serilog Contributors</Authors>
<TargetFrameworks>net45;netstandard2.0</TargetFrameworks>
<!-- .NET Framework version targeting is frozen at these two TFMs. -->
<TargetFrameworks Condition=" '$(OS)' == 'Windows_NT'">net471;net462</TargetFrameworks>
<!-- Policy is to trim TFM-specific builds to `netstandard2.0`, `net6.0`,
all active LTS versions, and optionally the latest RTM version, when releasing new
major Serilog versions. -->
<TargetFrameworks>$(TargetFrameworks);net8.0;net6.0;netstandard2.0</TargetFrameworks>
<AssemblyName>Serilog.Settings.AppSettings</AssemblyName>
<AssemblyOriginatorKeyFile>../../assets/Serilog.snk</AssemblyOriginatorKeyFile>
<SignAssembly>true</SignAssembly>
<PublicSign Condition=" '$(OS)' != 'Windows_NT' ">true</PublicSign>
<PackageId>Serilog.Settings.AppSettings</PackageId>
<PackageTags>serilog;xml</PackageTags>
<PackageIconUrl>https://serilog.net/images/serilog-configuration-nuget.png</PackageIconUrl>
<PackageIcon>icon.png</PackageIcon>
<PackageReadmeFile>README.md</PackageReadmeFile>
<PackageProjectUrl>https://github.com/serilog/serilog-settings-appsettings</PackageProjectUrl>
<PackageLicenseUrl>https://www.apache.org/licenses/LICENSE-2.0</PackageLicenseUrl>
<RepositoryUrl>https://github.com/serilog/serilog-settings-appsettings</RepositoryUrl>
<PackageLicenseExpression>Apache-2.0</PackageLicenseExpression>
<RepositoryType>git</RepositoryType>
<GenerateAssemblyVersionAttribute>false</GenerateAssemblyVersionAttribute>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<PublishRepositoryUrl>true</PublishRepositoryUrl>
<EmbedUntrackedSources>true</EmbedUntrackedSources>
<IncludeSymbols>true</IncludeSymbols>
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
<DelaySign>false</DelaySign>
<LangVersion>latest</LangVersion>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Serilog" Version="2.6.0" />
<PackageReference Include="Serilog" Version="4.0.0" />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'net45' ">
<Reference Include="System.Configuration" />
<Reference Include="System" />
<Reference Include="Microsoft.CSharp" />
<ItemGroup Condition="$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net462'))">
<Reference Include="System.Configuration" />
</ItemGroup>

<ItemGroup Condition="$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net6.0'))">
<PackageReference Include="System.Configuration.ConfigurationManager" Version="4.4.1" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">
<PackageReference Include="System.Configuration.ConfigurationManager">
<Version>4.4.1</Version>
</PackageReference>
<PackageReference Include="System.Configuration.ConfigurationManager" Version="4.4.1" />
</ItemGroup>

<ItemGroup>
<None Include="..\..\assets\icon.png" Pack="true" PackagePath="" Visible="false" />
<None Include="..\..\README.md" Pack="true" PackagePath="" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,18 @@ namespace Serilog.Settings.AppSettings
{
class AppSettingsSettings : ILoggerSettings
{
readonly string _filePath;
readonly string? _filePath;
readonly string _settingPrefix;

public AppSettingsSettings(string settingPrefix = null, string filePath = null)
public AppSettingsSettings(string? settingPrefix = null, string? filePath = null)
{
_filePath = filePath;
_settingPrefix = settingPrefix == null ? "serilog:" : $"{settingPrefix}:serilog:";
_settingPrefix = settingPrefix is null ? "serilog:" : $"{settingPrefix}:serilog:";
}

public void Configure(LoggerConfiguration loggerConfiguration)
{
if (loggerConfiguration == null) throw new ArgumentNullException(nameof(loggerConfiguration));
if (loggerConfiguration is null) throw new ArgumentNullException(nameof(loggerConfiguration));

IEnumerable<KeyValuePair<string, string>> settings;

Expand All @@ -56,7 +56,7 @@ public void Configure(LoggerConfiguration loggerConfiguration)
else
{
settings = ConfigurationManager.AppSettings.AllKeys
.Select(k => new KeyValuePair<string, string>(k, ConfigurationManager.AppSettings[k]));
.Select(k => new KeyValuePair<string, string>(k, ConfigurationManager.AppSettings[k]!));
}

var pairs = settings
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net45;netcoreapp2.0</TargetFrameworks>
<TargetFrameworks>net8.0;net48</TargetFrameworks>
<IsPackable>false</IsPackable>
</PropertyGroup>

Expand All @@ -10,24 +10,19 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.5.0" />
<PackageReference Include="xunit" Version="2.3.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.3.1" />
<DotNetCliToolReference Include="dotnet-xunit" Version="2.3.1" />
<PackageReference Include="Newtonsoft.Json" Version="9.0.1" />
<PackageReference Include="Serilog.Sinks.TextWriter" Version="2.0.0" />
<PackageReference Include="Serilog.Sinks.RollingFile" Version="3.1.0" />
<PackageReference Include="Serilog.Sinks.PeriodicBatching" Version="2.0.0" />
<PackageReference Include="Serilog.Sinks.Observable" Version="2.0.0-*" />
<PackageReference Include="Serilog.Enrichers.Environment" Version="2.0.0-*" />
<PackageReference Include="Serilog.Enrichers.Process" Version="2.0.0-*" />
<PackageReference Include="Serilog.Enrichers.Thread" Version="2.0.0" />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'net45' ">
<Reference Include="System.Configuration" />
<Reference Include="System" />
<Reference Include="Microsoft.CSharp" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.10.0" />
<PackageReference Include="xunit" Version="2.8.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Serilog.Sinks.File" Version="6.0.0" />
<PackageReference Include="Serilog.Sinks.TextWriter" Version="3.0.0" />
<PackageReference Include="Serilog.Sinks.PeriodicBatching" Version="5.0.0" />
<PackageReference Include="Serilog.Sinks.Observable" Version="3.0.0" />
<PackageReference Include="Serilog.Enrichers.Environment" Version="3.0.1" />
<PackageReference Include="Serilog.Enrichers.Process" Version="3.0.0" />
<PackageReference Include="Serilog.Enrichers.Thread" Version="4.0.0" />
</ItemGroup>

<ItemGroup>
Expand Down

0 comments on commit 0a7ff3d

Please sign in to comment.