Comments (4)
One quick workaround was to inherit the NLogTargetListener and add my own logic to bypass the verbosity of the text log:
public class NLogCustomTargetListener : NLogTargetListener, ILogListener { public new void OnBeginRequest(KissLog.Web.HttpRequest httpRequest, ILogger logger) { if (httpRequest.Url.PathAndQuery.IndexOf("/swagger/", StringComparison.InvariantCultureIgnoreCase) >= 0) { return; } base.OnBeginRequest(httpRequest, logger); } }
In the web interface everything works the same, as expected.
from kisslog.sdk.
If it works, keep it a while :)
I will update SDK to provide more flexibility for this scenario. I will keep you updated.
from kisslog.sdk.
Hi Robert,
The NLogTargetListener
is sending the logs to NLog as soon as they get executed in the code.
This implies that, by the time LogListenerParser.ShouldLog(FlushLogArgs args)
is evaluating the condition, the logs have already been saved to text files.
Below is the execution workflow:
Begin GET /swagger/ <---- start of the request
_logger.Debug("step 1"); <---- "step 1" is sent to NLog (text file)
_logger.Debug("step 2"); <---- "step 2" is sent to NLog (text file)
...
_logger.Debug("step n"); <---- "step n" is sent to NLog (text file)
<---- by this time, the log messages have already been sent to the NLog targets
END 200 OK GET /swagger/ <---- end of the request
<---- ShouldLog(FlushLogArgs args) is executed at this step
One possible solution would be to update the LogListenerParser
and provide callback for the BeginRequest event.
public class LogListenerParser
{
// will get executed just at the beginning of the request
// if return false, the listener will not listen for any logs for the current request
public virtual bool ShouldLog(BeginRequestArgs args)
{
if (args.Request.Url.LocalPath.Contains("/swagger/"))
return false;
return true;
}
public virtual bool ShouldLog(FlushLogArgs args, ILogListener logListener)
{
return true;
}
}
from kisslog.sdk.
Published KissLog 3.5.1 which fixes this issue.
Updated LogListenerParser
with one new method:
public class LogListenerParser
{
public virtual bool ShouldLog(BeginRequestArgs args, ILogListener logListener)
{
return true;
}
}
This method gets executed at the begging of the request.
If the result is false
, the Listener will stop logging the current request.
Begin GET /swagger/ <---- start of the request
<---- ShouldLog(BeginRequestArgs args) is executed
<---- if false, skip;
_logger.Debug("step 1"); <---- skipped
_logger.Debug("step 2"); <---- skipped
...
_logger.Debug("step n"); <---- skipped
END 200 OK GET /swagger/ <---- end of the request
from kisslog.sdk.
Related Issues (20)
- Using Kisslog in Custom DLL HOT 4
- Implement Compiler Services on the Log Method HOT 3
- Creating alerts for a group context HOT 1
- is out KissLog.net? HOT 2
- Dashboard does not list requests when the controller has the Authorize attribute. HOT 10
- "application/problem+json" Response Content-Type
- Friendly format *.xml files
- Allow anonymous access to KissLog-samples
- Replace Newtonsoft.Json with System.Text.Json HOT 1
- Alert Notification by Email HOT 9
- RequestLogsApiListener: create fallback event when REST fails
- Prevent Preview response body for large files
- RequestLogsApiListener: Ignore certificate errors HOT 1
- logger.SetHttpStatusCode() should work for Console apps (non-web) HOT 1
- MirrorStreamDecorator: Cannot access a closed Stream
- MachineName is null for ConsoleApps
- Response Json and search for a SearchKey HOT 3
- Logging same InnerException throws an error
- kisslog sdk error UnauthorizedAccessException HOT 4
- Logs not showing and some logs showing HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from kisslog.sdk.