Task Category for custom ETW events showing as number instead of name in Event Viewer - etw

I am implementing logging in our application using ETW.
I used ecmangen.exe to create the manifest with a set of custom events, templates, tasks and keywords.
I used mc.exe to compile and generated corresponding C# class for use in my code.
I used this generated class in our code to emit events.
I imported the manifest via wevtutil and captured events via event trace session (Win2K8R2 - Performance - Data Collector Sets)
When I open the generated trace file via Event Viewer, I see the events I was expecting. But I found that the custom task categories and keywords are showing in their numeric form, instead of their names.
Should these values be translated? Or am I going about this the wrong way?

Related

How to log last changes in hybris when the new feed/ feeds updates come through

I'm aware that Hybris have savedvaluesmodel and savedvalueentrymodel to capture last changes of the data model and its attribute value whatever has changed recently, and it also maintains the history.
And this works only if we are modifying the data after login into Backoffice and this doesn't seem to work in case of feeds which comes via HotFolder. I'd like to know, is there any provision which comes with Hybris out of the box to capture the same information or changes that was done for a given data model through feed?
What I have observed based on OOTB code is ,this class DefaultItemModificationHistoryService is responsible for logging the changes (populate the values and saved the last changes into the saved values model table) that was done at the model level, and this is located inside the OOTB Backoffice extension and this extension is already extended by myprojectbakcoffice extension which further extends myprojectcore extension.
In order to capture the last changes done via feed we thought of handling that logic in an interceptor, however the above class isn't accessible in our myprojectcore extension as it's declared in Backoffice.
What are the other possible solutions that I can think of in order to implement this?
Found some article related to this in here.
Please advise.
You can use the hybris commerce audit framework to log all of the changes happening in the system.
The documentation here says, "Generic audit tracks every persistence action, including creation, modification, and deletion for specified types. The audit is stored as a change log that allows you to see how an item changed over time."
But this comes with a DB overhead. There are specific tables that gets heavily logged with the details of the changes.
These tables have a naming convention as <item_type>_sn.
E.g.: For Order item type, the audit table would be auto created as orders_sn
This is why it is always advisable to turn off the audit as applicable.

logstash - store content of fields in dynamic lists

Purpose: Track privileged user activity in Windows logs.
Logic:
If logon event contains token_elev %1937 or %1938 save the logon_id (hex value) to a dynamic priv_logons list.
For subsequent events, if the logon_id in the event matches one of the entries in priv_logons list, add a 'privileged' tag to the event.
When receiving a logoff event with one of the logon_ids saved in priv_logons list, remove it from the list.
Is this doable in LogStash? If yes, how?
Not with Logstash alone.
Logstash does not maintain internal states or data objects in between events, it is simply a parsing engine.
Logstash may help you create this kind of solution by doing the parsing work and then passing clean and sensible data to a program which performs the logic you are looking for.

Dynamics CRM FetchXML Report Event for Plugin to Fire On

Is there an event that a plugin can be registered on when a FetchXML (or even SQL) report is run?
RetrieveMultiple and Retrieve do not get fired!
public void Execute(IServiceProvider serviceProvider)
{
IPluginExecutionContext context = (IPluginExecutionContext)serviceProvider.GetService(typeof(IPluginExecutionContext));
// The FetchXML report does not fire the plugin on RetrieveMultiple
if (context.InputParameters["Query"] is FetchExpression)
{
IOrganizationServiceFactory factory = (IOrganizationServiceFactory)serviceProvider.GetService(typeof(IOrganizationServiceFactory));
IOrganizationService service = factory.CreateOrganizationService(context.UserId);
using (Context linq = new Context(service))
{
// Do the work.
}
}
}
I had the same issue and the solution is the following:
Reports do not trigger plugins. SQL reports bypass CRM completely, and
Fetch reports also bypass the plugin pipeline
More about this here: https://crmbusiness.wordpress.com/2014/11/25/fetchxml-reports-do-not-trigger-retrievemultiple-plugins-in-crm-2011/
I have had similar needs to perform an action when a report is run and the best [supported] way I could find to accomplish this by triggering the report to run via Javascript.
The rough process is this:
In the applicable entity, create ribbon button to launch the report via Javascript. (This post gives a how-to: Trigger a report from a ribbon button)
As part of Javascript function which runs the report, update a field (e.g. "new_ReportRunOn") in the respective record (A standard REST update operation would work here) prior to report run code. The idea here is simply running the report will always cause the "new_ReportRunOn" field to update first.
Have your plugin listen for changes on this field by applying a filter only the "new_ReportRunOn" field. (Alternately, you could just have your logic run in Javascript [as part step 2] instead of updating a field just to trigger a plugin.)
This isn't without drawbacks though:
You would need to "hide" the report in CRM Reports section so it is essentially only accessible via the entity form. It would still be visible in the Reports section if users chose to browse "All Reports" in the reports section. If a "savy" user launched the report this way then it would bypass your Javascript code which fires the plugin.
If the report can be run across multiple records (e.g. the user selects applicable records from the entity grid view) then additional considerations/coding would need to be done. It is possible to handle this case, but based on your question it doesn't appear this would be use case.
I've had process similar to this in place for a while on our 2013 install and it actually works quite well. It isn't ideal but gets the job done.

