-
Notifications
You must be signed in to change notification settings - Fork 16
Learning to use #3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
As additional info, looking through the NuGet code base (of the nuget I want to include, not your nuget) I see one place, and one place only that Trace is used. A Tracing class has been created that puts a facade on the different levels of events, The rest of the code then calls like
|
Hi Keith, The author of this project has some other commitments but invited me to help keep the wheels turning here, which so far I've failed miserably to do :-) ... but I'm picking things up now. Do you still need help with this? I've added what information I have to the README, it'd be great to know if anything is missing. Regards, |
Example program: using Serilog;
using System;
using System.Diagnostics;
namespace Example.SerilogTrace
{
// PM> Install-Package SerilogTraceListener
// PM> Install-Package Serilog.Sinks.Literate
public class Program
{
static void Main(string[] args)
{
// Initialise serilog (can also be done via appSettings in config file)
Log.Logger = new LoggerConfiguration()
.WriteTo.LiterateConsole()
.CreateLogger();
// Set correlation id
Trace.CorrelationManager.ActivityId = Guid.NewGuid();
// Create a source
var source = new TraceSource("Example.Source.Name");
// Trace an event
source.TraceEvent(TraceEventType.Information, 1001, "level={0} os={1}", 5, Environment.OSVersion);
Console.ReadLine();
}
}
} With config file: <?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
</startup>
<system.diagnostics>
<sharedListeners>
<add name="serilog" type="SerilogTraceListener.SerilogTraceListener, SerilogTraceListener" />
</sharedListeners>
<sources>
<source name="Example.Source.Name" switchValue="All">
<listeners>
<clear/>
<add name="serilog"/>
</listeners>
</source>
</sources>
</system.diagnostics>
</configuration> |
Getting caught back up, and 2 clients later. I will play with this over the next 10 days and see how it goes. |
Hello, I tried the sample but it only output the string. It doesn't treat it as MessageTemplate. So it lost the most powerful feature of serilog which is structured log. see image below I tried |
Update README.md
Thanks for the library. Now, how do we properly use it? I've barely ever used trace and am wondering if it should be injected into the Trace.Listeners?
Scenario: A Nuget contains tracing to a file. I would like to capture that and send, via Serilog, to Seq, my file, etc. Or do I need access to the code (the nuget package) and override the trace there? Or something different?
The text was updated successfully, but these errors were encountered: