Ticket S33691
Visible to All Users
Duplicate

We have closed this ticket because another page addresses its subject:

Core - Provide an option to override the Tracing class behavior

Validation - Do not write validation exceptions to the application log file

created 15 years ago
Comments (3)
KK KK
Krzysztof Krzyzsłof 12 years ago

    I hold my breath… ;)

    M M
    Martin Praxmarer - DevExpress MVP 12 years ago

      Amazing how fast 4 years pass :)

      KK KK
      Krzysztof Krzyzsłof 12 years ago

        I've been keeping breathless for 3 months, but I give up.

        Answers approved by DevExpress Support

        created 9 years ago (modified 8 years ago)

          Other Answers

          created 12 years ago (modified 12 years ago)

          It would be satisfying if DevExpress only made the following methods virtual:
          - Tracing.LogError(Exception exception)
          - Tracing.LogError(string text, params object[] args)
          - Tracing.LogLoadedAssemblies()
          Then, the following class could be used:

          C#
          public class CustomTracing : Tracing { public static void InjectTracer() { FieldInfo field = typeof(Tracing).GetField("tracer", BindingFlags.Static | BindingFlags.NonPublic); field.SetValue(null, new CustomTracing()); } public override void LogError(Exception exception) { if (!(exception is ValidationException)) base.LogError(exception); } public override void LogError(string text, params object[] args) { if (!text.Contains(" Type: ValidationException")) { int ind = text.LastIndexOf("Loaded assemblies"); if (ind != -1) text = text.Substring(0, ind); base.LogError(text, args); } } public override void LogLoadedAssemblies() { /* base.LogLoadedAssemblies();*/ } }

          …and initialisation of the mechanism:

          C#
          public sealed partial class YourApplicationModule : ModuleBase { ... public override void Setup(XafApplication application) { CustomTracing.InjectTracer(); base.Setup(application); } }
            Show previous comments (7)
            Dennis Garavsky (DevExpress) 11 years ago

              @PHN:
              >>
              But on my side, only one application is running. I change log file name to another but no luck, the problem still there.
              <<
              This may also occur for a single application if the log file is locked. This behavior is not related to XAF, but rather to the standard .NET trace listeners mechanism, which actually prefixes a file name with a GUID.
              You are free to use any custom logging solutions here. To avoid collisions, remove the default trace listeners by clearing the Trace.Listeners collection.

                Thanks Dennis,
                As your's comment above, if use custom tracing, the application will generate multiple log files. This is not good for finding problems in log files.
                Do you have any solution for that?

                Dennis Garavsky (DevExpress) 11 years ago

                  @PHN:
                  It all looks like you did not close previously active trace listeners before injecting your custom Tracing class. Here are two ways of doing this:

                  C#
                  //foreach(System.Diagnostics.TraceListener l in System.Diagnostics.Trace.Listeners) { // l.Close(); //} //System.Diagnostics.Trace.Listeners.Clear(); Tracing.Close(true); CustomTracing.InjectTracer(); winApplication.Setup();

                  Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

                  Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.