Revelation: Why my diagnostic logging was not working using log4net TraceAppender

I thought I better share with people some information that I found which has shed some light on why I've had such a hard time getting native Azure diagnostic logging working.  Hopefully, if I hit enough key words here, someone will find this discussion
in the future and may save you some time and heart ache.
Our application is a legacy ASP.Net application which I am porting to Azure.  The application makes extensive use of log4net and I decided that I would use the log4net TraceAppender to forward the logs to the Azure diagnostic listener.  Within
my worker role, I was configuring my azure logs like so:
private static void ConfigureLogging() {
CrashDumps.EnableCollection(true);
var diagConfig = DiagnosticMonitor.GetDefaultInitialConfiguration();
var directories = diagConfig.Directories;
var infrastructureDiagnostics = diagConfig.DiagnosticInfrastructureLogs;
var applicationLogs = diagConfig.Logs;
var eventLogs = diagConfig.WindowsEventLog;
SetTransferPeriod(applicationLogs, 1);
SetTransferPeriod(directories, 1);
SetTransferPeriod(infrastructureDiagnostics, 1);
SetTransferPeriod(eventLogs, 1);
SetFilterLevel(applicationLogs, LogLevel.Information);
SetFilterLevel(eventLogs, LogLevel.Information);
SetFilterLevel(infrastructureDiagnostics, LogLevel.Warning);
DiagnosticMonitor.Start("DiagnosticsConnectionString", diagConfig);
Log4NetHelper.ConfigureLog4Net();
private static void SetFilterLevel(WindowsEventLogsBufferConfiguration eventLogs, LogLevel logLevel)
eventLogs.DataSources.Add( "Application!*" );
eventLogs.DataSources.Add( "System!*" );
eventLogs.ScheduledTransferLogLevelFilter = logLevel;
private static void SetFilterLevel(BasicLogsBufferConfiguration infrastructureDiagnostics, LogLevel logLevel)
infrastructureDiagnostics.ScheduledTransferLogLevelFilter = logLevel;
private static void SetTransferPeriod(DiagnosticDataBufferConfiguration directories, int minutes)
var period = TimeSpan.FromMinutes(minutes);
directories.ScheduledTransferPeriod = period;
Log4NetHelper.Configure uses the log4net programattic API to setup and configure a TraceAppender that captured all LogLevels (DEBUG or higher).  I also made sure that the follwing appeared in my Web.Config
<system.diagnostics>
<trace autoflush="false" indentsize="4">
<listeners>
<clear />
<add type="Microsoft.WindowsAzure.Diagnostics.DiagnosticMonitorTraceListener, Microsoft.WindowsAzure.Diagnostics, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" name="AzureDiagnostics">
<filter type="" />
</add>
</listeners>
</trace>
</system.diagnostics>
However, this never worked.  I saw a number of forum posts that suggested that the Azure filter level should be "Undefined" - namely that I should replace
SetFilterLevel(applicationLogs, LogLevel.Information);
with
SetFilterLevel(applicationLogs, LogLevel.Undefined);
I had set my filter level to Information, cos our app does so much Debug level logging, that I thought I'd save money in storage by really only capturing the INFO or higher messages.  But in the interest of getting the blasted thing to work, I set to
Undefined, and sure enough all the log message from all levels came through. Setting back to Information and NO messages come though.
I then noticed that when my logging was working (filter = Undefined) that ALL my log messages were in fact being logged at the Verbose level - even log4net calls to log.Error/log.Warn (exceptions messages being logged at Verbose is not a good sign!)
You have to realize, that my thought process was not structured at this point as I had no idea what was going on.  Until I found this article:
http://www.dotnetsolutions.co.uk/blog/archive/2010/02/22/windows-azure-diagnostics-%E2%80%93-why-the-trace-writeline-method-only-sends-verbose-messages/
While not related to log4net, it was an eye opener, and I used reflector to look at the TraceAppender, and I see they are using Trace.Write to write messages.  
In my mind, this explains why I was seeing the behaviour I was seeing:  AzureDiagnostic listener is converting all Trace.Write messags to Verbose (details in the above article) and log4net TraceAppender is converting all log messages to Trace.Write
messages.  Setting the filter to Information was thus stripping all the calls.
My solution is to inherit TraceAppender and change their impl of Append to use a switch on the LogLevel:
using System.Diagnostics;
using log4net.Appender;
using log4net.Core;
namespace XXX.Azure
public class AzureTraceAppender : TraceAppender
protected override void Append(LoggingEvent loggingEvent)
var level = loggingEvent.Level;
var message = RenderLoggingEvent(loggingEvent);
if (level >= Level.Error)
Trace.TraceError(message);
else if (level >= Level.Warn)
Trace.TraceWarning(message);
else if (level >= Level.Info)
Trace.TraceInformation(message);
else
Trace.Write(message);
if (ImmediateFlush)
Trace.Flush();
With log4net configured to use this appender, then log messages appearing in the WADLogsTable are all appearing at the correct (or nearest appropriate) level
YMMV
Pete

Thanks, that's extremely useful!
Using your appender, Verbose level messages still were not shown though. What did the trick was changing
Trace.Write(message);
to
Trace.WriteLine(message);

Similar Messages

  • Why GWt suggest box is not working in the latest versions of Firefox ? It was working only in Firefox 3 and not other versions. could you please assist in this regards.,

    Why GWt suggest box is not working in the latest versions of Firefox ?
    It was working only in Firefox 3 and not other versions. could you please assist in this regards.,

    jbren wrote:
    I repeatedly have problems with playback on my STB's. Go thru all the motions, inhouse agent, fix multi room dvr problems. Unplug unit, unplug dvr, etc. etc. etc.  The DVR'd show will play on the DVR but not on the STB's. What's up with that?
    Sorry to hear the auto fix suggested early did not fix your problem. So we can get more information from you, I have copied your post to our private support board. Please refer all correspondences to there from here on out. You can easily get to the private support one of two ways. In the email you signed up for the forums with, you will receive a link to click on. Make sure you are already signed into the forums before clicking on this link. Another way of getting there is by clicking on your username anywhere you see it in the forums. This brings you to your account profile. Scroll down to the section labeled "My Support Cases" . In there you will see the link to your case.
    Anthony_VZ
    **If someones post has helped you, please acknowledge their assistance by clicking the red thumbs up button to give them Kudos. If you are the original poster and any response gave you your answer, please mark the post that had the answer as the solution**
    Notice: Content posted by Verizon employees is meant to be informational and does not supersede or change the Verizon Forums User Guidelines or Terms or Service, or your Customer Agreement Terms and Conditions or plan

  • I do have wifi connection but no internet, how is this possible? I logged in to the internet at my friends place and when I got home my own internet was not working anymore

    I do have wifi connection but no internet, how is this possible? I logged in to the internet at my friends place and when I got home my own internet was not working anymore

    This is possible to be connected to WiFi but not internet.
    You connect to your modem/router via WiFi and whether it is connected to the internet or configured properly to route the internet to WiFi devices is a different story.
    Now if you've already reset your WiFi (try disabling and enabling) and perhaps even restarting your MBP
    Then make sure that your modem/router is connected to the internet.
    You can try any other device, lights on the modem/router or use Eth cable to test.
    Report back your findings.

  • Why in my iphone5 iTunes Store was not working?

    In my iphone my iTunes Store was not working. When I want to open that apps in my iphone that was open but only iTunes U and podcast display another thing not working how can I solve this problem?

    Hi there Raazaan,
    You may want to try force closing all open apps and resetting the device as an initial troubleshooting step. Take a look at the articles below for more information.
    iOS: Force an app to close
    http://support.apple.com/kb/ht5137
    iPhone, iPad, iPod touch: Turning off and on (restarting) and resetting
    http://support.apple.com/kb/ht1430
    -Griff W.

  • Why is exporting to PDF not working?

    Why is exporting to PDF not working?

    Dear Claudio,
    I know it wasn't much to go on but I got your attention!
    I work for a charity and use a program called "Donor Perfect".
    It has a feature that when you generate a report it gives you the option to export to MSWord, Excel, and PDF.
    Below is the step by step description of what happens.
     After log on ......
         1. Click on Reports
         2. Listings
         3. Report Category(any)
         4. Select Record type(any)
         5. Select report options (any selection filter that fits or Build a filter) and sort order(any)
         6. Enter title (accordingly)
         7. Click on Preview
         8. When next screen opens with report visible - in "Report Print preview" line above report choose PDF icon
         9. Export to PDF window opens
         10. click on Page range-ALL
         11. What to print-All pages in Range
         12. Save as C:\DPW32\dpsumm.pdf
         13. collate
         14. number of copies(1)
         15. Click on "Screen" 
         16. Click on "Display Conversion Status"
         17. Then "OK"
         18. After conversion status reaches "100%" nothing happens -screen does not change!
    Then I minimize DP screen and I go to Start menu 
         1. Click on Start
         2. Then "My Computer"
         3. Local Disk "C"
         4. Dpw32
         5. Look for "dpsumm" file with today's date
         6. Size of file says 0 KB and that's it!!!!
    In previous versions of DP (8 and 9)
    the PDF would open on the screen as soon as the Step 18 was finished, then I could save it with an identifying name to a different folder and use it as an attachment that a Donor could receive by e-mail.
    I hope I can get back to that because now I have to convert to "Word" (Which takes a long time)then from that I have to create PDF from Acrobat. too many steps ..... if I have 20-30 reports it's too cumbersome.
    Waiting for your suggestions,

  • My IPad cannot download live Tv from skygo. I have no problem with my lap top so I assume the broad band is okay. Can anybody suggest why the live streaming will not work on my iPad one.

    My IPad cannot download live Tv from skygo. I have no problem with my lap top so I assume the broad band is okay. Can anybody suggest why the live streaming will not work on my iPad .

    Are you using the Sky Go app to try and watch it ? If so are you logged in with your Sky account ?
    If you are using the app then you could try closing the app completely and see if it works when you re-open it : from the home screen (i.e. not with Sky Go 'open' on-screen) double-click the home button to bring up the taskbar, then press and hold any of the apps on the taskbar for a couple of seconds or so until they start shaking, then press the '-' in the top left of the Sky Go app to close it, and touch any part of the screen above the taskbar so as to stop the shaking and close the taskbar.
    If that doesn't work then you could try a reset : press and hold both the sleep and home buttons for about 10 to 15 seconds (ignore the red slider), after which the Apple logo should appear - you won't lose any content, it's the iPad equivalent of a reboot.

  • Why does my card reader not work on my iPad since upgrade?

    I use my iPad mini to download photos from my camera when I'm on the road. In the summer I bought the "3 in 1 Card Reader Adapter Cable Camera Connection Kit, 3 Port Card Reader for iPad 4 and iPad Mini by Eurekka" and it worked wonderfully. I was able to download photos (jpg and RAW) directly to the iPad and off the camera, and once home it was a flawless upload to my iMac.
    However, once I upgraded to iOS 7 last week I get a message saying the device is not supported. What gives? Will this be fixed or will Apple products only accept Apple accessories from now on?

    No but I was just trying to find a way in to your help desk. I didn't find 
    your web page very helpful in this regard.
    Douglas Whiteley
    In a message dated 10/05/2012 20:43:50 GMT Daylight Time, [email protected] 
    writes:
    Re:  why does my adobe reader not work
    created by Claudio  González
    (http://forums.adobe.com/people/Claudio+González)  in Adobe Reader - View the full  discussion
    (http://forums.adobe.com/message/4395059#4395059)

  • Iphone 4s ios7 music player was not working, here's a bug fix.

    hi there
    i had a problem with my wifes iphone 4s, today morning while travelling to work i changed a setting on repeat option and changed it to repeat artist, it was fine until when i finish my work and on my way back i found songs are not playing anymore, lots of stop signs next to my song list, play/pause button not working, album arkwork keep moving from one to another on its own, so after i reach home i try to do some research on Apple support communities, try to soft reset my phone closing all the apps on background didnt work, also note that control centre music player was not working as well. none of the solutions worked. after trying for two hours i found out that the trouble is in repeat options , so i changed it from repeat artist to repeat off. and the music start playing as usual, but i still have those stop buttons next to the songs i tried to play earlier. At least it fixed temporarily. please also note that in the meantime i tried to sync my phone with the pc and suddenly its start syncing all the songs again assuming there were no songs on my iphone.  so guys i think soft reset might not help all the time but try to remember what settings you changed recently and change it back to the original option, not sure ,but it might help. hopin this will help some of you out there. and i already feed it back to Apple, so hopefully they will fix it soon.

    Not sure why you are having problems. I have had no problems with my 4S playing music after the update. Hopefully you will get it worked out.

  • Why is my Apple ID not working in iTunes and App Store on my iPhone? Nothing happens if I click buy for apps or music. If I then go to settings/iTunes App Store my Apple ID is not there. If I then enter ID and password it does not save or link to account?

    Why is my Apple ID not working in iTunes or App Store on my iPhone? When I try to buy apps or music it asks for Apple ID so I enter my info and nothing happens. When I go to settings/iTunes App Store my Apple ID is not there. When I enter my ID and password it does not save or link to account. I do not have this problem with iPad ID is stored and can be used in App Store and iTunes. I have just upgraded to 5c and it's still a problem.

    LeesaHeeley wrote:
    When I go to settings/iTunes App Store my Apple ID is not there. When I enter my ID and password it does not save or link to account.
    When fist setting up your new iphone you will be asked to log in with an apple id and password. If this did not happen you can then do as you suggested going to settings to itunes and app store and add your apple id login. This apple id login must have already been created for the iphone to accept it. If this apple id is already created but is not being accepted by your iphone you then should shut down your iphone and restart the device.
    Good luck.

  • Why is my BDC_CURSOR command not working to position the cursor?

    Why is my BDC_CURSOR command not working to position the cursor?  Here are the details regarding my issue.
    I am writing a BDC to mass delete routing material assignments using transaction CA02.  I am OK to navigate through the initial screen to go to the Header screen and from here I am OK to navigate to the Material Assignments screen.  But once here, I cannot get the BDC_CURSOR command to take me into the list.  Here are the commands I am using.  Please let me know what I may try differently.
    CA02 Material Assignment - Set position  <-- this resets list of materials to correct position
      PERFORM bdc_dynpro      USING 'SAPLCZDI'   '1010'.
      PERFORM bdc_field       USING 'BDC_CURSOR'  'RC27X-ENTRY_ACT'.
      PERFORM bdc_field       USING 'BDC_OKCODE'   '=ENT1'.
      PERFORM bdc_field       USING 'RC27X-ENTRY_ACT'  c_position.
    CA02 Material Assignment - Delete
      PERFORM bdc_dynpro      USING 'SAPLCZDI'   '1010'.
      PERFORM bdc_field       USING 'BDC_CURSOR'  'MAPL-MATNR(01)'.    <-- this is not working to set the cursor into the list
      PERFORM bdc_field       USING 'BDC_OKCODE'  '=LOE'.             " trash can
      PERFORM bdc_field       USING 'RC27X-ENTRY_ACT'  c_position.
    CA02 Material Assignment - Green Check OK
      PERFORM bdc_dynpro      USING 'SAPLCZDI'   '1010'.
      PERFORM bdc_field       USING 'BDC_CURSOR'  'RC27X-ENTRY_ACT'.
      PERFORM bdc_field       USING 'BDC_OKCODE'   '=BACK'.            " check mark
      PERFORM bdc_field       USING 'RC27X-ENTRY_ACT'  c_position.

    Thank you for your reply.
    I had used SM35 to record.  However, I was not aware of the "create program" feature.  I had commented out a section from my previous post which I have now added back (latest code below).  But it still did not resolve the issue.
    When I execute with dismode = 'N', I get back error message "No batch input data for screen SAPLCZDI 1010".
    When I execute with dismode = 'E' (only show dynpros when error), it stops at the material selection screen without placing my cursor in the list.  I can then MANUALLY click to set the cursor position in the list, MANUALLY click the trashcan, it then uses my BDC command to respond to the popup asking "Do you want to delete", still leaving me at the material selection screen.  I can then MANUALLY click the green check (or enter), then it continues with the BDC to go back to the previous screen, and saves.  But it still will not place my cursor in the material selection list (SAPLCZDI screen 1010).
    Here is code used.  It is the second section of code labeled "CA02 Material Assignment - Delete" that is not working.
    CA02 Material Assignment - Set position
    this code functions to position the desired material to first in screen list
      PERFORM bdc_dynpro      USING 'SAPLCZDI' '1010'.
      PERFORM bdc_field       USING 'BDC_CURSOR'
                                    'RC27X-ENTRY_ACT'.
      PERFORM bdc_field       USING 'BDC_OKCODE'
                                    '=ENT1'.
      PERFORM bdc_field       USING 'RC27X-ENTRY_ACT'
                                     c_position.
    CA02 Material Assignment - Delete
      PERFORM bdc_dynpro      USING 'SAPLCZDI' '1010'.
      PERFORM bdc_field       USING 'BDC_CURSOR' 
                                    'MAPL-MATNR(01)'.
      PERFORM bdc_field       USING 'BDC_OKCODE'
                                    '=LOE'.             " trash can
      PERFORM bdc_field       USING 'RC27X-ENTRY_ACT'
                                     c_position.
    Acknowledge Pop-Up Screen
      PERFORM bdc_dynpro      USING 'SAPLSPO1' '0100'.
      PERFORM bdc_field       USING 'BDC_OKCODE'
                                    '=YES'.
    CA02 Material Assignment - Green Check OK
      PERFORM bdc_dynpro      USING 'SAPLCZDI' '1010'.
      PERFORM bdc_field       USING 'BDC_CURSOR'
                                    'RC27X-ENTRY_ACT'.
      PERFORM bdc_field       USING 'BDC_OKCODE'
                                    '=BACK'.            " check mark
      PERFORM bdc_field       USING 'RC27X-ENTRY_ACT'
                                     c_position.

  • Why does the sync button not work in itunes when my ipod touch is connected

    why does the sync button not work in itunes when my ipod touch is connected?

    It's working for me in Acrobat XI:
    I'd try logging into Acrobat.com from your browser, and log in with your Adobe ID. There may be a problem there:
    workspaces.acrobat.com

  • Why does addChild(new Shape()) not work?

    I would like to know why the following code does not work:
    <mx:Application>
    private function doShape():void {
    var aShape:Shape = new Shape();
    this.addChild(aShape);
    <mx:Button click="doShape()" />
    </mx:Application>
    according to the docs, addChild() takes a DisplayObject as a
    parameter. Shape is a DisplayObject. However, I get an error
    (#1034) that Shape can't be converted to mx.core.IUIComponent
    I don't understand what the problem is...

    inlineblue -
    Thanks for the advice...
    I was actually converting code over from Flex 1.5 where there
    is a pretty big difference between calling a beginFill()/lineTo()
    method on a UIComponent and attaching a whole new
    Container/MovieClip. In Flex 1.5 the application was so slow I
    trimmed out every container/MovieClip I could.
    If it's not such an issue in Flex 2.0 then I will go with the
    easier to read addChild(new Box()) method.
    Flex harUI - I assume that you mean if I create a new
    UIComponent and then add a Shape for color, I am essentially doing
    the same thing that normal containers like Box (a UIComponent) do
    with their chrome instance (a Shape?).

  • Reactive subscription was not working

    yesterday my reactivate of subscription was not working. and once I subscribe another one month call, the previous 3 month subscription is activated. which is rubbish. why there is no control to recurring subscription by manual. because this results in over spending to subscribe skype rubbish service since microsoft took over. the website is very slow. and user interface is owful!

    Hi,
    It is because your subscription does not cover calls to India.
    You can call following destinations:
    Argentina
    Australia
    Austria
    Belgium
    Canada - (incl. mobiles)
    Chile
    Croatia
    Czech Republic
    Denmark
    Estonia
    Finland
    France
    Germany
    Greece
    Guam
    Hong Kong SAR - (incl. mobiles)
    Hungary
    Ireland, Republic of
    Israel
    Italy
    Japan
    Korea
    Luxembourg
    Malaysia
    Netherlands
    New Zealand
    Norway
    Poland
    Portugal
    Puerto Rico
    Russia - St Petersburg
    Russia - Moscow
    Singapore - (incl. mobiles)
    Slovakia
    Spain
    Sweden
    Switzerland
    Taiwan
    Thailand - (incl. mobiles)
    United Kingdom
    United States - (incl. mobiles)
    Venezuela
    I hope it helps!
    If my answer helped to fix your issue, mark it as a Solution to help others.
    Thank You!
    Please send private messages only upon request.

  • Has anyone been able to contact Adobe to learn why their Flash Player does not work on Mac OS 10.6.8, no matter how many updates you install?  This seems like a big error by Adobe.

    I have thee Mac computers with Mac OS 10.6.8, one of which is a Mac Pro.  No matter how many updates I install from Adobe, their Flash Player does not work on any of these 3 computers.  I don't know how to contact Adobe Systems about this problem, but I think it is their responsibility to make sure that their so-called "universal" software works proplerly on a relatively recent operating system like OS 10.6.8 that is still in widespread use.  When you install the updates, nothing happens -- not even an error message.  What is the point of a universal player that is not universal?  It works fine on my MacBook Pro with OS 9 Mavericks, but it does not work at all -- indeed, has never worked -- on my 3 Macs with OS 10.6.8.  Has anyone contacted Adobe Systems to find out why the Flash Player does not work with OS 10.6.8 and what they plan to do about it?

    Where are you getting Flash from?
    Get the appropriate dmg installer here and then run it.
    http://www.adobe.com/products/flashplayer/distribution3.html
    If it still won't install, do these two things: First uninstall any Flash by going into the second level Hard Drive Library>Internet Plug-ins, and trash the Flash Player.plugin and flashplayer.xpt. Then boot into Safe Boot, Shift at the startup chime (give it much longer than a usual boot) and run the installer while booted in Safe Boot.

  • Why is my apple id not working

    I wonder why my apple id is not working please help me out FAST or ASAP

    How about some more information. Any error messages? What happens when you try to make a purchase or download an app?

Maybe you are looking for

  • Printer 3510 not working witn windows 8.1 goes to print to file not printing

    IN installed the new driver from the hp website which is supposed to fix the print  problems since  the upgrade to windows 8.1. Now when I  tell the computer to print, it looks like it will print, but it goes to print to file and tries to save the do

  • ITunes wont open, won't uninstall

    I need to update my iPhone but iTunes will not open. I have tried re-installing it, uninstalling it, downloading again. When I click on iTunes icon, it says it's not installed. (even though it is in all my program lists) I get this message when I try

  • Bapi to Create/Update/Delete/Block G/L Accounts Centrally

    Hello experts, I'm searching for a BAPI to achieve some functionalities already done throw transaction FS00. After uploading account data from an input file I should: - Create G/L accounts - Update G/L accounts - Mark for deletion G/L accounts - Bloc

  • Dodgy download messing up mac software

    Hope you can help me. I have followed the instructions on a clip on youtube, http://www.youtube.com/watch?v=cocU_Mapgfg and it has - disabled spotlight, when I hover over writing it disappears and also the icons on finder and safari are no longer the

  • Sending to the internet redundancy..Is this possible

    Can anyone tell me how I can accomplish redundancy in mail transport to the internet Here is my setup Site A is production and holds all mailboxes Site B is our failover site In both site A and site B we have an ex2010 server that sends to the intern