Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fe69bf4
commit e878a76
Showing
24 changed files
with
559 additions
and
23 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,37 @@ | |||
<?xml version="1.0"?> | |||
<configuration> | |||
<configSections> | |||
<section name="nlog" type="NLog.Config.ConfigSectionHandler, NLog"/> | |||
</configSections> | |||
<nlog> | |||
<targets> | |||
<target name="console" type="Console" | |||
layout="${message}" | |||
/> | |||
<target name="file" type="AsyncWrapper" | |||
queueLimit="5000" | |||
overflowAction="Discard"> | |||
<target type="File" | |||
fileName="${basedir}/logs/this.Log-NLog.Sample.log" | |||
layout="${longdate} ${threadid} [${level:uppercase=true}] ${message}" | |||
/> | |||
</target> | |||
<target name="errorSmtp" type="Mail" | |||
layout="${longdate} ${threadid} [${level:uppercase=true}] ${logger} - ${message}" | |||
subject="this.Log Sample Console Errors - LOCAL DEBUG" | |||
to="noone@noreply.org" | |||
from="this.Log.sample@noreply.org" | |||
smtpServer="localhost" | |||
/> | |||
</targets> | |||
|
|||
<rules> | |||
<logger name="*" minlevel="Debug" writeTo="file" /> | |||
<logger name="*" minlevel="Debug" writeTo="console" /> | |||
<logger name="*" minlevel="Error" writeTo="errorSmtp" /> | |||
</rules> | |||
</nlog> | |||
<startup> | |||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/> | |||
</startup> | |||
</configuration> |
This file contains 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
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,56 @@ | |||
// ============================================================================== | |||
// | |||
// RealDimensions Software, LLC - Copyright © 2012 - Present - Released under the Apache 2.0 License | |||
// | |||
// Copyright 2007-2008 The Apache Software Foundation. | |||
// | |||
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use | |||
// this file except in compliance with the License. You may obtain a copy of the | |||
// License at | |||
// | |||
// http://www.apache.org/licenses/LICENSE-2.0 | |||
// | |||
// Unless required by applicable law or agreed to in writing, software distributed | |||
// under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR | |||
// CONDITIONS OF ANY KIND, either express or implied. See the License for the | |||
// specific language governing permissions and limitations under the License. | |||
// ============================================================================== | |||
|
|||
namespace LoggingExtensions.Sample.NLog | |||
{ | |||
using System.Collections.Concurrent; | |||
using LoggingExtensions.Logging; | |||
|
|||
/// <summary> | |||
/// Extensions to help make logging awesome - this should be installed into the root namespace of your application | |||
/// </summary> | |||
public static class LogExtensions | |||
{ | |||
/// <summary> | |||
/// Concurrent dictionary that ensures only one instance of a logger for a type. | |||
/// </summary> | |||
private static readonly ConcurrentDictionary<string, ILog> _dictionary = new ConcurrentDictionary<string, ILog>(); | |||
|
|||
/// <summary> | |||
/// Gets the logger for <see cref="T"/>. | |||
/// </summary> | |||
/// <typeparam name="T"></typeparam> | |||
/// <param name="type">The type to get the logger for.</param> | |||
/// <returns>Instance of a logger for the object.</returns> | |||
public static ILog Log<T>(this T type) | |||
{ | |||
string objectName = typeof (T).FullName; | |||
return Log(objectName); | |||
} | |||
|
|||
/// <summary> | |||
/// Gets the logger for the specified object name. | |||
/// </summary> | |||
/// <param name="objectName">Either use the fully qualified object name or the short. If used with Log<T>() you must use the fully qualified object name"/></param> | |||
/// <returns>Instance of a logger for the object.</returns> | |||
public static ILog Log(this string objectName) | |||
{ | |||
return _dictionary.GetOrAdd(objectName, LoggingExtensions.Logging.Log.GetLoggerFor); | |||
} | |||
} | |||
} |
This file contains 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
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,13 @@ | |||
using System.Reflection; | |||
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("this.Log-log4net.Sample")] | |||
[assembly: AssemblyDescription("")] | |||
[assembly: AssemblyProduct("this.Log-log4net.Sample")] | |||
|
|||
// The following GUID is for the ID of the typelib if this project is exposed to COM | |||
|
|||
[assembly: Guid("81591123-786f-44c8-b3fa-2dc3ed0155ee")] |
This file contains 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
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,34 @@ | |||
// ============================================================================== | |||
// | |||
// RealDimensions Software, LLC - Copyright © 2012 - Present - Released under the Apache 2.0 License | |||
// | |||
// Copyright 2007-2008 The Apache Software Foundation. | |||
// | |||
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use | |||
// this file except in compliance with the License. You may obtain a copy of the | |||
// License at | |||
// | |||
// http://www.apache.org/licenses/LICENSE-2.0 | |||
// | |||
// Unless required by applicable law or agreed to in writing, software distributed | |||
// under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR | |||
// CONDITIONS OF ANY KIND, either express or implied. See the License for the | |||
// specific language governing permissions and limitations under the License. | |||
// ============================================================================== | |||
|
|||
namespace LoggingExtensions.Sample.NLog | |||
{ | |||
|
|||
/// <summary> | |||
/// Make sure this is added to a console x86 project (not Client Profile). Set the startup object to SampleRun. Take a look at the logging folder afterwards. | |||
/// </summary> | |||
public class SampleRun | |||
{ | |||
private static void Main(string[] args) | |||
{ | |||
LoggingExtensions.Logging.Log.InitializeWith<LoggingExtensions.NLog.NLogLog>(); | |||
|
|||
"Main".Log().Info(() => "This is a logging message"); | |||
} | |||
} | |||
} |
This file contains 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
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,34 @@ | |||
// ============================================================================== | |||
// | |||
// RealDimensions Software, LLC - Copyright © 2012 - Present - Released under the Apache 2.0 License | |||
// | |||
// Copyright 2007-2008 The Apache Software Foundation. | |||
// | |||
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use | |||
// this file except in compliance with the License. You may obtain a copy of the | |||
// License at | |||
// | |||
// http://www.apache.org/licenses/LICENSE-2.0 | |||
// | |||
// Unless required by applicable law or agreed to in writing, software distributed | |||
// under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR | |||
// CONDITIONS OF ANY KIND, either express or implied. See the License for the | |||
// specific language governing permissions and limitations under the License. | |||
// ============================================================================== | |||
|
|||
namespace $rootnamespace$ | |||
{ | |||
|
|||
/// <summary> | |||
/// Make sure this is added to a console x86 project (not Client Profile). Set the startup object to SampleRun. Take a look at the logging folder afterwards. | |||
/// </summary> | |||
public class SampleRun | |||
{ | |||
private static void Main(string[] args) | |||
{ | |||
LoggingExtensions.Logging.Log.InitializeWith<LoggingExtensions.NLog.NLogLog>(); | |||
|
|||
"Main".Log().Info(() => "This is a logging message"); | |||
} | |||
} | |||
} |
This file contains 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
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,34 @@ | |||
<?xml version="1.0"?> | |||
<configuration> | |||
<configSections> | |||
<section name="nlog" type="NLog.Config.ConfigSectionHandler, NLog"/> | |||
</configSections> | |||
<nlog> | |||
<targets> | |||
<target name="console" type="Console" | |||
layout="${message}" | |||
/> | |||
<target name="file" type="AsyncWrapper" | |||
queueLimit="5000" | |||
overflowAction="Discard"> | |||
<target type="File" | |||
fileName="${basedir}/logs/this.Log-NLog.Sample.log" | |||
layout="${longdate} ${threadid} [${level:uppercase=true}] ${message}" | |||
/> | |||
</target> | |||
<target name="errorSmtp" type="Mail" | |||
layout="${longdate} ${threadid} [${level:uppercase=true}] ${logger} - ${message}" | |||
subject="this.Log Sample Console Errors - LOCAL DEBUG" | |||
to="noone@noreply.org" | |||
from="this.Log.sample@noreply.org" | |||
smtpServer="localhost" | |||
/> | |||
</targets> | |||
|
|||
<rules> | |||
<logger name="*" minlevel="Debug" writeTo="file" /> | |||
<logger name="*" minlevel="Debug" writeTo="console" /> | |||
<logger name="*" minlevel="Error" writeTo="errorSmtp" /> | |||
</rules> | |||
</nlog> | |||
</configuration> |
This file contains 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
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,6 @@ | |||
<?xml version="1.0" encoding="utf-8"?> | |||
<packages> | |||
<package id="NLog" version="2.0.0.2000" targetFramework="net40" /> | |||
<package id="this.Log" version="0.0.1.0" targetFramework="net40-Client" /> | |||
<package id="this.Log-NLog" version="0.0.1.0" targetFramework="net40-Client" /> | |||
</packages> |
This file contains 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
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,27 @@ | |||
<?xml version="1.0"?> | |||
<package> | |||
<metadata> | |||
<id>this.Log-NLog.Sample</id> | |||
<version>0.0.1.0</version> | |||
<title>this.Log Logging Extension (NLog Plugin) SAMPLE</title> | |||
<authors>RealDimensions Software, LLC</authors> | |||
<owners>Rob Reynolds</owners> | |||
<projectUrl>https://github.com/ferventcoder/this.Log</projectUrl> | |||
<licenseUrl>https://raw.github.com/ferventcoder/this.Log/master/LICENSE</licenseUrl> | |||
<requireLicenseAcceptance>false</requireLicenseAcceptance> | |||
<summary>this.Log-NLog.Sample - this.Log logging extension using NLog</summary> | |||
<description>this.Log-NLog.Sample is a sample of how to use the NLog plugin to this.Log logging extension.</description> | |||
<releaseNotes> | |||
</releaseNotes> | |||
<copyright>Copyright 2012</copyright> | |||
<tags>logging log this.Log NLog sample</tags> | |||
<dependencies> | |||
<dependency id="this.Log-NLog" version="0.0.1.0" /> | |||
</dependencies> | |||
</metadata> | |||
<files> | |||
<file src="SampleRun.cs.pp" target="content" /> | |||
<file src="app.config.transform" target="content" /> | |||
<file src="web.config.transform" target="content" /> | |||
</files> | |||
</package> |
This file contains 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
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,34 @@ | |||
<?xml version="1.0"?> | |||
<configuration> | |||
<configSections> | |||
<section name="nlog" type="NLog.Config.ConfigSectionHandler, NLog"/> | |||
</configSections> | |||
<nlog> | |||
<targets> | |||
<target name="console" type="Console" | |||
layout="${message}" | |||
/> | |||
<target name="file" type="AsyncWrapper" | |||
queueLimit="5000" | |||
overflowAction="Discard"> | |||
<target type="File" | |||
fileName="${basedir}/logs/this.Log-NLog.Sample.log" | |||
layout="${longdate} ${threadid} [${level:uppercase=true}] ${message}" | |||
/> | |||
</target> | |||
<target name="errorSmtp" type="Mail" | |||
layout="${longdate} ${threadid} [${level:uppercase=true}] ${logger} - ${message}" | |||
subject="this.Log Sample Console Errors - LOCAL DEBUG" | |||
to="noone@noreply.org" | |||
from="this.Log.sample@noreply.org" | |||
smtpServer="localhost" | |||
/> | |||
</targets> | |||
|
|||
<rules> | |||
<logger name="*" minlevel="Debug" writeTo="file" /> | |||
<logger name="*" minlevel="Debug" writeTo="console" /> | |||
<logger name="*" minlevel="Error" writeTo="errorSmtp" /> | |||
</rules> | |||
</nlog> | |||
</configuration> |
This file contains 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
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,56 @@ | |||
' ============================================================================== | |||
' | |||
' RealDimensions Software, LLC - Copyright © 2012 - Present - Released under the Apache 2.0 License | |||
' | |||
' Copyright 2007-2008 The Apache Software Foundation. | |||
' | |||
' Licensed under the Apache License, Version 2.0 (the "License"); you may not use | |||
' this file except in compliance with the License. You may obtain a copy of the | |||
' License at | |||
' | |||
' http://www.apache.org/licenses/LICENSE-2.0 | |||
' | |||
' Unless required by applicable law or agreed to in writing, software distributed | |||
' under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR | |||
' CONDITIONS OF ANY KIND, either express or implied. See the License for the | |||
' specific language governing permissions and limitations under the License. | |||
' ============================================================================== | |||
|
|||
Imports System.Collections.Concurrent | |||
Imports System.Runtime.CompilerServices | |||
Imports LoggingExtensions.Logging | |||
|
|||
''' <summary> | |||
''' Extensions to help make logging awesome - this should be installed into the root namespace of your application | |||
''' </summary> | |||
Public Module LogExtensions | |||
|
|||
''' <summary> | |||
''' Concurrent dictionary that ensures only one instance of a logger for a type. | |||
''' </summary> | |||
Private ReadOnly _dictionary As ConcurrentDictionary(Of String, ILog) = New ConcurrentDictionary(Of String, ILog) | |||
|
|||
''' <summary> | |||
''' Gets the logger for the type indicated. | |||
''' </summary> | |||
''' <typeparam name="T"></typeparam> | |||
''' <param name="type">The type to get the logger for.</param> | |||
''' <returns>Instance of a logger for the object.</returns> | |||
<Extension()> | |||
Public Function Log(Of T)(type As T) As ILog | |||
Dim objectName As String = GetType(T).FullName | |||
|
|||
Return Log(objectName) | |||
End Function | |||
|
|||
''' <summary> | |||
''' Gets the logger for the specified object name. | |||
''' </summary> | |||
''' <param name="objectName">Either use the fully qualified object name or the short. If used with Log(Of T)() you must use the fully qualified object name"/></param> | |||
''' <returns>Instance of a logger for the object.</returns> | |||
<Extension()> | |||
Public Function Log(objectName As String) As ILog | |||
Return _dictionary.GetOrAdd(objectName, Function(name) (LoggingExtensions.Logging.Log.GetLoggerFor(name))) | |||
End Function | |||
|
|||
End Module |
15 changes: 15 additions & 0 deletions
15
LoggingExtensions.NLog.VB.Sample/My Project/AssemblyInfo.vb
This file contains 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
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,15 @@ | |||
Imports System.Reflection | |||
Imports 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. | |||
|
|||
' Review the values of the assembly attributes | |||
|
|||
<Assembly: AssemblyTitle("this.Log-log4net.Sample.VB")> | |||
<Assembly: AssemblyDescription("")> | |||
<Assembly: AssemblyProduct("this.Log-log4net.Sample.VB")> | |||
|
|||
'The following GUID is for the ID of the typelib if this project is exposed to COM | |||
<Assembly: Guid("e779a01c-5479-4156-8d66-a146a9566366")> |
This file contains 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
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,13 @@ | |||
Public Module SampleRun | |||
|
|||
''' <summary> | |||
''' The main entry point for the application. | |||
''' </summary> | |||
Public Sub Main(ByVal args() As String) | |||
LoggingExtensions.Logging.Log.InitializeWith(Of LoggingExtensions.NLog.NLogLog)() | |||
|
|||
Dim test As New TestClass() | |||
test.Noop() | |||
End Sub | |||
|
|||
End Module |
This file contains 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
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,13 @@ | |||
Public Module SampleRun | |||
|
|||
''' <summary> | |||
''' The main entry point for the application. | |||
''' </summary> | |||
Public Sub Main(ByVal args() As String) | |||
LoggingExtensions.Logging.Log.InitializeWith(Of LoggingExtensions.NLog.NLogLog)() | |||
Dim test As New TestClass() | |||
test.Noop() | |||
End Sub | |||
End Module |
Oops, something went wrong.