rho24 / glimpse.nlog Goto Github PK
View Code? Open in Web Editor NEWPlugin for Glimpse showing NLog information
License: MIT License
Plugin for Glimpse showing NLog information
License: MIT License
Is see the plugin is build to an old version of NLog. I would recommend to build this to NLog 4.0.0.
Since NLog 4.0.0 the assembly version is stable so you can use NLog 4.x.y without any assembly redirect.
e.g. red for error
I was hoping I could use this Glimpse tab to view logs without having to download the log files from my web server. However, this tab only allows you to see log messages associated with a single request. Please make an option so we can see the entire log, similar to how Glimpse.Elmah shows the entire error history.
I think you should read this issue Glimpse/Glimpse#993 that I open in glimpse because I think this trace should be removed
try
{
timer = _timerStrategy();
}
catch (Exception e)
{
Trace.Write(e.ToString());
}
And I think this is causing System.StackOverflowException when exceptions happen in _timerStrategy() and when using NLog.NLogTraceListener in system.diagnostics section in web.config
I added this project to my build, but it didn't get picked up as I'm targeting 4.5.0 and the nuget package was against 4.5.1. I've incremented my project to 4.5.1 to be compatible but I wondered if it was necessary to be targeting 4.5.1 by default?
Nice work btw, although could do with some documentation, even if it is as simple as adding the nuget package (which didn't work first time for me due to above issue and a warning rather than an error due to no explicit usage).
Hi.
This target is listed at https://github.com/NLog/NLog/wiki/Targets but it lacks a proper how-to use/config.
Please add it, otherwise it should be removed from the wiki.
Hello,
When using Common.Loggin ILog.TraceFormat and ILog.Trace(Action), logs are displayed as key/value in glimpse instead of displaying the actual message.
Here's an example:
_log.Trace("This is a call to _log.Trace(string)");//Works as expected
_log.TraceFormat("This is a call to _log.TraceFormat");//problem
_log.Trace(l => l("This is a call to _log.Trace(Action<FormatMessageHandler>)"));//problem
Log file is as expected:
2018-01-10 10:42:09.2121|TRACE|18|Business.Infrastructure.CachingRepositoryDecorator|This is a call to _log.Trace(string)|
2018-01-10 10:42:09.2121|TRACE|18|Business.Infrastructure.CachingRepositoryDecorator|This is a call to _log.TraceFormat|
2018-01-10 10:42:09.2121|TRACE|18|Business.Infrastructure.CachingRepositoryDecorator|This is a call to _log.Trace(Action)|
But here is what is displayed in glimpse
A quick look at Common.Logging sources seams to indicate that the call to nlog are supposed to be the same, so i'm not sure where the problem comes from.
Here's the full text shown in that tab (formatted somewhat for readability):
System.IO.FileLoadException: Could not load file or assembly 'NLog, Version=2.0.1.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c' or one of its dependencies.
The located assembly's manifest definition does not match the assembly reference.
(Exception from HRESULT: 0x80131040) File name: 'NLog, Version=2.0.1.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c' at Glimpse.NLog.NLogTab.GetData(ITabContext context) at Glimpse.Core.Framework.GlimpseRuntime.ExecuteTabs(RuntimeEvent runtimeEvent)
=== Pre-bind state information ===
LOG: User = RECP\taugustine LOG: DisplayName = NLog, Version=2.0.1.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c (Fully-specified)
LOG: Appbase = file:///C:/@Kiln/MriApps/Solutions/Mri.Web.Mvc/
LOG: Initial PrivatePath = C:\@Kiln\MriApps\Solutions\Mri.Web.Mvc\bin Calling assembly : Glimpse.NLog, Version=1.3.0.0, Culture=neutral, PublicKeyToken=null. ===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\@Kiln\MriApps\Solutions\Mri.Web.Mvc\web.config
LOG: Using host configuration file: C:\Users\kevitt\Documents\IISExpress\config\aspnet.config
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Post-policy reference: NLog, Version=2.0.1.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c
LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/Temporary ASP.NET Files/root/d1b5fe9b/5adbda/NLog.DLL.
LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/Temporary ASP.NET Files/root/d1b5fe9b/5adbda/NLog/NLog.DLL.
LOG: Attempting download of new URL file:///C:/@Kiln/MriApps/Solutions/Mri.Web.Mvc/bin/NLog.DLL. WRN: Comparing the assembly name resulted in the mismatch: Build Number ERR: Failed to complete setup of assembly (hr = 0x80131040). Probing terminated.
I'm at a loss understanding why it seems to be trying to load version 2.0.1.0 of NLog as version 2.0.0.2000 is installed instead. I couldn't find any explicit references to the former version in any files in my project either.
e.g. Exception details
I see only empty nlog tab. At the same time I got udp notofication via log2console.
Should i specify any custom targets for glimpse?
Here is my nlog.config and web.config:
<?xml version="1.0" encoding="utf-8" ?>
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<targets>
<target name="udp" xsi:type="Chainsaw" address="udp4://localhost:7071" />
<target name="mail" xsi:type="Mail" html="true" subject="" body="${message}"
to=""
from=""
encoding="UTF-8"
enableSsl="false"
smtpUserName=""
smtpPassword=""
smtpAuthentication="Basic"
smtpServer=""
smtpPort="25" />
</targets>
<rules>
<logger name="*" minlevel="Trace" writeTo="udp" />
<!--<logger name="*" minlevel="Trace" writeTo="mail" />-->
<!--Trace, Debug, Info, Warn, Error, Fatal-->
</rules>
</nlog>
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
<section name="glimpse" type="Glimpse.Core.Configuration.Section, Glimpse.Core" />
<sectionGroup name="elmah">
<section name="security" requirePermission="false" type="Elmah.SecuritySectionHandler, Elmah" />
<section name="errorLog" requirePermission="false" type="Elmah.ErrorLogSectionHandler, Elmah" />
<section name="errorMail" requirePermission="false" type="Elmah.ErrorMailSectionHandler, Elmah" />
<section name="errorFilter" requirePermission="false" type="Elmah.ErrorFilterSectionHandler, Elmah" />
</sectionGroup>
<section name="glimpsePerformanceConfiguration" type="Glimpse.Performance.Config.GlimpsePerformanceConfiguration, Glimpse.Performance" />
</configSections>
<connectionStrings>
...
</connectionStrings>
<appSettings>
<add key="webpages:Version" value="2.0.0.0" />
<add key="webpages:Enabled" value="false" />
<add key="PreserveLoginUrl" value="true" />
<add key="ClientValidationEnabled" value="true" />
<add key="UnobtrusiveJavaScriptEnabled" value="true" />
<add key="elmah.mvc.disableHandler" value="false" />
<add key="elmah.mvc.disableHandleErrorFilter" value="false" />
<add key="elmah.mvc.requiresAuthentication" value="false" />
<add key="elmah.mvc.IgnoreDefaultRoute" value="false" />
<add key="elmah.mvc.allowedRoles" value="*" />
<add key="elmah.mvc.allowedUsers" value="*" />
<add key="elmah.mvc.route" value="elmah" />
</appSettings>
<system.web>
<caching>
<outputCacheSettings>
<outputCacheProfiles>
<!--<add name="CacheUsers" duration="604800" varyByParam="none" enabled="true" location="Any" />-->
<!--<add name="CacheUserPhotos" duration="2419200" varyByParam="userID, width, height" enabled="true" location="Any" />-->
</outputCacheProfiles>
</outputCacheSettings>
</caching>
<httpRuntime />
<compilation debug="true" targetFramework="4.0" />
<authentication mode="Windows" />
<pages controlRenderingCompatibilityVersion="4.0">
<namespaces>
<add namespace="System.Web.Helpers" />
<add namespace="System.Web.Mvc" />
<add namespace="System.Web.Mvc.Ajax" />
<add namespace="System.Web.Mvc.Html" />
<add namespace="System.Web.Optimization" />
<add namespace="System.Web.Routing" />
<add namespace="System.Web.WebPages" />
</namespaces>
</pages>
<identity impersonate="false" />
<httpModules>
<add name="ErrorLog" type="Elmah.ErrorLogModule, Elmah" />
<add name="ErrorMail" type="Elmah.ErrorMailModule, Elmah" />
<add name="ErrorFilter" type="Elmah.ErrorFilterModule, Elmah" />
<add name="Glimpse" type="Glimpse.AspNet.HttpModule, Glimpse.AspNet" />
</httpModules>
<httpHandlers>
<add path="glimpse.axd" verb="GET" type="Glimpse.AspNet.HttpHandler, Glimpse.AspNet" />
</httpHandlers>
</system.web>
<system.webServer>
<httpProtocol>
<customHeaders>
<clear />
<add name="X-UA-Compatible" value="IE=edge" />
<add name="Access-Control-Allow-Origin" value="*" />
<add name="Access-Control-Allow-Headers" value="Origin, X-Requested-With, Content-Type, Accept" />
</customHeaders>
</httpProtocol>
<modules>
<remove name="BundleModule" />
<add name="BundleModule" type="System.Web.Optimization.BundleModule" />
<add name="ErrorLog" type="Elmah.ErrorLogModule, Elmah" preCondition="managedHandler" />
<add name="ErrorMail" type="Elmah.ErrorMailModule, Elmah" preCondition="managedHandler" />
<add name="ErrorFilter" type="Elmah.ErrorFilterModule, Elmah" preCondition="managedHandler" />
<add name="Glimpse" type="Glimpse.AspNet.HttpModule, Glimpse.AspNet" preCondition="integratedMode" />
</modules>
<staticContent>
<mimeMap fileExtension=".coffee" mimeType="text/plain" />
<mimeMap fileExtension=".handlebars" mimeType="text/plain" />
</staticContent>
<handlers>
<remove name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" />
<remove name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" />
<remove name="ExtensionlessUrlHandler-Integrated-4.0" />
<add name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework\v4.0.30319\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness32" responseBufferLimit="0" />
<add name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework64\v4.0.30319\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness64" responseBufferLimit="0" />
<add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
<add name="Glimpse" path="glimpse.axd" verb="GET" type="Glimpse.AspNet.HttpHandler, Glimpse.AspNet" preCondition="integratedMode" />
</handlers>
<validation validateIntegratedModeConfiguration="false" />
</system.webServer>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-4.0.0.0" newVersion="4.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="EntityFramework" publicKeyToken="b77a5c561934e089" />
<bindingRedirect oldVersion="0.0.0.0-5.0.0.0" newVersion="5.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="0.0.0.0-1.5.2.14234" newVersion="1.5.2.14234" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="PostSharp" publicKeyToken="b13fd38b8f9c99d7" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-3.0.37.9" newVersion="3.0.37.9" />
</dependentAssembly>
</assemblyBinding>
</runtime>
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
</entityFramework>
<elmah xmlns="http://Elmah.Configuration">
<security allowRemoteAccess="true" />
<errorMail from="" to="" subject="" async="true" smtpPort="25" smtpServer="" userName="" password="" />
</elmah>
<location path="elmah.axd" inheritInChildApplications="false">
<system.web>
<httpHandlers>
<add verb="POST,GET,HEAD" path="elmah.axd" type="Elmah.ErrorLogPageFactory, Elmah" />
</httpHandlers>
</system.web>
<system.webServer>
<handlers>
<add name="ELMAH" verb="POST,GET,HEAD" path="elmah.axd" type="Elmah.ErrorLogPageFactory, Elmah" preCondition="integratedMode" />
</handlers>
</system.webServer>
</location>
<glimpse defaultRuntimePolicy="On" endpointBaseUri="~/Glimpse.axd">
<runtimePolicies>
<ignoredTypes>
<add type="Glimpse.AspNet.Policy.LocalPolicy, Glimpse.AspNet" />
</ignoredTypes>
</runtimePolicies>
</glimpse>
<glimpsePerformanceConfiguration enabled="true" maxResults="200" warningThresholdMs="2000" ignoreThresholdMs="-1" />
</configuration>
I have a web app which logs to the NLogViewer target (essentially fires off udp to a listener).
When Glimpse.Nlog is included in the web app, the process of attaching the Glimpse target to the NLog config is causing NLog NetworkTargets to be closed - and subsequent calls to them fail with a first time exception swallowed by NLog.
It appears the root cause is that calling
LogManager.Configuration = LogManager.Configuration; //Re initialize configuration.
as per the changes made to fix #5,
causes NLog to close existing network connections - and these turn out not to be reopened. When a network target is configured to reuse existing connections, this causes a NullRef exception every time trying to log to the network target - and it also causes other targets in the chain to fail.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.