How to Add User Tag
david
Posted on
Feb 21 2015
Hi,
I am using Log4Net + Raygun and XML to log message and send email. Here is the appender block in my XML:
In my start up code, I read a configuration setting key, basically to retrieve the name of the site (DEV/TEST/PROD) where the messages come from
if (ConfigurationManager.AppSettings["RaygunTags"] != null) { log4net.GlobalContext.Properties[RaygunAppender.PropertyKeys.Tags] = ConfigurationManager.AppSettings["RaygunTags"]; }
I am trying to add user tag, so that from the RayRun site, I can generate an error report based on user name.
How do I do it?
Thanks.
Jason Fauchelle
Raygun
Posted on
Feb 23 2015
Hi David,
With Raygun4Net, to send a list of tags, or a dictionary of data, you can do this either when manually sending an exception (use one of the Send method overloads that takes tags and custom data), OR attach an event handler to the SendingMessage event of a RaygunClient instance, and then set the e.Message.Details.Tags property there. The SendingMessage event gets called whenever Raygun4Net is about to serialize and send an exception.
To send user information, you can set the User (string) or UserInfo (RaygunIdentifierMessage) property on the RaygunClient instance you are using to send exceptions. e.g:
_raygunClient.UserInfo = new RaygunIdentifierMessage("jason@mindscape.com")
{
IsAnonymous = false,
FullName = "Jason Fauchelle",
FirstName = "Jason"
};
Once set, this information will be sent with all exceptions sent to Raygun.
More information about these features can be found in the documentation: https://raygun.io/docs/languages/net
Please let me know if you have further questions about this.
-Jason Fauchelle