I've been trying to work with ETW in .net 4.5.
I have a WCF Service and Console App, and I want which uses EventSource to write messages, however, I'm struggling to understand how to create my own ETW (EventSource and EventListener) for log to a file (rolling file).
Any suggestions?
In addition to magicandre1981's answer, you should add: -
TraceEventSession _session = new TraceEventSession(
"yourSessionName", #"C:\yourLogFile.etl")
{
CircularBufferMB = 100 //100mb rolling log file
};
_session.EnableProvider(TraceEventProviders.GetEventSourceGuidFromName(
"Samples-EventSourceDemos-EventLog"), TraceEventLevel.Always);
This can be in the same application as you are logging from (in process), or in a completely separate application (out of process).
Install the Nuget Package of Microsoft EventSource Library
Install-Package Microsoft.Diagnostics.Tracing.EventSource -Pre
and define the Events in a class which is derived from EventSource.
Now use the Semantic Logging Application Block from Enterprise Library to consume Events.
Here is a video how to use it:
Introducing Semantic Logging
http://channel9.msdn.com/posts/Introducing-Semantic-Logging
Related
I am using VS2017 in Mac( with latest packages added for Azure Service Bus), to pull a message from Service bus Queue in Azure. On execution of below code, getting the error
BadImageFormatException - could not resolve field token 0x0400089c
Its coming from CreateFromConnectionString and the stack points to MessageFactory.create call which happens under the hood, on our call to CreateFromConnectionString.
Got many pointers like x86 issue and all, but none were certain on what to look into. I was using Release x86, then tried Rel AnyCpu as well.
Does anyone faced this issue before or any pointers to resolve this.
string connectionString = "Endpoint=sb://spxxxx.servicebus.windows.net/;SharedAccessKeyName=Root**Key;SharedAccessKey=xxxx.......xxxxxxxx=";
string queueName = "spqueue";
QueueClient client = QueueClient.CreateFromConnectionString(connectionString, queueName);
Also did an trail by creating the MessageFactory in the program itself. Got same error at MessagingFactory.Create
Also connectionString and queue name are fine, as I am able to generate the Authorization token correctly using this code and postman connected to the Q using the same without any issues.
Thanks!
Let me know if any additional details needs to be added.
AFAIK, Visual Studio 2017 for Mac provides the ability for using Xamarin and .NET Core to build mobile,web, and cloud applications on macOS. Per my understanding,
the Microsoft Azure Service Bus 4.1.3 targets on the traditional .NET Framework, you could try to use the next generation Azure Service Bus .NET Standard client library Microsoft.Azure.ServiceBus 0.0.7-preview.
Currently the application, Logger writes to the console by using the AddConsole() method.
How can it be set to write to a file?
for example to the directory "c:\workspace\TestProject\Log.txt"
logger = new LoggerFactory()
.AddConsole()
.CreateLogger("Msg");
I guess, you are using Microsoft.Framework.Logging
But out-of-the-box implementations are provided for basic console logging and a few other targets, you’ll need a logging back-end like Serilog or NLog to gain the kind of functionality you're requesting.
I would recommend you to use NLog (just personal preference)
Install-Package NLog
then add to your code
loggerFactory.AddNLog(new global::NLog.LogFactory());
https://github.com/aspnet/Logging/tree/dev/samples/SampleApp
http://nlog-project.org/
I'm tracking metrics from WPF application. I have updated Application Insights DLLs from 0.17 to 1.1. This meant removing Old DLLs and adding the SDK via Nuget. Now i don't see my metrics/events in the portal. I see no activity in the debugger output window.
Activating DeveloperMode don't seem to do anything.
TelemetryConfiguration.Active.TelemetryChannel.DeveloperMode = true;
I can see that the AI DLLs are placed correctly in the output folder, and I get no error messages when sending events. But no data seems to come through any more.
I have tried to check traffic with fiddler. But no data seems to be sent. I have already tried to do what is suggested here:
https://azure.microsoft.com/en-us/documentation/articles/app-insights-troubleshoot-faq/#how-do-i-upgrade-from-older-sdk-versions
Any suggestions to what could be the problem?
Solution:
Make sure the ApplicationInsights.config properties is set to
"Always copy"
or
"Copy if newer"
Bonus:
How to configure 1.1
https://azure.microsoft.com/en-us/documentation/articles/app-insights-configuration-with-applicationinsights-config/
In the newer 1.1 SDK setting up should be simpler. You can simply new up a telemetryClient to send. You shouldn't need any additional config file or additional code.
tc = new TelemetryClient();
tc.InstrumentationKey = "GET YOUR KEY FROM THE PORTAL";
tc.TrackEvent("SampleEvent");
Some additional details about getting setup for a WPF app can be found here.
I'm currently implementing connection resiliency for a windows phone game following this documentation: Appwarp Connection Resiliency.
I can't seem to access the RecoverConnection API or any of the Connect Event Result Codes related to Connection Resiliency (SUCCESS_RECOVERED, CONNECTION_ERROR_RECOVERABLE, etc) in the ConnectionRequestListener in my project.
Looking at the AppWarp_WP7_SDK.dll in my project it doesnt seem to contain these API calls. I'm using the .dll downloaded from Appwarp Windows SDK. Anyone know has the .dll changed? Have they been removed from the latest version?
Cheers,
xDev
Please take our latest dll from below link
https://github.com/shephertz/AppWarp_WP7_SDK_DLL
We have also one sample game "Catapult War" in which we have implemented Connection Resiliency feature.Find it from below link
https://github.com/rahulpshephertz/CatapultWar
At the time of initialization don't forget to set recovery allowance.
WarpClient.setRecoveryAllowance(60);
It is possible to pass the system/environment information to the log4net log in my C# WinForms application?
It would be good to have details like what Windows version they are using, if any Service Packs are installed, what .Net they have installed etc.
I haven't used Log4Net for a long time, but can't you set this information to the global or thread context?
log4net.GlobalContext.Properties["WindowsVersion"] = windowsVersion;
Then you can output this information in your log file with the following pattern:
%property{WindowsVersion}
See http://logging.apache.org/log4net/release/manual/contexts.html for more information.