How can I have log4net help me log structured data inside %message?

We had our own custom logger in a C# program and now are trying to port to log4net.
In our app, there is further structure to what would normally go into %message. It may contain requestid, associated users, and other structure where requestid and user have internal significance to the program.
The hope is to ultimately be able to search on the fields inside %message, say requestid so we can collect all log entries with the same requestid for example.
Does log4net assist in anyway in creating own custom fields? The reason we ask is that currently the entire %message is logged as one string by default.
Any other suggestions on how to provide further formatting for %message? Otherwise we would have to pre-format %message inside our own code as, say, a CSV format
You can use event context to add additional structured data to a log entry:
http://www.beefycode.com/post/Log4Net-Tutorial-pt-6-Log-Event-Context.aspx
Depending on what kind of information you want to log you may need to create a wrapper that accepts additional parameters or else you have to write verbose code like this:
log4net.ThreadContext.Properties["myInformation"] = yourAdditionalInformation;
log.Info("info message");
Other information can be calculated and thus can be set once (for instance on application start up). Have a look at the calculated context properties in the above tutorial.

How to add a property an ASP.Net user control or web page and have that property read by Microsoft coded-ui testing? (CUIT)

I am using Microsoft coded-ui testing (CUIT) in VS 2010 Ultimate to test an ASP.Net 4.0 site.
I have the source code to the ASP.Net site, so I can modify it as needed.
I've got record/playback working.
I can write simple assert statements in the test methods to check properties of the UITestControl descendents (HTML links, tables, etc.) and compare them to expected values.
I want to add properties to user controls (ASCX's) and pages in my site, to pass back useful values to the testing code.
For example, I have a user control that implements a menu which displays different sets of menu items depending on the role of the current user.
Rather than having the test script click at the various menu items to check whether or not they're present, I want to add a property to the user control. This property will return info to the caller, listing the menus and menu items present.
I've found info on the Net on how to do this in WinForms, but this code relies on accessability, which I believe is only useful for CUIT with WinForms. Likewise, I've found info on how to do it with WPF/SL.
The answer may be related to getting the UITestControl.NativeElement property, then calling a method that overrides GetProperty(), but I haven't been able to get this approach to work.
Can anyone provide a short code sample showing how to add a property to an ASCX or ASPX page, where that property can be written in C# code-behind, and read by Microsoft Coded UI Testing (CUIT) code?
Thanks!
Adam Leffert
http://www.leffert.com
I haven't found an answer to this question, but I have written some code to solve the underlying problem.
I realized that adding properties to user controls would keep the validation data together with the control under test, but only for the case where the section of UI was implemented as a user control.
There are at least two other cases I need to cover:
1) Third-party controls added to the page, for example ASPxGridView, ASPxTreeView, etc.
2) Items that are not visible in the UI, for example the user profile data for the current user.
When you're running CUIT validation code with a Web app, the data you have available is DOM data, i.e. a tree that represents the contents of the Document Object Model of the contents of the browser window. There is no Request object, .Net Page object, etc. This DOM data is accessible through the UIMap object.
I don't want to wrap the third-party controls in user controls, because doing so would disturb the application under test, causing me to re-write the application code that touches properties and events of the grid, tree view, etc. Too intrusive for testing code.
So I created a code interface (ITestable) that contains a dictionary of string values, and a list of ITestable children.
In the LoadComplete event handler of the master page, I create an ITestable for the master page and fill the list with child ITestable objects for the child page, which can themselves contain lists of children.
I serialize this object into JSON, then store it in a hidden field on the master page.
I added the hidden field to the UIMap.
The test validation code deserializes the ITestable, then looks through it for values that need validation.
The controls create their own ITestable objects, so they can easily fill the objects with values that may be needed for validation, rather than forcing the test code to manipulate the UI trying to read validation values.
For example, a tree view could return its contents without the testing code having to click on each node and try to read the value displayed there. Additional properties (visible, enabled, etc.) can be stored in the values dictionary for each ITestable object.
CUIT has some very powerful features. I would very much appreciate it if Microsoft would document some best practices for solving these non-trivial validation problems. I've read through the Microsoft documentation but haven't found much on this topic for Web apps.

Resources