How do I efficiently log errors in my R project.

I'm trying to understand the best way to log errors in an A project. I have a project where I'm ingesting data from an API and pushing a cloud database and I want to be able to create/monitor logs.

I found this tutorial that uses a combination of tryCatch() and futile.logger R package. In the tutorial, he creates a function that would generate an error and according to him, the error will generate a log file. However when I run the code, the error appears in my console but no log file is generated. See code below -


# Function to run
get_test_function <- function() {

# Trycatch configuration
options(keep.source = TRUE)
options("tryCatchLog.write.error.dump.file" = TRUE)

# Run function
  1. If this is an efficient way to log errors, what am I doing wrong that the log file is not generated.
  2. If there is a better way to achieve this, please do kindly share.

There are a number of logging packages for R. I've had good luck using the "loggit" library (inside a Shiny app). You can insert function calls to log errors inside the error processing function of a tryCatch call. When running the program locally, the log is written to a local file. Inside a Shiny app, the log is written to a file stored in some temp directory on the server (which will be erased when the app shuts down), so you need to give the user a download button to snag the log file.

This topic was automatically closed 42 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.