Search code examples
rloggingshinyshiny-server

Print information into shiny-server log


Is there a way to include/print information into a shiny-server log file?

I am working with a shiny app which includes an user login and if my app crashes I would like to know what user caused this crash.

I tried to include this into my server.R:

#PRINT FOR LOG FILE------------
cat(paste0("Username: ",userdata$name, "\n"))
cat(paste0("Datum: ",Sys.time(), "\n"))

But it doesn't work. Any ideas?


Solution

  • Try this, assuming you're using my answer here for the password

      observe({
        if (USER$Logged == FALSE) {
    
          output$page <- renderUI({
            div(class="outer",do.call(bootstrapPage,c("",ui1())))
          })
        }
        if (USER$Logged == TRUE) {
          output$page <- renderUI({
            div(class="outer",do.call(navbarPage,c(inverse=TRUE,title = "Contratulations you got in!",ui2())))
          })
          cat(paste0("Username: ",input$userName, "\n"))
          cat(paste0("Datum: ",Sys.time(), "\n"))
          print(ui)
        }
      })