locked
Wcf SVC Log Date Wise RRS feed

  • Question

  • Hi,

    I Want Log SVCLog Daily that is Date Wise Log Eg foo_12-12-2012.svclog .Please let me know how to go head on this issuse

    Thanks & Regards

    Sanathkumar


    SANATHKUMAR KSHIRASAGAR

    Wednesday, December 5, 2012 11:28 AM

Answers

  • Hi,

    You can specify the output file location by setting initializeData to the name of the file for that listener, something like:

    <system.diagnostics>
       <sources>
           <source name="UserTraceSource" switchValue="Warning, ActivityTracing" >
              <listeners>
                  <add name="xml"
                     type="System.Diagnostics.XmlWriterTraceListener"
                     initializeData="C:\logs\UserTraces.svclog" />
              </listeners>
           </source>
       </sources>
       <trace autoflush="true" /> 
    </system.diagnostics>

    If I am misunderstanding, please elaborate more clearly. Thanks.

    Best Regards.


    Haixia
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    • Marked as answer by Haixia_Xie Wednesday, December 19, 2012 5:57 AM
    Thursday, December 6, 2012 9:16 AM
  • AFIK there is no built in support inside WCF to create this file in date wise. The reason could be – As Tracing is an on-demand activity for a production debug purpose, enabling this for many days will impact performance on production.

    No worry you can achieve it using many ways.

    Option One: The feature you are looking is a part of EnterpriseLibrary.Logging.TraceListeners feature which provides Roll Interval Enumeration. You can plug this TraceListner with WCF listener through configuration as below: http://weblogs.asp.net/cibrax/archive/2007/06/18/integrating-the-wcf-trace-with-the-logging-application-block.aspx

    Option Two: Extend Existing XmlWriterTraceListener of WCF to write your own logic for rolling a new log file. There is a working example mentioned here: http://callicode.com/myBlogs/tabid/53/EntryId/45/Extending-WCF-tracing-to-support-trace-file-rotation.aspx

    Option Three: There is an open source initiative @ Codeplex. I cannot remember the name but few months ago I evaluated it.

    I think Option 2 will be a right solution for you.


    Lingaraj Mishra

    • Marked as answer by Haixia_Xie Wednesday, December 12, 2012 7:39 AM
    Friday, December 7, 2012 3:44 PM

All replies

  • Hi Sanathkumar,

    You can enable WCF tracing to outputs the traces and error events and use Service Trace Viewer Tool to analyze the diagnostic traces.

    Best Regards.


    Haixia
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Thursday, December 6, 2012 3:45 AM
  • Hi Haixia Xie - MSFT,

     I i can enable WCF tracing i need to know is there any way to store output  in file on daily basis of file name Changing 


    SANATHKUMAR KSHIRASAGAR

    Thursday, December 6, 2012 6:06 AM
  • Hi,

    You can specify the output file location by setting initializeData to the name of the file for that listener, something like:

    <system.diagnostics>
       <sources>
           <source name="UserTraceSource" switchValue="Warning, ActivityTracing" >
              <listeners>
                  <add name="xml"
                     type="System.Diagnostics.XmlWriterTraceListener"
                     initializeData="C:\logs\UserTraces.svclog" />
              </listeners>
           </source>
       </sources>
       <trace autoflush="true" /> 
    </system.diagnostics>

    If I am misunderstanding, please elaborate more clearly. Thanks.

    Best Regards.


    Haixia
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    • Marked as answer by Haixia_Xie Wednesday, December 19, 2012 5:57 AM
    Thursday, December 6, 2012 9:16 AM
  • Hi 

    YOu Are correct but as i want to Store the log file as below

    <system.diagnostics>
       <sources>
           <source name="UserTraceSource" switchValue="Warning, ActivityTracing" >
              <listeners>
                  <add name="xml"
                     type="System.Diagnostics.XmlWriterTraceListener"
                     initializeData="C:\logs\UserTraces{0:DD}-{0:MM}-{0:yyyy}.svclog" />
              </listeners>
           </source>
       </sources>
       <trace autoflush="true" /> 
    </system.diagnostics>


    SANATHKUMAR KSHIRASAGAR

    Friday, December 7, 2012 6:16 AM
  • AFIK there is no built in support inside WCF to create this file in date wise. The reason could be – As Tracing is an on-demand activity for a production debug purpose, enabling this for many days will impact performance on production.

    No worry you can achieve it using many ways.

    Option One: The feature you are looking is a part of EnterpriseLibrary.Logging.TraceListeners feature which provides Roll Interval Enumeration. You can plug this TraceListner with WCF listener through configuration as below: http://weblogs.asp.net/cibrax/archive/2007/06/18/integrating-the-wcf-trace-with-the-logging-application-block.aspx

    Option Two: Extend Existing XmlWriterTraceListener of WCF to write your own logic for rolling a new log file. There is a working example mentioned here: http://callicode.com/myBlogs/tabid/53/EntryId/45/Extending-WCF-tracing-to-support-trace-file-rotation.aspx

    Option Three: There is an open source initiative @ Codeplex. I cannot remember the name but few months ago I evaluated it.

    I think Option 2 will be a right solution for you.


    Lingaraj Mishra

    • Marked as answer by Haixia_Xie Wednesday, December 12, 2012 7:39 AM
    Friday, December 7, 2012 3:44 PM