diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..bdb0cab --- /dev/null +++ b/.gitattributes @@ -0,0 +1,17 @@ +# Auto detect text files and perform LF normalization +* text=auto + +# Custom for Visual Studio +*.cs diff=csharp + +# Standard to msysgit +*.doc diff=astextplain +*.DOC diff=astextplain +*.docx diff=astextplain +*.DOCX diff=astextplain +*.dot diff=astextplain +*.DOT diff=astextplain +*.pdf diff=astextplain +*.PDF diff=astextplain +*.rtf diff=astextplain +*.RTF diff=astextplain diff --git a/Build.ps1 b/Build.ps1 new file mode 100644 index 0000000..243f86a --- /dev/null +++ b/Build.ps1 @@ -0,0 +1,94 @@ +param( + [String] $majorMinor = "5.5", # 5.5 + [String] $patch = "0", # $env:APPVEYOR_BUILD_VERSION + [String] $customLogger = "", # C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll + [Switch] $notouch, + [String] $project = "ReflectSoftware.Insight.Extensions.Log4Net" +) + +function Set-AssemblyVersions($informational, $assembly) +{ + (Get-Content assets/VersionInfo.cs) | + ForEach-Object { $_ -replace """1.0.0.0""", """$assembly""" } | + ForEach-Object { $_ -replace """1.0.0""", """$informational""" } | + ForEach-Object { $_ -replace """1.1.1.1""", """$($informational).0""" } | + Set-Content assets/VersionInfo.cs +} + +function Install-NuGetPackages($solution) +{ + nuget restore $solution +} + +function Invoke-MSBuild($solution, $customLogger) +{ + if ($customLogger) + { + msbuild "$solution" /verbosity:minimal /p:Configuration=Release /logger:"$customLogger" + } + else + { + msbuild "$solution" /verbosity:minimal /p:Configuration=Release + } +} + +function Invoke-NuGetPackProj($csproj) +{ + nuget pack -Prop Configuration=Release -Symbols $csproj +} + +function Invoke-NuGetPackSpec($nuspec, $version) +{ + nuget pack $nuspec -Version $version -OutputDirectory ..\..\ +} + +function Invoke-NuGetPack($version) +{ + ls src/**/*.csproj | + Where-Object { -not ($_.Name -like "*net40*") } | + ForEach-Object { Invoke-NuGetPackProj $_ } +} + +function Invoke-Build($project, $majorMinor, $patch, $customLogger, $notouch) +{ + $solution2 = "$project 2.0.sln" + $solution4 = "$project 4.0.sln" + $solution45 = "$project 4.5.sln" + + $package="$majorMinor.$patch" + + Write-Output "$project $package" + + if (-not $notouch) + { + $assembly = "$majorMinor.0.0" + + Write-Output "Assembly version will be set to $assembly" + Set-AssemblyVersions $package $assembly + } + + Install-NuGetPackages $solution45 + Invoke-MSBuild $solution45 $customLogger + + Install-NuGetPackages $solution4 + Invoke-MSBuild $solution4 $customLogger + + Install-NuGetPackages $solution2 + Invoke-MSBuild $solution2 $customLogger + + Invoke-NuGetPack $package +} + +$ErrorActionPreference = "Stop" + +if (-not $sln) +{ + $slnfull = ls *.sln | + Where-Object { -not ($_.Name -like "*net40*") } | + Select -first 1 + + $sln = $slnfull.BaseName +} + +Invoke-Build $project $majorMinor $patch $customLogger $notouch + diff --git a/CHANGES.md b/CHANGES.md new file mode 100644 index 0000000..92528f5 --- /dev/null +++ b/CHANGES.md @@ -0,0 +1,5 @@ +## Change Log ## + +#### Version 5.5 #### + + * Moved from [CodePlex](http://insightextensions.codeplex.com/ "CodePlex") \ No newline at end of file diff --git a/LICENSE.md b/LICENSE.md new file mode 100644 index 0000000..ae532e4 --- /dev/null +++ b/LICENSE.md @@ -0,0 +1,28 @@ +Microsoft Public License (Ms-PL) + +This license governs use of the accompanying software. If you use the software, you accept this license. If you do not accept the license, do not use the software. +1.Definitions + +The terms "reproduce," "reproduction," "derivative works," and "distribution" have the same meaning here as under U.S. copyright law. + +A "contribution" is the original software, or any additions or changes to the software. + +A "contributor" is any person that distributes its contribution under this license. + +"Licensed patents" are a contributor's patent claims that read directly on its contribution. +1.Grant of Rights + +(A) Copyright Grant- Subject to the terms of this license, including the license conditions and limitations in section 3, each contributor grants you a non-exclusive, worldwide, royalty-free copyright license to reproduce its contribution, prepare derivative works of its contribution, and distribute its contribution or any derivative works that you create. + +(B) Patent Grant- Subject to the terms of this license, including the license conditions and limitations in section 3, each contributor grants you a non-exclusive, worldwide, royalty-free license under its licensed patents to make, have made, use, sell, offer for sale, import, and/or otherwise dispose of its contribution in the software or derivative works of the contribution in the software. +1.Conditions and Limitations + +(A) No Trademark License- This license does not grant you rights to use any contributors' name, logo, or trademarks. + +(B) If you bring a patent claim against any contributor over patents that you claim are infringed by the software, your patent license from such contributor to the software ends automatically. + +(C) If you distribute any portion of the software, you must retain all copyright, patent, trademark, and attribution notices that are present in the software. + +(D) If you distribute any portion of the software in source code form, you may do so only under this license by including a complete copy of this license with your distribution. If you distribute any portion of the software in compiled or object code form, you may only do so under a license that complies with this license. + +(E) The software is licensed "as-is." You bear the risk of using it. The contributors give no express warranties, guarantees or conditions. You may have additional consumer rights under your local laws which this license cannot change. To the extent permitted under your local laws, the contributors exclude the implied warranties of merchantability, fitness for a particular purpose and non-infringement. diff --git a/README.md b/README.md new file mode 100644 index 0000000..7def60b --- /dev/null +++ b/README.md @@ -0,0 +1,30 @@ +# ReflectInsight-Extensions-Log4Net + +[![Build status](https://img.shields.io/appveyor/ci/reflectsoftware/reflectinsight-extensions-log4net.svg)](https://ci.appveyor.com/project/reflectsoftware/reflectinsight-extensions-log4net) +[![Release](https://img.shields.io/github/release/reflectsoftware/reflectinsight-extensions-log4net.svg)](https://github.com/reflectsoftware/reflectinsight-extensions-log4net/releases/latest) +[![NuGet](https://img.shields.io/nuget/dt/reflectsoftware.insight.extensions.log4net.svg)](http://www.nuget.org/packages/ReflectSoftware.Insight.Extensions.Log4net/) +[![Stars](https://img.shields.io/github/stars/reflectsoftware/reflectinsight-extensions-log4net.svg)](https://github.com/reflectsoftware/reflectinsight-extensions-log4net/stargazers) + +## Overview ## + +We've added support for the Log4net appender. This allows you to leverage your current investment in log4net, but leverage the power and flexibility that comes with the ReflectInsight viewer. You can view your log4net messages in realtime, in a rich viewer that allows you to filter out and search for what really matters to you. + + The log4net extension supports Log4net v1.2.11.0. However if you need to support an older version, then you will need to download the ReflectInsight Logging Extensions Library from GitHub. You can then reference and rebuild the extension against a specific release of the log4net dll. + +## Benefits of ReflectInsight Extensions ## + +The benefits to using the Insight Extensions is that you can easily and quickly add them to your applicable with little effort and then use the ReflectInsight Viewer to view your logging in real-time, allowing you to filter, search, navigate and see the details of your logged messages. + +## Getting Started + +Coming soon... + +## Additional Resources + +[Documentation](https://reflectsoftware.atlassian.net/wiki/display/RI5/ReflectInsight+5+documentation) + +[Knowledge Base](http://reflectsoftware.uservoice.com/knowledgebase) + +[Submit User Feedback](http://reflectsoftware.uservoice.com/forums/158277-reflectinsight-feedback) + +[Contact Support](support@reflectsoftware.com) \ No newline at end of file diff --git a/ReflectSoftware.Insight.Extensions.Log4Net 2.0.sln b/ReflectSoftware.Insight.Extensions.Log4Net 2.0.sln new file mode 100644 index 0000000..b6f359e --- /dev/null +++ b/ReflectSoftware.Insight.Extensions.Log4Net 2.0.sln @@ -0,0 +1,30 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 2013 +VisualStudioVersion = 12.0.31101.0 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "_Solution Items", "_Solution Items", "{42B0F2D4-228B-4E1B-B81C-685CEE15D2E4}" + ProjectSection(SolutionItems) = preProject + Build.ps1 = Build.ps1 + CHANGES.md = CHANGES.md + LICENSE.md = LICENSE.md + README.md = README.md + EndProjectSection +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ReflectSoftware.Insight.Extensions.Log4net 2.0", "src\ReflectSoftware.Insight.Extensions.Log4net 2.0.csproj", "{A7A9040C-826F-4CF6-8D70-288DFF88ADE1}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {A7A9040C-826F-4CF6-8D70-288DFF88ADE1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A7A9040C-826F-4CF6-8D70-288DFF88ADE1}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A7A9040C-826F-4CF6-8D70-288DFF88ADE1}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A7A9040C-826F-4CF6-8D70-288DFF88ADE1}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/ReflectSoftware.Insight.Extensions.Log4Net 4.0.sln b/ReflectSoftware.Insight.Extensions.Log4Net 4.0.sln new file mode 100644 index 0000000..7bf37f0 --- /dev/null +++ b/ReflectSoftware.Insight.Extensions.Log4Net 4.0.sln @@ -0,0 +1,30 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 2013 +VisualStudioVersion = 12.0.31101.0 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "_Solution Items", "_Solution Items", "{42B0F2D4-228B-4E1B-B81C-685CEE15D2E4}" + ProjectSection(SolutionItems) = preProject + Build.ps1 = Build.ps1 + CHANGES.md = CHANGES.md + LICENSE.md = LICENSE.md + README.md = README.md + EndProjectSection +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ReflectSoftware.Insight.Extensions.Log4net 4.0", "src\ReflectSoftware.Insight.Extensions.Log4net 4.0.csproj", "{2CFB2E87-1C47-4E78-ADDC-99F246471FC1}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {2CFB2E87-1C47-4E78-ADDC-99F246471FC1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {2CFB2E87-1C47-4E78-ADDC-99F246471FC1}.Debug|Any CPU.Build.0 = Debug|Any CPU + {2CFB2E87-1C47-4E78-ADDC-99F246471FC1}.Release|Any CPU.ActiveCfg = Release|Any CPU + {2CFB2E87-1C47-4E78-ADDC-99F246471FC1}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/ReflectSoftware.Insight.Extensions.Log4Net 4.5.sln b/ReflectSoftware.Insight.Extensions.Log4Net 4.5.sln new file mode 100644 index 0000000..0a33910 --- /dev/null +++ b/ReflectSoftware.Insight.Extensions.Log4Net 4.5.sln @@ -0,0 +1,30 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 2013 +VisualStudioVersion = 12.0.30501.0 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ReflectSoftware.Insight.Extensions.Log4net 4.5", "src\ReflectSoftware.Insight.Extensions.Log4net 4.5.csproj", "{2CFB2E87-1C47-4E78-ADDC-99F246471FC1}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "_Solution Items", "_Solution Items", "{5083DB16-D99D-48E4-8B72-90F9AFD54F7C}" + ProjectSection(SolutionItems) = preProject + Build.ps1 = Build.ps1 + CHANGES.md = CHANGES.md + LICENSE.md = LICENSE.md + README.md = README.md + EndProjectSection +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {2CFB2E87-1C47-4E78-ADDC-99F246471FC1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {2CFB2E87-1C47-4E78-ADDC-99F246471FC1}.Debug|Any CPU.Build.0 = Debug|Any CPU + {2CFB2E87-1C47-4E78-ADDC-99F246471FC1}.Release|Any CPU.ActiveCfg = Release|Any CPU + {2CFB2E87-1C47-4E78-ADDC-99F246471FC1}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/assets/ReflectSoftware.Public.snk b/assets/ReflectSoftware.Public.snk new file mode 100644 index 0000000..8574a2a Binary files /dev/null and b/assets/ReflectSoftware.Public.snk differ diff --git a/assets/VersionInfo.cs b/assets/VersionInfo.cs new file mode 100644 index 0000000..ccf1420 --- /dev/null +++ b/assets/VersionInfo.cs @@ -0,0 +1,12 @@ +using System.Reflection; + +[assembly: AssemblyCompany("ReflectSoftware Inc.")] +[assembly: AssemblyProduct("ReflectSoftware.Insight.Extensions Library")] +[assembly: AssemblyCopyright("© 2014 ReflectSoftware Inc. All rights reserved.")] +[assembly: AssemblyDescription("Provides extensions to the ReflectInsight Logging Framework")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyVersion("5.5.0.1500")] +[assembly: AssemblyFileVersion("5.5.0.1500")] +[assembly: AssemblyInformationalVersion("5.5.0")] diff --git a/src/Log4netAppender.cs b/src/Log4netAppender.cs new file mode 100644 index 0000000..af44cf9 --- /dev/null +++ b/src/Log4netAppender.cs @@ -0,0 +1,229 @@ +/****************************************************************************** +* +* Copyright (c) ReflectSoftware, Inc. All rights reserved. +* +* See License.rtf in the solution root for license information. +* +******************************************************************************/ +using System; +using System.Text; +using System.Reflection; + +using log4net.Core; +using log4net.Appender; + +using ReflectSoftware.Insight; +using ReflectSoftware.Insight.Common; + +using RI.Utils.ExceptionManagement; + +namespace ReflectSoftware.Insight.Extensions.Log4net +{ + ///------------------------------------------------------------------------ + /// Redirect all log4net messages to ReflectInsight. + /// + ///------------------------------------------------------------------------ + public class LogAppender : AppenderSkeleton + { + class ActiveStates + { + public ReflectInsight RI { get; set; } + public Boolean DisplayLevel { get; set; } + public Boolean DisplayLocation { get; set; } + } + + static private readonly String FLine; + static private readonly MethodInfo FSendInternalErrorMethodInfo; + + private ActiveStates CurrentActiveStates { get; set; } + protected String InstanceName { get; set; } + protected String DisplayLevel { get; set; } + protected String DisplayLocation { get; set; } + + ///-------------------------------------------------------------------- + static LogAppender() + { + FLine = String.Format("{0,40}", String.Empty).Replace(" ", "-"); + FSendInternalErrorMethodInfo = typeof(ReflectInsight).GetMethod("SendInternalError", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.InvokeMethod); + } + ///-------------------------------------------------------------------- + /// Initializes a new instance of the class. + /// Empty default constructor. + ///-------------------------------------------------------------------- + public LogAppender() + { + InstanceName = String.Empty; + DisplayLevel = String.Empty; + DisplayLocation = String.Empty; + CurrentActiveStates = new ActiveStates(); + + RIEventManager.OnServiceConfigChange += DoOnConfigChange; + } + ///-------------------------------------------------------------------- + protected override void OnClose() + { + RIEventManager.OnServiceConfigChange -= DoOnConfigChange; + base.OnClose(); + } + ///-------------------------------------------------------------------- + private void DoOnConfigChange() + { + OnConfigChange(); + } + ///-------------------------------------------------------------------- + /// Activates the options. + /// + /// + /// + /// This is part of the delayed object activation + /// scheme. The method must + /// be called on this object after the configuration properties have been set. Until + /// is called this object + /// is in an undefined state and must not be used. + /// + /// + /// If any of the configuration properties are modified then + /// must be called again. + /// + /// + /// + /// + ///-------------------------------------------------------------------- + public override void ActivateOptions() + { + base.ActivateOptions(); + OnConfigChange(); + } + ///-------------------------------------------------------------------- + private void OnConfigChange() + { + try + { + lock (this) + { + ActiveStates states = new ActiveStates(); + states.RI = RILogManager.Get(InstanceName) ?? RILogManager.Default; + states.DisplayLevel = String.Compare(DisplayLevel.ToLower().Trim(), "true", false) == 0; + states.DisplayLocation = String.Compare(DisplayLocation.ToLower().Trim() , "true", false) == 0; + + CurrentActiveStates = states; + } + } + catch (Exception ex) + { + RIExceptionManager.Publish(ex, "Failed during: LogAppender.OnConfigChange()"); + } + } + ///-------------------------------------------------------------------- + static private Boolean SendInternalError(ReflectInsight ri, MessageType mType, Exception ex) + { + return (Boolean)FSendInternalErrorMethodInfo.Invoke(ri, new object[] { mType, ex }); + } + ///-------------------------------------------------------------------- + static private void SendMessage(ActiveStates states, MessageType mType, LoggingEvent loggingEvent) + { + try + { + // build details + StringBuilder sb = null; + + if (loggingEvent.ExceptionObject != null) + { + sb = new StringBuilder(); + sb.Append(ExceptionBasePublisher.ConstructIndentedMessage(loggingEvent.ExceptionObject)); + sb.AppendLine(); + sb.AppendLine(); + } + + if (states.DisplayLevel || states.DisplayLocation) + { + sb = sb ?? new StringBuilder(); + + sb.AppendLine("Log4net Details:"); + sb.AppendLine(FLine); + + if (states.DisplayLevel) + sb.AppendFormat("{0,10}: {1}{2}", "Level", loggingEvent.Level.DisplayName, Environment.NewLine); + + if (states.DisplayLocation) + { + sb.AppendFormat("{0,10}: {1}{2}", "ClassName", loggingEvent.LocationInformation.ClassName, Environment.NewLine); + sb.AppendFormat("{0,10}: {1}{2}", "MethodName", loggingEvent.LocationInformation.MethodName, Environment.NewLine); + sb.AppendFormat("{0,10}: {1}{2}", "FileName", loggingEvent.LocationInformation.FileName, Environment.NewLine); + sb.AppendFormat("{0,10}: {1}{2}", "LineNumber", loggingEvent.LocationInformation.LineNumber, Environment.NewLine); + sb.AppendFormat("{0,10}: {1}{2}", "FullInfo", loggingEvent.LocationInformation.FullInfo, Environment.NewLine); + } + } + + String details = sb != null ? sb.ToString() : null; + states.RI.Send(mType, loggingEvent.RenderedMessage, details); + } + catch (Exception ex) + { + if (!SendInternalError(states.RI, mType, ex)) throw; + } + } + ///-------------------------------------------------------------------- + protected override void Append(LoggingEvent loggingEvent) + { + ActiveStates states = CurrentActiveStates; + MessageType mType = MessageType.SendMessage; + + if (loggingEvent.Level == Level.Info) + { + if (loggingEvent.RenderedMessage.StartsWith("[Enter]")) + { + states.RI.EnterMethod(loggingEvent.RenderedMessage.Replace("[Enter]", String.Empty)); + return; + } + if (loggingEvent.RenderedMessage.StartsWith("[Exit]")) + { + states.RI.ExitMethod(loggingEvent.RenderedMessage.Replace("[Exit]", String.Empty)); + return; + } + + mType = MessageType.SendInformation; + } + else if (loggingEvent.Level == Level.Trace) + { + mType = MessageType.SendTrace; + } + else if (loggingEvent.Level == Level.Debug + || loggingEvent.Level == Level.Log4Net_Debug) + { + mType = MessageType.SendDebug; + } + else if (loggingEvent.Level == Level.Warn) + { + mType = MessageType.SendWarning; + } + else if (loggingEvent.Level == Level.Error + || loggingEvent.Level == Level.Alert + || loggingEvent.Level == Level.Emergency + || loggingEvent.Level == Level.Severe) + { + mType = MessageType.SendError; + } + else if (loggingEvent.Level == Level.Fatal + || loggingEvent.Level == Level.Critical) + { + mType = MessageType.SendFatal; + } + else if (loggingEvent.Level == Level.Notice) + { + mType = MessageType.SendNote; + } + else if (loggingEvent.Level == Level.Verbose) + { + mType = MessageType.SendVerbose; + } + + SendMessage(states, mType, loggingEvent); + } + ///-------------------------------------------------------------------- + protected override bool RequiresLayout + { + get { return false; } + } + } +} diff --git a/src/LogLinqToSql.cs b/src/LogLinqToSql.cs new file mode 100644 index 0000000..64cff32 --- /dev/null +++ b/src/LogLinqToSql.cs @@ -0,0 +1,159 @@ +using System; +using System.Collections; +using System.Text; +using System.Threading; +using System.IO; + +using RI.Utils.MemoryCache; + +using ReflectSoftware.Insight; +using ReflectSoftware.Insight.Common; + +namespace ReflectSoftware.Insight.Extensions.LogLinq +{ + internal class LogLinqToSqlRequest : IRequestObject + { + public StringBuilder StrBuilder; + public UInt32 RequestId { get; private set; } + + //--------------------------------------------------------------------- + public void Attached(UInt32 requestId) + { + RequestId = requestId; + StrBuilder = new StringBuilder(); + } + //--------------------------------------------------------------------- + public void Detached() + { + } + //--------------------------------------------------------------------- + public void Reset() + { + } + } + + /// + /// Redirect all Linq to Sql messages to ReflectInsight + /// + public class LogLinqToSql: TextWriter + { + static private RequestObjectManager FRequestObjectManager; + + protected String FLabel; + protected Boolean FOwnsRI; + protected ReflectInsight FReflectInsight; + + //--------------------------------------------------------------------- + static LogLinqToSql() + { + FRequestObjectManager = new RequestObjectManager(); + } + //--------------------------------------------------------------------- + public LogLinqToSql(String label, ReflectInsight ri) + { + FLabel = label; + FReflectInsight = ri; + FOwnsRI = ri != null; + + OnConfigChange(); + RIEventManager.OnServiceConfigChange += DoOnConfigChange; + } + //--------------------------------------------------------------------- + public LogLinqToSql(String label): this(label, null) + { + } + //--------------------------------------------------------------------- + public LogLinqToSql(ReflectInsight ri): this(null, ri) + { + } + //--------------------------------------------------------------------- + public LogLinqToSql(): this(null, null) + { + } + //--------------------------------------------------------------------- + protected override void Dispose(bool disposing) + { + lock (this) + { + RIEventManager.OnServiceConfigChange -= DoOnConfigChange; + + if (FOwnsRI && FReflectInsight != null) + { + FReflectInsight.Dispose(); + FReflectInsight = null; + } + } + + base.Dispose(disposing); + } + //--------------------------------------------------------------------- + private void DoOnConfigChange() + { + OnConfigChange(); + } + //--------------------------------------------------------------------- + private void OnConfigChange() + { + try + { + lock (this) + { + if (!FOwnsRI) + { + String instanceName = ReflectInsightConfig.Settings.GetExtensionAttribute("logLinqToSql", "instance", "logLinqToSql"); + FReflectInsight = RILogManager.Get(instanceName) ?? RILogManager.Default; + + FRequestObjectManager.RequestDetachLifeSpan = GetRequestObjectLifeSpan(); + } + } + } + catch (Exception ex) + { + RIExceptionManager.Publish(ex, "Failed during: LogLinqToSql.OnConfigChange()"); + } + } + //--------------------------------------------------------------------------- + private Int32 GetRequestObjectLifeSpan() + { + Int32 requestLifeSpan = 10; + Int32.TryParse(ReflectInsightConfig.Settings.GetBaseRequestObjectAttribute("requestLifeSpan", "10"), out requestLifeSpan); + + return requestLifeSpan; + } + //--------------------------------------------------------------------------- + protected void AppendMessage(String message) + { + FRequestObjectManager.GetRequestObject().StrBuilder.Append(message); + } + //--------------------------------------------------------------------------- + protected String GetFullWriteMessage() + { + LogLinqToSqlRequest request = FRequestObjectManager.GetRequestObject(false); + if (request != null) + { + FRequestObjectManager.RemoveRequest(request); + return request.StrBuilder.ToString(); + } + + return String.Empty; + } + //--------------------------------------------------------------------- + public override void Write(Char[] buffer, Int32 index, Int32 count) + { + String line = new String(buffer, index, count); + if (line.Trim() != String.Empty) + { + AppendMessage(line); + return; + } + + line = GetFullWriteMessage(); + FReflectInsight.SendSQLString(FLabel ?? line, line); + } + //--------------------------------------------------------------------- + public override Encoding Encoding + { + get { return System.Text.Encoding.Default; } + } + } +} diff --git a/src/Properties/AssemblyInfo.cs b/src/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..9584b78 --- /dev/null +++ b/src/Properties/AssemblyInfo.cs @@ -0,0 +1,3 @@ +using System.Reflection; + +[assembly: AssemblyTitle("ReflectSoftware.Insight.Extensions.Log4net")] diff --git a/src/ReflectSoftware.Insight.Extensions.Log4net 2.0.csproj b/src/ReflectSoftware.Insight.Extensions.Log4net 2.0.csproj new file mode 100644 index 0000000..5827489 --- /dev/null +++ b/src/ReflectSoftware.Insight.Extensions.Log4net 2.0.csproj @@ -0,0 +1,117 @@ + + + + Debug + AnyCPU + 9.0.30729 + 2.0 + {A7A9040C-826F-4CF6-8D70-288DFF88ADE1} + Library + Properties + ReflectSoftware.Insight.Extensions.Log4net + ReflectSoftware.Insight.Extensions.Log4net + v3.5 + 512 + SAK + SAK + SAK + SAK + true + ReflectSoftware.Public.snk + + + 3.5 + + http://localhost/ReflectSoftware.Insight.Extensions/ + true + Web + true + Foreground + 7 + Days + false + false + true + 0 + 1.0.0.%2a + true + false + true + + ..\ + true + + + false + none + false + ..\Build\Libraries\NET2.0\ + TRACE;DEBUG;NET20 + prompt + 4 + AllRules.ruleset + false + + + none + true + ..\Build\Libraries\NET2.0\ + TRACE;NET20 + prompt + 4 + AllRules.ruleset + false + false + + + + False + ..\packages\log4net.2.0.3\lib\net35-full\log4net.dll + + + ..\packages\ReflectSoftware.Insight.5.4.0\lib\net20\ReflectSoftware.Insight.dll + + + + 3.5 + + + + + + + Properties\VersionInfo.cs + + + + + + + False + .NET Framework 3.5 SP1 Client Profile + false + + + False + .NET Framework 3.5 SP1 + true + + + False + Windows Installer 3.1 + true + + + + + + + + + \ No newline at end of file diff --git a/src/ReflectSoftware.Insight.Extensions.Log4net 4.0.csproj b/src/ReflectSoftware.Insight.Extensions.Log4net 4.0.csproj new file mode 100644 index 0000000..9af59dc --- /dev/null +++ b/src/ReflectSoftware.Insight.Extensions.Log4net 4.0.csproj @@ -0,0 +1,115 @@ + + + + Debug + AnyCPU + 9.0.30729 + 2.0 + {2CFB2E87-1C47-4E78-ADDC-99F246471FC1} + Library + Properties + ReflectSoftware.Insight.Extensions.Log4net + ReflectSoftware.Insight.Extensions.Log4net + v4.0 + 512 + SAK + SAK + SAK + SAK + true + ReflectSoftware.Public.snk + + + 3.5 + + http://localhost/ReflectSoftware.Insight.Extensions/ + true + Web + true + Foreground + 7 + Days + false + false + true + 0 + 1.0.0.%2a + true + false + true + + ..\ + true + + + false + none + false + ..\Build\Libraries\NET4.0\ + TRACE;DEBUG + prompt + 4 + AllRules.ruleset + false + + + none + true + ..\Build\Libraries\NET4.0\ + TRACE + prompt + 4 + AllRules.ruleset + false + false + + + + False + ..\packages\log4net.2.0.3\lib\net40-full\log4net.dll + + + ..\packages\ReflectSoftware.Insight.5.4.0\lib\net40\ReflectSoftware.Insight.dll + + + + + + + + + Properties\VersionInfo.cs + + + + + + + False + .NET Framework 3.5 SP1 Client Profile + false + + + False + .NET Framework 3.5 SP1 + true + + + False + Windows Installer 3.1 + true + + + + + + + + + \ No newline at end of file diff --git a/src/ReflectSoftware.Insight.Extensions.Log4net 4.5.csproj b/src/ReflectSoftware.Insight.Extensions.Log4net 4.5.csproj new file mode 100644 index 0000000..d060fb8 --- /dev/null +++ b/src/ReflectSoftware.Insight.Extensions.Log4net 4.5.csproj @@ -0,0 +1,117 @@ + + + + Debug + AnyCPU + 9.0.30729 + 2.0 + {2CFB2E87-1C47-4E78-ADDC-99F246471FC1} + Library + Properties + ReflectSoftware.Insight.Extensions.Log4net + ReflectSoftware.Insight.Extensions.Log4net + v4.5 + 512 + SAK + SAK + SAK + SAK + true + ReflectSoftware.Public.snk + + + 3.5 + + http://localhost/ReflectSoftware.Insight.Extensions/ + true + Web + true + Foreground + 7 + Days + false + false + true + 0 + 1.0.0.%2a + true + false + true + + ..\ + true + + + false + none + false + ..\Build\Libraries\NET4.5\ + TRACE;DEBUG + prompt + 4 + AllRules.ruleset + false + false + + + none + true + ..\Build\Libraries\NET4.5\ + TRACE + prompt + 4 + AllRules.ruleset + false + false + false + + + + False + ..\packages\log4net.2.0.3\lib\net40-full\log4net.dll + + + ..\packages\ReflectSoftware.Insight.5.4.0\lib\net45\ReflectSoftware.Insight.dll + + + + + + + + + Properties\VersionInfo.cs + + + + + + + False + .NET Framework 3.5 SP1 Client Profile + false + + + False + .NET Framework 3.5 SP1 + true + + + False + Windows Installer 3.1 + true + + + + + + + + + \ No newline at end of file diff --git a/src/ReflectSoftware.Insight.Extensions.Log4net.nuspec b/src/ReflectSoftware.Insight.Extensions.Log4net.nuspec new file mode 100644 index 0000000..2001321 --- /dev/null +++ b/src/ReflectSoftware.Insight.Extensions.Log4net.nuspec @@ -0,0 +1,42 @@ + + + + ReflectSoftware.Insight.Extensions.Log4net + 5.4.0 + ReflectSoftware.Insight.Extensions.Log4net + ReflectSoftware Inc. + ReflectSoftware Inc. + http://insightextensions.codeplex.com/license + http://insightextensions.codeplex.com + http://reflectsoftware.com/images/ri_logo_green.ico + false + We've added support for the Log4net appender. This allows you to leverage your current investment in log4net, but leverage the power and flexibility that comes with the ReflectInsight viewer. + +In order to use this extension you must have the ReflectInsight Viewer installed. Download and install the ReflectInsight Viewer from this location: + +http://www.ReflectSoftware.com/Public/Download.aspx + +You can view your log4net messages in realtime, in a rich viewer that allows you to filter out and search for what really matters to you. + ReflectInsight Log4net logging extention makes it easy to integrate ReflectInsight into your existing application logging infrastructure and leverage the power of the ReflectInsight log viewer. + The log4net extension supports Log4net v2.0.3. However if you need to support an older version, then you will need to download the ReflectInsight Logging Extensions Library from CodePlex. You can then reference and rebuild the extension against a specific release of the log4net dll. + +As of version 5.1 of the ReflectInsight NuGet Package, you are now required to manually add in the ReflectInsight configuration details that you may require. + +For help on configuration, please see our documentation on the website (https://insightextensions.codeplex.com/wikipage?title=Getting%20Started%20with%20Log4net%20Extension&referringTitle=Documentation) and/or the knowledge base articles on our UserVoice site (http://reflectsoftware.uservoice.com/knowledgebase). + © 2014 ReflectSoftware Inc. + Log4net Logging Extensions ReflectInsight Appender Log Tracing RabbitMQ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/ReflectSoftware.Public.snk b/src/ReflectSoftware.Public.snk new file mode 100644 index 0000000..8574a2a Binary files /dev/null and b/src/ReflectSoftware.Public.snk differ diff --git a/src/packages.config b/src/packages.config new file mode 100644 index 0000000..89bee07 --- /dev/null +++ b/src/packages.config @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/src/readme.txt b/src/readme.txt new file mode 100644 index 0000000..293cd90 --- /dev/null +++ b/src/readme.txt @@ -0,0 +1,40 @@ +REFLECTSOFTWARE INC. +REFLECTINSIGHT LOGGING LIBRARY +VERSION 5.4 + +RELEASE NOTES + +Version 5.4.0 +- Added auto save log file by file size +- Added support for overloading ConfigurationMode to avoid a local configuration file +- Minor bug fixes and enhancements + +Version 5.3.1 +- New message type SendMiniDumpFile +- New message type SendTypedCollection (renamed from SendEnumerable which is now deprecated) +- New message type SendString (can send String and StringBuilder objects, will also show NULL for null strings) +- XML documentation for methods +- Fine tuning and performance improvements +- Bug fixes + +Version 5.2.1 +- Performance improvements. +- Bug fixes. + +Version 5.2 +- New SendEnumeration message type. +- Performance improvements. +- Bug fixes. + +Version 5.1 +- This version of the library now requires ReflectInsight 5.1 to be installed for the Viewer to work. +- As of version 5.1 of the ReflectInsight NuGet Package, you are now required to manually add in the ReflectInsight configuration details that you may require. For help on configuration, please see our documentation on the website (http://reflectsoftware.com) or on our CodePlex site or from the knowledgebase articles on our UserVoice site (http://reflectsoftware.uservoice.com/knowledgebase). + +Documentation on CodePlex - Getting Started +https://insightextensions.codeplex.com/wikipage?title=Getting%20Started%20with%20Log4net%20Extension&referringTitle=Documentation + +Feedback and Support +http://reflectsoftware.uservoice.com/ + +ReflectSoftware +http://reflectsoftware.com \ No newline at end of file