Suppressing Client Message Log |
The following code snippet can be used to suppress messages being sent to the client message log.
// Call ClientLog.SetShoulSuppressClientMessage which takes the message level, the message itself, and the exception // If true it suppresses the message // If false it logs the message public void OnApplicationLoaded(UrlParameter[] urlParameters) { ClientLog.SetShouldSuppressClientMessage((level, message, exception) => { if (level == MessageLogLevel.Warn) return true; if (message?.Contains("Hello") == true) return true; return false; }); } // Assuming there are 4 buttons on the screen the following will either log or supress based off the above function call // This message will not appear in the client log as it contains "hello" public void Button1_OnClick(object sender, EventArgs eventArgs) { Log.Info("Hello"); } // This message will appear in the client log public void Button2_OnClick(object sender, EventArgs eventArgs) { Log.Info("World"); } // This message will appear in the client log public void Button3_OnClick(object sender, EventArgs eventArgs) { Log.Error("Houston, we have a problem!"); } // This message will not appear in the client log as the log level is Warn public void Button4_OnClick(object sender, EventArgs eventArgs) { Log.Warn("Yield!"); }