Exception Logging in ArcGIS Pro SDK

08-29-2019 11:41 AM
New Contributor II

I would like to know if anyone has worked on exception logging and place all the logs in a text file. 

I created a small add-in and would like to Log the details on each function so that it will be easy for me to track the logs and fix it.

0 Kudos
2 Replies
by Anonymous User
Not applicable

Hi Naresh,

I have uploaded the sample project for you. 


Try firstaddon-ArcgisPro project. 

It is using the nlog and you can configure where to log in nlog.config

If you have difficulty downloading from github, you can download from this attachment as well.

Let me know how's you go.

Occasional Contributor II

I use serilog and log to the folder where the add-in is installed.

         private void SetupLogging() {
            var addinFolder = GetAddinFolder();
            var logLocation = Path.Combine(addinFolder"{Date}-log.txt");

            var email = new EmailConnectionInfo {
                EmailSubject = "subject,
                FromEmail = "noreply@email",
                ToEmail = "you@email",
                MailServer = "smtp.server",
                Port = 25

            Log.Logger = new LoggerConfiguration()
                .WriteTo.Email(email, restrictedToMinimumLevel: LogEventLevel.Error)
                .WriteTo.RollingFile(logLocation, retainedFileCountLimit: 7)
        public string GetAddinFolder() {
            var myDocs = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
            var arcGisProLocation = Path.Combine(myDocs"ArcGIS""AddIns""ArcGISPro");

            var attribute = (GuidAttribute)Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(GuidAttribute),
            var proAddinFolder = $"{{{attribute.Value}}}";

            var addinFolder = Path.Combine(arcGisProLocationproAddinFolder);

            return addinFolder;

I also created a feedback button in my pro addin ribbon that grabs the most current file and attaches it with their feedback message.

The project I am working on is on github, GitHub - agrc/uic-addin: An ArcGIS Pro add-in to help manage, create, and validate the UIC GIS datab... 

0 Kudos