-
Notifications
You must be signed in to change notification settings - Fork 22
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
Implement logging #78
Comments
I looked around a bit and have some thoughts Application Insights The API itself is really simple and easy to use. They released a new version late last year, with You get nice way to browse the logs, aggregations on numeric data, etc. Seems nice and quite usable. Session/Request information
I didn't find anything about stuff like this that would be built into ASP.NET. Maybe there is some library that would do that? I think it's worth looking or even writing custom solution, e.g. based on It would be nice to have a helper class that would let you simply log an event without worrying about all that stuff. I mean you just call |
Application Insights looks great so far! It already helped us figure out the cause of an annoying bug -> #77 I'm familiar with log4net, but if there is a built-in way to send logs ( Do you propose that we should write to log on Yes, the helper class should take care of string formatting, adding a timestamp (unless we can skip this?), and as you said: |
Yes, Questions are:
I'm not sure if you get TimeStamp for free. I'll set a dummy ASP.NET WebPage on Azure and see how it looks like in practice - what you get for free, etc. |
I couldn't find RequestID in Some people on the internet suggest attaching a unique value to the thread. Under (probably correct) assumption that one thread handles one request only, this can be used to track the request. But it will fail in multithreaded code. Is that what you meant by initializing the RequestID? SessionID can be found in |
There is nothing like this on Why do I think it had value? You can correlate multiple logs into a single request and see which code was executed to handle it, what were the parameters, etc. Attaching value to thread would work as long you don't do multithreading stuff (you'd have to rewrite that value to all the threads you create). Definitely doable, but a bit problematic. |
You have very good points about I've found |
You can get current Do you have any resources about attaching information into the thread? |
either If you have any resources, please share :) |
Currently experimenting with logging at AmadeusW/SourceBrowser, on branch logging How is requestId stored? [ThreadStatic]
private static Guid _requestId; How logging is done? public static void Error(string message,
[System.Runtime.CompilerServices.CallerMemberName] string memberName = "",
[System.Runtime.CompilerServices.CallerFilePath] string sourceFilePath = "",
[System.Runtime.CompilerServices.CallerLineNumber] int sourceLineNumber = 0)
{
string requestId = RequestUtils.GetRequestId().ToString();
Trace.WriteLine(String.Format("[{0}, {1}] at {2}:{3} ({4}); {5}", DateTime.UtcNow, requestId, sourceFilePath, sourceLineNumber, memberName, message), CATEGORY_ERROR);
} addition to <system.diagnostics>
<trace autoflush="false" indentsize="4">
<listeners>
<add name="myListener" type="System.Diagnostics.TextWriterTraceListener" initializeData="TextWriterOutput.log" />
<remove name="Default" />
</listeners>
</trace>
</system.diagnostics> I've added ApplicationInsights to the project but haven't touched the |
I don't think the fact that you're running the app on VM matters. Did you try following steps from here? You should probably also Install Application Insights Status Monitor on your web server. About
|
Sometimes things go wrong and we need a good way to know what exactly happens.
The following links illustrate how we can get logging:
http://azure.microsoft.com/en-us/documentation/articles/web-sites-enable-diagnostic-log/
http://azure.microsoft.com/en-us/documentation/articles/cloud-services-dotnet-diagnostics/#virtual-machine
This is another way of getting more information (not necessarily logs) through Application Insights: http://msdn.microsoft.com/en-us/library/dn481100.aspx
The text was updated successfully, but these errors were encountered: